aboutsummaryrefslogtreecommitdiff
path: root/lldb
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2020-07-26 19:36:28 +0000
committerDimitry Andric <dim@FreeBSD.org>2020-07-26 19:36:28 +0000
commitcfca06d7963fa0909f90483b42a6d7d194d01e08 (patch)
tree209fb2a2d68f8f277793fc8df46c753d31bc853b /lldb
parent706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff)
downloadsrc-cfca06d7963fa0909f90483b42a6d7d194d01e08.tar.gz
src-cfca06d7963fa0909f90483b42a6d7d194d01e08.zip
Vendor import of llvm-project master 2e10b7a39b9, the last commit beforevendor/llvm-project/llvmorg-11-init-20887-g2e10b7a39b9vendor/llvm-project/master
the llvmorg-12-init tag, from which release/11.x was branched.
Notes
Notes: svn path=/vendor/llvm-project/master/; revision=363578 svn path=/vendor/llvm-project/llvmorg-11-init-20887-g2e10b7a39b9/; revision=363579; tag=vendor/llvm-project/llvmorg-11-init-20887-g2e10b7a39b9
Diffstat (limited to 'lldb')
-rw-r--r--lldb/bindings/headers.swig79
-rw-r--r--lldb/bindings/interface/SBAddress.i192
-rw-r--r--lldb/bindings/interface/SBAttachInfo.i115
-rw-r--r--lldb/bindings/interface/SBBlock.i163
-rw-r--r--lldb/bindings/interface/SBBreakpoint.i337
-rw-r--r--lldb/bindings/interface/SBBreakpointLocation.i141
-rw-r--r--lldb/bindings/interface/SBBreakpointName.i115
-rw-r--r--lldb/bindings/interface/SBBroadcaster.i69
-rw-r--r--lldb/bindings/interface/SBCommandInterpreter.i171
-rw-r--r--lldb/bindings/interface/SBCommandInterpreterRunOptions.i75
-rw-r--r--lldb/bindings/interface/SBCommandReturnObject.i127
-rw-r--r--lldb/bindings/interface/SBCommunication.i83
-rw-r--r--lldb/bindings/interface/SBCompileUnit.i138
-rw-r--r--lldb/bindings/interface/SBData.i297
-rw-r--r--lldb/bindings/interface/SBDebugger.i535
-rw-r--r--lldb/bindings/interface/SBDeclaration.i67
-rw-r--r--lldb/bindings/interface/SBEnvironment.i48
-rw-r--r--lldb/bindings/interface/SBError.i122
-rw-r--r--lldb/bindings/interface/SBEvent.i153
-rw-r--r--lldb/bindings/interface/SBExecutionContext.i51
-rw-r--r--lldb/bindings/interface/SBExpressionOptions.i166
-rw-r--r--lldb/bindings/interface/SBFile.i101
-rw-r--r--lldb/bindings/interface/SBFileSpec.i107
-rw-r--r--lldb/bindings/interface/SBFileSpecList.i44
-rw-r--r--lldb/bindings/interface/SBFrame.i364
-rw-r--r--lldb/bindings/interface/SBFunction.i134
-rw-r--r--lldb/bindings/interface/SBHostOS.i49
-rw-r--r--lldb/bindings/interface/SBInstruction.i104
-rw-r--r--lldb/bindings/interface/SBInstructionList.i107
-rw-r--r--lldb/bindings/interface/SBLanguageRuntime.i21
-rw-r--r--lldb/bindings/interface/SBLaunchInfo.i137
-rw-r--r--lldb/bindings/interface/SBLineEntry.i100
-rw-r--r--lldb/bindings/interface/SBListener.i100
-rw-r--r--lldb/bindings/interface/SBMemoryRegionInfo.i61
-rw-r--r--lldb/bindings/interface/SBMemoryRegionInfoList.i37
-rw-r--r--lldb/bindings/interface/SBModule.i563
-rw-r--r--lldb/bindings/interface/SBModuleSpec.i134
-rw-r--r--lldb/bindings/interface/SBPlatform.i202
-rw-r--r--lldb/bindings/interface/SBProcess.i510
-rw-r--r--lldb/bindings/interface/SBProcessInfo.i67
-rw-r--r--lldb/bindings/interface/SBQueue.i74
-rw-r--r--lldb/bindings/interface/SBQueueItem.i47
-rw-r--r--lldb/bindings/interface/SBReproducer.i18
-rw-r--r--lldb/bindings/interface/SBSection.i149
-rw-r--r--lldb/bindings/interface/SBSourceManager.i59
-rw-r--r--lldb/bindings/interface/SBStream.i96
-rw-r--r--lldb/bindings/interface/SBStringList.i57
-rw-r--r--lldb/bindings/interface/SBStructuredData.i63
-rw-r--r--lldb/bindings/interface/SBSymbol.i96
-rw-r--r--lldb/bindings/interface/SBSymbolContext.i99
-rw-r--r--lldb/bindings/interface/SBSymbolContextList.i139
-rw-r--r--lldb/bindings/interface/SBTarget.i1073
-rw-r--r--lldb/bindings/interface/SBThread.i461
-rw-r--r--lldb/bindings/interface/SBThreadCollection.i39
-rw-r--r--lldb/bindings/interface/SBThreadPlan.i137
-rw-r--r--lldb/bindings/interface/SBTrace.i35
-rw-r--r--lldb/bindings/interface/SBTraceOptions.i39
-rw-r--r--lldb/bindings/interface/SBType.i487
-rw-r--r--lldb/bindings/interface/SBTypeCategory.i225
-rw-r--r--lldb/bindings/interface/SBTypeEnumMember.i107
-rw-r--r--lldb/bindings/interface/SBTypeFilter.i75
-rw-r--r--lldb/bindings/interface/SBTypeFormat.i77
-rw-r--r--lldb/bindings/interface/SBTypeNameSpecifier.i69
-rw-r--r--lldb/bindings/interface/SBTypeSummary.i119
-rw-r--r--lldb/bindings/interface/SBTypeSynthetic.i78
-rw-r--r--lldb/bindings/interface/SBUnixSignals.i76
-rw-r--r--lldb/bindings/interface/SBValue.i598
-rw-r--r--lldb/bindings/interface/SBValueList.i172
-rw-r--r--lldb/bindings/interface/SBVariablesOptions.i68
-rw-r--r--lldb/bindings/interface/SBWatchpoint.i96
-rw-r--r--lldb/bindings/interfaces.swig85
-rw-r--r--lldb/bindings/lua.swig21
-rw-r--r--lldb/bindings/lua/lua-typemaps.swig1
-rw-r--r--lldb/bindings/macros.swig33
-rw-r--r--lldb/bindings/python.swig145
-rw-r--r--lldb/bindings/python/createPythonInit.py17
-rw-r--r--lldb/bindings/python/python-extensions.swig592
-rw-r--r--lldb/bindings/python/python-swigsafecast.swig154
-rw-r--r--lldb/bindings/python/python-typemaps.swig532
-rw-r--r--lldb/bindings/python/python-wrapper.swig1067
-rw-r--r--lldb/docs/man/lldb.rst22
-rw-r--r--lldb/include/lldb/API/LLDB.h7
-rw-r--r--lldb/include/lldb/API/SBAddress.h6
-rw-r--r--lldb/include/lldb/API/SBAttachInfo.h6
-rw-r--r--lldb/include/lldb/API/SBBlock.h6
-rw-r--r--lldb/include/lldb/API/SBBreakpoint.h8
-rw-r--r--lldb/include/lldb/API/SBBreakpointLocation.h6
-rw-r--r--lldb/include/lldb/API/SBBreakpointName.h6
-rw-r--r--lldb/include/lldb/API/SBBroadcaster.h6
-rw-r--r--lldb/include/lldb/API/SBCommandInterpreter.h200
-rw-r--r--lldb/include/lldb/API/SBCommandInterpreterRunOptions.h102
-rw-r--r--lldb/include/lldb/API/SBCommandReturnObject.h6
-rw-r--r--lldb/include/lldb/API/SBCommunication.h9
-rw-r--r--lldb/include/lldb/API/SBCompileUnit.h6
-rw-r--r--lldb/include/lldb/API/SBData.h6
-rw-r--r--lldb/include/lldb/API/SBDebugger.h47
-rw-r--r--lldb/include/lldb/API/SBDeclaration.h6
-rw-r--r--lldb/include/lldb/API/SBDefines.h9
-rw-r--r--lldb/include/lldb/API/SBEnvironment.h137
-rw-r--r--lldb/include/lldb/API/SBError.h6
-rw-r--r--lldb/include/lldb/API/SBEvent.h6
-rw-r--r--lldb/include/lldb/API/SBExecutionContext.h6
-rw-r--r--lldb/include/lldb/API/SBExpressionOptions.h10
-rw-r--r--lldb/include/lldb/API/SBFile.h9
-rw-r--r--lldb/include/lldb/API/SBFileSpec.h6
-rw-r--r--lldb/include/lldb/API/SBFileSpecList.h6
-rw-r--r--lldb/include/lldb/API/SBFrame.h6
-rw-r--r--lldb/include/lldb/API/SBFunction.h6
-rw-r--r--lldb/include/lldb/API/SBHostOS.h6
-rw-r--r--lldb/include/lldb/API/SBInstruction.h6
-rw-r--r--lldb/include/lldb/API/SBInstructionList.h6
-rw-r--r--lldb/include/lldb/API/SBLanguageRuntime.h6
-rw-r--r--lldb/include/lldb/API/SBLaunchInfo.h43
-rw-r--r--lldb/include/lldb/API/SBLineEntry.h6
-rw-r--r--lldb/include/lldb/API/SBListener.h6
-rw-r--r--lldb/include/lldb/API/SBMemoryRegionInfo.h6
-rw-r--r--lldb/include/lldb/API/SBMemoryRegionInfoList.h6
-rw-r--r--lldb/include/lldb/API/SBModule.h9
-rw-r--r--lldb/include/lldb/API/SBModuleSpec.h6
-rw-r--r--lldb/include/lldb/API/SBPlatform.h24
-rw-r--r--lldb/include/lldb/API/SBProcess.h8
-rw-r--r--lldb/include/lldb/API/SBProcessInfo.h6
-rw-r--r--lldb/include/lldb/API/SBQueue.h6
-rw-r--r--lldb/include/lldb/API/SBQueueItem.h6
-rw-r--r--lldb/include/lldb/API/SBReproducer.h9
-rw-r--r--lldb/include/lldb/API/SBSection.h6
-rw-r--r--lldb/include/lldb/API/SBSourceManager.h6
-rw-r--r--lldb/include/lldb/API/SBStream.h11
-rw-r--r--lldb/include/lldb/API/SBStringList.h6
-rw-r--r--lldb/include/lldb/API/SBStructuredData.h7
-rw-r--r--lldb/include/lldb/API/SBSymbol.h6
-rw-r--r--lldb/include/lldb/API/SBSymbolContext.h6
-rw-r--r--lldb/include/lldb/API/SBSymbolContextList.h6
-rw-r--r--lldb/include/lldb/API/SBTarget.h24
-rw-r--r--lldb/include/lldb/API/SBThread.h6
-rw-r--r--lldb/include/lldb/API/SBThreadCollection.h6
-rw-r--r--lldb/include/lldb/API/SBThreadPlan.h6
-rw-r--r--lldb/include/lldb/API/SBTrace.h6
-rw-r--r--lldb/include/lldb/API/SBTraceOptions.h6
-rw-r--r--lldb/include/lldb/API/SBType.h6
-rw-r--r--lldb/include/lldb/API/SBTypeCategory.h6
-rw-r--r--lldb/include/lldb/API/SBTypeEnumMember.h6
-rw-r--r--lldb/include/lldb/API/SBTypeFilter.h6
-rw-r--r--lldb/include/lldb/API/SBTypeFormat.h6
-rw-r--r--lldb/include/lldb/API/SBTypeNameSpecifier.h6
-rw-r--r--lldb/include/lldb/API/SBTypeSummary.h6
-rw-r--r--lldb/include/lldb/API/SBTypeSynthetic.h6
-rw-r--r--lldb/include/lldb/API/SBUnixSignals.h6
-rw-r--r--lldb/include/lldb/API/SBValue.h6
-rw-r--r--lldb/include/lldb/API/SBValueList.h6
-rw-r--r--lldb/include/lldb/API/SBVariablesOptions.h6
-rw-r--r--lldb/include/lldb/API/SBWatchpoint.h6
-rw-r--r--lldb/include/lldb/Breakpoint/Breakpoint.h25
-rw-r--r--lldb/include/lldb/Breakpoint/BreakpointID.h7
-rw-r--r--lldb/include/lldb/Breakpoint/BreakpointIDList.h9
-rw-r--r--lldb/include/lldb/Breakpoint/BreakpointList.h9
-rw-r--r--lldb/include/lldb/Breakpoint/BreakpointLocation.h9
-rw-r--r--lldb/include/lldb/Breakpoint/BreakpointLocationCollection.h6
-rw-r--r--lldb/include/lldb/Breakpoint/BreakpointLocationList.h6
-rw-r--r--lldb/include/lldb/Breakpoint/BreakpointName.h6
-rw-r--r--lldb/include/lldb/Breakpoint/BreakpointOptions.h6
-rw-r--r--lldb/include/lldb/Breakpoint/BreakpointPrecondition.h4
-rw-r--r--lldb/include/lldb/Breakpoint/BreakpointResolver.h38
-rw-r--r--lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h27
-rw-r--r--lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h20
-rw-r--r--lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h19
-rw-r--r--lldb/include/lldb/Breakpoint/BreakpointResolverName.h23
-rw-r--r--lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h21
-rw-r--r--lldb/include/lldb/Breakpoint/BreakpointSite.h12
-rw-r--r--lldb/include/lldb/Breakpoint/BreakpointSiteList.h6
-rw-r--r--lldb/include/lldb/Breakpoint/Stoppoint.h9
-rw-r--r--lldb/include/lldb/Breakpoint/StoppointCallbackContext.h6
-rw-r--r--lldb/include/lldb/Breakpoint/StoppointLocation.h11
-rw-r--r--lldb/include/lldb/Breakpoint/Watchpoint.h16
-rw-r--r--lldb/include/lldb/Breakpoint/WatchpointList.h6
-rw-r--r--lldb/include/lldb/Breakpoint/WatchpointOptions.h6
-rw-r--r--lldb/include/lldb/Core/Address.h6
-rw-r--r--lldb/include/lldb/Core/AddressRange.h6
-rw-r--r--lldb/include/lldb/Core/AddressResolver.h9
-rw-r--r--lldb/include/lldb/Core/AddressResolverFileLine.h10
-rw-r--r--lldb/include/lldb/Core/AddressResolverName.h9
-rw-r--r--lldb/include/lldb/Core/ClangForward.h133
-rw-r--r--lldb/include/lldb/Core/Communication.h11
-rw-r--r--lldb/include/lldb/Core/Debugger.h40
-rw-r--r--lldb/include/lldb/Core/Disassembler.h76
-rw-r--r--lldb/include/lldb/Core/EmulateInstruction.h9
-rw-r--r--lldb/include/lldb/Core/FileLineResolver.h9
-rw-r--r--lldb/include/lldb/Core/FileSpecList.h6
-rw-r--r--lldb/include/lldb/Core/FormatEntity.h7
-rw-r--r--lldb/include/lldb/Core/Highlighter.h9
-rw-r--r--lldb/include/lldb/Core/IOHandler.h16
-rw-r--r--lldb/include/lldb/Core/IOHandlerCursesGUI.h6
-rw-r--r--lldb/include/lldb/Core/LoadedModuleInfoList.h7
-rw-r--r--lldb/include/lldb/Core/Mangled.h20
-rw-r--r--lldb/include/lldb/Core/MappedHash.h6
-rw-r--r--lldb/include/lldb/Core/Module.h39
-rw-r--r--lldb/include/lldb/Core/ModuleChild.h6
-rw-r--r--lldb/include/lldb/Core/ModuleList.h14
-rw-r--r--lldb/include/lldb/Core/ModuleSpec.h49
-rw-r--r--lldb/include/lldb/Core/Opcode.h8
-rw-r--r--lldb/include/lldb/Core/PluginInterface.h6
-rw-r--r--lldb/include/lldb/Core/PluginManager.h79
-rw-r--r--lldb/include/lldb/Core/PropertiesBase.td6
-rw-r--r--lldb/include/lldb/Core/RichManglingContext.h4
-rw-r--r--lldb/include/lldb/Core/SearchFilter.h53
-rw-r--r--lldb/include/lldb/Core/Section.h18
-rw-r--r--lldb/include/lldb/Core/SourceManager.h20
-rw-r--r--lldb/include/lldb/Core/StreamAsynchronousIO.h6
-rw-r--r--lldb/include/lldb/Core/StreamBuffer.h6
-rw-r--r--lldb/include/lldb/Core/StreamFile.h9
-rw-r--r--lldb/include/lldb/Core/StructuredDataImpl.h4
-rw-r--r--lldb/include/lldb/Core/ThreadSafeDenseMap.h6
-rw-r--r--lldb/include/lldb/Core/ThreadSafeValue.h10
-rw-r--r--lldb/include/lldb/Core/UniqueCStringMap.h25
-rw-r--r--lldb/include/lldb/Core/UserSettingsController.h6
-rw-r--r--lldb/include/lldb/Core/Value.h6
-rw-r--r--lldb/include/lldb/Core/ValueObject.h27
-rw-r--r--lldb/include/lldb/Core/ValueObjectCast.h9
-rw-r--r--lldb/include/lldb/Core/ValueObjectChild.h10
-rw-r--r--lldb/include/lldb/Core/ValueObjectConstResult.h34
-rw-r--r--lldb/include/lldb/Core/ValueObjectConstResultCast.h10
-rw-r--r--lldb/include/lldb/Core/ValueObjectConstResultChild.h10
-rw-r--r--lldb/include/lldb/Core/ValueObjectConstResultImpl.h10
-rw-r--r--lldb/include/lldb/Core/ValueObjectDynamicValue.h11
-rw-r--r--lldb/include/lldb/Core/ValueObjectList.h6
-rw-r--r--lldb/include/lldb/Core/ValueObjectMemory.h15
-rw-r--r--lldb/include/lldb/Core/ValueObjectRegister.h54
-rw-r--r--lldb/include/lldb/Core/ValueObjectSyntheticFilter.h11
-rw-r--r--lldb/include/lldb/Core/ValueObjectVariable.h12
-rw-r--r--lldb/include/lldb/Core/dwarf.h8
-rw-r--r--lldb/include/lldb/DataFormatters/CXXFunctionPointer.h6
-rw-r--r--lldb/include/lldb/DataFormatters/DataVisualization.h7
-rw-r--r--lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h7
-rw-r--r--lldb/include/lldb/DataFormatters/FormatCache.h12
-rw-r--r--lldb/include/lldb/DataFormatters/FormatClasses.h24
-rw-r--r--lldb/include/lldb/DataFormatters/FormatManager.h9
-rw-r--r--lldb/include/lldb/DataFormatters/FormattersContainer.h23
-rw-r--r--lldb/include/lldb/DataFormatters/FormattersHelpers.h8
-rw-r--r--lldb/include/lldb/DataFormatters/LanguageCategory.h7
-rw-r--r--lldb/include/lldb/DataFormatters/StringPrinter.h95
-rw-r--r--lldb/include/lldb/DataFormatters/TypeCategory.h12
-rw-r--r--lldb/include/lldb/DataFormatters/TypeCategoryMap.h6
-rw-r--r--lldb/include/lldb/DataFormatters/TypeFormat.h18
-rw-r--r--lldb/include/lldb/DataFormatters/TypeSummary.h19
-rw-r--r--lldb/include/lldb/DataFormatters/TypeSynthetic.h34
-rw-r--r--lldb/include/lldb/DataFormatters/ValueObjectPrinter.h12
-rw-r--r--lldb/include/lldb/DataFormatters/VectorIterator.h6
-rw-r--r--lldb/include/lldb/DataFormatters/VectorType.h6
-rw-r--r--lldb/include/lldb/Expression/DWARFExpression.h21
-rw-r--r--lldb/include/lldb/Expression/DiagnosticManager.h8
-rw-r--r--lldb/include/lldb/Expression/DynamicCheckerFunctions.h6
-rw-r--r--lldb/include/lldb/Expression/Expression.h10
-rw-r--r--lldb/include/lldb/Expression/ExpressionParser.h6
-rw-r--r--lldb/include/lldb/Expression/ExpressionSourceCode.h4
-rw-r--r--lldb/include/lldb/Expression/ExpressionTypeSystemHelper.h6
-rw-r--r--lldb/include/lldb/Expression/ExpressionVariable.h16
-rw-r--r--lldb/include/lldb/Expression/FunctionCaller.h6
-rw-r--r--lldb/include/lldb/Expression/IRExecutionUnit.h8
-rw-r--r--lldb/include/lldb/Expression/IRInterpreter.h5
-rw-r--r--lldb/include/lldb/Expression/IRMemoryMap.h7
-rw-r--r--lldb/include/lldb/Expression/LLVMUserExpression.h6
-rw-r--r--lldb/include/lldb/Expression/Materializer.h22
-rw-r--r--lldb/include/lldb/Expression/REPL.h10
-rw-r--r--lldb/include/lldb/Expression/UserExpression.h14
-rw-r--r--lldb/include/lldb/Expression/UtilityFunction.h6
-rw-r--r--lldb/include/lldb/Host/Config.h.cmake2
-rw-r--r--lldb/include/lldb/Host/ConnectionFileDescriptor.h4
-rw-r--r--lldb/include/lldb/Host/Debug.h6
-rw-r--r--lldb/include/lldb/Host/Editline.h24
-rw-r--r--lldb/include/lldb/Host/File.h12
-rw-r--r--lldb/include/lldb/Host/FileCache.h4
-rw-r--r--lldb/include/lldb/Host/FileSystem.h7
-rw-r--r--lldb/include/lldb/Host/Host.h6
-rw-r--r--lldb/include/lldb/Host/HostGetOpt.h6
-rw-r--r--lldb/include/lldb/Host/HostInfo.h6
-rw-r--r--lldb/include/lldb/Host/HostInfoBase.h11
-rw-r--r--lldb/include/lldb/Host/HostNativeProcess.h4
-rw-r--r--lldb/include/lldb/Host/HostNativeProcessBase.h8
-rw-r--r--lldb/include/lldb/Host/HostNativeThread.h4
-rw-r--r--lldb/include/lldb/Host/HostNativeThreadBase.h7
-rw-r--r--lldb/include/lldb/Host/HostNativeThreadForward.h4
-rw-r--r--lldb/include/lldb/Host/HostProcess.h4
-rw-r--r--lldb/include/lldb/Host/HostThread.h4
-rw-r--r--lldb/include/lldb/Host/LZMA.h6
-rw-r--r--lldb/include/lldb/Host/LockFile.h6
-rw-r--r--lldb/include/lldb/Host/LockFileBase.h4
-rw-r--r--lldb/include/lldb/Host/MainLoop.h9
-rw-r--r--lldb/include/lldb/Host/MainLoopBase.h13
-rw-r--r--lldb/include/lldb/Host/MonitoringProcessLauncher.h6
-rw-r--r--lldb/include/lldb/Host/OptionParser.h6
-rw-r--r--lldb/include/lldb/Host/Pipe.h6
-rw-r--r--lldb/include/lldb/Host/PipeBase.h4
-rw-r--r--lldb/include/lldb/Host/PosixApi.h4
-rw-r--r--lldb/include/lldb/Host/ProcessLaunchInfo.h6
-rw-r--r--lldb/include/lldb/Host/ProcessLauncher.h4
-rw-r--r--lldb/include/lldb/Host/ProcessRunLock.h12
-rw-r--r--lldb/include/lldb/Host/PseudoTerminal.h152
-rw-r--r--lldb/include/lldb/Host/SafeMachO.h6
-rw-r--r--lldb/include/lldb/Host/Socket.h25
-rw-r--r--lldb/include/lldb/Host/SocketAddress.h6
-rw-r--r--lldb/include/lldb/Host/StringConvert.h4
-rw-r--r--lldb/include/lldb/Host/TaskPool.h92
-rw-r--r--lldb/include/lldb/Host/Terminal.h6
-rw-r--r--lldb/include/lldb/Host/ThreadLauncher.h4
-rw-r--r--lldb/include/lldb/Host/Time.h6
-rw-r--r--lldb/include/lldb/Host/XML.h6
-rw-r--r--lldb/include/lldb/Host/common/GetOptInc.h13
-rw-r--r--lldb/include/lldb/Host/common/NativeBreakpointList.h6
-rw-r--r--lldb/include/lldb/Host/common/NativeProcessProtocol.h18
-rw-r--r--lldb/include/lldb/Host/common/NativeRegisterContext.h10
-rw-r--r--lldb/include/lldb/Host/common/NativeThreadProtocol.h6
-rw-r--r--lldb/include/lldb/Host/common/NativeWatchpointList.h6
-rw-r--r--lldb/include/lldb/Host/common/TCPSocket.h6
-rw-r--r--lldb/include/lldb/Host/common/UDPSocket.h10
-rw-r--r--lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h10
-rw-r--r--lldb/include/lldb/Host/posix/DomainSocket.h6
-rw-r--r--lldb/include/lldb/Host/posix/HostInfoPosix.h4
-rw-r--r--lldb/include/lldb/Host/posix/HostProcessPosix.h6
-rw-r--r--lldb/include/lldb/Host/posix/HostThreadPosix.h9
-rw-r--r--lldb/include/lldb/Host/posix/LockFilePosix.h6
-rw-r--r--lldb/include/lldb/Host/posix/PipePosix.h6
-rw-r--r--lldb/include/lldb/Host/posix/ProcessLauncherPosixFork.h4
-rw-r--r--lldb/include/lldb/Initialization/SystemInitializer.h4
-rw-r--r--lldb/include/lldb/Initialization/SystemInitializerCommon.h6
-rw-r--r--lldb/include/lldb/Initialization/SystemLifetimeManager.h4
-rw-r--r--lldb/include/lldb/Interpreter/CommandAlias.h6
-rw-r--r--lldb/include/lldb/Interpreter/CommandCompletions.h119
-rw-r--r--lldb/include/lldb/Interpreter/CommandHistory.h9
-rw-r--r--lldb/include/lldb/Interpreter/CommandInterpreter.h66
-rw-r--r--lldb/include/lldb/Interpreter/CommandObject.h8
-rw-r--r--lldb/include/lldb/Interpreter/CommandObjectMultiword.h6
-rw-r--r--lldb/include/lldb/Interpreter/CommandObjectRegexCommand.h10
-rw-r--r--lldb/include/lldb/Interpreter/CommandOptionValidators.h6
-rw-r--r--lldb/include/lldb/Interpreter/CommandReturnObject.h17
-rw-r--r--lldb/include/lldb/Interpreter/OptionGroupArchitecture.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionGroupBoolean.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionGroupFile.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionGroupFormat.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionGroupOutputFile.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionGroupPlatform.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionGroupPythonClassWithDict.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionGroupString.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionGroupUInt64.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionGroupUUID.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionGroupVariable.h9
-rw-r--r--lldb/include/lldb/Interpreter/OptionGroupWatchpoint.h10
-rw-r--r--lldb/include/lldb/Interpreter/OptionValue.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionValueArch.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionValueArgs.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionValueArray.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionValueBoolean.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionValueChar.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionValueDictionary.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionValueEnumeration.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionValueFileSpec.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionValueFileSpecList.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionValueFormat.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionValueFormatEntity.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionValueLanguage.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionValuePathMappings.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionValueProperties.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionValueRegex.h12
-rw-r--r--lldb/include/lldb/Interpreter/OptionValueSInt64.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionValueString.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionValueUInt64.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionValueUUID.h6
-rw-r--r--lldb/include/lldb/Interpreter/OptionValues.h6
-rw-r--r--lldb/include/lldb/Interpreter/Options.h8
-rw-r--r--lldb/include/lldb/Interpreter/Property.h6
-rw-r--r--lldb/include/lldb/Interpreter/ScriptInterpreter.h49
-rw-r--r--lldb/include/lldb/Symbol/ArmUnwindInfo.h6
-rw-r--r--lldb/include/lldb/Symbol/Block.h11
-rw-r--r--lldb/include/lldb/Symbol/CallFrameInfo.h6
-rw-r--r--lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h46
-rw-r--r--lldb/include/lldb/Symbol/CompactUnwindInfo.h6
-rw-r--r--lldb/include/lldb/Symbol/CompileUnit.h9
-rw-r--r--lldb/include/lldb/Symbol/CompilerDecl.h6
-rw-r--r--lldb/include/lldb/Symbol/CompilerDeclContext.h8
-rw-r--r--lldb/include/lldb/Symbol/CompilerType.h184
-rw-r--r--lldb/include/lldb/Symbol/DWARFCallFrameInfo.h6
-rw-r--r--lldb/include/lldb/Symbol/DebugMacros.h10
-rw-r--r--lldb/include/lldb/Symbol/DeclVendor.h7
-rw-r--r--lldb/include/lldb/Symbol/Declaration.h6
-rw-r--r--lldb/include/lldb/Symbol/FuncUnwinders.h9
-rw-r--r--lldb/include/lldb/Symbol/Function.h151
-rw-r--r--lldb/include/lldb/Symbol/LineEntry.h8
-rw-r--r--lldb/include/lldb/Symbol/LineTable.h27
-rw-r--r--lldb/include/lldb/Symbol/LocateSymbolFile.h6
-rw-r--r--lldb/include/lldb/Symbol/ObjectContainer.h9
-rw-r--r--lldb/include/lldb/Symbol/ObjectFile.h17
-rw-r--r--lldb/include/lldb/Symbol/SourceModule.h4
-rw-r--r--lldb/include/lldb/Symbol/Symbol.h6
-rw-r--r--lldb/include/lldb/Symbol/SymbolContext.h6
-rw-r--r--lldb/include/lldb/Symbol/SymbolContextScope.h6
-rw-r--r--lldb/include/lldb/Symbol/SymbolFile.h35
-rw-r--r--lldb/include/lldb/Symbol/SymbolVendor.h9
-rw-r--r--lldb/include/lldb/Symbol/Symtab.h9
-rw-r--r--lldb/include/lldb/Symbol/TaggedASTType.h4
-rw-r--r--lldb/include/lldb/Symbol/Type.h26
-rw-r--r--lldb/include/lldb/Symbol/TypeList.h9
-rw-r--r--lldb/include/lldb/Symbol/TypeMap.h12
-rw-r--r--lldb/include/lldb/Symbol/TypeSystem.h35
-rw-r--r--lldb/include/lldb/Symbol/UnwindPlan.h8
-rw-r--r--lldb/include/lldb/Symbol/UnwindTable.h9
-rw-r--r--lldb/include/lldb/Symbol/Variable.h6
-rw-r--r--lldb/include/lldb/Symbol/VariableList.h9
-rw-r--r--lldb/include/lldb/Target/ABI.h49
-rw-r--r--lldb/include/lldb/Target/AssertFrameRecognizer.h54
-rw-r--r--lldb/include/lldb/Target/DynamicLoader.h9
-rw-r--r--lldb/include/lldb/Target/ExecutionContext.h6
-rw-r--r--lldb/include/lldb/Target/ExecutionContextScope.h6
-rw-r--r--lldb/include/lldb/Target/InstrumentationRuntime.h6
-rw-r--r--lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h6
-rw-r--r--lldb/include/lldb/Target/JITLoader.h6
-rw-r--r--lldb/include/lldb/Target/JITLoaderList.h6
-rw-r--r--lldb/include/lldb/Target/Language.h13
-rw-r--r--lldb/include/lldb/Target/LanguageRuntime.h25
-rw-r--r--lldb/include/lldb/Target/Memory.h14
-rw-r--r--lldb/include/lldb/Target/MemoryHistory.h6
-rw-r--r--lldb/include/lldb/Target/MemoryRegionInfo.h6
-rw-r--r--lldb/include/lldb/Target/ModuleCache.h2
-rw-r--r--lldb/include/lldb/Target/OperatingSystem.h10
-rw-r--r--lldb/include/lldb/Target/PathMappingList.h6
-rw-r--r--lldb/include/lldb/Target/Platform.h66
-rw-r--r--lldb/include/lldb/Target/Process.h119
-rw-r--r--lldb/include/lldb/Target/ProcessStructReader.h2
-rw-r--r--lldb/include/lldb/Target/Queue.h9
-rw-r--r--lldb/include/lldb/Target/QueueItem.h9
-rw-r--r--lldb/include/lldb/Target/QueueList.h6
-rw-r--r--lldb/include/lldb/Target/RegisterCheckpoint.h9
-rw-r--r--lldb/include/lldb/Target/RegisterContext.h13
-rw-r--r--lldb/include/lldb/Target/RegisterContextUnwind.h (renamed from lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h)34
-rw-r--r--lldb/include/lldb/Target/RegisterNumber.h2
-rw-r--r--lldb/include/lldb/Target/RemoteAwarePlatform.h4
-rw-r--r--lldb/include/lldb/Target/SectionLoadHistory.h9
-rw-r--r--lldb/include/lldb/Target/SectionLoadList.h6
-rw-r--r--lldb/include/lldb/Target/StackFrame.h20
-rw-r--r--lldb/include/lldb/Target/StackFrameList.h11
-rw-r--r--lldb/include/lldb/Target/StackFrameRecognizer.h26
-rw-r--r--lldb/include/lldb/Target/StackID.h6
-rw-r--r--lldb/include/lldb/Target/StopInfo.h9
-rw-r--r--lldb/include/lldb/Target/StructuredDataPlugin.h7
-rw-r--r--lldb/include/lldb/Target/SystemRuntime.h9
-rw-r--r--lldb/include/lldb/Target/Target.h46
-rw-r--r--lldb/include/lldb/Target/TargetList.h9
-rw-r--r--lldb/include/lldb/Target/Thread.h73
-rw-r--r--lldb/include/lldb/Target/ThreadCollection.h6
-rw-r--r--lldb/include/lldb/Target/ThreadList.h6
-rw-r--r--lldb/include/lldb/Target/ThreadPlan.h49
-rw-r--r--lldb/include/lldb/Target/ThreadPlanBase.h9
-rw-r--r--lldb/include/lldb/Target/ThreadPlanCallFunction.h10
-rw-r--r--lldb/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h11
-rw-r--r--lldb/include/lldb/Target/ThreadPlanCallOnFunctionExit.h6
-rw-r--r--lldb/include/lldb/Target/ThreadPlanCallUserExpression.h10
-rw-r--r--lldb/include/lldb/Target/ThreadPlanPython.h11
-rw-r--r--lldb/include/lldb/Target/ThreadPlanRunToAddress.h10
-rw-r--r--lldb/include/lldb/Target/ThreadPlanShouldStopHere.h10
-rw-r--r--lldb/include/lldb/Target/ThreadPlanStack.h173
-rw-r--r--lldb/include/lldb/Target/ThreadPlanStepInRange.h16
-rw-r--r--lldb/include/lldb/Target/ThreadPlanStepInstruction.h10
-rw-r--r--lldb/include/lldb/Target/ThreadPlanStepOut.h9
-rw-r--r--lldb/include/lldb/Target/ThreadPlanStepOverBreakpoint.h10
-rw-r--r--lldb/include/lldb/Target/ThreadPlanStepOverRange.h10
-rw-r--r--lldb/include/lldb/Target/ThreadPlanStepRange.h9
-rw-r--r--lldb/include/lldb/Target/ThreadPlanStepThrough.h10
-rw-r--r--lldb/include/lldb/Target/ThreadPlanStepUntil.h9
-rw-r--r--lldb/include/lldb/Target/ThreadPlanTracer.h12
-rw-r--r--lldb/include/lldb/Target/ThreadSpec.h12
-rw-r--r--lldb/include/lldb/Target/UnixSignals.h6
-rw-r--r--lldb/include/lldb/Target/Unwind.h9
-rw-r--r--lldb/include/lldb/Target/UnwindAssembly.h9
-rw-r--r--lldb/include/lldb/Target/UnwindLLDB.h (renamed from lldb/source/Plugins/Process/Utility/UnwindLLDB.h)27
-rw-r--r--lldb/include/lldb/Utility/AnsiTerminal.h8
-rw-r--r--lldb/include/lldb/Utility/ArchSpec.h19
-rw-r--r--lldb/include/lldb/Utility/Args.h30
-rw-r--r--lldb/include/lldb/Utility/Baton.h6
-rw-r--r--lldb/include/lldb/Utility/Broadcaster.h28
-rw-r--r--lldb/include/lldb/Utility/CompletionRequest.h53
-rw-r--r--lldb/include/lldb/Utility/Connection.h11
-rw-r--r--lldb/include/lldb/Utility/ConstString.h24
-rw-r--r--lldb/include/lldb/Utility/DataBuffer.h20
-rw-r--r--lldb/include/lldb/Utility/DataBufferHeap.h6
-rw-r--r--lldb/include/lldb/Utility/DataBufferLLVM.h4
-rw-r--r--lldb/include/lldb/Utility/DataEncoder.h10
-rw-r--r--lldb/include/lldb/Utility/DataExtractor.h52
-rw-r--r--lldb/include/lldb/Utility/Endian.h2
-rw-r--r--lldb/include/lldb/Utility/Environment.h6
-rw-r--r--lldb/include/lldb/Utility/Event.h13
-rw-r--r--lldb/include/lldb/Utility/FileSpec.h21
-rw-r--r--lldb/include/lldb/Utility/Flags.h4
-rw-r--r--lldb/include/lldb/Utility/GDBRemote.h6
-rw-r--r--lldb/include/lldb/Utility/IOObject.h7
-rw-r--r--lldb/include/lldb/Utility/Iterable.h6
-rw-r--r--lldb/include/lldb/Utility/LLDBAssert.h6
-rw-r--r--lldb/include/lldb/Utility/Listener.h3
-rw-r--r--lldb/include/lldb/Utility/Predicate.h9
-rw-r--r--lldb/include/lldb/Utility/ProcessInfo.h90
-rw-r--r--lldb/include/lldb/Utility/RangeMap.h295
-rw-r--r--lldb/include/lldb/Utility/RegisterValue.h10
-rw-r--r--lldb/include/lldb/Utility/RegularExpression.h6
-rw-r--r--lldb/include/lldb/Utility/Reproducer.h116
-rw-r--r--lldb/include/lldb/Utility/ReproducerInstrumentation.h632
-rw-r--r--lldb/include/lldb/Utility/Scalar.h47
-rw-r--r--lldb/include/lldb/Utility/SelectHelper.h6
-rw-r--r--lldb/include/lldb/Utility/SharedCluster.h86
-rw-r--r--lldb/include/lldb/Utility/SharingPtr.h609
-rw-r--r--lldb/include/lldb/Utility/Status.h8
-rw-r--r--lldb/include/lldb/Utility/Stream.h23
-rw-r--r--lldb/include/lldb/Utility/StreamCallback.h6
-rw-r--r--lldb/include/lldb/Utility/StreamString.h6
-rw-r--r--lldb/include/lldb/Utility/StreamTee.h9
-rw-r--r--lldb/include/lldb/Utility/StringExtractor.h8
-rw-r--r--lldb/include/lldb/Utility/StringLexer.h6
-rw-r--r--lldb/include/lldb/Utility/StringList.h6
-rw-r--r--lldb/include/lldb/Utility/StructuredData.h8
-rw-r--r--lldb/include/lldb/Utility/TildeExpressionResolver.h6
-rw-r--r--lldb/include/lldb/Utility/Timeout.h6
-rw-r--r--lldb/include/lldb/Utility/Timer.h12
-rw-r--r--lldb/include/lldb/Utility/TraceOptions.h6
-rw-r--r--lldb/include/lldb/Utility/UUID.h16
-rw-r--r--lldb/include/lldb/Utility/UriParser.h6
-rw-r--r--lldb/include/lldb/Utility/UserID.h6
-rw-r--r--lldb/include/lldb/Utility/UserIDResolver.h2
-rw-r--r--lldb/include/lldb/Utility/VASPrintf.h2
-rw-r--r--lldb/include/lldb/Utility/VMRange.h6
-rw-r--r--lldb/include/lldb/Utility/XcodeSDK.h96
-rw-r--r--lldb/include/lldb/lldb-defines.h17
-rw-r--r--lldb/include/lldb/lldb-enumerations.h25
-rw-r--r--lldb/include/lldb/lldb-forward.h116
-rw-r--r--lldb/include/lldb/lldb-private-defines.h6
-rw-r--r--lldb/include/lldb/lldb-private-enumerations.h18
-rw-r--r--lldb/include/lldb/lldb-private-forward.h6
-rw-r--r--lldb/include/lldb/lldb-private-interfaces.h16
-rw-r--r--lldb/include/lldb/lldb-private-types.h135
-rw-r--r--lldb/include/lldb/lldb-private.h6
-rw-r--r--lldb/include/lldb/lldb-public.h6
-rw-r--r--lldb/include/lldb/lldb-types.h6
-rw-r--r--lldb/include/lldb/lldb-versioning.h6
-rw-r--r--lldb/include/lldb/module.modulemap6
-rw-r--r--lldb/source/API/SBAddress.cpp10
-rw-r--r--lldb/source/API/SBAttachInfo.cpp4
-rw-r--r--lldb/source/API/SBBlock.cpp10
-rw-r--r--lldb/source/API/SBBreakpoint.cpp25
-rw-r--r--lldb/source/API/SBBreakpointLocation.cpp4
-rw-r--r--lldb/source/API/SBBreakpointName.cpp15
-rw-r--r--lldb/source/API/SBBreakpointOptionCommon.cpp2
-rw-r--r--lldb/source/API/SBBreakpointOptionCommon.h6
-rw-r--r--lldb/source/API/SBBroadcaster.cpp2
-rw-r--r--lldb/source/API/SBCommandInterpreter.cpp235
-rw-r--r--lldb/source/API/SBCommandInterpreterRunOptions.cpp272
-rw-r--r--lldb/source/API/SBCommandReturnObject.cpp4
-rw-r--r--lldb/source/API/SBCommunication.cpp7
-rw-r--r--lldb/source/API/SBCompileUnit.cpp2
-rw-r--r--lldb/source/API/SBData.cpp4
-rw-r--r--lldb/source/API/SBDebugger.cpp97
-rw-r--r--lldb/source/API/SBDeclaration.cpp6
-rw-r--r--lldb/source/API/SBEnvironment.cpp155
-rw-r--r--lldb/source/API/SBError.cpp6
-rw-r--r--lldb/source/API/SBEvent.cpp4
-rw-r--r--lldb/source/API/SBExecutionContext.cpp5
-rw-r--r--lldb/source/API/SBExpressionOptions.cpp22
-rw-r--r--lldb/source/API/SBFile.cpp48
-rw-r--r--lldb/source/API/SBFileSpec.cpp10
-rw-r--r--lldb/source/API/SBFileSpecList.cpp4
-rw-r--r--lldb/source/API/SBFrame.cpp33
-rw-r--r--lldb/source/API/SBFunction.cpp17
-rw-r--r--lldb/source/API/SBHostOS.cpp2
-rw-r--r--lldb/source/API/SBInstruction.cpp4
-rw-r--r--lldb/source/API/SBInstructionList.cpp4
-rw-r--r--lldb/source/API/SBLanguageRuntime.cpp2
-rw-r--r--lldb/source/API/SBLaunchInfo.cpp42
-rw-r--r--lldb/source/API/SBLineEntry.cpp6
-rw-r--r--lldb/source/API/SBListener.cpp4
-rw-r--r--lldb/source/API/SBMemoryRegionInfo.cpp4
-rw-r--r--lldb/source/API/SBMemoryRegionInfoList.cpp4
-rw-r--r--lldb/source/API/SBModule.cpp21
-rw-r--r--lldb/source/API/SBModuleSpec.cpp6
-rw-r--r--lldb/source/API/SBPlatform.cpp73
-rw-r--r--lldb/source/API/SBProcess.cpp51
-rw-r--r--lldb/source/API/SBProcessInfo.cpp6
-rw-r--r--lldb/source/API/SBQueue.cpp6
-rw-r--r--lldb/source/API/SBQueueItem.cpp2
-rw-r--r--lldb/source/API/SBReproducer.cpp61
-rw-r--r--lldb/source/API/SBReproducerPrivate.h28
-rw-r--r--lldb/source/API/SBSection.cpp6
-rw-r--r--lldb/source/API/SBSourceManager.cpp12
-rw-r--r--lldb/source/API/SBStream.cpp22
-rw-r--r--lldb/source/API/SBStringList.cpp12
-rw-r--r--lldb/source/API/SBStructuredData.cpp30
-rw-r--r--lldb/source/API/SBSymbol.cpp15
-rw-r--r--lldb/source/API/SBSymbolContext.cpp8
-rw-r--r--lldb/source/API/SBSymbolContextList.cpp4
-rw-r--r--lldb/source/API/SBTarget.cpp101
-rw-r--r--lldb/source/API/SBThread.cpp133
-rw-r--r--lldb/source/API/SBThreadCollection.cpp4
-rw-r--r--lldb/source/API/SBThreadPlan.cpp18
-rw-r--r--lldb/source/API/SBTrace.cpp2
-rw-r--r--lldb/source/API/SBTraceOptions.cpp2
-rw-r--r--lldb/source/API/SBType.cpp20
-rw-r--r--lldb/source/API/SBTypeCategory.cpp5
-rw-r--r--lldb/source/API/SBTypeEnumMember.cpp8
-rw-r--r--lldb/source/API/SBTypeFilter.cpp5
-rw-r--r--lldb/source/API/SBTypeFormat.cpp5
-rw-r--r--lldb/source/API/SBTypeNameSpecifier.cpp5
-rw-r--r--lldb/source/API/SBTypeSummary.cpp13
-rw-r--r--lldb/source/API/SBTypeSynthetic.cpp5
-rw-r--r--lldb/source/API/SBUnixSignals.cpp5
-rw-r--r--lldb/source/API/SBValue.cpp16
-rw-r--r--lldb/source/API/SBValueList.cpp12
-rw-r--r--lldb/source/API/SBVariablesOptions.cpp5
-rw-r--r--lldb/source/API/SBWatchpoint.cpp4
-rw-r--r--lldb/source/API/SystemInitializerFull.cpp367
-rw-r--r--lldb/source/API/SystemInitializerFull.h6
-rw-r--r--lldb/source/API/Utils.h4
-rw-r--r--lldb/source/Breakpoint/Breakpoint.cpp39
-rw-r--r--lldb/source/Breakpoint/BreakpointID.cpp4
-rw-r--r--lldb/source/Breakpoint/BreakpointIDList.cpp4
-rw-r--r--lldb/source/Breakpoint/BreakpointList.cpp2
-rw-r--r--lldb/source/Breakpoint/BreakpointLocation.cpp11
-rw-r--r--lldb/source/Breakpoint/BreakpointLocationCollection.cpp2
-rw-r--r--lldb/source/Breakpoint/BreakpointLocationList.cpp2
-rw-r--r--lldb/source/Breakpoint/BreakpointName.cpp2
-rw-r--r--lldb/source/Breakpoint/BreakpointOptions.cpp15
-rw-r--r--lldb/source/Breakpoint/BreakpointPrecondition.cpp2
-rw-r--r--lldb/source/Breakpoint/BreakpointResolver.cpp11
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverAddress.cpp35
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverFileLine.cpp14
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp16
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverName.cpp155
-rw-r--r--lldb/source/Breakpoint/BreakpointResolverScripted.cpp61
-rw-r--r--lldb/source/Breakpoint/BreakpointSite.cpp9
-rw-r--r--lldb/source/Breakpoint/BreakpointSiteList.cpp2
-rw-r--r--lldb/source/Breakpoint/Stoppoint.cpp2
-rw-r--r--lldb/source/Breakpoint/StoppointCallbackContext.cpp2
-rw-r--r--lldb/source/Breakpoint/StoppointLocation.cpp2
-rw-r--r--lldb/source/Breakpoint/Watchpoint.cpp2
-rw-r--r--lldb/source/Breakpoint/WatchpointList.cpp2
-rw-r--r--lldb/source/Breakpoint/WatchpointOptions.cpp8
-rw-r--r--lldb/source/Commands/CommandCompletions.cpp475
-rw-r--r--lldb/source/Commands/CommandObjectApropos.cpp3
-rw-r--r--lldb/source/Commands/CommandObjectApropos.h6
-rw-r--r--lldb/source/Commands/CommandObjectBreakpoint.cpp107
-rw-r--r--lldb/source/Commands/CommandObjectBreakpoint.h7
-rw-r--r--lldb/source/Commands/CommandObjectBreakpointCommand.cpp4
-rw-r--r--lldb/source/Commands/CommandObjectBreakpointCommand.h6
-rw-r--r--lldb/source/Commands/CommandObjectCommands.cpp55
-rw-r--r--lldb/source/Commands/CommandObjectCommands.h6
-rw-r--r--lldb/source/Commands/CommandObjectDisassemble.cpp456
-rw-r--r--lldb/source/Commands/CommandObjectDisassemble.h20
-rw-r--r--lldb/source/Commands/CommandObjectExpression.cpp105
-rw-r--r--lldb/source/Commands/CommandObjectExpression.h27
-rw-r--r--lldb/source/Commands/CommandObjectFrame.cpp126
-rw-r--r--lldb/source/Commands/CommandObjectFrame.h6
-rw-r--r--lldb/source/Commands/CommandObjectGUI.cpp6
-rw-r--r--lldb/source/Commands/CommandObjectGUI.h6
-rw-r--r--lldb/source/Commands/CommandObjectHelp.cpp4
-rw-r--r--lldb/source/Commands/CommandObjectHelp.h6
-rw-r--r--lldb/source/Commands/CommandObjectLanguage.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectLanguage.h6
-rw-r--r--lldb/source/Commands/CommandObjectLog.cpp227
-rw-r--r--lldb/source/Commands/CommandObjectLog.h10
-rw-r--r--lldb/source/Commands/CommandObjectMemory.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectMemory.h6
-rw-r--r--lldb/source/Commands/CommandObjectMultiword.cpp27
-rw-r--r--lldb/source/Commands/CommandObjectPlatform.cpp77
-rw-r--r--lldb/source/Commands/CommandObjectPlatform.h10
-rw-r--r--lldb/source/Commands/CommandObjectPlugin.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectPlugin.h6
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp184
-rw-r--r--lldb/source/Commands/CommandObjectProcess.h6
-rw-r--r--lldb/source/Commands/CommandObjectQuit.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectQuit.h6
-rw-r--r--lldb/source/Commands/CommandObjectRegister.cpp24
-rw-r--r--lldb/source/Commands/CommandObjectRegister.h10
-rw-r--r--lldb/source/Commands/CommandObjectReproducer.cpp99
-rw-r--r--lldb/source/Commands/CommandObjectReproducer.h6
-rw-r--r--lldb/source/Commands/CommandObjectSettings.cpp62
-rw-r--r--lldb/source/Commands/CommandObjectSettings.h6
-rw-r--r--lldb/source/Commands/CommandObjectSource.cpp10
-rw-r--r--lldb/source/Commands/CommandObjectSource.h6
-rw-r--r--lldb/source/Commands/CommandObjectStats.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectStats.h6
-rw-r--r--lldb/source/Commands/CommandObjectTarget.cpp320
-rw-r--r--lldb/source/Commands/CommandObjectTarget.h6
-rw-r--r--lldb/source/Commands/CommandObjectThread.cpp179
-rw-r--r--lldb/source/Commands/CommandObjectThread.h6
-rw-r--r--lldb/source/Commands/CommandObjectType.cpp29
-rw-r--r--lldb/source/Commands/CommandObjectType.h6
-rw-r--r--lldb/source/Commands/CommandObjectVersion.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectVersion.h6
-rw-r--r--lldb/source/Commands/CommandObjectWatchpoint.cpp12
-rw-r--r--lldb/source/Commands/CommandObjectWatchpoint.h6
-rw-r--r--lldb/source/Commands/CommandObjectWatchpointCommand.cpp12
-rw-r--r--lldb/source/Commands/CommandObjectWatchpointCommand.h6
-rw-r--r--lldb/source/Commands/Options.td29
-rw-r--r--lldb/source/Core/Address.cpp4
-rw-r--r--lldb/source/Core/AddressRange.cpp2
-rw-r--r--lldb/source/Core/AddressResolver.cpp2
-rw-r--r--lldb/source/Core/AddressResolverFileLine.cpp2
-rw-r--r--lldb/source/Core/AddressResolverName.cpp4
-rw-r--r--lldb/source/Core/Communication.cpp38
-rw-r--r--lldb/source/Core/CoreProperties.td18
-rw-r--r--lldb/source/Core/Debugger.cpp265
-rw-r--r--lldb/source/Core/Disassembler.cpp274
-rw-r--r--lldb/source/Core/DumpDataExtractor.cpp246
-rw-r--r--lldb/source/Core/DumpRegisterValue.cpp4
-rw-r--r--lldb/source/Core/DynamicLoader.cpp4
-rw-r--r--lldb/source/Core/EmulateInstruction.cpp2
-rw-r--r--lldb/source/Core/FileLineResolver.cpp2
-rw-r--r--lldb/source/Core/FileSpecList.cpp2
-rw-r--r--lldb/source/Core/FormatEntity.cpp51
-rw-r--r--lldb/source/Core/Highlighter.cpp2
-rw-r--r--lldb/source/Core/IOHandler.cpp26
-rw-r--r--lldb/source/Core/IOHandlerCursesGUI.cpp13
-rw-r--r--lldb/source/Core/Mangled.cpp37
-rw-r--r--lldb/source/Core/Module.cpp99
-rw-r--r--lldb/source/Core/ModuleChild.cpp2
-rw-r--r--lldb/source/Core/ModuleList.cpp42
-rw-r--r--lldb/source/Core/Opcode.cpp2
-rw-r--r--lldb/source/Core/PluginManager.cpp1891
-rw-r--r--lldb/source/Core/RichManglingContext.cpp2
-rw-r--r--lldb/source/Core/SearchFilter.cpp71
-rw-r--r--lldb/source/Core/Section.cpp78
-rw-r--r--lldb/source/Core/SourceManager.cpp79
-rw-r--r--lldb/source/Core/StreamAsynchronousIO.cpp2
-rw-r--r--lldb/source/Core/StreamFile.cpp2
-rw-r--r--lldb/source/Core/UserSettingsController.cpp2
-rw-r--r--lldb/source/Core/Value.cpp2
-rw-r--r--lldb/source/Core/ValueObject.cpp209
-rw-r--r--lldb/source/Core/ValueObjectCast.cpp5
-rw-r--r--lldb/source/Core/ValueObjectChild.cpp6
-rw-r--r--lldb/source/Core/ValueObjectConstResult.cpp75
-rw-r--r--lldb/source/Core/ValueObjectConstResultCast.cpp2
-rw-r--r--lldb/source/Core/ValueObjectConstResultChild.cpp2
-rw-r--r--lldb/source/Core/ValueObjectConstResultImpl.cpp3
-rw-r--r--lldb/source/Core/ValueObjectDynamicValue.cpp5
-rw-r--r--lldb/source/Core/ValueObjectList.cpp3
-rw-r--r--lldb/source/Core/ValueObjectMemory.cpp23
-rw-r--r--lldb/source/Core/ValueObjectRegister.cpp92
-rw-r--r--lldb/source/Core/ValueObjectSyntheticFilter.cpp11
-rw-r--r--lldb/source/Core/ValueObjectVariable.cpp84
-rw-r--r--lldb/source/DataFormatters/CXXFunctionPointer.cpp2
-rw-r--r--lldb/source/DataFormatters/DataVisualization.cpp3
-rw-r--r--lldb/source/DataFormatters/DumpValueObjectOptions.cpp3
-rw-r--r--lldb/source/DataFormatters/FormatCache.cpp20
-rw-r--r--lldb/source/DataFormatters/FormatClasses.cpp3
-rw-r--r--lldb/source/DataFormatters/FormatManager.cpp27
-rw-r--r--lldb/source/DataFormatters/FormattersHelpers.cpp14
-rw-r--r--lldb/source/DataFormatters/LanguageCategory.cpp7
-rw-r--r--lldb/source/DataFormatters/StringPrinter.cpp585
-rw-r--r--lldb/source/DataFormatters/TypeCategory.cpp40
-rw-r--r--lldb/source/DataFormatters/TypeCategoryMap.cpp11
-rw-r--r--lldb/source/DataFormatters/TypeFormat.cpp12
-rw-r--r--lldb/source/DataFormatters/TypeSummary.cpp14
-rw-r--r--lldb/source/DataFormatters/TypeSynthetic.cpp9
-rw-r--r--lldb/source/DataFormatters/ValueObjectPrinter.cpp35
-rw-r--r--lldb/source/DataFormatters/VectorType.cpp2
-rw-r--r--lldb/source/Expression/DWARFExpression.cpp297
-rw-r--r--lldb/source/Expression/DiagnosticManager.cpp4
-rw-r--r--lldb/source/Expression/Expression.cpp2
-rw-r--r--lldb/source/Expression/ExpressionVariable.cpp14
-rw-r--r--lldb/source/Expression/FunctionCaller.cpp7
-rw-r--r--lldb/source/Expression/IRExecutionUnit.cpp61
-rw-r--r--lldb/source/Expression/IRInterpreter.cpp59
-rw-r--r--lldb/source/Expression/IRMemoryMap.cpp2
-rw-r--r--lldb/source/Expression/LLVMUserExpression.cpp19
-rw-r--r--lldb/source/Expression/Materializer.cpp47
-rw-r--r--lldb/source/Expression/REPL.cpp36
-rw-r--r--lldb/source/Expression/UserExpression.cpp124
-rw-r--r--lldb/source/Expression/UtilityFunction.cpp2
-rw-r--r--lldb/source/Host/common/Editline.cpp85
-rw-r--r--lldb/source/Host/common/File.cpp2
-rw-r--r--lldb/source/Host/common/FileAction.cpp2
-rw-r--r--lldb/source/Host/common/FileCache.cpp2
-rw-r--r--lldb/source/Host/common/FileSystem.cpp47
-rw-r--r--lldb/source/Host/common/GetOptInc.cpp2
-rw-r--r--lldb/source/Host/common/Host.cpp28
-rw-r--r--lldb/source/Host/common/HostInfoBase.cpp2
-rw-r--r--lldb/source/Host/common/HostNativeThreadBase.cpp2
-rw-r--r--lldb/source/Host/common/HostProcess.cpp2
-rw-r--r--lldb/source/Host/common/HostThread.cpp2
-rw-r--r--lldb/source/Host/common/LZMA.cpp2
-rw-r--r--lldb/source/Host/common/LockFileBase.cpp2
-rw-r--r--lldb/source/Host/common/MainLoop.cpp2
-rw-r--r--lldb/source/Host/common/MonitoringProcessLauncher.cpp2
-rw-r--r--lldb/source/Host/common/NativeProcessProtocol.cpp4
-rw-r--r--lldb/source/Host/common/NativeRegisterContext.cpp2
-rw-r--r--lldb/source/Host/common/NativeThreadProtocol.cpp2
-rw-r--r--lldb/source/Host/common/NativeWatchpointList.cpp2
-rw-r--r--lldb/source/Host/common/OptionParser.cpp4
-rw-r--r--lldb/source/Host/common/PipeBase.cpp2
-rw-r--r--lldb/source/Host/common/ProcessLaunchInfo.cpp22
-rw-r--r--lldb/source/Host/common/ProcessRunLock.cpp2
-rw-r--r--lldb/source/Host/common/PseudoTerminal.cpp202
-rw-r--r--lldb/source/Host/common/Socket.cpp78
-rw-r--r--lldb/source/Host/common/SocketAddress.cpp2
-rw-r--r--lldb/source/Host/common/StringConvert.cpp2
-rw-r--r--lldb/source/Host/common/TCPSocket.cpp30
-rw-r--r--lldb/source/Host/common/TaskPool.cpp126
-rw-r--r--lldb/source/Host/common/Terminal.cpp2
-rw-r--r--lldb/source/Host/common/ThreadLauncher.cpp2
-rw-r--r--lldb/source/Host/common/UDPSocket.cpp37
-rw-r--r--lldb/source/Host/common/XML.cpp2
-rw-r--r--lldb/source/Host/freebsd/Host.cpp15
-rw-r--r--lldb/source/Host/freebsd/HostInfoFreeBSD.cpp2
-rw-r--r--lldb/source/Host/netbsd/HostInfoNetBSD.cpp2
-rw-r--r--lldb/source/Host/netbsd/HostNetBSD.cpp (renamed from lldb/source/Host/netbsd/Host.cpp)44
-rw-r--r--lldb/source/Host/openbsd/Host.cpp10
-rw-r--r--lldb/source/Host/openbsd/HostInfoOpenBSD.cpp2
-rw-r--r--lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp78
-rw-r--r--lldb/source/Host/posix/DomainSocket.cpp10
-rw-r--r--lldb/source/Host/posix/FileSystemPosix.cpp6
-rw-r--r--lldb/source/Host/posix/HostInfoPosix.cpp2
-rw-r--r--lldb/source/Host/posix/HostProcessPosix.cpp2
-rw-r--r--lldb/source/Host/posix/HostThreadPosix.cpp2
-rw-r--r--lldb/source/Host/posix/LockFilePosix.cpp2
-rw-r--r--lldb/source/Host/posix/PipePosix.cpp2
-rw-r--r--lldb/source/Host/posix/ProcessLauncherPosixFork.cpp2
-rw-r--r--lldb/source/Initialization/SystemInitializer.cpp2
-rw-r--r--lldb/source/Initialization/SystemInitializerCommon.cpp2
-rw-r--r--lldb/source/Initialization/SystemLifetimeManager.cpp2
-rw-r--r--lldb/source/Interpreter/CommandAlias.cpp9
-rw-r--r--lldb/source/Interpreter/CommandHistory.cpp4
-rw-r--r--lldb/source/Interpreter/CommandInterpreter.cpp166
-rw-r--r--lldb/source/Interpreter/CommandObject.cpp65
-rw-r--r--lldb/source/Interpreter/CommandObjectRegexCommand.cpp2
-rw-r--r--lldb/source/Interpreter/CommandObjectScript.cpp2
-rw-r--r--lldb/source/Interpreter/CommandObjectScript.h6
-rw-r--r--lldb/source/Interpreter/CommandOptionValidators.cpp2
-rw-r--r--lldb/source/Interpreter/CommandReturnObject.cpp41
-rw-r--r--lldb/source/Interpreter/OptionArgParser.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupArchitecture.cpp4
-rw-r--r--lldb/source/Interpreter/OptionGroupBoolean.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupFile.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupFormat.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupOutputFile.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupPlatform.cpp4
-rw-r--r--lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp6
-rw-r--r--lldb/source/Interpreter/OptionGroupString.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupUInt64.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupUUID.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupVariable.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupWatchpoint.cpp2
-rw-r--r--lldb/source/Interpreter/OptionValue.cpp27
-rw-r--r--lldb/source/Interpreter/OptionValueArch.cpp2
-rw-r--r--lldb/source/Interpreter/OptionValueArgs.cpp2
-rw-r--r--lldb/source/Interpreter/OptionValueArray.cpp2
-rw-r--r--lldb/source/Interpreter/OptionValueBoolean.cpp2
-rw-r--r--lldb/source/Interpreter/OptionValueChar.cpp2
-rw-r--r--lldb/source/Interpreter/OptionValueDictionary.cpp4
-rw-r--r--lldb/source/Interpreter/OptionValueEnumeration.cpp2
-rw-r--r--lldb/source/Interpreter/OptionValueFileSpec.cpp2
-rw-r--r--lldb/source/Interpreter/OptionValueFormat.cpp2
-rw-r--r--lldb/source/Interpreter/OptionValueFormatEntity.cpp4
-rw-r--r--lldb/source/Interpreter/OptionValueLanguage.cpp2
-rw-r--r--lldb/source/Interpreter/OptionValuePathMappings.cpp60
-rw-r--r--lldb/source/Interpreter/OptionValueProperties.cpp2
-rw-r--r--lldb/source/Interpreter/OptionValueRegex.cpp2
-rw-r--r--lldb/source/Interpreter/OptionValueSInt64.cpp2
-rw-r--r--lldb/source/Interpreter/OptionValueString.cpp7
-rw-r--r--lldb/source/Interpreter/OptionValueUInt64.cpp3
-rw-r--r--lldb/source/Interpreter/OptionValueUUID.cpp4
-rw-r--r--lldb/source/Interpreter/Options.cpp17
-rw-r--r--lldb/source/Interpreter/Property.cpp2
-rw-r--r--lldb/source/Interpreter/ScriptInterpreter.cpp128
-rw-r--r--lldb/source/Interpreter/embedded_interpreter.py7
-rw-r--r--lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp52
-rw-r--r--lldb/source/Plugins/ABI/AArch64/ABIAArch64.h32
-rw-r--r--lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp831
-rw-r--r--lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.h (renamed from lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h)21
-rw-r--r--lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp800
-rw-r--r--lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.h (renamed from lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h)21
-rw-r--r--lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp (renamed from lldb/source/Plugins/ABI/SysV-arc/ABISysV_arc.cpp)10
-rw-r--r--lldb/source/Plugins/ABI/ARC/ABISysV_arc.h (renamed from lldb/source/Plugins/ABI/SysV-arc/ABISysV_arc.h)4
-rw-r--r--lldb/source/Plugins/ABI/ARM/ABIARM.cpp24
-rw-r--r--lldb/source/Plugins/ABI/ARM/ABIARM.h17
-rw-r--r--lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp (renamed from lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp)2
-rw-r--r--lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.h (renamed from lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h)14
-rw-r--r--lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp (renamed from lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp)4
-rw-r--r--lldb/source/Plugins/ABI/ARM/ABISysV_arm.h (renamed from lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.h)14
-rw-r--r--lldb/source/Plugins/ABI/Hexagon/ABISysV_hexagon.cpp (renamed from lldb/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp)4
-rw-r--r--lldb/source/Plugins/ABI/Hexagon/ABISysV_hexagon.h (renamed from lldb/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h)14
-rw-r--r--lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp2451
-rw-r--r--lldb/source/Plugins/ABI/Mips/ABIMips.cpp24
-rw-r--r--lldb/source/Plugins/ABI/Mips/ABIMips.h17
-rw-r--r--lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp (renamed from lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp)4
-rw-r--r--lldb/source/Plugins/ABI/Mips/ABISysV_mips.h (renamed from lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.h)14
-rw-r--r--lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp (renamed from lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp)4
-rw-r--r--lldb/source/Plugins/ABI/Mips/ABISysV_mips64.h (renamed from lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h)16
-rw-r--r--lldb/source/Plugins/ABI/PowerPC/ABIPowerPC.cpp24
-rw-r--r--lldb/source/Plugins/ABI/PowerPC/ABIPowerPC.h17
-rw-r--r--lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp (renamed from lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp)4
-rw-r--r--lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.h (renamed from lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h)16
-rw-r--r--lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp (renamed from lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp)12
-rw-r--r--lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.h (renamed from lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h)16
-rw-r--r--lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp2420
-rw-r--r--lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp (renamed from lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp)4
-rw-r--r--lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.h (renamed from lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h)14
-rw-r--r--lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.cpp (renamed from lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp)662
-rw-r--r--lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.h (renamed from lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h)26
-rw-r--r--lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp (renamed from lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp)131
-rw-r--r--lldb/source/Plugins/ABI/X86/ABISysV_i386.h (renamed from lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.h)21
-rw-r--r--lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp (renamed from lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp)173
-rw-r--r--lldb/source/Plugins/ABI/X86/ABISysV_x86_64.h (renamed from lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h)23
-rw-r--r--lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp (renamed from lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp)997
-rw-r--r--lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.h (renamed from lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h)21
-rw-r--r--lldb/source/Plugins/ABI/X86/ABIX86.cpp43
-rw-r--r--lldb/source/Plugins/ABI/X86/ABIX86.h24
-rw-r--r--lldb/source/Plugins/ABI/X86/ABIX86_64.h26
-rw-r--r--lldb/source/Plugins/Architecture/Arm/ArchitectureArm.cpp4
-rw-r--r--lldb/source/Plugins/Architecture/Arm/ArchitectureArm.h6
-rw-r--r--lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp16
-rw-r--r--lldb/source/Plugins/Architecture/Mips/ArchitectureMips.h9
-rw-r--r--lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp4
-rw-r--r--lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.h6
-rw-r--r--lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp (renamed from lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp)158
-rw-r--r--lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h (renamed from lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h)6
-rw-r--r--lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp8
-rw-r--r--lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h10
-rw-r--r--lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp2
-rw-r--r--lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h6
-rw-r--r--lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp2
-rw-r--r--lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h4
-rw-r--r--lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp4
-rw-r--r--lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h12
-rw-r--r--lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp19
-rw-r--r--lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h9
-rw-r--r--lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp9
-rw-r--r--lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h6
-rw-r--r--lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp70
-rw-r--r--lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h48
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp50
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.h15
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp2
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.h7
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.cpp2
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h9
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp (renamed from lldb/source/Symbol/ClangASTImporter.cpp)309
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h (renamed from lldb/include/lldb/Symbol/ClangASTImporter.h)40
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangASTMetadata.cpp (renamed from lldb/source/Symbol/ClangASTMetadata.cpp)4
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangASTMetadata.h (renamed from lldb/include/lldb/Symbol/ClangASTMetadata.h)20
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp1154
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h166
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp7
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h12
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h6
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp400
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h115
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h13
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp357
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h18
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp142
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h38
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp2
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h19
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp88
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h66
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp8
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h7
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp10
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangHost.h4
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp65
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h7
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp26
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h28
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp155
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h12
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangUtil.cpp (renamed from lldb/source/Symbol/ClangUtil.cpp)13
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangUtil.h (renamed from lldb/include/lldb/Symbol/ClangUtil.h)8
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp16
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h7
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp2
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.h6
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp (renamed from lldb/source/Symbol/CxxModuleHandler.cpp)16
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.h (renamed from lldb/include/lldb/Symbol/CxxModuleHandler.h)6
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp8
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.h6
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp47
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h11
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/ModuleDependencyCollector.h4
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp179
-rw-r--r--lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.h124
-rw-r--r--lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp19
-rw-r--r--lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h6
-rw-r--r--lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp2
-rw-r--r--lldb/source/Plugins/Instruction/ARM/EmulationStateARM.h9
-rw-r--r--lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp59
-rw-r--r--lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h9
-rw-r--r--lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp8
-rw-r--r--lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h8
-rw-r--r--lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp8
-rw-r--r--lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h8
-rw-r--r--lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp6
-rw-r--r--lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h6
-rw-r--r--lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp (renamed from lldb/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp)48
-rw-r--r--lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.h (renamed from lldb/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h)14
-rw-r--r--lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp (renamed from lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp)65
-rw-r--r--lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h68
-rw-r--r--lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h67
-rw-r--r--lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp (renamed from lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp)118
-rw-r--r--lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.h (renamed from lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h)14
-rw-r--r--lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp (renamed from lldb/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp)55
-rw-r--r--lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.h (renamed from lldb/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h)14
-rw-r--r--lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp10
-rw-r--r--lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.h6
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp22
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/BlockPointer.h6
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp25
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h6
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp33
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h7
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp4
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.h6
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp261
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxx.h34
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp22
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h6
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp4
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp2
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp17
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp8
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp13
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp2
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp2
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp4
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp28
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.h6
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp2
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp6
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h6
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp2
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp2
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp2
-rw-r--r--lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h4
-rw-r--r--lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp3
-rw-r--r--lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.h6
-rw-r--r--lldb/source/Plugins/Language/ObjC/CF.cpp7
-rw-r--r--lldb/source/Plugins/Language/ObjC/CF.h6
-rw-r--r--lldb/source/Plugins/Language/ObjC/CFBasicHash.cpp114
-rw-r--r--lldb/source/Plugins/Language/ObjC/CFBasicHash.h76
-rw-r--r--lldb/source/Plugins/Language/ObjC/Cocoa.cpp22
-rw-r--r--lldb/source/Plugins/Language/ObjC/Cocoa.h6
-rw-r--r--lldb/source/Plugins/Language/ObjC/CoreMedia.cpp3
-rw-r--r--lldb/source/Plugins/Language/ObjC/CoreMedia.h6
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSArray.cpp79
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSDictionary.cpp330
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSDictionary.h9
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSError.cpp8
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSException.cpp6
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp6
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSSet.cpp213
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSSet.h6
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSString.cpp21
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSString.h6
-rw-r--r--lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp33
-rw-r--r--lldb/source/Plugins/Language/ObjC/ObjCLanguage.h6
-rw-r--r--lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp5
-rw-r--r--lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h6
-rw-r--r--lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp5
-rw-r--r--lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h13
-rw-r--r--lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp29
-rw-r--r--lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h19
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp64
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h26
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp76
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h10
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp83
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h14
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp11
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h12
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp132
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h32
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp145
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h14
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp46
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h22
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp254
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h78
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp16
-rw-r--r--lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h20
-rw-r--r--lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp4
-rw-r--r--lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h4
-rw-r--r--lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp39
-rw-r--r--lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h42
-rw-r--r--lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp2
-rw-r--r--lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.h6
-rw-r--r--lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp16
-rw-r--r--lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.h4
-rw-r--r--lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp11
-rw-r--r--lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h6
-rw-r--r--lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp6
-rw-r--r--lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h6
-rw-r--r--lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp4
-rw-r--r--lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.h6
-rw-r--r--lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp4
-rw-r--r--lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h6
-rw-r--r--lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp2
-rw-r--r--lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h6
-rw-r--r--lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp42
-rw-r--r--lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h9
-rw-r--r--lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp11
-rw-r--r--lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h6
-rw-r--r--lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp466
-rw-r--r--lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h151
-rw-r--r--lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp6
-rw-r--r--lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp4
-rw-r--r--lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h9
-rw-r--r--lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp8
-rw-r--r--lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h9
-rw-r--r--lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp4
-rw-r--r--lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h9
-rw-r--r--lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp157
-rw-r--r--lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h13
-rw-r--r--lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp96
-rw-r--r--lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h14
-rw-r--r--lldb/source/Plugins/Plugins.def.in37
-rw-r--r--lldb/source/Plugins/Process/Darwin/CFBundle.cpp68
-rw-r--r--lldb/source/Plugins/Process/Darwin/CFBundle.h35
-rw-r--r--lldb/source/Plugins/Process/Darwin/CFString.cpp153
-rw-r--r--lldb/source/Plugins/Process/Darwin/CFString.h40
-rw-r--r--lldb/source/Plugins/Process/Darwin/CFUtils.h75
-rw-r--r--lldb/source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp638
-rw-r--r--lldb/source/Plugins/Process/Darwin/DarwinProcessLauncher.h48
-rw-r--r--lldb/source/Plugins/Process/Darwin/LaunchFlavor.h32
-rw-r--r--lldb/source/Plugins/Process/Darwin/MachException.cpp514
-rw-r--r--lldb/source/Plugins/Process/Darwin/MachException.h139
-rw-r--r--lldb/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp1535
-rw-r--r--lldb/source/Plugins/Process/Darwin/NativeProcessDarwin.h337
-rw-r--r--lldb/source/Plugins/Process/Darwin/NativeThreadDarwin.cpp281
-rw-r--r--lldb/source/Plugins/Process/Darwin/NativeThreadDarwin.h165
-rw-r--r--lldb/source/Plugins/Process/Darwin/NativeThreadListDarwin.cpp702
-rw-r--r--lldb/source/Plugins/Process/Darwin/NativeThreadListDarwin.h138
-rw-r--r--lldb/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp22
-rw-r--r--lldb/source/Plugins/Process/FreeBSD/FreeBSDThread.h2
-rw-r--r--lldb/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp2
-rw-r--r--lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp8
-rw-r--r--lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp6
-rw-r--r--lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp2
-rw-r--r--lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp8
-rw-r--r--lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h4
-rw-r--r--lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp2
-rw-r--r--lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp2
-rw-r--r--lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp2
-rw-r--r--lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp4
-rw-r--r--lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp2
-rw-r--r--lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp614
-rw-r--r--lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h15
-rw-r--r--lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp2
-rw-r--r--lldb/source/Plugins/Process/POSIX/CrashReason.cpp2
-rw-r--r--lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp7
-rw-r--r--lldb/source/Plugins/Process/POSIX/NativeProcessELF.h10
-rw-r--r--lldb/source/Plugins/Process/POSIX/ProcessMessage.cpp2
-rw-r--r--lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp3
-rw-r--r--lldb/source/Plugins/Process/Utility/ARMDefines.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/ARMUtils.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/AuxVector.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/AuxVector.h4
-rw-r--r--lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp4
-rw-r--r--lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/FreeBSDSignals.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/FreeBSDSignals.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/GDBRemoteSignals.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/GDBRemoteSignals.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/HistoryThread.cpp8
-rw-r--r--lldb/source/Plugins/Process/Utility/HistoryThread.h9
-rw-r--r--lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp13
-rw-r--r--lldb/source/Plugins/Process/Utility/HistoryUnwind.h12
-rw-r--r--lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/InstructionUtils.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/LinuxProcMaps.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/LinuxProcMaps.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/LinuxSignals.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/LinuxSignals.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/MipsLinuxSignals.cpp3
-rw-r--r--lldb/source/Plugins/Process/Utility/MipsLinuxSignals.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/NetBSDSignals.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/NetBSDSignals.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp3
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextDummy.cpp3
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextDummy.h9
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.h4
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h4
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h4
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextHistory.cpp3
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextHistory.h10
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.h4
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips.h4
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h4
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextLinux_s390x.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextLinux_s390x.h4
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h4
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp160
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h56
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextMach_arm.h7
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextMach_i386.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextMach_x86_64.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextMemory.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextMemory.h10
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.cpp96
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.h25
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp59
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h7
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.h4
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h4
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp31
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h11
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp176
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h54
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp13
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h8
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp31
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h11
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp30
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.h10
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp30
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h11
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp30
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h11
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h10
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextWindows_i386.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextWindows_i386.h4
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextWindows_x86_64.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContextWindows_x86_64.h4
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContext_mips.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContext_powerpc.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContext_s390x.h4
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterContext_x86.h4
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterInfoAndSetInterface.h36
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterInfoInterface.h5
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp127
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h28
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.cpp2
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.h4
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterInfos_arm64.h37
-rw-r--r--lldb/source/Plugins/Process/Utility/RegisterInfos_i386.h2
-rw-r--r--lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp63
-rw-r--r--lldb/source/Plugins/Process/Utility/StopInfoMachException.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/ThreadMemory.cpp18
-rw-r--r--lldb/source/Plugins/Process/Utility/ThreadMemory.h9
-rw-r--r--lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp247
-rw-r--r--lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h54
-rw-r--r--lldb/source/Plugins/Process/Utility/lldb-arm-register-enums.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/lldb-arm64-register-enums.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/lldb-mips-linux-register-enums.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/lldb-ppc64-register-enums.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/lldb-ppc64le-register-enums.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/lldb-s390x-register-enums.h6
-rw-r--r--lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h11
-rw-r--r--lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp4
-rw-r--r--lldb/source/Plugins/Process/elf-core/ProcessElfCore.h9
-rw-r--r--lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp12
-rw-r--r--lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h6
-rw-r--r--lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp32
-rw-r--r--lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h9
-rw-r--r--lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp2
-rw-r--r--lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h6
-rw-r--r--lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp2
-rw-r--r--lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h6
-rw-r--r--lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp2
-rw-r--r--lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.h6
-rw-r--r--lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp2
-rw-r--r--lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h6
-rw-r--r--lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp2
-rw-r--r--lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h6
-rw-r--r--lldb/source/Plugins/Process/elf-core/RegisterUtilities.cpp2
-rw-r--r--lldb/source/Plugins/Process/elf-core/RegisterUtilities.h6
-rw-r--r--lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp37
-rw-r--r--lldb/source/Plugins/Process/elf-core/ThreadElfCore.h6
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp4
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h6
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp72
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h13
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp131
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h32
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp2
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h6
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp39
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h14
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp2
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h10
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp14
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h6
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp360
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h15
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp4
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h11
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp2
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h14
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp359
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h16
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp2
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h7
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td4
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp6
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h6
-rw-r--r--lldb/source/Plugins/Process/minidump/MinidumpParser.cpp2
-rw-r--r--lldb/source/Plugins/Process/minidump/MinidumpParser.h7
-rw-r--r--lldb/source/Plugins/Process/minidump/MinidumpTypes.cpp2
-rw-r--r--lldb/source/Plugins/Process/minidump/MinidumpTypes.h7
-rw-r--r--lldb/source/Plugins/Process/minidump/NtStructures.h6
-rw-r--r--lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp12
-rw-r--r--lldb/source/Plugins/Process/minidump/ProcessMinidump.h6
-rw-r--r--lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp2
-rw-r--r--lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h6
-rw-r--r--lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp2
-rw-r--r--lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h6
-rw-r--r--lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp2
-rw-r--r--lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h6
-rw-r--r--lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp2
-rw-r--r--lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h6
-rw-r--r--lldb/source/Plugins/Process/minidump/ThreadMinidump.cpp2
-rw-r--r--lldb/source/Plugins/Process/minidump/ThreadMinidump.h6
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp32
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h1
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp56
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h2
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp4
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h6
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp95
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h30
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp230
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h2
-rw-r--r--lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp14
-rw-r--r--lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h8
-rw-r--r--lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp54
-rw-r--r--lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h12
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp135
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h42
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DIERef.h16
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h6
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp1295
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h72
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h6
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h6
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp34
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h16
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp24
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h9
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp45
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h11
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp110
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h16
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp5
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h6
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h6
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp9
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h6
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h6
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp27
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h14
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp450
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h47
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h6
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h6
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h7
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp317
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.h46
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp50
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h6
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp58
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h80
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h6
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp216
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h41
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp176
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h55
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp226
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h54
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h6
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp273
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h54
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp34
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h19
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp1391
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h117
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp32
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h21
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp91
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h34
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp37
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h39
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp138
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h50
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td4
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h6
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.h4
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp4
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h4
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.h5
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp64
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h14
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.h4
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.h4
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/PdbSymUid.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h4
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h4
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp31
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h14
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp90
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h14
-rw-r--r--lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp156
-rw-r--r--lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.h14
-rw-r--r--lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h4
-rw-r--r--lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp95
-rw-r--r--lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h18
-rw-r--r--lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp4
-rw-r--r--lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h9
-rw-r--r--lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp4
-rw-r--r--lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h9
-rw-r--r--lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.cpp147
-rw-r--r--lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.h45
-rw-r--r--lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (renamed from lldb/source/Symbol/ClangASTContext.cpp)1745
-rw-r--r--lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h (renamed from lldb/include/lldb/Symbol/ClangASTContext.h)257
-rw-r--r--lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp50
-rw-r--r--lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h6
-rw-r--r--lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp6
-rw-r--r--lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h6
-rw-r--r--lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp2
-rw-r--r--lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h10
-rw-r--r--lldb/source/Symbol/ArmUnwindInfo.cpp4
-rw-r--r--lldb/source/Symbol/Block.cpp2
-rw-r--r--lldb/source/Symbol/ClangExternalASTSourceCallbacks.cpp45
-rw-r--r--lldb/source/Symbol/CompactUnwindInfo.cpp2
-rw-r--r--lldb/source/Symbol/CompileUnit.cpp2
-rw-r--r--lldb/source/Symbol/CompilerDecl.cpp2
-rw-r--r--lldb/source/Symbol/CompilerDeclContext.cpp2
-rw-r--r--lldb/source/Symbol/CompilerType.cpp45
-rw-r--r--lldb/source/Symbol/DWARFCallFrameInfo.cpp4
-rw-r--r--lldb/source/Symbol/DebugMacros.cpp2
-rw-r--r--lldb/source/Symbol/DeclVendor.cpp2
-rw-r--r--lldb/source/Symbol/Declaration.cpp2
-rw-r--r--lldb/source/Symbol/FuncUnwinders.cpp2
-rw-r--r--lldb/source/Symbol/Function.cpp95
-rw-r--r--lldb/source/Symbol/LineEntry.cpp2
-rw-r--r--lldb/source/Symbol/LineTable.cpp26
-rw-r--r--lldb/source/Symbol/LocateSymbolFile.cpp2
-rw-r--r--lldb/source/Symbol/LocateSymbolFileMacOSX.cpp72
-rw-r--r--lldb/source/Symbol/ObjectFile.cpp13
-rw-r--r--lldb/source/Symbol/PostfixExpression.cpp2
-rw-r--r--lldb/source/Symbol/Symbol.cpp21
-rw-r--r--lldb/source/Symbol/SymbolContext.cpp22
-rw-r--r--lldb/source/Symbol/SymbolFile.cpp8
-rw-r--r--lldb/source/Symbol/SymbolVendor.cpp4
-rw-r--r--lldb/source/Symbol/Symtab.cpp6
-rw-r--r--lldb/source/Symbol/Type.cpp37
-rw-r--r--lldb/source/Symbol/TypeList.cpp5
-rw-r--r--lldb/source/Symbol/TypeMap.cpp9
-rw-r--r--lldb/source/Symbol/TypeSystem.cpp25
-rw-r--r--lldb/source/Symbol/UnwindPlan.cpp14
-rw-r--r--lldb/source/Symbol/UnwindTable.cpp16
-rw-r--r--lldb/source/Symbol/Variable.cpp17
-rw-r--r--lldb/source/Symbol/VariableList.cpp2
-rw-r--r--lldb/source/Target/ABI.cpp63
-rw-r--r--lldb/source/Target/AssertFrameRecognizer.cpp168
-rw-r--r--lldb/source/Target/ExecutionContext.cpp2
-rw-r--r--lldb/source/Target/InstrumentationRuntime.cpp2
-rw-r--r--lldb/source/Target/InstrumentationRuntimeStopInfo.cpp2
-rw-r--r--lldb/source/Target/JITLoader.cpp2
-rw-r--r--lldb/source/Target/JITLoaderList.cpp2
-rw-r--r--lldb/source/Target/Language.cpp10
-rw-r--r--lldb/source/Target/LanguageRuntime.cpp17
-rw-r--r--lldb/source/Target/Memory.cpp11
-rw-r--r--lldb/source/Target/MemoryHistory.cpp2
-rw-r--r--lldb/source/Target/MemoryRegionInfo.cpp2
-rw-r--r--lldb/source/Target/ModuleCache.cpp4
-rw-r--r--lldb/source/Target/OperatingSystem.cpp2
-rw-r--r--lldb/source/Target/PathMappingList.cpp2
-rw-r--r--lldb/source/Target/Platform.cpp91
-rw-r--r--lldb/source/Target/Process.cpp523
-rw-r--r--lldb/source/Target/Queue.cpp2
-rw-r--r--lldb/source/Target/QueueItem.cpp2
-rw-r--r--lldb/source/Target/QueueList.cpp2
-rw-r--r--lldb/source/Target/RegisterContext.cpp31
-rw-r--r--lldb/source/Target/RegisterContextUnwind.cpp (renamed from lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp)157
-rw-r--r--lldb/source/Target/RegisterNumber.cpp2
-rw-r--r--lldb/source/Target/RemoteAwarePlatform.cpp150
-rw-r--r--lldb/source/Target/SectionLoadHistory.cpp2
-rw-r--r--lldb/source/Target/SectionLoadList.cpp4
-rw-r--r--lldb/source/Target/StackFrame.cpp68
-rw-r--r--lldb/source/Target/StackFrameList.cpp126
-rw-r--r--lldb/source/Target/StackFrameRecognizer.cpp63
-rw-r--r--lldb/source/Target/StackID.cpp2
-rw-r--r--lldb/source/Target/StopInfo.cpp14
-rw-r--r--lldb/source/Target/StructuredDataPlugin.cpp2
-rw-r--r--lldb/source/Target/SystemRuntime.cpp2
-rw-r--r--lldb/source/Target/Target.cpp207
-rw-r--r--lldb/source/Target/TargetList.cpp4
-rw-r--r--lldb/source/Target/TargetProperties.td29
-rw-r--r--lldb/source/Target/Thread.cpp551
-rw-r--r--lldb/source/Target/ThreadCollection.cpp2
-rw-r--r--lldb/source/Target/ThreadList.cpp10
-rw-r--r--lldb/source/Target/ThreadPlan.cpp62
-rw-r--r--lldb/source/Target/ThreadPlanBase.cpp28
-rw-r--r--lldb/source/Target/ThreadPlanCallFunction.cpp41
-rw-r--r--lldb/source/Target/ThreadPlanCallFunctionUsingABI.cpp10
-rw-r--r--lldb/source/Target/ThreadPlanCallOnFunctionExit.cpp2
-rw-r--r--lldb/source/Target/ThreadPlanCallUserExpression.cpp5
-rw-r--r--lldb/source/Target/ThreadPlanPython.cpp31
-rw-r--r--lldb/source/Target/ThreadPlanRunToAddress.cpp21
-rw-r--r--lldb/source/Target/ThreadPlanShouldStopHere.cpp2
-rw-r--r--lldb/source/Target/ThreadPlanStack.cpp508
-rw-r--r--lldb/source/Target/ThreadPlanStepInRange.cpp48
-rw-r--r--lldb/source/Target/ThreadPlanStepInstruction.cpp44
-rw-r--r--lldb/source/Target/ThreadPlanStepOut.cpp86
-rw-r--r--lldb/source/Target/ThreadPlanStepOverBreakpoint.cpp22
-rw-r--r--lldb/source/Target/ThreadPlanStepOverRange.cpp51
-rw-r--r--lldb/source/Target/ThreadPlanStepRange.cpp64
-rw-r--r--lldb/source/Target/ThreadPlanStepThrough.cpp32
-rw-r--r--lldb/source/Target/ThreadPlanStepUntil.cpp84
-rw-r--r--lldb/source/Target/ThreadPlanTracer.cpp54
-rw-r--r--lldb/source/Target/ThreadSpec.cpp2
-rw-r--r--lldb/source/Target/UnixSignals.cpp8
-rw-r--r--lldb/source/Target/UnwindAssembly.cpp2
-rw-r--r--lldb/source/Target/UnwindLLDB.cpp (renamed from lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp)19
-rw-r--r--lldb/source/Utility/ARM64_DWARF_Registers.h68
-rw-r--r--lldb/source/Utility/ARM64_ehframe_Registers.h72
-rw-r--r--lldb/source/Utility/ARM_DWARF_Registers.h6
-rw-r--r--lldb/source/Utility/ARM_ehframe_Registers.h6
-rw-r--r--lldb/source/Utility/ArchSpec.cpp27
-rw-r--r--lldb/source/Utility/Args.cpp31
-rw-r--r--lldb/source/Utility/Baton.cpp2
-rw-r--r--lldb/source/Utility/Broadcaster.cpp12
-rw-r--r--lldb/source/Utility/CompletionRequest.cpp2
-rw-r--r--lldb/source/Utility/Connection.cpp2
-rw-r--r--lldb/source/Utility/ConstString.cpp48
-rw-r--r--lldb/source/Utility/DataBufferHeap.cpp2
-rw-r--r--lldb/source/Utility/DataBufferLLVM.cpp2
-rw-r--r--lldb/source/Utility/DataEncoder.cpp2
-rw-r--r--lldb/source/Utility/DataExtractor.cpp147
-rw-r--r--lldb/source/Utility/Environment.cpp2
-rw-r--r--lldb/source/Utility/Event.cpp4
-rw-r--r--lldb/source/Utility/FileSpec.cpp18
-rw-r--r--lldb/source/Utility/IOObject.cpp2
-rw-r--r--lldb/source/Utility/LLDBAssert.cpp2
-rw-r--r--lldb/source/Utility/Listener.cpp2
-rw-r--r--lldb/source/Utility/Log.cpp4
-rw-r--r--lldb/source/Utility/Logging.cpp2
-rw-r--r--lldb/source/Utility/NameMatches.cpp2
-rw-r--r--lldb/source/Utility/PPC64LE_DWARF_Registers.h6
-rw-r--r--lldb/source/Utility/PPC64_DWARF_Registers.h6
-rw-r--r--lldb/source/Utility/ProcessInfo.cpp102
-rw-r--r--lldb/source/Utility/RegisterValue.cpp9
-rw-r--r--lldb/source/Utility/RegularExpression.cpp8
-rw-r--r--lldb/source/Utility/Reproducer.cpp88
-rw-r--r--lldb/source/Utility/ReproducerInstrumentation.cpp118
-rw-r--r--lldb/source/Utility/Scalar.cpp2193
-rw-r--r--lldb/source/Utility/SelectHelper.cpp2
-rw-r--r--lldb/source/Utility/SharingPtr.cpp134
-rw-r--r--lldb/source/Utility/State.cpp2
-rw-r--r--lldb/source/Utility/Status.cpp14
-rw-r--r--lldb/source/Utility/Stream.cpp22
-rw-r--r--lldb/source/Utility/StreamCallback.cpp2
-rw-r--r--lldb/source/Utility/StreamString.cpp2
-rw-r--r--lldb/source/Utility/StringExtractor.cpp5
-rw-r--r--lldb/source/Utility/StringExtractorGDBRemote.cpp2
-rw-r--r--lldb/source/Utility/StringLexer.cpp2
-rw-r--r--lldb/source/Utility/StringList.cpp4
-rw-r--r--lldb/source/Utility/StructuredData.cpp4
-rw-r--r--lldb/source/Utility/TildeExpressionResolver.cpp2
-rw-r--r--lldb/source/Utility/Timer.cpp3
-rw-r--r--lldb/source/Utility/UUID.cpp45
-rw-r--r--lldb/source/Utility/UriParser.cpp4
-rw-r--r--lldb/source/Utility/UserID.cpp2
-rw-r--r--lldb/source/Utility/UserIDResolver.cpp2
-rw-r--r--lldb/source/Utility/VASprintf.cpp2
-rw-r--r--lldb/source/Utility/VMRange.cpp2
-rw-r--r--lldb/source/Utility/XcodeSDK.cpp309
-rw-r--r--lldb/source/lldb.cpp6
-rw-r--r--lldb/tools/driver/Driver.cpp180
-rw-r--r--lldb/tools/driver/Driver.h6
-rw-r--r--lldb/tools/driver/Options.td8
-rw-r--r--lldb/tools/driver/Platform.h6
-rw-r--r--lldb/tools/lldb-instr/Instrument.cpp7
-rw-r--r--lldb/tools/lldb-mi/lldb-mi.exports0
-rw-r--r--lldb/tools/lldb-server/Acceptor.cpp2
-rw-r--r--lldb/tools/lldb-server/Acceptor.h6
-rw-r--r--lldb/tools/lldb-server/LLDBServerUtilities.h6
-rw-r--r--lldb/tools/lldb-server/SystemInitializerLLGS.h6
-rw-r--r--lldb/tools/lldb-server/lldb-platform.cpp4
-rw-r--r--lldb/utils/TableGen/LLDBOptionDefEmitter.cpp8
-rw-r--r--lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp15
-rw-r--r--lldb/utils/TableGen/LLDBTableGenBackends.h4
-rw-r--r--lldb/utils/TableGen/LLDBTableGenUtils.h4
1631 files changed, 42610 insertions, 36348 deletions
diff --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig
new file mode 100644
index 000000000000..6e1668ea4c42
--- /dev/null
+++ b/lldb/bindings/headers.swig
@@ -0,0 +1,79 @@
+/* C++ headers to be included. */
+%{
+#include <algorithm>
+#include <string>
+%}
+
+/* The liblldb header files to be included. */
+%{
+#include "lldb/lldb-public.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"
+#include "lldb/API/SBBreakpointName.h"
+#include "lldb/API/SBBroadcaster.h"
+#include "lldb/API/SBCommandInterpreter.h"
+#include "lldb/API/SBCommandInterpreterRunOptions.h"
+#include "lldb/API/SBCommandReturnObject.h"
+#include "lldb/API/SBCommunication.h"
+#include "lldb/API/SBCompileUnit.h"
+#include "lldb/API/SBData.h"
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBDeclaration.h"
+#include "lldb/API/SBEnvironment.h"
+#include "lldb/API/SBError.h"
+#include "lldb/API/SBEvent.h"
+#include "lldb/API/SBExecutionContext.h"
+#include "lldb/API/SBExpressionOptions.h"
+#include "lldb/API/SBFile.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/SBMemoryRegionInfo.h"
+#include "lldb/API/SBMemoryRegionInfoList.h"
+#include "lldb/API/SBModule.h"
+#include "lldb/API/SBModuleSpec.h"
+#include "lldb/API/SBPlatform.h"
+#include "lldb/API/SBProcess.h"
+#include "lldb/API/SBProcessInfo.h"
+#include "lldb/API/SBQueue.h"
+#include "lldb/API/SBQueueItem.h"
+#include "lldb/API/SBReproducer.h"
+#include "lldb/API/SBSection.h"
+#include "lldb/API/SBSourceManager.h"
+#include "lldb/API/SBStream.h"
+#include "lldb/API/SBStringList.h"
+#include "lldb/API/SBStructuredData.h"
+#include "lldb/API/SBSymbol.h"
+#include "lldb/API/SBSymbolContext.h"
+#include "lldb/API/SBSymbolContextList.h"
+#include "lldb/API/SBTarget.h"
+#include "lldb/API/SBThread.h"
+#include "lldb/API/SBThreadCollection.h"
+#include "lldb/API/SBThreadPlan.h"
+#include "lldb/API/SBTrace.h"
+#include "lldb/API/SBTraceOptions.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"
+%}
diff --git a/lldb/bindings/interface/SBAddress.i b/lldb/bindings/interface/SBAddress.i
new file mode 100644
index 000000000000..6fd06c83d293
--- /dev/null
+++ b/lldb/bindings/interface/SBAddress.i
@@ -0,0 +1,192 @@
+//===-- SWIG Interface for SBAddress ----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"A section + offset based address class.
+
+The SBAddress class allows addresses to be relative to a section
+that can move during runtime due to images (executables, shared
+libraries, bundles, frameworks) being loaded at different
+addresses than the addresses found in the object file that
+represents them on disk. There are currently two types of addresses
+for a section:
+ o file addresses
+ o load addresses
+
+File addresses represents the virtual addresses that are in the 'on
+disk' object files. These virtual addresses are converted to be
+relative to unique sections scoped to the object file so that
+when/if the addresses slide when the images are loaded/unloaded
+in memory, we can easily track these changes without having to
+update every object (compile unit ranges, line tables, function
+address ranges, lexical block and inlined subroutine address
+ranges, global and static variables) each time an image is loaded or
+unloaded.
+
+Load addresses represents the virtual addresses where each section
+ends up getting loaded at runtime. Before executing a program, it
+is common for all of the load addresses to be unresolved. When a
+DynamicLoader plug-in receives notification that shared libraries
+have been loaded/unloaded, the load addresses of the main executable
+and any images (shared libraries) will be resolved/unresolved. When
+this happens, breakpoints that are in one of these sections can be
+set/cleared.
+
+See docstring of SBFunction for example usage of SBAddress."
+) SBAddress;
+class SBAddress
+{
+public:
+
+ SBAddress ();
+
+ SBAddress (const lldb::SBAddress &rhs);
+
+ SBAddress (lldb::SBSection section,
+ lldb::addr_t offset);
+
+ %feature("docstring", "
+ Create an address by resolving a load address using the supplied target.") SBAddress;
+ SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target);
+
+ ~SBAddress ();
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+#ifdef SWIGPYTHON
+ // operator== is a free function, which swig does not handle, so we inject
+ // our own equality operator here
+ %pythoncode%{
+ def __eq__(self, other):
+ return not self.__ne__(other)
+ %}
+#endif
+
+ bool operator!=(const SBAddress &rhs) const;
+
+ void
+ Clear ();
+
+ addr_t
+ GetFileAddress () const;
+
+ addr_t
+ GetLoadAddress (const lldb::SBTarget &target) const;
+
+ void
+ SetLoadAddress (lldb::addr_t load_addr,
+ lldb::SBTarget &target);
+
+ bool
+ OffsetAddress (addr_t offset);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ lldb::SBSection
+ GetSection ();
+
+ lldb::addr_t
+ SBAddress::GetOffset ();
+
+ void
+ SetAddress (lldb::SBSection section,
+ lldb::addr_t offset);
+
+ %feature("docstring", "
+ GetSymbolContext() and the following can lookup symbol information for a given address.
+ An address might refer to code or data from an existing module, or it
+ might refer to something on the stack or heap. The following functions
+ will only return valid values if the address has been resolved to a code
+ or data address using 'void SBAddress::SetLoadAddress(...)' or
+ 'lldb::SBAddress SBTarget::ResolveLoadAddress (...)'.") GetSymbolContext;
+ lldb::SBSymbolContext
+ GetSymbolContext (uint32_t resolve_scope);
+
+ %feature("docstring", "
+ GetModule() and the following grab individual objects for a given address and
+ are less efficient if you want more than one symbol related objects.
+ Use one of the following when you want multiple debug symbol related
+ objects for an address:
+ lldb::SBSymbolContext SBAddress::GetSymbolContext (uint32_t resolve_scope);
+ lldb::SBSymbolContext SBTarget::ResolveSymbolContextForAddress (const SBAddress &addr, uint32_t resolve_scope);
+ One or more bits from the SymbolContextItem enumerations can be logically
+ OR'ed together to more efficiently retrieve multiple symbol objects.") GetModule;
+ lldb::SBModule
+ GetModule ();
+
+ lldb::SBCompileUnit
+ GetCompileUnit ();
+
+ lldb::SBFunction
+ GetFunction ();
+
+ lldb::SBBlock
+ GetBlock ();
+
+ lldb::SBSymbol
+ GetSymbol ();
+
+ lldb::SBLineEntry
+ GetLineEntry ();
+
+ STRING_EXTENSION(SBAddress)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ __runtime_error_str = 'This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.'
+
+ def __get_load_addr_property__ (self):
+ '''Get the load address for a lldb.SBAddress using the current target. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.'''
+ if not target:
+ raise RuntimeError(self.__runtime_error_str)
+ return self.GetLoadAddress (target)
+
+ def __set_load_addr_property__ (self, load_addr):
+ '''Set the load address for a lldb.SBAddress using the current target. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.'''
+ if not target:
+ raise RuntimeError(self.__runtime_error_str)
+ return self.SetLoadAddress (load_addr, target)
+
+ def __int__(self):
+ '''Convert an address to a load address if there is a process and that process is alive, or to a file address otherwise. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.'''
+ if not process or not target:
+ raise RuntimeError(self.__runtime_error_str)
+ if process.is_alive:
+ return self.GetLoadAddress (target)
+ return self.GetFileAddress ()
+
+ def __oct__(self):
+ '''Convert the address to an octal string. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.'''
+ return '%o' % int(self)
+
+ def __hex__(self):
+ '''Convert the address to an hex string. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.'''
+ return '0x%x' % int(self)
+
+ module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) that this address resides within.''')
+ compile_unit = property(GetCompileUnit, None, doc='''A read only property that returns an lldb object that represents the compile unit (lldb.SBCompileUnit) that this address resides within.''')
+ line_entry = property(GetLineEntry, None, doc='''A read only property that returns an lldb object that represents the line entry (lldb.SBLineEntry) that this address resides within.''')
+ function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) that this address resides within.''')
+ block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) that this address resides within.''')
+ symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) that this address resides within.''')
+ offset = property(GetOffset, None, doc='''A read only property that returns the section offset in bytes as an integer.''')
+ section = property(GetSection, None, doc='''A read only property that returns an lldb object that represents the section (lldb.SBSection) that this address resides within.''')
+ file_addr = property(GetFileAddress, None, doc='''A read only property that returns file address for the section as an integer. This is the address that represents the address as it is found in the object file that defines it.''')
+ load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. This resolves the SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command). For things like Python based commands and breakpoint callbacks use GetLoadAddress instead.''')
+ %}
+#endif
+
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBAttachInfo.i b/lldb/bindings/interface/SBAttachInfo.i
new file mode 100644
index 000000000000..3f4634e14619
--- /dev/null
+++ b/lldb/bindings/interface/SBAttachInfo.i
@@ -0,0 +1,115 @@
+//===-- SWIG Interface for SBAttachInfo--------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBAttachInfo
+{
+public:
+ SBAttachInfo ();
+
+ SBAttachInfo (lldb::pid_t pid);
+
+ SBAttachInfo (const char *path, bool wait_for);
+
+ SBAttachInfo (const char *path, bool wait_for, bool async);
+
+ SBAttachInfo (const lldb::SBAttachInfo &rhs);
+
+ lldb::pid_t
+ GetProcessID ();
+
+ void
+ SetProcessID (lldb::pid_t pid);
+
+ void
+ SetExecutable (const char *path);
+
+ void
+ SetExecutable (lldb::SBFileSpec exe_file);
+
+ bool
+ GetWaitForLaunch ();
+
+ void
+ SetWaitForLaunch (bool b);
+
+ void
+ SetWaitForLaunch (bool b, bool async);
+
+ bool
+ GetIgnoreExisting ();
+
+ void
+ SetIgnoreExisting (bool b);
+
+ uint32_t
+ GetResumeCount ();
+
+ void
+ SetResumeCount (uint32_t c);
+
+ const char *
+ GetProcessPluginName ();
+
+ void
+ SetProcessPluginName (const char *plugin_name);
+
+ uint32_t
+ GetUserID();
+
+ uint32_t
+ GetGroupID();
+
+ bool
+ UserIDIsValid ();
+
+ bool
+ GroupIDIsValid ();
+
+ void
+ SetUserID (uint32_t uid);
+
+ void
+ SetGroupID (uint32_t gid);
+
+ uint32_t
+ GetEffectiveUserID();
+
+ uint32_t
+ GetEffectiveGroupID();
+
+ bool
+ EffectiveUserIDIsValid ();
+
+ bool
+ EffectiveGroupIDIsValid ();
+
+ void
+ SetEffectiveUserID (uint32_t uid);
+
+ void
+ SetEffectiveGroupID (uint32_t gid);
+
+ lldb::pid_t
+ GetParentProcessID ();
+
+ void
+ SetParentProcessID (lldb::pid_t pid);
+
+ bool
+ ParentProcessIDIsValid();
+
+ lldb::SBListener
+ GetListener ();
+
+ void
+ SetListener (lldb::SBListener &listener);
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBBlock.i b/lldb/bindings/interface/SBBlock.i
new file mode 100644
index 000000000000..812b41fe5c3e
--- /dev/null
+++ b/lldb/bindings/interface/SBBlock.i
@@ -0,0 +1,163 @@
+//===-- SWIG Interface for SBBlock ------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a lexical block. SBFunction contains SBBlock(s)."
+) SBBlock;
+class SBBlock
+{
+public:
+
+ SBBlock ();
+
+ SBBlock (const lldb::SBBlock &rhs);
+
+ ~SBBlock ();
+
+ %feature("docstring",
+ "Does this block represent an inlined function?"
+ ) IsInlined;
+ bool
+ IsInlined () const;
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+ %feature("docstring", "
+ Get the function name if this block represents an inlined function;
+ otherwise, return None.") GetInlinedName;
+ const char *
+ GetInlinedName () const;
+
+ %feature("docstring", "
+ Get the call site file if this block represents an inlined function;
+ otherwise, return an invalid file spec.") GetInlinedCallSiteFile;
+ lldb::SBFileSpec
+ GetInlinedCallSiteFile () const;
+
+ %feature("docstring", "
+ Get the call site line if this block represents an inlined function;
+ otherwise, return 0.") GetInlinedCallSiteLine;
+ uint32_t
+ GetInlinedCallSiteLine () const;
+
+ %feature("docstring", "
+ Get the call site column if this block represents an inlined function;
+ otherwise, return 0.") GetInlinedCallSiteColumn;
+ uint32_t
+ GetInlinedCallSiteColumn () const;
+
+ %feature("docstring", "Get the parent block.") GetParent;
+ lldb::SBBlock
+ GetParent ();
+
+ %feature("docstring", "Get the inlined block that is or contains this block.") GetContainingInlinedBlock;
+ lldb::SBBlock
+ GetContainingInlinedBlock ();
+
+ %feature("docstring", "Get the sibling block for this block.") GetSibling;
+ lldb::SBBlock
+ GetSibling ();
+
+ %feature("docstring", "Get the first child block.") GetFirstChild;
+ lldb::SBBlock
+ GetFirstChild ();
+
+ uint32_t
+ GetNumRanges ();
+
+ lldb::SBAddress
+ GetRangeStartAddress (uint32_t idx);
+
+ lldb::SBAddress
+ GetRangeEndAddress (uint32_t idx);
+
+ uint32_t
+ GetRangeIndexForBlockAddress (lldb::SBAddress block_addr);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ lldb::SBValueList
+ GetVariables (lldb::SBFrame& frame,
+ bool arguments,
+ bool locals,
+ bool statics,
+ lldb::DynamicValueType use_dynamic);
+
+ lldb::SBValueList
+ GetVariables (lldb::SBTarget& target,
+ bool arguments,
+ bool locals,
+ bool statics);
+
+ STRING_EXTENSION(SBBlock)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ def get_range_at_index(self, idx):
+ if idx < self.GetNumRanges():
+ return [self.GetRangeStartAddress(idx), self.GetRangeEndAddress(idx)]
+ return []
+
+ class ranges_access(object):
+ '''A helper object that will lazily hand out an array of lldb.SBAddress that represent address ranges for a block.'''
+ def __init__(self, sbblock):
+ self.sbblock = sbblock
+
+ def __len__(self):
+ if self.sbblock:
+ return int(self.sbblock.GetNumRanges())
+ return 0
+
+ def __getitem__(self, key):
+ count = len(self)
+ if type(key) is int:
+ return self.sbblock.get_range_at_index (key);
+ if isinstance(key, SBAddress):
+ range_idx = self.sbblock.GetRangeIndexForBlockAddress(key);
+ if range_idx < len(self):
+ return [self.sbblock.GetRangeStartAddress(range_idx), self.sbblock.GetRangeEndAddress(range_idx)]
+ else:
+ print("error: unsupported item type: %s" % type(key))
+ return None
+
+ def get_ranges_access_object(self):
+ '''An accessor function that returns a ranges_access() object which allows lazy block address ranges access.'''
+ return self.ranges_access (self)
+
+ def get_ranges_array(self):
+ '''An accessor function that returns an array object that contains all ranges in this block object.'''
+ if not hasattr(self, 'ranges_array'):
+ self.ranges_array = []
+ for idx in range(self.num_ranges):
+ self.ranges_array.append ([self.GetRangeStartAddress(idx), self.GetRangeEndAddress(idx)])
+ return self.ranges_array
+
+ def get_call_site(self):
+ return declaration(self.GetInlinedCallSiteFile(), self.GetInlinedCallSiteLine(), self.GetInlinedCallSiteColumn())
+
+ parent = property(GetParent, None, doc='''A read only property that returns the same result as GetParent().''')
+ first_child = property(GetFirstChild, None, doc='''A read only property that returns the same result as GetFirstChild().''')
+ call_site = property(get_call_site, None, doc='''A read only property that returns a lldb.declaration object that contains the inlined call site file, line and column.''')
+ sibling = property(GetSibling, None, doc='''A read only property that returns the same result as GetSibling().''')
+ name = property(GetInlinedName, None, doc='''A read only property that returns the same result as GetInlinedName().''')
+ inlined_block = property(GetContainingInlinedBlock, None, doc='''A read only property that returns the same result as GetContainingInlinedBlock().''')
+ range = property(get_ranges_access_object, None, doc='''A read only property that allows item access to the address ranges for a block by integer (range = block.range[0]) and by lldb.SBAddress (find the range that contains the specified lldb.SBAddress like "pc_range = lldb.frame.block.range[frame.addr]").''')
+ ranges = property(get_ranges_array, None, doc='''A read only property that returns a list() object that contains all of the address ranges for the block.''')
+ num_ranges = property(GetNumRanges, None, doc='''A read only property that returns the same result as GetNumRanges().''')
+ %}
+#endif
+
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBBreakpoint.i b/lldb/bindings/interface/SBBreakpoint.i
new file mode 100644
index 000000000000..a2d747db0bf6
--- /dev/null
+++ b/lldb/bindings/interface/SBBreakpoint.i
@@ -0,0 +1,337 @@
+//===-- SWIG Interface for SBBreakpoint -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+namespace lldb {
+
+%feature("docstring",
+"Represents a logical breakpoint and its associated settings.
+
+For example (from test/functionalities/breakpoint/breakpoint_ignore_count/
+TestBreakpointIgnoreCount.py),
+
+ def breakpoint_ignore_count_python(self):
+ '''Use Python APIs to set breakpoint ignore count.'''
+ exe = os.path.join(os.getcwd(), 'a.out')
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Now create a breakpoint on main.c by name 'c'.
+ breakpoint = target.BreakpointCreateByName('c', 'a.out')
+ self.assertTrue(breakpoint and
+ breakpoint.GetNumLocations() == 1,
+ VALID_BREAKPOINT)
+
+ # Get the breakpoint location from breakpoint after we verified that,
+ # indeed, it has one location.
+ location = breakpoint.GetLocationAtIndex(0)
+ self.assertTrue(location and
+ location.IsEnabled(),
+ VALID_BREAKPOINT_LOCATION)
+
+ # Set the ignore count on the breakpoint location.
+ location.SetIgnoreCount(2)
+ self.assertTrue(location.GetIgnoreCount() == 2,
+ 'SetIgnoreCount() works correctly')
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(None, None, os.getcwd())
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # Frame#0 should be on main.c:37, frame#1 should be on main.c:25, and
+ # frame#2 should be on main.c:48.
+ #lldbutil.print_stacktraces(process)
+ from lldbutil import get_stopped_thread
+ thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+ self.assertTrue(thread != None, 'There should be a thread stopped due to breakpoint')
+ frame0 = thread.GetFrameAtIndex(0)
+ frame1 = thread.GetFrameAtIndex(1)
+ frame2 = thread.GetFrameAtIndex(2)
+ self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1 and
+ frame1.GetLineEntry().GetLine() == self.line3 and
+ frame2.GetLineEntry().GetLine() == self.line4,
+ STOPPED_DUE_TO_BREAKPOINT_IGNORE_COUNT)
+
+ # The hit count for the breakpoint should be 3.
+ self.assertTrue(breakpoint.GetHitCount() == 3)
+
+ process.Continue()
+
+SBBreakpoint supports breakpoint location iteration, for example,
+
+ for bl in breakpoint:
+ print('breakpoint location load addr: %s' % hex(bl.GetLoadAddress()))
+ print('breakpoint location condition: %s' % hex(bl.GetCondition()))
+
+and rich comparison methods which allow the API program to use,
+
+ if aBreakpoint == bBreakpoint:
+ ...
+
+to compare two breakpoints for equality."
+) SBBreakpoint;
+class SBBreakpoint
+{
+public:
+
+ SBBreakpoint ();
+
+ SBBreakpoint (const lldb::SBBreakpoint& rhs);
+
+ ~SBBreakpoint();
+
+ bool operator==(const lldb::SBBreakpoint &rhs);
+
+ bool operator!=(const lldb::SBBreakpoint &rhs);
+
+ break_id_t
+ GetID () const;
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ void
+ ClearAllBreakpointSites ();
+
+ lldb::SBBreakpointLocation
+ FindLocationByAddress (lldb::addr_t vm_addr);
+
+ lldb::break_id_t
+ FindLocationIDByAddress (lldb::addr_t vm_addr);
+
+ lldb::SBBreakpointLocation
+ FindLocationByID (lldb::break_id_t bp_loc_id);
+
+ lldb::SBBreakpointLocation
+ GetLocationAtIndex (uint32_t index);
+
+ void
+ SetEnabled (bool enable);
+
+ bool
+ IsEnabled ();
+
+ void
+ SetOneShot (bool one_shot);
+
+ bool
+ IsOneShot ();
+
+ bool
+ IsInternal ();
+
+ uint32_t
+ GetHitCount () const;
+
+ void
+ SetIgnoreCount (uint32_t count);
+
+ uint32_t
+ GetIgnoreCount () const;
+
+ %feature("docstring", "
+ The breakpoint stops only if the condition expression evaluates to true.") SetCondition;
+ void
+ SetCondition (const char *condition);
+
+ %feature("docstring", "
+ Get the condition expression for the breakpoint.") GetCondition;
+ const char *
+ GetCondition ();
+
+ void SetAutoContinue(bool auto_continue);
+
+ bool GetAutoContinue();
+
+ void
+ SetThreadID (lldb::tid_t sb_thread_id);
+
+ lldb::tid_t
+ GetThreadID ();
+
+ void
+ SetThreadIndex (uint32_t index);
+
+ uint32_t
+ GetThreadIndex() const;
+
+ void
+ SetThreadName (const char *thread_name);
+
+ const char *
+ GetThreadName () const;
+
+ void
+ SetQueueName (const char *queue_name);
+
+ const char *
+ GetQueueName () const;
+
+ %feature("docstring", "
+ Set the name of the script function to be called when the breakpoint is hit.") SetScriptCallbackFunction;
+ void
+ SetScriptCallbackFunction (const char *callback_function_name);
+
+ %feature("docstring", "
+ Set the name of the script function to be called when the breakpoint is hit.
+ To use this variant, the function should take (frame, bp_loc, extra_args, dict) and
+ when the breakpoint is hit the extra_args will be passed to the callback function.") SetScriptCallbackFunction;
+ SBError
+ SetScriptCallbackFunction (const char *callback_function_name,
+ SBStructuredData &extra_args);
+
+ %feature("docstring", "
+ Provide the body for the script function to be called when the breakpoint is hit.
+ The body will be wrapped in a function, which be passed two arguments:
+ 'frame' - which holds the bottom-most SBFrame of the thread that hit the breakpoint
+ 'bpno' - which is the SBBreakpointLocation to which the callback was attached.
+
+ The error parameter is currently ignored, but will at some point hold the Python
+ compilation diagnostics.
+ Returns true if the body compiles successfully, false if not.") SetScriptCallbackBody;
+ SBError
+ SetScriptCallbackBody (const char *script_body_text);
+
+ void SetCommandLineCommands(SBStringList &commands);
+
+ bool GetCommandLineCommands(SBStringList &commands);
+
+ bool
+ AddName (const char *new_name);
+
+ SBError
+ AddNameWithErrorHandling (const char *new_name);
+
+ void
+ RemoveName (const char *name_to_remove);
+
+ bool
+ MatchesName (const char *name);
+
+ void
+ GetNames (SBStringList &names);
+
+ size_t
+ GetNumResolvedLocations() const;
+
+ size_t
+ GetNumLocations() const;
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ bool
+ GetDescription(lldb::SBStream &description, bool include_locations);
+
+ // Can only be called from a ScriptedBreakpointResolver...
+ SBError
+ AddLocation(SBAddress &address);
+
+ static bool
+ EventIsBreakpointEvent (const lldb::SBEvent &event);
+
+ static lldb::BreakpointEventType
+ GetBreakpointEventTypeFromEvent (const lldb::SBEvent& event);
+
+ static lldb::SBBreakpoint
+ GetBreakpointFromEvent (const lldb::SBEvent& event);
+
+ static lldb::SBBreakpointLocation
+ GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx);
+
+ static uint32_t
+ GetNumBreakpointLocationsFromEvent (const lldb::SBEvent &event_sp);
+
+ bool
+ IsHardware ();
+
+ STRING_EXTENSION(SBBreakpoint)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+
+ class locations_access(object):
+ '''A helper object that will lazily hand out locations for a breakpoint when supplied an index.'''
+ def __init__(self, sbbreakpoint):
+ self.sbbreakpoint = sbbreakpoint
+
+ def __len__(self):
+ if self.sbbreakpoint:
+ return int(self.sbbreakpoint.GetNumLocations())
+ return 0
+
+ def __getitem__(self, key):
+ if type(key) is int and key < len(self):
+ return self.sbbreakpoint.GetLocationAtIndex(key)
+ return None
+
+ def get_locations_access_object(self):
+ '''An accessor function that returns a locations_access() object which allows lazy location access from a lldb.SBBreakpoint object.'''
+ return self.locations_access (self)
+
+ def get_breakpoint_location_list(self):
+ '''An accessor function that returns a list() that contains all locations in a lldb.SBBreakpoint object.'''
+ locations = []
+ accessor = self.get_locations_access_object()
+ for idx in range(len(accessor)):
+ locations.append(accessor[idx])
+ return locations
+
+ def __iter__(self):
+ '''Iterate over all breakpoint locations in a lldb.SBBreakpoint
+ object.'''
+ return lldb_iter(self, 'GetNumLocations', 'GetLocationAtIndex')
+
+ def __len__(self):
+ '''Return the number of breakpoint locations in a lldb.SBBreakpoint
+ object.'''
+ return self.GetNumLocations()
+
+ locations = property(get_breakpoint_location_list, None, doc='''A read only property that returns a list() of lldb.SBBreakpointLocation objects for this breakpoint.''')
+ location = property(get_locations_access_object, None, doc='''A read only property that returns an object that can access locations by index (not location ID) (location = bkpt.location[12]).''')
+ id = property(GetID, None, doc='''A read only property that returns the ID of this breakpoint.''')
+ enabled = property(IsEnabled, SetEnabled, doc='''A read/write property that configures whether this breakpoint is enabled or not.''')
+ one_shot = property(IsOneShot, SetOneShot, doc='''A read/write property that configures whether this breakpoint is one-shot (deleted when hit) or not.''')
+ num_locations = property(GetNumLocations, None, doc='''A read only property that returns the count of locations of this breakpoint.''')
+ %}
+#endif
+
+
+};
+
+class SBBreakpointListImpl;
+
+class LLDB_API SBBreakpointList
+{
+public:
+ SBBreakpointList(SBTarget &target);
+
+ ~SBBreakpointList();
+
+ size_t GetSize() const;
+
+ SBBreakpoint
+ GetBreakpointAtIndex(size_t idx);
+
+ SBBreakpoint
+ FindBreakpointByID(lldb::break_id_t);
+
+ void Append(const SBBreakpoint &sb_bkpt);
+
+ bool AppendIfUnique(const SBBreakpoint &sb_bkpt);
+
+ void AppendByID (lldb::break_id_t id);
+
+ void Clear();
+private:
+ std::shared_ptr<SBBreakpointListImpl> m_opaque_sp;
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBBreakpointLocation.i b/lldb/bindings/interface/SBBreakpointLocation.i
new file mode 100644
index 000000000000..dc39c83c2d67
--- /dev/null
+++ b/lldb/bindings/interface/SBBreakpointLocation.i
@@ -0,0 +1,141 @@
+//===-- SWIG Interface for SBBreakpointLocation -----------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents one unique instance (by address) of a logical breakpoint.
+
+A breakpoint location is defined by the breakpoint that produces it,
+and the address that resulted in this particular instantiation.
+Each breakpoint location has its settable options.
+
+SBBreakpoint contains SBBreakpointLocation(s). See docstring of SBBreakpoint
+for retrieval of an SBBreakpointLocation from an SBBreakpoint."
+) SBBreakpointLocation;
+class SBBreakpointLocation
+{
+public:
+
+ SBBreakpointLocation ();
+
+ SBBreakpointLocation (const lldb::SBBreakpointLocation &rhs);
+
+ ~SBBreakpointLocation ();
+
+ break_id_t
+ GetID ();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ lldb::SBAddress
+ GetAddress();
+
+ lldb::addr_t
+ GetLoadAddress ();
+
+ void
+ SetEnabled(bool enabled);
+
+ bool
+ IsEnabled ();
+
+ uint32_t
+ GetHitCount ();
+
+ uint32_t
+ GetIgnoreCount ();
+
+ void
+ SetIgnoreCount (uint32_t n);
+
+ %feature("docstring", "
+ The breakpoint location stops only if the condition expression evaluates
+ to true.") SetCondition;
+ void
+ SetCondition (const char *condition);
+
+ %feature("docstring", "
+ Get the condition expression for the breakpoint location.") GetCondition;
+ const char *
+ GetCondition ();
+
+ bool GetAutoContinue();
+
+ void SetAutoContinue(bool auto_continue);
+
+ %feature("docstring", "
+ Set the callback to the given Python function name.
+ The function takes three arguments (frame, bp_loc, dict).") SetScriptCallbackFunction;
+ void
+ SetScriptCallbackFunction (const char *callback_function_name);
+
+ %feature("docstring", "
+ Set the name of the script function to be called when the breakpoint is hit.
+ To use this variant, the function should take (frame, bp_loc, extra_args, dict) and
+ when the breakpoint is hit the extra_args will be passed to the callback function.") SetScriptCallbackFunction;
+ SBError
+ SetScriptCallbackFunction (const char *callback_function_name,
+ SBStructuredData &extra_args);
+
+ %feature("docstring", "
+ Provide the body for the script function to be called when the breakpoint location is hit.
+ The body will be wrapped in a function, which be passed two arguments:
+ 'frame' - which holds the bottom-most SBFrame of the thread that hit the breakpoint
+ 'bpno' - which is the SBBreakpointLocation to which the callback was attached.
+
+ The error parameter is currently ignored, but will at some point hold the Python
+ compilation diagnostics.
+ Returns true if the body compiles successfully, false if not.") SetScriptCallbackBody;
+ SBError
+ SetScriptCallbackBody (const char *script_body_text);
+
+ void SetCommandLineCommands(SBStringList &commands);
+
+ bool GetCommandLineCommands(SBStringList &commands);
+
+ void
+ SetThreadID (lldb::tid_t sb_thread_id);
+
+ lldb::tid_t
+ GetThreadID ();
+
+ void
+ SetThreadIndex (uint32_t index);
+
+ uint32_t
+ GetThreadIndex() const;
+
+ void
+ SetThreadName (const char *thread_name);
+
+ const char *
+ GetThreadName () const;
+
+ void
+ SetQueueName (const char *queue_name);
+
+ const char *
+ GetQueueName () const;
+
+ bool
+ IsResolved ();
+
+ bool
+ GetDescription (lldb::SBStream &description, DescriptionLevel level);
+
+ SBBreakpoint
+ GetBreakpoint ();
+
+ STRING_EXTENSION_LEVEL(SBBreakpointLocation, lldb::eDescriptionLevelFull)
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBBreakpointName.i b/lldb/bindings/interface/SBBreakpointName.i
new file mode 100644
index 000000000000..e280d4224591
--- /dev/null
+++ b/lldb/bindings/interface/SBBreakpointName.i
@@ -0,0 +1,115 @@
+//===-- SWIG interface for SBBreakpointName.h -------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+%feature("docstring",
+"Represents a breakpoint name registered in a given SBTarget.
+
+Breakpoint names provide a way to act on groups of breakpoints. When you add a
+name to a group of breakpoints, you can then use the name in all the command
+line lldb commands for that name. You can also configure the SBBreakpointName
+options and those options will be propagated to any SBBreakpoints currently
+using that name. Adding a name to a breakpoint will also apply any of the
+set options to that breakpoint.
+
+You can also set permissions on a breakpoint name to disable listing, deleting
+and disabling breakpoints. That will disallow the given operation for breakpoints
+except when the breakpoint is mentioned by ID. So for instance deleting all the
+breakpoints won't delete breakpoints so marked."
+) SBBreakpointName;
+class LLDB_API SBBreakpointName {
+public:
+ SBBreakpointName();
+
+ SBBreakpointName(SBTarget &target, const char *name);
+
+ SBBreakpointName(SBBreakpoint &bkpt, const char *name);
+
+ SBBreakpointName(const lldb::SBBreakpointName &rhs);
+
+ ~SBBreakpointName();
+
+ // Tests to see if the opaque breakpoint object in this object matches the
+ // opaque breakpoint object in "rhs".
+ bool operator==(const lldb::SBBreakpointName &rhs);
+
+ bool operator!=(const lldb::SBBreakpointName &rhs);
+
+ explicit operator bool() const;
+
+ bool IsValid() const;
+
+ const char *GetName() const;
+
+ void SetEnabled(bool enable);
+
+ bool IsEnabled();
+
+ void SetOneShot(bool one_shot);
+
+ bool IsOneShot() const;
+
+ void SetIgnoreCount(uint32_t count);
+
+ uint32_t GetIgnoreCount() const;
+
+ void SetCondition(const char *condition);
+
+ const char *GetCondition();
+
+ void SetAutoContinue(bool auto_continue);
+
+ bool GetAutoContinue();
+
+ void SetThreadID(lldb::tid_t sb_thread_id);
+
+ lldb::tid_t GetThreadID();
+
+ void SetThreadIndex(uint32_t index);
+
+ uint32_t GetThreadIndex() const;
+
+ void SetThreadName(const char *thread_name);
+
+ const char *GetThreadName() const;
+
+ void SetQueueName(const char *queue_name);
+
+ const char *GetQueueName() const;
+
+ void SetScriptCallbackFunction(const char *callback_function_name);
+
+ SBError
+ SetScriptCallbackFunction (const char *callback_function_name,
+ SBStructuredData &extra_args);
+
+ void SetCommandLineCommands(SBStringList &commands);
+
+ bool GetCommandLineCommands(SBStringList &commands);
+
+ SBError SetScriptCallbackBody(const char *script_body_text);
+
+ const char *GetHelpString() const;
+ void SetHelpString(const char *help_string);
+
+ bool GetAllowList() const;
+ void SetAllowList(bool value);
+
+ bool GetAllowDelete();
+ void SetAllowDelete(bool value);
+
+ bool GetAllowDisable();
+ void SetAllowDisable(bool value);
+
+ bool GetDescription(lldb::SBStream &description);
+
+ STRING_EXTENSION(SBBreakpointName)
+};
+
+} // namespace lldb
+
diff --git a/lldb/bindings/interface/SBBroadcaster.i b/lldb/bindings/interface/SBBroadcaster.i
new file mode 100644
index 000000000000..79100e171b49
--- /dev/null
+++ b/lldb/bindings/interface/SBBroadcaster.i
@@ -0,0 +1,69 @@
+//===-- SWIG Interface for SBBroadcaster ------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents an entity which can broadcast events. A default broadcaster is
+associated with an SBCommandInterpreter, SBProcess, and SBTarget. For
+example, use
+
+ broadcaster = process.GetBroadcaster()
+
+to retrieve the process's broadcaster.
+
+See also SBEvent for example usage of interacting with a broadcaster."
+) SBBroadcaster;
+class SBBroadcaster
+{
+public:
+ SBBroadcaster ();
+
+ SBBroadcaster (const char *name);
+
+ SBBroadcaster (const SBBroadcaster &rhs);
+
+ ~SBBroadcaster();
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+ void
+ Clear ();
+
+ void
+ BroadcastEventByType (uint32_t event_type, bool unique = false);
+
+ void
+ BroadcastEvent (const lldb::SBEvent &event, bool unique = false);
+
+ void
+ AddInitialEventsToListener (const lldb::SBListener &listener, uint32_t requested_events);
+
+ uint32_t
+ AddListener (const lldb::SBListener &listener, uint32_t event_mask);
+
+ const char *
+ GetName () const;
+
+ bool
+ EventTypeHasListeners (uint32_t event_type);
+
+ bool
+ RemoveListener (const lldb::SBListener &listener, uint32_t event_mask = UINT32_MAX);
+
+ bool
+ operator == (const lldb::SBBroadcaster &rhs) const;
+
+ bool
+ operator != (const lldb::SBBroadcaster &rhs) const;
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBCommandInterpreter.i b/lldb/bindings/interface/SBCommandInterpreter.i
new file mode 100644
index 000000000000..498084ae3ab1
--- /dev/null
+++ b/lldb/bindings/interface/SBCommandInterpreter.i
@@ -0,0 +1,171 @@
+//===-- SWIG Interface for SBCommandInterpreter -----------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"SBCommandInterpreter handles/interprets commands for lldb. You get the
+command interpreter from the SBDebugger instance. For example (from test/
+python_api/interpreter/TestCommandInterpreterAPI.py),
+
+ def command_interpreter_api(self):
+ '''Test the SBCommandInterpreter APIs.'''
+ exe = os.path.join(os.getcwd(), 'a.out')
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Retrieve the associated command interpreter from our debugger.
+ ci = self.dbg.GetCommandInterpreter()
+ self.assertTrue(ci, VALID_COMMAND_INTERPRETER)
+
+ # Exercise some APIs....
+
+ self.assertTrue(ci.HasCommands())
+ self.assertTrue(ci.HasAliases())
+ self.assertTrue(ci.HasAliasOptions())
+ self.assertTrue(ci.CommandExists('breakpoint'))
+ self.assertTrue(ci.CommandExists('target'))
+ self.assertTrue(ci.CommandExists('platform'))
+ self.assertTrue(ci.AliasExists('file'))
+ self.assertTrue(ci.AliasExists('run'))
+ self.assertTrue(ci.AliasExists('bt'))
+
+ res = lldb.SBCommandReturnObject()
+ ci.HandleCommand('breakpoint set -f main.c -l %d' % self.line, res)
+ self.assertTrue(res.Succeeded())
+ ci.HandleCommand('process launch', res)
+ self.assertTrue(res.Succeeded())
+
+ process = ci.GetProcess()
+ self.assertTrue(process)
+
+ ...
+
+The HandleCommand() instance method takes two args: the command string and
+an SBCommandReturnObject instance which encapsulates the result of command
+execution.") SBCommandInterpreter;
+class SBCommandInterpreter
+{
+public:
+ enum
+ {
+ eBroadcastBitThreadShouldExit = (1 << 0),
+ eBroadcastBitResetPrompt = (1 << 1),
+ eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit
+ eBroadcastBitAsynchronousOutputData = (1 << 3),
+ eBroadcastBitAsynchronousErrorData = (1 << 4)
+ };
+
+ SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs);
+
+ ~SBCommandInterpreter ();
+
+ static const char *
+ GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type);
+
+ static const char *
+ GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type);
+
+ static bool
+ EventIsCommandInterpreterEvent (const lldb::SBEvent &event);
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ const char *
+ GetIOHandlerControlSequence(char ch);
+
+ bool
+ GetPromptOnQuit();
+
+ void
+ SetPromptOnQuit(bool b);
+
+ void
+ AllowExitCodeOnQuit(bool b);
+
+ bool
+ HasCustomQuitExitCode();
+
+ int
+ GetQuitStatus();
+
+ void
+ ResolveCommand(const char *command_line, SBCommandReturnObject &result);
+
+ bool
+ CommandExists (const char *cmd);
+
+ bool
+ AliasExists (const char *cmd);
+
+ lldb::SBBroadcaster
+ GetBroadcaster ();
+
+ static const char *
+ GetBroadcasterClass ();
+
+ bool
+ HasCommands ();
+
+ bool
+ HasAliases ();
+
+ bool
+ HasAliasOptions ();
+
+ lldb::SBProcess
+ GetProcess ();
+
+ lldb::SBDebugger
+ GetDebugger ();
+
+ void
+ SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result);
+
+ void
+ SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result);
+
+ lldb::ReturnStatus
+ HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false);
+
+ lldb::ReturnStatus
+ HandleCommand (const char *command_line, SBExecutionContext &exe_ctx, SBCommandReturnObject &result, bool add_to_history = false);
+
+ void
+ HandleCommandsFromFile (lldb::SBFileSpec &file,
+ lldb::SBExecutionContext &override_context,
+ lldb::SBCommandInterpreterRunOptions &options,
+ lldb::SBCommandReturnObject result);
+
+ int
+ HandleCompletion (const char *current_line,
+ uint32_t cursor_pos,
+ int match_start_point,
+ int max_return_elements,
+ lldb::SBStringList &matches);
+
+ int
+ HandleCompletionWithDescriptions (const char *current_line,
+ uint32_t cursor_pos,
+ int match_start_point,
+ int max_return_elements,
+ lldb::SBStringList &matches,
+ lldb::SBStringList &descriptions);
+ bool
+ IsActive ();
+
+ bool
+ WasInterrupted () const;
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBCommandInterpreterRunOptions.i b/lldb/bindings/interface/SBCommandInterpreterRunOptions.i
new file mode 100644
index 000000000000..f9ccbbd24dbe
--- /dev/null
+++ b/lldb/bindings/interface/SBCommandInterpreterRunOptions.i
@@ -0,0 +1,75 @@
+//===-- SWIG Interface for SBCommandInterpreter -----------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"SBCommandInterpreterRunOptions controls how the RunCommandInterpreter runs the code it is fed.
+A default SBCommandInterpreterRunOptions object has:
+ StopOnContinue: false
+ StopOnError: false
+ StopOnCrash: false
+ EchoCommands: true
+ PrintResults: true
+ AddToHistory: true
+
+") SBCommandInterpreterRunOptions;
+class SBCommandInterpreterRunOptions
+{
+friend class SBDebugger;
+public:
+ SBCommandInterpreterRunOptions();
+ ~SBCommandInterpreterRunOptions();
+
+ bool
+ GetStopOnContinue () const;
+
+ void
+ SetStopOnContinue (bool);
+
+ bool
+ GetStopOnError () const;
+
+ void
+ SetStopOnError (bool);
+
+ bool
+ GetStopOnCrash () const;
+
+ void
+ SetStopOnCrash (bool);
+
+ bool
+ GetEchoCommands () const;
+
+ void
+ SetEchoCommands (bool);
+
+ bool
+ GetPrintResults () const;
+
+ void
+ SetPrintResults (bool);
+
+ bool
+ GetAddToHistory () const;
+
+ void
+ SetAddToHistory (bool);
+private:
+ lldb_private::CommandInterpreterRunOptions *
+ get () const;
+
+ lldb_private::CommandInterpreterRunOptions &
+ ref () const;
+
+ // This is set in the constructor and will always be valid.
+ mutable std::unique_ptr<lldb_private::CommandInterpreterRunOptions> m_opaque_up;
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBCommandReturnObject.i b/lldb/bindings/interface/SBCommandReturnObject.i
new file mode 100644
index 000000000000..affa16520f28
--- /dev/null
+++ b/lldb/bindings/interface/SBCommandReturnObject.i
@@ -0,0 +1,127 @@
+//===-- SWIG Interface for SBCommandReturnObject ----------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a container which holds the result from command execution.
+It works with SBCommandInterpreter.HandleCommand() to encapsulate the result
+of command execution.
+
+See SBCommandInterpreter for example usage of SBCommandReturnObject."
+) SBCommandReturnObject;
+class SBCommandReturnObject
+{
+public:
+
+ SBCommandReturnObject ();
+
+ SBCommandReturnObject (const lldb::SBCommandReturnObject &rhs);
+
+ ~SBCommandReturnObject ();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ const char *
+ GetOutput ();
+
+ const char *
+ GetError ();
+
+ size_t
+ GetOutputSize ();
+
+ size_t
+ GetErrorSize ();
+
+ const char *
+ GetOutput (bool only_if_no_immediate);
+
+ const char *
+ GetError (bool if_no_immediate);
+
+ size_t
+ PutOutput (lldb::SBFile file);
+
+ size_t
+ PutError (lldb::SBFile file);
+
+ size_t
+ PutOutput (lldb::FileSP BORROWED);
+
+ size_t
+ PutError (lldb::FileSP BORROWED);
+
+ void
+ Clear();
+
+ void
+ SetStatus (lldb::ReturnStatus status);
+
+ void
+ SetError (lldb::SBError &error,
+ const char *fallback_error_cstr = NULL);
+
+ void
+ SetError (const char *error_cstr);
+
+ lldb::ReturnStatus
+ GetStatus();
+
+ bool
+ Succeeded ();
+
+ bool
+ HasResult ();
+
+ void
+ AppendMessage (const char *message);
+
+ void
+ AppendWarning (const char *message);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ void SetImmediateOutputFile(lldb::SBFile file);
+ void SetImmediateErrorFile(lldb::SBFile file);
+ void SetImmediateOutputFile(lldb::FileSP BORROWED);
+ void SetImmediateErrorFile(lldb::FileSP BORROWED);
+
+ STRING_EXTENSION(SBCommandReturnObject)
+
+ %extend {
+ // transfer_ownership does nothing, and is here for compatibility with
+ // old scripts. Ownership is tracked by reference count in the ordinary way.
+
+ void SetImmediateOutputFile(lldb::FileSP BORROWED, bool transfer_ownership) {
+ self->SetImmediateOutputFile(BORROWED);
+ }
+ void SetImmediateErrorFile(lldb::FileSP BORROWED, bool transfer_ownership) {
+ self->SetImmediateErrorFile(BORROWED);
+ }
+ }
+
+ void
+ PutCString(const char* string, int len);
+
+ // wrapping the variadic Printf() with a plain Print()
+ // because it is hard to support varargs in SWIG bridgings
+ %extend {
+ void Print (const char* str)
+ {
+ self->Printf("%s", str);
+ }
+ }
+
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBCommunication.i b/lldb/bindings/interface/SBCommunication.i
new file mode 100644
index 000000000000..87d3d0c9c5e4
--- /dev/null
+++ b/lldb/bindings/interface/SBCommunication.i
@@ -0,0 +1,83 @@
+//===-- SWIG Interface for SBCommunication ----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBCommunication
+{
+public:
+ enum {
+ eBroadcastBitDisconnected = (1 << 0), ///< Sent when the communications connection is lost.
+ eBroadcastBitReadThreadGotBytes = (1 << 1), ///< Sent by the read thread when bytes become available.
+ eBroadcastBitReadThreadDidExit = (1 << 2), ///< Sent by the read thread when it exits to inform clients.
+ eBroadcastBitReadThreadShouldExit = (1 << 3), ///< Sent by clients that need to cancel the read thread.
+ eBroadcastBitPacketAvailable = (1 << 4), ///< Sent when data received makes a complete packet.
+ eAllEventBits = 0xffffffff
+ };
+
+ typedef void (*ReadThreadBytesReceived) (void *baton, const void *src, size_t src_len);
+
+ SBCommunication ();
+ SBCommunication (const char * broadcaster_name);
+ ~SBCommunication ();
+
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+ lldb::SBBroadcaster
+ GetBroadcaster ();
+
+ static const char *GetBroadcasterClass();
+
+ lldb::ConnectionStatus
+ AdoptFileDesriptor (int fd, bool owns_fd);
+
+ lldb::ConnectionStatus
+ Connect (const char *url);
+
+ lldb::ConnectionStatus
+ Disconnect ();
+
+ bool
+ IsConnected () const;
+
+ bool
+ GetCloseOnEOF ();
+
+ void
+ SetCloseOnEOF (bool b);
+
+ size_t
+ Read (void *dst,
+ size_t dst_len,
+ uint32_t timeout_usec,
+ lldb::ConnectionStatus &status);
+
+ size_t
+ Write (const void *src,
+ size_t src_len,
+ lldb::ConnectionStatus &status);
+
+ bool
+ ReadThreadStart ();
+
+ bool
+ ReadThreadStop ();
+
+ bool
+ ReadThreadIsRunning ();
+
+ bool
+ SetReadThreadBytesReceivedCallback (ReadThreadBytesReceived callback,
+ void *callback_baton);
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBCompileUnit.i b/lldb/bindings/interface/SBCompileUnit.i
new file mode 100644
index 000000000000..d6a4c07038c6
--- /dev/null
+++ b/lldb/bindings/interface/SBCompileUnit.i
@@ -0,0 +1,138 @@
+//===-- SWIG Interface for SBCompileUnit ------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a compilation unit, or compiled source file.
+
+SBCompileUnit supports line entry iteration. For example,
+
+ # Now get the SBSymbolContext from this frame. We want everything. :-)
+ context = frame0.GetSymbolContext(lldb.eSymbolContextEverything)
+ ...
+
+ compileUnit = context.GetCompileUnit()
+
+ for lineEntry in compileUnit:
+ print('line entry: %s:%d' % (str(lineEntry.GetFileSpec()),
+ lineEntry.GetLine()))
+ print('start addr: %s' % str(lineEntry.GetStartAddress()))
+ print('end addr: %s' % str(lineEntry.GetEndAddress()))
+
+produces:
+
+line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:20
+start addr: a.out[0x100000d98]
+end addr: a.out[0x100000da3]
+line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:21
+start addr: a.out[0x100000da3]
+end addr: a.out[0x100000da9]
+line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:22
+start addr: a.out[0x100000da9]
+end addr: a.out[0x100000db6]
+line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:23
+start addr: a.out[0x100000db6]
+end addr: a.out[0x100000dbc]
+...
+
+See also SBSymbolContext and SBLineEntry"
+) SBCompileUnit;
+class SBCompileUnit
+{
+public:
+
+ SBCompileUnit ();
+
+ SBCompileUnit (const lldb::SBCompileUnit &rhs);
+
+ ~SBCompileUnit ();
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+ lldb::SBFileSpec
+ GetFileSpec () const;
+
+ uint32_t
+ GetNumLineEntries () const;
+
+ lldb::SBLineEntry
+ GetLineEntryAtIndex (uint32_t idx) const;
+
+ uint32_t
+ FindLineEntryIndex (uint32_t start_idx,
+ uint32_t line,
+ lldb::SBFileSpec *inline_file_spec) const;
+
+ uint32_t
+ FindLineEntryIndex (uint32_t start_idx,
+ uint32_t line,
+ lldb::SBFileSpec *inline_file_spec,
+ bool exact) const;
+
+ SBFileSpec
+ GetSupportFileAtIndex (uint32_t idx) const;
+
+ uint32_t
+ GetNumSupportFiles () const;
+
+ uint32_t
+ FindSupportFileIndex (uint32_t start_idx, const SBFileSpec &sb_file, bool full);
+
+ %feature("docstring", "
+ Get all types matching type_mask from debug info in this
+ compile unit.
+
+ @param[in] type_mask
+ A bitfield that consists of one or more bits logically OR'ed
+ together from the lldb::TypeClass enumeration. This allows
+ you to request only structure types, or only class, struct
+ and union types. Passing in lldb::eTypeClassAny will return
+ all types found in the debug information for this compile
+ unit.
+
+ @return
+ A list of types in this compile unit that match type_mask") GetTypes;
+ lldb::SBTypeList
+ GetTypes (uint32_t type_mask = lldb::eTypeClassAny);
+
+ lldb::LanguageType
+ GetLanguage ();
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ bool
+ operator == (const lldb::SBCompileUnit &rhs) const;
+
+ bool
+ operator != (const lldb::SBCompileUnit &rhs) const;
+
+ STRING_EXTENSION(SBCompileUnit)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ def __iter__(self):
+ '''Iterate over all line entries in a lldb.SBCompileUnit object.'''
+ return lldb_iter(self, 'GetNumLineEntries', 'GetLineEntryAtIndex')
+
+ def __len__(self):
+ '''Return the number of line entries in a lldb.SBCompileUnit
+ object.'''
+ return self.GetNumLineEntries()
+
+ file = property(GetFileSpec, None, doc='''A read only property that returns the same result an lldb object that represents the source file (lldb.SBFileSpec) for the compile unit.''')
+ num_line_entries = property(GetNumLineEntries, None, doc='''A read only property that returns the number of line entries in a compile unit as an integer.''')
+ %}
+#endif
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBData.i b/lldb/bindings/interface/SBData.i
new file mode 100644
index 000000000000..3e74240329e0
--- /dev/null
+++ b/lldb/bindings/interface/SBData.i
@@ -0,0 +1,297 @@
+//===-- SWIG Interface for SBData -------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+
+namespace lldb {
+
+class SBData
+{
+public:
+
+ SBData ();
+
+ SBData (const SBData &rhs);
+
+ ~SBData ();
+
+ uint8_t
+ GetAddressByteSize ();
+
+ void
+ SetAddressByteSize (uint8_t addr_byte_size);
+
+ void
+ Clear ();
+
+ bool
+ IsValid();
+
+ explicit operator bool() const;
+
+ size_t
+ GetByteSize ();
+
+ lldb::ByteOrder
+ GetByteOrder();
+
+ void
+ SetByteOrder (lldb::ByteOrder endian);
+
+ float
+ GetFloat (lldb::SBError& error, lldb::offset_t offset);
+
+ double
+ GetDouble (lldb::SBError& error, lldb::offset_t offset);
+
+ long double
+ GetLongDouble (lldb::SBError& error, lldb::offset_t offset);
+
+ lldb::addr_t
+ GetAddress (lldb::SBError& error, lldb::offset_t offset);
+
+ uint8_t
+ GetUnsignedInt8 (lldb::SBError& error, lldb::offset_t offset);
+
+ uint16_t
+ GetUnsignedInt16 (lldb::SBError& error, lldb::offset_t offset);
+
+ uint32_t
+ GetUnsignedInt32 (lldb::SBError& error, lldb::offset_t offset);
+
+ uint64_t
+ GetUnsignedInt64 (lldb::SBError& error, lldb::offset_t offset);
+
+ int8_t
+ GetSignedInt8 (lldb::SBError& error, lldb::offset_t offset);
+
+ int16_t
+ GetSignedInt16 (lldb::SBError& error, lldb::offset_t offset);
+
+ int32_t
+ GetSignedInt32 (lldb::SBError& error, lldb::offset_t offset);
+
+ int64_t
+ GetSignedInt64 (lldb::SBError& error, lldb::offset_t offset);
+
+ const char*
+ GetString (lldb::SBError& error, lldb::offset_t offset);
+
+ bool
+ GetDescription (lldb::SBStream &description, lldb::addr_t base_addr);
+
+ size_t
+ ReadRawData (lldb::SBError& error,
+ lldb::offset_t offset,
+ void *buf,
+ size_t size);
+
+ void
+ SetData (lldb::SBError& error, const void *buf, size_t size, lldb::ByteOrder endian, uint8_t addr_size);
+
+ bool
+ Append (const SBData& rhs);
+
+ static lldb::SBData
+ CreateDataFromCString (lldb::ByteOrder endian, uint32_t addr_byte_size, const char* data);
+
+ // in the following CreateData*() and SetData*() prototypes, the two parameters array and array_len
+ // should not be renamed or rearranged, because doing so will break the SWIG typemap
+ static lldb::SBData
+ CreateDataFromUInt64Array (lldb::ByteOrder endian, uint32_t addr_byte_size, uint64_t* array, size_t array_len);
+
+ static lldb::SBData
+ CreateDataFromUInt32Array (lldb::ByteOrder endian, uint32_t addr_byte_size, uint32_t* array, size_t array_len);
+
+ static lldb::SBData
+ CreateDataFromSInt64Array (lldb::ByteOrder endian, uint32_t addr_byte_size, int64_t* array, size_t array_len);
+
+ static lldb::SBData
+ CreateDataFromSInt32Array (lldb::ByteOrder endian, uint32_t addr_byte_size, int32_t* array, size_t array_len);
+
+ static lldb::SBData
+ CreateDataFromDoubleArray (lldb::ByteOrder endian, uint32_t addr_byte_size, double* array, size_t array_len);
+
+ bool
+ SetDataFromCString (const char* data);
+
+ bool
+ SetDataFromUInt64Array (uint64_t* array, size_t array_len);
+
+ bool
+ SetDataFromUInt32Array (uint32_t* array, size_t array_len);
+
+ bool
+ SetDataFromSInt64Array (int64_t* array, size_t array_len);
+
+ bool
+ SetDataFromSInt32Array (int32_t* array, size_t array_len);
+
+ bool
+ SetDataFromDoubleArray (double* array, size_t array_len);
+
+ STRING_EXTENSION(SBData)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+
+ class read_data_helper:
+ def __init__(self, sbdata, readerfunc, item_size):
+ self.sbdata = sbdata
+ self.readerfunc = readerfunc
+ self.item_size = item_size
+ def __getitem__(self,key):
+ if isinstance(key,slice):
+ list = []
+ for x in range(*key.indices(self.__len__())):
+ list.append(self.__getitem__(x))
+ return list
+ if not (isinstance(key,six.integer_types)):
+ raise TypeError('must be int')
+ key = key * self.item_size # SBData uses byte-based indexes, but we want to use itemsize-based indexes here
+ error = SBError()
+ my_data = self.readerfunc(self.sbdata,error,key)
+ if error.Fail():
+ raise IndexError(error.GetCString())
+ else:
+ return my_data
+ def __len__(self):
+ return int(self.sbdata.GetByteSize()/self.item_size)
+ def all(self):
+ return self[0:len(self)]
+
+ @classmethod
+ def CreateDataFromInt (cls, value, size = None, target = None, ptr_size = None, endian = None):
+ import sys
+ lldbmodule = sys.modules[cls.__module__]
+ lldbdict = lldbmodule.__dict__
+ if 'target' in lldbdict:
+ lldbtarget = lldbdict['target']
+ else:
+ lldbtarget = None
+ if target == None and lldbtarget != None and lldbtarget.IsValid():
+ target = lldbtarget
+ if ptr_size == None:
+ if target and target.IsValid():
+ ptr_size = target.addr_size
+ else:
+ ptr_size = 8
+ if endian == None:
+ if target and target.IsValid():
+ endian = target.byte_order
+ else:
+ endian = lldbdict['eByteOrderLittle']
+ if size == None:
+ if value > 2147483647:
+ size = 8
+ elif value < -2147483648:
+ size = 8
+ elif value > 4294967295:
+ size = 8
+ else:
+ size = 4
+ if size == 4:
+ if value < 0:
+ return SBData().CreateDataFromSInt32Array(endian, ptr_size, [value])
+ return SBData().CreateDataFromUInt32Array(endian, ptr_size, [value])
+ if size == 8:
+ if value < 0:
+ return SBData().CreateDataFromSInt64Array(endian, ptr_size, [value])
+ return SBData().CreateDataFromUInt64Array(endian, ptr_size, [value])
+ return None
+
+ def _make_helper(self, sbdata, getfunc, itemsize):
+ return self.read_data_helper(sbdata, getfunc, itemsize)
+
+ def _make_helper_uint8(self):
+ return self._make_helper(self, SBData.GetUnsignedInt8, 1)
+
+ def _make_helper_uint16(self):
+ return self._make_helper(self, SBData.GetUnsignedInt16, 2)
+
+ def _make_helper_uint32(self):
+ return self._make_helper(self, SBData.GetUnsignedInt32, 4)
+
+ def _make_helper_uint64(self):
+ return self._make_helper(self, SBData.GetUnsignedInt64, 8)
+
+ def _make_helper_sint8(self):
+ return self._make_helper(self, SBData.GetSignedInt8, 1)
+
+ def _make_helper_sint16(self):
+ return self._make_helper(self, SBData.GetSignedInt16, 2)
+
+ def _make_helper_sint32(self):
+ return self._make_helper(self, SBData.GetSignedInt32, 4)
+
+ def _make_helper_sint64(self):
+ return self._make_helper(self, SBData.GetSignedInt64, 8)
+
+ def _make_helper_float(self):
+ return self._make_helper(self, SBData.GetFloat, 4)
+
+ def _make_helper_double(self):
+ return self._make_helper(self, SBData.GetDouble, 8)
+
+ def _read_all_uint8(self):
+ return self._make_helper_uint8().all()
+
+ def _read_all_uint16(self):
+ return self._make_helper_uint16().all()
+
+ def _read_all_uint32(self):
+ return self._make_helper_uint32().all()
+
+ def _read_all_uint64(self):
+ return self._make_helper_uint64().all()
+
+ def _read_all_sint8(self):
+ return self._make_helper_sint8().all()
+
+ def _read_all_sint16(self):
+ return self._make_helper_sint16().all()
+
+ def _read_all_sint32(self):
+ return self._make_helper_sint32().all()
+
+ def _read_all_sint64(self):
+ return self._make_helper_sint64().all()
+
+ def _read_all_float(self):
+ return self._make_helper_float().all()
+
+ def _read_all_double(self):
+ return self._make_helper_double().all()
+
+ uint8 = property(_make_helper_uint8, None, doc='''A read only property that returns an array-like object out of which you can read uint8 values.''')
+ uint16 = property(_make_helper_uint16, None, doc='''A read only property that returns an array-like object out of which you can read uint16 values.''')
+ uint32 = property(_make_helper_uint32, None, doc='''A read only property that returns an array-like object out of which you can read uint32 values.''')
+ uint64 = property(_make_helper_uint64, None, doc='''A read only property that returns an array-like object out of which you can read uint64 values.''')
+ sint8 = property(_make_helper_sint8, None, doc='''A read only property that returns an array-like object out of which you can read sint8 values.''')
+ sint16 = property(_make_helper_sint16, None, doc='''A read only property that returns an array-like object out of which you can read sint16 values.''')
+ sint32 = property(_make_helper_sint32, None, doc='''A read only property that returns an array-like object out of which you can read sint32 values.''')
+ sint64 = property(_make_helper_sint64, None, doc='''A read only property that returns an array-like object out of which you can read sint64 values.''')
+ float = property(_make_helper_float, None, doc='''A read only property that returns an array-like object out of which you can read float values.''')
+ double = property(_make_helper_double, None, doc='''A read only property that returns an array-like object out of which you can read double values.''')
+ uint8s = property(_read_all_uint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint8 values.''')
+ uint16s = property(_read_all_uint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint16 values.''')
+ uint32s = property(_read_all_uint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint32 values.''')
+ uint64s = property(_read_all_uint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as uint64 values.''')
+ sint8s = property(_read_all_sint8, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint8 values.''')
+ sint16s = property(_read_all_sint16, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint16 values.''')
+ sint32s = property(_read_all_sint32, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint32 values.''')
+ sint64s = property(_read_all_sint64, None, doc='''A read only property that returns an array with all the contents of this SBData represented as sint64 values.''')
+ floats = property(_read_all_float, None, doc='''A read only property that returns an array with all the contents of this SBData represented as float values.''')
+ doubles = property(_read_all_double, None, doc='''A read only property that returns an array with all the contents of this SBData represented as double values.''')
+ byte_order = property(GetByteOrder, SetByteOrder, doc='''A read/write property getting and setting the endianness of this SBData (data.byte_order = lldb.eByteOrderLittle).''')
+ size = property(GetByteSize, None, doc='''A read only property that returns the size the same result as GetByteSize().''')
+ %}
+#endif
+
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBDebugger.i b/lldb/bindings/interface/SBDebugger.i
new file mode 100644
index 000000000000..f2e23a7ed780
--- /dev/null
+++ b/lldb/bindings/interface/SBDebugger.i
@@ -0,0 +1,535 @@
+//===-- SWIG Interface for SBDebugger ---------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"SBDebugger is the primordial object that creates SBTargets and provides
+access to them. It also manages the overall debugging experiences.
+
+For example (from example/disasm.py),
+
+import lldb
+import os
+import sys
+
+def disassemble_instructions (insts):
+ for i in insts:
+ print i
+
+...
+
+# Create a new debugger instance
+debugger = lldb.SBDebugger.Create()
+
+# When we step or continue, don't return from the function until the process
+# stops. We do this by setting the async mode to false.
+debugger.SetAsync (False)
+
+# Create a target from a file and arch
+print('Creating a target for \'%s\'' % exe)
+
+target = debugger.CreateTargetWithFileAndArch (exe, lldb.LLDB_ARCH_DEFAULT)
+
+if target:
+ # If the target is valid set a breakpoint at main
+ main_bp = target.BreakpointCreateByName (fname, target.GetExecutable().GetFilename());
+
+ print main_bp
+
+ # Launch the process. Since we specified synchronous mode, we won't return
+ # from this function until we hit the breakpoint at main
+ process = target.LaunchSimple (None, None, os.getcwd())
+
+ # Make sure the launch went ok
+ if process:
+ # Print some simple process info
+ state = process.GetState ()
+ print process
+ if state == lldb.eStateStopped:
+ # Get the first thread
+ thread = process.GetThreadAtIndex (0)
+ if thread:
+ # Print some simple thread info
+ print thread
+ # Get the first frame
+ frame = thread.GetFrameAtIndex (0)
+ if frame:
+ # Print some simple frame info
+ print frame
+ function = frame.GetFunction()
+ # See if we have debug info (a function)
+ if function:
+ # We do have a function, print some info for the function
+ print function
+ # Now get all instructions for this function and print them
+ insts = function.GetInstructions(target)
+ disassemble_instructions (insts)
+ else:
+ # See if we have a symbol in the symbol table for where we stopped
+ symbol = frame.GetSymbol();
+ if symbol:
+ # We do have a symbol, print some info for the symbol
+ print symbol
+ # Now get all instructions for this symbol and print them
+ insts = symbol.GetInstructions(target)
+ disassemble_instructions (insts)
+
+ registerList = frame.GetRegisters()
+ print('Frame registers (size of register set = %d):' % registerList.GetSize())
+ for value in registerList:
+ #print value
+ print('%s (number of children = %d):' % (value.GetName(), value.GetNumChildren()))
+ for child in value:
+ print('Name: ', child.GetName(), ' Value: ', child.GetValue())
+
+ print('Hit the breakpoint at main, enter to continue and wait for program to exit or \'Ctrl-D\'/\'quit\' to terminate the program')
+ next = sys.stdin.readline()
+ if not next or next.rstrip('\n') == 'quit':
+ print('Terminating the inferior process...')
+ process.Kill()
+ else:
+ # Now continue to the program exit
+ process.Continue()
+ # When we return from the above function we will hopefully be at the
+ # program exit. Print out some process info
+ print process
+ elif state == lldb.eStateExited:
+ print('Didn\'t hit the breakpoint at main, program has exited...')
+ else:
+ print('Unexpected process state: %s, killing process...' % debugger.StateAsCString (state))
+ process.Kill()
+
+Sometimes you need to create an empty target that will get filled in later. The most common use for this
+is to attach to a process by name or pid where you don't know the executable up front. The most convenient way
+to do this is:
+
+target = debugger.CreateTarget('')
+error = lldb.SBError()
+process = target.AttachToProcessWithName(debugger.GetListener(), 'PROCESS_NAME', False, error)
+
+or the equivalent arguments for AttachToProcessWithID.") SBDebugger;
+class SBDebugger
+{
+public:
+
+ static void
+ Initialize();
+
+ static SBError
+ InitializeWithErrorHandling();
+
+ static void
+ Terminate();
+
+ static lldb::SBDebugger
+ Create();
+
+ static lldb::SBDebugger
+ Create(bool source_init_files);
+
+ static lldb::SBDebugger
+ Create(bool source_init_files, lldb::LogOutputCallback log_callback, void *baton);
+
+ static void
+ Destroy (lldb::SBDebugger &debugger);
+
+ static void
+ MemoryPressureDetected();
+
+ SBDebugger();
+
+ SBDebugger(const lldb::SBDebugger &rhs);
+
+ ~SBDebugger();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ void
+ Clear ();
+
+ void
+ SetAsync (bool b);
+
+ bool
+ GetAsync ();
+
+ void
+ SkipLLDBInitFiles (bool b);
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ def SetOutputFileHandle(self, file, transfer_ownership):
+ "DEPRECATED, use SetOutputFile"
+ if file is None:
+ import sys
+ file = sys.stdout
+ self.SetOutputFile(SBFile.Create(file, borrow=True))
+
+ def SetInputFileHandle(self, file, transfer_ownership):
+ "DEPRECATED, use SetInputFile"
+ if file is None:
+ import sys
+ file = sys.stdin
+ self.SetInputFile(SBFile.Create(file, borrow=True))
+
+ def SetErrorFileHandle(self, file, transfer_ownership):
+ "DEPRECATED, use SetErrorFile"
+ if file is None:
+ import sys
+ file = sys.stderr
+ self.SetErrorFile(SBFile.Create(file, borrow=True))
+ %}
+#endif
+
+
+ %extend {
+
+ lldb::FileSP GetInputFileHandle() {
+ return self->GetInputFile().GetFile();
+ }
+
+ lldb::FileSP GetOutputFileHandle() {
+ return self->GetOutputFile().GetFile();
+ }
+
+ lldb::FileSP GetErrorFileHandle() {
+ return self->GetErrorFile().GetFile();
+ }
+ }
+
+ SBError
+ SetInputFile (SBFile file);
+
+ SBError
+ SetOutputFile (SBFile file);
+
+ SBError
+ SetErrorFile (SBFile file);
+
+ SBError
+ SetInputFile (FileSP file);
+
+ SBError
+ SetOutputFile (FileSP file);
+
+ SBError
+ SetErrorFile (FileSP file);
+
+ SBFile
+ GetInputFile ();
+
+ SBFile
+ GetOutputFile ();
+
+ SBFile
+ GetErrorFile ();
+
+ lldb::SBCommandInterpreter
+ GetCommandInterpreter ();
+
+ void
+ HandleCommand (const char *command);
+
+ lldb::SBListener
+ GetListener ();
+
+ void
+ HandleProcessEvent (const lldb::SBProcess &process,
+ const lldb::SBEvent &event,
+ SBFile out,
+ SBFile err);
+
+ void
+ HandleProcessEvent (const lldb::SBProcess &process,
+ const lldb::SBEvent &event,
+ FileSP BORROWED,
+ FileSP BORROWED);
+
+ lldb::SBTarget
+ CreateTarget (const char *filename,
+ const char *target_triple,
+ const char *platform_name,
+ bool add_dependent_modules,
+ lldb::SBError& sb_error);
+
+ lldb::SBTarget
+ CreateTargetWithFileAndTargetTriple (const char *filename,
+ const char *target_triple);
+
+ lldb::SBTarget
+ CreateTargetWithFileAndArch (const char *filename,
+ const char *archname);
+
+ lldb::SBTarget
+ CreateTarget (const char *filename);
+
+ %feature("docstring",
+ "The dummy target holds breakpoints and breakpoint names that will prime newly created targets."
+ ) GetDummyTarget;
+ lldb::SBTarget GetDummyTarget();
+
+ %feature("docstring",
+ "Return true if target is deleted from the target list of the debugger."
+ ) DeleteTarget;
+ bool
+ DeleteTarget (lldb::SBTarget &target);
+
+ lldb::SBTarget
+ GetTargetAtIndex (uint32_t idx);
+
+ uint32_t
+ GetIndexOfTarget (lldb::SBTarget target);
+
+ lldb::SBTarget
+ FindTargetWithProcessID (pid_t pid);
+
+ lldb::SBTarget
+ FindTargetWithFileAndArch (const char *filename,
+ const char *arch);
+
+ uint32_t
+ GetNumTargets ();
+
+ lldb::SBTarget
+ GetSelectedTarget ();
+
+ void
+ SetSelectedTarget (lldb::SBTarget &target);
+
+ lldb::SBPlatform
+ GetSelectedPlatform();
+
+ void
+ SetSelectedPlatform(lldb::SBPlatform &platform);
+
+ %feature("docstring",
+ "Get the number of currently active platforms."
+ ) GetNumPlatforms;
+ uint32_t
+ GetNumPlatforms ();
+
+ %feature("docstring",
+ "Get one of the currently active platforms."
+ ) GetPlatformAtIndex;
+ lldb::SBPlatform
+ GetPlatformAtIndex (uint32_t idx);
+
+ %feature("docstring",
+ "Get the number of available platforms."
+ ) GetNumAvailablePlatforms;
+ uint32_t
+ GetNumAvailablePlatforms ();
+
+ %feature("docstring", "
+ Get the name and description of one of the available platforms.
+
+ @param idx Zero-based index of the platform for which info should be
+ retrieved, must be less than the value returned by
+ GetNumAvailablePlatforms().") GetAvailablePlatformInfoAtIndex;
+ lldb::SBStructuredData
+ GetAvailablePlatformInfoAtIndex (uint32_t idx);
+
+ lldb::SBSourceManager
+ GetSourceManager ();
+
+ // REMOVE: just for a quick fix, need to expose platforms through
+ // SBPlatform from this class.
+ lldb::SBError
+ SetCurrentPlatform (const char *platform_name);
+
+ bool
+ SetCurrentPlatformSDKRoot (const char *sysroot);
+
+ // FIXME: Once we get the set show stuff in place, the driver won't need
+ // an interface to the Set/Get UseExternalEditor.
+ bool
+ SetUseExternalEditor (bool input);
+
+ bool
+ GetUseExternalEditor ();
+
+ bool
+ SetUseColor (bool use_color);
+
+ bool
+ GetUseColor () const;
+
+ static bool
+ GetDefaultArchitecture (char *arch_name, size_t arch_name_len);
+
+ static bool
+ SetDefaultArchitecture (const char *arch_name);
+
+ lldb::ScriptLanguage
+ GetScriptingLanguage (const char *script_language_name);
+
+ static const char *
+ GetVersionString ();
+
+ static const char *
+ StateAsCString (lldb::StateType state);
+
+ static SBStructuredData GetBuildConfiguration();
+
+ static bool
+ StateIsRunningState (lldb::StateType state);
+
+ static bool
+ StateIsStoppedState (lldb::StateType state);
+
+ bool
+ EnableLog (const char *channel, const char ** types);
+
+ void
+ SetLoggingCallback (lldb::LogOutputCallback log_callback, void *baton);
+
+ void
+ DispatchInput (const void *data, size_t data_len);
+
+ void
+ DispatchInputInterrupt ();
+
+ void
+ DispatchInputEndOfFile ();
+
+ const char *
+ GetInstanceName ();
+
+ static SBDebugger
+ FindDebuggerWithID (int id);
+
+ static lldb::SBError
+ SetInternalVariable (const char *var_name, const char *value, const char *debugger_instance_name);
+
+ static lldb::SBStringList
+ GetInternalVariableValue (const char *var_name, const char *debugger_instance_name);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ uint32_t
+ GetTerminalWidth () const;
+
+ void
+ SetTerminalWidth (uint32_t term_width);
+
+ lldb::user_id_t
+ GetID ();
+
+ const char *
+ GetPrompt() const;
+
+ void
+ SetPrompt (const char *prompt);
+
+ const char *
+ GetReproducerPath() const;
+
+ lldb::ScriptLanguage
+ GetScriptLanguage() const;
+
+ void
+ SetScriptLanguage (lldb::ScriptLanguage script_lang);
+
+ bool
+ GetCloseInputOnEOF () const;
+
+ void
+ SetCloseInputOnEOF (bool b);
+
+ lldb::SBTypeCategory
+ GetCategory (const char* category_name);
+
+ SBTypeCategory
+ GetCategory (lldb::LanguageType lang_type);
+
+ lldb::SBTypeCategory
+ CreateCategory (const char* category_name);
+
+ bool
+ DeleteCategory (const char* category_name);
+
+ uint32_t
+ GetNumCategories ();
+
+ lldb::SBTypeCategory
+ GetCategoryAtIndex (uint32_t);
+
+ lldb::SBTypeCategory
+ GetDefaultCategory();
+
+ lldb::SBTypeFormat
+ GetFormatForType (lldb::SBTypeNameSpecifier);
+
+ lldb::SBTypeSummary
+ GetSummaryForType (lldb::SBTypeNameSpecifier);
+
+ lldb::SBTypeFilter
+ GetFilterForType (lldb::SBTypeNameSpecifier);
+
+ lldb::SBTypeSynthetic
+ GetSyntheticForType (lldb::SBTypeNameSpecifier);
+
+ STRING_EXTENSION(SBDebugger)
+
+ %feature("docstring",
+"Launch a command interpreter session. Commands are read from standard input or
+from the input handle specified for the debugger object. Output/errors are
+similarly redirected to standard output/error or the configured handles.
+
+@param[in] auto_handle_events If true, automatically handle resulting events.
+@param[in] spawn_thread If true, start a new thread for IO handling.
+@param[in] options Parameter collection of type SBCommandInterpreterRunOptions.
+@param[in] num_errors Initial error counter.
+@param[in] quit_requested Initial quit request flag.
+@param[in] stopped_for_crash Initial crash flag.
+
+@return
+A tuple with the number of errors encountered by the interpreter, a boolean
+indicating whether quitting the interpreter was requested and another boolean
+set to True in case of a crash.
+
+Example:
+
+# Start an interactive lldb session from a script (with a valid debugger object
+# created beforehand):
+n_errors, quit_requested, has_crashed = debugger.RunCommandInterpreter(True,
+ False, lldb.SBCommandInterpreterRunOptions(), 0, False, False)") RunCommandInterpreter;
+ %apply int& INOUT { int& num_errors };
+ %apply bool& INOUT { bool& quit_requested };
+ %apply bool& INOUT { bool& stopped_for_crash };
+ void
+ RunCommandInterpreter (bool auto_handle_events,
+ bool spawn_thread,
+ SBCommandInterpreterRunOptions &options,
+ int &num_errors,
+ bool &quit_requested,
+ bool &stopped_for_crash);
+
+ lldb::SBError
+ RunREPL (lldb::LanguageType language, const char *repl_options);
+
+#ifdef SWIGPYTHON
+ %pythoncode%{
+ def __iter__(self):
+ '''Iterate over all targets in a lldb.SBDebugger object.'''
+ return lldb_iter(self, 'GetNumTargets', 'GetTargetAtIndex')
+
+ def __len__(self):
+ '''Return the number of targets in a lldb.SBDebugger object.'''
+ return self.GetNumTargets()
+ %}
+#endif
+
+}; // class SBDebugger
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBDeclaration.i b/lldb/bindings/interface/SBDeclaration.i
new file mode 100644
index 000000000000..621c1a0ab7c8
--- /dev/null
+++ b/lldb/bindings/interface/SBDeclaration.i
@@ -0,0 +1,67 @@
+//===-- SWIG Interface for SBDeclaration --------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+ %feature("docstring",
+ "Specifies an association with a line and column for a variable."
+ ) SBDeclaration;
+ class SBDeclaration
+ {
+ public:
+
+ SBDeclaration ();
+
+ SBDeclaration (const lldb::SBDeclaration &rhs);
+
+ ~SBDeclaration ();
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+ lldb::SBFileSpec
+ GetFileSpec () const;
+
+ uint32_t
+ GetLine () const;
+
+ uint32_t
+ GetColumn () const;
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ void
+ SetFileSpec (lldb::SBFileSpec filespec);
+
+ void
+ SetLine (uint32_t line);
+
+ void
+ SetColumn (uint32_t column);
+
+ bool
+ operator == (const lldb::SBDeclaration &rhs) const;
+
+ bool
+ operator != (const lldb::SBDeclaration &rhs) const;
+
+ STRING_EXTENSION(SBDeclaration)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''')
+ line = property(GetLine, None, doc='''A read only property that returns the 1 based line number for this line entry, a return value of zero indicates that no line information is available.''')
+ column = property(GetColumn, None, doc='''A read only property that returns the 1 based column number for this line entry, a return value of zero indicates that no column information is available.''')
+ %}
+#endif
+ };
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBEnvironment.i b/lldb/bindings/interface/SBEnvironment.i
new file mode 100644
index 000000000000..4ca22fc314d2
--- /dev/null
+++ b/lldb/bindings/interface/SBEnvironment.i
@@ -0,0 +1,48 @@
+//===-- SWIG Interface for SBEnvironment-------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents the environment of a certain process.
+
+Example:
+ for entry in lldb.debugger.GetSelectedTarget().GetEnvironment().GetEntries():
+ print(entry)
+
+") SBEnvironment;
+class SBEnvironment {
+public:
+ SBEnvironment ();
+
+ SBEnvironment (const lldb::SBEnvironment &rhs);
+
+ ~SBEnvironment();
+
+ size_t GetNumValues();
+
+ const char *Get(const char *name);
+
+ const char *GetNameAtIndex(size_t index);
+
+ const char *GetValueAtIndex(size_t index);
+
+ SBStringList GetEntries();
+
+ void PutEntry(const char *name_and_value);
+
+ void SetEntries(const SBStringList &entries, bool append);
+
+ bool Set(const char *name, const char *value, bool overwrite);
+
+ bool Unset(const char *name);
+
+ void Clear();
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBError.i b/lldb/bindings/interface/SBError.i
new file mode 100644
index 000000000000..ea48e2263a77
--- /dev/null
+++ b/lldb/bindings/interface/SBError.i
@@ -0,0 +1,122 @@
+//===-- SWIG Interface for SBError ------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a container for holding any error code.
+
+For example (from test/python_api/hello_world/TestHelloWorld.py),
+
+ def hello_world_attach_with_id_api(self):
+ '''Create target, spawn a process, and attach to it by id.'''
+
+ target = self.dbg.CreateTarget(self.exe)
+
+ # Spawn a new process and don't display the stdout if not in TraceOn() mode.
+ import subprocess
+ popen = subprocess.Popen([self.exe, 'abc', 'xyz'],
+ stdout = open(os.devnull, 'w') if not self.TraceOn() else None)
+
+ listener = lldb.SBListener('my.attach.listener')
+ error = lldb.SBError()
+ process = target.AttachToProcessWithID(listener, popen.pid, error)
+
+ self.assertTrue(error.Success() and process, PROCESS_IS_VALID)
+
+ # Let's check the stack traces of the attached process.
+ import lldbutil
+ stacktraces = lldbutil.print_stacktraces(process, string_buffer=True)
+ self.expect(stacktraces, exe=False,
+ substrs = ['main.c:%d' % self.line2,
+ '(int)argc=3'])
+
+ listener = lldb.SBListener('my.attach.listener')
+ error = lldb.SBError()
+ process = target.AttachToProcessWithID(listener, popen.pid, error)
+
+ self.assertTrue(error.Success() and process, PROCESS_IS_VALID)
+
+checks that after the attach, there is no error condition by asserting
+that error.Success() is True and we get back a valid process object.
+
+And (from test/python_api/event/TestEvent.py),
+
+ # Now launch the process, and do not stop at entry point.
+ error = lldb.SBError()
+ process = target.Launch(listener, None, None, None, None, None, None, 0, False, error)
+ self.assertTrue(error.Success() and process, PROCESS_IS_VALID)
+
+checks that after calling the target.Launch() method there's no error
+condition and we get back a void process object.") SBError;
+
+class SBError {
+public:
+ SBError ();
+
+ SBError (const lldb::SBError &rhs);
+
+ ~SBError();
+
+ const char *
+ GetCString () const;
+
+ void
+ Clear ();
+
+ bool
+ Fail () const;
+
+ bool
+ Success () const;
+
+ uint32_t
+ GetError () const;
+
+ lldb::ErrorType
+ GetType () const;
+
+ void
+ SetError (uint32_t err, lldb::ErrorType type);
+
+ void
+ SetErrorToErrno ();
+
+ void
+ SetErrorToGenericError ();
+
+ void
+ SetErrorString (const char *err_str);
+
+ %varargs(3, char *str = NULL) SetErrorStringWithFormat;
+ int
+ SetErrorStringWithFormat (const char *format, ...);
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ STRING_EXTENSION(SBError)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ value = property(GetError, None, doc='''A read only property that returns the same result as GetError().''')
+ fail = property(Fail, None, doc='''A read only property that returns the same result as Fail().''')
+ success = property(Success, None, doc='''A read only property that returns the same result as Success().''')
+ description = property(GetCString, None, doc='''A read only property that returns the same result as GetCString().''')
+ type = property(GetType, None, doc='''A read only property that returns the same result as GetType().''')
+ %}
+#endif
+
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBEvent.i b/lldb/bindings/interface/SBEvent.i
new file mode 100644
index 000000000000..99aa5319e371
--- /dev/null
+++ b/lldb/bindings/interface/SBEvent.i
@@ -0,0 +1,153 @@
+//===-- SWIG Interface for SBEvent ------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBBroadcaster;
+
+%feature("docstring",
+"API clients can register to receive events.
+
+For example, check out the following output:
+
+Try wait for event...
+Event description: 0x103d0bb70 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = running}
+Event data flavor: Process::ProcessEventData
+Process state: running
+
+Try wait for event...
+Event description: 0x103a700a0 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = stopped}
+Event data flavor: Process::ProcessEventData
+Process state: stopped
+
+Try wait for event...
+Event description: 0x103d0d4a0 Event: broadcaster = 0x1009c8410, type = 0x00000001, data = { process = 0x1009c8400 (pid = 21528), state = exited}
+Event data flavor: Process::ProcessEventData
+Process state: exited
+
+Try wait for event...
+timeout occurred waiting for event...
+
+from test/python_api/event/TestEventspy:
+
+ def do_listen_for_and_print_event(self):
+ '''Create a listener and use SBEvent API to print the events received.'''
+ exe = os.path.join(os.getcwd(), 'a.out')
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ # Now create a breakpoint on main.c by name 'c'.
+ breakpoint = target.BreakpointCreateByName('c', 'a.out')
+
+ # Now launch the process, and do not stop at the entry point.
+ process = target.LaunchSimple(None, None, os.getcwd())
+ self.assertTrue(process.GetState() == lldb.eStateStopped,
+ PROCESS_STOPPED)
+
+ # Get a handle on the process's broadcaster.
+ broadcaster = process.GetBroadcaster()
+
+ # Create an empty event object.
+ event = lldb.SBEvent()
+
+ # Create a listener object and register with the broadcaster.
+ listener = lldb.SBListener('my listener')
+ rc = broadcaster.AddListener(listener, lldb.SBProcess.eBroadcastBitStateChanged)
+ self.assertTrue(rc, 'AddListener successfully retruns')
+
+ traceOn = self.TraceOn()
+ if traceOn:
+ lldbutil.print_stacktraces(process)
+
+ # Create MyListeningThread class to wait for any kind of event.
+ import threading
+ class MyListeningThread(threading.Thread):
+ def run(self):
+ count = 0
+ # Let's only try at most 4 times to retrieve any kind of event.
+ # After that, the thread exits.
+ while not count > 3:
+ if traceOn:
+ print('Try wait for event...')
+ if listener.WaitForEventForBroadcasterWithType(5,
+ broadcaster,
+ lldb.SBProcess.eBroadcastBitStateChanged,
+ event):
+ if traceOn:
+ desc = lldbutil.get_description(event))
+ print('Event description:', desc)
+ print('Event data flavor:', event.GetDataFlavor())
+ print('Process state:', lldbutil.state_type_to_str(process.GetState()))
+ print()
+ else:
+ if traceOn:
+ print 'timeout occurred waiting for event...'
+ count = count + 1
+ return
+
+ # Let's start the listening thread to retrieve the events.
+ my_thread = MyListeningThread()
+ my_thread.start()
+
+ # Use Python API to continue the process. The listening thread should be
+ # able to receive the state changed events.
+ process.Continue()
+
+ # Use Python API to kill the process. The listening thread should be
+ # able to receive the state changed event, too.
+ process.Kill()
+
+ # Wait until the 'MyListeningThread' terminates.
+ my_thread.join()") SBEvent;
+class SBEvent
+{
+public:
+ SBEvent();
+
+ SBEvent (const lldb::SBEvent &rhs);
+
+ %feature("autodoc",
+ "__init__(self, int type, str data) -> SBEvent (make an event that contains a C string)"
+ ) SBEvent;
+ SBEvent (uint32_t event, const char *cstr, uint32_t cstr_len);
+
+ ~SBEvent();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ const char *
+ GetDataFlavor ();
+
+ uint32_t
+ GetType () const;
+
+ lldb::SBBroadcaster
+ GetBroadcaster () const;
+
+ const char *
+ GetBroadcasterClass () const;
+
+ bool
+ BroadcasterMatchesRef (const lldb::SBBroadcaster &broadcaster);
+
+ void
+ Clear();
+
+ static const char *
+ GetCStringFromEvent (const lldb::SBEvent &event);
+
+ bool
+ GetDescription (lldb::SBStream &description) const;
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBExecutionContext.i b/lldb/bindings/interface/SBExecutionContext.i
new file mode 100644
index 000000000000..46968d04ae32
--- /dev/null
+++ b/lldb/bindings/interface/SBExecutionContext.i
@@ -0,0 +1,51 @@
+//===-- SWIG Interface for SBExecutionContext ---------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBExecutionContext
+{
+public:
+ SBExecutionContext();
+
+ SBExecutionContext (const lldb::SBExecutionContext &rhs);
+
+ SBExecutionContext (const lldb::SBTarget &target);
+
+ SBExecutionContext (const lldb::SBProcess &process);
+
+ SBExecutionContext (lldb::SBThread thread); // can't be a const& because SBThread::get() isn't itself a const function
+
+ SBExecutionContext (const lldb::SBFrame &frame);
+
+ ~SBExecutionContext();
+
+ SBTarget
+ GetTarget () const;
+
+ SBProcess
+ GetProcess () const;
+
+ SBThread
+ GetThread () const;
+
+ SBFrame
+ GetFrame () const;
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ target = property(GetTarget, None, doc='''A read only property that returns the same result as GetTarget().''')
+ process = property(GetProcess, None, doc='''A read only property that returns the same result as GetProcess().''')
+ thread = property(GetThread, None, doc='''A read only property that returns the same result as GetThread().''')
+ frame = property(GetFrame, None, doc='''A read only property that returns the same result as GetFrame().''')
+ %}
+#endif
+
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBExpressionOptions.i b/lldb/bindings/interface/SBExpressionOptions.i
new file mode 100644
index 000000000000..950641c320de
--- /dev/null
+++ b/lldb/bindings/interface/SBExpressionOptions.i
@@ -0,0 +1,166 @@
+//===-- SWIG interface for SBExpressionOptions -----------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"A container for options to use when evaluating expressions."
+) SBExpressionOptions;
+
+class SBExpressionOptions
+{
+friend class SBFrame;
+friend class SBValue;
+
+public:
+ SBExpressionOptions();
+
+ SBExpressionOptions (const lldb::SBExpressionOptions &rhs);
+
+ ~SBExpressionOptions();
+
+ bool
+ GetCoerceResultToId () const;
+
+ %feature("docstring", "Sets whether to coerce the expression result to ObjC id type after evaluation.") SetCoerceResultToId;
+
+ void
+ SetCoerceResultToId (bool coerce = true);
+
+ bool
+ GetUnwindOnError () const;
+
+ %feature("docstring", "Sets whether to unwind the expression stack on error.") SetUnwindOnError;
+
+ void
+ SetUnwindOnError (bool unwind = true);
+
+ bool
+ GetIgnoreBreakpoints () const;
+
+ %feature("docstring", "Sets whether to ignore breakpoint hits while running expressions.") SetUnwindOnError;
+
+ void
+ SetIgnoreBreakpoints (bool ignore = true);
+
+ lldb::DynamicValueType
+ GetFetchDynamicValue () const;
+
+ %feature("docstring", "Sets whether to cast the expression result to its dynamic type.") SetFetchDynamicValue;
+
+ void
+ SetFetchDynamicValue (lldb::DynamicValueType dynamic = lldb::eDynamicCanRunTarget);
+
+ uint32_t
+ GetTimeoutInMicroSeconds () const;
+
+ %feature("docstring", "Sets the timeout in microseconds to run the expression for. If try all threads is set to true and the expression doesn't complete within the specified timeout, all threads will be resumed for the same timeout to see if the expression will finish.") SetTimeoutInMicroSeconds;
+ void
+ SetTimeoutInMicroSeconds (uint32_t timeout = 0);
+
+ uint32_t
+ GetOneThreadTimeoutInMicroSeconds () const;
+
+ %feature("docstring", "Sets the timeout in microseconds to run the expression on one thread before either timing out or trying all threads.") SetTimeoutInMicroSeconds;
+ void
+ SetOneThreadTimeoutInMicroSeconds (uint32_t timeout = 0);
+
+ bool
+ GetTryAllThreads () const;
+
+ %feature("docstring", "Sets whether to run all threads if the expression does not complete on one thread.") SetTryAllThreads;
+ void
+ SetTryAllThreads (bool run_others = true);
+
+ bool
+ GetStopOthers () const;
+
+ %feature("docstring", "Sets whether to stop other threads at all while running expressions. If false, TryAllThreads does nothing.") SetTryAllThreads;
+ void
+ SetStopOthers (bool stop_others = true);
+
+ bool
+ GetTrapExceptions () const;
+
+ %feature("docstring", "Sets whether to abort expression evaluation if an exception is thrown while executing. Don't set this to false unless you know the function you are calling traps all exceptions itself.") SetTryAllThreads;
+ void
+ SetTrapExceptions (bool trap_exceptions = true);
+
+ %feature ("docstring", "Sets the language that LLDB should assume the expression is written in") SetLanguage;
+ void
+ SetLanguage (lldb::LanguageType language);
+
+ bool
+ GetGenerateDebugInfo ();
+
+ %feature("docstring", "Sets whether to generate debug information for the expression and also controls if a SBModule is generated.") SetGenerateDebugInfo;
+ void
+ SetGenerateDebugInfo (bool b = true);
+
+ bool
+ GetSuppressPersistentResult ();
+
+ %feature("docstring", "Sets whether to produce a persistent result that can be used in future expressions.") SetSuppressPersistentResult;
+ void
+ SetSuppressPersistentResult (bool b = false);
+
+
+ %feature("docstring", "Gets the prefix to use for this expression.") GetPrefix;
+ const char *
+ GetPrefix () const;
+
+ %feature("docstring", "Sets the prefix to use for this expression. This prefix gets inserted after the 'target.expr-prefix' prefix contents, but before the wrapped expression function body.") SetPrefix;
+ void
+ SetPrefix (const char *prefix);
+
+ %feature("docstring", "Sets whether to auto-apply fix-it hints to the expression being evaluated.") SetAutoApplyFixIts;
+ void
+ SetAutoApplyFixIts(bool b = true);
+
+ %feature("docstring", "Gets whether to auto-apply fix-it hints to an expression.") GetAutoApplyFixIts;
+ bool
+ GetAutoApplyFixIts();
+
+ %feature("docstring", "Sets how often LLDB should retry applying fix-its to an expression.") SetRetriesWithFixIts;
+ void
+ SetRetriesWithFixIts(uint64_t retries);
+
+ %feature("docstring", "Gets how often LLDB will retry applying fix-its to an expression.") GetRetriesWithFixIts;
+ uint64_t
+ GetRetriesWithFixIts();
+
+ bool
+ GetTopLevel();
+
+ void
+ SetTopLevel(bool b = true);
+
+ %feature("docstring", "Gets whether to JIT an expression if it cannot be interpreted.") GetAllowJIT;
+ bool
+ GetAllowJIT();
+
+ %feature("docstring", "Sets whether to JIT an expression if it cannot be interpreted.") SetAllowJIT;
+ void
+ SetAllowJIT(bool allow);
+
+protected:
+
+ SBExpressionOptions (lldb_private::EvaluateExpressionOptions &expression_options);
+
+ lldb_private::EvaluateExpressionOptions *
+ get () const;
+
+ lldb_private::EvaluateExpressionOptions &
+ ref () const;
+
+private:
+ // This auto_pointer is made in the constructor and is always valid.
+ mutable std::unique_ptr<lldb_private::EvaluateExpressionOptions> m_opaque_ap;
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBFile.i b/lldb/bindings/interface/SBFile.i
new file mode 100644
index 000000000000..c86c5f26f147
--- /dev/null
+++ b/lldb/bindings/interface/SBFile.i
@@ -0,0 +1,101 @@
+//===-- SWIG Interface for SBFile -----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a file."
+) SBFile;
+
+class SBFile
+{
+public:
+
+ SBFile();
+
+ %feature("docstring", "
+ Initialize a SBFile from a file descriptor. mode is
+ 'r', 'r+', or 'w', like fdopen.");
+ SBFile(int fd, const char *mode, bool transfer_ownership);
+
+ %feature("docstring", "initialize a SBFile from a python file object");
+ SBFile(FileSP file);
+
+ %extend {
+ static lldb::SBFile MakeBorrowed(lldb::FileSP BORROWED) {
+ return lldb::SBFile(BORROWED);
+ }
+ static lldb::SBFile MakeForcingIOMethods(lldb::FileSP FORCE_IO_METHODS) {
+ return lldb::SBFile(FORCE_IO_METHODS);
+ }
+ static lldb::SBFile MakeBorrowedForcingIOMethods(lldb::FileSP BORROWED_FORCE_IO_METHODS) {
+ return lldb::SBFile(BORROWED_FORCE_IO_METHODS);
+ }
+ }
+
+#ifdef SWIGPYTHON
+ %pythoncode {
+ @classmethod
+ def Create(cls, file, borrow=False, force_io_methods=False):
+ """
+ Create a SBFile from a python file object, with options.
+
+ If borrow is set then the underlying file will
+ not be closed when the SBFile is closed or destroyed.
+
+ If force_scripting_io is set then the python read/write
+ methods will be called even if a file descriptor is available.
+ """
+ if borrow:
+ if force_io_methods:
+ return cls.MakeBorrowedForcingIOMethods(file)
+ else:
+ return cls.MakeBorrowed(file)
+ else:
+ if force_io_methods:
+ return cls.MakeForcingIOMethods(file)
+ else:
+ return cls(file)
+ }
+#endif
+
+ ~SBFile ();
+
+ %feature("autodoc", "Read(buffer) -> SBError, bytes_read") Read;
+ SBError Read(uint8_t *buf, size_t num_bytes, size_t *OUTPUT);
+
+ %feature("autodoc", "Write(buffer) -> SBError, written_read") Write;
+ SBError Write(const uint8_t *buf, size_t num_bytes, size_t *OUTPUT);
+
+ void Flush();
+
+ bool IsValid() const;
+
+ operator bool() const;
+
+ SBError Close();
+
+ %feature("docstring", "
+ Convert this SBFile into a python io.IOBase file object.
+
+ If the SBFile is itself a wrapper around a python file object,
+ this will return that original object.
+
+ The file returned from here should be considered borrowed,
+ in the sense that you may read and write to it, and flush it,
+ etc, but you should not close it. If you want to close the
+ SBFile, call SBFile.Close().
+
+ If there is no underlying python file to unwrap, GetFile will
+ use the file descriptor, if available to create a new python
+ file object using `open(fd, mode=..., closefd=False)`
+ ");
+ FileSP GetFile();
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBFileSpec.i b/lldb/bindings/interface/SBFileSpec.i
new file mode 100644
index 000000000000..d287a940c051
--- /dev/null
+++ b/lldb/bindings/interface/SBFileSpec.i
@@ -0,0 +1,107 @@
+//===-- SWIG Interface for SBFileSpec ---------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a file specification that divides the path into a directory and
+basename. The string values of the paths are put into uniqued string pools
+for fast comparisons and efficient memory usage.
+
+For example, the following code
+
+ lineEntry = context.GetLineEntry()
+ self.expect(lineEntry.GetFileSpec().GetDirectory(), 'The line entry should have the correct directory',
+ exe=False,
+ substrs = [self.mydir])
+ self.expect(lineEntry.GetFileSpec().GetFilename(), 'The line entry should have the correct filename',
+ exe=False,
+ substrs = ['main.c'])
+ self.assertTrue(lineEntry.GetLine() == self.line,
+ 'The line entry's line number should match ')
+
+gets the line entry from the symbol context when a thread is stopped.
+It gets the file spec corresponding to the line entry and checks that
+the filename and the directory matches what we expect.") SBFileSpec;
+class SBFileSpec
+{
+public:
+ SBFileSpec ();
+
+ SBFileSpec (const lldb::SBFileSpec &rhs);
+
+ SBFileSpec (const char *path);// Deprecated, use SBFileSpec (const char *path, bool resolve)
+
+ SBFileSpec (const char *path, bool resolve);
+
+ ~SBFileSpec ();
+
+ bool operator==(const SBFileSpec &rhs) const;
+
+ bool operator!=(const SBFileSpec &rhs) const;
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ bool
+ Exists () const;
+
+ bool
+ ResolveExecutableLocation ();
+
+ const char *
+ GetFilename() const;
+
+ const char *
+ GetDirectory() const;
+
+ void
+ SetFilename(const char *filename);
+
+ void
+ SetDirectory(const char *directory);
+
+ uint32_t
+ GetPath (char *dst_path, size_t dst_len) const;
+
+ static int
+ ResolvePath (const char *src_path, char *dst_path, size_t dst_len);
+
+ bool
+ GetDescription (lldb::SBStream &description) const;
+
+ void
+ AppendPathComponent (const char *file_or_directory);
+
+ STRING_EXTENSION(SBFileSpec)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ def __get_fullpath__(self):
+ spec_dir = self.GetDirectory()
+ spec_file = self.GetFilename()
+ if spec_dir and spec_file:
+ return '%s/%s' % (spec_dir, spec_file)
+ elif spec_dir:
+ return spec_dir
+ elif spec_file:
+ return spec_file
+ return None
+
+ fullpath = property(__get_fullpath__, None, doc='''A read only property that returns the fullpath as a python string.''')
+ basename = property(GetFilename, None, doc='''A read only property that returns the path basename as a python string.''')
+ dirname = property(GetDirectory, None, doc='''A read only property that returns the path directory name as a python string.''')
+ exists = property(Exists, None, doc='''A read only property that returns a boolean value that indicates if the file exists.''')
+ %}
+#endif
+
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBFileSpecList.i b/lldb/bindings/interface/SBFileSpecList.i
new file mode 100644
index 000000000000..96641613f459
--- /dev/null
+++ b/lldb/bindings/interface/SBFileSpecList.i
@@ -0,0 +1,44 @@
+//===-- SWIG Interface for SBFileSpecList -----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBFileSpecList
+{
+public:
+ SBFileSpecList ();
+
+ SBFileSpecList (const lldb::SBFileSpecList &rhs);
+
+ ~SBFileSpecList ();
+
+ uint32_t
+ GetSize () const;
+
+ bool
+ GetDescription (SBStream &description) const;
+
+ void
+ Append (const SBFileSpec &sb_file);
+
+ bool
+ AppendIfUnique (const SBFileSpec &sb_file);
+
+ void
+ Clear();
+
+ uint32_t
+ FindFileIndex (uint32_t idx, const SBFileSpec &sb_file, bool full);
+
+ const SBFileSpec
+ GetFileSpecAtIndex (uint32_t idx) const;
+
+};
+
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBFrame.i b/lldb/bindings/interface/SBFrame.i
new file mode 100644
index 000000000000..c65b88f863e7
--- /dev/null
+++ b/lldb/bindings/interface/SBFrame.i
@@ -0,0 +1,364 @@
+//===-- SWIG Interface for SBFrame ------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents one of the stack frames associated with a thread.
+SBThread contains SBFrame(s). For example (from test/lldbutil.py),
+
+def print_stacktrace(thread, string_buffer = False):
+ '''Prints a simple stack trace of this thread.'''
+
+ ...
+
+ for i in range(depth):
+ frame = thread.GetFrameAtIndex(i)
+ function = frame.GetFunction()
+
+ load_addr = addrs[i].GetLoadAddress(target)
+ if not function:
+ file_addr = addrs[i].GetFileAddress()
+ start_addr = frame.GetSymbol().GetStartAddress().GetFileAddress()
+ symbol_offset = file_addr - start_addr
+ print >> output, ' frame #{num}: {addr:#016x} {mod}`{symbol} + {offset}'.format(
+ num=i, addr=load_addr, mod=mods[i], symbol=symbols[i], offset=symbol_offset)
+ else:
+ print >> output, ' frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}'.format(
+ num=i, addr=load_addr, mod=mods[i],
+ func='%s [inlined]' % funcs[i] if frame.IsInlined() else funcs[i],
+ file=files[i], line=lines[i],
+ args=get_args_as_string(frame, showFuncName=False) if not frame.IsInlined() else '()')
+
+ ...
+
+And,
+
+ for frame in thread:
+ print frame
+
+See also SBThread."
+) SBFrame;
+class SBFrame
+{
+public:
+ SBFrame ();
+
+ SBFrame (const lldb::SBFrame &rhs);
+
+ ~SBFrame();
+
+ bool
+ IsEqual (const lldb::SBFrame &rhs) const;
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ uint32_t
+ GetFrameID () const;
+
+ %feature("docstring", "
+ Get the Canonical Frame Address for this stack frame.
+ This is the DWARF standard's definition of a CFA, a stack address
+ that remains constant throughout the lifetime of the function.
+ Returns an lldb::addr_t stack address, or LLDB_INVALID_ADDRESS if
+ the CFA cannot be determined.") GetCFA;
+ lldb::addr_t
+ GetCFA () const;
+
+ lldb::addr_t
+ GetPC () const;
+
+ bool
+ SetPC (lldb::addr_t new_pc);
+
+ lldb::addr_t
+ GetSP () const;
+
+ lldb::addr_t
+ GetFP () const;
+
+ lldb::SBAddress
+ GetPCAddress () const;
+
+ lldb::SBSymbolContext
+ GetSymbolContext (uint32_t resolve_scope) const;
+
+ lldb::SBModule
+ GetModule () const;
+
+ lldb::SBCompileUnit
+ GetCompileUnit () const;
+
+ lldb::SBFunction
+ GetFunction () const;
+
+ lldb::SBSymbol
+ GetSymbol () const;
+
+ %feature("docstring", "
+ Gets the deepest block that contains the frame PC.
+
+ See also GetFrameBlock().") GetBlock;
+ lldb::SBBlock
+ GetBlock () const;
+
+ %feature("docstring", "
+ Get the appropriate function name for this frame. Inlined functions in
+ LLDB are represented by Blocks that have inlined function information, so
+ just looking at the SBFunction or SBSymbol for a frame isn't enough.
+ This function will return the appropriate function, symbol or inlined
+ function name for the frame.
+
+ This function returns:
+ - the name of the inlined function (if there is one)
+ - the name of the concrete function (if there is one)
+ - the name of the symbol (if there is one)
+ - NULL
+
+ See also IsInlined().") GetFunctionName;
+ const char *
+ GetFunctionName();
+
+ const char *
+ GetDisplayFunctionName ();
+
+ const char *
+ GetFunctionName() const;
+
+ %feature("docstring", "
+ Returns the language of the frame's SBFunction, or if there.
+ is no SBFunction, guess the language from the mangled name.
+ .") GuessLanguage;
+ lldb::LanguageType
+ GuessLanguage() const;
+
+ %feature("docstring", "
+ Return true if this frame represents an inlined function.
+
+ See also GetFunctionName().") IsInlined;
+ bool
+ IsInlined();
+
+ bool
+ IsInlined() const;
+
+ %feature("docstring", "
+ Return true if this frame is artificial (e.g a frame synthesized to
+ capture a tail call). Local variables may not be available in an artificial
+ frame.") IsArtificial;
+ bool
+ IsArtificial();
+
+ bool
+ IsArtificial() const;
+
+ %feature("docstring", "
+ The version that doesn't supply a 'use_dynamic' value will use the
+ target's default.") EvaluateExpression;
+ lldb::SBValue
+ EvaluateExpression (const char *expr);
+
+ lldb::SBValue
+ EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic);
+
+ lldb::SBValue
+ EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic, bool unwind_on_error);
+
+ lldb::SBValue
+ EvaluateExpression (const char *expr, SBExpressionOptions &options);
+
+ %feature("docstring", "
+ Gets the lexical block that defines the stack frame. Another way to think
+ of this is it will return the block that contains all of the variables
+ for a stack frame. Inlined functions are represented as SBBlock objects
+ that have inlined function information: the name of the inlined function,
+ where it was called from. The block that is returned will be the first
+ block at or above the block for the PC (SBFrame::GetBlock()) that defines
+ the scope of the frame. When a function contains no inlined functions,
+ this will be the top most lexical block that defines the function.
+ When a function has inlined functions and the PC is currently
+ in one of those inlined functions, this method will return the inlined
+ block that defines this frame. If the PC isn't currently in an inlined
+ function, the lexical block that defines the function is returned.") GetFrameBlock;
+ lldb::SBBlock
+ GetFrameBlock () const;
+
+ lldb::SBLineEntry
+ GetLineEntry () const;
+
+ lldb::SBThread
+ GetThread () const;
+
+ const char *
+ Disassemble () const;
+
+ void
+ Clear();
+
+ bool
+ operator == (const lldb::SBFrame &rhs) const;
+
+ bool
+ operator != (const lldb::SBFrame &rhs) const;
+
+ %feature("docstring", "
+ The version that doesn't supply a 'use_dynamic' value will use the
+ target's default.") GetVariables;
+ lldb::SBValueList
+ GetVariables (bool arguments,
+ bool locals,
+ bool statics,
+ bool in_scope_only);
+
+ lldb::SBValueList
+ GetVariables (bool arguments,
+ bool locals,
+ bool statics,
+ bool in_scope_only,
+ lldb::DynamicValueType use_dynamic);
+
+ lldb::SBValueList
+ GetVariables (const lldb::SBVariablesOptions& options);
+
+ lldb::SBValueList
+ GetRegisters ();
+
+ %feature("docstring", "
+ The version that doesn't supply a 'use_dynamic' value will use the
+ target's default.") FindVariable;
+ lldb::SBValue
+ FindVariable (const char *var_name);
+
+ lldb::SBValue
+ FindVariable (const char *var_name, lldb::DynamicValueType use_dynamic);
+
+ lldb::SBValue
+ FindRegister (const char *name);
+
+ %feature("docstring", "
+ Get a lldb.SBValue for a variable path.
+
+ Variable paths can include access to pointer or instance members:
+ rect_ptr->origin.y
+ pt.x
+ Pointer dereferences:
+ *this->foo_ptr
+ **argv
+ Address of:
+ &pt
+ &my_array[3].x
+ Array accesses and treating pointers as arrays:
+ int_array[1]
+ pt_ptr[22].x
+
+ Unlike EvaluateExpression() which returns lldb.SBValue objects
+ with constant copies of the values at the time of evaluation,
+ the result of this function is a value that will continue to
+ track the current value of the value as execution progresses
+ in the current frame.") GetValueForVariablePath;
+ lldb::SBValue
+ GetValueForVariablePath (const char *var_path);
+
+ lldb::SBValue
+ GetValueForVariablePath (const char *var_path, lldb::DynamicValueType use_dynamic);
+
+ %feature("docstring", "
+ Find variables, register sets, registers, or persistent variables using
+ the frame as the scope.
+
+ The version that doesn't supply a 'use_dynamic' value will use the
+ target's default.") FindValue;
+ lldb::SBValue
+ FindValue (const char *name, ValueType value_type);
+
+ lldb::SBValue
+ FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ STRING_EXTENSION(SBFrame)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ def get_all_variables(self):
+ return self.GetVariables(True,True,True,True)
+
+ def get_parent_frame(self):
+ parent_idx = self.idx + 1
+ if parent_idx >= 0 and parent_idx < len(self.thread.frame):
+ return self.thread.frame[parent_idx]
+ else:
+ return SBFrame()
+
+ def get_arguments(self):
+ return self.GetVariables(True,False,False,False)
+
+ def get_locals(self):
+ return self.GetVariables(False,True,False,False)
+
+ def get_statics(self):
+ return self.GetVariables(False,False,True,False)
+
+ def var(self, var_expr_path):
+ '''Calls through to lldb.SBFrame.GetValueForVariablePath() and returns
+ a value that represents the variable expression path'''
+ return self.GetValueForVariablePath(var_expr_path)
+
+ def get_registers_access(self):
+ class registers_access(object):
+ '''A helper object that exposes a flattened view of registers, masking away the notion of register sets for easy scripting.'''
+ def __init__(self, regs):
+ self.regs = regs
+
+ def __getitem__(self, key):
+ if type(key) is str:
+ for i in range(0,len(self.regs)):
+ rs = self.regs[i]
+ for j in range (0,rs.num_children):
+ reg = rs.GetChildAtIndex(j)
+ if reg.name == key: return reg
+ else:
+ return lldb.SBValue()
+
+ return registers_access(self.registers)
+
+ pc = property(GetPC, SetPC)
+ addr = property(GetPCAddress, None, doc='''A read only property that returns the program counter (PC) as a section offset address (lldb.SBAddress).''')
+ fp = property(GetFP, None, doc='''A read only property that returns the frame pointer (FP) as an unsigned integer.''')
+ sp = property(GetSP, None, doc='''A read only property that returns the stack pointer (SP) as an unsigned integer.''')
+ module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) for this stack frame.''')
+ compile_unit = property(GetCompileUnit, None, doc='''A read only property that returns an lldb object that represents the compile unit (lldb.SBCompileUnit) for this stack frame.''')
+ function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) for this stack frame.''')
+ symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) for this stack frame.''')
+ block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) for this stack frame.''')
+ is_inlined = property(IsInlined, None, doc='''A read only property that returns an boolean that indicates if the block frame is an inlined function.''')
+ name = property(GetFunctionName, None, doc='''A read only property that retuns the name for the function that this frame represents. Inlined stack frame might have a concrete function that differs from the name of the inlined function (a named lldb.SBBlock).''')
+ line_entry = property(GetLineEntry, None, doc='''A read only property that returns an lldb object that represents the line table entry (lldb.SBLineEntry) for this stack frame.''')
+ thread = property(GetThread, None, doc='''A read only property that returns an lldb object that represents the thread (lldb.SBThread) for this stack frame.''')
+ disassembly = property(Disassemble, None, doc='''A read only property that returns the disassembly for this stack frame as a python string.''')
+ idx = property(GetFrameID, None, doc='''A read only property that returns the zero based stack frame index.''')
+ variables = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''')
+ vars = property(get_all_variables, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the variables in this stack frame.''')
+ locals = property(get_locals, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the local variables in this stack frame.''')
+ args = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''')
+ arguments = property(get_arguments, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the argument variables in this stack frame.''')
+ statics = property(get_statics, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the static variables in this stack frame.''')
+ registers = property(GetRegisters, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the CPU registers for this stack frame.''')
+ regs = property(GetRegisters, None, doc='''A read only property that returns a list() that contains a collection of lldb.SBValue objects that represent the CPU registers for this stack frame.''')
+ register = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame.''')
+ reg = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame''')
+ parent = property(get_parent_frame, None, doc='''A read only property that returns the parent (caller) frame of the current frame.''')
+ %}
+#endif
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBFunction.i b/lldb/bindings/interface/SBFunction.i
new file mode 100644
index 000000000000..630c4db22c55
--- /dev/null
+++ b/lldb/bindings/interface/SBFunction.i
@@ -0,0 +1,134 @@
+//===-- SWIG Interface for SBFunction ---------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a generic function, which can be inlined or not.
+
+For example (from test/lldbutil.py, but slightly modified for doc purpose),
+
+ ...
+
+ frame = thread.GetFrameAtIndex(i)
+ addr = frame.GetPCAddress()
+ load_addr = addr.GetLoadAddress(target)
+ function = frame.GetFunction()
+ mod_name = frame.GetModule().GetFileSpec().GetFilename()
+
+ if not function:
+ # No debug info for 'function'.
+ symbol = frame.GetSymbol()
+ file_addr = addr.GetFileAddress()
+ start_addr = symbol.GetStartAddress().GetFileAddress()
+ symbol_name = symbol.GetName()
+ symbol_offset = file_addr - start_addr
+ print >> output, ' frame #{num}: {addr:#016x} {mod}`{symbol} + {offset}'.format(
+ num=i, addr=load_addr, mod=mod_name, symbol=symbol_name, offset=symbol_offset)
+ else:
+ # Debug info is available for 'function'.
+ func_name = frame.GetFunctionName()
+ file_name = frame.GetLineEntry().GetFileSpec().GetFilename()
+ line_num = frame.GetLineEntry().GetLine()
+ print >> output, ' frame #{num}: {addr:#016x} {mod}`{func} at {file}:{line} {args}'.format(
+ num=i, addr=load_addr, mod=mod_name,
+ func='%s [inlined]' % func_name] if frame.IsInlined() else func_name,
+ file=file_name, line=line_num, args=get_args_as_string(frame, showFuncName=False))
+
+ ...") SBFunction;
+class SBFunction
+{
+public:
+
+ SBFunction ();
+
+ SBFunction (const lldb::SBFunction &rhs);
+
+ ~SBFunction ();
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+ const char *
+ GetName() const;
+
+ const char *
+ GetDisplayName() const;
+
+ const char *
+ GetMangledName () const;
+
+ lldb::SBInstructionList
+ GetInstructions (lldb::SBTarget target);
+
+ lldb::SBInstructionList
+ GetInstructions (lldb::SBTarget target, const char *flavor);
+
+ lldb::SBAddress
+ GetStartAddress ();
+
+ lldb::SBAddress
+ GetEndAddress ();
+
+ const char *
+ GetArgumentName (uint32_t arg_idx);
+
+ uint32_t
+ GetPrologueByteSize ();
+
+ lldb::SBType
+ GetType ();
+
+ lldb::SBBlock
+ GetBlock ();
+
+ lldb::LanguageType
+ GetLanguage ();
+
+ %feature("docstring", "
+ Returns true if the function was compiled with optimization.
+ Optimization, in this case, is meant to indicate that the debugger
+ experience may be confusing for the user -- variables optimized away,
+ stepping jumping between source lines -- and the driver may want to
+ provide some guidance to the user about this.
+ Returns false if unoptimized, or unknown.") GetIsOptimized;
+ bool
+ GetIsOptimized();
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ bool
+ operator == (const lldb::SBFunction &rhs) const;
+
+ bool
+ operator != (const lldb::SBFunction &rhs) const;
+
+ STRING_EXTENSION(SBFunction)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ def get_instructions_from_current_target (self):
+ return self.GetInstructions (target)
+
+ addr = property(GetStartAddress, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this function.''')
+ end_addr = property(GetEndAddress, None, doc='''A read only property that returns an lldb object that represents the end address (lldb.SBAddress) for this function.''')
+ block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the top level lexical block (lldb.SBBlock) for this function.''')
+ instructions = property(get_instructions_from_current_target, None, doc='''A read only property that returns an lldb object that represents the instructions (lldb.SBInstructionList) for this function.''')
+ mangled = property(GetMangledName, None, doc='''A read only property that returns the mangled (linkage) name for this function as a string.''')
+ name = property(GetName, None, doc='''A read only property that returns the name for this function as a string.''')
+ prologue_size = property(GetPrologueByteSize, None, doc='''A read only property that returns the size in bytes of the prologue instructions as an unsigned integer.''')
+ type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the return type (lldb.SBType) for this function.''')
+ %}
+#endif
+
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBHostOS.i b/lldb/bindings/interface/SBHostOS.i
new file mode 100644
index 000000000000..14f4186cb9f3
--- /dev/null
+++ b/lldb/bindings/interface/SBHostOS.i
@@ -0,0 +1,49 @@
+//===-- SWIG Interface for SBHostOS -----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBHostOS
+{
+public:
+
+ static lldb::SBFileSpec
+ GetProgramFileSpec ();
+
+ static lldb::SBFileSpec
+ GetLLDBPythonPath ();
+
+ static lldb::SBFileSpec
+ GetLLDBPath (lldb::PathType path_type);
+
+ static lldb::SBFileSpec
+ GetUserHomeDirectory ();
+
+ static void
+ ThreadCreated (const char *name);
+
+ static lldb::thread_t
+ ThreadCreate (const char *name,
+ lldb::thread_func_t,
+ void *thread_arg,
+ lldb::SBError *err);
+
+ static bool
+ ThreadCancel (lldb::thread_t thread,
+ lldb::SBError *err);
+
+ static bool
+ ThreadDetach (lldb::thread_t thread,
+ lldb::SBError *err);
+ static bool
+ ThreadJoin (lldb::thread_t thread,
+ lldb::thread_result_t *result,
+ lldb::SBError *err);
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBInstruction.i b/lldb/bindings/interface/SBInstruction.i
new file mode 100644
index 000000000000..d50a080fd045
--- /dev/null
+++ b/lldb/bindings/interface/SBInstruction.i
@@ -0,0 +1,104 @@
+//===-- SWIG Interface for SBInstruction ------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+// There's a lot to be fixed here, but need to wait for underlying insn implementation
+// to be revised & settle down first.
+
+namespace lldb {
+
+class SBInstruction
+{
+public:
+
+ SBInstruction ();
+
+ SBInstruction (const SBInstruction &rhs);
+
+ ~SBInstruction ();
+
+ bool
+ IsValid();
+
+ explicit operator bool() const;
+
+ lldb::SBAddress
+ GetAddress();
+
+
+ const char *
+ GetMnemonic (lldb::SBTarget target);
+
+ const char *
+ GetOperands (lldb::SBTarget target);
+
+ const char *
+ GetComment (lldb::SBTarget target);
+
+ lldb::SBData
+ GetData (lldb::SBTarget target);
+
+ size_t
+ GetByteSize ();
+
+ bool
+ DoesBranch ();
+
+ bool
+ HasDelaySlot ();
+
+ bool
+ CanSetBreakpoint ();
+
+ void
+ Print (lldb::SBFile out);
+
+ void
+ Print (lldb::FileSP BORROWED);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ bool
+ EmulateWithFrame (lldb::SBFrame &frame, uint32_t evaluate_options);
+
+ bool
+ DumpEmulation (const char * triple); // triple is to specify the architecture, e.g. 'armv6' or 'armv7-apple-ios'
+
+ bool
+ TestEmulation (lldb::SBStream &output_stream, const char *test_file);
+
+ STRING_EXTENSION(SBInstruction)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ def __mnemonic_property__ (self):
+ return self.GetMnemonic (target)
+ def __operands_property__ (self):
+ return self.GetOperands (target)
+ def __comment_property__ (self):
+ return self.GetComment (target)
+ def __file_addr_property__ (self):
+ return self.GetAddress ().GetFileAddress()
+ def __load_adrr_property__ (self):
+ return self.GetComment (target)
+
+ mnemonic = property(__mnemonic_property__, None, doc='''A read only property that returns the mnemonic for this instruction as a string.''')
+ operands = property(__operands_property__, None, doc='''A read only property that returns the operands for this instruction as a string.''')
+ comment = property(__comment_property__, None, doc='''A read only property that returns the comment for this instruction as a string.''')
+ addr = property(GetAddress, None, doc='''A read only property that returns an lldb object that represents the address (lldb.SBAddress) for this instruction.''')
+ size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes for this instruction as an integer.''')
+ is_branch = property(DoesBranch, None, doc='''A read only property that returns a boolean value that indicates if this instruction is a branch instruction.''')
+ %}
+#endif
+
+
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBInstructionList.i b/lldb/bindings/interface/SBInstructionList.i
new file mode 100644
index 000000000000..135732302757
--- /dev/null
+++ b/lldb/bindings/interface/SBInstructionList.i
@@ -0,0 +1,107 @@
+//===-- SWIG Interface for SBInstructionList --------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a list of machine instructions. SBFunction and SBSymbol have
+GetInstructions() methods which return SBInstructionList instances.
+
+SBInstructionList supports instruction (SBInstruction instance) iteration.
+For example (see also SBDebugger for a more complete example),
+
+def disassemble_instructions (insts):
+ for i in insts:
+ print i
+
+defines a function which takes an SBInstructionList instance and prints out
+the machine instructions in assembly format."
+) SBInstructionList;
+class SBInstructionList
+{
+public:
+
+ SBInstructionList ();
+
+ SBInstructionList (const SBInstructionList &rhs);
+
+ ~SBInstructionList ();
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+ size_t
+ GetSize ();
+
+ lldb::SBInstruction
+ GetInstructionAtIndex (uint32_t idx);
+
+ size_t GetInstructionsCount(const SBAddress &start, const SBAddress &end,
+ bool canSetBreakpoint);
+
+ void
+ Clear ();
+
+ void
+ AppendInstruction (lldb::SBInstruction inst);
+
+ void
+ Print (lldb::SBFile out);
+
+ void
+ Print (lldb::FileSP BORROWED);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ bool
+ DumpEmulationForAllInstructions (const char *triple);
+
+ STRING_EXTENSION(SBInstructionList)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ def __iter__(self):
+ '''Iterate over all instructions in a lldb.SBInstructionList
+ object.'''
+ return lldb_iter(self, 'GetSize', 'GetInstructionAtIndex')
+
+ def __len__(self):
+ '''Access len of the instruction list.'''
+ return int(self.GetSize())
+
+ def __getitem__(self, key):
+ '''Access instructions by integer index for array access or by lldb.SBAddress to find an instruction that matches a section offset address object.'''
+ if type(key) is int:
+ # Find an instruction by index
+ if key < len(self):
+ return self.GetInstructionAtIndex(key)
+ elif type(key) is SBAddress:
+ # Find an instruction using a lldb.SBAddress object
+ lookup_file_addr = key.file_addr
+ closest_inst = None
+ for idx in range(self.GetSize()):
+ inst = self.GetInstructionAtIndex(idx)
+ inst_file_addr = inst.addr.file_addr
+ if inst_file_addr == lookup_file_addr:
+ return inst
+ elif inst_file_addr > lookup_file_addr:
+ return closest_inst
+ else:
+ closest_inst = inst
+ return None
+ %}
+#endif
+
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBLanguageRuntime.i b/lldb/bindings/interface/SBLanguageRuntime.i
new file mode 100644
index 000000000000..f28170b9ce77
--- /dev/null
+++ b/lldb/bindings/interface/SBLanguageRuntime.i
@@ -0,0 +1,21 @@
+//===-- SWIG Interface for SBLanguageRuntime --------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBLanguageRuntime
+{
+public:
+ static lldb::LanguageType
+ GetLanguageTypeFromString (const char *string);
+
+ static const char *
+ GetNameForLanguageType (lldb::LanguageType language);
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBLaunchInfo.i b/lldb/bindings/interface/SBLaunchInfo.i
new file mode 100644
index 000000000000..1de89b58b272
--- /dev/null
+++ b/lldb/bindings/interface/SBLaunchInfo.i
@@ -0,0 +1,137 @@
+//===-- SWIG Interface for SBLaunchInfo--------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBLaunchInfo
+{
+public:
+ SBLaunchInfo (const char **argv);
+
+ pid_t
+ GetProcessID();
+
+ uint32_t
+ GetUserID();
+
+ uint32_t
+ GetGroupID();
+
+ bool
+ UserIDIsValid ();
+
+ bool
+ GroupIDIsValid ();
+
+ void
+ SetUserID (uint32_t uid);
+
+ void
+ SetGroupID (uint32_t gid);
+
+ lldb::SBFileSpec
+ GetExecutableFile ();
+
+ void
+ SetExecutableFile (lldb::SBFileSpec exe_file, bool add_as_first_arg);
+
+ lldb::SBListener
+ GetListener ();
+
+ void
+ SetListener (lldb::SBListener &listener);
+
+ uint32_t
+ GetNumArguments ();
+
+ const char *
+ GetArgumentAtIndex (uint32_t idx);
+
+ void
+ SetArguments (const char **argv, bool append);
+
+ uint32_t
+ GetNumEnvironmentEntries ();
+
+ const char *
+ GetEnvironmentEntryAtIndex (uint32_t idx);
+
+ void
+ SetEnvironmentEntries (const char **envp, bool append);
+
+ void
+ SetEnvironment(const SBEnvironment &env, bool append);
+
+ SBEnvironment
+ GetEnvironment();
+
+ void
+ Clear ();
+
+ const char *
+ GetWorkingDirectory () const;
+
+ void
+ SetWorkingDirectory (const char *working_dir);
+
+ uint32_t
+ GetLaunchFlags ();
+
+ void
+ SetLaunchFlags (uint32_t flags);
+
+ const char *
+ GetProcessPluginName ();
+
+ void
+ SetProcessPluginName (const char *plugin_name);
+
+ const char *
+ GetShell ();
+
+ void
+ SetShell (const char * path);
+
+ bool
+ GetShellExpandArguments ();
+
+ void
+ SetShellExpandArguments (bool expand);
+
+ uint32_t
+ GetResumeCount ();
+
+ void
+ SetResumeCount (uint32_t c);
+
+ bool
+ AddCloseFileAction (int fd);
+
+ bool
+ AddDuplicateFileAction (int fd, int dup_fd);
+
+ bool
+ AddOpenFileAction (int fd, const char *path, bool read, bool write);
+
+ bool
+ AddSuppressFileAction (int fd, bool read, bool write);
+
+ void
+ SetLaunchEventData (const char *data);
+
+ const char *
+ GetLaunchEventData () const;
+
+ bool
+ GetDetachOnError() const;
+
+ void
+ SetDetachOnError(bool enable);
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBLineEntry.i b/lldb/bindings/interface/SBLineEntry.i
new file mode 100644
index 000000000000..be365377ba8b
--- /dev/null
+++ b/lldb/bindings/interface/SBLineEntry.i
@@ -0,0 +1,100 @@
+//===-- SWIG Interface for SBLineEntry --------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Specifies an association with a contiguous range of instructions and
+a source file location. SBCompileUnit contains SBLineEntry(s). For example,
+
+ for lineEntry in compileUnit:
+ print('line entry: %s:%d' % (str(lineEntry.GetFileSpec()),
+ lineEntry.GetLine()))
+ print('start addr: %s' % str(lineEntry.GetStartAddress()))
+ print('end addr: %s' % str(lineEntry.GetEndAddress()))
+
+produces:
+
+line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:20
+start addr: a.out[0x100000d98]
+end addr: a.out[0x100000da3]
+line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:21
+start addr: a.out[0x100000da3]
+end addr: a.out[0x100000da9]
+line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:22
+start addr: a.out[0x100000da9]
+end addr: a.out[0x100000db6]
+line entry: /Volumes/data/lldb/svn/trunk/test/python_api/symbol-context/main.c:23
+start addr: a.out[0x100000db6]
+end addr: a.out[0x100000dbc]
+...
+
+See also SBCompileUnit."
+) SBLineEntry;
+class SBLineEntry
+{
+public:
+
+ SBLineEntry ();
+
+ SBLineEntry (const lldb::SBLineEntry &rhs);
+
+ ~SBLineEntry ();
+
+ lldb::SBAddress
+ GetStartAddress () const;
+
+ lldb::SBAddress
+ GetEndAddress () const;
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+ lldb::SBFileSpec
+ GetFileSpec () const;
+
+ uint32_t
+ GetLine () const;
+
+ uint32_t
+ GetColumn () const;
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ void
+ SetFileSpec (lldb::SBFileSpec filespec);
+
+ void
+ SetLine (uint32_t line);
+
+ void
+ SetColumn (uint32_t column);
+
+ bool
+ operator == (const lldb::SBLineEntry &rhs) const;
+
+ bool
+ operator != (const lldb::SBLineEntry &rhs) const;
+
+ STRING_EXTENSION(SBLineEntry)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this line entry.''')
+ line = property(GetLine, None, doc='''A read only property that returns the 1 based line number for this line entry, a return value of zero indicates that no line information is available.''')
+ column = property(GetColumn, None, doc='''A read only property that returns the 1 based column number for this line entry, a return value of zero indicates that no column information is available.''')
+ addr = property(GetStartAddress, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this line entry.''')
+ end_addr = property(GetEndAddress, None, doc='''A read only property that returns an lldb object that represents the end address (lldb.SBAddress) for this line entry.''')
+ %}
+#endif
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBListener.i b/lldb/bindings/interface/SBListener.i
new file mode 100644
index 000000000000..535aef9f0ae7
--- /dev/null
+++ b/lldb/bindings/interface/SBListener.i
@@ -0,0 +1,100 @@
+//===-- SWIG Interface for SBListener ---------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"API clients can register its own listener to debugger events.
+
+See aslo SBEvent for example usage of creating and adding a listener."
+) SBListener;
+class SBListener
+{
+public:
+ SBListener ();
+
+ SBListener (const char *name);
+
+ SBListener (const SBListener &rhs);
+
+ ~SBListener ();
+
+ void
+ AddEvent (const lldb::SBEvent &event);
+
+ void
+ Clear ();
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+ uint32_t
+ StartListeningForEventClass (SBDebugger &debugger,
+ const char *broadcaster_class,
+ uint32_t event_mask);
+
+ uint32_t
+ StopListeningForEventClass (SBDebugger &debugger,
+ const char *broadcaster_class,
+ uint32_t event_mask);
+
+ uint32_t
+ StartListeningForEvents (const lldb::SBBroadcaster& broadcaster,
+ uint32_t event_mask);
+
+ bool
+ StopListeningForEvents (const lldb::SBBroadcaster& broadcaster,
+ uint32_t event_mask);
+
+ // Returns true if an event was received, false if we timed out.
+ bool
+ WaitForEvent (uint32_t num_seconds,
+ lldb::SBEvent &event);
+
+ bool
+ WaitForEventForBroadcaster (uint32_t num_seconds,
+ const lldb::SBBroadcaster &broadcaster,
+ lldb::SBEvent &sb_event);
+
+ bool
+ WaitForEventForBroadcasterWithType (uint32_t num_seconds,
+ const lldb::SBBroadcaster &broadcaster,
+ uint32_t event_type_mask,
+ lldb::SBEvent &sb_event);
+
+ bool
+ PeekAtNextEvent (lldb::SBEvent &sb_event);
+
+ bool
+ PeekAtNextEventForBroadcaster (const lldb::SBBroadcaster &broadcaster,
+ lldb::SBEvent &sb_event);
+
+ bool
+ PeekAtNextEventForBroadcasterWithType (const lldb::SBBroadcaster &broadcaster,
+ uint32_t event_type_mask,
+ lldb::SBEvent &sb_event);
+
+ bool
+ GetNextEvent (lldb::SBEvent &sb_event);
+
+ bool
+ GetNextEventForBroadcaster (const lldb::SBBroadcaster &broadcaster,
+ lldb::SBEvent &sb_event);
+
+ bool
+ GetNextEventForBroadcasterWithType (const lldb::SBBroadcaster &broadcaster,
+ uint32_t event_type_mask,
+ lldb::SBEvent &sb_event);
+
+ bool
+ HandleBroadcastEvent (const lldb::SBEvent &event);
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBMemoryRegionInfo.i b/lldb/bindings/interface/SBMemoryRegionInfo.i
new file mode 100644
index 000000000000..6a2ad6a3e364
--- /dev/null
+++ b/lldb/bindings/interface/SBMemoryRegionInfo.i
@@ -0,0 +1,61 @@
+//===-- SWIG Interface for SBMemoryRegionInfo -------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"API clients can get information about memory regions in processes."
+) SBMemoryRegionInfo;
+
+class SBMemoryRegionInfo
+{
+public:
+
+ SBMemoryRegionInfo ();
+
+ SBMemoryRegionInfo (const lldb::SBMemoryRegionInfo &rhs);
+
+ ~SBMemoryRegionInfo ();
+
+ void
+ Clear();
+
+ lldb::addr_t
+ GetRegionBase ();
+
+ lldb::addr_t
+ GetRegionEnd ();
+
+ bool
+ IsReadable ();
+
+ bool
+ IsWritable ();
+
+ bool
+ IsExecutable ();
+
+ bool
+ IsMapped ();
+
+ const char *
+ GetName ();
+
+ bool
+ operator == (const lldb::SBMemoryRegionInfo &rhs) const;
+
+ bool
+ operator != (const lldb::SBMemoryRegionInfo &rhs) const;
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ STRING_EXTENSION(SBMemoryRegionInfo)
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBMemoryRegionInfoList.i b/lldb/bindings/interface/SBMemoryRegionInfoList.i
new file mode 100644
index 000000000000..e408fc0f88b8
--- /dev/null
+++ b/lldb/bindings/interface/SBMemoryRegionInfoList.i
@@ -0,0 +1,37 @@
+//===-- SBMemoryRegionInfoList.h --------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBMemoryRegionInfoList
+{
+public:
+
+ SBMemoryRegionInfoList ();
+
+ SBMemoryRegionInfoList (const lldb::SBMemoryRegionInfoList &rhs);
+
+ ~SBMemoryRegionInfoList ();
+
+ uint32_t
+ GetSize () const;
+
+ bool
+ GetMemoryRegionAtIndex (uint32_t idx, SBMemoryRegionInfo &region_info);
+
+ void
+ Append (lldb::SBMemoryRegionInfo &region);
+
+ void
+ Append (lldb::SBMemoryRegionInfoList &region_list);
+
+ void
+ Clear ();
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBModule.i b/lldb/bindings/interface/SBModule.i
new file mode 100644
index 000000000000..e902af0c49ce
--- /dev/null
+++ b/lldb/bindings/interface/SBModule.i
@@ -0,0 +1,563 @@
+//===-- SWIG Interface for SBModule -----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+#ifdef SWIGPYTHON
+%pythoncode%{
+# ==================================
+# Helper function for SBModule class
+# ==================================
+def in_range(symbol, section):
+ """Test whether a symbol is within the range of a section."""
+ symSA = symbol.GetStartAddress().GetFileAddress()
+ symEA = symbol.GetEndAddress().GetFileAddress()
+ secSA = section.GetFileAddress()
+ secEA = secSA + section.GetByteSize()
+
+ if symEA != LLDB_INVALID_ADDRESS:
+ if secSA <= symSA and symEA <= secEA:
+ return True
+ else:
+ return False
+ else:
+ if secSA <= symSA and symSA < secEA:
+ return True
+ else:
+ return False
+%}
+#endif
+
+%feature("docstring",
+"Represents an executable image and its associated object and symbol files.
+
+The module is designed to be able to select a single slice of an
+executable image as it would appear on disk and during program
+execution.
+
+You can retrieve SBModule from SBSymbolContext, which in turn is available
+from SBFrame.
+
+SBModule supports symbol iteration, for example,
+
+ for symbol in module:
+ name = symbol.GetName()
+ saddr = symbol.GetStartAddress()
+ eaddr = symbol.GetEndAddress()
+
+and rich comparison methods which allow the API program to use,
+
+ if thisModule == thatModule:
+ print('This module is the same as that module')
+
+to test module equality. A module also contains object file sections, namely
+SBSection. SBModule supports section iteration through section_iter(), for
+example,
+
+ print('Number of sections: %d' % module.GetNumSections())
+ for sec in module.section_iter():
+ print(sec)
+
+And to iterate the symbols within a SBSection, use symbol_in_section_iter(),
+
+ # Iterates the text section and prints each symbols within each sub-section.
+ for subsec in text_sec:
+ print(INDENT + repr(subsec))
+ for sym in exe_module.symbol_in_section_iter(subsec):
+ print(INDENT2 + repr(sym))
+ print(INDENT2 + 'symbol type: %s' % symbol_type_to_str(sym.GetType()))
+
+produces this following output:
+
+ [0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text
+ id = {0x00000004}, name = 'mask_access(MaskAction, unsigned int)', range = [0x00000001000017c0-0x0000000100001870)
+ symbol type: code
+ id = {0x00000008}, name = 'thread_func(void*)', range = [0x0000000100001870-0x00000001000019b0)
+ symbol type: code
+ id = {0x0000000c}, name = 'main', range = [0x00000001000019b0-0x0000000100001d5c)
+ symbol type: code
+ id = {0x00000023}, name = 'start', address = 0x0000000100001780
+ symbol type: code
+ [0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs
+ id = {0x00000024}, name = '__stack_chk_fail', range = [0x0000000100001d5c-0x0000000100001d62)
+ symbol type: trampoline
+ id = {0x00000028}, name = 'exit', range = [0x0000000100001d62-0x0000000100001d68)
+ symbol type: trampoline
+ id = {0x00000029}, name = 'fflush', range = [0x0000000100001d68-0x0000000100001d6e)
+ symbol type: trampoline
+ id = {0x0000002a}, name = 'fgets', range = [0x0000000100001d6e-0x0000000100001d74)
+ symbol type: trampoline
+ id = {0x0000002b}, name = 'printf', range = [0x0000000100001d74-0x0000000100001d7a)
+ symbol type: trampoline
+ id = {0x0000002c}, name = 'pthread_create', range = [0x0000000100001d7a-0x0000000100001d80)
+ symbol type: trampoline
+ id = {0x0000002d}, name = 'pthread_join', range = [0x0000000100001d80-0x0000000100001d86)
+ symbol type: trampoline
+ id = {0x0000002e}, name = 'pthread_mutex_lock', range = [0x0000000100001d86-0x0000000100001d8c)
+ symbol type: trampoline
+ id = {0x0000002f}, name = 'pthread_mutex_unlock', range = [0x0000000100001d8c-0x0000000100001d92)
+ symbol type: trampoline
+ id = {0x00000030}, name = 'rand', range = [0x0000000100001d92-0x0000000100001d98)
+ symbol type: trampoline
+ id = {0x00000031}, name = 'strtoul', range = [0x0000000100001d98-0x0000000100001d9e)
+ symbol type: trampoline
+ id = {0x00000032}, name = 'usleep', range = [0x0000000100001d9e-0x0000000100001da4)
+ symbol type: trampoline
+ [0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper
+ [0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring
+ [0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info
+ [0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame
+"
+) SBModule;
+class SBModule
+{
+public:
+
+ SBModule ();
+
+ SBModule (const lldb::SBModule &rhs);
+
+ SBModule (const lldb::SBModuleSpec &module_spec);
+
+ SBModule (lldb::SBProcess &process,
+ lldb::addr_t header_addr);
+
+ ~SBModule ();
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+ void
+ Clear();
+
+ %feature("docstring", "
+ Get const accessor for the module file specification.
+
+ This function returns the file for the module on the host system
+ that is running LLDB. This can differ from the path on the
+ platform since we might be doing remote debugging.
+
+ @return
+ A const reference to the file specification object.") GetFileSpec;
+ lldb::SBFileSpec
+ GetFileSpec () const;
+
+ %feature("docstring", "
+ Get accessor for the module platform file specification.
+
+ Platform file refers to the path of the module as it is known on
+ the remote system on which it is being debugged. For local
+ debugging this is always the same as Module::GetFileSpec(). But
+ remote debugging might mention a file '/usr/lib/liba.dylib'
+ which might be locally downloaded and cached. In this case the
+ platform file could be something like:
+ '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib'
+ The file could also be cached in a local developer kit directory.
+
+ @return
+ A const reference to the file specification object.") GetPlatformFileSpec;
+ lldb::SBFileSpec
+ GetPlatformFileSpec () const;
+
+ bool
+ SetPlatformFileSpec (const lldb::SBFileSpec &platform_file);
+
+ lldb::SBFileSpec
+ GetRemoteInstallFileSpec ();
+
+ bool
+ SetRemoteInstallFileSpec (lldb::SBFileSpec &file);
+
+ %feature("docstring", "Returns the UUID of the module as a Python string."
+ ) GetUUIDString;
+ const char *
+ GetUUIDString () const;
+
+ bool operator==(const lldb::SBModule &rhs) const;
+
+ bool operator!=(const lldb::SBModule &rhs) const;
+
+ lldb::SBSection
+ FindSection (const char *sect_name);
+
+ lldb::SBAddress
+ ResolveFileAddress (lldb::addr_t vm_addr);
+
+ lldb::SBSymbolContext
+ ResolveSymbolContextForAddress (const lldb::SBAddress& addr,
+ uint32_t resolve_scope);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ uint32_t
+ GetNumCompileUnits();
+
+ lldb::SBCompileUnit
+ GetCompileUnitAtIndex (uint32_t);
+
+ %feature("docstring", "
+ Find compile units related to *this module and passed source
+ file.
+
+ @param[in] sb_file_spec
+ A lldb::SBFileSpec object that contains source file
+ specification.
+
+ @return
+ A lldb::SBSymbolContextList that gets filled in with all of
+ the symbol contexts for all the matches.") FindCompileUnits;
+ lldb::SBSymbolContextList
+ FindCompileUnits (const lldb::SBFileSpec &sb_file_spec);
+
+ size_t
+ GetNumSymbols ();
+
+ lldb::SBSymbol
+ GetSymbolAtIndex (size_t idx);
+
+ lldb::SBSymbol
+ FindSymbol (const char *name,
+ lldb::SymbolType type = eSymbolTypeAny);
+
+ lldb::SBSymbolContextList
+ FindSymbols (const char *name,
+ lldb::SymbolType type = eSymbolTypeAny);
+
+
+ size_t
+ GetNumSections ();
+
+ lldb::SBSection
+ GetSectionAtIndex (size_t idx);
+
+
+ %feature("docstring", "
+ Find functions by name.
+
+ @param[in] name
+ The name of the function we are looking for.
+
+ @param[in] name_type_mask
+ A logical OR of one or more FunctionNameType enum bits that
+ indicate what kind of names should be used when doing the
+ lookup. Bits include fully qualified names, base names,
+ C++ methods, or ObjC selectors.
+ See FunctionNameType for more details.
+
+ @return
+ A symbol context list that gets filled in with all of the
+ matches.") FindFunctions;
+ lldb::SBSymbolContextList
+ FindFunctions (const char *name,
+ uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
+
+ lldb::SBType
+ FindFirstType (const char* name);
+
+ lldb::SBTypeList
+ FindTypes (const char* type);
+
+ lldb::SBType
+ GetTypeByID (lldb::user_id_t uid);
+
+ lldb::SBType
+ GetBasicType(lldb::BasicType type);
+
+ %feature("docstring", "
+ Get all types matching type_mask from debug info in this
+ module.
+
+ @param[in] type_mask
+ A bitfield that consists of one or more bits logically OR'ed
+ together from the lldb::TypeClass enumeration. This allows
+ you to request only structure types, or only class, struct
+ and union types. Passing in lldb::eTypeClassAny will return
+ all types found in the debug information for this module.
+
+ @return
+ A list of types in this module that match type_mask") GetTypes;
+ lldb::SBTypeList
+ GetTypes (uint32_t type_mask = lldb::eTypeClassAny);
+
+ %feature("docstring", "
+ Find global and static variables by name.
+
+ @param[in] target
+ A valid SBTarget instance representing the debuggee.
+
+ @param[in] name
+ The name of the global or static variable we are looking
+ for.
+
+ @param[in] max_matches
+ Allow the number of matches to be limited to max_matches.
+
+ @return
+ A list of matched variables in an SBValueList.") FindGlobalVariables;
+ lldb::SBValueList
+ FindGlobalVariables (lldb::SBTarget &target,
+ const char *name,
+ uint32_t max_matches);
+
+ %feature("docstring", "
+ Find the first global (or static) variable by name.
+
+ @param[in] target
+ A valid SBTarget instance representing the debuggee.
+
+ @param[in] name
+ The name of the global or static variable we are looking
+ for.
+
+ @return
+ An SBValue that gets filled in with the found variable (if any).") FindFirstGlobalVariable;
+ lldb::SBValue
+ FindFirstGlobalVariable (lldb::SBTarget &target, const char *name);
+
+ lldb::ByteOrder
+ GetByteOrder ();
+
+ uint32_t
+ GetAddressByteSize();
+
+ const char *
+ GetTriple ();
+
+ uint32_t
+ GetVersion (uint32_t *versions,
+ uint32_t num_versions);
+
+ lldb::SBFileSpec
+ GetSymbolFileSpec() const;
+
+ lldb::SBAddress
+ GetObjectFileHeaderAddress() const;
+
+ lldb::SBAddress
+ GetObjectFileEntryPointAddress() const;
+
+ %feature("docstring", "
+ Returns the number of modules in the module cache. This is an
+ implementation detail exposed for testing and should not be relied upon.
+
+ @return
+ The number of modules in the module cache.") GetNumberAllocatedModules;
+ static uint32_t
+ GetNumberAllocatedModules();
+
+ STRING_EXTENSION(SBModule)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ def __len__(self):
+ '''Return the number of symbols in a lldb.SBModule object.'''
+ return self.GetNumSymbols()
+
+ def __iter__(self):
+ '''Iterate over all symbols in a lldb.SBModule object.'''
+ return lldb_iter(self, 'GetNumSymbols', 'GetSymbolAtIndex')
+
+ def section_iter(self):
+ '''Iterate over all sections in a lldb.SBModule object.'''
+ return lldb_iter(self, 'GetNumSections', 'GetSectionAtIndex')
+
+ def compile_unit_iter(self):
+ '''Iterate over all compile units in a lldb.SBModule object.'''
+ return lldb_iter(self, 'GetNumCompileUnits', 'GetCompileUnitAtIndex')
+
+ def symbol_in_section_iter(self, section):
+ '''Given a module and its contained section, returns an iterator on the
+ symbols within the section.'''
+ for sym in self:
+ if in_range(sym, section):
+ yield sym
+
+ class symbols_access(object):
+ re_compile_type = type(re.compile('.'))
+ '''A helper object that will lazily hand out lldb.SBSymbol objects for a module when supplied an index, name, or regular expression.'''
+ def __init__(self, sbmodule):
+ self.sbmodule = sbmodule
+
+ def __len__(self):
+ if self.sbmodule:
+ return int(self.sbmodule.GetNumSymbols())
+ return 0
+
+ def __getitem__(self, key):
+ count = len(self)
+ if type(key) is int:
+ if key < count:
+ return self.sbmodule.GetSymbolAtIndex(key)
+ elif type(key) is str:
+ matches = []
+ sc_list = self.sbmodule.FindSymbols(key)
+ for sc in sc_list:
+ symbol = sc.symbol
+ if symbol:
+ matches.append(symbol)
+ return matches
+ elif isinstance(key, self.re_compile_type):
+ matches = []
+ for idx in range(count):
+ symbol = self.sbmodule.GetSymbolAtIndex(idx)
+ added = False
+ name = symbol.name
+ if name:
+ re_match = key.search(name)
+ if re_match:
+ matches.append(symbol)
+ added = True
+ if not added:
+ mangled = symbol.mangled
+ if mangled:
+ re_match = key.search(mangled)
+ if re_match:
+ matches.append(symbol)
+ return matches
+ else:
+ print("error: unsupported item type: %s" % type(key))
+ return None
+
+ def get_symbols_access_object(self):
+ '''An accessor function that returns a symbols_access() object which allows lazy symbol access from a lldb.SBModule object.'''
+ return self.symbols_access (self)
+
+ def get_compile_units_access_object (self):
+ '''An accessor function that returns a compile_units_access() object which allows lazy compile unit access from a lldb.SBModule object.'''
+ return self.compile_units_access (self)
+
+ def get_symbols_array(self):
+ '''An accessor function that returns a list() that contains all symbols in a lldb.SBModule object.'''
+ symbols = []
+ for idx in range(self.num_symbols):
+ symbols.append(self.GetSymbolAtIndex(idx))
+ return symbols
+
+ class sections_access(object):
+ re_compile_type = type(re.compile('.'))
+ '''A helper object that will lazily hand out lldb.SBSection objects for a module when supplied an index, name, or regular expression.'''
+ def __init__(self, sbmodule):
+ self.sbmodule = sbmodule
+
+ def __len__(self):
+ if self.sbmodule:
+ return int(self.sbmodule.GetNumSections())
+ return 0
+
+ def __getitem__(self, key):
+ count = len(self)
+ if type(key) is int:
+ if key < count:
+ return self.sbmodule.GetSectionAtIndex(key)
+ elif type(key) is str:
+ for idx in range(count):
+ section = self.sbmodule.GetSectionAtIndex(idx)
+ if section.name == key:
+ return section
+ elif isinstance(key, self.re_compile_type):
+ matches = []
+ for idx in range(count):
+ section = self.sbmodule.GetSectionAtIndex(idx)
+ name = section.name
+ if name:
+ re_match = key.search(name)
+ if re_match:
+ matches.append(section)
+ return matches
+ else:
+ print("error: unsupported item type: %s" % type(key))
+ return None
+
+ class compile_units_access(object):
+ re_compile_type = type(re.compile('.'))
+ '''A helper object that will lazily hand out lldb.SBCompileUnit objects for a module when supplied an index, full or partial path, or regular expression.'''
+ def __init__(self, sbmodule):
+ self.sbmodule = sbmodule
+
+ def __len__(self):
+ if self.sbmodule:
+ return int(self.sbmodule.GetNumCompileUnits())
+ return 0
+
+ def __getitem__(self, key):
+ count = len(self)
+ if type(key) is int:
+ if key < count:
+ return self.sbmodule.GetCompileUnitAtIndex(key)
+ elif type(key) is str:
+ is_full_path = key[0] == '/'
+ for idx in range(count):
+ comp_unit = self.sbmodule.GetCompileUnitAtIndex(idx)
+ if is_full_path:
+ if comp_unit.file.fullpath == key:
+ return comp_unit
+ else:
+ if comp_unit.file.basename == key:
+ return comp_unit
+ elif isinstance(key, self.re_compile_type):
+ matches = []
+ for idx in range(count):
+ comp_unit = self.sbmodule.GetCompileUnitAtIndex(idx)
+ fullpath = comp_unit.file.fullpath
+ if fullpath:
+ re_match = key.search(fullpath)
+ if re_match:
+ matches.append(comp_unit)
+ return matches
+ else:
+ print("error: unsupported item type: %s" % type(key))
+ return None
+
+ def get_sections_access_object(self):
+ '''An accessor function that returns a sections_access() object which allows lazy section array access.'''
+ return self.sections_access (self)
+
+ def get_sections_array(self):
+ '''An accessor function that returns an array object that contains all sections in this module object.'''
+ if not hasattr(self, 'sections_array'):
+ self.sections_array = []
+ for idx in range(self.num_sections):
+ self.sections_array.append(self.GetSectionAtIndex(idx))
+ return self.sections_array
+
+ def get_compile_units_array(self):
+ '''An accessor function that returns an array object that contains all compile_units in this module object.'''
+ if not hasattr(self, 'compile_units_array'):
+ self.compile_units_array = []
+ for idx in range(self.GetNumCompileUnits()):
+ self.compile_units_array.append(self.GetCompileUnitAtIndex(idx))
+ return self.compile_units_array
+
+ symbols = property(get_symbols_array, None, doc='''A read only property that returns a list() of lldb.SBSymbol objects contained in this module.''')
+ symbol = property(get_symbols_access_object, None, doc='''A read only property that can be used to access symbols by index ("symbol = module.symbol[0]"), name ("symbols = module.symbol['main']"), or using a regular expression ("symbols = module.symbol[re.compile(...)]"). The return value is a single lldb.SBSymbol object for array access, and a list() of lldb.SBSymbol objects for name and regular expression access''')
+ sections = property(get_sections_array, None, doc='''A read only property that returns a list() of lldb.SBSection objects contained in this module.''')
+ compile_units = property(get_compile_units_array, None, doc='''A read only property that returns a list() of lldb.SBCompileUnit objects contained in this module.''')
+ section = property(get_sections_access_object, None, doc='''A read only property that can be used to access symbols by index ("section = module.section[0]"), name ("sections = module.section[\'main\']"), or using a regular expression ("sections = module.section[re.compile(...)]"). The return value is a single lldb.SBSection object for array access, and a list() of lldb.SBSection objects for name and regular expression access''')
+ section = property(get_sections_access_object, None, doc='''A read only property that can be used to access compile units by index ("compile_unit = module.compile_unit[0]"), name ("compile_unit = module.compile_unit[\'main.cpp\']"), or using a regular expression ("compile_unit = module.compile_unit[re.compile(...)]"). The return value is a single lldb.SBCompileUnit object for array access or by full or partial path, and a list() of lldb.SBCompileUnit objects regular expressions.''')
+
+ def get_uuid(self):
+ return uuid.UUID (self.GetUUIDString())
+
+ uuid = property(get_uuid, None, doc='''A read only property that returns a standard python uuid.UUID object that represents the UUID of this module.''')
+ file = property(GetFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this object file for this module as it is represented where it is being debugged.''')
+ platform_file = property(GetPlatformFileSpec, None, doc='''A read only property that returns an lldb object that represents the file (lldb.SBFileSpec) for this object file for this module as it is represented on the current host system.''')
+ byte_order = property(GetByteOrder, None, doc='''A read only property that returns an lldb enumeration value (lldb.eByteOrderLittle, lldb.eByteOrderBig, lldb.eByteOrderInvalid) that represents the byte order for this module.''')
+ addr_size = property(GetAddressByteSize, None, doc='''A read only property that returns the size in bytes of an address for this module.''')
+ triple = property(GetTriple, None, doc='''A read only property that returns the target triple (arch-vendor-os) for this module.''')
+ num_symbols = property(GetNumSymbols, None, doc='''A read only property that returns number of symbols in the module symbol table as an integer.''')
+ num_sections = property(GetNumSections, None, doc='''A read only property that returns number of sections in the module as an integer.''')
+
+ %}
+#endif
+
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBModuleSpec.i b/lldb/bindings/interface/SBModuleSpec.i
new file mode 100644
index 000000000000..64d0aa641a77
--- /dev/null
+++ b/lldb/bindings/interface/SBModuleSpec.i
@@ -0,0 +1,134 @@
+//===-- SWIG Interface for SBModule -----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBModuleSpec
+{
+public:
+
+ SBModuleSpec ();
+
+ SBModuleSpec (const lldb::SBModuleSpec &rhs);
+
+ ~SBModuleSpec ();
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+ void
+ Clear();
+
+ %feature("docstring", "
+ Get const accessor for the module file.
+
+ This function returns the file for the module on the host system
+ that is running LLDB. This can differ from the path on the
+ platform since we might be doing remote debugging.
+
+ @return
+ A const reference to the file specification object.") GetFileSpec;
+ lldb::SBFileSpec
+ GetFileSpec ();
+
+ void
+ SetFileSpec (const lldb::SBFileSpec &fspec);
+
+ %feature("docstring", "
+ Get accessor for the module platform file.
+
+ Platform file refers to the path of the module as it is known on
+ the remote system on which it is being debugged. For local
+ debugging this is always the same as Module::GetFileSpec(). But
+ remote debugging might mention a file '/usr/lib/liba.dylib'
+ which might be locally downloaded and cached. In this case the
+ platform file could be something like:
+ '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib'
+ The file could also be cached in a local developer kit directory.
+
+ @return
+ A const reference to the file specification object.") GetPlatformFileSpec;
+ lldb::SBFileSpec
+ GetPlatformFileSpec ();
+
+ void
+ SetPlatformFileSpec (const lldb::SBFileSpec &fspec);
+
+ lldb::SBFileSpec
+ GetSymbolFileSpec ();
+
+ void
+ SetSymbolFileSpec (const lldb::SBFileSpec &fspec);
+
+ const char *
+ GetObjectName ();
+
+ void
+ SetObjectName (const char *name);
+
+ const char *
+ GetTriple ();
+
+ void
+ SetTriple (const char *triple);
+
+ const uint8_t *
+ GetUUIDBytes ();
+
+ size_t
+ GetUUIDLength ();
+
+ bool
+ SetUUIDBytes (const uint8_t *uuid, size_t uuid_len);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ STRING_EXTENSION(SBModuleSpec)
+};
+
+
+class SBModuleSpecList
+{
+public:
+ SBModuleSpecList();
+
+ SBModuleSpecList (const SBModuleSpecList &rhs);
+
+ ~SBModuleSpecList();
+
+ static SBModuleSpecList
+ GetModuleSpecifications (const char *path);
+
+ void
+ Append (const lldb::SBModuleSpec &spec);
+
+ void
+ Append (const lldb::SBModuleSpecList &spec_list);
+
+ lldb::SBModuleSpec
+ FindFirstMatchingSpec (const lldb::SBModuleSpec &match_spec);
+
+ lldb::SBModuleSpecList
+ FindMatchingSpecs (const lldb::SBModuleSpec &match_spec);
+
+ size_t
+ GetSize();
+
+ lldb::SBModuleSpec
+ GetSpecAtIndex (size_t i);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ STRING_EXTENSION(SBModuleSpecList)
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBPlatform.i b/lldb/bindings/interface/SBPlatform.i
new file mode 100644
index 000000000000..81945222c059
--- /dev/null
+++ b/lldb/bindings/interface/SBPlatform.i
@@ -0,0 +1,202 @@
+//===-- SWIG Interface for SBPlatform ---------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+
+class SBPlatformConnectOptions
+{
+public:
+ SBPlatformConnectOptions (const char *url);
+
+ SBPlatformConnectOptions (const SBPlatformConnectOptions &rhs);
+
+ ~SBPlatformConnectOptions ();
+
+ const char *
+ GetURL();
+
+ void
+ SetURL(const char *url);
+
+ bool
+ GetRsyncEnabled();
+
+ void
+ EnableRsync (const char *options,
+ const char *remote_path_prefix,
+ bool omit_remote_hostname);
+
+ void
+ DisableRsync ();
+
+ const char *
+ GetLocalCacheDirectory();
+
+ void
+ SetLocalCacheDirectory(const char *path);
+};
+
+class SBPlatformShellCommand
+{
+public:
+ SBPlatformShellCommand (const char *shell_command);
+
+ SBPlatformShellCommand (const SBPlatformShellCommand &rhs);
+
+ ~SBPlatformShellCommand();
+
+ void
+ Clear();
+
+ const char *
+ GetCommand();
+
+ void
+ SetCommand(const char *shell_command);
+
+ const char *
+ GetWorkingDirectory ();
+
+ void
+ SetWorkingDirectory (const char *path);
+
+ uint32_t
+ GetTimeoutSeconds ();
+
+ void
+ SetTimeoutSeconds (uint32_t sec);
+
+ int
+ GetSignal ();
+
+ int
+ GetStatus ();
+
+ const char *
+ GetOutput ();
+};
+
+%feature("docstring",
+"A class that represents a platform that can represent the current host or a remote host debug platform.
+
+The SBPlatform class represents the current host, or a remote host.
+It can be connected to a remote platform in order to provide ways
+to remotely launch and attach to processes, upload/download files,
+create directories, run remote shell commands, find locally cached
+versions of files from the remote system, and much more.
+
+SBPlatform objects can be created and then used to connect to a remote
+platform which allows the SBPlatform to be used to get a list of the
+current processes on the remote host, attach to one of those processes,
+install programs on the remote system, attach and launch processes,
+and much more.
+
+Every SBTarget has a corresponding SBPlatform. The platform can be
+specified upon target creation, or the currently selected platform
+will attempt to be used when creating the target automatically as long
+as the currently selected platform matches the target architecture
+and executable type. If the architecture or executable type do not match,
+a suitable platform will be found automatically."
+
+) SBPlatform;
+class SBPlatform
+{
+public:
+
+ SBPlatform ();
+
+ SBPlatform (const char *);
+
+ ~SBPlatform();
+
+ static SBPlatform GetHostPlatform();
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+ void
+ Clear ();
+
+ const char *
+ GetWorkingDirectory();
+
+ bool
+ SetWorkingDirectory(const char *);
+
+ const char *
+ GetName ();
+
+ SBError
+ ConnectRemote (lldb::SBPlatformConnectOptions &connect_options);
+
+ void
+ DisconnectRemote ();
+
+ bool
+ IsConnected();
+
+ const char *
+ GetTriple();
+
+ const char *
+ GetHostname ();
+
+ const char *
+ GetOSBuild ();
+
+ const char *
+ GetOSDescription ();
+
+ uint32_t
+ GetOSMajorVersion ();
+
+ uint32_t
+ GetOSMinorVersion ();
+
+ uint32_t
+ GetOSUpdateVersion ();
+
+ lldb::SBError
+ Get (lldb::SBFileSpec &src, lldb::SBFileSpec &dst);
+
+ lldb::SBError
+ Put (lldb::SBFileSpec &src, lldb::SBFileSpec &dst);
+
+ lldb::SBError
+ Install (lldb::SBFileSpec &src, lldb::SBFileSpec &dst);
+
+ lldb::SBError
+ Run (lldb::SBPlatformShellCommand &shell_command);
+
+ lldb::SBError
+ Launch (lldb::SBLaunchInfo &launch_info);
+
+ lldb::SBError
+ Kill (const lldb::pid_t pid);
+
+ lldb::SBError
+ MakeDirectory (const char *path, uint32_t file_permissions = lldb::eFilePermissionsDirectoryDefault);
+
+ uint32_t
+ GetFilePermissions (const char *path);
+
+ lldb::SBError
+ SetFilePermissions (const char *path, uint32_t file_permissions);
+
+ lldb::SBUnixSignals
+ GetUnixSignals();
+
+ lldb::SBEnvironment
+ GetEnvironment();
+
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBProcess.i b/lldb/bindings/interface/SBProcess.i
new file mode 100644
index 000000000000..b54c4629f9df
--- /dev/null
+++ b/lldb/bindings/interface/SBProcess.i
@@ -0,0 +1,510 @@
+//===-- SWIG Interface for SBProcess ----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents the process associated with the target program.
+
+SBProcess supports thread iteration. For example (from test/lldbutil.py),
+
+# ==================================================
+# Utility functions related to Threads and Processes
+# ==================================================
+
+def get_stopped_threads(process, reason):
+ '''Returns the thread(s) with the specified stop reason in a list.
+
+ The list can be empty if no such thread exists.
+ '''
+ threads = []
+ for t in process:
+ if t.GetStopReason() == reason:
+ threads.append(t)
+ return threads
+
+...
+"
+) SBProcess;
+class SBProcess
+{
+public:
+ enum
+ {
+ eBroadcastBitStateChanged = (1 << 0),
+ eBroadcastBitInterrupt = (1 << 1),
+ eBroadcastBitSTDOUT = (1 << 2),
+ eBroadcastBitSTDERR = (1 << 3),
+ eBroadcastBitProfileData = (1 << 4),
+ eBroadcastBitStructuredData = (1 << 5)
+ };
+
+ SBProcess ();
+
+ SBProcess (const lldb::SBProcess& rhs);
+
+ ~SBProcess();
+
+ static const char *
+ GetBroadcasterClassName ();
+
+ const char *
+ GetPluginName ();
+
+ const char *
+ GetShortPluginName ();
+
+ void
+ Clear ();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ lldb::SBTarget
+ GetTarget() const;
+
+ lldb::ByteOrder
+ GetByteOrder() const;
+
+ %feature("autodoc", "
+ Writes data into the current process's stdin. API client specifies a Python
+ string as the only argument.") PutSTDIN;
+ size_t
+ PutSTDIN (const char *src, size_t src_len);
+
+ %feature("autodoc", "
+ Reads data from the current process's stdout stream. API client specifies
+ the size of the buffer to read data into. It returns the byte buffer in a
+ Python string.") GetSTDOUT;
+ size_t
+ GetSTDOUT (char *dst, size_t dst_len) const;
+
+ %feature("autodoc", "
+ Reads data from the current process's stderr stream. API client specifies
+ the size of the buffer to read data into. It returns the byte buffer in a
+ Python string.") GetSTDERR;
+ size_t
+ GetSTDERR (char *dst, size_t dst_len) const;
+
+ size_t
+ GetAsyncProfileData(char *dst, size_t dst_len) const;
+
+ void
+ ReportEventState (const lldb::SBEvent &event, SBFile out) const;
+
+ void
+ ReportEventState (const lldb::SBEvent &event, FileSP BORROWED) const;
+
+ void
+ AppendEventStateReport (const lldb::SBEvent &event, lldb::SBCommandReturnObject &result);
+
+ %feature("docstring", "
+ Remote connection related functions. These will fail if the
+ process is not in eStateConnected. They are intended for use
+ when connecting to an externally managed debugserver instance.") RemoteAttachToProcessWithID;
+ bool
+ RemoteAttachToProcessWithID (lldb::pid_t pid,
+ lldb::SBError& error);
+
+ %feature("docstring",
+ "See SBTarget.Launch for argument description and usage."
+ ) RemoteLaunch;
+ bool
+ RemoteLaunch (char const **argv,
+ char const **envp,
+ const char *stdin_path,
+ const char *stdout_path,
+ const char *stderr_path,
+ const char *working_directory,
+ uint32_t launch_flags,
+ bool stop_at_entry,
+ lldb::SBError& error);
+
+ //------------------------------------------------------------------
+ // Thread related functions
+ //------------------------------------------------------------------
+ uint32_t
+ GetNumThreads ();
+
+ %feature("autodoc", "
+ Returns the INDEX'th thread from the list of current threads. The index
+ of a thread is only valid for the current stop. For a persistent thread
+ identifier use either the thread ID or the IndexID. See help on SBThread
+ for more details.") GetThreadAtIndex;
+ lldb::SBThread
+ GetThreadAtIndex (size_t index);
+
+ %feature("autodoc", "
+ Returns the thread with the given thread ID.") GetThreadByID;
+ lldb::SBThread
+ GetThreadByID (lldb::tid_t sb_thread_id);
+
+ %feature("autodoc", "
+ Returns the thread with the given thread IndexID.") GetThreadByIndexID;
+ lldb::SBThread
+ GetThreadByIndexID (uint32_t index_id);
+
+ %feature("autodoc", "
+ Returns the currently selected thread.") GetSelectedThread;
+ lldb::SBThread
+ GetSelectedThread () const;
+
+ %feature("autodoc", "
+ Lazily create a thread on demand through the current OperatingSystem plug-in, if the current OperatingSystem plug-in supports it.") CreateOSPluginThread;
+ lldb::SBThread
+ CreateOSPluginThread (lldb::tid_t tid, lldb::addr_t context);
+
+ bool
+ SetSelectedThread (const lldb::SBThread &thread);
+
+ bool
+ SetSelectedThreadByID (lldb::tid_t tid);
+
+ bool
+ SetSelectedThreadByIndexID (uint32_t index_id);
+
+ //------------------------------------------------------------------
+ // Queue related functions
+ //------------------------------------------------------------------
+ uint32_t
+ GetNumQueues ();
+
+ lldb::SBQueue
+ GetQueueAtIndex (uint32_t index);
+
+ //------------------------------------------------------------------
+ // Stepping related functions
+ //------------------------------------------------------------------
+
+ lldb::StateType
+ GetState ();
+
+ int
+ GetExitStatus ();
+
+ const char *
+ GetExitDescription ();
+
+ %feature("autodoc", "
+ Returns the process ID of the process.") GetProcessID;
+ lldb::pid_t
+ GetProcessID ();
+
+ %feature("autodoc", "
+ Returns an integer ID that is guaranteed to be unique across all process instances. This is not the process ID, just a unique integer for comparison and caching purposes.") GetUniqueID;
+ uint32_t
+ GetUniqueID();
+
+ uint32_t
+ GetAddressByteSize() const;
+
+ %feature("docstring", "
+ Kills the process and shuts down all threads that were spawned to
+ track and monitor process.") Destroy;
+ lldb::SBError
+ Destroy ();
+
+ lldb::SBError
+ Continue ();
+
+ lldb::SBError
+ Stop ();
+
+ %feature("docstring", "Same as Destroy(self).") Destroy;
+ lldb::SBError
+ Kill ();
+
+ lldb::SBError
+ Detach ();
+
+ %feature("docstring", "Sends the process a unix signal.") Signal;
+ lldb::SBError
+ Signal (int signal);
+
+ lldb::SBUnixSignals
+ GetUnixSignals();
+
+ %feature("docstring", "
+ Returns a stop id that will increase every time the process executes. If
+ include_expression_stops is true, then stops caused by expression evaluation
+ will cause the returned value to increase, otherwise the counter returned will
+ only increase when execution is continued explicitly by the user. Note, the value
+ will always increase, but may increase by more than one per stop.") GetStopID;
+ uint32_t
+ GetStopID(bool include_expression_stops = false);
+
+ void
+ SendAsyncInterrupt();
+
+ %feature("autodoc", "
+ Reads memory from the current process's address space and removes any
+ traps that may have been inserted into the memory. It returns the byte
+ buffer in a Python string. Example:
+
+ # Read 4 bytes from address 'addr' and assume error.Success() is True.
+ content = process.ReadMemory(addr, 4, error)
+ new_bytes = bytearray(content)") ReadMemory;
+ size_t
+ ReadMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error);
+
+ %feature("autodoc", "
+ Writes memory to the current process's address space and maintains any
+ traps that might be present due to software breakpoints. Example:
+
+ # Create a Python string from the byte array.
+ new_value = str(bytes)
+ result = process.WriteMemory(addr, new_value, error)
+ if not error.Success() or result != len(bytes):
+ print('SBProcess.WriteMemory() failed!')") WriteMemory;
+ size_t
+ WriteMemory (addr_t addr, const void *buf, size_t size, lldb::SBError &error);
+
+ %feature("autodoc", "
+ Reads a NULL terminated C string from the current process's address space.
+ It returns a python string of the exact length, or truncates the string if
+ the maximum character limit is reached. Example:
+
+ # Read a C string of at most 256 bytes from address '0x1000'
+ error = lldb.SBError()
+ cstring = process.ReadCStringFromMemory(0x1000, 256, error)
+ if error.Success():
+ print('cstring: ', cstring)
+ else
+ print('error: ', error)") ReadCStringFromMemory;
+
+ size_t
+ ReadCStringFromMemory (addr_t addr, void *char_buf, size_t size, lldb::SBError &error);
+
+ %feature("autodoc", "
+ Reads an unsigned integer from memory given a byte size and an address.
+ Returns the unsigned integer that was read. Example:
+
+ # Read a 4 byte unsigned integer from address 0x1000
+ error = lldb.SBError()
+ uint = ReadUnsignedFromMemory(0x1000, 4, error)
+ if error.Success():
+ print('integer: %u' % uint)
+ else
+ print('error: ', error)") ReadUnsignedFromMemory;
+
+ uint64_t
+ ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error);
+
+ %feature("autodoc", "
+ Reads a pointer from memory from an address and returns the value. Example:
+
+ # Read a pointer from address 0x1000
+ error = lldb.SBError()
+ ptr = ReadPointerFromMemory(0x1000, error)
+ if error.Success():
+ print('pointer: 0x%x' % ptr)
+ else
+ print('error: ', error)") ReadPointerFromMemory;
+
+ lldb::addr_t
+ ReadPointerFromMemory (addr_t addr, lldb::SBError &error);
+
+
+ // Events
+ static lldb::StateType
+ GetStateFromEvent (const lldb::SBEvent &event);
+
+ static bool
+ GetRestartedFromEvent (const lldb::SBEvent &event);
+
+ static size_t
+ GetNumRestartedReasonsFromEvent (const lldb::SBEvent &event);
+
+ static const char *
+ GetRestartedReasonAtIndexFromEvent (const lldb::SBEvent &event, size_t idx);
+
+ static lldb::SBProcess
+ GetProcessFromEvent (const lldb::SBEvent &event);
+
+ static bool
+ GetInterruptedFromEvent (const lldb::SBEvent &event);
+
+ static lldb::SBStructuredData
+ GetStructuredDataFromEvent (const lldb::SBEvent &event);
+
+ static bool
+ EventIsProcessEvent (const lldb::SBEvent &event);
+
+ static bool
+ EventIsStructuredDataEvent (const lldb::SBEvent &event);
+
+ lldb::SBBroadcaster
+ GetBroadcaster () const;
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ %feature("autodoc", "
+ Returns the process' extended crash information.") GetExtendedCrashInformation;
+ lldb::SBStructuredData
+ GetExtendedCrashInformation ();
+
+ uint32_t
+ GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const;
+
+ uint32_t
+ LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error);
+
+ %feature("autodoc", "
+ Load the library whose filename is given by image_spec looking in all the
+ paths supplied in the paths argument. If successful, return a token that
+ can be passed to UnloadImage and fill loaded_path with the path that was
+ successfully loaded. On failure, return
+ lldb.LLDB_INVALID_IMAGE_TOKEN.") LoadImageUsingPaths;
+ uint32_t
+ LoadImageUsingPaths(const lldb::SBFileSpec &image_spec,
+ SBStringList &paths,
+ lldb::SBFileSpec &loaded_path,
+ SBError &error);
+
+ lldb::SBError
+ UnloadImage (uint32_t image_token);
+
+ lldb::SBError
+ SendEventData (const char *event_data);
+
+ %feature("autodoc", "
+ Return the number of different thread-origin extended backtraces
+ this process can support as a uint32_t.
+ When the process is stopped and you have an SBThread, lldb may be
+ able to show a backtrace of when that thread was originally created,
+ or the work item was enqueued to it (in the case of a libdispatch
+ queue).") GetNumExtendedBacktraceTypes;
+
+ uint32_t
+ GetNumExtendedBacktraceTypes ();
+
+ %feature("autodoc", "
+ Takes an index argument, returns the name of one of the thread-origin
+ extended backtrace methods as a str.") GetExtendedBacktraceTypeAtIndex;
+
+ const char *
+ GetExtendedBacktraceTypeAtIndex (uint32_t idx);
+
+ lldb::SBThreadCollection
+ GetHistoryThreads (addr_t addr);
+
+ bool
+ IsInstrumentationRuntimePresent(lldb::InstrumentationRuntimeType type);
+
+ lldb::SBError
+ SaveCore(const char *file_name);
+
+ lldb::SBTrace
+ StartTrace(SBTraceOptions &options, lldb::SBError &error);
+
+ lldb::SBError
+ GetMemoryRegionInfo(lldb::addr_t load_addr, lldb::SBMemoryRegionInfo &region_info);
+
+ lldb::SBMemoryRegionInfoList
+ GetMemoryRegions();
+
+ %feature("autodoc", "
+ Get information about the process.
+ Valid process info will only be returned when the process is alive,
+ use IsValid() to check if the info returned is valid.
+
+ process_info = process.GetProcessInfo()
+ if process_info.IsValid():
+ process_info.GetProcessID()") GetProcessInfo;
+ lldb::SBProcessInfo
+ GetProcessInfo();
+
+ STRING_EXTENSION(SBProcess)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ def __get_is_alive__(self):
+ '''Returns "True" if the process is currently alive, "False" otherwise'''
+ s = self.GetState()
+ if (s == eStateAttaching or
+ s == eStateLaunching or
+ s == eStateStopped or
+ s == eStateRunning or
+ s == eStateStepping or
+ s == eStateCrashed or
+ s == eStateSuspended):
+ return True
+ return False
+
+ def __get_is_running__(self):
+ '''Returns "True" if the process is currently running, "False" otherwise'''
+ state = self.GetState()
+ if state == eStateRunning or state == eStateStepping:
+ return True
+ return False
+
+ def __get_is_stopped__(self):
+ '''Returns "True" if the process is currently stopped, "False" otherwise'''
+ state = self.GetState()
+ if state == eStateStopped or state == eStateCrashed or state == eStateSuspended:
+ return True
+ return False
+
+ class threads_access(object):
+ '''A helper object that will lazily hand out thread for a process when supplied an index.'''
+ def __init__(self, sbprocess):
+ self.sbprocess = sbprocess
+
+ def __len__(self):
+ if self.sbprocess:
+ return int(self.sbprocess.GetNumThreads())
+ return 0
+
+ def __getitem__(self, key):
+ if type(key) is int and key < len(self):
+ return self.sbprocess.GetThreadAtIndex(key)
+ return None
+
+ def get_threads_access_object(self):
+ '''An accessor function that returns a modules_access() object which allows lazy thread access from a lldb.SBProcess object.'''
+ return self.threads_access (self)
+
+ def get_process_thread_list(self):
+ '''An accessor function that returns a list() that contains all threads in a lldb.SBProcess object.'''
+ threads = []
+ accessor = self.get_threads_access_object()
+ for idx in range(len(accessor)):
+ threads.append(accessor[idx])
+ return threads
+
+ def __iter__(self):
+ '''Iterate over all threads in a lldb.SBProcess object.'''
+ return lldb_iter(self, 'GetNumThreads', 'GetThreadAtIndex')
+
+ def __len__(self):
+ '''Return the number of threads in a lldb.SBProcess object.'''
+ return self.GetNumThreads()
+
+
+ threads = property(get_process_thread_list, None, doc='''A read only property that returns a list() of lldb.SBThread objects for this process.''')
+ thread = property(get_threads_access_object, None, doc='''A read only property that returns an object that can access threads by thread index (thread = lldb.process.thread[12]).''')
+ is_alive = property(__get_is_alive__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently alive.''')
+ is_running = property(__get_is_running__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently running.''')
+ is_stopped = property(__get_is_stopped__, None, doc='''A read only property that returns a boolean value that indicates if this process is currently stopped.''')
+ id = property(GetProcessID, None, doc='''A read only property that returns the process ID as an integer.''')
+ target = property(GetTarget, None, doc='''A read only property that an lldb object that represents the target (lldb.SBTarget) that owns this process.''')
+ num_threads = property(GetNumThreads, None, doc='''A read only property that returns the number of threads in this process as an integer.''')
+ selected_thread = property(GetSelectedThread, SetSelectedThread, doc='''A read/write property that gets/sets the currently selected thread in this process. The getter returns a lldb.SBThread object and the setter takes an lldb.SBThread object.''')
+ state = property(GetState, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eState") that represents the current state of this process (running, stopped, exited, etc.).''')
+ exit_state = property(GetExitStatus, None, doc='''A read only property that returns an exit status as an integer of this process when the process state is lldb.eStateExited.''')
+ exit_description = property(GetExitDescription, None, doc='''A read only property that returns an exit description as a string of this process when the process state is lldb.eStateExited.''')
+ broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this process.''')
+ %}
+#endif
+
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBProcessInfo.i b/lldb/bindings/interface/SBProcessInfo.i
new file mode 100644
index 000000000000..009842599bf8
--- /dev/null
+++ b/lldb/bindings/interface/SBProcessInfo.i
@@ -0,0 +1,67 @@
+//===-- SWIG Interface for SBProcessInfo-------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Describes an existing process and any discoverable information that pertains to
+that process."
+) SBProcessInfo;
+
+class SBProcessInfo
+{
+public:
+ SBProcessInfo();
+
+ SBProcessInfo (const SBProcessInfo &rhs);
+
+ ~SBProcessInfo ();
+
+ bool
+ IsValid ();
+
+ explicit operator bool() const;
+
+ const char *
+ GetName ();
+
+ SBFileSpec
+ GetExecutableFile ();
+
+ lldb::pid_t
+ GetProcessID ();
+
+ uint32_t
+ GetUserID ();
+
+ uint32_t
+ GetGroupID ();
+
+ bool
+ UserIDIsValid ();
+
+ bool
+ GroupIDIsValid ();
+
+ uint32_t
+ GetEffectiveUserID ();
+
+ uint32_t
+ GetEffectiveGroupID ();
+
+ bool
+ EffectiveUserIDIsValid ();
+
+ bool
+ EffectiveGroupIDIsValid ();
+
+ lldb::pid_t
+ GetParentProcessID ();
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBQueue.i b/lldb/bindings/interface/SBQueue.i
new file mode 100644
index 000000000000..f209d59f1bf9
--- /dev/null
+++ b/lldb/bindings/interface/SBQueue.i
@@ -0,0 +1,74 @@
+//===-- SWIG Interface for SBQueue.h -----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBQueue
+{
+public:
+ SBQueue ();
+
+ SBQueue (const lldb::QueueSP& queue_sp);
+
+ ~SBQueue();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ void
+ Clear ();
+
+ lldb::SBProcess
+ GetProcess ();
+
+ %feature("autodoc", "
+ Returns an lldb::queue_id_t type unique identifier number for this
+ queue that will not be used by any other queue during this process'
+ execution. These ID numbers often start at 1 with the first
+ system-created queues and increment from there.")
+ GetQueueID;
+
+ lldb::queue_id_t
+ GetQueueID () const;
+
+ const char *
+ GetName () const;
+
+ %feature("autodoc", "
+ Returns an lldb::QueueKind enumerated value (e.g. eQueueKindUnknown,
+ eQueueKindSerial, eQueueKindConcurrent) describing the type of this
+ queue.")
+ GetKind();
+
+ lldb::QueueKind
+ GetKind();
+
+ uint32_t
+ GetIndexID () const;
+
+ uint32_t
+ GetNumThreads ();
+
+ lldb::SBThread
+ GetThreadAtIndex (uint32_t);
+
+ uint32_t
+ GetNumPendingItems ();
+
+ lldb::SBQueueItem
+ GetPendingItemAtIndex (uint32_t);
+
+ uint32_t
+ GetNumRunningItems ();
+
+};
+
+} // namespace lldb
+
diff --git a/lldb/bindings/interface/SBQueueItem.i b/lldb/bindings/interface/SBQueueItem.i
new file mode 100644
index 000000000000..089771e80378
--- /dev/null
+++ b/lldb/bindings/interface/SBQueueItem.i
@@ -0,0 +1,47 @@
+//===-- SWIG Interface for SBQueueItem.h ------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBQueueItem
+{
+public:
+ SBQueueItem ();
+
+ SBQueueItem (const lldb::QueueItemSP& queue_item_sp);
+
+ ~SBQueueItem();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ void
+ Clear ();
+
+ lldb::QueueItemKind
+ GetKind () const;
+
+ void
+ SetKind (lldb::QueueItemKind kind);
+
+ lldb::SBAddress
+ GetAddress () const;
+
+ void
+ SetAddress (lldb::SBAddress addr);
+
+ void
+ SetQueueItem (const lldb::QueueItemSP& queue_item_sp);
+
+ lldb::SBThread
+ GetExtendedBacktraceThread (const char *type);
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBReproducer.i b/lldb/bindings/interface/SBReproducer.i
new file mode 100644
index 000000000000..7c9b007db3c0
--- /dev/null
+++ b/lldb/bindings/interface/SBReproducer.i
@@ -0,0 +1,18 @@
+//===-- SWIG Interface for SBReproducer--------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+class SBReproducer
+{
+ public:
+ static const char *Capture(const char *path);
+ static const char *PassiveReplay(const char *path);
+ static bool SetAutoGenerate(bool b);
+ static void SetWorkingDirectory(const char *path);
+};
+}
diff --git a/lldb/bindings/interface/SBSection.i b/lldb/bindings/interface/SBSection.i
new file mode 100644
index 000000000000..3d1c900917fd
--- /dev/null
+++ b/lldb/bindings/interface/SBSection.i
@@ -0,0 +1,149 @@
+//===-- SWIG Interface for SBSection ----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents an executable image section.
+
+SBSection supports iteration through its subsection, represented as SBSection
+as well. For example,
+
+ for sec in exe_module:
+ if sec.GetName() == '__TEXT':
+ print sec
+ break
+ print INDENT + 'Number of subsections: %d' % sec.GetNumSubSections()
+ for subsec in sec:
+ print INDENT + repr(subsec)
+
+produces:
+
+[0x0000000100000000-0x0000000100002000) a.out.__TEXT
+ Number of subsections: 6
+ [0x0000000100001780-0x0000000100001d5c) a.out.__TEXT.__text
+ [0x0000000100001d5c-0x0000000100001da4) a.out.__TEXT.__stubs
+ [0x0000000100001da4-0x0000000100001e2c) a.out.__TEXT.__stub_helper
+ [0x0000000100001e2c-0x0000000100001f10) a.out.__TEXT.__cstring
+ [0x0000000100001f10-0x0000000100001f68) a.out.__TEXT.__unwind_info
+ [0x0000000100001f68-0x0000000100001ff8) a.out.__TEXT.__eh_frame
+
+See also SBModule."
+) SBSection;
+
+class SBSection
+{
+public:
+
+ SBSection ();
+
+ SBSection (const lldb::SBSection &rhs);
+
+ ~SBSection ();
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+ const char *
+ GetName ();
+
+ lldb::SBSection
+ GetParent();
+
+ lldb::SBSection
+ FindSubSection (const char *sect_name);
+
+ size_t
+ GetNumSubSections ();
+
+ lldb::SBSection
+ GetSubSectionAtIndex (size_t idx);
+
+ lldb::addr_t
+ GetFileAddress ();
+
+ lldb::addr_t
+ GetLoadAddress (lldb::SBTarget &target);
+
+ lldb::addr_t
+ GetByteSize ();
+
+ uint64_t
+ GetFileOffset ();
+
+ uint64_t
+ GetFileByteSize ();
+
+ lldb::SBData
+ GetSectionData ();
+
+ lldb::SBData
+ GetSectionData (uint64_t offset,
+ uint64_t size);
+
+ SectionType
+ GetSectionType ();
+
+ uint32_t
+ GetPermissions() const;
+
+ %feature("docstring", "
+ Return the size of a target's byte represented by this section
+ in numbers of host bytes. Note that certain architectures have
+ varying minimum addressable unit (i.e. byte) size for their
+ CODE or DATA buses.
+
+ @return
+ The number of host (8-bit) bytes needed to hold a target byte") GetTargetByteSize;
+ uint32_t
+ GetTargetByteSize ();
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ bool
+ operator == (const lldb::SBSection &rhs);
+
+ bool
+ operator != (const lldb::SBSection &rhs);
+
+ STRING_EXTENSION(SBSection)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ def __iter__(self):
+ '''Iterate over all subsections in a lldb.SBSection object.'''
+ return lldb_iter(self, 'GetNumSubSections', 'GetSubSectionAtIndex')
+
+ def __len__(self):
+ '''Return the number of subsections in a lldb.SBSection object.'''
+ return self.GetNumSubSections()
+
+ def get_addr(self):
+ return SBAddress(self, 0)
+
+ name = property(GetName, None, doc='''A read only property that returns the name of this section as a string.''')
+ addr = property(get_addr, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this section.''')
+ file_addr = property(GetFileAddress, None, doc='''A read only property that returns an integer that represents the starting "file" address for this section, or the address of the section in the object file in which it is defined.''')
+ size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes of this section as an integer.''')
+ file_offset = property(GetFileOffset, None, doc='''A read only property that returns the file offset in bytes of this section as an integer.''')
+ file_size = property(GetFileByteSize, None, doc='''A read only property that returns the file size in bytes of this section as an integer.''')
+ data = property(GetSectionData, None, doc='''A read only property that returns an lldb object that represents the bytes for this section (lldb.SBData) for this section.''')
+ type = property(GetSectionType, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eSectionType") that represents the type of this section (code, data, etc.).''')
+ target_byte_size = property(GetTargetByteSize, None, doc='''A read only property that returns the size of a target byte represented by this section as a number of host bytes.''')
+ %}
+#endif
+
+private:
+
+ std::unique_ptr<lldb_private::SectionImpl> m_opaque_ap;
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBSourceManager.i b/lldb/bindings/interface/SBSourceManager.i
new file mode 100644
index 000000000000..dfbdc612a06e
--- /dev/null
+++ b/lldb/bindings/interface/SBSourceManager.i
@@ -0,0 +1,59 @@
+//===-- SWIG Interface for SBSourceManager ----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a central authority for displaying source code.
+
+For example (from test/source-manager/TestSourceManager.py),
+
+ # Create the filespec for 'main.c'.
+ filespec = lldb.SBFileSpec('main.c', False)
+ source_mgr = self.dbg.GetSourceManager()
+ # Use a string stream as the destination.
+ stream = lldb.SBStream()
+ source_mgr.DisplaySourceLinesWithLineNumbers(filespec,
+ self.line,
+ 2, # context before
+ 2, # context after
+ '=>', # prefix for current line
+ stream)
+
+ # 2
+ # 3 int main(int argc, char const *argv[]) {
+ # => 4 printf('Hello world.\\n'); // Set break point at this line.
+ # 5 return 0;
+ # 6 }
+ self.expect(stream.GetData(), 'Source code displayed correctly',
+ exe=False,
+ patterns = ['=> %d.*Hello world' % self.line])") SBSourceManager;
+class SBSourceManager
+{
+public:
+ SBSourceManager (const lldb::SBSourceManager &rhs);
+
+ ~SBSourceManager();
+
+ size_t
+ DisplaySourceLinesWithLineNumbers (const lldb::SBFileSpec &file,
+ uint32_t line,
+ uint32_t context_before,
+ uint32_t context_after,
+ const char* current_line_cstr,
+ lldb::SBStream &s);
+ size_t
+ DisplaySourceLinesWithLineNumbersAndColumn (const lldb::SBFileSpec &file,
+ uint32_t line, uint32_t column,
+ uint32_t context_before,
+ uint32_t context_after,
+ const char* current_line_cstr,
+ lldb::SBStream &s);
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBStream.i b/lldb/bindings/interface/SBStream.i
new file mode 100644
index 000000000000..edd67f87c3fb
--- /dev/null
+++ b/lldb/bindings/interface/SBStream.i
@@ -0,0 +1,96 @@
+//===-- SWIG Interface for SBStream -----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a destination for streaming data output to. By default, a string
+stream is created.
+
+For example (from test/source-manager/TestSourceManager.py),
+
+ # Create the filespec for 'main.c'.
+ filespec = lldb.SBFileSpec('main.c', False)
+ source_mgr = self.dbg.GetSourceManager()
+ # Use a string stream as the destination.
+ stream = lldb.SBStream()
+ source_mgr.DisplaySourceLinesWithLineNumbers(filespec,
+ self.line,
+ 2, # context before
+ 2, # context after
+ '=>', # prefix for current line
+ stream)
+
+ # 2
+ # 3 int main(int argc, char const *argv[]) {
+ # => 4 printf('Hello world.\\n'); // Set break point at this line.
+ # 5 return 0;
+ # 6 }
+ self.expect(stream.GetData(), 'Source code displayed correctly',
+ exe=False,
+ patterns = ['=> %d.*Hello world' % self.line])") SBStream;
+class SBStream
+{
+public:
+
+ SBStream ();
+
+ ~SBStream ();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ %feature("docstring", "
+ If this stream is not redirected to a file, it will maintain a local
+ cache for the stream data which can be accessed using this accessor.") GetData;
+ const char *
+ GetData ();
+
+ %feature("docstring", "
+ If this stream is not redirected to a file, it will maintain a local
+ cache for the stream output whose length can be accessed using this
+ accessor.") GetSize;
+ size_t
+ GetSize();
+
+ void
+ Print (const char* str);
+
+ void
+ RedirectToFile (const char *path, bool append);
+
+ void
+ RedirectToFile (lldb::SBFile file);
+
+ void
+ RedirectToFile (lldb::FileSP file);
+
+ %extend {
+ %feature("autodoc", "DEPRECATED, use RedirectToFile");
+ void
+ RedirectToFileHandle (lldb::FileSP file, bool transfer_fh_ownership) {
+ self->RedirectToFile(file);
+ }
+ }
+
+ void
+ RedirectToFileDescriptor (int fd, bool transfer_fh_ownership);
+
+ %feature("docstring", "
+ If the stream is redirected to a file, forget about the file and if
+ ownership of the file was transferred to this object, close the file.
+ If the stream is backed by a local cache, clear this cache.") Clear;
+ void
+ Clear ();
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBStringList.i b/lldb/bindings/interface/SBStringList.i
new file mode 100644
index 000000000000..c8e1e357ed2b
--- /dev/null
+++ b/lldb/bindings/interface/SBStringList.i
@@ -0,0 +1,57 @@
+//===-- SWIG Interface for SBStringList -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBStringList
+{
+public:
+
+ SBStringList ();
+
+ SBStringList (const lldb::SBStringList &rhs);
+
+ ~SBStringList ();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ void
+ AppendString (const char *str);
+
+ void
+ AppendList (const char **strv, int strc);
+
+ void
+ AppendList (const lldb::SBStringList &strings);
+
+ uint32_t
+ GetSize () const;
+
+ const char *
+ GetStringAtIndex (size_t idx);
+
+ void
+ Clear ();
+
+#ifdef SWIGPYTHON
+ %pythoncode%{
+ def __iter__(self):
+ '''Iterate over all strings in a lldb.SBStringList object.'''
+ return lldb_iter(self, 'GetSize', 'GetStringAtIndex')
+
+ def __len__(self):
+ '''Return the number of strings in a lldb.SBStringList object.'''
+ return self.GetSize()
+ %}
+#endif
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBStructuredData.i b/lldb/bindings/interface/SBStructuredData.i
new file mode 100644
index 000000000000..c7601bf6cf95
--- /dev/null
+++ b/lldb/bindings/interface/SBStructuredData.i
@@ -0,0 +1,63 @@
+//===-- SWIG Interface for SBStructuredData ---------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+ %feature("docstring",
+ "A class representing a StructuredData event.
+
+ This class wraps the event type generated by StructuredData
+ features."
+ ) SBStructuredData;
+ class SBStructuredData
+ {
+ public:
+ SBStructuredData();
+
+ SBStructuredData(const lldb::SBStructuredData &rhs);
+
+ SBStructuredData(const lldb::EventSP &event_sp);
+
+ ~SBStructuredData();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ void
+ Clear();
+
+ lldb::StructuredDataType GetType() const;
+
+ size_t GetSize() const;
+
+ bool GetKeys(lldb::SBStringList &keys) const;
+
+ lldb::SBStructuredData GetValueForKey(const char *key) const;
+
+ lldb::SBStructuredData GetItemAtIndex(size_t idx) const;
+
+ uint64_t GetIntegerValue(uint64_t fail_value = 0) const;
+
+ double GetFloatValue(double fail_value = 0.0) const;
+
+ bool GetBooleanValue(bool fail_value = false) const;
+
+ size_t GetStringValue(char *dst, size_t dst_len) const;
+
+ lldb::SBError
+ GetAsJSON(lldb::SBStream &stream) const;
+
+ lldb::SBError
+ GetDescription(lldb::SBStream &stream) const;
+
+ lldb::SBError
+ SetFromJSON(lldb::SBStream &stream);
+ };
+}
diff --git a/lldb/bindings/interface/SBSymbol.i b/lldb/bindings/interface/SBSymbol.i
new file mode 100644
index 000000000000..4e17ab5af0fd
--- /dev/null
+++ b/lldb/bindings/interface/SBSymbol.i
@@ -0,0 +1,96 @@
+//===-- SWIG Interface for SBSymbol -----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents the symbol possibly associated with a stack frame.
+SBModule contains SBSymbol(s). SBSymbol can also be retrieved from SBFrame.
+
+See also SBModule and SBFrame."
+) SBSymbol;
+class SBSymbol
+{
+public:
+
+ SBSymbol ();
+
+ ~SBSymbol ();
+
+ SBSymbol (const lldb::SBSymbol &rhs);
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+
+ const char *
+ GetName() const;
+
+ const char *
+ GetDisplayName() const;
+
+ const char *
+ GetMangledName () const;
+
+ lldb::SBInstructionList
+ GetInstructions (lldb::SBTarget target);
+
+ lldb::SBInstructionList
+ GetInstructions (lldb::SBTarget target, const char *flavor_string);
+
+ SBAddress
+ GetStartAddress ();
+
+ SBAddress
+ GetEndAddress ();
+
+ uint32_t
+ GetPrologueByteSize ();
+
+ SymbolType
+ GetType ();
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ bool
+ IsExternal();
+
+ bool
+ IsSynthetic();
+
+ bool
+ operator == (const lldb::SBSymbol &rhs) const;
+
+ bool
+ operator != (const lldb::SBSymbol &rhs) const;
+
+ STRING_EXTENSION(SBSymbol)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ def get_instructions_from_current_target (self):
+ return self.GetInstructions (target)
+
+ name = property(GetName, None, doc='''A read only property that returns the name for this symbol as a string.''')
+ mangled = property(GetMangledName, None, doc='''A read only property that returns the mangled (linkage) name for this symbol as a string.''')
+ type = property(GetType, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eSymbolType") that represents the type of this symbol.''')
+ addr = property(GetStartAddress, None, doc='''A read only property that returns an lldb object that represents the start address (lldb.SBAddress) for this symbol.''')
+ end_addr = property(GetEndAddress, None, doc='''A read only property that returns an lldb object that represents the end address (lldb.SBAddress) for this symbol.''')
+ prologue_size = property(GetPrologueByteSize, None, doc='''A read only property that returns the size in bytes of the prologue instructions as an unsigned integer.''')
+ instructions = property(get_instructions_from_current_target, None, doc='''A read only property that returns an lldb object that represents the instructions (lldb.SBInstructionList) for this symbol.''')
+ external = property(IsExternal, None, doc='''A read only property that returns a boolean value that indicates if this symbol is externally visiable (exported) from the module that contains it.''')
+ synthetic = property(IsSynthetic, None, doc='''A read only property that returns a boolean value that indicates if this symbol was synthetically created from information in module that contains it.''')
+ %}
+#endif
+
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBSymbolContext.i b/lldb/bindings/interface/SBSymbolContext.i
new file mode 100644
index 000000000000..b6b336516c94
--- /dev/null
+++ b/lldb/bindings/interface/SBSymbolContext.i
@@ -0,0 +1,99 @@
+//===-- SWIG Interface for SBSymbolContext ----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"A context object that provides access to core debugger entities.
+
+Many debugger functions require a context when doing lookups. This class
+provides a common structure that can be used as the result of a query that
+can contain a single result.
+
+For example,
+
+ exe = os.path.join(os.getcwd(), 'a.out')
+
+ # Create a target for the debugger.
+ target = self.dbg.CreateTarget(exe)
+
+ # Now create a breakpoint on main.c by name 'c'.
+ breakpoint = target.BreakpointCreateByName('c', 'a.out')
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple(None, None, os.getcwd())
+
+ # The inferior should stop on 'c'.
+ from lldbutil import get_stopped_thread
+ thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+ frame0 = thread.GetFrameAtIndex(0)
+
+ # Now get the SBSymbolContext from this frame. We want everything. :-)
+ context = frame0.GetSymbolContext(lldb.eSymbolContextEverything)
+
+ # Get the module.
+ module = context.GetModule()
+ ...
+
+ # And the compile unit associated with the frame.
+ compileUnit = context.GetCompileUnit()
+ ...
+"
+) SBSymbolContext;
+class SBSymbolContext
+{
+public:
+ SBSymbolContext ();
+
+ SBSymbolContext (const lldb::SBSymbolContext& rhs);
+
+ ~SBSymbolContext ();
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+ lldb::SBModule GetModule ();
+ lldb::SBCompileUnit GetCompileUnit ();
+ lldb::SBFunction GetFunction ();
+ lldb::SBBlock GetBlock ();
+ lldb::SBLineEntry GetLineEntry ();
+ lldb::SBSymbol GetSymbol ();
+
+ void SetModule (lldb::SBModule module);
+ void SetCompileUnit (lldb::SBCompileUnit compile_unit);
+ void SetFunction (lldb::SBFunction function);
+ void SetBlock (lldb::SBBlock block);
+ void SetLineEntry (lldb::SBLineEntry line_entry);
+ void SetSymbol (lldb::SBSymbol symbol);
+
+ lldb::SBSymbolContext
+ GetParentOfInlinedScope (const lldb::SBAddress &curr_frame_pc,
+ lldb::SBAddress &parent_frame_addr) const;
+
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ STRING_EXTENSION(SBSymbolContext)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ module = property(GetModule, SetModule, doc='''A read/write property that allows the getting/setting of the module (lldb.SBModule) in this symbol context.''')
+ compile_unit = property(GetCompileUnit, SetCompileUnit, doc='''A read/write property that allows the getting/setting of the compile unit (lldb.SBCompileUnit) in this symbol context.''')
+ function = property(GetFunction, SetFunction, doc='''A read/write property that allows the getting/setting of the function (lldb.SBFunction) in this symbol context.''')
+ block = property(GetBlock, SetBlock, doc='''A read/write property that allows the getting/setting of the block (lldb.SBBlock) in this symbol context.''')
+ symbol = property(GetSymbol, SetSymbol, doc='''A read/write property that allows the getting/setting of the symbol (lldb.SBSymbol) in this symbol context.''')
+ line_entry = property(GetLineEntry, SetLineEntry, doc='''A read/write property that allows the getting/setting of the line entry (lldb.SBLineEntry) in this symbol context.''')
+ %}
+#endif
+
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBSymbolContextList.i b/lldb/bindings/interface/SBSymbolContextList.i
new file mode 100644
index 000000000000..f5adcfcebfb5
--- /dev/null
+++ b/lldb/bindings/interface/SBSymbolContextList.i
@@ -0,0 +1,139 @@
+//===-- SWIG Interface for SBSymbolContextList ------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a list of symbol context object. See also SBSymbolContext.
+
+For example (from test/python_api/target/TestTargetAPI.py),
+
+ def find_functions(self, exe_name):
+ '''Exercise SBTaget.FindFunctions() API.'''
+ exe = os.path.join(os.getcwd(), exe_name)
+
+ # Create a target by the debugger.
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ list = lldb.SBSymbolContextList()
+ num = target.FindFunctions('c', lldb.eFunctionNameTypeAuto, False, list)
+ self.assertTrue(num == 1 and list.GetSize() == 1)
+
+ for sc in list:
+ self.assertTrue(sc.GetModule().GetFileSpec().GetFilename() == exe_name)
+ self.assertTrue(sc.GetSymbol().GetName() == 'c')") SBSymbolContextList;
+class SBSymbolContextList
+{
+public:
+ SBSymbolContextList ();
+
+ SBSymbolContextList (const lldb::SBSymbolContextList& rhs);
+
+ ~SBSymbolContextList ();
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+ uint32_t
+ GetSize() const;
+
+ SBSymbolContext
+ GetContextAtIndex (uint32_t idx);
+
+ void
+ Append (lldb::SBSymbolContext &sc);
+
+ void
+ Append (lldb::SBSymbolContextList &sc_list);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ void
+ Clear();
+
+ STRING_EXTENSION(SBSymbolContextList)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ def __iter__(self):
+ '''Iterate over all symbol contexts in a lldb.SBSymbolContextList
+ object.'''
+ return lldb_iter(self, 'GetSize', 'GetContextAtIndex')
+
+ def __len__(self):
+ return int(self.GetSize())
+
+ def __getitem__(self, key):
+ count = len(self)
+ if type(key) is int:
+ if key < count:
+ return self.GetContextAtIndex(key)
+ else:
+ raise IndexError
+ raise TypeError
+
+ def get_module_array(self):
+ a = []
+ for i in range(len(self)):
+ obj = self.GetContextAtIndex(i).module
+ if obj:
+ a.append(obj)
+ return a
+
+ def get_compile_unit_array(self):
+ a = []
+ for i in range(len(self)):
+ obj = self.GetContextAtIndex(i).compile_unit
+ if obj:
+ a.append(obj)
+ return a
+ def get_function_array(self):
+ a = []
+ for i in range(len(self)):
+ obj = self.GetContextAtIndex(i).function
+ if obj:
+ a.append(obj)
+ return a
+ def get_block_array(self):
+ a = []
+ for i in range(len(self)):
+ obj = self.GetContextAtIndex(i).block
+ if obj:
+ a.append(obj)
+ return a
+ def get_symbol_array(self):
+ a = []
+ for i in range(len(self)):
+ obj = self.GetContextAtIndex(i).symbol
+ if obj:
+ a.append(obj)
+ return a
+ def get_line_entry_array(self):
+ a = []
+ for i in range(len(self)):
+ obj = self.GetContextAtIndex(i).line_entry
+ if obj:
+ a.append(obj)
+ return a
+
+ modules = property(get_module_array, None, doc='''Returns a list() of lldb.SBModule objects, one for each module in each SBSymbolContext object in this list.''')
+ compile_units = property(get_compile_unit_array, None, doc='''Returns a list() of lldb.SBCompileUnit objects, one for each compile unit in each SBSymbolContext object in this list.''')
+ functions = property(get_function_array, None, doc='''Returns a list() of lldb.SBFunction objects, one for each function in each SBSymbolContext object in this list.''')
+ blocks = property(get_block_array, None, doc='''Returns a list() of lldb.SBBlock objects, one for each block in each SBSymbolContext object in this list.''')
+ line_entries = property(get_line_entry_array, None, doc='''Returns a list() of lldb.SBLineEntry objects, one for each line entry in each SBSymbolContext object in this list.''')
+ symbols = property(get_symbol_array, None, doc='''Returns a list() of lldb.SBSymbol objects, one for each symbol in each SBSymbolContext object in this list.''')
+ %}
+#endif
+
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBTarget.i b/lldb/bindings/interface/SBTarget.i
new file mode 100644
index 000000000000..57b5ccea6399
--- /dev/null
+++ b/lldb/bindings/interface/SBTarget.i
@@ -0,0 +1,1073 @@
+//===-- SWIG Interface for SBTarget -----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents the target program running under the debugger.
+
+SBTarget supports module, breakpoint, and watchpoint iterations. For example,
+
+ for m in target.module_iter():
+ print m
+
+produces:
+
+(x86_64) /Volumes/data/lldb/svn/trunk/test/python_api/lldbutil/iter/a.out
+(x86_64) /usr/lib/dyld
+(x86_64) /usr/lib/libstdc++.6.dylib
+(x86_64) /usr/lib/libSystem.B.dylib
+(x86_64) /usr/lib/system/libmathCommon.A.dylib
+(x86_64) /usr/lib/libSystem.B.dylib(__commpage)
+
+and,
+
+ for b in target.breakpoint_iter():
+ print b
+
+produces:
+
+SBBreakpoint: id = 1, file ='main.cpp', line = 66, locations = 1
+SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1
+
+and,
+
+ for wp_loc in target.watchpoint_iter():
+ print wp_loc
+
+produces:
+
+Watchpoint 1: addr = 0x1034ca048 size = 4 state = enabled type = rw
+ declare @ '/Volumes/data/lldb/svn/trunk/test/python_api/watchpoint/main.c:12'
+ hw_index = 0 hit_count = 2 ignore_count = 0"
+) SBTarget;
+class SBTarget
+{
+public:
+ //------------------------------------------------------------------
+ // Broadcaster bits.
+ //------------------------------------------------------------------
+ enum
+ {
+ eBroadcastBitBreakpointChanged = (1 << 0),
+ eBroadcastBitModulesLoaded = (1 << 1),
+ eBroadcastBitModulesUnloaded = (1 << 2),
+ eBroadcastBitWatchpointChanged = (1 << 3),
+ eBroadcastBitSymbolsLoaded = (1 << 4)
+ };
+
+ //------------------------------------------------------------------
+ // Constructors
+ //------------------------------------------------------------------
+ SBTarget ();
+
+ SBTarget (const lldb::SBTarget& rhs);
+
+ //------------------------------------------------------------------
+ // Destructor
+ //------------------------------------------------------------------
+ ~SBTarget();
+
+ static const char *
+ GetBroadcasterClassName ();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ static bool
+ EventIsTargetEvent (const lldb::SBEvent &event);
+
+ static lldb::SBTarget
+ GetTargetFromEvent (const lldb::SBEvent &event);
+
+ static uint32_t
+ GetNumModulesFromEvent (const lldb::SBEvent &event);
+
+ static lldb::SBModule
+ GetModuleAtIndexFromEvent (const uint32_t idx, const lldb::SBEvent &event);
+
+ lldb::SBProcess
+ GetProcess ();
+
+
+ %feature("docstring", "
+ Return the platform object associated with the target.
+
+ After return, the platform object should be checked for
+ validity.
+
+ @return
+ A platform object.") GetPlatform;
+ lldb::SBPlatform
+ GetPlatform ();
+
+ %feature("docstring", "
+ Install any binaries that need to be installed.
+
+ This function does nothing when debugging on the host system.
+ When connected to remote platforms, the target's main executable
+ and any modules that have their install path set will be
+ installed on the remote platform. If the main executable doesn't
+ have an install location set, it will be installed in the remote
+ platform's working directory.
+
+ @return
+ An error describing anything that went wrong during
+ installation.") Install;
+ lldb::SBError
+ Install();
+
+ %feature("docstring", "
+ Launch a new process.
+
+ Launch a new process by spawning a new process using the
+ target object's executable module's file as the file to launch.
+ Arguments are given in argv, and the environment variables
+ are in envp. Standard input and output files can be
+ optionally re-directed to stdin_path, stdout_path, and
+ stderr_path.
+
+ @param[in] listener
+ An optional listener that will receive all process events.
+ If listener is valid then listener will listen to all
+ process events. If not valid, then this target's debugger
+ (SBTarget::GetDebugger()) will listen to all process events.
+
+ @param[in] argv
+ The argument array.
+
+ @param[in] envp
+ The environment array.
+
+ @param[in] launch_flags
+ Flags to modify the launch (@see lldb::LaunchFlags)
+
+ @param[in] stdin_path
+ The path to use when re-directing the STDIN of the new
+ process. If all stdXX_path arguments are NULL, 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
+ 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
+ terminal will be used.
+
+ @param[in] working_directory
+ The working directory to have the child process run in
+
+ @param[in] launch_flags
+ Some launch options specified by logical OR'ing
+ lldb::LaunchFlags enumeration values together.
+
+ @param[in] stop_at_entry
+ If false do not stop the inferior at the entry point.
+
+ @param[out]
+ An error object. Contains the reason if there is some failure.
+
+ @return
+ A process object for the newly created process.
+
+ For example,
+
+ process = target.Launch(self.dbg.GetListener(), None, None,
+ None, '/tmp/stdout.txt', None,
+ None, 0, False, error)
+
+ launches a new process by passing nothing for both the args and the envs
+ and redirect the standard output of the inferior to the /tmp/stdout.txt
+ file. It does not specify a working directory so that the debug server
+ will use its idea of what the current working directory is for the
+ inferior. Also, we ask the debugger not to stop the inferior at the
+ entry point. If no breakpoint is specified for the inferior, it should
+ run to completion if no user interaction is required.") Launch;
+ lldb::SBProcess
+ Launch (SBListener &listener,
+ char const **argv,
+ char const **envp,
+ const char *stdin_path,
+ const char *stdout_path,
+ const char *stderr_path,
+ const char *working_directory,
+ uint32_t launch_flags, // See LaunchFlags
+ bool stop_at_entry,
+ lldb::SBError& error);
+
+ %feature("docstring", "
+ Launch a new process with sensible defaults.
+
+ @param[in] argv
+ The argument array.
+
+ @param[in] envp
+ The environment array.
+
+ @param[in] working_directory
+ The working directory to have the child process run in
+
+ Default: listener
+ Set to the target's debugger (SBTarget::GetDebugger())
+
+ Default: launch_flags
+ Empty launch flags
+
+ Default: stdin_path
+ Default: stdout_path
+ Default: stderr_path
+ A pseudo terminal will be used.
+
+ @return
+ A process object for the newly created process.
+
+ For example,
+
+ process = target.LaunchSimple(['X', 'Y', 'Z'], None, os.getcwd())
+
+ launches a new process by passing 'X', 'Y', 'Z' as the args to the
+ executable.") LaunchSimple;
+ lldb::SBProcess
+ LaunchSimple (const char **argv,
+ const char **envp,
+ const char *working_directory);
+
+ lldb::SBProcess
+ Launch (lldb::SBLaunchInfo &launch_info, lldb::SBError& error);
+
+ %feature("docstring", "
+ Load a core file
+
+ @param[in] core_file
+ File path of the core dump.
+
+ @param[out] error
+ An error explaining what went wrong if the operation fails.
+ (Optional)
+
+ @return
+ A process object for the newly created core file.
+
+ For example,
+
+ process = target.LoadCore('./a.out.core')
+
+ loads a new core file and returns the process object.") LoadCore;
+ lldb::SBProcess
+ LoadCore(const char *core_file);
+
+ lldb::SBProcess
+ LoadCore(const char *core_file, lldb::SBError &error);
+
+ lldb::SBProcess
+ Attach(lldb::SBAttachInfo &attach_info, lldb::SBError& error);
+
+ %feature("docstring", "
+ Attach to process with pid.
+
+ @param[in] listener
+ An optional listener that will receive all process events.
+ If listener is valid then listener will listen to all
+ process events. If not valid, then this target's debugger
+ (SBTarget::GetDebugger()) will listen to all process events.
+
+ @param[in] pid
+ The process ID to attach to.
+
+ @param[out]
+ An error explaining what went wrong if attach fails.
+
+ @return
+ A process object for the attached process.") AttachToProcessWithID;
+ lldb::SBProcess
+ AttachToProcessWithID (SBListener &listener,
+ lldb::pid_t pid,
+ lldb::SBError& error);
+
+ %feature("docstring", "
+ Attach to process with name.
+
+ @param[in] listener
+ An optional listener that will receive all process events.
+ If listener is valid then listener will listen to all
+ process events. If not valid, then this target's debugger
+ (SBTarget::GetDebugger()) will listen to all process events.
+
+ @param[in] name
+ Basename of process to attach to.
+
+ @param[in] wait_for
+ If true wait for a new instance of 'name' to be launched.
+
+ @param[out]
+ An error explaining what went wrong if attach fails.
+
+ @return
+ A process object for the attached process.") AttachToProcessWithName;
+ lldb::SBProcess
+ AttachToProcessWithName (SBListener &listener,
+ const char *name,
+ bool wait_for,
+ lldb::SBError& error);
+
+ %feature("docstring", "
+ Connect to a remote debug server with url.
+
+ @param[in] listener
+ An optional listener that will receive all process events.
+ If listener is valid then listener will listen to all
+ process events. If not valid, then this target's debugger
+ (SBTarget::GetDebugger()) will listen to all process events.
+
+ @param[in] url
+ The url to connect to, e.g., 'connect://localhost:12345'.
+
+ @param[in] plugin_name
+ The plugin name to be used; can be NULL.
+
+ @param[out]
+ An error explaining what went wrong if the connect fails.
+
+ @return
+ A process object for the connected process.") ConnectRemote;
+ lldb::SBProcess
+ ConnectRemote (SBListener &listener,
+ const char *url,
+ const char *plugin_name,
+ SBError& error);
+
+ lldb::SBFileSpec
+ GetExecutable ();
+
+ %feature("docstring", "
+ Append the path mapping (from -> to) to the target's paths mapping list.") AppendImageSearchPath;
+ void
+ AppendImageSearchPath (const char *from,
+ const char *to,
+ SBError &error);
+
+ bool
+ AddModule (lldb::SBModule &module);
+
+ lldb::SBModule
+ AddModule (const char *path,
+ const char *triple,
+ const char *uuid);
+
+ lldb::SBModule
+ AddModule (const char *path,
+ const char *triple,
+ const char *uuid_cstr,
+ const char *symfile);
+
+ lldb::SBModule
+ AddModule (const SBModuleSpec &module_spec);
+
+ uint32_t
+ GetNumModules () const;
+
+ lldb::SBModule
+ GetModuleAtIndex (uint32_t idx);
+
+ bool
+ RemoveModule (lldb::SBModule module);
+
+ lldb::SBDebugger
+ GetDebugger() const;
+
+ lldb::SBModule
+ FindModule (const lldb::SBFileSpec &file_spec);
+
+ %feature("docstring", "
+ Find compile units related to *this target and passed source
+ file.
+
+ @param[in] sb_file_spec
+ A lldb::SBFileSpec object that contains source file
+ specification.
+
+ @return
+ A lldb::SBSymbolContextList that gets filled in with all of
+ the symbol contexts for all the matches.") FindCompileUnits;
+ lldb::SBSymbolContextList
+ FindCompileUnits (const lldb::SBFileSpec &sb_file_spec);
+
+ lldb::ByteOrder
+ GetByteOrder ();
+
+ uint32_t
+ GetAddressByteSize();
+
+ const char *
+ GetTriple ();
+
+ %feature("docstring", "
+ Architecture data byte width accessor
+
+ @return
+ The size in 8-bit (host) bytes of a minimum addressable
+ unit from the Architecture's data bus") GetDataByteSize;
+ uint32_t
+ GetDataByteSize ();
+
+ %feature("docstring", "
+ Architecture code byte width accessor
+
+ @return
+ The size in 8-bit (host) bytes of a minimum addressable
+ unit from the Architecture's code bus") GetCodeByteSize;
+ uint32_t
+ GetCodeByteSize ();
+
+ lldb::SBError
+ SetSectionLoadAddress (lldb::SBSection section,
+ lldb::addr_t section_base_addr);
+
+ lldb::SBError
+ ClearSectionLoadAddress (lldb::SBSection section);
+
+ lldb::SBError
+ SetModuleLoadAddress (lldb::SBModule module,
+ int64_t sections_offset);
+
+ lldb::SBError
+ ClearModuleLoadAddress (lldb::SBModule module);
+
+ %feature("docstring", "
+ Find functions by name.
+
+ @param[in] name
+ The name of the function we are looking for.
+
+ @param[in] name_type_mask
+ A logical OR of one or more FunctionNameType enum bits that
+ indicate what kind of names should be used when doing the
+ lookup. Bits include fully qualified names, base names,
+ C++ methods, or ObjC selectors.
+ See FunctionNameType for more details.
+
+ @return
+ A lldb::SBSymbolContextList that gets filled in with all of
+ the symbol contexts for all the matches.") FindFunctions;
+ lldb::SBSymbolContextList
+ FindFunctions (const char *name,
+ uint32_t name_type_mask = lldb::eFunctionNameTypeAny);
+
+ lldb::SBType
+ FindFirstType (const char* type);
+
+ lldb::SBTypeList
+ FindTypes (const char* type);
+
+ lldb::SBType
+ GetBasicType(lldb::BasicType type);
+
+ lldb::SBSourceManager
+ GetSourceManager ();
+
+ %feature("docstring", "
+ Find global and static variables by name.
+
+ @param[in] name
+ The name of the global or static variable we are looking
+ for.
+
+ @param[in] max_matches
+ Allow the number of matches to be limited to max_matches.
+
+ @return
+ A list of matched variables in an SBValueList.") FindGlobalVariables;
+ lldb::SBValueList
+ FindGlobalVariables (const char *name,
+ uint32_t max_matches);
+
+ %feature("docstring", "
+ Find the first global (or static) variable by name.
+
+ @param[in] name
+ The name of the global or static variable we are looking
+ for.
+
+ @return
+ An SBValue that gets filled in with the found variable (if any).") FindFirstGlobalVariable;
+ lldb::SBValue
+ FindFirstGlobalVariable (const char* name);
+
+
+ lldb::SBValueList
+ FindGlobalVariables(const char *name,
+ uint32_t max_matches,
+ MatchType matchtype);
+
+ lldb::SBSymbolContextList
+ FindGlobalFunctions(const char *name,
+ uint32_t max_matches,
+ MatchType matchtype);
+
+ void
+ Clear ();
+
+ %feature("docstring", "
+ Resolve a current file address into a section offset address.
+
+ @param[in] file_addr
+
+ @return
+ An SBAddress which will be valid if...") ResolveFileAddress;
+ lldb::SBAddress
+ ResolveFileAddress (lldb::addr_t file_addr);
+
+ lldb::SBAddress
+ ResolveLoadAddress (lldb::addr_t vm_addr);
+
+ lldb::SBAddress
+ ResolvePastLoadAddress (uint32_t stop_id, lldb::addr_t vm_addr);
+
+ SBSymbolContext
+ ResolveSymbolContextForAddress (const SBAddress& addr,
+ uint32_t resolve_scope);
+
+ %feature("docstring", "
+ Read target memory. If a target process is running then memory
+ is read from here. Otherwise the memory is read from the object
+ files. For a target whose bytes are sized as a multiple of host
+ bytes, the data read back will preserve the target's byte order.
+
+ @param[in] addr
+ A target address to read from.
+
+ @param[out] buf
+ The buffer to read memory into.
+
+ @param[in] size
+ The maximum number of host bytes to read in the buffer passed
+ into this call
+
+ @param[out] error
+ Error information is written here if the memory read fails.
+
+ @return
+ The amount of data read in host bytes.") ReadMemory;
+ size_t
+ ReadMemory (const SBAddress addr, void *buf, size_t size, lldb::SBError &error);
+
+ lldb::SBBreakpoint
+ BreakpointCreateByLocation (const char *file, uint32_t line);
+
+ lldb::SBBreakpoint
+ BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line);
+
+ lldb::SBBreakpoint
+ BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line, lldb::addr_t offset);
+
+ lldb::SBBreakpoint
+ BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line,
+ lldb::addr_t offset, SBFileSpecList &module_list);
+
+ lldb::SBBreakpoint
+ BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line,
+ uint32_t column, lldb::addr_t offset,
+ SBFileSpecList &module_list);
+
+ lldb::SBBreakpoint
+ BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL);
+
+ lldb::SBBreakpoint
+ BreakpointCreateByName (const char *symbol_name,
+ uint32_t func_name_type, // Logical OR one or more FunctionNameType enum bits
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint
+ BreakpointCreateByName (const char *symbol_name,
+ uint32_t func_name_type, // Logical OR one or more FunctionNameType enum bits
+ lldb::LanguageType symbol_language,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
+#ifdef SWIGPYTHON
+%typemap(in) (const char **symbol_name, uint32_t num_names) {
+ using namespace lldb_private;
+ /* Check if is a list */
+ if (PythonList::Check($input)) {
+ PythonList list(PyRefType::Borrowed, $input);
+ $2 = list.GetSize();
+ int i = 0;
+ $1 = (char**)malloc(($2+1)*sizeof(char*));
+ for (i = 0; i < $2; i++) {
+ PythonString py_str = list.GetItemAtIndex(i).AsType<PythonString>();
+ if (!py_str.IsAllocated()) {
+ PyErr_SetString(PyExc_TypeError,"list must contain strings and blubby");
+ free($1);
+ return nullptr;
+ }
+
+ $1[i] = const_cast<char*>(py_str.GetString().data());
+ }
+ $1[i] = 0;
+ } else if ($input == Py_None) {
+ $1 = NULL;
+ } else {
+ PyErr_SetString(PyExc_TypeError,"not a list");
+ return NULL;
+ }
+}
+#endif
+
+ lldb::SBBreakpoint
+ BreakpointCreateByNames (const char **symbol_name,
+ uint32_t num_names,
+ uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint
+ BreakpointCreateByNames (const char **symbol_name,
+ uint32_t num_names,
+ uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
+ lldb::LanguageType symbol_language,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint
+ BreakpointCreateByNames (const char **symbol_name,
+ uint32_t num_names,
+ uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
+ lldb::LanguageType symbol_language,
+ lldb::addr_t offset,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint
+ BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL);
+
+ lldb::SBBreakpoint
+ BreakpointCreateByRegex (const char *symbol_name_regex,
+ lldb::LanguageType symbol_language,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &comp_unit_list);
+
+ lldb::SBBreakpoint
+ BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name = NULL);
+
+ lldb::SBBreakpoint
+ BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpecList &module_list, const lldb::SBFileSpecList &file_list);
+
+ lldb::SBBreakpoint
+ BreakpointCreateBySourceRegex (const char *source_regex,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &source_file,
+ const SBStringList &func_names);
+
+ lldb::SBBreakpoint
+ BreakpointCreateForException (lldb::LanguageType language,
+ bool catch_bp,
+ bool throw_bp);
+
+ lldb::SBBreakpoint
+ BreakpointCreateByAddress (addr_t address);
+
+ lldb::SBEnvironment
+ GetEnvironment();
+
+ lldb::SBBreakpoint
+ BreakpointCreateBySBAddress (SBAddress &sb_address);
+
+ %feature("docstring", "
+ Create a breakpoint using a scripted resolver.
+
+ @param[in] class_name
+ This is the name of the class that implements a scripted resolver.
+ The class should have the following signature:
+ class Resolver:
+ def __init__(self, bkpt, extra_args):
+ # bkpt - the breakpoint for which this is the resolver. When
+ # the resolver finds an interesting address, call AddLocation
+ # on this breakpoint to add it.
+ #
+ # extra_args - an SBStructuredData that can be used to
+ # parametrize this instance. Same as the extra_args passed
+ # to BreakpointCreateFromScript.
+
+ def __get_depth__ (self):
+ # This is optional, but if defined, you should return the
+ # depth at which you want the callback to be called. The
+ # available options are:
+ # lldb.eSearchDepthModule
+ # lldb.eSearchDepthCompUnit
+ # The default if you don't implement this method is
+ # eSearchDepthModule.
+
+ def __callback__(self, sym_ctx):
+ # sym_ctx - an SBSymbolContext that is the cursor in the
+ # search through the program to resolve breakpoints.
+ # The sym_ctx will be filled out to the depth requested in
+ # __get_depth__.
+ # Look in this sym_ctx for new breakpoint locations,
+ # and if found use bkpt.AddLocation to add them.
+ # Note, you will only get called for modules/compile_units that
+ # pass the SearchFilter provided by the module_list & file_list
+ # passed into BreakpointCreateFromScript.
+
+ def get_short_help(self):
+ # Optional, but if implemented return a short string that will
+ # be printed at the beginning of the break list output for the
+ # breakpoint.
+
+ @param[in] extra_args
+ This is an SBStructuredData object that will get passed to the
+ constructor of the class in class_name. You can use this to
+ reuse the same class, parametrizing it with entries from this
+ dictionary.
+
+ @param module_list
+ If this is non-empty, this will be used as the module filter in the
+ SearchFilter created for this breakpoint.
+
+ @param file_list
+ If this is non-empty, this will be used as the comp unit filter in the
+ SearchFilter created for this breakpoint.
+
+ @return
+ An SBBreakpoint that will set locations based on the logic in the
+ resolver's search callback.") BreakpointCreateFromScript;
+ lldb::SBBreakpoint BreakpointCreateFromScript(
+ const char *class_name,
+ SBStructuredData &extra_args,
+ const SBFileSpecList &module_list,
+ const SBFileSpecList &file_list,
+ bool request_hardware = false);
+
+ uint32_t
+ GetNumBreakpoints () const;
+
+ lldb::SBBreakpoint
+ GetBreakpointAtIndex (uint32_t idx) const;
+
+ bool
+ BreakpointDelete (break_id_t break_id);
+
+ lldb::SBBreakpoint
+ FindBreakpointByID (break_id_t break_id);
+
+
+ bool FindBreakpointsByName(const char *name, SBBreakpointList &bkpt_list);
+
+ void DeleteBreakpointName(const char *name);
+
+ void GetBreakpointNames(SBStringList &names);
+
+ bool
+ EnableAllBreakpoints ();
+
+ bool
+ DisableAllBreakpoints ();
+
+ bool
+ DeleteAllBreakpoints ();
+
+ %feature("docstring", "
+ Read breakpoints from source_file and return the newly created
+ breakpoints in bkpt_list.
+
+ @param[in] source_file
+ The file from which to read the breakpoints
+
+ @param[out] bkpt_list
+ A list of the newly created breakpoints.
+
+ @return
+ An SBError detailing any errors in reading in the breakpoints.") BreakpointsCreateFromFile;
+ lldb::SBError
+ BreakpointsCreateFromFile(SBFileSpec &source_file,
+ SBBreakpointList &bkpt_list);
+
+ %feature("docstring", "
+ Read breakpoints from source_file and return the newly created
+ breakpoints in bkpt_list.
+
+ @param[in] source_file
+ The file from which to read the breakpoints
+
+ @param[in] matching_names
+ Only read in breakpoints whose names match one of the names in this
+ list.
+
+ @param[out] bkpt_list
+ A list of the newly created breakpoints.
+
+ @return
+ An SBError detailing any errors in reading in the breakpoints.") BreakpointsCreateFromFile;
+ lldb::SBError BreakpointsCreateFromFile(SBFileSpec &source_file,
+ SBStringList &matching_names,
+ SBBreakpointList &new_bps);
+
+ %feature("docstring", "
+ Write breakpoints to dest_file.
+
+ @param[in] dest_file
+ The file to which to write the breakpoints.
+
+ @return
+ An SBError detailing any errors in writing in the breakpoints.") BreakpointsCreateFromFile;
+ lldb::SBError
+ BreakpointsWriteToFile(SBFileSpec &dest_file);
+
+ %feature("docstring", "
+ Write breakpoints listed in bkpt_list to dest_file.
+
+ @param[in] dest_file
+ The file to which to write the breakpoints.
+
+ @param[in] bkpt_list
+ Only write breakpoints from this list.
+
+ @param[in] append
+ If true, append the breakpoints in bkpt_list to the others
+ serialized in dest_file. If dest_file doesn't exist, then a new
+ file will be created and the breakpoints in bkpt_list written to it.
+
+ @return
+ An SBError detailing any errors in writing in the breakpoints.") BreakpointsCreateFromFile;
+ lldb::SBError
+ BreakpointsWriteToFile(SBFileSpec &dest_file,
+ SBBreakpointList &bkpt_list,
+ bool append = false);
+
+ uint32_t
+ GetNumWatchpoints () const;
+
+ lldb::SBWatchpoint
+ GetWatchpointAtIndex (uint32_t idx) const;
+
+ bool
+ DeleteWatchpoint (lldb::watch_id_t watch_id);
+
+ lldb::SBWatchpoint
+ FindWatchpointByID (lldb::watch_id_t watch_id);
+
+ bool
+ EnableAllWatchpoints ();
+
+ bool
+ DisableAllWatchpoints ();
+
+ bool
+ DeleteAllWatchpoints ();
+
+ lldb::SBWatchpoint
+ WatchAddress (lldb::addr_t addr,
+ size_t size,
+ bool read,
+ bool write,
+ SBError &error);
+
+
+ lldb::SBBroadcaster
+ GetBroadcaster () const;
+
+ %feature("docstring", "
+ Create an SBValue with the given name by treating the memory starting at addr as an entity of type.
+
+ @param[in] name
+ The name of the resultant SBValue
+
+ @param[in] addr
+ The address of the start of the memory region to be used.
+
+ @param[in] type
+ The type to use to interpret the memory starting at addr.
+
+ @return
+ An SBValue of the given type, may be invalid if there was an error reading
+ the underlying memory.") CreateValueFromAddress;
+ lldb::SBValue
+ CreateValueFromAddress (const char *name, lldb::SBAddress addr, lldb::SBType type);
+
+ lldb::SBValue
+ CreateValueFromData (const char *name, lldb::SBData data, lldb::SBType type);
+
+ lldb::SBValue
+ CreateValueFromExpression (const char *name, const char* expr);
+
+ %feature("docstring", "
+ Disassemble a specified number of instructions starting at an address.
+ Parameters:
+ base_addr -- the address to start disassembly from
+ count -- the number of instructions to disassemble
+ flavor_string -- may be 'intel' or 'att' on x86 targets to specify that style of disassembly
+ Returns an SBInstructionList.")
+ ReadInstructions;
+ lldb::SBInstructionList
+ ReadInstructions (lldb::SBAddress base_addr, uint32_t count);
+
+ lldb::SBInstructionList
+ ReadInstructions (lldb::SBAddress base_addr, uint32_t count, const char *flavor_string);
+
+ %feature("docstring", "
+ Disassemble the bytes in a buffer and return them in an SBInstructionList.
+ Parameters:
+ base_addr -- used for symbolicating the offsets in the byte stream when disassembling
+ buf -- bytes to be disassembled
+ size -- (C++) size of the buffer
+ Returns an SBInstructionList.")
+ GetInstructions;
+ lldb::SBInstructionList
+ GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size);
+
+ %feature("docstring", "
+ Disassemble the bytes in a buffer and return them in an SBInstructionList, with a supplied flavor.
+ Parameters:
+ base_addr -- used for symbolicating the offsets in the byte stream when disassembling
+ flavor -- may be 'intel' or 'att' on x86 targets to specify that style of disassembly
+ buf -- bytes to be disassembled
+ size -- (C++) size of the buffer
+ Returns an SBInstructionList.")
+ GetInstructionsWithFlavor;
+ lldb::SBInstructionList
+ GetInstructionsWithFlavor (lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size);
+
+ lldb::SBSymbolContextList
+ FindSymbols (const char *name, lldb::SymbolType type = eSymbolTypeAny);
+
+ bool
+ GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level);
+
+ lldb::addr_t
+ GetStackRedZoneSize();
+
+ lldb::SBLaunchInfo
+ GetLaunchInfo () const;
+
+ void
+ SetLaunchInfo (const lldb::SBLaunchInfo &launch_info);
+
+ void SetCollectingStats(bool v);
+
+ bool GetCollectingStats();
+
+ lldb::SBStructuredData GetStatistics();
+
+ bool
+ operator == (const lldb::SBTarget &rhs) const;
+
+ bool
+ operator != (const lldb::SBTarget &rhs) const;
+
+ lldb::SBValue
+ EvaluateExpression (const char *expr);
+
+ lldb::SBValue
+ EvaluateExpression (const char *expr, const lldb::SBExpressionOptions &options);
+
+ STRING_EXTENSION_LEVEL(SBTarget, lldb::eDescriptionLevelBrief)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ class modules_access(object):
+ '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.'''
+ def __init__(self, sbtarget):
+ self.sbtarget = sbtarget
+
+ def __len__(self):
+ if self.sbtarget:
+ return int(self.sbtarget.GetNumModules())
+ return 0
+
+ def __getitem__(self, key):
+ num_modules = self.sbtarget.GetNumModules()
+ if type(key) is int:
+ if key < num_modules:
+ return self.sbtarget.GetModuleAtIndex(key)
+ elif type(key) is str:
+ if key.find('/') == -1:
+ for idx in range(num_modules):
+ module = self.sbtarget.GetModuleAtIndex(idx)
+ if module.file.basename == key:
+ return module
+ else:
+ for idx in range(num_modules):
+ module = self.sbtarget.GetModuleAtIndex(idx)
+ if module.file.fullpath == key:
+ return module
+ # See if the string is a UUID
+ try:
+ the_uuid = uuid.UUID(key)
+ if the_uuid:
+ for idx in range(num_modules):
+ module = self.sbtarget.GetModuleAtIndex(idx)
+ if module.uuid == the_uuid:
+ return module
+ except:
+ return None
+ elif type(key) is uuid.UUID:
+ for idx in range(num_modules):
+ module = self.sbtarget.GetModuleAtIndex(idx)
+ if module.uuid == key:
+ return module
+ elif type(key) is re.SRE_Pattern:
+ matching_modules = []
+ for idx in range(num_modules):
+ module = self.sbtarget.GetModuleAtIndex(idx)
+ re_match = key.search(module.path.fullpath)
+ if re_match:
+ matching_modules.append(module)
+ return matching_modules
+ else:
+ print("error: unsupported item type: %s" % type(key))
+ return None
+
+ def get_modules_access_object(self):
+ '''An accessor function that returns a modules_access() object which allows lazy module access from a lldb.SBTarget object.'''
+ return self.modules_access (self)
+
+ def get_modules_array(self):
+ '''An accessor function that returns a list() that contains all modules in a lldb.SBTarget object.'''
+ modules = []
+ for idx in range(self.GetNumModules()):
+ modules.append(self.GetModuleAtIndex(idx))
+ return modules
+
+ def module_iter(self):
+ '''Returns an iterator over all modules in a lldb.SBTarget
+ object.'''
+ return lldb_iter(self, 'GetNumModules', 'GetModuleAtIndex')
+
+ def breakpoint_iter(self):
+ '''Returns an iterator over all breakpoints in a lldb.SBTarget
+ object.'''
+ return lldb_iter(self, 'GetNumBreakpoints', 'GetBreakpointAtIndex')
+
+ def watchpoint_iter(self):
+ '''Returns an iterator over all watchpoints in a lldb.SBTarget
+ object.'''
+ return lldb_iter(self, 'GetNumWatchpoints', 'GetWatchpointAtIndex')
+
+ modules = property(get_modules_array, None, doc='''A read only property that returns a list() of lldb.SBModule objects contained in this target. This list is a list all modules that the target currently is tracking (the main executable and all dependent shared libraries).''')
+ module = property(get_modules_access_object, None, doc=r'''A read only property that returns an object that implements python operator overloading with the square brackets().\n target.module[<int>] allows array access to any modules.\n target.module[<str>] allows access to modules by basename, full path, or uuid string value.\n target.module[uuid.UUID()] allows module access by UUID.\n target.module[re] allows module access using a regular expression that matches the module full path.''')
+ process = property(GetProcess, None, doc='''A read only property that returns an lldb object that represents the process (lldb.SBProcess) that this target owns.''')
+ executable = property(GetExecutable, None, doc='''A read only property that returns an lldb object that represents the main executable module (lldb.SBModule) for this target.''')
+ debugger = property(GetDebugger, None, doc='''A read only property that returns an lldb object that represents the debugger (lldb.SBDebugger) that owns this target.''')
+ num_breakpoints = property(GetNumBreakpoints, None, doc='''A read only property that returns the number of breakpoints that this target has as an integer.''')
+ num_watchpoints = property(GetNumWatchpoints, None, doc='''A read only property that returns the number of watchpoints that this target has as an integer.''')
+ broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this target.''')
+ byte_order = property(GetByteOrder, None, doc='''A read only property that returns an lldb enumeration value (lldb.eByteOrderLittle, lldb.eByteOrderBig, lldb.eByteOrderInvalid) that represents the byte order for this target.''')
+ addr_size = property(GetAddressByteSize, None, doc='''A read only property that returns the size in bytes of an address for this target.''')
+ triple = property(GetTriple, None, doc='''A read only property that returns the target triple (arch-vendor-os) for this target as a string.''')
+ data_byte_size = property(GetDataByteSize, None, doc='''A read only property that returns the size in host bytes of a byte in the data address space for this target.''')
+ code_byte_size = property(GetCodeByteSize, None, doc='''A read only property that returns the size in host bytes of a byte in the code address space for this target.''')
+ platform = property(GetPlatform, None, doc='''A read only property that returns the platform associated with with this target.''')
+ %}
+#endif
+};
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBThread.i b/lldb/bindings/interface/SBThread.i
new file mode 100644
index 000000000000..66466b7947fd
--- /dev/null
+++ b/lldb/bindings/interface/SBThread.i
@@ -0,0 +1,461 @@
+//===-- SWIG Interface for SBThread -----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a thread of execution. SBProcess contains SBThread(s).
+
+SBThreads can be referred to by their ID, which maps to the system specific thread
+identifier, or by IndexID. The ID may or may not be unique depending on whether the
+system reuses its thread identifiers. The IndexID is a monotonically increasing identifier
+that will always uniquely reference a particular thread, and when that thread goes
+away it will not be reused.
+
+SBThread supports frame iteration. For example (from test/python_api/
+lldbutil/iter/TestLLDBIterator.py),
+
+ from lldbutil import print_stacktrace
+ stopped_due_to_breakpoint = False
+ for thread in process:
+ if self.TraceOn():
+ print_stacktrace(thread)
+ ID = thread.GetThreadID()
+ if thread.GetStopReason() == lldb.eStopReasonBreakpoint:
+ stopped_due_to_breakpoint = True
+ for frame in thread:
+ self.assertTrue(frame.GetThread().GetThreadID() == ID)
+ if self.TraceOn():
+ print frame
+
+ self.assertTrue(stopped_due_to_breakpoint)
+
+See also SBProcess and SBFrame."
+) SBThread;
+class SBThread
+{
+public:
+ //------------------------------------------------------------------
+ // Broadcaster bits.
+ //------------------------------------------------------------------
+ enum
+ {
+ eBroadcastBitStackChanged = (1 << 0),
+ eBroadcastBitThreadSuspended = (1 << 1),
+ eBroadcastBitThreadResumed = (1 << 2),
+ eBroadcastBitSelectedFrameChanged = (1 << 3),
+ eBroadcastBitThreadSelected = (1 << 4)
+ };
+
+
+ SBThread ();
+
+ SBThread (const lldb::SBThread &thread);
+
+ ~SBThread();
+
+ static const char *
+ GetBroadcasterClassName ();
+
+ static bool
+ EventIsThreadEvent (const SBEvent &event);
+
+ static SBFrame
+ GetStackFrameFromEvent (const SBEvent &event);
+
+ static SBThread
+ GetThreadFromEvent (const SBEvent &event);
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ void
+ Clear ();
+
+ lldb::StopReason
+ GetStopReason();
+
+ %feature("docstring", "
+ Get the number of words associated with the stop reason.
+ See also GetStopReasonDataAtIndex().") GetStopReasonDataCount;
+ size_t
+ GetStopReasonDataCount();
+
+ %feature("docstring", "
+ Get information associated with a stop reason.
+
+ Breakpoint stop reasons will have data that consists of pairs of
+ breakpoint IDs followed by the breakpoint location IDs (they always come
+ in pairs).
+
+ Stop Reason Count Data Type
+ ======================== ===== =========================================
+ eStopReasonNone 0
+ eStopReasonTrace 0
+ eStopReasonBreakpoint N duple: {breakpoint id, location id}
+ eStopReasonWatchpoint 1 watchpoint id
+ eStopReasonSignal 1 unix signal number
+ eStopReasonException N exception data
+ eStopReasonExec 0
+ eStopReasonPlanComplete 0") GetStopReasonDataAtIndex;
+ uint64_t
+ GetStopReasonDataAtIndex(uint32_t idx);
+
+ %feature("autodoc", "
+ Collects a thread's stop reason extended information dictionary and prints it
+ into the SBStream in a JSON format. The format of this JSON dictionary depends
+ on the stop reason and is currently used only for instrumentation plugins.") GetStopReasonExtendedInfoAsJSON;
+ bool
+ GetStopReasonExtendedInfoAsJSON (lldb::SBStream &stream);
+
+ %feature("autodoc", "
+ Returns a collection of historical stack traces that are significant to the
+ current stop reason. Used by ThreadSanitizer, where we provide various stack
+ traces that were involved in a data race or other type of detected issue.") GetStopReasonExtendedBacktraces;
+ SBThreadCollection
+ GetStopReasonExtendedBacktraces (InstrumentationRuntimeType type);
+
+
+ %feature("autodoc", "
+ Pass only an (int)length and expect to get a Python string describing the
+ stop reason.") GetStopDescription;
+ size_t
+ GetStopDescription (char *dst_or_null, size_t dst_len);
+
+ SBValue
+ GetStopReturnValue ();
+
+ %feature("autodoc", "
+ Returns a unique thread identifier (type lldb::tid_t, typically a 64-bit type)
+ for the current SBThread that will remain constant throughout the thread's
+ lifetime in this process and will not be reused by another thread during this
+ process lifetime. On Mac OS X systems, this is a system-wide unique thread
+ identifier; this identifier is also used by other tools like sample which helps
+ to associate data from those tools with lldb. See related GetIndexID.")
+ GetThreadID;
+ lldb::tid_t
+ GetThreadID () const;
+
+ %feature("autodoc", "
+ Return the index number for this SBThread. The index number is the same thing
+ that a user gives as an argument to 'thread select' in the command line lldb.
+ These numbers start at 1 (for the first thread lldb sees in a debug session)
+ and increments up throughout the process lifetime. An index number will not be
+ reused for a different thread later in a process - thread 1 will always be
+ associated with the same thread. See related GetThreadID.
+ This method returns a uint32_t index number, takes no arguments.")
+ GetIndexID;
+ uint32_t
+ GetIndexID () const;
+
+ const char *
+ GetName () const;
+
+ %feature("autodoc", "
+ Return the queue name associated with this thread, if any, as a str.
+ For example, with a libdispatch (aka Grand Central Dispatch) queue.") GetQueueName;
+
+ const char *
+ GetQueueName() const;
+
+ %feature("autodoc", "
+ Return the dispatch_queue_id for this thread, if any, as a lldb::queue_id_t.
+ For example, with a libdispatch (aka Grand Central Dispatch) queue.") GetQueueID;
+
+ lldb::queue_id_t
+ GetQueueID() const;
+
+ %feature("docstring", "
+ Takes a path string and a SBStream reference as parameters, returns a bool.
+ Collects the thread's 'info' dictionary from the remote system, uses the path
+ argument to descend into the dictionary to an item of interest, and prints
+ it into the SBStream in a natural format. Return bool is to indicate if
+ anything was printed into the stream (true) or not (false).") GetInfoItemByPathAsString;
+
+ bool
+ GetInfoItemByPathAsString (const char *path, lldb::SBStream &strm);
+
+ %feature("autodoc", "
+ Return the SBQueue for this thread. If this thread is not currently associated
+ with a libdispatch queue, the SBQueue object's IsValid() method will return false.
+ If this SBThread is actually a HistoryThread, we may be able to provide QueueID
+ and QueueName, but not provide an SBQueue. Those individual attributes may have
+ been saved for the HistoryThread without enough information to reconstitute the
+ entire SBQueue at that time.
+ This method takes no arguments, returns an SBQueue.") GetQueue;
+
+ lldb::SBQueue
+ GetQueue () const;
+
+ void
+ StepOver (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
+
+ %feature("autodoc",
+ "Do a source level single step over in the currently selected thread.") StepOver;
+ void
+ StepOver (lldb::RunMode stop_other_threads, SBError &error);
+
+ void
+ StepInto (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
+
+ void
+ StepInto (const char *target_name, lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
+
+ %feature("autodoc", "
+ Step the current thread from the current source line to the line given by end_line, stopping if
+ the thread steps into the function given by target_name. If target_name is None, then stepping will stop
+ in any of the places we would normally stop.") StepInto;
+ void
+ StepInto (const char *target_name,
+ uint32_t end_line,
+ SBError &error,
+ lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
+
+ void
+ StepOut ();
+
+ %feature("autodoc",
+ "Step out of the currently selected thread.") StepOut;
+ void
+ StepOut (SBError &error);
+
+ void
+ StepOutOfFrame (SBFrame &frame);
+
+ %feature("autodoc",
+ "Step out of the specified frame.") StepOutOfFrame;
+ void
+ StepOutOfFrame (SBFrame &frame, SBError &error);
+
+ void
+ StepInstruction(bool step_over);
+
+ %feature("autodoc",
+ "Do an instruction level single step in the currently selected thread.") StepInstruction;
+ void
+ StepInstruction(bool step_over, SBError &error);
+
+ SBError
+ StepOverUntil (lldb::SBFrame &frame,
+ lldb::SBFileSpec &file_spec,
+ uint32_t line);
+
+ SBError
+ StepUsingScriptedThreadPlan (const char *script_class_name);
+
+ SBError
+ StepUsingScriptedThreadPlan (const char *script_class_name, bool resume_immediately);
+
+ SBError
+ StepUsingScriptedThreadPlan(const char *script_class_name,
+ lldb::SBStructuredData &args_data,
+ bool resume_immediately);
+
+ SBError
+ JumpToLine (lldb::SBFileSpec &file_spec, uint32_t line);
+
+ void
+ RunToAddress (lldb::addr_t addr);
+
+ void
+ RunToAddress (lldb::addr_t addr, SBError &error);
+
+ %feature("autodoc", "
+ Force a return from the frame passed in (and any frames younger than it)
+ without executing any more code in those frames. If return_value contains
+ a valid SBValue, that will be set as the return value from frame. Note, at
+ present only scalar return values are supported.") ReturnFromFrame;
+
+ SBError
+ ReturnFromFrame (SBFrame &frame, SBValue &return_value);
+
+ %feature("autodoc", "
+ Unwind the stack frames from the innermost expression evaluation.
+ This API is equivalent to 'thread return -x'.") UnwindInnermostExpression;
+
+ SBError
+ UnwindInnermostExpression();
+
+ %feature("docstring", "
+ LLDB currently supports process centric debugging which means when any
+ thread in a process stops, all other threads are stopped. The Suspend()
+ call here tells our process to suspend a thread and not let it run when
+ the other threads in a process are allowed to run. So when
+ SBProcess::Continue() is called, any threads that aren't suspended will
+ be allowed to run. If any of the SBThread functions for stepping are
+ called (StepOver, StepInto, StepOut, StepInstruction, RunToAddres), the
+ thread will now be allowed to run and these functions will simply return.
+
+ Eventually we plan to add support for thread centric debugging where
+ each thread is controlled individually and each thread would broadcast
+ its state, but we haven't implemented this yet.
+
+ Likewise the SBThread::Resume() call will again allow the thread to run
+ when the process is continued.
+
+ Suspend() and Resume() functions are not currently reference counted, if
+ anyone has the need for them to be reference counted, please let us
+ know.") Suspend;
+ bool
+ Suspend();
+
+ bool
+ Suspend(SBError &error);
+
+ bool
+ Resume ();
+
+ bool
+ Resume (SBError &error);
+
+ bool
+ IsSuspended();
+
+ bool
+ IsStopped();
+
+ uint32_t
+ GetNumFrames ();
+
+ lldb::SBFrame
+ GetFrameAtIndex (uint32_t idx);
+
+ lldb::SBFrame
+ GetSelectedFrame ();
+
+ lldb::SBFrame
+ SetSelectedFrame (uint32_t frame_idx);
+
+ lldb::SBProcess
+ GetProcess ();
+
+ bool
+ GetDescription (lldb::SBStream &description) const;
+
+ %feature("docstring", "
+ Get the description strings for this thread that match what the
+ lldb driver will present, using the thread-format (stop_format==false)
+ or thread-stop-format (stop_format = true).") GetDescription;
+ bool GetDescription(lldb::SBStream &description, bool stop_format) const;
+
+ bool
+ GetStatus (lldb::SBStream &status) const;
+
+ bool
+ operator == (const lldb::SBThread &rhs) const;
+
+ bool
+ operator != (const lldb::SBThread &rhs) const;
+
+ %feature("autodoc","
+ Given an argument of str to specify the type of thread-origin extended
+ backtrace to retrieve, query whether the origin of this thread is
+ available. An SBThread is retured; SBThread.IsValid will return true
+ if an extended backtrace was available. The returned SBThread is not
+ a part of the SBProcess' thread list and it cannot be manipulated like
+ normal threads -- you cannot step or resume it, for instance -- it is
+ intended to used primarily for generating a backtrace. You may request
+ the returned thread's own thread origin in turn.") GetExtendedBacktraceThread;
+ lldb::SBThread
+ GetExtendedBacktraceThread (const char *type);
+
+ %feature("autodoc","
+ Takes no arguments, returns a uint32_t.
+ If this SBThread is an ExtendedBacktrace thread, get the IndexID of the
+ original thread that this ExtendedBacktrace thread represents, if
+ available. The thread that was running this backtrace in the past may
+ not have been registered with lldb's thread index (if it was created,
+ did its work, and was destroyed without lldb ever stopping execution).
+ In that case, this ExtendedBacktrace thread's IndexID will be returned.") GetExtendedBacktraceOriginatingIndexID;
+ uint32_t
+ GetExtendedBacktraceOriginatingIndexID();
+
+ %feature("autodoc","
+ Returns an SBValue object represeting the current exception for the thread,
+ if there is any. Currently, this works for Obj-C code and returns an SBValue
+ representing the NSException object at the throw site or that's currently
+ being processes.") GetCurrentException;
+ lldb::SBValue
+ GetCurrentException();
+
+ %feature("autodoc","
+ Returns a historical (fake) SBThread representing the stack trace of an
+ exception, if there is one for the thread. Currently, this works for Obj-C
+ code, and can retrieve the throw-site backtrace of an NSException object
+ even when the program is no longer at the throw site.") GetCurrentExceptionBacktrace;
+ lldb::SBThread
+ GetCurrentExceptionBacktrace();
+
+ %feature("autodoc","
+ Takes no arguments, returns a bool.
+ lldb may be able to detect that function calls should not be executed
+ on a given thread at a particular point in time. It is recommended that
+ this is checked before performing an inferior function call on a given
+ thread.") SafeToCallFunctions;
+ bool
+ SafeToCallFunctions ();
+
+ STRING_EXTENSION(SBThread)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ def __iter__(self):
+ '''Iterate over all frames in a lldb.SBThread object.'''
+ return lldb_iter(self, 'GetNumFrames', 'GetFrameAtIndex')
+
+ def __len__(self):
+ '''Return the number of frames in a lldb.SBThread object.'''
+ return self.GetNumFrames()
+
+ class frames_access(object):
+ '''A helper object that will lazily hand out frames for a thread when supplied an index.'''
+ def __init__(self, sbthread):
+ self.sbthread = sbthread
+
+ def __len__(self):
+ if self.sbthread:
+ return int(self.sbthread.GetNumFrames())
+ return 0
+
+ def __getitem__(self, key):
+ if type(key) is int and key < self.sbthread.GetNumFrames():
+ return self.sbthread.GetFrameAtIndex(key)
+ return None
+
+ def get_frames_access_object(self):
+ '''An accessor function that returns a frames_access() object which allows lazy frame access from a lldb.SBThread object.'''
+ return self.frames_access (self)
+
+ def get_thread_frames(self):
+ '''An accessor function that returns a list() that contains all frames in a lldb.SBThread object.'''
+ frames = []
+ for frame in self:
+ frames.append(frame)
+ return frames
+
+ id = property(GetThreadID, None, doc='''A read only property that returns the thread ID as an integer.''')
+ idx = property(GetIndexID, None, doc='''A read only property that returns the thread index ID as an integer. Thread index ID values start at 1 and increment as threads come and go and can be used to uniquely identify threads.''')
+ return_value = property(GetStopReturnValue, None, doc='''A read only property that returns an lldb object that represents the return value from the last stop (lldb.SBValue) if we just stopped due to stepping out of a function.''')
+ process = property(GetProcess, None, doc='''A read only property that returns an lldb object that represents the process (lldb.SBProcess) that owns this thread.''')
+ num_frames = property(GetNumFrames, None, doc='''A read only property that returns the number of stack frames in this thread as an integer.''')
+ frames = property(get_thread_frames, None, doc='''A read only property that returns a list() of lldb.SBFrame objects for all frames in this thread.''')
+ frame = property(get_frames_access_object, None, doc='''A read only property that returns an object that can be used to access frames as an array ("frame_12 = lldb.thread.frame[12]").''')
+ name = property(GetName, None, doc='''A read only property that returns the name of this thread as a string.''')
+ queue = property(GetQueueName, None, doc='''A read only property that returns the dispatch queue name of this thread as a string.''')
+ queue_id = property(GetQueueID, None, doc='''A read only property that returns the dispatch queue id of this thread as an integer.''')
+ stop_reason = property(GetStopReason, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eStopReason") that represents the reason this thread stopped.''')
+ is_suspended = property(IsSuspended, None, doc='''A read only property that returns a boolean value that indicates if this thread is suspended.''')
+ is_stopped = property(IsStopped, None, doc='''A read only property that returns a boolean value that indicates if this thread is stopped but not exited.''')
+ %}
+#endif
+
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBThreadCollection.i b/lldb/bindings/interface/SBThreadCollection.i
new file mode 100644
index 000000000000..c2d9d8318dcd
--- /dev/null
+++ b/lldb/bindings/interface/SBThreadCollection.i
@@ -0,0 +1,39 @@
+//===-- SWIG Interface for SBThreadCollection -------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a collection of SBThread objects."
+) SBThreadCollection;
+class SBThreadCollection
+{
+public:
+
+ SBThreadCollection ();
+
+ SBThreadCollection (const SBThreadCollection &rhs);
+
+ ~SBThreadCollection ();
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+ size_t
+ GetSize ();
+
+ lldb::SBThread
+ GetThreadAtIndex (size_t idx);
+
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBThreadPlan.i b/lldb/bindings/interface/SBThreadPlan.i
new file mode 100644
index 000000000000..36131d529b7b
--- /dev/null
+++ b/lldb/bindings/interface/SBThreadPlan.i
@@ -0,0 +1,137 @@
+//===-- SBThread.h ----------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SBThreadPlan_h_
+#define LLDB_SBThreadPlan_h_
+
+#include "lldb/API/SBDefines.h"
+
+#include <stdio.h>
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a plan for the execution control of a given thread.
+
+See also SBThread and SBFrame."
+) SBThread;
+
+class SBThreadPlan
+{
+
+friend class lldb_private::ThreadPlan;
+
+public:
+ SBThreadPlan ();
+
+ SBThreadPlan (const lldb::SBThreadPlan &threadPlan);
+
+ SBThreadPlan (const lldb::ThreadPlanSP& lldb_object_sp);
+
+ SBThreadPlan (lldb::SBThread &thread, const char *class_name);
+
+ ~SBThreadPlan ();
+
+ bool
+ IsValid();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ void
+ Clear ();
+
+ lldb::StopReason
+ GetStopReason();
+
+ %feature("docstring", "
+ Get the number of words associated with the stop reason.
+ See also GetStopReasonDataAtIndex().") GetStopReasonDataCount;
+ size_t
+ GetStopReasonDataCount();
+
+ %feature("docstring", "
+ Get information associated with a stop reason.
+
+ Breakpoint stop reasons will have data that consists of pairs of
+ breakpoint IDs followed by the breakpoint location IDs (they always come
+ in pairs).
+
+ Stop Reason Count Data Type
+ ======================== ===== =========================================
+ eStopReasonNone 0
+ eStopReasonTrace 0
+ eStopReasonBreakpoint N duple: {breakpoint id, location id}
+ eStopReasonWatchpoint 1 watchpoint id
+ eStopReasonSignal 1 unix signal number
+ eStopReasonException N exception data
+ eStopReasonExec 0
+ eStopReasonPlanComplete 0") GetStopReasonDataAtIndex;
+ uint64_t
+ GetStopReasonDataAtIndex(uint32_t idx);
+
+ SBThread
+ GetThread () const;
+
+ bool
+ GetDescription (lldb::SBStream &description) const;
+
+ void
+ SetPlanComplete (bool success);
+
+ bool
+ IsPlanComplete();
+
+ bool
+ IsPlanStale();
+
+ SBThreadPlan
+ QueueThreadPlanForStepOverRange (SBAddress &start_address,
+ lldb::addr_t range_size);
+
+ SBThreadPlan
+ QueueThreadPlanForStepInRange (SBAddress &start_address,
+ lldb::addr_t range_size);
+
+ SBThreadPlan
+ QueueThreadPlanForStepOut (uint32_t frame_idx_to_step_to, bool first_insn = false);
+
+ SBThreadPlan
+ QueueThreadPlanForRunToAddress (SBAddress address);
+
+ SBThreadPlan
+ QueueThreadPlanForStepScripted(const char *script_class_name);
+
+ SBThreadPlan
+ QueueThreadPlanForStepScripted(const char *script_class_name,
+ SBError &error);
+ SBThreadPlan
+ QueueThreadPlanForStepScripted(const char *script_class_name,
+ SBStructuredData &args_data,
+ SBError &error);
+
+
+protected:
+ friend class SBBreakpoint;
+ friend class SBBreakpointLocation;
+ friend class SBFrame;
+ friend class SBProcess;
+ friend class SBDebugger;
+ friend class SBValue;
+ friend class lldb_private::QueueImpl;
+ friend class SBQueueItem;
+
+private:
+ lldb::ThreadPlanSP m_opaque_sp;
+};
+
+} // namespace lldb
+
+#endif // LLDB_SBThreadPlan_h_
diff --git a/lldb/bindings/interface/SBTrace.i b/lldb/bindings/interface/SBTrace.i
new file mode 100644
index 000000000000..a4cb2667ec10
--- /dev/null
+++ b/lldb/bindings/interface/SBTrace.i
@@ -0,0 +1,35 @@
+//===-- SWIG Interface for SBTrace.h ----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class LLDB_API SBTrace {
+public:
+ SBTrace();
+ size_t GetTraceData(SBError &error, void *buf,
+ size_t size, size_t offset,
+ lldb::tid_t thread_id);
+
+ size_t GetMetaData(SBError &error, void *buf,
+ size_t size, size_t offset,
+ lldb::tid_t thread_id);
+
+ void StopTrace(SBError &error,
+ lldb::tid_t thread_id);
+
+ void GetTraceConfig(SBTraceOptions &options,
+ SBError &error);
+
+ lldb::user_id_t GetTraceUID();
+
+ explicit operator bool() const;
+
+ bool IsValid();
+
+};
+} // namespace lldb \ No newline at end of file
diff --git a/lldb/bindings/interface/SBTraceOptions.i b/lldb/bindings/interface/SBTraceOptions.i
new file mode 100644
index 000000000000..ce17af5376ca
--- /dev/null
+++ b/lldb/bindings/interface/SBTraceOptions.i
@@ -0,0 +1,39 @@
+//===-- SWIG Interface for SBTraceOptions -----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class LLDB_API SBTraceOptions {
+public:
+ SBTraceOptions();
+
+ lldb::TraceType getType() const;
+
+ uint64_t getTraceBufferSize() const;
+
+ lldb::SBStructuredData getTraceParams(lldb::SBError &error);
+
+ uint64_t getMetaDataBufferSize() const;
+
+ void setTraceParams(lldb::SBStructuredData &params);
+
+ void setType(lldb::TraceType type);
+
+ void setTraceBufferSize(uint64_t size);
+
+ void setMetaDataBufferSize(uint64_t size);
+
+ void setThreadID(lldb::tid_t thread_id);
+
+ lldb::tid_t getThreadID();
+
+ explicit operator bool() const;
+
+ bool IsValid();
+};
+}
diff --git a/lldb/bindings/interface/SBType.i b/lldb/bindings/interface/SBType.i
new file mode 100644
index 000000000000..3cd82452084b
--- /dev/null
+++ b/lldb/bindings/interface/SBType.i
@@ -0,0 +1,487 @@
+//===-- SWIG Interface for SBType -------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+ %feature("docstring",
+"Represents a member of a type in lldb.") SBTypeMember;
+
+class SBTypeMember
+{
+public:
+ SBTypeMember ();
+
+ SBTypeMember (const lldb::SBTypeMember& rhs);
+
+ ~SBTypeMember();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ const char *
+ GetName ();
+
+ lldb::SBType
+ GetType ();
+
+ uint64_t
+ GetOffsetInBytes();
+
+ uint64_t
+ GetOffsetInBits();
+
+ bool
+ IsBitfield();
+
+ uint32_t
+ GetBitfieldSizeInBits();
+
+ STRING_EXTENSION_LEVEL(SBTypeMember, lldb::eDescriptionLevelBrief)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ name = property(GetName, None, doc='''A read only property that returns the name for this member as a string.''')
+ type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the type (lldb.SBType) for this member.''')
+ byte_offset = property(GetOffsetInBytes, None, doc='''A read only property that returns offset in bytes for this member as an integer.''')
+ bit_offset = property(GetOffsetInBits, None, doc='''A read only property that returns offset in bits for this member as an integer.''')
+ is_bitfield = property(IsBitfield, None, doc='''A read only property that returns true if this member is a bitfield.''')
+ bitfield_bit_size = property(GetBitfieldSizeInBits, None, doc='''A read only property that returns the bitfield size in bits for this member as an integer, or zero if this member is not a bitfield.''')
+ %}
+#endif
+
+protected:
+ std::unique_ptr<lldb_private::TypeMemberImpl> m_opaque_ap;
+};
+
+class SBTypeMemberFunction
+{
+public:
+ SBTypeMemberFunction ();
+
+ SBTypeMemberFunction (const lldb::SBTypeMemberFunction& rhs);
+
+ ~SBTypeMemberFunction();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ const char *
+ GetName ();
+
+ const char *
+ GetDemangledName ();
+
+ const char *
+ GetMangledName ();
+
+ lldb::SBType
+ GetType ();
+
+ lldb::SBType
+ GetReturnType ();
+
+ uint32_t
+ GetNumberOfArguments ();
+
+ lldb::SBType
+ GetArgumentTypeAtIndex (uint32_t);
+
+ lldb::MemberFunctionKind
+ GetKind();
+
+ bool
+ GetDescription (lldb::SBStream &description,
+ lldb::DescriptionLevel description_level);
+
+ STRING_EXTENSION_LEVEL(SBTypeMemberFunction, lldb::eDescriptionLevelBrief)
+protected:
+ lldb::TypeMemberFunctionImplSP m_opaque_sp;
+};
+
+%feature("docstring",
+"Represents a data type in lldb. The FindFirstType() method of SBTarget/SBModule
+returns a SBType.
+
+SBType supports the eq/ne operator. For example,
+
+main.cpp:
+
+class Task {
+public:
+ int id;
+ Task *next;
+ Task(int i, Task *n):
+ id(i),
+ next(n)
+ {}
+};
+
+int main (int argc, char const *argv[])
+{
+ Task *task_head = new Task(-1, NULL);
+ Task *task1 = new Task(1, NULL);
+ Task *task2 = new Task(2, NULL);
+ Task *task3 = new Task(3, NULL); // Orphaned.
+ Task *task4 = new Task(4, NULL);
+ Task *task5 = new Task(5, NULL);
+
+ task_head->next = task1;
+ task1->next = task2;
+ task2->next = task4;
+ task4->next = task5;
+
+ int total = 0;
+ Task *t = task_head;
+ while (t != NULL) {
+ if (t->id >= 0)
+ ++total;
+ t = t->next;
+ }
+ printf('We have a total number of %d tasks\\n', total);
+
+ // This corresponds to an empty task list.
+ Task *empty_task_head = new Task(-1, NULL);
+
+ return 0; // Break at this line
+}
+
+find_type.py:
+
+ # Get the type 'Task'.
+ task_type = target.FindFirstType('Task')
+ self.assertTrue(task_type)
+
+ # Get the variable 'task_head'.
+ frame0.FindVariable('task_head')
+ task_head_type = task_head.GetType()
+ self.assertTrue(task_head_type.IsPointerType())
+
+ # task_head_type is 'Task *'.
+ task_pointer_type = task_type.GetPointerType()
+ self.assertTrue(task_head_type == task_pointer_type)
+
+ # Get the child mmember 'id' from 'task_head'.
+ id = task_head.GetChildMemberWithName('id')
+ id_type = id.GetType()
+
+ # SBType.GetBasicType() takes an enum 'BasicType' (lldb-enumerations.h).
+ int_type = id_type.GetBasicType(lldb.eBasicTypeInt)
+ # id_type and int_type should be the same type!
+ self.assertTrue(id_type == int_type)
+
+...") SBType;
+class SBType
+{
+public:
+ SBType ();
+
+ SBType (const lldb::SBType &rhs);
+
+ ~SBType ();
+
+ bool
+ IsValid();
+
+ explicit operator bool() const;
+
+ uint64_t
+ GetByteSize();
+
+ bool
+ IsPointerType();
+
+ bool
+ IsReferenceType();
+
+ bool
+ IsFunctionType ();
+
+ bool
+ IsPolymorphicClass ();
+
+ bool
+ IsArrayType ();
+
+ bool
+ IsVectorType ();
+
+ bool
+ IsTypedefType ();
+
+ bool
+ IsAnonymousType ();
+
+ lldb::SBType
+ GetPointerType();
+
+ lldb::SBType
+ GetPointeeType();
+
+ lldb::SBType
+ GetReferenceType();
+
+ lldb::SBType
+ SBType::GetTypedefedType();
+
+ lldb::SBType
+ GetDereferencedType();
+
+ lldb::SBType
+ GetUnqualifiedType();
+
+ lldb::SBType
+ GetCanonicalType();
+
+ lldb::SBType
+ GetArrayElementType ();
+
+ lldb::SBType
+ GetArrayType (uint64_t size);
+
+ lldb::SBType
+ GetVectorElementType ();
+
+ lldb::BasicType
+ GetBasicType();
+
+ lldb::SBType
+ GetBasicType (lldb::BasicType type);
+
+ uint32_t
+ GetNumberOfFields ();
+
+ uint32_t
+ GetNumberOfDirectBaseClasses ();
+
+ uint32_t
+ GetNumberOfVirtualBaseClasses ();
+
+ lldb::SBTypeMember
+ GetFieldAtIndex (uint32_t idx);
+
+ lldb::SBTypeMember
+ GetDirectBaseClassAtIndex (uint32_t idx);
+
+ lldb::SBTypeMember
+ GetVirtualBaseClassAtIndex (uint32_t idx);
+
+ lldb::SBTypeEnumMemberList
+ GetEnumMembers();
+
+ const char*
+ GetName();
+
+ const char *
+ GetDisplayTypeName ();
+
+ lldb::TypeClass
+ GetTypeClass ();
+
+ uint32_t
+ GetNumberOfTemplateArguments ();
+
+ lldb::SBType
+ GetTemplateArgumentType (uint32_t idx);
+
+ lldb::TemplateArgumentKind
+ GetTemplateArgumentKind (uint32_t idx);
+
+ lldb::SBType
+ GetFunctionReturnType ();
+
+ lldb::SBTypeList
+ GetFunctionArgumentTypes ();
+
+ uint32_t
+ GetNumberOfMemberFunctions ();
+
+ lldb::SBTypeMemberFunction
+ GetMemberFunctionAtIndex (uint32_t idx);
+
+ bool
+ IsTypeComplete ();
+
+ uint32_t
+ GetTypeFlags ();
+
+ bool operator==(lldb::SBType &rhs);
+
+ bool operator!=(lldb::SBType &rhs);
+
+ STRING_EXTENSION_LEVEL(SBType, lldb::eDescriptionLevelBrief)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ def template_arg_array(self):
+ num_args = self.num_template_args
+ if num_args:
+ template_args = []
+ for i in range(num_args):
+ template_args.append(self.GetTemplateArgumentType(i))
+ return template_args
+ return None
+
+ name = property(GetName, None, doc='''A read only property that returns the name for this type as a string.''')
+ size = property(GetByteSize, None, doc='''A read only property that returns size in bytes for this type as an integer.''')
+ is_pointer = property(IsPointerType, None, doc='''A read only property that returns a boolean value that indicates if this type is a pointer type.''')
+ is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a reference type.''')
+ is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a function type.''')
+ num_fields = property(GetNumberOfFields, None, doc='''A read only property that returns number of fields in this type as an integer.''')
+ num_bases = property(GetNumberOfDirectBaseClasses, None, doc='''A read only property that returns number of direct base classes in this type as an integer.''')
+ num_vbases = property(GetNumberOfVirtualBaseClasses, None, doc='''A read only property that returns number of virtual base classes in this type as an integer.''')
+ num_template_args = property(GetNumberOfTemplateArguments, None, doc='''A read only property that returns number of template arguments in this type as an integer.''')
+ template_args = property(template_arg_array, None, doc='''A read only property that returns a list() of lldb.SBType objects that represent all template arguments in this type.''')
+ type = property(GetTypeClass, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eTypeClass") that represents a classification for this type.''')
+ is_complete = property(IsTypeComplete, None, doc='''A read only property that returns a boolean value that indicates if this type is a complete type (True) or a forward declaration (False).''')
+
+ def get_bases_array(self):
+ '''An accessor function that returns a list() that contains all direct base classes in a lldb.SBType object.'''
+ bases = []
+ for idx in range(self.GetNumberOfDirectBaseClasses()):
+ bases.append(self.GetDirectBaseClassAtIndex(idx))
+ return bases
+
+ def get_vbases_array(self):
+ '''An accessor function that returns a list() that contains all fields in a lldb.SBType object.'''
+ vbases = []
+ for idx in range(self.GetNumberOfVirtualBaseClasses()):
+ vbases.append(self.GetVirtualBaseClassAtIndex(idx))
+ return vbases
+
+ def get_fields_array(self):
+ '''An accessor function that returns a list() that contains all fields in a lldb.SBType object.'''
+ fields = []
+ for idx in range(self.GetNumberOfFields()):
+ fields.append(self.GetFieldAtIndex(idx))
+ return fields
+
+ def get_members_array(self):
+ '''An accessor function that returns a list() that contains all members (base classes and fields) in a lldb.SBType object in ascending bit offset order.'''
+ members = []
+ bases = self.get_bases_array()
+ fields = self.get_fields_array()
+ vbases = self.get_vbases_array()
+ for base in bases:
+ bit_offset = base.bit_offset
+ added = False
+ for idx, member in enumerate(members):
+ if member.bit_offset > bit_offset:
+ members.insert(idx, base)
+ added = True
+ break
+ if not added:
+ members.append(base)
+ for vbase in vbases:
+ bit_offset = vbase.bit_offset
+ added = False
+ for idx, member in enumerate(members):
+ if member.bit_offset > bit_offset:
+ members.insert(idx, vbase)
+ added = True
+ break
+ if not added:
+ members.append(vbase)
+ for field in fields:
+ bit_offset = field.bit_offset
+ added = False
+ for idx, member in enumerate(members):
+ if member.bit_offset > bit_offset:
+ members.insert(idx, field)
+ added = True
+ break
+ if not added:
+ members.append(field)
+ return members
+
+ def get_enum_members_array(self):
+ '''An accessor function that returns a list() that contains all enum members in an lldb.SBType object.'''
+ enum_members_list = []
+ sb_enum_members = self.GetEnumMembers()
+ for idx in range(sb_enum_members.GetSize()):
+ enum_members_list.append(sb_enum_members.GetTypeEnumMemberAtIndex(idx))
+ return enum_members_list
+
+ bases = property(get_bases_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the direct base classes for this type.''')
+ vbases = property(get_vbases_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the virtual base classes for this type.''')
+ fields = property(get_fields_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the fields for this type.''')
+ members = property(get_members_array, None, doc='''A read only property that returns a list() of all lldb.SBTypeMember objects that represent all of the base classes, virtual base classes and fields for this type in ascending bit offset order.''')
+ enum_members = property(get_enum_members_array, None, doc='''A read only property that returns a list() of all lldb.SBTypeEnumMember objects that represent the enum members for this type.''')
+ %}
+#endif
+
+};
+
+%feature("docstring",
+"Represents a list of SBTypes. The FindTypes() method of SBTarget/SBModule
+returns a SBTypeList.
+
+SBTypeList supports SBType iteration. For example,
+
+main.cpp:
+
+class Task {
+public:
+ int id;
+ Task *next;
+ Task(int i, Task *n):
+ id(i),
+ next(n)
+ {}
+};
+
+...
+
+find_type.py:
+
+ # Get the type 'Task'.
+ type_list = target.FindTypes('Task')
+ self.assertTrue(len(type_list) == 1)
+ # To illustrate the SBType iteration.
+ for type in type_list:
+ # do something with type
+
+...") SBTypeList;
+class SBTypeList
+{
+public:
+ SBTypeList();
+
+ bool
+ IsValid();
+
+ explicit operator bool() const;
+
+ void
+ Append (lldb::SBType type);
+
+ lldb::SBType
+ GetTypeAtIndex (uint32_t index);
+
+ uint32_t
+ GetSize();
+
+ ~SBTypeList();
+
+#ifdef SWIGPYTHON
+ %pythoncode%{
+ def __iter__(self):
+ '''Iterate over all types in a lldb.SBTypeList object.'''
+ return lldb_iter(self, 'GetSize', 'GetTypeAtIndex')
+
+ def __len__(self):
+ '''Return the number of types in a lldb.SBTypeList object.'''
+ return self.GetSize()
+ %}
+#endif
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBTypeCategory.i b/lldb/bindings/interface/SBTypeCategory.i
new file mode 100644
index 000000000000..b762bf8a95a3
--- /dev/null
+++ b/lldb/bindings/interface/SBTypeCategory.i
@@ -0,0 +1,225 @@
+//===-- SWIG Interface for SBTypeCategory---------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+ %feature("docstring",
+ "Represents a category that can contain formatters for types.") SBTypeCategory;
+
+ class SBTypeCategory
+ {
+ public:
+
+ SBTypeCategory();
+
+ SBTypeCategory (const lldb::SBTypeCategory &rhs);
+
+ ~SBTypeCategory ();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ bool
+ GetEnabled ();
+
+ void
+ SetEnabled (bool);
+
+ const char*
+ GetName();
+
+ lldb::LanguageType
+ GetLanguageAtIndex (uint32_t idx);
+
+ uint32_t
+ GetNumLanguages ();
+
+ void
+ AddLanguage (lldb::LanguageType language);
+
+ bool
+ GetDescription (lldb::SBStream &description,
+ lldb::DescriptionLevel description_level);
+
+ uint32_t
+ GetNumFormats ();
+
+ uint32_t
+ GetNumSummaries ();
+
+ uint32_t
+ GetNumFilters ();
+
+ uint32_t
+ GetNumSynthetics ();
+
+ lldb::SBTypeNameSpecifier
+ GetTypeNameSpecifierForFilterAtIndex (uint32_t);
+
+ lldb::SBTypeNameSpecifier
+ GetTypeNameSpecifierForFormatAtIndex (uint32_t);
+
+ lldb::SBTypeNameSpecifier
+ GetTypeNameSpecifierForSummaryAtIndex (uint32_t);
+
+ lldb::SBTypeNameSpecifier
+ GetTypeNameSpecifierForSyntheticAtIndex (uint32_t);
+
+ lldb::SBTypeFilter
+ GetFilterForType (lldb::SBTypeNameSpecifier);
+
+ lldb::SBTypeFormat
+ GetFormatForType (lldb::SBTypeNameSpecifier);
+
+ lldb::SBTypeSummary
+ GetSummaryForType (lldb::SBTypeNameSpecifier);
+
+ lldb::SBTypeSynthetic
+ GetSyntheticForType (lldb::SBTypeNameSpecifier);
+
+ lldb::SBTypeFilter
+ GetFilterAtIndex (uint32_t);
+
+ lldb::SBTypeFormat
+ GetFormatAtIndex (uint32_t);
+
+ lldb::SBTypeSummary
+ GetSummaryAtIndex (uint32_t);
+
+ lldb::SBTypeSynthetic
+ GetSyntheticAtIndex (uint32_t);
+
+ bool
+ AddTypeFormat (lldb::SBTypeNameSpecifier,
+ lldb::SBTypeFormat);
+
+ bool
+ DeleteTypeFormat (lldb::SBTypeNameSpecifier);
+
+ bool
+ AddTypeSummary (lldb::SBTypeNameSpecifier,
+ lldb::SBTypeSummary);
+
+ bool
+ DeleteTypeSummary (lldb::SBTypeNameSpecifier);
+
+ bool
+ AddTypeFilter (lldb::SBTypeNameSpecifier,
+ lldb::SBTypeFilter);
+
+ bool
+ DeleteTypeFilter (lldb::SBTypeNameSpecifier);
+
+ bool
+ AddTypeSynthetic (lldb::SBTypeNameSpecifier,
+ lldb::SBTypeSynthetic);
+
+ bool
+ DeleteTypeSynthetic (lldb::SBTypeNameSpecifier);
+
+ STRING_EXTENSION_LEVEL(SBTypeCategory, lldb::eDescriptionLevelBrief)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+
+ class formatters_access_class(object):
+ '''A helper object that will lazily hand out formatters for a specific category.'''
+ def __init__(self, sbcategory, get_count_function, get_at_index_function, get_by_name_function):
+ self.sbcategory = sbcategory
+ self.get_count_function = get_count_function
+ self.get_at_index_function = get_at_index_function
+ self.get_by_name_function = get_by_name_function
+ self.regex_type = type(re.compile('.'))
+
+
+ def __len__(self):
+ if self.sbcategory and self.get_count_function:
+ return int(self.get_count_function(self.sbcategory))
+ return 0
+
+ def __getitem__(self, key):
+ num_items = len(self)
+ if type(key) is int:
+ if key < num_items:
+ return self.get_at_index_function(self.sbcategory,key)
+ elif type(key) is str:
+ return self.get_by_name_function(self.sbcategory,SBTypeNameSpecifier(key))
+ elif isinstance(key,self.regex_type):
+ return self.get_by_name_function(self.sbcategory,SBTypeNameSpecifier(key.pattern,True))
+ else:
+ print("error: unsupported item type: %s" % type(key))
+ return None
+
+ def get_formats_access_object(self):
+ '''An accessor function that returns an accessor object which allows lazy format access from a lldb.SBTypeCategory object.'''
+ return self.formatters_access_class (self,self.__class__.GetNumFormats,self.__class__.GetFormatAtIndex,self.__class__.GetFormatForType)
+
+ def get_formats_array(self):
+ '''An accessor function that returns a list() that contains all formats in a lldb.SBCategory object.'''
+ formats = []
+ for idx in range(self.GetNumFormats()):
+ formats.append(self.GetFormatAtIndex(idx))
+ return formats
+
+ def get_summaries_access_object(self):
+ '''An accessor function that returns an accessor object which allows lazy summary access from a lldb.SBTypeCategory object.'''
+ return self.formatters_access_class (self,self.__class__.GetNumSummaries,self.__class__.GetSummaryAtIndex,self.__class__.GetSummaryForType)
+
+ def get_summaries_array(self):
+ '''An accessor function that returns a list() that contains all summaries in a lldb.SBCategory object.'''
+ summaries = []
+ for idx in range(self.GetNumSummaries()):
+ summaries.append(self.GetSummaryAtIndex(idx))
+ return summaries
+
+ def get_synthetics_access_object(self):
+ '''An accessor function that returns an accessor object which allows lazy synthetic children provider access from a lldb.SBTypeCategory object.'''
+ return self.formatters_access_class (self,self.__class__.GetNumSynthetics,self.__class__.GetSyntheticAtIndex,self.__class__.GetSyntheticForType)
+
+ def get_synthetics_array(self):
+ '''An accessor function that returns a list() that contains all synthetic children providers in a lldb.SBCategory object.'''
+ synthetics = []
+ for idx in range(self.GetNumSynthetics()):
+ synthetics.append(self.GetSyntheticAtIndex(idx))
+ return synthetics
+
+ def get_filters_access_object(self):
+ '''An accessor function that returns an accessor object which allows lazy filter access from a lldb.SBTypeCategory object.'''
+ return self.formatters_access_class (self,self.__class__.GetNumFilters,self.__class__.GetFilterAtIndex,self.__class__.GetFilterForType)
+
+ def get_filters_array(self):
+ '''An accessor function that returns a list() that contains all filters in a lldb.SBCategory object.'''
+ filters = []
+ for idx in range(self.GetNumFilters()):
+ filters.append(self.GetFilterAtIndex(idx))
+ return filters
+
+ formats = property(get_formats_array, None, doc='''A read only property that returns a list() of lldb.SBTypeFormat objects contained in this category''')
+ format = property(get_formats_access_object, None, doc=r'''A read only property that returns an object that you can use to look for formats by index or type name.''')
+ summaries = property(get_summaries_array, None, doc='''A read only property that returns a list() of lldb.SBTypeSummary objects contained in this category''')
+ summary = property(get_summaries_access_object, None, doc=r'''A read only property that returns an object that you can use to look for summaries by index or type name or regular expression.''')
+ filters = property(get_filters_array, None, doc='''A read only property that returns a list() of lldb.SBTypeFilter objects contained in this category''')
+ filter = property(get_filters_access_object, None, doc=r'''A read only property that returns an object that you can use to look for filters by index or type name or regular expression.''')
+ synthetics = property(get_synthetics_array, None, doc='''A read only property that returns a list() of lldb.SBTypeSynthetic objects contained in this category''')
+ synthetic = property(get_synthetics_access_object, None, doc=r'''A read only property that returns an object that you can use to look for synthetic children provider by index or type name or regular expression.''')
+ num_formats = property(GetNumFormats, None)
+ num_summaries = property(GetNumSummaries, None)
+ num_filters = property(GetNumFilters, None)
+ num_synthetics = property(GetNumSynthetics, None)
+ name = property(GetName, None)
+ enabled = property(GetEnabled, SetEnabled)
+ %}
+#endif
+
+ };
+
+
+} // namespace lldb
+
diff --git a/lldb/bindings/interface/SBTypeEnumMember.i b/lldb/bindings/interface/SBTypeEnumMember.i
new file mode 100644
index 000000000000..006bdeaa8cee
--- /dev/null
+++ b/lldb/bindings/interface/SBTypeEnumMember.i
@@ -0,0 +1,107 @@
+//===-- SWIG Interface for SBTypeEnumMember ---------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature(
+ "docstring",
+ "Represents a member of an enum in lldb."
+) SBTypeEnumMember;
+
+class SBTypeEnumMember
+{
+public:
+ SBTypeEnumMember ();
+
+ SBTypeEnumMember (const SBTypeEnumMember& rhs);
+
+ ~SBTypeEnumMember();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ int64_t
+ GetValueAsSigned();
+
+ uint64_t
+ GetValueAsUnsigned();
+
+ const char *
+ GetName ();
+
+ lldb::SBType
+ GetType ();
+
+ bool
+ GetDescription (lldb::SBStream &description,
+ lldb::DescriptionLevel description_level);
+
+ STRING_EXTENSION_LEVEL(SBTypeEnumMember, lldb::eDescriptionLevelBrief)
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ name = property(GetName, None, doc='''A read only property that returns the name for this enum member as a string.''')
+ type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the type (lldb.SBType) for this enum member.''')
+ signed = property(GetValueAsSigned, None, doc='''A read only property that returns the value of this enum member as a signed integer.''')
+ unsigned = property(GetValueAsUnsigned, None, doc='''A read only property that returns the value of this enum member as a unsigned integer.''')
+ %}
+#endif
+
+protected:
+ friend class SBType;
+ friend class SBTypeEnumMemberList;
+
+ void
+ reset (lldb_private::TypeEnumMemberImpl *);
+
+ lldb_private::TypeEnumMemberImpl &
+ ref ();
+
+ const lldb_private::TypeEnumMemberImpl &
+ ref () const;
+
+ lldb::TypeEnumMemberImplSP m_opaque_sp;
+
+ SBTypeEnumMember (const lldb::TypeEnumMemberImplSP &);
+};
+
+%feature(
+ "docstring",
+ "Represents a list of SBTypeEnumMembers."
+) SBTypeEnumMemberList;
+
+class SBTypeEnumMemberList
+{
+public:
+ SBTypeEnumMemberList();
+
+ SBTypeEnumMemberList(const SBTypeEnumMemberList& rhs);
+
+ ~SBTypeEnumMemberList();
+
+ bool
+ IsValid();
+
+ explicit operator bool() const;
+
+ void
+ Append (SBTypeEnumMember entry);
+
+ SBTypeEnumMember
+ GetTypeEnumMemberAtIndex (uint32_t index);
+
+ uint32_t
+ GetSize();
+
+
+private:
+ std::unique_ptr<lldb_private::TypeEnumMemberListImpl> m_opaque_ap;
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBTypeFilter.i b/lldb/bindings/interface/SBTypeFilter.i
new file mode 100644
index 000000000000..c1d282c6d4fb
--- /dev/null
+++ b/lldb/bindings/interface/SBTypeFilter.i
@@ -0,0 +1,75 @@
+//===-- SWIG Interface for SBTypeFilter----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+ %feature("docstring",
+ "Represents a filter that can be associated to one or more types.") SBTypeFilter;
+
+ class SBTypeFilter
+ {
+ public:
+
+ SBTypeFilter();
+
+ SBTypeFilter (uint32_t options);
+
+ SBTypeFilter (const lldb::SBTypeFilter &rhs);
+
+ ~SBTypeFilter ();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ bool
+ IsEqualTo (lldb::SBTypeFilter &rhs);
+
+ uint32_t
+ GetNumberOfExpressionPaths ();
+
+ const char*
+ GetExpressionPathAtIndex (uint32_t i);
+
+ bool
+ ReplaceExpressionPathAtIndex (uint32_t i, const char* item);
+
+ void
+ AppendExpressionPath (const char* item);
+
+ void
+ Clear();
+
+ uint32_t
+ GetOptions();
+
+ void
+ SetOptions (uint32_t);
+
+ bool
+ GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level);
+
+ bool
+ operator == (lldb::SBTypeFilter &rhs);
+
+ bool
+ operator != (lldb::SBTypeFilter &rhs);
+
+ STRING_EXTENSION_LEVEL(SBTypeFilter, lldb::eDescriptionLevelBrief)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ options = property(GetOptions, SetOptions)
+ count = property(GetNumberOfExpressionPaths)
+ %}
+#endif
+
+ };
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBTypeFormat.i b/lldb/bindings/interface/SBTypeFormat.i
new file mode 100644
index 000000000000..765a2a7bb99d
--- /dev/null
+++ b/lldb/bindings/interface/SBTypeFormat.i
@@ -0,0 +1,77 @@
+//===-- SWIG Interface for SBTypeFormat----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+ %feature("docstring",
+ "Represents a format that can be associated to one or more types.") SBTypeFormat;
+
+ class SBTypeFormat
+ {
+ public:
+
+ SBTypeFormat();
+
+ SBTypeFormat (lldb::Format format, uint32_t options = 0);
+
+ SBTypeFormat (const char* type, uint32_t options = 0);
+
+ SBTypeFormat (const lldb::SBTypeFormat &rhs);
+
+ ~SBTypeFormat ();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ bool
+ IsEqualTo (lldb::SBTypeFormat &rhs);
+
+ lldb::Format
+ GetFormat ();
+
+ const char*
+ GetTypeName ();
+
+ uint32_t
+ GetOptions();
+
+ void
+ SetFormat (lldb::Format);
+
+ void
+ SetTypeName (const char*);
+
+ void
+ SetOptions (uint32_t);
+
+ bool
+ GetDescription (lldb::SBStream &description,
+ lldb::DescriptionLevel description_level);
+
+ bool
+ operator == (lldb::SBTypeFormat &rhs);
+
+ bool
+ operator != (lldb::SBTypeFormat &rhs);
+
+ STRING_EXTENSION_LEVEL(SBTypeFormat, lldb::eDescriptionLevelBrief)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ format = property(GetFormat, SetFormat)
+ options = property(GetOptions, SetOptions)
+ %}
+#endif
+
+ };
+
+
+} // namespace lldb
+
diff --git a/lldb/bindings/interface/SBTypeNameSpecifier.i b/lldb/bindings/interface/SBTypeNameSpecifier.i
new file mode 100644
index 000000000000..772f7c174093
--- /dev/null
+++ b/lldb/bindings/interface/SBTypeNameSpecifier.i
@@ -0,0 +1,69 @@
+//===-- SWIG Interface for SBTypeNameSpecifier---------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+ %feature("docstring",
+ "Represents a general way to provide a type name to LLDB APIs.") SBTypeNameSpecifier;
+
+ class SBTypeNameSpecifier
+ {
+ public:
+
+ SBTypeNameSpecifier();
+
+ SBTypeNameSpecifier (const char* name,
+ bool is_regex = false);
+
+ SBTypeNameSpecifier (SBType type);
+
+ SBTypeNameSpecifier (const lldb::SBTypeNameSpecifier &rhs);
+
+ ~SBTypeNameSpecifier ();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ bool
+ IsEqualTo (lldb::SBTypeNameSpecifier &rhs);
+
+ const char*
+ GetName();
+
+ lldb::SBType
+ GetType ();
+
+ bool
+ IsRegex();
+
+ bool
+ GetDescription (lldb::SBStream &description,
+ lldb::DescriptionLevel description_level);
+
+ bool
+ operator == (lldb::SBTypeNameSpecifier &rhs);
+
+ bool
+ operator != (lldb::SBTypeNameSpecifier &rhs);
+
+ STRING_EXTENSION_LEVEL(SBTypeNameSpecifier, lldb::eDescriptionLevelBrief)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ name = property(GetName)
+ is_regex = property(IsRegex)
+ %}
+#endif
+
+
+ };
+
+} // namespace lldb
+
diff --git a/lldb/bindings/interface/SBTypeSummary.i b/lldb/bindings/interface/SBTypeSummary.i
new file mode 100644
index 000000000000..adcc79b5a6ee
--- /dev/null
+++ b/lldb/bindings/interface/SBTypeSummary.i
@@ -0,0 +1,119 @@
+//===-- SWIG Interface for SBTypeSummary---------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+ class SBTypeSummaryOptions
+ {
+ public:
+ SBTypeSummaryOptions();
+
+ SBTypeSummaryOptions (const lldb::SBTypeSummaryOptions &rhs);
+
+ ~SBTypeSummaryOptions ();
+
+ bool
+ IsValid ();
+
+ explicit operator bool() const;
+
+ lldb::LanguageType
+ GetLanguage ();
+
+ lldb::TypeSummaryCapping
+ GetCapping ();
+
+ void
+ SetLanguage (lldb::LanguageType);
+
+ void
+ SetCapping (lldb::TypeSummaryCapping);
+ };
+
+ %feature("docstring",
+ "Represents a summary that can be associated to one or more types.") SBTypeSummary;
+
+ class SBTypeSummary
+ {
+ public:
+
+ SBTypeSummary();
+
+ static SBTypeSummary
+ CreateWithSummaryString (const char* data, uint32_t options = 0);
+
+ static SBTypeSummary
+ CreateWithFunctionName (const char* data, uint32_t options = 0);
+
+ static SBTypeSummary
+ CreateWithScriptCode (const char* data, uint32_t options = 0);
+
+ SBTypeSummary (const lldb::SBTypeSummary &rhs);
+
+ ~SBTypeSummary ();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ bool
+ IsEqualTo (lldb::SBTypeSummary &rhs);
+
+ bool
+ IsFunctionCode();
+
+ bool
+ IsFunctionName();
+
+ bool
+ IsSummaryString();
+
+ const char*
+ GetData ();
+
+ void
+ SetSummaryString (const char* data);
+
+ void
+ SetFunctionName (const char* data);
+
+ void
+ SetFunctionCode (const char* data);
+
+ uint32_t
+ GetOptions ();
+
+ void
+ SetOptions (uint32_t);
+
+ bool
+ GetDescription (lldb::SBStream &description,
+ lldb::DescriptionLevel description_level);
+
+ bool
+ operator == (lldb::SBTypeSummary &rhs);
+
+ bool
+ operator != (lldb::SBTypeSummary &rhs);
+
+ STRING_EXTENSION_LEVEL(SBTypeSummary, lldb::eDescriptionLevelBrief)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ options = property(GetOptions, SetOptions)
+ is_summary_string = property(IsSummaryString)
+ is_function_name = property(IsFunctionName)
+ is_function_name = property(IsFunctionCode)
+ summary_data = property(GetData)
+ %}
+#endif
+
+ };
+
+} // namespace lldb
+
diff --git a/lldb/bindings/interface/SBTypeSynthetic.i b/lldb/bindings/interface/SBTypeSynthetic.i
new file mode 100644
index 000000000000..f57139ebf9f1
--- /dev/null
+++ b/lldb/bindings/interface/SBTypeSynthetic.i
@@ -0,0 +1,78 @@
+//===-- SWIG Interface for SBTypeSynthetic-------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+ %feature("docstring",
+ "Represents a summary that can be associated to one or more types.") SBTypeSynthetic;
+
+ class SBTypeSynthetic
+ {
+ public:
+
+ SBTypeSynthetic();
+
+ static lldb::SBTypeSynthetic
+ CreateWithClassName (const char* data, uint32_t options = 0);
+
+ static lldb::SBTypeSynthetic
+ CreateWithScriptCode (const char* data, uint32_t options = 0);
+
+ SBTypeSynthetic (const lldb::SBTypeSynthetic &rhs);
+
+ ~SBTypeSynthetic ();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ bool
+ IsEqualTo (lldb::SBTypeSynthetic &rhs);
+
+ bool
+ IsClassCode();
+
+ const char*
+ GetData ();
+
+ void
+ SetClassName (const char* data);
+
+ void
+ SetClassCode (const char* data);
+
+ uint32_t
+ GetOptions ();
+
+ void
+ SetOptions (uint32_t);
+
+ bool
+ GetDescription (lldb::SBStream &description,
+ lldb::DescriptionLevel description_level);
+
+ bool
+ operator == (lldb::SBTypeSynthetic &rhs);
+
+ bool
+ operator != (lldb::SBTypeSynthetic &rhs);
+
+ STRING_EXTENSION_LEVEL(SBTypeSynthetic, lldb::eDescriptionLevelBrief)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ options = property(GetOptions, SetOptions)
+ contains_code = property(IsClassCode, None)
+ synthetic_data = property(GetData, None)
+ %}
+#endif
+
+ };
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBUnixSignals.i b/lldb/bindings/interface/SBUnixSignals.i
new file mode 100644
index 000000000000..8fe3e2a3911f
--- /dev/null
+++ b/lldb/bindings/interface/SBUnixSignals.i
@@ -0,0 +1,76 @@
+//===-- SWIG Interface for SBUnixSignals ------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Allows you to manipulate LLDB's signal disposition"
+) SBUnixSignals;
+class SBUnixSignals
+{
+public:
+ SBUnixSignals ();
+
+ SBUnixSignals (const lldb::SBUnixSignals &rhs);
+
+ ~SBUnixSignals();
+
+ void
+ Clear ();
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+ const char *
+ GetSignalAsCString (int32_t signo) const;
+
+ int32_t
+ GetSignalNumberFromName (const char *name) const;
+
+ bool
+ GetShouldSuppress (int32_t signo) const;
+
+ bool
+ SetShouldSuppress (int32_t signo,
+ bool value);
+
+ bool
+ GetShouldStop (int32_t signo) const;
+
+ bool
+ SetShouldStop (int32_t signo,
+ bool value);
+
+ bool
+ GetShouldNotify (int32_t signo) const;
+
+ bool
+ SetShouldNotify (int32_t signo, bool value);
+
+ int32_t
+ GetNumSignals () const;
+
+ int32_t
+ GetSignalAtIndex (int32_t index) const;
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ def get_unix_signals_list(self):
+ signals = []
+ for idx in range(0, self.GetNumSignals()):
+ signals.append(self.GetSignalAtIndex(sig))
+ return signals
+
+ threads = property(get_unix_signals_list, None, doc='''A read only property that returns a list() of valid signal numbers for this platform.''')
+ %}
+#endif
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBValue.i b/lldb/bindings/interface/SBValue.i
new file mode 100644
index 000000000000..fb899805c395
--- /dev/null
+++ b/lldb/bindings/interface/SBValue.i
@@ -0,0 +1,598 @@
+//===-- SWIG Interface for SBValue ------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents the value of a variable, a register, or an expression.
+
+SBValue supports iteration through its child, which in turn is represented
+as an SBValue. For example, we can get the general purpose registers of a
+frame as an SBValue, and iterate through all the registers,
+
+ registerSet = frame.registers # Returns an SBValueList.
+ for regs in registerSet:
+ if 'general purpose registers' in regs.name.lower():
+ GPRs = regs
+ break
+
+ print('%s (number of children = %d):' % (GPRs.name, GPRs.num_children))
+ for reg in GPRs:
+ print('Name: ', reg.name, ' Value: ', reg.value)
+
+produces the output:
+
+General Purpose Registers (number of children = 21):
+Name: rax Value: 0x0000000100000c5c
+Name: rbx Value: 0x0000000000000000
+Name: rcx Value: 0x00007fff5fbffec0
+Name: rdx Value: 0x00007fff5fbffeb8
+Name: rdi Value: 0x0000000000000001
+Name: rsi Value: 0x00007fff5fbffea8
+Name: rbp Value: 0x00007fff5fbffe80
+Name: rsp Value: 0x00007fff5fbffe60
+Name: r8 Value: 0x0000000008668682
+Name: r9 Value: 0x0000000000000000
+Name: r10 Value: 0x0000000000001200
+Name: r11 Value: 0x0000000000000206
+Name: r12 Value: 0x0000000000000000
+Name: r13 Value: 0x0000000000000000
+Name: r14 Value: 0x0000000000000000
+Name: r15 Value: 0x0000000000000000
+Name: rip Value: 0x0000000100000dae
+Name: rflags Value: 0x0000000000000206
+Name: cs Value: 0x0000000000000027
+Name: fs Value: 0x0000000000000010
+Name: gs Value: 0x0000000000000048
+
+See also linked_list_iter() for another perspective on how to iterate through an
+SBValue instance which interprets the value object as representing the head of a
+linked list."
+) SBValue;
+class SBValue
+{
+public:
+ SBValue ();
+
+ SBValue (const SBValue &rhs);
+
+ ~SBValue ();
+
+ bool
+ IsValid();
+
+ explicit operator bool() const;
+
+ void
+ Clear();
+
+ SBError
+ GetError();
+
+ lldb::user_id_t
+ GetID ();
+
+ const char *
+ GetName();
+
+ const char *
+ GetTypeName ();
+
+ const char *
+ GetDisplayTypeName ();
+
+ size_t
+ GetByteSize ();
+
+ bool
+ IsInScope ();
+
+ lldb::Format
+ GetFormat ();
+
+ void
+ SetFormat (lldb::Format format);
+
+ const char *
+ GetValue ();
+
+ int64_t
+ GetValueAsSigned(SBError& error, int64_t fail_value=0);
+
+ uint64_t
+ GetValueAsUnsigned(SBError& error, uint64_t fail_value=0);
+
+ int64_t
+ GetValueAsSigned(int64_t fail_value=0);
+
+ uint64_t
+ GetValueAsUnsigned(uint64_t fail_value=0);
+
+ ValueType
+ GetValueType ();
+
+ bool
+ GetValueDidChange ();
+
+ const char *
+ GetSummary ();
+
+ const char *
+ GetSummary (lldb::SBStream& stream,
+ lldb::SBTypeSummaryOptions& options);
+
+ const char *
+ GetObjectDescription ();
+
+ lldb::SBValue
+ GetDynamicValue (lldb::DynamicValueType use_dynamic);
+
+ lldb::SBValue
+ GetStaticValue ();
+
+ lldb::SBValue
+ GetNonSyntheticValue ();
+
+ lldb::DynamicValueType
+ GetPreferDynamicValue ();
+
+ void
+ SetPreferDynamicValue (lldb::DynamicValueType use_dynamic);
+
+ bool
+ GetPreferSyntheticValue ();
+
+ void
+ SetPreferSyntheticValue (bool use_synthetic);
+
+ bool
+ IsDynamic();
+
+ bool
+ IsSynthetic ();
+
+ bool
+ IsSyntheticChildrenGenerated ();
+
+ void
+ SetSyntheticChildrenGenerated (bool);
+
+ const char *
+ GetLocation ();
+
+ bool
+ SetValueFromCString (const char *value_str);
+
+ bool
+ SetValueFromCString (const char *value_str, lldb::SBError& error);
+
+ lldb::SBTypeFormat
+ GetTypeFormat ();
+
+ lldb::SBTypeSummary
+ GetTypeSummary ();
+
+ lldb::SBTypeFilter
+ GetTypeFilter ();
+
+ lldb::SBTypeSynthetic
+ GetTypeSynthetic ();
+
+ lldb::SBValue
+ GetChildAtIndex (uint32_t idx);
+
+ %feature("docstring", "
+ Get a child value by index from a value.
+
+ Structs, unions, classes, arrays and pointers have child
+ values that can be access by index.
+
+ Structs and unions access child members using a zero based index
+ for each child member. For
+
+ Classes reserve the first indexes for base classes that have
+ members (empty base classes are omitted), and all members of the
+ current class will then follow the base classes.
+
+ Pointers differ depending on what they point to. If the pointer
+ points to a simple type, the child at index zero
+ is the only child value available, unless synthetic_allowed
+ is true, in which case the pointer will be used as an array
+ and can create 'synthetic' child values using positive or
+ negative indexes. If the pointer points to an aggregate type
+ (an array, class, union, struct), then the pointee is
+ transparently skipped and any children are going to be the indexes
+ of the child values within the aggregate type. For example if
+ we have a 'Point' type and we have a SBValue that contains a
+ pointer to a 'Point' type, then the child at index zero will be
+ the 'x' member, and the child at index 1 will be the 'y' member
+ (the child at index zero won't be a 'Point' instance).
+
+ If you actually need an SBValue that represents the type pointed
+ to by a SBValue for which GetType().IsPointeeType() returns true,
+ regardless of the pointee type, you can do that with the SBValue.Dereference
+ method (or the equivalent deref property).
+
+ 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 synthetic_allowed is true. In this
+ case the array can create 'synthetic' child values for indexes
+ that aren't in the array bounds using positive or negative
+ indexes.
+
+ @param[in] idx
+ The index of the child value to get
+
+ @param[in] use_dynamic
+ An enumeration that specifies whether to get dynamic values,
+ and also if the target can be run to figure out the dynamic
+ type of the child value.
+
+ @param[in] synthetic_allowed
+ If true, then allow child values to be created by index
+ for pointers and arrays for indexes that normally wouldn't
+ be allowed.
+
+ @return
+ A new SBValue object that represents the child member value.") GetChildAtIndex;
+ lldb::SBValue
+ GetChildAtIndex (uint32_t idx,
+ lldb::DynamicValueType use_dynamic,
+ bool can_create_synthetic);
+
+ lldb::SBValue
+ CreateChildAtOffset (const char *name, uint32_t offset, lldb::SBType type);
+
+ lldb::SBValue
+ SBValue::Cast (lldb::SBType type);
+
+ lldb::SBValue
+ CreateValueFromExpression (const char *name, const char* expression);
+
+ lldb::SBValue
+ CreateValueFromExpression (const char *name, const char* expression, SBExpressionOptions &options);
+
+ lldb::SBValue
+ CreateValueFromAddress(const char* name, lldb::addr_t address, lldb::SBType type);
+
+ lldb::SBValue
+ CreateValueFromData (const char* name,
+ lldb::SBData data,
+ lldb::SBType type);
+
+ lldb::SBType
+ GetType();
+
+ %feature("docstring", "
+ Returns the child member index.
+
+ Matches children of this object only and will match base classes and
+ member names if this is a clang typed object.
+
+ @param[in] name
+ The name of the child value to get
+
+ @return
+ An index to the child member value.") GetIndexOfChildWithName;
+ uint32_t
+ GetIndexOfChildWithName (const char *name);
+
+ lldb::SBValue
+ GetChildMemberWithName (const char *name);
+
+ %feature("docstring", "
+ Returns the child member value.
+
+ Matches child members of this object and child members of any base
+ classes.
+
+ @param[in] name
+ The name of the child value to get
+
+ @param[in] use_dynamic
+ An enumeration that specifies whether to get dynamic values,
+ and also if the target can be run to figure out the dynamic
+ type of the child value.
+
+ @return
+ A new SBValue object that represents the child member value.") GetChildMemberWithName;
+ lldb::SBValue
+ GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic);
+
+ %feature("docstring", "Expands nested expressions like .a->b[0].c[1]->d."
+ ) GetValueForExpressionPath;
+ lldb::SBValue
+ GetValueForExpressionPath(const char* expr_path);
+
+ lldb::SBDeclaration
+ GetDeclaration ();
+
+ bool
+ MightHaveChildren ();
+
+ bool
+ IsRuntimeSupportValue ();
+
+ uint32_t
+ GetNumChildren ();
+
+ %feature("doctstring", "
+ Returns the number for children.
+
+ @param[in] max
+ If max is less the lldb.UINT32_MAX, then the returned value is
+ capped to max.
+
+ @return
+ An integer value capped to the argument max.") GetNumChildren;
+ uint32_t
+ GetNumChildren (uint32_t max);
+
+ void *
+ GetOpaqueType();
+
+ lldb::SBValue
+ Dereference ();
+
+ lldb::SBValue
+ AddressOf();
+
+ bool
+ TypeIsPointerType ();
+
+ lldb::SBTarget
+ GetTarget();
+
+ lldb::SBProcess
+ GetProcess();
+
+ lldb::SBThread
+ GetThread();
+
+ lldb::SBFrame
+ GetFrame();
+
+ %feature("docstring", "
+ Find and watch a variable.
+ It returns an SBWatchpoint, which may be invalid.") Watch;
+ lldb::SBWatchpoint
+ Watch (bool resolve_location, bool read, bool write, SBError &error);
+
+ %feature("docstring", "
+ Find and watch the location pointed to by a variable.
+ It returns an SBWatchpoint, which may be invalid.") WatchPointee;
+ lldb::SBWatchpoint
+ WatchPointee (bool resolve_location, bool read, bool write, SBError &error);
+
+ bool
+ GetDescription (lldb::SBStream &description);
+
+ bool
+ GetExpressionPath (lldb::SBStream &description);
+
+ %feature("docstring", "
+ Get an SBData wrapping what this SBValue points to.
+
+ This method will dereference the current SBValue, if its
+ data type is a T* or T[], and extract item_count elements
+ of type T from it, copying their contents in an SBData.
+
+ @param[in] item_idx
+ The index of the first item to retrieve. For an array
+ this is equivalent to array[item_idx], for a pointer
+ to *(pointer + item_idx). In either case, the measurement
+ unit for item_idx is the sizeof(T) rather than the byte
+
+ @param[in] item_count
+ How many items should be copied into the output. By default
+ only one item is copied, but more can be asked for.
+
+ @return
+ An SBData with the contents of the copied items, on success.
+ An empty SBData otherwise.") GetPointeeData;
+ lldb::SBData
+ GetPointeeData (uint32_t item_idx = 0,
+ uint32_t item_count = 1);
+
+ %feature("docstring", "
+ Get an SBData wrapping the contents of this SBValue.
+
+ This method will read the contents of this object in memory
+ and copy them into an SBData for future use.
+
+ @return
+ An SBData with the contents of this SBValue, on success.
+ An empty SBData otherwise.") GetData;
+ lldb::SBData
+ GetData ();
+
+ bool
+ SetData (lldb::SBData &data, lldb::SBError& error);
+
+ lldb::addr_t
+ GetLoadAddress();
+
+ lldb::SBAddress
+ GetAddress();
+
+ lldb::SBValue
+ Persist ();
+
+ %feature("docstring", "Returns an expression path for this value."
+ ) GetExpressionPath;
+ bool
+ GetExpressionPath (lldb::SBStream &description, bool qualify_cxx_base_classes);
+
+ lldb::SBValue
+ EvaluateExpression(const char *expr) const;
+
+ lldb::SBValue
+ EvaluateExpression(const char *expr,
+ const SBExpressionOptions &options) const;
+
+ lldb::SBValue
+ EvaluateExpression(const char *expr,
+ const SBExpressionOptions &options,
+ const char *name) const;
+
+ STRING_EXTENSION(SBValue)
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ def __get_dynamic__ (self):
+ '''Helper function for the "SBValue.dynamic" property.'''
+ return self.GetDynamicValue (eDynamicCanRunTarget)
+
+ class children_access(object):
+ '''A helper object that will lazily hand out thread for a process when supplied an index.'''
+
+ def __init__(self, sbvalue):
+ self.sbvalue = sbvalue
+
+ def __len__(self):
+ if self.sbvalue:
+ return int(self.sbvalue.GetNumChildren())
+ return 0
+
+ def __getitem__(self, key):
+ if type(key) is int and key < len(self):
+ return self.sbvalue.GetChildAtIndex(key)
+ return None
+
+ def get_child_access_object(self):
+ '''An accessor function that returns a children_access() object which allows lazy member variable access from a lldb.SBValue object.'''
+ return self.children_access (self)
+
+ def get_value_child_list(self):
+ '''An accessor function that returns a list() that contains all children in a lldb.SBValue object.'''
+ children = []
+ accessor = self.get_child_access_object()
+ for idx in range(len(accessor)):
+ children.append(accessor[idx])
+ return children
+
+ def __iter__(self):
+ '''Iterate over all child values of a lldb.SBValue object.'''
+ return lldb_iter(self, 'GetNumChildren', 'GetChildAtIndex')
+
+ def __len__(self):
+ '''Return the number of child values of a lldb.SBValue object.'''
+ return self.GetNumChildren()
+
+ children = property(get_value_child_list, None, doc='''A read only property that returns a list() of lldb.SBValue objects for the children of the value.''')
+ child = property(get_child_access_object, None, doc='''A read only property that returns an object that can access children of a variable by index (child_value = value.children[12]).''')
+ name = property(GetName, None, doc='''A read only property that returns the name of this value as a string.''')
+ type = property(GetType, None, doc='''A read only property that returns a lldb.SBType object that represents the type for this value.''')
+ size = property(GetByteSize, None, doc='''A read only property that returns the size in bytes of this value.''')
+ is_in_scope = property(IsInScope, None, doc='''A read only property that returns a boolean value that indicates whether this value is currently lexically in scope.''')
+ format = property(GetName, SetFormat, doc='''A read/write property that gets/sets the format used for lldb.SBValue().GetValue() for this value. See enumerations that start with "lldb.eFormat".''')
+ value = property(GetValue, SetValueFromCString, doc='''A read/write property that gets/sets value from a string.''')
+ value_type = property(GetValueType, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eValueType") that represents the type of this value (local, argument, global, register, etc.).''')
+ changed = property(GetValueDidChange, None, doc='''A read only property that returns a boolean value that indicates if this value has changed since it was last updated.''')
+ data = property(GetData, None, doc='''A read only property that returns an lldb object (lldb.SBData) that represents the bytes that make up the value for this object.''')
+ load_addr = property(GetLoadAddress, None, doc='''A read only property that returns the load address of this value as an integer.''')
+ addr = property(GetAddress, None, doc='''A read only property that returns an lldb.SBAddress that represents the address of this value if it is in memory.''')
+ deref = property(Dereference, None, doc='''A read only property that returns an lldb.SBValue that is created by dereferencing this value.''')
+ address_of = property(AddressOf, None, doc='''A read only property that returns an lldb.SBValue that represents the address-of this value.''')
+ error = property(GetError, None, doc='''A read only property that returns the lldb.SBError that represents the error from the last time the variable value was calculated.''')
+ summary = property(GetSummary, None, doc='''A read only property that returns the summary for this value as a string''')
+ description = property(GetObjectDescription, None, doc='''A read only property that returns the language-specific description of this value as a string''')
+ dynamic = property(__get_dynamic__, None, doc='''A read only property that returns an lldb.SBValue that is created by finding the dynamic type of this value.''')
+ location = property(GetLocation, None, doc='''A read only property that returns the location of this value as a string.''')
+ target = property(GetTarget, None, doc='''A read only property that returns the lldb.SBTarget that this value is associated with.''')
+ process = property(GetProcess, None, doc='''A read only property that returns the lldb.SBProcess that this value is associated with, the returned value might be invalid and should be tested.''')
+ thread = property(GetThread, None, doc='''A read only property that returns the lldb.SBThread that this value is associated with, the returned value might be invalid and should be tested.''')
+ frame = property(GetFrame, None, doc='''A read only property that returns the lldb.SBFrame that this value is associated with, the returned value might be invalid and should be tested.''')
+ num_children = property(GetNumChildren, None, doc='''A read only property that returns the number of child lldb.SBValues that this value has.''')
+ unsigned = property(GetValueAsUnsigned, None, doc='''A read only property that returns the value of this SBValue as an usigned integer.''')
+ signed = property(GetValueAsSigned, None, doc='''A read only property that returns the value of this SBValue as a signed integer.''')
+
+ def get_expr_path(self):
+ s = SBStream()
+ self.GetExpressionPath (s)
+ return s.GetData()
+
+ path = property(get_expr_path, None, doc='''A read only property that returns the expression path that one can use to reach this value in an expression.''')
+
+ def synthetic_child_from_expression(self, name, expr, options=None):
+ if options is None: options = lldb.SBExpressionOptions()
+ child = self.CreateValueFromExpression(name, expr, options)
+ child.SetSyntheticChildrenGenerated(True)
+ return child
+
+ def synthetic_child_from_data(self, name, data, type):
+ child = self.CreateValueFromData(name, data, type)
+ child.SetSyntheticChildrenGenerated(True)
+ return child
+
+ def synthetic_child_from_address(self, name, addr, type):
+ child = self.CreateValueFromAddress(name, addr, type)
+ child.SetSyntheticChildrenGenerated(True)
+ return child
+
+ def __eol_test(val):
+ """Default function for end of list test takes an SBValue object.
+
+ Return True if val is invalid or it corresponds to a null pointer.
+ Otherwise, return False.
+ """
+ if not val or val.GetValueAsUnsigned() == 0:
+ return True
+ else:
+ return False
+
+ # ==================================================
+ # Iterator for lldb.SBValue treated as a linked list
+ # ==================================================
+ def linked_list_iter(self, next_item_name, end_of_list_test=__eol_test):
+ """Generator adaptor to support iteration for SBValue as a linked list.
+
+ linked_list_iter() is a special purpose iterator to treat the SBValue as
+ the head of a list data structure, where you specify the child member
+ name which points to the next item on the list and you specify the
+ end-of-list test function which takes an SBValue for an item and returns
+ True if EOL is reached and False if not.
+
+ linked_list_iter() also detects infinite loop and bails out early.
+
+ The end_of_list_test arg, if omitted, defaults to the __eol_test
+ function above.
+
+ For example,
+
+ # Get Frame #0.
+ ...
+
+ # Get variable 'task_head'.
+ task_head = frame0.FindVariable('task_head')
+ ...
+
+ for t in task_head.linked_list_iter('next'):
+ print t
+ """
+ if end_of_list_test(self):
+ return
+ item = self
+ visited = set()
+ try:
+ while not end_of_list_test(item) and not item.GetValueAsUnsigned() in visited:
+ visited.add(item.GetValueAsUnsigned())
+ yield item
+ # Prepare for the next iteration.
+ item = item.GetChildMemberWithName(next_item_name)
+ except:
+ # Exception occurred. Stop the generator.
+ pass
+
+ return
+ %}
+#endif
+
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBValueList.i b/lldb/bindings/interface/SBValueList.i
new file mode 100644
index 000000000000..17ba2056f0c2
--- /dev/null
+++ b/lldb/bindings/interface/SBValueList.i
@@ -0,0 +1,172 @@
+//===-- SWIG Interface for SBValueList --------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents a collection of SBValues. Both SBFrame's GetVariables() and
+GetRegisters() return a SBValueList.
+
+SBValueList supports SBValue iteration. For example (from test/lldbutil.py),
+
+def get_registers(frame, kind):
+ '''Returns the registers given the frame and the kind of registers desired.
+
+ Returns None if there's no such kind.
+ '''
+ registerSet = frame.GetRegisters() # Return type of SBValueList.
+ for value in registerSet:
+ if kind.lower() in value.GetName().lower():
+ return value
+
+ return None
+
+def get_GPRs(frame):
+ '''Returns the general purpose registers of the frame as an SBValue.
+
+ The returned SBValue object is iterable. An example:
+ ...
+ from lldbutil import get_GPRs
+ regs = get_GPRs(frame)
+ for reg in regs:
+ print('%s => %s' % (reg.GetName(), reg.GetValue()))
+ ...
+ '''
+ return get_registers(frame, 'general purpose')
+
+def get_FPRs(frame):
+ '''Returns the floating point registers of the frame as an SBValue.
+
+ The returned SBValue object is iterable. An example:
+ ...
+ from lldbutil import get_FPRs
+ regs = get_FPRs(frame)
+ for reg in regs:
+ print('%s => %s' % (reg.GetName(), reg.GetValue()))
+ ...
+ '''
+ return get_registers(frame, 'floating point')
+
+def get_ESRs(frame):
+ '''Returns the exception state registers of the frame as an SBValue.
+
+ The returned SBValue object is iterable. An example:
+ ...
+ from lldbutil import get_ESRs
+ regs = get_ESRs(frame)
+ for reg in regs:
+ print('%s => %s' % (reg.GetName(), reg.GetValue()))
+ ...
+ '''
+ return get_registers(frame, 'exception state')"
+) SBValueList;
+class SBValueList
+{
+public:
+
+ SBValueList ();
+
+ SBValueList (const lldb::SBValueList &rhs);
+
+ ~SBValueList();
+
+ bool
+ IsValid() const;
+
+ explicit operator bool() const;
+
+ void
+ Clear();
+
+ void
+ Append (const lldb::SBValue &val_obj);
+
+ void
+ Append (const lldb::SBValueList& value_list);
+
+ uint32_t
+ GetSize() const;
+
+ lldb::SBValue
+ GetValueAtIndex (uint32_t idx) const;
+
+ lldb::SBValue
+ FindValueObjectByUID (lldb::user_id_t uid);
+
+ lldb::SBValue
+ GetFirstValueByName (const char* name) const;
+
+ %extend {
+ %nothreadallow;
+ std::string lldb::SBValueList::__str__ (){
+ lldb::SBStream description;
+ const size_t n = $self->GetSize();
+ if (n)
+ {
+ for (size_t i=0; i<n; ++i)
+ $self->GetValueAtIndex(i).GetDescription(description);
+ }
+ else
+ {
+ description.Printf("<empty> lldb.SBValueList()");
+ }
+ const char *desc = description.GetData();
+ size_t desc_len = description.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r'))
+ --desc_len;
+ return std::string(desc, desc_len);
+ }
+ %clearnothreadallow;
+ }
+
+#ifdef SWIGPYTHON
+ %pythoncode %{
+ def __iter__(self):
+ '''Iterate over all values in a lldb.SBValueList object.'''
+ return lldb_iter(self, 'GetSize', 'GetValueAtIndex')
+
+ def __len__(self):
+ return int(self.GetSize())
+
+ def __getitem__(self, key):
+ count = len(self)
+ #------------------------------------------------------------
+ # Access with "int" to get Nth item in the list
+ #------------------------------------------------------------
+ if type(key) is int:
+ if key < count:
+ return self.GetValueAtIndex(key)
+ #------------------------------------------------------------
+ # Access with "str" to get values by name
+ #------------------------------------------------------------
+ elif type(key) is str:
+ matches = []
+ for idx in range(count):
+ value = self.GetValueAtIndex(idx)
+ if value.name == key:
+ matches.append(value)
+ return matches
+ #------------------------------------------------------------
+ # Match with regex
+ #------------------------------------------------------------
+ elif isinstance(key, type(re.compile('.'))):
+ matches = []
+ for idx in range(count):
+ value = self.GetValueAtIndex(idx)
+ re_match = key.search(value.name)
+ if re_match:
+ matches.append(value)
+ return matches
+
+ %}
+#endif
+
+
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBVariablesOptions.i b/lldb/bindings/interface/SBVariablesOptions.i
new file mode 100644
index 000000000000..362f7159d7d2
--- /dev/null
+++ b/lldb/bindings/interface/SBVariablesOptions.i
@@ -0,0 +1,68 @@
+//===-- SWIG Interface for SBVariablesOptions ----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+class SBVariablesOptions
+{
+public:
+ SBVariablesOptions ();
+
+ SBVariablesOptions (const SBVariablesOptions& options);
+
+ ~SBVariablesOptions ();
+
+ bool
+ IsValid () const;
+
+ explicit operator bool() const;
+
+ bool
+ GetIncludeArguments () const;
+
+ void
+ SetIncludeArguments (bool);
+
+ bool
+ GetIncludeRecognizedArguments (const lldb::SBTarget &) const;
+
+ void
+ SetIncludeRecognizedArguments (bool);
+
+ bool
+ GetIncludeLocals () const;
+
+ void
+ SetIncludeLocals (bool);
+
+ bool
+ GetIncludeStatics () const;
+
+ void
+ SetIncludeStatics (bool);
+
+ bool
+ GetInScopeOnly () const;
+
+ void
+ SetInScopeOnly (bool);
+
+ bool
+ GetIncludeRuntimeSupportValues () const;
+
+ void
+ SetIncludeRuntimeSupportValues (bool);
+
+ lldb::DynamicValueType
+ GetUseDynamic () const;
+
+ void
+ SetUseDynamic (lldb::DynamicValueType);
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interface/SBWatchpoint.i b/lldb/bindings/interface/SBWatchpoint.i
new file mode 100644
index 000000000000..cb0bc5f9859a
--- /dev/null
+++ b/lldb/bindings/interface/SBWatchpoint.i
@@ -0,0 +1,96 @@
+//===-- SWIG Interface for SBWatchpoint -----------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+namespace lldb {
+
+%feature("docstring",
+"Represents an instance of watchpoint for a specific target program.
+
+A watchpoint is determined by the address and the byte size that resulted in
+this particular instantiation. Each watchpoint has its settable options.
+
+See also SBTarget.watchpoint_iter() for example usage of iterating through the
+watchpoints of the target."
+) SBWatchpoint;
+class SBWatchpoint
+{
+public:
+
+ SBWatchpoint ();
+
+ SBWatchpoint (const lldb::SBWatchpoint &rhs);
+
+ ~SBWatchpoint ();
+
+ bool
+ IsValid();
+
+ explicit operator bool() const;
+
+ bool operator==(const SBWatchpoint &rhs) const;
+
+ bool operator!=(const SBWatchpoint &rhs) const;
+
+ SBError
+ GetError();
+
+ watch_id_t
+ GetID ();
+
+ %feature("docstring", "
+ With -1 representing an invalid hardware index.") GetHardwareIndex;
+ int32_t
+ GetHardwareIndex ();
+
+ lldb::addr_t
+ GetWatchAddress ();
+
+ size_t
+ GetWatchSize();
+
+ void
+ SetEnabled(bool enabled);
+
+ bool
+ IsEnabled ();
+
+ uint32_t
+ GetHitCount ();
+
+ uint32_t
+ GetIgnoreCount ();
+
+ void
+ SetIgnoreCount (uint32_t n);
+
+ %feature("docstring", "
+ Get the condition expression for the watchpoint.") GetCondition;
+ const char *
+ GetCondition ();
+
+ %feature("docstring", "
+ The watchpoint stops only if the condition expression evaluates to true.") SetCondition;
+ void
+ SetCondition (const char *condition);
+
+ bool
+ GetDescription (lldb::SBStream &description, DescriptionLevel level);
+
+ static bool
+ EventIsWatchpointEvent (const lldb::SBEvent &event);
+
+ static lldb::WatchpointEventType
+ GetWatchpointEventTypeFromEvent (const lldb::SBEvent& event);
+
+ static lldb::SBWatchpoint
+ GetWatchpointFromEvent (const lldb::SBEvent& event);
+
+ STRING_EXTENSION_LEVEL(SBWatchpoint, lldb::eDescriptionLevelVerbose)
+};
+
+} // namespace lldb
diff --git a/lldb/bindings/interfaces.swig b/lldb/bindings/interfaces.swig
new file mode 100644
index 000000000000..2df7a05b4f48
--- /dev/null
+++ b/lldb/bindings/interfaces.swig
@@ -0,0 +1,85 @@
+/* Various liblldb typedefs that SWIG needs to know about. */
+#define __extension__ /* Undefine GCC keyword to make Swig happy when processing glibc's stdint.h. */
+/* The ISO C99 standard specifies that in C++ implementations limit macros such
+ as INT32_MAX should only be defined if __STDC_LIMIT_MACROS is. */
+#define __STDC_LIMIT_MACROS
+%include "stdint.i"
+
+%include "lldb/lldb-defines.h"
+%include "lldb/lldb-enumerations.h"
+%include "lldb/lldb-forward.h"
+%include "lldb/lldb-types.h"
+
+/* Forward declaration of SB classes. */
+%include "lldb/API/SBDefines.h"
+
+/* Python interface files with docstrings. */
+%include "./interface/SBAddress.i"
+%include "./interface/SBAttachInfo.i"
+%include "./interface/SBBlock.i"
+%include "./interface/SBBreakpoint.i"
+%include "./interface/SBBreakpointLocation.i"
+%include "./interface/SBBreakpointName.i"
+%include "./interface/SBBroadcaster.i"
+%include "./interface/SBCommandInterpreter.i"
+%include "./interface/SBCommandInterpreterRunOptions.i"
+%include "./interface/SBCommandReturnObject.i"
+%include "./interface/SBCommunication.i"
+%include "./interface/SBCompileUnit.i"
+%include "./interface/SBData.i"
+%include "./interface/SBDebugger.i"
+%include "./interface/SBDeclaration.i"
+%include "./interface/SBError.i"
+%include "./interface/SBEnvironment.i"
+%include "./interface/SBEvent.i"
+%include "./interface/SBExecutionContext.i"
+%include "./interface/SBExpressionOptions.i"
+%include "./interface/SBFile.i"
+%include "./interface/SBFileSpec.i"
+%include "./interface/SBFileSpecList.i"
+%include "./interface/SBFrame.i"
+%include "./interface/SBFunction.i"
+%include "./interface/SBHostOS.i"
+%include "./interface/SBInstruction.i"
+%include "./interface/SBInstructionList.i"
+%include "./interface/SBLanguageRuntime.i"
+%include "./interface/SBLaunchInfo.i"
+%include "./interface/SBLineEntry.i"
+%include "./interface/SBListener.i"
+%include "./interface/SBMemoryRegionInfo.i"
+%include "./interface/SBMemoryRegionInfoList.i"
+%include "./interface/SBModule.i"
+%include "./interface/SBModuleSpec.i"
+%include "./interface/SBPlatform.i"
+%include "./interface/SBProcess.i"
+%include "./interface/SBProcessInfo.i"
+%include "./interface/SBQueue.i"
+%include "./interface/SBQueueItem.i"
+%include "./interface/SBReproducer.i"
+%include "./interface/SBSection.i"
+%include "./interface/SBSourceManager.i"
+%include "./interface/SBStream.i"
+%include "./interface/SBStringList.i"
+%include "./interface/SBStructuredData.i"
+%include "./interface/SBSymbol.i"
+%include "./interface/SBSymbolContext.i"
+%include "./interface/SBSymbolContextList.i"
+%include "./interface/SBTarget.i"
+%include "./interface/SBThread.i"
+%include "./interface/SBThreadCollection.i"
+%include "./interface/SBThreadPlan.i"
+%include "./interface/SBTrace.i"
+%include "./interface/SBTraceOptions.i"
+%include "./interface/SBType.i"
+%include "./interface/SBTypeCategory.i"
+%include "./interface/SBTypeEnumMember.i"
+%include "./interface/SBTypeFilter.i"
+%include "./interface/SBTypeFormat.i"
+%include "./interface/SBTypeNameSpecifier.i"
+%include "./interface/SBTypeSummary.i"
+%include "./interface/SBTypeSynthetic.i"
+%include "./interface/SBUnixSignals.i"
+%include "./interface/SBValue.i"
+%include "./interface/SBValueList.i"
+%include "./interface/SBVariablesOptions.i"
+%include "./interface/SBWatchpoint.i"
diff --git a/lldb/bindings/lua.swig b/lldb/bindings/lua.swig
new file mode 100644
index 000000000000..9bfc49b359bc
--- /dev/null
+++ b/lldb/bindings/lua.swig
@@ -0,0 +1,21 @@
+/*
+ lldb.swig
+
+ This is the input file for SWIG, to create the appropriate C++ wrappers and
+ functions for various scripting languages, to enable them to call the
+ liblldb Script Bridge functions.
+*/
+
+%module lldb
+
+%include <std_string.i>
+%include "./lua/lua-typemaps.swig"
+%include "./macros.swig"
+%include "./headers.swig"
+
+%{
+using namespace lldb_private;
+using namespace lldb;
+%}
+
+%include "./interfaces.swig"
diff --git a/lldb/bindings/lua/lua-typemaps.swig b/lldb/bindings/lua/lua-typemaps.swig
new file mode 100644
index 000000000000..28d63fa2f402
--- /dev/null
+++ b/lldb/bindings/lua/lua-typemaps.swig
@@ -0,0 +1 @@
+%include <typemaps.i>
diff --git a/lldb/bindings/macros.swig b/lldb/bindings/macros.swig
new file mode 100644
index 000000000000..0387f27f3cb9
--- /dev/null
+++ b/lldb/bindings/macros.swig
@@ -0,0 +1,33 @@
+%define STRING_EXTENSION_LEVEL(Class, Level)
+%extend {
+ %nothreadallow;
+ std::string lldb:: ## Class ## ::__str__(){
+ lldb::SBStream stream;
+ $self->GetDescription (stream, Level);
+ const char *desc = stream.GetData();
+ size_t desc_len = stream.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) {
+ --desc_len;
+ }
+ return std::string(desc, desc_len);
+ }
+ %clearnothreadallow;
+}
+%enddef
+
+%define STRING_EXTENSION(Class)
+%extend {
+ %nothreadallow;
+ std::string lldb:: ## Class ## ::__str__(){
+ lldb::SBStream stream;
+ $self->GetDescription (stream);
+ const char *desc = stream.GetData();
+ size_t desc_len = stream.GetSize();
+ if (desc_len > 0 && (desc[desc_len-1] == '\n' || desc[desc_len-1] == '\r')) {
+ --desc_len;
+ }
+ return std::string(desc, desc_len);
+ }
+ %clearnothreadallow;
+}
+%enddef
diff --git a/lldb/bindings/python.swig b/lldb/bindings/python.swig
new file mode 100644
index 000000000000..5b1269878dac
--- /dev/null
+++ b/lldb/bindings/python.swig
@@ -0,0 +1,145 @@
+/*
+ lldb.swig
+
+ This is the input file for SWIG, to create the appropriate C++ wrappers and
+ functions for various scripting languages, to enable them to call the
+ liblldb Script Bridge functions.
+*/
+
+/* Define our module docstring. */
+%define DOCSTRING
+"The lldb module contains the public APIs for Python binding.
+
+Some of the important classes are described here:
+
+o SBTarget: Represents the target program running under the debugger.
+o SBProcess: Represents the process associated with the target program.
+o SBThread: Represents a thread of execution. SBProcess contains SBThread(s).
+o SBFrame: Represents one of the stack frames associated with a thread. SBThread
+ contains SBFrame(s).
+o SBSymbolContext: A container that stores various debugger related info.
+o SBValue: Represents the value of a variable, a register, or an expression.
+o SBModule: Represents an executable image and its associated object and symbol
+ files. SBTarget contains SBModule(s).
+o SBBreakpoint: Represents a logical breakpoint and its associated settings.
+ SBTarget contains SBBreakpoint(s).
+o SBSymbol: Represents the symbol possibly associated with a stack frame.
+o SBCompileUnit: Represents a compilation unit, or compiled source file.
+o SBFunction: Represents a generic function, which can be inlined or not.
+o SBBlock: Represents a lexical block. SBFunction contains SBBlock(s).
+o SBLineEntry: Specifies an association with a contiguous range of instructions
+ and a source file location. SBCompileUnit contains SBLineEntry(s)."
+%enddef
+
+/*
+Since version 3.0.9, swig's logic for importing the native module has changed in
+a way that is incompatible with our usage of the python module as __init__.py
+(See swig bug #769). Fortunately, since version 3.0.11, swig provides a way for
+us to override the module import logic to suit our needs. This does that.
+
+Older swig versions will simply ignore this setting.
+*/
+%define MODULEIMPORT
+"try:
+ # Try an absolute import first. If we're being loaded from lldb,
+ # _lldb should be a built-in module.
+ import $module
+except ImportError:
+ # Relative import should work if we are being loaded by Python.
+ from . import $module"
+%enddef
+// These versions will not generate working python modules, so error out early.
+#if SWIG_VERSION >= 0x030009 && SWIG_VERSION < 0x030011
+#error Swig versions 3.0.9 and 3.0.10 are incompatible with lldb.
+#endif
+
+// The name of the module to be created.
+%module(docstring=DOCSTRING, moduleimport=MODULEIMPORT) lldb
+
+// Parameter types will be used in the autodoc string.
+%feature("autodoc", "1");
+
+%define ARRAYHELPER(type,name)
+%inline %{
+type *new_ ## name (int nitems) {
+ return (type *) malloc(sizeof(type)*nitems);
+}
+void delete_ ## name(type *t) {
+ free(t);
+}
+type name ## _get(type *t, int index) {
+ return t[index];
+}
+void name ## _set(type *t, int index, type val) {
+ t[index] = val;
+}
+%}
+%enddef
+
+%pythoncode%{
+import uuid
+import re
+import os
+
+import six
+%}
+
+// Include the version of swig that was used to generate this interface.
+%define EMBED_VERSION(VERSION)
+%pythoncode%{
+# SWIG_VERSION is written as a single hex number, but the components of it are
+# meant to be interpreted in decimal. So, 0x030012 is swig 3.0.12, and not
+# 3.0.18.
+def _to_int(hex):
+ return hex // 0x10 % 0x10 * 10 + hex % 0x10
+swig_version = (_to_int(VERSION // 0x10000), _to_int(VERSION // 0x100), _to_int(VERSION))
+del _to_int
+%}
+%enddef
+EMBED_VERSION(SWIG_VERSION)
+
+%pythoncode%{
+# ===================================
+# Iterator for lldb container objects
+# ===================================
+def lldb_iter(obj, getsize, getelem):
+ """A generator adaptor to support iteration for lldb container objects."""
+ size = getattr(obj, getsize)
+ elem = getattr(obj, getelem)
+ for i in range(size()):
+ yield elem(i)
+%}
+
+%include <std_string.i>
+%include "./python/python-typemaps.swig"
+%include "./macros.swig"
+%include "./headers.swig"
+
+%{
+#include "../source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h"
+#include "../bindings/python/python-swigsafecast.swig"
+using namespace lldb_private;
+using namespace lldb_private::python;
+using namespace lldb;
+%}
+
+%include "./interfaces.swig"
+%include "./python/python-extensions.swig"
+%include "./python/python-wrapper.swig"
+
+%pythoncode%{
+_initialize = True
+try:
+ import lldbconfig
+ _initialize = lldbconfig.INITIALIZE
+except ImportError:
+ pass
+debugger_unique_id = 0
+if _initialize:
+ SBDebugger.Initialize()
+debugger = None
+target = None
+process = None
+thread = None
+frame = None
+%}
diff --git a/lldb/bindings/python/createPythonInit.py b/lldb/bindings/python/createPythonInit.py
new file mode 100644
index 000000000000..3deb9159b702
--- /dev/null
+++ b/lldb/bindings/python/createPythonInit.py
@@ -0,0 +1,17 @@
+import os
+import sys
+
+pkgRelDir = sys.argv[1]
+pkgFiles = sys.argv[2:]
+
+getFileName = lambda f: os.path.splitext(os.path.basename(f))[0]
+importNames = ', '.join('"{}"'.format(getFileName(f)) for f in pkgFiles)
+
+script = """__all__ = [{import_names}]
+for x in __all__:
+ __import__('lldb.{pkg_name}.' + x)
+""".format(import_names=importNames, pkg_name=pkgRelDir.replace("/", "."))
+
+pkgIniFile = os.path.normpath(os.path.join(pkgRelDir, "__init__.py"))
+with open(pkgIniFile, "w") as f:
+ f.write(script)
diff --git a/lldb/bindings/python/python-extensions.swig b/lldb/bindings/python/python-extensions.swig
new file mode 100644
index 000000000000..0b23fdd40006
--- /dev/null
+++ b/lldb/bindings/python/python-extensions.swig
@@ -0,0 +1,592 @@
+%extend lldb::SBBreakpoint {
+ %pythoncode %{
+ def __eq__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return False
+
+ return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)
+
+ def __ne__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return True
+
+ return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
+ %}
+}
+
+%extend lldb::SBBroadcaster {
+ %pythoncode %{
+ def __eq__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return False
+
+ return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)
+
+ def __ne__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return True
+
+ return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
+ %}
+}
+
+%extend lldb::SBCommandReturnObject {
+ /* the write() and flush() calls are not part of the SB API proper, and are solely for Python usage
+ they are meant to make an SBCommandReturnObject into a file-like object so that instructions of the sort
+ print >>sb_command_return_object, "something"
+ will work correctly */
+
+ void lldb::SBCommandReturnObject::write (const char* str)
+ {
+ if (str)
+ $self->Printf("%s",str);
+ }
+ void lldb::SBCommandReturnObject::flush ()
+ {}
+}
+
+%extend lldb::SBCompileUnit {
+ %pythoncode %{
+ def __eq__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return False
+
+ return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)
+
+ def __ne__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return True
+
+ return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
+ %}
+}
+
+%extend lldb::SBDeclaration {
+ %pythoncode %{
+ def __eq__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return False
+
+ return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)
+
+ def __ne__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return True
+
+ return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
+ %}
+}
+
+%extend lldb::SBFunction {
+ %pythoncode %{
+ def __eq__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return False
+
+ return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)
+
+ def __ne__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return True
+
+ return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
+ %}
+}
+
+%extend lldb::SBLineEntry {
+ %pythoncode %{
+ def __eq__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return False
+
+ return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)
+
+ def __ne__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return True
+
+ return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
+ %}
+}
+
+%extend lldb::SBModule {
+ %pythoncode %{
+ def __eq__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return False
+
+ return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)
+
+ def __ne__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return True
+
+ return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
+ %}
+}
+
+%extend lldb::SBSection {
+ %pythoncode %{
+ def __eq__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return False
+
+ return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)
+
+ def __ne__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return True
+
+ return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
+ %}
+}
+%extend lldb::SBStream {
+ /* the write() and flush() calls are not part of the SB API proper, and are solely for Python usage
+ they are meant to make an SBStream into a file-like object so that instructions of the sort
+ print >>sb_stream, "something"
+ will work correctly */
+
+ void lldb::SBStream::write (const char* str)
+ {
+ if (str)
+ $self->Printf("%s",str);
+ }
+ void lldb::SBStream::flush ()
+ {}
+}
+%extend lldb::SBSymbol {
+ %pythoncode %{
+ def __eq__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return False
+
+ return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)
+
+ def __ne__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return True
+
+ return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
+ %}
+}
+
+%extend lldb::SBTarget {
+ %pythoncode %{
+ def __eq__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return False
+
+ return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)
+
+ def __ne__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return True
+
+ return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
+ %}
+}
+
+%extend lldb::SBTypeFilter {
+ %pythoncode %{
+ def __eq__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return False
+
+ return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)
+
+ def __ne__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return True
+
+ return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
+ %}
+}
+
+%extend lldb::SBTypeNameSpecifier {
+ %pythoncode %{
+ def __eq__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return False
+
+ return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)
+
+ def __ne__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return True
+
+ return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
+ %}
+}
+
+%extend lldb::SBTypeSummary {
+ %pythoncode %{
+ def __eq__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return False
+
+ return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)
+
+ def __ne__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return True
+
+ return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
+ %}
+}
+
+%extend lldb::SBTypeSynthetic {
+ %pythoncode %{
+ def __eq__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return False
+
+ return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)
+
+ def __ne__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return True
+
+ return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
+ %}
+}
+
+%extend lldb::SBThread {
+ %pythoncode %{
+ def __eq__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return False
+
+ return getattr(_lldb,self.__class__.__name__+"___eq__")(self, rhs)
+
+ def __ne__(self, rhs):
+ if not isinstance(rhs, type(self)):
+ return True
+
+ return getattr(_lldb,self.__class__.__name__+"___ne__")(self, rhs)
+ %}
+}
+
+%pythoncode %{
+
+def command(command_name=None, doc=None):
+ import lldb
+ """A decorator function that registers an LLDB command line
+ command that is bound to the function it is attached to."""
+ def callable(function):
+ """Registers an lldb command for the decorated function."""
+ command = "command script add -f %s.%s %s" % (function.__module__, function.__name__, command_name or function.__name__)
+ lldb.debugger.HandleCommand(command)
+ if doc:
+ function.__doc__ = doc
+ return function
+
+ return callable
+
+class declaration(object):
+ '''A class that represents a source declaration location with file, line and column.'''
+ def __init__(self, file, line, col):
+ self.file = file
+ self.line = line
+ self.col = col
+
+class value_iter(object):
+ def __iter__(self):
+ return self
+
+ def __next__(self):
+ if self.index >= self.length:
+ raise StopIteration()
+ child_sbvalue = self.sbvalue.GetChildAtIndex(self.index)
+ self.index += 1
+ return value(child_sbvalue)
+
+ def next(self):
+ return self.__next__()
+
+ def __init__(self,value):
+ self.index = 0
+ self.sbvalue = value
+ if type(self.sbvalue) is value:
+ self.sbvalue = self.sbvalue.sbvalue
+ self.length = self.sbvalue.GetNumChildren()
+
+class value(object):
+ '''A class designed to wrap lldb.SBValue() objects so the resulting object
+ can be used as a variable would be in code. So if you have a Point structure
+ variable in your code in the current frame named "pt", you can initialize an instance
+ of this class with it:
+
+ pt = lldb.value(lldb.frame.FindVariable("pt"))
+ print pt
+ print pt.x
+ print pt.y
+
+ pt = lldb.value(lldb.frame.FindVariable("rectangle_array"))
+ print rectangle_array[12]
+ print rectangle_array[5].origin.x'''
+ def __init__(self, sbvalue):
+ self.sbvalue = sbvalue
+
+ def __nonzero__(self):
+ return self.sbvalue.__nonzero__()
+
+ def __bool__(self):
+ return self.sbvalue.__bool__()
+
+ def __str__(self):
+ return self.sbvalue.__str__()
+
+ def __getitem__(self, key):
+ # Allow array access if this value has children...
+ if type(key) is value:
+ key = int(key)
+ if type(key) is int:
+ child_sbvalue = (self.sbvalue.GetValueForExpressionPath("[%i]" % key))
+ if child_sbvalue and child_sbvalue.IsValid():
+ return value(child_sbvalue)
+ raise IndexError("Index '%d' is out of range" % key)
+ raise TypeError("No array item of type %s" % str(type(key)))
+
+ def __iter__(self):
+ return value_iter(self.sbvalue)
+
+ def __getattr__(self, name):
+ child_sbvalue = self.sbvalue.GetChildMemberWithName (name)
+ if child_sbvalue and child_sbvalue.IsValid():
+ return value(child_sbvalue)
+ raise AttributeError("Attribute '%s' is not defined" % name)
+
+ def __add__(self, other):
+ return int(self) + int(other)
+
+ def __sub__(self, other):
+ return int(self) - int(other)
+
+ def __mul__(self, other):
+ return int(self) * int(other)
+
+ def __floordiv__(self, other):
+ return int(self) // int(other)
+
+ def __mod__(self, other):
+ return int(self) % int(other)
+
+ def __divmod__(self, other):
+ return int(self) % int(other)
+
+ def __pow__(self, other):
+ return int(self) ** int(other)
+
+ def __lshift__(self, other):
+ return int(self) << int(other)
+
+ def __rshift__(self, other):
+ return int(self) >> int(other)
+
+ def __and__(self, other):
+ return int(self) & int(other)
+
+ def __xor__(self, other):
+ return int(self) ^ int(other)
+
+ def __or__(self, other):
+ return int(self) | int(other)
+
+ def __div__(self, other):
+ return int(self) / int(other)
+
+ def __truediv__(self, other):
+ return int(self) / int(other)
+
+ def __iadd__(self, other):
+ result = self.__add__(other)
+ self.sbvalue.SetValueFromCString (str(result))
+ return result
+
+ def __isub__(self, other):
+ result = self.__sub__(other)
+ self.sbvalue.SetValueFromCString (str(result))
+ return result
+
+ def __imul__(self, other):
+ result = self.__mul__(other)
+ self.sbvalue.SetValueFromCString (str(result))
+ return result
+
+ def __idiv__(self, other):
+ result = self.__div__(other)
+ self.sbvalue.SetValueFromCString (str(result))
+ return result
+
+ def __itruediv__(self, other):
+ result = self.__truediv__(other)
+ self.sbvalue.SetValueFromCString (str(result))
+ return result
+
+ def __ifloordiv__(self, other):
+ result = self.__floordiv__(self, other)
+ self.sbvalue.SetValueFromCString (str(result))
+ return result
+
+ def __imod__(self, other):
+ result = self.__and__(self, other)
+ self.sbvalue.SetValueFromCString (str(result))
+ return result
+
+ def __ipow__(self, other):
+ result = self.__pow__(self, other)
+ self.sbvalue.SetValueFromCString (str(result))
+ return result
+
+ def __ipow__(self, other, modulo):
+ result = self.__pow__(self, other, modulo)
+ self.sbvalue.SetValueFromCString (str(result))
+ return result
+
+ def __ilshift__(self, other):
+ result = self.__lshift__(other)
+ self.sbvalue.SetValueFromCString (str(result))
+ return result
+
+ def __irshift__(self, other):
+ result = self.__rshift__(other)
+ self.sbvalue.SetValueFromCString (str(result))
+ return result
+
+ def __iand__(self, other):
+ result = self.__and__(self, other)
+ self.sbvalue.SetValueFromCString (str(result))
+ return result
+
+ def __ixor__(self, other):
+ result = self.__xor__(self, other)
+ self.sbvalue.SetValueFromCString (str(result))
+ return result
+
+ def __ior__(self, other):
+ result = self.__ior__(self, other)
+ self.sbvalue.SetValueFromCString (str(result))
+ return result
+
+ def __neg__(self):
+ return -int(self)
+
+ def __pos__(self):
+ return +int(self)
+
+ def __abs__(self):
+ return abs(int(self))
+
+ def __invert__(self):
+ return ~int(self)
+
+ def __complex__(self):
+ return complex (int(self))
+
+ def __int__(self):
+ is_num,is_sign = is_numeric_type(self.sbvalue.GetType().GetCanonicalType().GetBasicType())
+ if is_num and not is_sign: return self.sbvalue.GetValueAsUnsigned()
+ return self.sbvalue.GetValueAsSigned()
+
+ def __long__(self):
+ return self.__int__()
+
+ def __float__(self):
+ return float (self.sbvalue.GetValueAsSigned())
+
+ def __oct__(self):
+ return '0%o' % self.sbvalue.GetValueAsUnsigned()
+
+ def __hex__(self):
+ return '0x%x' % self.sbvalue.GetValueAsUnsigned()
+
+ def __len__(self):
+ return self.sbvalue.GetNumChildren()
+
+ def __eq__(self, other):
+ if type(other) is int:
+ return int(self) == other
+ elif type(other) is str:
+ return str(self) == other
+ elif type(other) is value:
+ self_err = SBError()
+ other_err = SBError()
+ self_val = self.sbvalue.GetValueAsUnsigned(self_err)
+ if self_err.fail:
+ raise ValueError("unable to extract value of self")
+ other_val = other.sbvalue.GetValueAsUnsigned(other_err)
+ if other_err.fail:
+ raise ValueError("unable to extract value of other")
+ return self_val == other_val
+ raise TypeError("Unknown type %s, No equality operation defined." % str(type(other)))
+
+ def __ne__(self, other):
+ return not self.__eq__(other)
+%}
+
+%pythoncode %{
+
+class SBSyntheticValueProvider(object):
+ def __init__(self,valobj):
+ pass
+
+ def num_children(self):
+ return 0
+
+ def get_child_index(self,name):
+ return None
+
+ def get_child_at_index(self,idx):
+ return None
+
+ def update(self):
+ pass
+
+ def has_children(self):
+ return False
+
+
+%}
+
+%pythoncode %{
+
+# given an lldb.SBBasicType it returns a tuple
+# (is_numeric, is_signed)
+# the value of is_signed is undefined if is_numeric == false
+def is_numeric_type(basic_type):
+ if basic_type == eBasicTypeInvalid: return (False,False)
+ if basic_type == eBasicTypeVoid: return (False,False)
+ if basic_type == eBasicTypeChar: return (True,False)
+ if basic_type == eBasicTypeSignedChar: return (True,True)
+ if basic_type == eBasicTypeUnsignedChar: return (True,False)
+ if basic_type == eBasicTypeWChar: return (True,False)
+ if basic_type == eBasicTypeSignedWChar: return (True,True)
+ if basic_type == eBasicTypeUnsignedWChar: return (True,False)
+ if basic_type == eBasicTypeChar16: return (True,False)
+ if basic_type == eBasicTypeChar32: return (True,False)
+ if basic_type == eBasicTypeShort: return (True,True)
+ if basic_type == eBasicTypeUnsignedShort: return (True,False)
+ if basic_type == eBasicTypeInt: return (True,True)
+ if basic_type == eBasicTypeUnsignedInt: return (True,False)
+ if basic_type == eBasicTypeLong: return (True,True)
+ if basic_type == eBasicTypeUnsignedLong: return (True,False)
+ if basic_type == eBasicTypeLongLong: return (True,True)
+ if basic_type == eBasicTypeUnsignedLongLong: return (True,False)
+ if basic_type == eBasicTypeInt128: return (True,True)
+ if basic_type == eBasicTypeUnsignedInt128: return (True,False)
+ if basic_type == eBasicTypeBool: return (False,False)
+ if basic_type == eBasicTypeHalf: return (True,True)
+ if basic_type == eBasicTypeFloat: return (True,True)
+ if basic_type == eBasicTypeDouble: return (True,True)
+ if basic_type == eBasicTypeLongDouble: return (True,True)
+ if basic_type == eBasicTypeFloatComplex: return (True,True)
+ if basic_type == eBasicTypeDoubleComplex: return (True,True)
+ if basic_type == eBasicTypeLongDoubleComplex: return (True,True)
+ if basic_type == eBasicTypeObjCID: return (False,False)
+ if basic_type == eBasicTypeObjCClass: return (False,False)
+ if basic_type == eBasicTypeObjCSel: return (False,False)
+ if basic_type == eBasicTypeNullPtr: return (False,False)
+ #if basic_type == eBasicTypeOther:
+ return (False,False)
+
+%}
diff --git a/lldb/bindings/python/python-swigsafecast.swig b/lldb/bindings/python/python-swigsafecast.swig
new file mode 100644
index 000000000000..d5cafbfa67cb
--- /dev/null
+++ b/lldb/bindings/python/python-swigsafecast.swig
@@ -0,0 +1,154 @@
+// leaving this undefined ensures we will get a linker error if we try to use SBTypeToSWIGWrapper()
+// for a type for which we did not specialze this function
+template <typename SBClass>
+PyObject*
+SBTypeToSWIGWrapper (SBClass* sb_object);
+
+template <typename SBClass>
+PyObject*
+SBTypeToSWIGWrapper (SBClass& sb_object)
+{
+ return SBTypeToSWIGWrapper(&sb_object);
+}
+
+template <typename SBClass>
+PyObject*
+SBTypeToSWIGWrapper (const SBClass& sb_object)
+{
+ return SBTypeToSWIGWrapper(&sb_object);
+}
+
+template <>
+PyObject*
+SBTypeToSWIGWrapper (PyObject* py_object)
+{
+ return py_object;
+}
+
+template <>
+PyObject*
+SBTypeToSWIGWrapper (unsigned int* c_int)
+{
+ if (!c_int)
+ return NULL;
+ return PyInt_FromLong(*c_int);
+}
+
+template <>
+PyObject*
+SBTypeToSWIGWrapper (lldb::SBEvent* event_sb)
+{
+ return SWIG_NewPointerObj((void *) event_sb, SWIGTYPE_p_lldb__SBEvent, 0);
+}
+
+template <>
+PyObject*
+SBTypeToSWIGWrapper (lldb::SBProcess* process_sb)
+{
+ return SWIG_NewPointerObj((void *) process_sb, SWIGTYPE_p_lldb__SBProcess, 0);
+}
+
+template <>
+PyObject*
+SBTypeToSWIGWrapper (lldb::SBThread* thread_sb)
+{
+ return SWIG_NewPointerObj((void *) thread_sb, SWIGTYPE_p_lldb__SBThread, 0);
+}
+
+template <>
+PyObject*
+SBTypeToSWIGWrapper (lldb::SBThreadPlan* thread_plan_sb)
+{
+ return SWIG_NewPointerObj((void *) thread_plan_sb, SWIGTYPE_p_lldb__SBThreadPlan, 0);
+}
+
+template <>
+PyObject*
+SBTypeToSWIGWrapper (lldb::SBTarget* target_sb)
+{
+ return SWIG_NewPointerObj((void *) target_sb, SWIGTYPE_p_lldb__SBTarget, 0);
+}
+
+template <>
+PyObject*
+SBTypeToSWIGWrapper (lldb::SBFrame* frame_sb)
+{
+ return SWIG_NewPointerObj((void *) frame_sb, SWIGTYPE_p_lldb__SBFrame, 0);
+}
+
+template <>
+PyObject*
+SBTypeToSWIGWrapper (lldb::SBDebugger* debugger_sb)
+{
+ return SWIG_NewPointerObj((void *) debugger_sb, SWIGTYPE_p_lldb__SBDebugger, 0);
+}
+
+template <>
+PyObject*
+SBTypeToSWIGWrapper (lldb::SBBreakpoint* breakpoint_sb)
+{
+ return SWIG_NewPointerObj((void *) breakpoint_sb, SWIGTYPE_p_lldb__SBBreakpoint, 0);
+}
+
+template <>
+PyObject*
+SBTypeToSWIGWrapper (lldb::SBWatchpoint* watchpoint_sb)
+{
+ return SWIG_NewPointerObj((void *) watchpoint_sb, SWIGTYPE_p_lldb__SBWatchpoint, 0);
+}
+
+template <>
+PyObject*
+SBTypeToSWIGWrapper (lldb::SBBreakpointLocation* breakpoint_location_sb)
+{
+ return SWIG_NewPointerObj((void *) breakpoint_location_sb, SWIGTYPE_p_lldb__SBBreakpointLocation, 0);
+}
+
+template <>
+PyObject*
+SBTypeToSWIGWrapper (lldb::SBBreakpointName* breakpoint_name_sb)
+{
+ return SWIG_NewPointerObj((void *) breakpoint_name_sb, SWIGTYPE_p_lldb__SBBreakpointName, 0);
+}
+
+template <>
+PyObject*
+SBTypeToSWIGWrapper (lldb::SBValue* value_sb)
+{
+ return SWIG_NewPointerObj((void *) value_sb, SWIGTYPE_p_lldb__SBValue, 0);
+}
+
+template <>
+PyObject*
+SBTypeToSWIGWrapper (lldb::SBCommandReturnObject* cmd_ret_obj_sb)
+{
+ return SWIG_NewPointerObj((void *) cmd_ret_obj_sb, SWIGTYPE_p_lldb__SBCommandReturnObject, 0);
+}
+
+template <>
+PyObject*
+SBTypeToSWIGWrapper (lldb::SBExecutionContext* ctx_sb)
+{
+ return SWIG_NewPointerObj((void *) ctx_sb, SWIGTYPE_p_lldb__SBExecutionContext, 0);
+}
+
+template <>
+PyObject*
+SBTypeToSWIGWrapper (lldb::SBTypeSummaryOptions* summary_options_sb)
+{
+ return SWIG_NewPointerObj((void *) summary_options_sb, SWIGTYPE_p_lldb__SBTypeSummaryOptions, 0);
+}
+
+template <>
+PyObject*
+SBTypeToSWIGWrapper (lldb::SBStructuredData* structured_data_sb)
+{
+ return SWIG_NewPointerObj((void *) structured_data_sb, SWIGTYPE_p_lldb__SBStructuredData, 0);
+}
+
+template <>
+PyObject*
+SBTypeToSWIGWrapper (lldb::SBSymbolContext* sym_ctx_sb)
+{
+ return SWIG_NewPointerObj((void *) sym_ctx_sb, SWIGTYPE_p_lldb__SBSymbolContext, 0);
+}
diff --git a/lldb/bindings/python/python-typemaps.swig b/lldb/bindings/python/python-typemaps.swig
new file mode 100644
index 000000000000..c08aeab71f78
--- /dev/null
+++ b/lldb/bindings/python/python-typemaps.swig
@@ -0,0 +1,532 @@
+/* Typemap definitions, to allow SWIG to properly handle 'char**' data types. */
+
+%typemap(in) char ** {
+ /* Check if is a list */
+ if (PythonList::Check($input)) {
+ PythonList list(PyRefType::Borrowed, $input);
+ int size = list.GetSize();
+ int i = 0;
+ $1 = (char**)malloc((size+1)*sizeof(char*));
+ for (i = 0; i < size; i++) {
+ PythonString py_str = list.GetItemAtIndex(i).AsType<PythonString>();
+ if (!py_str.IsAllocated()) {
+ PyErr_SetString(PyExc_TypeError,"list must contain strings");
+ free($1);
+ return nullptr;
+ }
+
+ $1[i] = const_cast<char*>(py_str.GetString().data());
+ }
+ $1[i] = 0;
+ } else if ($input == Py_None) {
+ $1 = NULL;
+ } else {
+ PyErr_SetString(PyExc_TypeError,"not a list");
+ return NULL;
+ }
+}
+
+%typemap(typecheck) char ** {
+ /* Check if is a list */
+ $1 = 1;
+ if (PythonList::Check($input)) {
+ PythonList list(PyRefType::Borrowed, $input);
+ int size = list.GetSize();
+ int i = 0;
+ for (i = 0; i < size; i++) {
+ PythonString s = list.GetItemAtIndex(i).AsType<PythonString>();
+ if (!s.IsAllocated()) { $1 = 0; }
+ }
+ }
+ else
+ {
+ $1 = ( ($input == Py_None) ? 1 : 0);
+ }
+}
+
+%typemap(freearg) char** {
+ free((char *) $1);
+}
+
+%typemap(out) char** {
+ int len;
+ int i;
+ len = 0;
+ while ($1[len]) len++;
+ PythonList list(len);
+ for (i = 0; i < len; i++)
+ list.SetItemAtIndex(i, PythonString($1[i]));
+ $result = list.release();
+}
+
+%typemap(in) lldb::tid_t {
+ PythonObject obj = Retain<PythonObject>($input);
+ lldb::tid_t value = unwrapOrSetPythonException(As<unsigned long long>(obj));
+ if (PyErr_Occurred())
+ return nullptr;
+ $1 = value;
+}
+
+%typemap(in) lldb::StateType {
+ PythonObject obj = Retain<PythonObject>($input);
+ unsigned long long state_type_value =
+ unwrapOrSetPythonException(As<unsigned long long>(obj));
+ if (PyErr_Occurred())
+ return nullptr;
+ if (state_type_value > lldb::StateType::kLastStateType) {
+ PyErr_SetString(PyExc_ValueError, "Not a valid StateType value");
+ return nullptr;
+ }
+ $1 = static_cast<lldb::StateType>(state_type_value);
+}
+
+/* Typemap definitions to allow SWIG to properly handle char buffer. */
+
+// typemap for a char buffer
+%typemap(in) (char *dst, size_t dst_len) {
+ if (!PyInt_Check($input)) {
+ PyErr_SetString(PyExc_ValueError, "Expecting an integer");
+ return NULL;
+ }
+ $2 = PyInt_AsLong($input);
+ if ($2 <= 0) {
+ PyErr_SetString(PyExc_ValueError, "Positive integer expected");
+ return NULL;
+ }
+ $1 = (char *) malloc($2);
+}
+// SBProcess::ReadCStringFromMemory() uses a void*, but needs to be treated
+// as char data instead of byte data.
+%typemap(in) (void *char_buf, size_t size) = (char *dst, size_t dst_len);
+
+// Return the char buffer. Discarding any previous return result
+%typemap(argout) (char *dst, size_t dst_len) {
+ Py_XDECREF($result); /* Blow away any previous result */
+ if (result == 0) {
+ PythonString string("");
+ $result = string.release();
+ Py_INCREF($result);
+ } else {
+ llvm::StringRef ref(static_cast<const char*>($1), result);
+ PythonString string(ref);
+ $result = string.release();
+ }
+ free($1);
+}
+// SBProcess::ReadCStringFromMemory() uses a void*, but needs to be treated
+// as char data instead of byte data.
+%typemap(argout) (void *char_buf, size_t size) = (char *dst, size_t dst_len);
+
+
+// typemap for handling an snprintf-like API like SBThread::GetStopDescription.
+%typemap(in) (char *dst_or_null, size_t dst_len) {
+ if (!PyInt_Check($input)) {
+ PyErr_SetString(PyExc_ValueError, "Expecting an integer");
+ return NULL;
+ }
+ $2 = PyInt_AsLong($input);
+ if ($2 <= 0) {
+ PyErr_SetString(PyExc_ValueError, "Positive integer expected");
+ return NULL;
+ }
+ $1 = (char *) malloc($2);
+}
+%typemap(argout) (char *dst_or_null, size_t dst_len) {
+ Py_XDECREF($result); /* Blow away any previous result */
+ llvm::StringRef ref($1);
+ PythonString string(ref);
+ $result = string.release();
+ free($1);
+}
+
+
+// typemap for an outgoing buffer
+// See also SBEvent::SBEvent(uint32_t event, const char *cstr, uint32_t cstr_len).
+// Ditto for SBProcess::PutSTDIN(const char *src, size_t src_len).
+%typemap(in) (const char *cstr, uint32_t cstr_len),
+ (const char *src, size_t src_len) {
+ if (PythonString::Check($input)) {
+ PythonString str(PyRefType::Borrowed, $input);
+ $1 = (char*)str.GetString().data();
+ $2 = str.GetSize();
+ }
+ else if(PythonByteArray::Check($input)) {
+ PythonByteArray bytearray(PyRefType::Borrowed, $input);
+ $1 = (char*)bytearray.GetBytes().data();
+ $2 = bytearray.GetSize();
+ }
+ else if (PythonBytes::Check($input)) {
+ PythonBytes bytes(PyRefType::Borrowed, $input);
+ $1 = (char*)bytes.GetBytes().data();
+ $2 = bytes.GetSize();
+ }
+ else {
+ PyErr_SetString(PyExc_ValueError, "Expecting a string");
+ return NULL;
+ }
+}
+// For SBProcess::WriteMemory, SBTarget::GetInstructions and SBDebugger::DispatchInput.
+%typemap(in) (const void *buf, size_t size),
+ (const void *data, size_t data_len) {
+ if (PythonString::Check($input)) {
+ PythonString str(PyRefType::Borrowed, $input);
+ $1 = (void*)str.GetString().data();
+ $2 = str.GetSize();
+ }
+ else if(PythonByteArray::Check($input)) {
+ PythonByteArray bytearray(PyRefType::Borrowed, $input);
+ $1 = (void*)bytearray.GetBytes().data();
+ $2 = bytearray.GetSize();
+ }
+ else if (PythonBytes::Check($input)) {
+ PythonBytes bytes(PyRefType::Borrowed, $input);
+ $1 = (void*)bytes.GetBytes().data();
+ $2 = bytes.GetSize();
+ }
+ else {
+ PyErr_SetString(PyExc_ValueError, "Expecting a buffer");
+ return NULL;
+ }
+}
+
+// typemap for an incoming buffer
+// See also SBProcess::ReadMemory.
+%typemap(in) (void *buf, size_t size) {
+ if (PyInt_Check($input)) {
+ $2 = PyInt_AsLong($input);
+ } else if (PyLong_Check($input)) {
+ $2 = PyLong_AsLong($input);
+ } else {
+ PyErr_SetString(PyExc_ValueError, "Expecting an integer or long object");
+ return NULL;
+ }
+ if ($2 <= 0) {
+ PyErr_SetString(PyExc_ValueError, "Positive integer expected");
+ return NULL;
+ }
+ $1 = (void *) malloc($2);
+}
+
+// Return the buffer. Discarding any previous return result
+// See also SBProcess::ReadMemory.
+%typemap(argout) (void *buf, size_t size) {
+ Py_XDECREF($result); /* Blow away any previous result */
+ if (result == 0) {
+ $result = Py_None;
+ Py_INCREF($result);
+ } else {
+ PythonBytes bytes(static_cast<const uint8_t*>($1), result);
+ $result = bytes.release();
+ }
+ free($1);
+}
+
+%{
+namespace {
+template <class T>
+T PyLongAsT(PyObject *obj) {
+ static_assert(true, "unsupported type");
+}
+
+template <> uint64_t PyLongAsT<uint64_t>(PyObject *obj) {
+ return static_cast<uint64_t>(PyLong_AsUnsignedLongLong(obj));
+}
+
+template <> uint32_t PyLongAsT<uint32_t>(PyObject *obj) {
+ return static_cast<uint32_t>(PyLong_AsUnsignedLong(obj));
+}
+
+template <> int64_t PyLongAsT<int64_t>(PyObject *obj) {
+ return static_cast<int64_t>(PyLong_AsLongLong(obj));
+}
+
+template <> int32_t PyLongAsT<int32_t>(PyObject *obj) {
+ return static_cast<int32_t>(PyLong_AsLong(obj));
+}
+
+template <class T>
+bool SetNumberFromPyObject(T &number, PyObject *obj) {
+ if (PyInt_Check(obj))
+ number = static_cast<T>(PyInt_AsLong(obj));
+ else if (PyLong_Check(obj))
+ number = PyLongAsT<T>(obj);
+ else return false;
+
+ return true;
+}
+
+template <>
+bool SetNumberFromPyObject<double>(double &number, PyObject *obj) {
+ if (PyFloat_Check(obj)) {
+ number = PyFloat_AsDouble(obj);
+ return true;
+ }
+
+ return false;
+}
+
+} // namespace
+%}
+
+// these typemaps allow Python users to pass list objects
+// and have them turn into C++ arrays (this is useful, for instance
+// when creating SBData objects from lists of numbers)
+%typemap(in) (uint64_t* array, size_t array_len),
+ (uint32_t* array, size_t array_len),
+ (int64_t* array, size_t array_len),
+ (int32_t* array, size_t array_len),
+ (double* array, size_t array_len) {
+ /* Check if is a list */
+ if (PyList_Check($input)) {
+ int size = PyList_Size($input);
+ int i = 0;
+ $2 = size;
+ $1 = ($1_type) malloc(size * sizeof($*1_type));
+ for (i = 0; i < size; i++) {
+ PyObject *o = PyList_GetItem($input,i);
+ if (!SetNumberFromPyObject($1[i], o)) {
+ PyErr_SetString(PyExc_TypeError,"list must contain numbers");
+ free($1);
+ return NULL;
+ }
+
+ if (PyErr_Occurred()) {
+ free($1);
+ return NULL;
+ }
+ }
+ } else if ($input == Py_None) {
+ $1 = NULL;
+ $2 = 0;
+ } else {
+ PyErr_SetString(PyExc_TypeError,"not a list");
+ return NULL;
+ }
+}
+
+%typemap(freearg) (uint64_t* array, size_t array_len),
+ (uint32_t* array, size_t array_len),
+ (int64_t* array, size_t array_len),
+ (int32_t* array, size_t array_len),
+ (double* array, size_t array_len) {
+ free($1);
+}
+
+// these typemaps wrap SBModule::GetVersion() from requiring a memory buffer
+// to the more Pythonic style where a list is returned and no previous allocation
+// is necessary - this will break if more than 50 versions are ever returned
+%typemap(typecheck) (uint32_t *versions, uint32_t num_versions) {
+ $1 = ($input == Py_None ? 1 : 0);
+}
+
+%typemap(in, numinputs=0) (uint32_t *versions) {
+ $1 = (uint32_t*)malloc(sizeof(uint32_t) * 50);
+}
+
+%typemap(in, numinputs=0) (uint32_t num_versions) {
+ $1 = 50;
+}
+
+%typemap(argout) (uint32_t *versions, uint32_t num_versions) {
+ uint32_t count = result;
+ if (count >= $2)
+ count = $2;
+ PyObject* list = PyList_New(count);
+ for (uint32_t j = 0; j < count; j++)
+ {
+ PyObject* item = PyInt_FromLong($1[j]);
+ int ok = PyList_SetItem(list,j,item);
+ if (ok != 0)
+ {
+ $result = Py_None;
+ break;
+ }
+ }
+ $result = list;
+}
+
+%typemap(freearg) (uint32_t *versions) {
+ free($1);
+}
+
+
+// For Log::LogOutputCallback
+%typemap(in) (lldb::LogOutputCallback log_callback, void *baton) {
+ if (!($input == Py_None || PyCallable_Check(reinterpret_cast<PyObject*>($input)))) {
+ PyErr_SetString(PyExc_TypeError, "Need a callable object or None!");
+ return NULL;
+ }
+
+ // FIXME (filcab): We can't currently check if our callback is already
+ // LLDBSwigPythonCallPythonLogOutputCallback (to DECREF the previous
+ // baton) nor can we just remove all traces of a callback, if we want to
+ // revert to a file logging mechanism.
+
+ // Don't lose the callback reference
+ Py_INCREF($input);
+ $1 = LLDBSwigPythonCallPythonLogOutputCallback;
+ $2 = $input;
+}
+
+%typemap(typecheck) (lldb::LogOutputCallback log_callback, void *baton) {
+ $1 = $input == Py_None;
+ $1 = $1 || PyCallable_Check(reinterpret_cast<PyObject*>($input));
+}
+
+
+%typemap(in) lldb::FileSP {
+ PythonFile py_file(PyRefType::Borrowed, $input);
+ if (!py_file) {
+ PyErr_SetString(PyExc_TypeError, "not a file");
+ return nullptr;
+ }
+ auto sp = unwrapOrSetPythonException(py_file.ConvertToFile());
+ if (!sp)
+ return nullptr;
+ $1 = sp;
+}
+
+%typemap(in) lldb::FileSP FORCE_IO_METHODS {
+ PythonFile py_file(PyRefType::Borrowed, $input);
+ if (!py_file) {
+ PyErr_SetString(PyExc_TypeError, "not a file");
+ return nullptr;
+ }
+ auto sp = unwrapOrSetPythonException(py_file.ConvertToFileForcingUseOfScriptingIOMethods());
+ if (!sp)
+ return nullptr;
+ $1 = sp;
+}
+
+%typemap(in) lldb::FileSP BORROWED {
+ PythonFile py_file(PyRefType::Borrowed, $input);
+ if (!py_file) {
+ PyErr_SetString(PyExc_TypeError, "not a file");
+ return nullptr;
+ }
+ auto sp = unwrapOrSetPythonException(py_file.ConvertToFile(/*borrowed=*/true));
+ if (!sp)
+ return nullptr;
+ $1 = sp;
+}
+
+%typemap(in) lldb::FileSP BORROWED_FORCE_IO_METHODS {
+ PythonFile py_file(PyRefType::Borrowed, $input);
+ if (!py_file) {
+ PyErr_SetString(PyExc_TypeError, "not a file");
+ return nullptr;
+ }
+ auto sp = unwrapOrSetPythonException(py_file.ConvertToFileForcingUseOfScriptingIOMethods(/*borrowed=*/true));
+ if (!sp)
+ return nullptr;
+ $1 = sp;
+}
+
+%typecheck(SWIG_TYPECHECK_POINTER) lldb::FileSP {
+ if (PythonFile::Check($input)) {
+ $1 = 1;
+ } else {
+ PyErr_Clear();
+ $1 = 0;
+ }
+}
+
+%typemap(out) lldb::FileSP {
+ $result = nullptr;
+ lldb::FileSP &sp = $1;
+ if (sp) {
+ PythonFile pyfile = unwrapOrSetPythonException(PythonFile::FromFile(*sp));
+ if (!pyfile.IsValid())
+ return nullptr;
+ $result = pyfile.release();
+ }
+ if (!$result)
+ {
+ $result = Py_None;
+ Py_INCREF(Py_None);
+ }
+}
+
+%typemap(in) (const char* string, int len) {
+ if ($input == Py_None)
+ {
+ $1 = NULL;
+ $2 = 0;
+ }
+ else if (PythonString::Check($input))
+ {
+ PythonString py_str(PyRefType::Borrowed, $input);
+ llvm::StringRef str = py_str.GetString();
+ $1 = const_cast<char*>(str.data());
+ $2 = str.size();
+ // In Python 2, if $input is a PyUnicode object then this
+ // will trigger a Unicode -> String conversion, in which
+ // case the `PythonString` will now own the PyString. Thus
+ // if it goes out of scope, the data will be deleted. The
+ // only way to avoid this is to leak the Python object in
+ // that case. Note that if there was no conversion, then
+ // releasing the string will not leak anything, since we
+ // created this as a borrowed reference.
+ py_str.release();
+ }
+ else
+ {
+ PyErr_SetString(PyExc_TypeError,"not a string-like object");
+ return NULL;
+ }
+}
+
+%inline %{
+
+struct Py_buffer_RAII {
+ Py_buffer buffer = {};
+ Py_buffer_RAII() {};
+ Py_buffer &operator=(const Py_buffer_RAII &) = delete;
+ Py_buffer_RAII(const Py_buffer_RAII &) = delete;
+ ~Py_buffer_RAII() {
+ if (buffer.obj)
+ PyBuffer_Release(&buffer);
+ }
+};
+
+%}
+
+// These two pybuffer macros are copied out of swig/Lib/python/pybuffer.i,
+// and fixed so they will not crash if PyObject_GetBuffer fails.
+// https://github.com/swig/swig/issues/1640
+//
+// I've also moved the call to PyBuffer_Release to the end of the SWIG wrapper,
+// doing it right away is not legal according to the python buffer protocol.
+
+%define %pybuffer_mutable_binary(TYPEMAP, SIZE)
+%typemap(in) (TYPEMAP, SIZE) (Py_buffer_RAII view) {
+ int res; Py_ssize_t size = 0; void *buf = 0;
+ res = PyObject_GetBuffer($input, &view.buffer, PyBUF_WRITABLE);
+ if (res < 0) {
+ PyErr_Clear();
+ %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
+ }
+ size = view.buffer.len;
+ buf = view.buffer.buf;
+ $1 = ($1_ltype) buf;
+ $2 = ($2_ltype) (size/sizeof($*1_type));
+}
+%enddef
+
+%define %pybuffer_binary(TYPEMAP, SIZE)
+%typemap(in) (TYPEMAP, SIZE) (Py_buffer_RAII view) {
+ int res; Py_ssize_t size = 0; const void *buf = 0;
+ res = PyObject_GetBuffer($input, &view.buffer, PyBUF_CONTIG_RO);
+ if (res < 0) {
+ PyErr_Clear();
+ %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
+ }
+ size = view.buffer.len;
+ buf = view.buffer.buf;
+ $1 = ($1_ltype) buf;
+ $2 = ($2_ltype) (size / sizeof($*1_type));
+}
+%enddef
+
+%pybuffer_binary(const uint8_t *buf, size_t num_bytes);
+%pybuffer_mutable_binary(uint8_t *buf, size_t num_bytes);
diff --git a/lldb/bindings/python/python-wrapper.swig b/lldb/bindings/python/python-wrapper.swig
new file mode 100644
index 000000000000..f9e89373fe25
--- /dev/null
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -0,0 +1,1067 @@
+%header %{
+
+template <typename T>
+PyObject *
+SBTypeToSWIGWrapper (T* item);
+
+class PyErr_Cleaner
+{
+public:
+ PyErr_Cleaner(bool print=false) :
+ m_print(print)
+ {
+ }
+
+ ~PyErr_Cleaner()
+ {
+ if (PyErr_Occurred())
+ {
+ if(m_print && !PyErr_ExceptionMatches(PyExc_SystemExit))
+ PyErr_Print();
+ PyErr_Clear();
+ }
+ }
+
+private:
+ bool m_print;
+};
+
+%}
+
+%wrapper %{
+
+// resolve a dotted Python name in the form
+// foo.bar.baz.Foobar to an actual Python object
+// if pmodule is NULL, the __main__ module will be used
+// as the starting point for the search
+
+
+// This function is called by lldb_private::ScriptInterpreterPython::BreakpointCallbackFunction(...)
+// and is used when a script command is attached to a breakpoint for execution.
+
+SWIGEXPORT llvm::Expected<bool>
+LLDBSwigPythonBreakpointCallbackFunction
+(
+ const char *python_function_name,
+ const char *session_dictionary_name,
+ const lldb::StackFrameSP& frame_sp,
+ const lldb::BreakpointLocationSP& bp_loc_sp,
+ lldb_private::StructuredDataImpl *args_impl
+)
+{
+ using namespace llvm;
+
+ lldb::SBFrame sb_frame (frame_sp);
+ lldb::SBBreakpointLocation sb_bp_loc(bp_loc_sp);
+
+ PyErr_Cleaner py_err_cleaner(true);
+ auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(session_dictionary_name);
+ auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(python_function_name, dict);
+
+ unsigned max_positional_args;
+ if (auto arg_info = pfunc.GetArgInfo())
+ max_positional_args = arg_info.get().max_positional_args;
+ else
+ return arg_info.takeError();
+
+ PythonObject frame_arg(PyRefType::Owned, SBTypeToSWIGWrapper(sb_frame));
+ PythonObject bp_loc_arg(PyRefType::Owned, SBTypeToSWIGWrapper(sb_bp_loc));
+
+ auto result = [&] () -> Expected<PythonObject> {
+ // If the called function doesn't take extra_args, drop them here:
+ if (max_positional_args < 4) {
+ return pfunc.Call(frame_arg, bp_loc_arg, dict);
+ } else {
+ lldb::SBStructuredData *args_value = new lldb::SBStructuredData(args_impl);
+ PythonObject args_arg(PyRefType::Owned, SBTypeToSWIGWrapper(args_value));
+ return pfunc.Call(frame_arg, bp_loc_arg, args_arg, dict);
+ }
+ } ();
+
+ if (!result)
+ return result.takeError();
+
+ // Only False counts as false!
+ return result.get().get() != Py_False;
+}
+
+// This function is called by lldb_private::ScriptInterpreterPython::WatchpointCallbackFunction(...)
+// and is used when a script command is attached to a watchpoint for execution.
+
+SWIGEXPORT bool
+LLDBSwigPythonWatchpointCallbackFunction
+(
+ const char *python_function_name,
+ const char *session_dictionary_name,
+ const lldb::StackFrameSP& frame_sp,
+ const lldb::WatchpointSP& wp_sp
+)
+{
+ lldb::SBFrame sb_frame (frame_sp);
+ lldb::SBWatchpoint sb_wp(wp_sp);
+
+ bool stop_at_watchpoint = true;
+
+ PyErr_Cleaner py_err_cleaner(true);
+
+ auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(session_dictionary_name);
+ auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(python_function_name, dict);
+
+ if (!pfunc.IsAllocated())
+ return stop_at_watchpoint;
+
+ PythonObject frame_arg(PyRefType::Owned, SBTypeToSWIGWrapper(sb_frame));
+ PythonObject wp_arg(PyRefType::Owned, SBTypeToSWIGWrapper(sb_wp));
+ PythonObject result = pfunc(frame_arg, wp_arg, dict);
+
+ if (result.get() == Py_False)
+ stop_at_watchpoint = false;
+
+ return stop_at_watchpoint;
+}
+
+SWIGEXPORT bool
+LLDBSwigPythonCallTypeScript
+(
+ const char *python_function_name,
+ const void *session_dictionary,
+ const lldb::ValueObjectSP& valobj_sp,
+ void** pyfunct_wrapper,
+ const lldb::TypeSummaryOptionsSP& options_sp,
+ std::string& retval
+)
+{
+ lldb::SBValue sb_value (valobj_sp);
+ lldb::SBTypeSummaryOptions sb_options(options_sp.get());
+
+ retval.clear();
+
+ if (!python_function_name || !session_dictionary)
+ return false;
+
+ PyObject *pfunc_impl = nullptr;
+
+ if (pyfunct_wrapper && *pyfunct_wrapper && PyFunction_Check (*pyfunct_wrapper))
+ {
+ pfunc_impl = (PyObject*)(*pyfunct_wrapper);
+ if (pfunc_impl->ob_refcnt == 1)
+ {
+ Py_XDECREF(pfunc_impl);
+ pfunc_impl = NULL;
+ }
+ }
+
+ PyObject *py_dict = (PyObject*)session_dictionary;
+ if (!PythonDictionary::Check(py_dict))
+ return true;
+
+ PythonDictionary dict(PyRefType::Borrowed, py_dict);
+
+ PyErr_Cleaner pyerr_cleanup(true); // show Python errors
+
+ PythonCallable pfunc(PyRefType::Borrowed, pfunc_impl);
+
+ if (!pfunc.IsAllocated())
+ {
+ pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(python_function_name, dict);
+ if (!pfunc.IsAllocated())
+ return false;
+
+ if (pyfunct_wrapper)
+ {
+ *pyfunct_wrapper = pfunc.get();
+ Py_XINCREF(pfunc.get());
+ }
+ }
+
+ PythonObject result;
+ auto argc = pfunc.GetArgInfo();
+ if (!argc) {
+ llvm::consumeError(argc.takeError());
+ return false;
+ }
+
+ PythonObject value_arg(PyRefType::Owned, SBTypeToSWIGWrapper(sb_value));
+ PythonObject options_arg(PyRefType::Owned, SBTypeToSWIGWrapper(sb_options));
+
+ if (argc.get().max_positional_args < 3)
+ result = pfunc(value_arg,dict);
+ else
+ result = pfunc(value_arg,dict,options_arg);
+
+ retval = result.Str().GetString().str();
+
+ return true;
+}
+
+SWIGEXPORT void*
+LLDBSwigPythonCreateSyntheticProvider
+(
+ const char *python_class_name,
+ const char *session_dictionary_name,
+ const lldb::ValueObjectSP& valobj_sp
+)
+{
+ if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name)
+ Py_RETURN_NONE;
+
+ PyErr_Cleaner py_err_cleaner(true);
+
+ auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(session_dictionary_name);
+ auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(python_class_name,dict);
+
+ if (!pfunc.IsAllocated())
+ Py_RETURN_NONE;
+
+ // I do not want the SBValue to be deallocated when going out of scope because python
+ // has ownership of it and will manage memory for this object by itself
+ lldb::SBValue *sb_value = new lldb::SBValue(valobj_sp);
+ sb_value->SetPreferSyntheticValue(false);
+
+ PythonObject val_arg(PyRefType::Owned, SBTypeToSWIGWrapper(sb_value));
+ if (!val_arg.IsAllocated())
+ Py_RETURN_NONE;
+
+ PythonObject result = pfunc(val_arg, dict);
+
+ if (result.IsAllocated())
+ return result.release();
+
+ Py_RETURN_NONE;
+}
+
+SWIGEXPORT void*
+LLDBSwigPythonCreateCommandObject
+(
+ const char *python_class_name,
+ const char *session_dictionary_name,
+ const lldb::DebuggerSP debugger_sp
+)
+{
+ if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name)
+ Py_RETURN_NONE;
+
+ PyErr_Cleaner py_err_cleaner(true);
+ auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(session_dictionary_name);
+ auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(python_class_name, dict);
+
+ if (!pfunc.IsAllocated())
+ return nullptr;
+
+ lldb::SBDebugger debugger_sb(debugger_sp);
+ PythonObject debugger_arg(PyRefType::Owned, SBTypeToSWIGWrapper(debugger_sb));
+ PythonObject result = pfunc(debugger_arg, dict);
+
+ if (result.IsAllocated())
+ return result.release();
+
+ Py_RETURN_NONE;
+}
+
+SWIGEXPORT void*
+LLDBSwigPythonCreateScriptedThreadPlan
+(
+ const char *python_class_name,
+ const char *session_dictionary_name,
+ lldb_private::StructuredDataImpl *args_impl,
+ std::string &error_string,
+ const lldb::ThreadPlanSP& thread_plan_sp
+)
+{
+ if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name)
+ Py_RETURN_NONE;
+
+ // I do not want the SBThreadPlan to be deallocated when going out of scope because python
+ // has ownership of it and will manage memory for this object by itself
+ lldb::SBThreadPlan *tp_value = new lldb::SBThreadPlan(thread_plan_sp);
+
+ PyErr_Cleaner py_err_cleaner(true);
+
+ auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(session_dictionary_name);
+ auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(python_class_name, dict);
+
+ if (!pfunc.IsAllocated()) {
+ error_string.append("could not find script class: ");
+ error_string.append(python_class_name);
+ return nullptr;
+ }
+
+ PythonObject tp_arg(PyRefType::Owned, SBTypeToSWIGWrapper(tp_value));
+
+ if (!tp_arg.IsAllocated())
+ Py_RETURN_NONE;
+
+ llvm::Expected<PythonCallable::ArgInfo> arg_info = pfunc.GetArgInfo();
+ if (!arg_info) {
+ llvm::handleAllErrors(
+ arg_info.takeError(),
+ [&](PythonException &E) {
+ error_string.append(E.ReadBacktrace());
+ },
+ [&](const llvm::ErrorInfoBase &E) {
+ error_string.append(E.message());
+ });
+ Py_RETURN_NONE;
+ }
+
+ PythonObject result = {};
+ if (arg_info.get().max_positional_args == 2) {
+ if (args_impl != nullptr) {
+ error_string.assign("args passed, but __init__ does not take an args dictionary");
+ Py_RETURN_NONE;
+ }
+ result = pfunc(tp_arg, dict);
+ } else if (arg_info.get().max_positional_args >= 3) {
+ lldb::SBStructuredData *args_value = new lldb::SBStructuredData(args_impl);
+ PythonObject args_arg(PyRefType::Owned, SBTypeToSWIGWrapper(args_value));
+ result = pfunc(tp_arg, args_arg, dict);
+ } else {
+ error_string.assign("wrong number of arguments in __init__, should be 2 or 3 (not including self)");
+ Py_RETURN_NONE;
+ }
+
+ // FIXME: At this point we should check that the class we found supports all the methods
+ // that we need.
+
+ if (result.IsAllocated())
+ return result.release();
+ Py_RETURN_NONE;
+}
+
+SWIGEXPORT bool
+LLDBSWIGPythonCallThreadPlan
+(
+ void *implementor,
+ const char *method_name,
+ lldb_private::Event *event,
+ bool &got_error
+)
+{
+ got_error = false;
+
+ PyErr_Cleaner py_err_cleaner(false);
+ PythonObject self(PyRefType::Borrowed, static_cast<PyObject*>(implementor));
+ auto pfunc = self.ResolveName<PythonCallable>(method_name);
+
+ if (!pfunc.IsAllocated())
+ return false;
+
+ PythonObject result;
+ if (event != nullptr)
+ {
+ lldb::SBEvent sb_event(event);
+ PythonObject event_arg(PyRefType::Owned, SBTypeToSWIGWrapper(sb_event));
+ result = pfunc(event_arg);
+ }
+ else
+ result = pfunc();
+
+ if (PyErr_Occurred())
+ {
+ got_error = true;
+ printf ("Return value was neither false nor true for call to %s.\n", method_name);
+ PyErr_Print();
+ return false;
+ }
+
+ if (result.get() == Py_True)
+ return true;
+ else if (result.get() == Py_False)
+ return false;
+
+ // Somebody returned the wrong thing...
+ got_error = true;
+ printf ("Wrong return value type for call to %s.\n", method_name);
+ return false;
+}
+
+SWIGEXPORT void *
+LLDBSwigPythonCreateScriptedBreakpointResolver
+(
+ const char *python_class_name,
+ const char *session_dictionary_name,
+ lldb_private::StructuredDataImpl *args_impl,
+ lldb::BreakpointSP &breakpoint_sp
+)
+{
+ if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name)
+ Py_RETURN_NONE;
+
+ PyErr_Cleaner py_err_cleaner(true);
+
+ auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(session_dictionary_name);
+ auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(python_class_name, dict);
+
+ if (!pfunc.IsAllocated())
+ return nullptr;
+
+ lldb::SBBreakpoint *bkpt_value = new lldb::SBBreakpoint(breakpoint_sp);
+
+ PythonObject bkpt_arg(PyRefType::Owned, SBTypeToSWIGWrapper(bkpt_value));
+
+ lldb::SBStructuredData *args_value = new lldb::SBStructuredData(args_impl);
+ PythonObject args_arg(PyRefType::Owned, SBTypeToSWIGWrapper(args_value));
+
+ PythonObject result = pfunc(bkpt_arg, args_arg, dict);
+ // FIXME: At this point we should check that the class we found supports all the methods
+ // that we need.
+
+ if (result.IsAllocated())
+ {
+ // Check that __callback__ is defined:
+ auto callback_func = result.ResolveName<PythonCallable>("__callback__");
+ if (callback_func.IsAllocated())
+ return result.release();
+ else
+ result.release();
+ }
+ Py_RETURN_NONE;
+}
+
+SWIGEXPORT unsigned int
+LLDBSwigPythonCallBreakpointResolver
+(
+ void *implementor,
+ const char *method_name,
+ lldb_private::SymbolContext *sym_ctx
+)
+{
+ PyErr_Cleaner py_err_cleaner(false);
+ PythonObject self(PyRefType::Borrowed, static_cast<PyObject*>(implementor));
+ auto pfunc = self.ResolveName<PythonCallable>(method_name);
+
+ if (!pfunc.IsAllocated())
+ return 0;
+
+ PythonObject result;
+ if (sym_ctx != nullptr) {
+ lldb::SBSymbolContext sb_sym_ctx(sym_ctx);
+ PythonObject sym_ctx_arg(PyRefType::Owned, SBTypeToSWIGWrapper(sb_sym_ctx));
+ result = pfunc(sym_ctx_arg);
+ } else
+ result = pfunc();
+
+ if (PyErr_Occurred())
+ {
+ PyErr_Print();
+ PyErr_Clear();
+ return 0;
+ }
+
+ // The callback will return a bool, but we're need to also return ints
+ // so we're squirrelling the bool through as an int... And if you return
+ // nothing, we'll continue.
+ if (strcmp(method_name, "__callback__") == 0) {
+ if (result.get() == Py_False)
+ return 0;
+ else
+ return 1;
+ }
+
+ long long ret_val = unwrapOrSetPythonException(As<long long>(result));
+
+ if (PyErr_Occurred()) {
+ PyErr_Print();
+ PyErr_Clear();
+ return 0;
+ }
+
+ return ret_val;
+}
+
+// wrapper that calls an optional instance member of an object taking no arguments
+static PyObject*
+LLDBSwigPython_CallOptionalMember
+(
+ PyObject* implementor,
+ char* callee_name,
+ PyObject* ret_if_not_found = Py_None,
+ bool* was_found = NULL
+)
+{
+ PyErr_Cleaner py_err_cleaner(false);
+
+ PythonObject self(PyRefType::Borrowed, static_cast<PyObject*>(implementor));
+ auto pfunc = self.ResolveName<PythonCallable>(callee_name);
+
+ if (!pfunc.IsAllocated())
+ {
+ if (was_found)
+ *was_found = false;
+ Py_XINCREF(ret_if_not_found);
+ return ret_if_not_found;
+ }
+
+ if (was_found)
+ *was_found = true;
+
+ PythonObject result = pfunc();
+ return result.release();
+}
+
+SWIGEXPORT size_t
+LLDBSwigPython_CalculateNumChildren
+(
+ PyObject *implementor,
+ uint32_t max
+)
+{
+ PythonObject self(PyRefType::Borrowed, implementor);
+ auto pfunc = self.ResolveName<PythonCallable>("num_children");
+
+ if (!pfunc.IsAllocated())
+ return 0;
+
+ auto arg_info = pfunc.GetArgInfo();
+ if (!arg_info) {
+ llvm::consumeError(arg_info.takeError());
+ return 0;
+ }
+
+ size_t ret_val;
+ if (arg_info.get().max_positional_args < 1)
+ ret_val = unwrapOrSetPythonException(As<long long>(pfunc.Call()));
+ else
+ ret_val = unwrapOrSetPythonException(As<long long>(pfunc.Call(PythonInteger(max))));
+
+ if (PyErr_Occurred())
+ {
+ PyErr_Print();
+ PyErr_Clear();
+ return 0;
+ }
+
+ if (arg_info.get().max_positional_args < 1)
+ ret_val = std::min(ret_val, static_cast<size_t>(max));
+
+ return ret_val;
+}
+
+SWIGEXPORT PyObject*
+LLDBSwigPython_GetChildAtIndex
+(
+ PyObject *implementor,
+ uint32_t idx
+)
+{
+ PyErr_Cleaner py_err_cleaner(true);
+
+ PythonObject self(PyRefType::Borrowed, implementor);
+ auto pfunc = self.ResolveName<PythonCallable>("get_child_at_index");
+
+ if (!pfunc.IsAllocated())
+ return nullptr;
+
+ PythonObject result = pfunc(PythonInteger(idx));
+
+ if (!result.IsAllocated())
+ return nullptr;
+
+ lldb::SBValue* sbvalue_ptr = nullptr;
+ if (SWIG_ConvertPtr(result.get(), (void**)&sbvalue_ptr, SWIGTYPE_p_lldb__SBValue, 0) == -1)
+ return nullptr;
+
+ if (sbvalue_ptr == nullptr)
+ return nullptr;
+
+ return result.release();
+}
+
+SWIGEXPORT int
+LLDBSwigPython_GetIndexOfChildWithName
+(
+ PyObject *implementor,
+ const char* child_name
+)
+{
+ PyErr_Cleaner py_err_cleaner(true);
+
+ PythonObject self(PyRefType::Borrowed, implementor);
+ auto pfunc = self.ResolveName<PythonCallable>("get_child_index");
+
+ if (!pfunc.IsAllocated())
+ return UINT32_MAX;
+
+ llvm::Expected<PythonObject> result = pfunc.Call(PythonString(child_name));
+
+ long long retval = unwrapOrSetPythonException(As<long long>(std::move(result)));
+
+ if (PyErr_Occurred()) {
+ PyErr_Clear(); // FIXME print this? do something else
+ return UINT32_MAX;
+ }
+
+ if (retval >= 0)
+ return (uint32_t)retval;
+
+ return UINT32_MAX;
+}
+
+SWIGEXPORT bool
+LLDBSwigPython_UpdateSynthProviderInstance
+(
+ PyObject *implementor
+)
+{
+ bool ret_val = false;
+
+ static char callee_name[] = "update";
+
+ PyObject* py_return = LLDBSwigPython_CallOptionalMember(implementor,callee_name);
+
+ if (py_return == Py_True)
+ ret_val = true;
+
+ Py_XDECREF(py_return);
+
+ return ret_val;
+}
+
+SWIGEXPORT bool
+LLDBSwigPython_MightHaveChildrenSynthProviderInstance
+(
+ PyObject *implementor
+)
+{
+ bool ret_val = false;
+
+ static char callee_name[] = "has_children";
+
+ PyObject* py_return = LLDBSwigPython_CallOptionalMember(implementor,callee_name, Py_True);
+
+ if (py_return == Py_True)
+ ret_val = true;
+
+ Py_XDECREF(py_return);
+
+ return ret_val;
+}
+
+SWIGEXPORT PyObject*
+LLDBSwigPython_GetValueSynthProviderInstance
+(
+ PyObject *implementor
+)
+{
+ PyObject* ret_val = nullptr;
+
+ static char callee_name[] = "get_value";
+
+ PyObject* py_return = LLDBSwigPython_CallOptionalMember(implementor,callee_name, Py_None);
+
+ if (py_return == Py_None || py_return == nullptr)
+ ret_val = nullptr;
+
+ lldb::SBValue* sbvalue_ptr = NULL;
+
+ if (SWIG_ConvertPtr(py_return, (void**)&sbvalue_ptr, SWIGTYPE_p_lldb__SBValue, 0) == -1)
+ ret_val = nullptr;
+ else if (sbvalue_ptr == NULL)
+ ret_val = nullptr;
+ else
+ ret_val = py_return;
+
+ Py_XDECREF(py_return);
+ return ret_val;
+}
+
+SWIGEXPORT void*
+LLDBSWIGPython_CastPyObjectToSBValue
+(
+ PyObject* data
+)
+{
+ lldb::SBValue* sb_ptr = NULL;
+
+ int valid_cast = SWIG_ConvertPtr(data, (void**)&sb_ptr, SWIGTYPE_p_lldb__SBValue, 0);
+
+ if (valid_cast == -1)
+ return NULL;
+
+ return sb_ptr;
+}
+
+SWIGEXPORT bool
+LLDBSwigPythonCallCommand
+(
+ const char *python_function_name,
+ const char *session_dictionary_name,
+ lldb::DebuggerSP& debugger,
+ const char* args,
+ lldb_private::CommandReturnObject& cmd_retobj,
+ lldb::ExecutionContextRefSP exe_ctx_ref_sp
+)
+{
+ lldb::SBCommandReturnObject cmd_retobj_sb(cmd_retobj);
+ lldb::SBDebugger debugger_sb(debugger);
+ lldb::SBExecutionContext exe_ctx_sb(exe_ctx_ref_sp);
+
+ PyErr_Cleaner py_err_cleaner(true);
+ auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(session_dictionary_name);
+ auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(python_function_name, dict);
+
+ if (!pfunc.IsAllocated())
+ return false;
+
+ // pass the pointer-to cmd_retobj_sb or watch the underlying object disappear from under you
+ // see comment above for SBCommandReturnObjectReleaser for further details
+ auto argc = pfunc.GetArgInfo();
+ if (!argc) {
+ llvm::consumeError(argc.takeError());
+ return false;
+ }
+ PythonObject debugger_arg(PyRefType::Owned, SBTypeToSWIGWrapper(debugger_sb));
+ PythonObject exe_ctx_arg(PyRefType::Owned, SBTypeToSWIGWrapper(exe_ctx_sb));
+ PythonObject cmd_retobj_arg(PyRefType::Owned, SBTypeToSWIGWrapper(&cmd_retobj_sb));
+
+ if (argc.get().max_positional_args < 5u)
+ pfunc(debugger_arg, PythonString(args), cmd_retobj_arg, dict);
+ else
+ pfunc(debugger_arg, PythonString(args), exe_ctx_arg, cmd_retobj_arg, dict);
+
+ return true;
+}
+
+SWIGEXPORT bool
+LLDBSwigPythonCallCommandObject
+(
+ PyObject *implementor,
+ lldb::DebuggerSP& debugger,
+ const char* args,
+ lldb_private::CommandReturnObject& cmd_retobj,
+ lldb::ExecutionContextRefSP exe_ctx_ref_sp
+)
+{
+ lldb::SBCommandReturnObject cmd_retobj_sb(cmd_retobj);
+ lldb::SBDebugger debugger_sb(debugger);
+ lldb::SBExecutionContext exe_ctx_sb(exe_ctx_ref_sp);
+
+ PyErr_Cleaner py_err_cleaner(true);
+
+ PythonObject self(PyRefType::Borrowed, implementor);
+ auto pfunc = self.ResolveName<PythonCallable>("__call__");
+
+ if (!pfunc.IsAllocated())
+ return false;
+
+ // pass the pointer-to cmd_retobj_sb or watch the underlying object disappear from under you
+ // see comment above for SBCommandReturnObjectReleaser for further details
+ PythonObject debugger_arg(PyRefType::Owned, SBTypeToSWIGWrapper(debugger_sb));
+ PythonObject exe_ctx_arg(PyRefType::Owned, SBTypeToSWIGWrapper(exe_ctx_sb));
+ PythonObject cmd_retobj_arg(PyRefType::Owned, SBTypeToSWIGWrapper(&cmd_retobj_sb));
+
+ pfunc(debugger_arg, PythonString(args), exe_ctx_arg, cmd_retobj_arg);
+
+ return true;
+}
+
+SWIGEXPORT void*
+LLDBSWIGPythonCreateOSPlugin
+(
+ const char *python_class_name,
+ const char *session_dictionary_name,
+ const lldb::ProcessSP& process_sp
+)
+{
+ if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name)
+ Py_RETURN_NONE;
+
+ PyErr_Cleaner py_err_cleaner(true);
+
+ auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(session_dictionary_name);
+ auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(python_class_name, dict);
+
+ if (!pfunc.IsAllocated())
+ Py_RETURN_NONE;
+
+ // I do not want the SBProcess to be deallocated when going out of scope because python
+ // has ownership of it and will manage memory for this object by itself
+ lldb::SBProcess *process_sb = new lldb::SBProcess(process_sp);
+ PythonObject process_arg(PyRefType::Owned, SBTypeToSWIGWrapper(process_sb));
+ if (!process_arg.IsAllocated())
+ Py_RETURN_NONE;
+
+ auto result = pfunc(process_arg);
+
+ if (result.IsAllocated())
+ return result.release();
+
+ Py_RETURN_NONE;
+}
+
+SWIGEXPORT void*
+LLDBSWIGPython_CreateFrameRecognizer
+(
+ const char *python_class_name,
+ const char *session_dictionary_name
+)
+{
+ if (python_class_name == NULL || python_class_name[0] == '\0' || !session_dictionary_name)
+ Py_RETURN_NONE;
+
+ PyErr_Cleaner py_err_cleaner(true);
+
+ auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(session_dictionary_name);
+ auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(python_class_name, dict);
+
+ if (!pfunc.IsAllocated())
+ Py_RETURN_NONE;
+
+ auto result = pfunc();
+
+ if (result.IsAllocated())
+ return result.release();
+
+ Py_RETURN_NONE;
+}
+
+SWIGEXPORT PyObject*
+LLDBSwigPython_GetRecognizedArguments
+(
+ PyObject *implementor,
+ const lldb::StackFrameSP& frame_sp
+)
+{
+ static char callee_name[] = "get_recognized_arguments";
+
+ lldb::SBFrame frame_sb(frame_sp);
+ PyObject *arg = SBTypeToSWIGWrapper(frame_sb);
+
+ PythonString str(callee_name);
+ PyObject* result = PyObject_CallMethodObjArgs(implementor, str.get(), arg,
+ NULL);
+ return result;
+}
+
+SWIGEXPORT void*
+LLDBSWIGPython_GetDynamicSetting (void* module, const char* setting, const lldb::TargetSP& target_sp)
+{
+ if (!module || !setting)
+ Py_RETURN_NONE;
+
+ PyErr_Cleaner py_err_cleaner(true);
+ PythonObject py_module(PyRefType::Borrowed, (PyObject *)module);
+ auto pfunc = py_module.ResolveName<PythonCallable>("get_dynamic_setting");
+
+ if (!pfunc.IsAllocated())
+ Py_RETURN_NONE;
+
+ lldb::SBTarget target_sb(target_sp);
+ PythonObject target_arg(PyRefType::Owned, SBTypeToSWIGWrapper(target_sb));
+ auto result = pfunc(target_arg, PythonString(setting));
+
+ return result.release();
+}
+
+SWIGEXPORT bool
+LLDBSWIGPythonRunScriptKeywordProcess
+(const char* python_function_name,
+const char* session_dictionary_name,
+lldb::ProcessSP& process,
+std::string& output)
+
+{
+ if (python_function_name == NULL || python_function_name[0] == '\0' || !session_dictionary_name)
+ return false;
+
+ PyErr_Cleaner py_err_cleaner(true);
+
+ auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(session_dictionary_name);
+ auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(python_function_name, dict);
+
+ if (!pfunc.IsAllocated())
+ return false;
+
+ lldb::SBProcess process_sb(process);
+ PythonObject process_arg(PyRefType::Owned, SBTypeToSWIGWrapper(process_sb));
+ auto result = pfunc(process_arg, dict);
+
+ output = result.Str().GetString().str();
+
+ return true;
+}
+
+SWIGEXPORT bool
+LLDBSWIGPythonRunScriptKeywordThread
+(const char* python_function_name,
+const char* session_dictionary_name,
+lldb::ThreadSP& thread,
+std::string& output)
+
+{
+ if (python_function_name == NULL || python_function_name[0] == '\0' || !session_dictionary_name)
+ return false;
+
+ PyErr_Cleaner py_err_cleaner(true);
+
+ auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(session_dictionary_name);
+ auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(python_function_name, dict);
+
+ if (!pfunc.IsAllocated())
+ return false;
+
+ lldb::SBThread thread_sb(thread);
+ PythonObject thread_arg(PyRefType::Owned, SBTypeToSWIGWrapper(thread_sb));
+ auto result = pfunc(thread_arg, dict);
+
+ output = result.Str().GetString().str();
+
+ return true;
+}
+
+SWIGEXPORT bool
+LLDBSWIGPythonRunScriptKeywordTarget
+(const char* python_function_name,
+const char* session_dictionary_name,
+lldb::TargetSP& target,
+std::string& output)
+
+{
+ if (python_function_name == NULL || python_function_name[0] == '\0' || !session_dictionary_name)
+ return false;
+
+ PyErr_Cleaner py_err_cleaner(true);
+
+ auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(session_dictionary_name);
+ auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(python_function_name,dict);
+
+ if (!pfunc.IsAllocated())
+ return false;
+
+ lldb::SBTarget target_sb(target);
+ PythonObject target_arg(PyRefType::Owned, SBTypeToSWIGWrapper(target_sb));
+ auto result = pfunc(target_arg, dict);
+
+ output = result.Str().GetString().str();
+
+ return true;
+}
+
+SWIGEXPORT bool
+LLDBSWIGPythonRunScriptKeywordFrame
+(const char* python_function_name,
+const char* session_dictionary_name,
+lldb::StackFrameSP& frame,
+std::string& output)
+
+{
+ if (python_function_name == NULL || python_function_name[0] == '\0' || !session_dictionary_name)
+ return false;
+
+ PyErr_Cleaner py_err_cleaner(true);
+
+ auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(session_dictionary_name);
+ auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(python_function_name,dict);
+
+ if (!pfunc.IsAllocated())
+ return false;
+
+ lldb::SBFrame frame_sb(frame);
+ PythonObject frame_arg(PyRefType::Owned, SBTypeToSWIGWrapper(frame_sb));
+ auto result = pfunc(frame_arg, dict);
+
+ output = result.Str().GetString().str();
+
+ return true;
+}
+
+SWIGEXPORT bool
+LLDBSWIGPythonRunScriptKeywordValue
+(const char* python_function_name,
+const char* session_dictionary_name,
+lldb::ValueObjectSP& value,
+std::string& output)
+
+{
+ if (python_function_name == NULL || python_function_name[0] == '\0' || !session_dictionary_name)
+ return false;
+
+ PyErr_Cleaner py_err_cleaner(true);
+
+ auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(session_dictionary_name);
+ auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(python_function_name, dict);
+
+ if (!pfunc.IsAllocated())
+ return false;
+
+ lldb::SBValue value_sb(value);
+ PythonObject value_arg(PyRefType::Owned, SBTypeToSWIGWrapper(value_sb));
+ auto result = pfunc(value_arg, dict);
+
+ output = result.Str().GetString().str();
+
+ return true;
+}
+
+SWIGEXPORT bool
+LLDBSwigPythonCallModuleInit
+(
+ const char *python_module_name,
+ const char *session_dictionary_name,
+ lldb::DebuggerSP& debugger
+)
+{
+ std::string python_function_name_string = python_module_name;
+ python_function_name_string += ".__lldb_init_module";
+ const char* python_function_name = python_function_name_string.c_str();
+
+ PyErr_Cleaner py_err_cleaner(true);
+
+ auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>(session_dictionary_name);
+ auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>(python_function_name, dict);
+
+ // This method is optional and need not exist. So if we don't find it,
+ // it's actually a success, not a failure.
+ if (!pfunc.IsAllocated())
+ return true;
+
+ lldb::SBDebugger debugger_sb(debugger);
+ PythonObject debugger_arg(PyRefType::Owned, SBTypeToSWIGWrapper(debugger_sb));
+ pfunc(debugger_arg, dict);
+
+ return true;
+}
+%}
+
+
+%runtime %{
+// Forward declaration to be inserted at the start of LLDBWrapPython.h
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBValue.h"
+
+SWIGEXPORT lldb::ValueObjectSP
+LLDBSWIGPython_GetValueObjectSPFromSBValue (void* data)
+{
+ lldb::ValueObjectSP valobj_sp;
+ if (data)
+ {
+ lldb::SBValue* sb_ptr = (lldb::SBValue *)data;
+ valobj_sp = sb_ptr->GetSP();
+ }
+ return valobj_sp;
+}
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void LLDBSwigPythonCallPythonLogOutputCallback(const char *str, void *baton);
+
+#ifdef __cplusplus
+}
+#endif
+%}
+
+%wrapper %{
+
+
+// For the LogOutputCallback functions
+void LLDBSwigPythonCallPythonLogOutputCallback(const char *str, void *baton) {
+ if (baton != Py_None) {
+ SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+ PyObject *result = PyObject_CallFunction(reinterpret_cast<PyObject*>(baton), const_cast<char*>("s"), str);
+ Py_XDECREF(result);
+ SWIG_PYTHON_THREAD_END_BLOCK;
+ }
+}
+%}
diff --git a/lldb/docs/man/lldb.rst b/lldb/docs/man/lldb.rst
index b4972df1b601..87be124d788e 100644
--- a/lldb/docs/man/lldb.rst
+++ b/lldb/docs/man/lldb.rst
@@ -251,11 +251,16 @@ EXAMPLES
The debugger can be started in several modes.
-Passing an executable as a positional argument prepares :program:`lldb` to
-debug the given executable. Arguments passed after -- are considered arguments
-to the debugged executable.
+Passing an executable as a positional argument prepares lldb to debug the given
+executable. To disambiguate between arguments passed to lldb and arguments
+passed to the debugged executable, arguments starting with a - must be passed
+after --.
- lldb --arch x86_64 /path/to/program -- --arch arvm7
+ lldb --arch x86_64 /path/to/program program argument -- --arch arvm7
+
+For convenience, passing the executable after -- is also supported.
+
+ lldb --arch x86_64 -- /path/to/program program argument --arch arvm7
Passing one of the attach options causes :program:`lldb` to immediately attach
to the given process.
@@ -298,7 +303,14 @@ CONFIGURATION FILES
-------------------
:program:`lldb` reads things like settings, aliases and commands from the
-.lldbinit file. It will first look for ~/.lldbinit and load that first.
+.lldbinit file.
+
+First, it will read the application specific init file whose name is
+~/.lldbinit followed by a "-" and the name of the current program. This would
+be ~/.lldbinit-lldb for the command line :program:`lldb` and ~/.lldbinit-Xcode
+for Xcode. If there is no application specific init file, the global
+~/.lldbinit is read.
+
Secondly, it will look for an .lldbinit file in the current working directory.
For security reasons, :program:`lldb` will print a warning and not source this
file by default. This behavior can be changed by changing the
diff --git a/lldb/include/lldb/API/LLDB.h b/lldb/include/lldb/API/LLDB.h
index 75e2d70c0c39..83c38d3b6166 100644
--- a/lldb/include/lldb/API/LLDB.h
+++ b/lldb/include/lldb/API/LLDB.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_LLDB_h_
-#define LLDB_LLDB_h_
+#ifndef LLDB_API_LLDB_H
+#define LLDB_API_LLDB_H
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBAttachInfo.h"
@@ -24,6 +24,7 @@
#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBDeclaration.h"
#include "lldb/API/SBDefines.h"
+#include "lldb/API/SBEnvironment.h"
#include "lldb/API/SBError.h"
#include "lldb/API/SBEvent.h"
#include "lldb/API/SBExecutionContext.h"
@@ -78,4 +79,4 @@
#include "lldb/API/SBVariablesOptions.h"
#include "lldb/API/SBWatchpoint.h"
-#endif // LLDB_LLDB_h_
+#endif // LLDB_API_LLDB_H
diff --git a/lldb/include/lldb/API/SBAddress.h b/lldb/include/lldb/API/SBAddress.h
index 2874a3602af2..cf7555dc2ee8 100644
--- a/lldb/include/lldb/API/SBAddress.h
+++ b/lldb/include/lldb/API/SBAddress.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBAddress_h_
-#define LLDB_SBAddress_h_
+#ifndef LLDB_API_SBADDRESS_H
+#define LLDB_API_SBADDRESS_H
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBModule.h"
@@ -127,4 +127,4 @@ bool LLDB_API operator==(const SBAddress &lhs, const SBAddress &rhs);
} // namespace lldb
-#endif // LLDB_SBAddress_h_
+#endif // LLDB_API_SBADDRESS_H
diff --git a/lldb/include/lldb/API/SBAttachInfo.h b/lldb/include/lldb/API/SBAttachInfo.h
index 3c20a08cb4a9..9b211d0f74bd 100644
--- a/lldb/include/lldb/API/SBAttachInfo.h
+++ b/lldb/include/lldb/API/SBAttachInfo.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBAttachInfo_h_
-#define LLDB_SBAttachInfo_h_
+#ifndef LLDB_API_SBATTACHINFO_H
+#define LLDB_API_SBATTACHINFO_H
#include "lldb/API/SBDefines.h"
@@ -174,4 +174,4 @@ protected:
} // namespace lldb
-#endif // LLDB_SBAttachInfo_h_
+#endif // LLDB_API_SBATTACHINFO_H
diff --git a/lldb/include/lldb/API/SBBlock.h b/lldb/include/lldb/API/SBBlock.h
index 0ca92ff0c6ac..be1ae18e9db5 100644
--- a/lldb/include/lldb/API/SBBlock.h
+++ b/lldb/include/lldb/API/SBBlock.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBBlock_h_
-#define LLDB_SBBlock_h_
+#ifndef LLDB_API_SBBLOCK_H
+#define LLDB_API_SBBLOCK_H
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBFrame.h"
@@ -92,4 +92,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBBlock_h_
+#endif // LLDB_API_SBBLOCK_H
diff --git a/lldb/include/lldb/API/SBBreakpoint.h b/lldb/include/lldb/API/SBBreakpoint.h
index a5ce91d95089..c9a52fcacf1a 100644
--- a/lldb/include/lldb/API/SBBreakpoint.h
+++ b/lldb/include/lldb/API/SBBreakpoint.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBBreakpoint_h_
-#define LLDB_SBBreakpoint_h_
+#ifndef LLDB_API_SBBREAKPOINT_H
+#define LLDB_API_SBBREAKPOINT_H
#include "lldb/API/SBDefines.h"
@@ -105,6 +105,8 @@ public:
bool AddName(const char *new_name);
+ SBError AddNameWithErrorHandling(const char *new_name);
+
void RemoveName(const char *name_to_remove);
bool MatchesName(const char *name);
@@ -181,4 +183,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBBreakpoint_h_
+#endif // LLDB_API_SBBREAKPOINT_H
diff --git a/lldb/include/lldb/API/SBBreakpointLocation.h b/lldb/include/lldb/API/SBBreakpointLocation.h
index a9e2ef1dd1b8..a906727f938a 100644
--- a/lldb/include/lldb/API/SBBreakpointLocation.h
+++ b/lldb/include/lldb/API/SBBreakpointLocation.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBBreakpointLocation_h_
-#define LLDB_SBBreakpointLocation_h_
+#ifndef LLDB_API_SBBREAKPOINTLOCATION_H
+#define LLDB_API_SBBREAKPOINTLOCATION_H
#include "lldb/API/SBBreakpoint.h"
#include "lldb/API/SBDefines.h"
@@ -100,4 +100,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBBreakpointLocation_h_
+#endif // LLDB_API_SBBREAKPOINTLOCATION_H
diff --git a/lldb/include/lldb/API/SBBreakpointName.h b/lldb/include/lldb/API/SBBreakpointName.h
index 3a5f1acf3e4a..8dd2c4e5ef34 100644
--- a/lldb/include/lldb/API/SBBreakpointName.h
+++ b/lldb/include/lldb/API/SBBreakpointName.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBBreakpointName_h_
-#define LLDB_SBBreakpointName_h_
+#ifndef LLDB_API_SBBREAKPOINTNAME_H
+#define LLDB_API_SBBREAKPOINTNAME_H
#include "lldb/API/SBDefines.h"
@@ -119,4 +119,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBBreakpointName_h_
+#endif // LLDB_API_SBBREAKPOINTNAME_H
diff --git a/lldb/include/lldb/API/SBBroadcaster.h b/lldb/include/lldb/API/SBBroadcaster.h
index fc5e8880e9f2..69a516a8bfb1 100644
--- a/lldb/include/lldb/API/SBBroadcaster.h
+++ b/lldb/include/lldb/API/SBBroadcaster.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBBroadcaster_h_
-#define LLDB_SBBroadcaster_h_
+#ifndef LLDB_API_SBBROADCASTER_H
+#define LLDB_API_SBBROADCASTER_H
#include "lldb/API/SBDefines.h"
@@ -81,4 +81,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBBroadcaster_h_
+#endif // LLDB_API_SBBROADCASTER_H
diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h b/lldb/include/lldb/API/SBCommandInterpreter.h
index 6c80e8eb26dc..a70e060bec99 100644
--- a/lldb/include/lldb/API/SBCommandInterpreter.h
+++ b/lldb/include/lldb/API/SBCommandInterpreter.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBCommandInterpreter_h_
-#define LLDB_SBCommandInterpreter_h_
+#ifndef LLDB_API_SBCOMMANDINTERPRETER_H
+#define LLDB_API_SBCOMMANDINTERPRETER_H
#include <memory>
@@ -16,52 +16,6 @@
namespace lldb {
-class LLDB_API SBCommandInterpreterRunOptions {
- friend class SBDebugger;
- friend class SBCommandInterpreter;
-
-public:
- SBCommandInterpreterRunOptions();
- ~SBCommandInterpreterRunOptions();
-
- bool GetStopOnContinue() const;
-
- void SetStopOnContinue(bool);
-
- bool GetStopOnError() const;
-
- void SetStopOnError(bool);
-
- bool GetStopOnCrash() const;
-
- void SetStopOnCrash(bool);
-
- bool GetEchoCommands() const;
-
- void SetEchoCommands(bool);
-
- bool GetEchoCommentCommands() const;
-
- void SetEchoCommentCommands(bool echo);
-
- bool GetPrintResults() const;
-
- void SetPrintResults(bool);
-
- bool GetAddToHistory() const;
-
- void SetAddToHistory(bool);
-
-private:
- lldb_private::CommandInterpreterRunOptions *get() const;
-
- lldb_private::CommandInterpreterRunOptions &ref() const;
-
- // This is set in the constructor and will always be valid.
- mutable std::unique_ptr<lldb_private::CommandInterpreterRunOptions>
- m_opaque_up;
-};
-
class SBCommandInterpreter {
public:
enum {
@@ -111,14 +65,86 @@ public:
lldb::SBCommand AddMultiwordCommand(const char *name, const char *help);
+ /// Add a new command to the lldb::CommandInterpreter.
+ ///
+ /// The new command won't support autorepeat. If you need this functionality,
+ /// use the override of this function that accepts the \a auto_repeat_command
+ /// parameter.
+ ///
+ /// \param[in] name
+ /// The name of the command.
+ ///
+ /// \param[in] impl
+ /// The handler of this command.
+ ///
+ /// \param[in] help
+ /// The general description to show as part of the help message of this
+ /// command.
+ ///
+ /// \return
+ /// A lldb::SBCommand representing the newly created command.
lldb::SBCommand AddCommand(const char *name,
lldb::SBCommandPluginInterface *impl,
const char *help);
+ /// Add a new command to the lldb::CommandInterpreter.
+ ///
+ /// The new command won't support autorepeat. If you need this functionality,
+ /// use the override of this function that accepts the \a auto_repeat_command
+ /// parameter.
+ ///
+ /// \param[in] name
+ /// The name of the command.
+ ///
+ /// \param[in] impl
+ /// The handler of this command.
+ ///
+ /// \param[in] help
+ /// The general description to show as part of the help message of this
+ /// command.
+ ///
+ /// \param[in] syntax
+ /// The syntax to show as part of the help message of this command. This
+ /// could include a description of the different arguments and flags this
+ /// command accepts.
+ ///
+ /// \return
+ /// A lldb::SBCommand representing the newly created command.
lldb::SBCommand AddCommand(const char *name,
lldb::SBCommandPluginInterface *impl,
const char *help, const char *syntax);
+ /// Add a new command to the lldb::CommandInterpreter.
+ ///
+ /// \param[in] name
+ /// The name of the command.
+ ///
+ /// \param[in] impl
+ /// The handler of this command.
+ ///
+ /// \param[in] help
+ /// The general description to show as part of the help message of this
+ /// command.
+ ///
+ /// \param[in] syntax
+ /// The syntax to show as part of the help message of this command. This
+ /// could include a description of the different arguments and flags this
+ /// command accepts.
+ ///
+ /// \param[in] auto_repeat_command
+ /// Autorepeating is triggered when the user presses Enter successively
+ /// after executing a command. If \b nullptr is provided, the previous
+ /// exact command will be repeated. If \b "" is provided, autorepeating
+ /// is disabled. Otherwise, the provided string is used as a repeat
+ /// command.
+ ///
+ /// \return
+ /// A lldb::SBCommand representing the newly created command.
+ lldb::SBCommand AddCommand(const char *name,
+ lldb::SBCommandPluginInterface *impl,
+ const char *help, const char *syntax,
+ const char *auto_repeat_command);
+
void SourceInitFileInHomeDirectory(lldb::SBCommandReturnObject &result);
void
@@ -283,14 +309,90 @@ public:
lldb::SBCommand AddMultiwordCommand(const char *name,
const char *help = nullptr);
+ /// Add a new subcommand to the lldb::SBCommand.
+ ///
+ /// The new command won't support autorepeat. If you need this functionality,
+ /// use the override of this function that accepts the \a auto_repeat
+ /// parameter.
+ ///
+ /// \param[in] name
+ /// The name of the command.
+ ///
+ /// \param[in] impl
+ /// The handler of this command.
+ ///
+ /// \param[in] help
+ /// The general description to show as part of the help message of this
+ /// command.
+ ///
+ /// \return
+ /// A lldb::SBCommand representing the newly created command.
lldb::SBCommand AddCommand(const char *name,
lldb::SBCommandPluginInterface *impl,
const char *help = nullptr);
+ /// Add a new subcommand to the lldb::SBCommand.
+ ///
+ /// The new command won't support autorepeat. If you need this functionality,
+ /// use the override of this function that accepts the \a auto_repeat_command
+ /// parameter.
+ ///
+ /// \param[in] name
+ /// The name of the command.
+ ///
+ /// \param[in] impl
+ /// The handler of this command.
+ ///
+ /// \param[in] help
+ /// The general description to show as part of the help message of this
+ /// command.
+ ///
+ /// \param[in] syntax
+ /// The syntax to show as part of the help message of this command. This
+ /// could include a description of the different arguments and flags this
+ /// command accepts.
+ ///
+ /// \return
+ /// A lldb::SBCommand representing the newly created command.
lldb::SBCommand AddCommand(const char *name,
lldb::SBCommandPluginInterface *impl,
const char *help, const char *syntax);
+ /// Add a new subcommand to the lldb::SBCommand.
+ ///
+ /// The new command won't support autorepeat. If you need this functionality,
+ /// use the override of this function that accepts the \a auto_repeat_command
+ /// parameter.
+ ///
+ /// \param[in] name
+ /// The name of the command.
+ ///
+ /// \param[in] impl
+ /// The handler of this command.
+ ///
+ /// \param[in] help
+ /// The general description to show as part of the help message of this
+ /// command.
+ ///
+ /// \param[in] syntax
+ /// The syntax to show as part of the help message of this command. This
+ /// could include a description of the different arguments and flags this
+ /// command accepts.
+ ///
+ /// \param[in] auto_repeat_command
+ /// Autorepeating is triggered when the user presses Enter successively
+ /// after executing a command. If \b nullptr is provided, the previous
+ /// exact command will be repeated. If \b "" is provided, autorepeating
+ /// is disabled. Otherwise, the provided string is used as a repeat
+ /// command.
+ ///
+ /// \return
+ /// A lldb::SBCommand representing the newly created command.
+ lldb::SBCommand AddCommand(const char *name,
+ lldb::SBCommandPluginInterface *impl,
+ const char *help, const char *syntax,
+ const char *auto_repeat_command);
+
private:
friend class SBDebugger;
friend class SBCommandInterpreter;
@@ -302,4 +404,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBCommandInterpreter_h_
+#endif // LLDB_API_SBCOMMANDINTERPRETER_H
diff --git a/lldb/include/lldb/API/SBCommandInterpreterRunOptions.h b/lldb/include/lldb/API/SBCommandInterpreterRunOptions.h
new file mode 100644
index 000000000000..82d6feedc02e
--- /dev/null
+++ b/lldb/include/lldb/API/SBCommandInterpreterRunOptions.h
@@ -0,0 +1,102 @@
+//===-- SBCommandInterpreterRunOptions.h ------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_API_SBCOMMANDINTERPRETERRUNOPTIONS_H
+#define LLDB_API_SBCOMMANDINTERPRETERRUNOPTIONS_H
+
+#include <memory>
+
+#include "lldb/API/SBDefines.h"
+
+namespace lldb_private {
+class CommandInterpreterRunOptions;
+class CommandInterpreterRunResult;
+} // namespace lldb_private
+
+namespace lldb {
+
+class LLDB_API SBCommandInterpreterRunOptions {
+ friend class SBDebugger;
+ friend class SBCommandInterpreter;
+
+public:
+ SBCommandInterpreterRunOptions();
+ ~SBCommandInterpreterRunOptions();
+
+ bool GetStopOnContinue() const;
+
+ void SetStopOnContinue(bool);
+
+ bool GetStopOnError() const;
+
+ void SetStopOnError(bool);
+
+ bool GetStopOnCrash() const;
+
+ void SetStopOnCrash(bool);
+
+ bool GetEchoCommands() const;
+
+ void SetEchoCommands(bool);
+
+ bool GetEchoCommentCommands() const;
+
+ void SetEchoCommentCommands(bool echo);
+
+ bool GetPrintResults() const;
+
+ void SetPrintResults(bool);
+
+ bool GetAddToHistory() const;
+
+ void SetAddToHistory(bool);
+
+ bool GetAutoHandleEvents() const;
+
+ void SetAutoHandleEvents(bool);
+
+ bool GetSpawnThread() const;
+
+ void SetSpawnThread(bool);
+
+private:
+ lldb_private::CommandInterpreterRunOptions *get() const;
+
+ lldb_private::CommandInterpreterRunOptions &ref() const;
+
+ // This is set in the constructor and will always be valid.
+ mutable std::unique_ptr<lldb_private::CommandInterpreterRunOptions>
+ m_opaque_up;
+};
+
+class LLDB_API SBCommandInterpreterRunResult {
+ friend class SBDebugger;
+ friend class SBCommandInterpreter;
+
+public:
+ SBCommandInterpreterRunResult();
+ SBCommandInterpreterRunResult(const SBCommandInterpreterRunResult &rhs);
+ ~SBCommandInterpreterRunResult();
+
+ SBCommandInterpreterRunResult &
+ operator=(const SBCommandInterpreterRunResult &rhs);
+
+ int GetNumberOfErrors() const;
+ lldb::CommandInterpreterResult GetResult() const;
+
+private:
+ SBCommandInterpreterRunResult(
+ const lldb_private::CommandInterpreterRunResult &rhs);
+
+ // This is set in the constructor and will always be valid.
+ std::unique_ptr<lldb_private::CommandInterpreterRunResult> m_opaque_up;
+};
+
+} // namespace lldb
+
+#endif // LLDB_API_SBCOMMANDINTERPRETERRUNOPTIONS_H
diff --git a/lldb/include/lldb/API/SBCommandReturnObject.h b/lldb/include/lldb/API/SBCommandReturnObject.h
index e3fbacf85afc..4ee296eb1797 100644
--- a/lldb/include/lldb/API/SBCommandReturnObject.h
+++ b/lldb/include/lldb/API/SBCommandReturnObject.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBCommandReturnObject_h_
-#define LLDB_SBCommandReturnObject_h_
+#ifndef LLDB_API_SBCOMMANDRETURNOBJECT_H
+#define LLDB_API_SBCOMMANDRETURNOBJECT_H
#include <stdio.h>
@@ -124,4 +124,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBCommandReturnObject_h_
+#endif // LLDB_API_SBCOMMANDRETURNOBJECT_H
diff --git a/lldb/include/lldb/API/SBCommunication.h b/lldb/include/lldb/API/SBCommunication.h
index 5b803fc6017c..84c341c0dfef 100644
--- a/lldb/include/lldb/API/SBCommunication.h
+++ b/lldb/include/lldb/API/SBCommunication.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBCommunication_h_
-#define LLDB_SBCommunication_h_
+#ifndef LLDB_API_SBCOMMUNICATION_H
+#define LLDB_API_SBCOMMUNICATION_H
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBError.h"
@@ -72,7 +72,8 @@ public:
void *callback_baton);
private:
- DISALLOW_COPY_AND_ASSIGN(SBCommunication);
+ SBCommunication(const SBCommunication &) = delete;
+ const SBCommunication &operator=(const SBCommunication &) = delete;
lldb_private::Communication *m_opaque;
bool m_opaque_owned;
@@ -80,4 +81,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBCommunication_h_
+#endif // LLDB_API_SBCOMMUNICATION_H
diff --git a/lldb/include/lldb/API/SBCompileUnit.h b/lldb/include/lldb/API/SBCompileUnit.h
index b6b138207d60..0c05ef44e31c 100644
--- a/lldb/include/lldb/API/SBCompileUnit.h
+++ b/lldb/include/lldb/API/SBCompileUnit.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBCompileUnit_h_
-#define LLDB_SBCompileUnit_h_
+#ifndef LLDB_API_SBCOMPILEUNIT_H
+#define LLDB_API_SBCOMPILEUNIT_H
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBFileSpec.h"
@@ -92,4 +92,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBCompileUnit_h_
+#endif // LLDB_API_SBCOMPILEUNIT_H
diff --git a/lldb/include/lldb/API/SBData.h b/lldb/include/lldb/API/SBData.h
index 886fe829a469..95c8086d5d47 100644
--- a/lldb/include/lldb/API/SBData.h
+++ b/lldb/include/lldb/API/SBData.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBData_h_
-#define LLDB_SBData_h_
+#ifndef LLDB_API_SBDATA_H
+#define LLDB_API_SBDATA_H
#include "lldb/API/SBDefines.h"
@@ -152,4 +152,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBData_h_
+#endif // LLDB_API_SBDATA_H
diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h
index 580f6281fbb6..b3bfa230139c 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBDebugger_h_
-#define LLDB_SBDebugger_h_
+#ifndef LLDB_API_SBDEBUGGER_H
+#define LLDB_API_SBDEBUGGER_H
#include <stdio.h>
@@ -199,6 +199,10 @@ public:
bool GetUseColor() const;
+ bool SetUseSourceCache(bool use_source_cache);
+
+ bool GetUseSourceCache() const;
+
static bool GetDefaultArchitecture(char *arch_name, size_t arch_name_len);
static bool SetDefaultArchitecture(const char *arch_name);
@@ -286,13 +290,50 @@ public:
SBTypeSynthetic GetSyntheticForType(SBTypeNameSpecifier);
+ /// Run the command interpreter.
+ ///
+ /// \param[in] auto_handle_events
+ /// If true, automatically handle resulting events. This takes precedence
+ /// and overrides the corresponding option in
+ /// SBCommandInterpreterRunOptions.
+ ///
+ /// \param[in] spawn_thread
+ /// If true, start a new thread for IO handling. This takes precedence
+ /// and overrides the corresponding option in
+ /// SBCommandInterpreterRunOptions.
void RunCommandInterpreter(bool auto_handle_events, bool spawn_thread);
+ /// Run the command interpreter.
+ ///
+ /// \param[in] auto_handle_events
+ /// If true, automatically handle resulting events. This takes precedence
+ /// and overrides the corresponding option in
+ /// SBCommandInterpreterRunOptions.
+ ///
+ /// \param[in] spawn_thread
+ /// If true, start a new thread for IO handling. This takes precedence
+ /// and overrides the corresponding option in
+ /// SBCommandInterpreterRunOptions.
+ ///
+ /// \param[in] options
+ /// Parameter collection of type SBCommandInterpreterRunOptions.
+ ///
+ /// \param[out] num_errors
+ /// The number of errors.
+ ///
+ /// \param[out] quit_requested
+ /// Whether a quit was requested.
+ ///
+ /// \param[out] stopped_for_crash
+ /// Whether the interpreter stopped for a crash.
void RunCommandInterpreter(bool auto_handle_events, bool spawn_thread,
SBCommandInterpreterRunOptions &options,
int &num_errors, bool &quit_requested,
bool &stopped_for_crash);
+ SBCommandInterpreterRunResult
+ RunCommandInterpreter(const SBCommandInterpreterRunOptions &options);
+
SBError RunREPL(lldb::LanguageType language, const char *repl_options);
private:
@@ -319,4 +360,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBDebugger_h_
+#endif // LLDB_API_SBDEBUGGER_H
diff --git a/lldb/include/lldb/API/SBDeclaration.h b/lldb/include/lldb/API/SBDeclaration.h
index d2b423e40fec..aeaa28e1cada 100644
--- a/lldb/include/lldb/API/SBDeclaration.h
+++ b/lldb/include/lldb/API/SBDeclaration.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBDeclaration_h_
-#define LLDB_SBDeclaration_h_
+#ifndef LLDB_API_SBDECLARATION_H
+#define LLDB_API_SBDECLARATION_H
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBFileSpec.h"
@@ -68,4 +68,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBDeclaration_h_
+#endif // LLDB_API_SBDECLARATION_H
diff --git a/lldb/include/lldb/API/SBDefines.h b/lldb/include/lldb/API/SBDefines.h
index 68aca930d199..a5b639c6dc73 100644
--- a/lldb/include/lldb/API/SBDefines.h
+++ b/lldb/include/lldb/API/SBDefines.h
@@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBDefines_h_
-#define LLDB_SBDefines_h_
-
+#ifndef LLDB_API_SBDEFINES_H
+#define LLDB_API_SBDEFINES_H
#include "lldb/lldb-defines.h"
#include "lldb/lldb-enumerations.h"
@@ -29,6 +28,7 @@ class LLDB_API SBBroadcaster;
class LLDB_API SBCommand;
class LLDB_API SBCommandInterpreter;
class LLDB_API SBCommandInterpreterRunOptions;
+class LLDB_API SBCommandInterpreterRunResult;
class LLDB_API SBCommandPluginInterface;
class LLDB_API SBCommandReturnObject;
class LLDB_API SBCommunication;
@@ -36,6 +36,7 @@ class LLDB_API SBCompileUnit;
class LLDB_API SBData;
class LLDB_API SBDebugger;
class LLDB_API SBDeclaration;
+class LLDB_API SBEnvironment;
class LLDB_API SBError;
class LLDB_API SBEvent;
class LLDB_API SBEventList;
@@ -99,4 +100,4 @@ typedef bool (*SBBreakpointHitCallback)(void *baton, SBProcess &process,
lldb::SBBreakpointLocation &location);
}
-#endif // LLDB_SBDefines_h_
+#endif // LLDB_API_SBDEFINES_H
diff --git a/lldb/include/lldb/API/SBEnvironment.h b/lldb/include/lldb/API/SBEnvironment.h
new file mode 100644
index 000000000000..f40ee01a42ab
--- /dev/null
+++ b/lldb/include/lldb/API/SBEnvironment.h
@@ -0,0 +1,137 @@
+//===-- SBEnvironment.h -----------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_API_SBENVIRONMENT_H
+#define LLDB_API_SBENVIRONMENT_H
+
+#include "lldb/API/SBDefines.h"
+
+namespace lldb {
+
+class LLDB_API SBEnvironment {
+public:
+ SBEnvironment();
+
+ SBEnvironment(const lldb::SBEnvironment &rhs);
+
+ ~SBEnvironment();
+
+ const lldb::SBEnvironment &operator=(const lldb::SBEnvironment &rhs);
+
+ /// Return the value of a given environment variable.
+ ///
+ /// \param [in] name
+ /// The name of the environment variable.
+ ///
+ /// \return
+ /// The value of the environment variable or null if not present.
+ /// If the environment variable has no value but is present, a valid
+ /// pointer to an empty string will be returned.
+ const char *Get(const char *name);
+
+ /// \return
+ /// The number of environment variables.
+ size_t GetNumValues();
+
+ /// Return the name of the environment variable at a given index from the
+ /// internal list of environment variables.
+ ///
+ /// \param [in] index
+ /// The index of the environment variable in the internal list.
+ ///
+ /// \return
+ /// The name at the given index or null if the index is invalid.
+ const char *GetNameAtIndex(size_t index);
+
+ /// Return the value of the environment variable at a given index from the
+ /// internal list of environment variables.
+ ///
+ /// \param [in] index
+ /// The index of the environment variable in the internal list.
+ ///
+ /// \return
+ /// The value at the given index or null if the index is invalid.
+ /// If the environment variable has no value but is present, a valid
+ /// pointer to an empty string will be returned.
+ const char *GetValueAtIndex(size_t index);
+
+ /// Return all environment variables contained in this object. Each variable
+ /// is returned as a string with the following format
+ /// name=value
+ ///
+ /// \return
+ /// Return an lldb::SBStringList object with the environment variables.
+ SBStringList GetEntries();
+
+ /// Add or replace an existing environment variable. The input must be a
+ /// string with the format
+ /// name=value
+ ///
+ /// \param [in] name_and_value
+ /// The entry to set which conforms to the format mentioned above.
+ void PutEntry(const char *name_and_value);
+
+ /// Update this object with the given environment variables. The input is a
+ /// list of entries with the same format required by SBEnvironment::PutEntry.
+ ///
+ /// If append is false, the provided environment will replace the existing
+ /// environment. Otherwise, existing values will be updated of left untouched
+ /// accordingly.
+ ///
+ /// \param [in] entries
+ /// The environment variable entries.
+ ///
+ /// \param [in] append
+ /// Flag that controls whether to replace the existing environment.
+ void SetEntries(const SBStringList &entries, bool append);
+
+ /// Set the value of a given environment variable.
+ /// If the variable exists, its value is updated only if overwrite is true.
+ ///
+ /// \param [in] name
+ /// The name of the environment variable to set.
+ ///
+ /// \param [in] value
+ /// The value of the environment variable to set.
+ ///
+ /// \param [in] overwrite
+ /// Flag that indicates whether to overwrite an existing environment
+ /// variable.
+ ///
+ /// \return
+ /// Return whether the variable was added or modified.
+ bool Set(const char *name, const char *value, bool overwrite);
+
+ /// Unset an environment variable if exists.
+ ///
+ /// \param [in] name
+ /// The name of the environment variable to unset.
+ ///
+ /// \return
+ /// Return whether a variable was actually unset.
+ bool Unset(const char *name);
+
+ /// Delete all the environment variables.
+ void Clear();
+
+protected:
+ friend class SBPlatform;
+ friend class SBTarget;
+ friend class SBLaunchInfo;
+
+ SBEnvironment(lldb_private::Environment rhs);
+
+ lldb_private::Environment &ref() const;
+
+private:
+ std::unique_ptr<lldb_private::Environment> m_opaque_up;
+};
+
+} // namespace lldb
+
+#endif // LLDB_API_SBENVIRONMENT_H
diff --git a/lldb/include/lldb/API/SBError.h b/lldb/include/lldb/API/SBError.h
index 3db2658d9fb7..e1960ef9a983 100644
--- a/lldb/include/lldb/API/SBError.h
+++ b/lldb/include/lldb/API/SBError.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBError_h_
-#define LLDB_SBError_h_
+#ifndef LLDB_API_SBERROR_H
+#define LLDB_API_SBERROR_H
#include "lldb/API/SBDefines.h"
@@ -90,4 +90,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBError_h_
+#endif // LLDB_API_SBERROR_H
diff --git a/lldb/include/lldb/API/SBEvent.h b/lldb/include/lldb/API/SBEvent.h
index d297cbeff671..a7975bf9abae 100644
--- a/lldb/include/lldb/API/SBEvent.h
+++ b/lldb/include/lldb/API/SBEvent.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBEvent_h_
-#define LLDB_SBEvent_h_
+#ifndef LLDB_API_SBEVENT_H
+#define LLDB_API_SBEVENT_H
#include "lldb/API/SBDefines.h"
@@ -84,4 +84,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBEvent_h_
+#endif // LLDB_API_SBEVENT_H
diff --git a/lldb/include/lldb/API/SBExecutionContext.h b/lldb/include/lldb/API/SBExecutionContext.h
index 45c0b1b7f97b..d8447aeb1a2f 100644
--- a/lldb/include/lldb/API/SBExecutionContext.h
+++ b/lldb/include/lldb/API/SBExecutionContext.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBExecutionContext_h_
-#define LLDB_SBExecutionContext_h_
+#ifndef LLDB_API_SBEXECUTIONCONTEXT_H
+#define LLDB_API_SBEXECUTIONCONTEXT_H
#include "lldb/API/SBDefines.h"
@@ -60,4 +60,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBExecutionContext_h_
+#endif // LLDB_API_SBEXECUTIONCONTEXT_H
diff --git a/lldb/include/lldb/API/SBExpressionOptions.h b/lldb/include/lldb/API/SBExpressionOptions.h
index 04cd74f730f2..9fc6e9ea957e 100644
--- a/lldb/include/lldb/API/SBExpressionOptions.h
+++ b/lldb/include/lldb/API/SBExpressionOptions.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBExpressionOptions_h_
-#define LLDB_SBExpressionOptions_h_
+#ifndef LLDB_API_SBEXPRESSIONOPTIONS_H
+#define LLDB_API_SBEXPRESSIONOPTIONS_H
#include "lldb/API/SBDefines.h"
@@ -86,6 +86,10 @@ public:
bool GetAutoApplyFixIts();
+ void SetRetriesWithFixIts(uint64_t retries);
+
+ uint64_t GetRetriesWithFixIts();
+
bool GetTopLevel();
void SetTopLevel(bool b = true);
@@ -112,4 +116,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBExpressionOptions_h_
+#endif // LLDB_API_SBEXPRESSIONOPTIONS_H
diff --git a/lldb/include/lldb/API/SBFile.h b/lldb/include/lldb/API/SBFile.h
index 7d6c14809923..a8b16520332d 100644
--- a/lldb/include/lldb/API/SBFile.h
+++ b/lldb/include/lldb/API/SBFile.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBFile_h_
-#define LLDB_SBFile_h_
+#ifndef LLDB_API_SBFILE_H
+#define LLDB_API_SBFILE_H
#include "lldb/API/SBDefines.h"
@@ -23,10 +23,13 @@ class LLDB_API SBFile {
public:
SBFile();
SBFile(FileSP file_sp);
+ SBFile(const SBFile &rhs);
SBFile(FILE *file, bool transfer_ownership);
SBFile(int fd, const char *mode, bool transfer_ownership);
~SBFile();
+ SBFile &operator=(const SBFile &rhs);
+
SBError Read(uint8_t *buf, size_t num_bytes, size_t *bytes_read);
SBError Write(const uint8_t *buf, size_t num_bytes, size_t *bytes_written);
SBError Flush();
@@ -44,4 +47,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBFile_h_
+#endif // LLDB_API_SBFILE_H
diff --git a/lldb/include/lldb/API/SBFileSpec.h b/lldb/include/lldb/API/SBFileSpec.h
index 27149775901e..a2f02ac78208 100644
--- a/lldb/include/lldb/API/SBFileSpec.h
+++ b/lldb/include/lldb/API/SBFileSpec.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBFileSpec_h_
-#define LLDB_SBFileSpec_h_
+#ifndef LLDB_API_SBFILESPEC_H
+#define LLDB_API_SBFILESPEC_H
#include "lldb/API/SBDefines.h"
@@ -92,4 +92,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBFileSpec_h_
+#endif // LLDB_API_SBFILESPEC_H
diff --git a/lldb/include/lldb/API/SBFileSpecList.h b/lldb/include/lldb/API/SBFileSpecList.h
index 5a131509d269..1a654865a307 100644
--- a/lldb/include/lldb/API/SBFileSpecList.h
+++ b/lldb/include/lldb/API/SBFileSpecList.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBFileSpecList_h_
-#define LLDB_SBFileSpecList_h_
+#ifndef LLDB_API_SBFILESPECLIST_H
+#define LLDB_API_SBFILESPECLIST_H
#include "lldb/API/SBDefines.h"
@@ -54,4 +54,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBFileSpecList_h_
+#endif // LLDB_API_SBFILESPECLIST_H
diff --git a/lldb/include/lldb/API/SBFrame.h b/lldb/include/lldb/API/SBFrame.h
index b213f8985510..2e368accbbb5 100644
--- a/lldb/include/lldb/API/SBFrame.h
+++ b/lldb/include/lldb/API/SBFrame.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBFrame_h_
-#define LLDB_SBFrame_h_
+#ifndef LLDB_API_SBFRAME_H
+#define LLDB_API_SBFRAME_H
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBValueList.h"
@@ -202,4 +202,4 @@ protected:
} // namespace lldb
-#endif // LLDB_SBFrame_h_
+#endif // LLDB_API_SBFRAME_H
diff --git a/lldb/include/lldb/API/SBFunction.h b/lldb/include/lldb/API/SBFunction.h
index 43f01d7e57de..bd643a62206f 100644
--- a/lldb/include/lldb/API/SBFunction.h
+++ b/lldb/include/lldb/API/SBFunction.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBFunction_h_
-#define LLDB_SBFunction_h_
+#ifndef LLDB_API_SBFUNCTION_H
+#define LLDB_API_SBFUNCTION_H
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBDefines.h"
@@ -79,4 +79,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBFunction_h_
+#endif // LLDB_API_SBFUNCTION_H
diff --git a/lldb/include/lldb/API/SBHostOS.h b/lldb/include/lldb/API/SBHostOS.h
index ecd7920f2c14..b170f8d65810 100644
--- a/lldb/include/lldb/API/SBHostOS.h
+++ b/lldb/include/lldb/API/SBHostOS.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBHostOS_h_
-#define LLDB_SBHostOS_h_
+#ifndef LLDB_API_SBHOSTOS_H
+#define LLDB_API_SBHOSTOS_H
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBFileSpec.h"
@@ -41,4 +41,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBHostOS_h_
+#endif // LLDB_API_SBHOSTOS_H
diff --git a/lldb/include/lldb/API/SBInstruction.h b/lldb/include/lldb/API/SBInstruction.h
index 7d83a37ba5d6..7d07e168cf03 100644
--- a/lldb/include/lldb/API/SBInstruction.h
+++ b/lldb/include/lldb/API/SBInstruction.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBInstruction_h_
-#define LLDB_SBInstruction_h_
+#ifndef LLDB_API_SBINSTRUCTION_H
+#define LLDB_API_SBINSTRUCTION_H
#include "lldb/API/SBData.h"
#include "lldb/API/SBDefines.h"
@@ -86,4 +86,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBInstruction_h_
+#endif // LLDB_API_SBINSTRUCTION_H
diff --git a/lldb/include/lldb/API/SBInstructionList.h b/lldb/include/lldb/API/SBInstructionList.h
index e203d0b80564..ae8988004e26 100644
--- a/lldb/include/lldb/API/SBInstructionList.h
+++ b/lldb/include/lldb/API/SBInstructionList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBInstructionList_h_
-#define LLDB_SBInstructionList_h_
+#ifndef LLDB_API_SBINSTRUCTIONLIST_H
+#define LLDB_API_SBINSTRUCTIONLIST_H
#include "lldb/API/SBDefines.h"
@@ -69,4 +69,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBInstructionList_h_
+#endif // LLDB_API_SBINSTRUCTIONLIST_H
diff --git a/lldb/include/lldb/API/SBLanguageRuntime.h b/lldb/include/lldb/API/SBLanguageRuntime.h
index d28c441593ea..38aac05d490c 100644
--- a/lldb/include/lldb/API/SBLanguageRuntime.h
+++ b/lldb/include/lldb/API/SBLanguageRuntime.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBLanguageRuntime_h_
-#define LLDB_SBLanguageRuntime_h_
+#ifndef LLDB_API_SBLANGUAGERUNTIME_H
+#define LLDB_API_SBLANGUAGERUNTIME_H
#include "lldb/API/SBDefines.h"
@@ -22,4 +22,4 @@ public:
} // namespace lldb
-#endif // LLDB_SBLanguageRuntime_h_
+#endif // LLDB_API_SBLANGUAGERUNTIME_H
diff --git a/lldb/include/lldb/API/SBLaunchInfo.h b/lldb/include/lldb/API/SBLaunchInfo.h
index c7b381ffdf97..04ebb5707688 100644
--- a/lldb/include/lldb/API/SBLaunchInfo.h
+++ b/lldb/include/lldb/API/SBLaunchInfo.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBLaunchInfo_h_
-#define LLDB_SBLaunchInfo_h_
+#ifndef LLDB_API_SBLAUNCHINFO_H
+#define LLDB_API_SBLAUNCHINFO_H
#include "lldb/API/SBDefines.h"
@@ -26,6 +26,10 @@ public:
~SBLaunchInfo();
+ SBLaunchInfo(const SBLaunchInfo &rhs);
+
+ SBLaunchInfo &operator=(const SBLaunchInfo &rhs);
+
lldb::pid_t GetProcessID();
uint32_t GetUserID();
@@ -90,8 +94,41 @@ public:
const char *GetEnvironmentEntryAtIndex(uint32_t idx);
+ /// Update this object with the given environment variables.
+ ///
+ /// If append is false, the provided environment will replace the existing
+ /// environment. Otherwise, existing values will be updated of left untouched
+ /// accordingly.
+ ///
+ /// \param [in] envp
+ /// The new environment variables as a list of strings with the following
+ /// format
+ /// name=value
+ ///
+ /// \param [in] append
+ /// Flag that controls whether to replace the existing environment.
void SetEnvironmentEntries(const char **envp, bool append);
+ /// Update this object with the given environment variables.
+ ///
+ /// If append is false, the provided environment will replace the existing
+ /// environment. Otherwise, existing values will be updated of left untouched
+ /// accordingly.
+ ///
+ /// \param [in] env
+ /// The new environment variables.
+ ///
+ /// \param [in] append
+ /// Flag that controls whether to replace the existing environment.
+ void SetEnvironment(const SBEnvironment &env, bool append);
+
+ /// Return the environment variables of this object.
+ ///
+ /// \return
+ /// An lldb::SBEnvironment object which is a copy of the SBLaunchInfo's
+ /// environment.
+ SBEnvironment GetEnvironment();
+
void Clear();
const char *GetWorkingDirectory() const;
@@ -146,4 +183,4 @@ protected:
} // namespace lldb
-#endif // LLDB_SBLaunchInfo_h_
+#endif // LLDB_API_SBLAUNCHINFO_H
diff --git a/lldb/include/lldb/API/SBLineEntry.h b/lldb/include/lldb/API/SBLineEntry.h
index 855c28d14b83..7c2431ba3c8a 100644
--- a/lldb/include/lldb/API/SBLineEntry.h
+++ b/lldb/include/lldb/API/SBLineEntry.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBLineEntry_h_
-#define LLDB_SBLineEntry_h_
+#ifndef LLDB_API_SBLINEENTRY_H
+#define LLDB_API_SBLINEENTRY_H
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBDefines.h"
@@ -75,4 +75,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBLineEntry_h_
+#endif // LLDB_API_SBLINEENTRY_H
diff --git a/lldb/include/lldb/API/SBListener.h b/lldb/include/lldb/API/SBListener.h
index 21aface97bd1..2144e7956b13 100644
--- a/lldb/include/lldb/API/SBListener.h
+++ b/lldb/include/lldb/API/SBListener.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBListener_h_
-#define LLDB_SBListener_h_
+#ifndef LLDB_API_SBLISTENER_H
+#define LLDB_API_SBLISTENER_H
#include "lldb/API/SBDefines.h"
@@ -105,4 +105,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBListener_h_
+#endif // LLDB_API_SBLISTENER_H
diff --git a/lldb/include/lldb/API/SBMemoryRegionInfo.h b/lldb/include/lldb/API/SBMemoryRegionInfo.h
index 2a9ae94218f2..d82c70606559 100644
--- a/lldb/include/lldb/API/SBMemoryRegionInfo.h
+++ b/lldb/include/lldb/API/SBMemoryRegionInfo.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBMemoryRegionInfo_h_
-#define LLDB_SBMemoryRegionInfo_h_
+#ifndef LLDB_API_SBMEMORYREGIONINFO_H
+#define LLDB_API_SBMEMORYREGIONINFO_H
#include "lldb/API/SBData.h"
#include "lldb/API/SBDefines.h"
@@ -95,4 +95,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBMemoryRegionInfo_h_
+#endif // LLDB_API_SBMEMORYREGIONINFO_H
diff --git a/lldb/include/lldb/API/SBMemoryRegionInfoList.h b/lldb/include/lldb/API/SBMemoryRegionInfoList.h
index 5592efef4851..a7122ee9108a 100644
--- a/lldb/include/lldb/API/SBMemoryRegionInfoList.h
+++ b/lldb/include/lldb/API/SBMemoryRegionInfoList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBMemoryRegionInfoList_h_
-#define LLDB_SBMemoryRegionInfoList_h_
+#ifndef LLDB_API_SBMEMORYREGIONINFOLIST_H
+#define LLDB_API_SBMEMORYREGIONINFOLIST_H
#include "lldb/API/SBDefines.h"
@@ -52,4 +52,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBMemoryRegionInfoList_h_
+#endif // LLDB_API_SBMEMORYREGIONINFOLIST_H
diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h
index d2b6a18db84d..859eaffe89a0 100644
--- a/lldb/include/lldb/API/SBModule.h
+++ b/lldb/include/lldb/API/SBModule.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBModule_h_
-#define LLDB_SBModule_h_
+#ifndef LLDB_API_SBMODULE_H
+#define LLDB_API_SBMODULE_H
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBError.h"
@@ -288,6 +288,9 @@ public:
lldb::SBAddress GetObjectFileHeaderAddress() const;
lldb::SBAddress GetObjectFileEntryPointAddress() const;
+ /// Get the number of global modules.
+ static uint32_t GetNumberAllocatedModules();
+
private:
friend class SBAddress;
friend class SBFrame;
@@ -306,4 +309,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBModule_h_
+#endif // LLDB_API_SBMODULE_H
diff --git a/lldb/include/lldb/API/SBModuleSpec.h b/lldb/include/lldb/API/SBModuleSpec.h
index 29b3117a261d..7529879b78b5 100644
--- a/lldb/include/lldb/API/SBModuleSpec.h
+++ b/lldb/include/lldb/API/SBModuleSpec.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBModuleSpec_h_
-#define LLDB_SBModuleSpec_h_
+#ifndef LLDB_API_SBMODULESPEC_H
+#define LLDB_API_SBMODULESPEC_H
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBFileSpec.h"
@@ -119,4 +119,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBModuleSpec_h_
+#endif // LLDB_API_SBMODULESPEC_H
diff --git a/lldb/include/lldb/API/SBPlatform.h b/lldb/include/lldb/API/SBPlatform.h
index 7207b2e2a78d..4d251b129954 100644
--- a/lldb/include/lldb/API/SBPlatform.h
+++ b/lldb/include/lldb/API/SBPlatform.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBPlatform_h_
-#define LLDB_SBPlatform_h_
+#ifndef LLDB_API_SBPLATFORM_H
+#define LLDB_API_SBPLATFORM_H
#include "lldb/API/SBDefines.h"
@@ -28,7 +28,7 @@ public:
~SBPlatformConnectOptions();
- void operator=(const SBPlatformConnectOptions &rhs);
+ SBPlatformConnectOptions &operator=(const SBPlatformConnectOptions &rhs);
const char *GetURL();
@@ -55,6 +55,8 @@ public:
SBPlatformShellCommand(const SBPlatformShellCommand &rhs);
+ SBPlatformShellCommand &operator=(const SBPlatformShellCommand &rhs);
+
~SBPlatformShellCommand();
void Clear();
@@ -89,8 +91,14 @@ public:
SBPlatform(const char *platform_name);
+ SBPlatform(const SBPlatform &rhs);
+
+ SBPlatform &operator=(const SBPlatform &rhs);
+
~SBPlatform();
+ static SBPlatform GetHostPlatform();
+
explicit operator bool() const;
bool IsValid() const;
@@ -146,6 +154,14 @@ public:
SBUnixSignals GetUnixSignals() const;
+ /// Return the environment variables of the remote platform connection
+ /// process.
+ ///
+ /// \return
+ /// An lldb::SBEnvironment object which is a copy of the platform's
+ /// environment.
+ SBEnvironment GetEnvironment();
+
protected:
friend class SBDebugger;
friend class SBTarget;
@@ -163,4 +179,4 @@ protected:
} // namespace lldb
-#endif // LLDB_SBPlatform_h_
+#endif // LLDB_API_SBPLATFORM_H
diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h
index 8ab8bfa3a93e..a90ec2a29a39 100644
--- a/lldb/include/lldb/API/SBProcess.h
+++ b/lldb/include/lldb/API/SBProcess.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBProcess_h_
-#define LLDB_SBProcess_h_
+#ifndef LLDB_API_SBPROCESS_H
+#define LLDB_API_SBPROCESS_H
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBError.h"
@@ -222,6 +222,8 @@ public:
bool GetDescription(lldb::SBStream &description);
+ SBStructuredData GetExtendedCrashInformation();
+
/// Start Tracing with the given SBTraceOptions.
///
/// \param[in] options
@@ -416,4 +418,4 @@ protected:
} // namespace lldb
-#endif // LLDB_SBProcess_h_
+#endif // LLDB_API_SBPROCESS_H
diff --git a/lldb/include/lldb/API/SBProcessInfo.h b/lldb/include/lldb/API/SBProcessInfo.h
index 86dba9a8e116..0cc5f6a2f9f6 100644
--- a/lldb/include/lldb/API/SBProcessInfo.h
+++ b/lldb/include/lldb/API/SBProcessInfo.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBProcessInfo_h_
-#define LLDB_SBProcessInfo_h_
+#ifndef LLDB_API_SBPROCESSINFO_H
+#define LLDB_API_SBPROCESSINFO_H
#include "lldb/API/SBDefines.h"
@@ -62,4 +62,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBProcessInfo_h_
+#endif // LLDB_API_SBPROCESSINFO_H
diff --git a/lldb/include/lldb/API/SBQueue.h b/lldb/include/lldb/API/SBQueue.h
index 0124c1c90dd2..c563f3ee1c20 100644
--- a/lldb/include/lldb/API/SBQueue.h
+++ b/lldb/include/lldb/API/SBQueue.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBQueue_h_
-#define LLDB_SBQueue_h_
+#ifndef LLDB_API_SBQUEUE_H
+#define LLDB_API_SBQUEUE_H
#include <vector>
@@ -66,4 +66,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBQueue_h_
+#endif // LLDB_API_SBQUEUE_H
diff --git a/lldb/include/lldb/API/SBQueueItem.h b/lldb/include/lldb/API/SBQueueItem.h
index 455a1f98379a..435dafe534a6 100644
--- a/lldb/include/lldb/API/SBQueueItem.h
+++ b/lldb/include/lldb/API/SBQueueItem.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBQueueItem_h_
-#define LLDB_SBQueueItem_h_
+#ifndef LLDB_API_SBQUEUEITEM_H
+#define LLDB_API_SBQUEUEITEM_H
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBDefines.h"
@@ -46,4 +46,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBQueueItem_h_
+#endif // LLDB_API_SBQUEUEITEM_H
diff --git a/lldb/include/lldb/API/SBReproducer.h b/lldb/include/lldb/API/SBReproducer.h
index 93d78f55fd76..78044e9acbc3 100644
--- a/lldb/include/lldb/API/SBReproducer.h
+++ b/lldb/include/lldb/API/SBReproducer.h
@@ -22,8 +22,17 @@ public:
static const char *Capture(const char *path);
static const char *Replay(const char *path);
static const char *Replay(const char *path, bool skip_version_check);
+ static const char *PassiveReplay(const char *path);
static const char *GetPath();
+ static bool SetAutoGenerate(bool b);
static bool Generate();
+
+ /// The working directory is set to the current working directory when the
+ /// reproducers are initialized. This method allows setting a different
+ /// working directory. This is used by the API test suite which temporarily
+ /// changes the directory to where the test lives. This is a NO-OP in every
+ /// mode but capture.
+ static void SetWorkingDirectory(const char *path);
};
} // namespace lldb
diff --git a/lldb/include/lldb/API/SBSection.h b/lldb/include/lldb/API/SBSection.h
index 06a195ee78df..d722dbe4ff1f 100644
--- a/lldb/include/lldb/API/SBSection.h
+++ b/lldb/include/lldb/API/SBSection.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBSection_h_
-#define LLDB_SBSection_h_
+#ifndef LLDB_API_SBSECTION_H
+#define LLDB_API_SBSECTION_H
#include "lldb/API/SBData.h"
#include "lldb/API/SBDefines.h"
@@ -98,4 +98,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBSection_h_
+#endif // LLDB_API_SBSECTION_H
diff --git a/lldb/include/lldb/API/SBSourceManager.h b/lldb/include/lldb/API/SBSourceManager.h
index 3d69aa25a934..c8302dbda3c0 100644
--- a/lldb/include/lldb/API/SBSourceManager.h
+++ b/lldb/include/lldb/API/SBSourceManager.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBSourceManager_h_
-#define LLDB_SBSourceManager_h_
+#ifndef LLDB_API_SBSOURCEMANAGER_H
+#define LLDB_API_SBSOURCEMANAGER_H
#include "lldb/API/SBDefines.h"
@@ -44,4 +44,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBSourceManager_h_
+#endif // LLDB_API_SBSOURCEMANAGER_H
diff --git a/lldb/include/lldb/API/SBStream.h b/lldb/include/lldb/API/SBStream.h
index b78c498e5f3d..f44b87bb4c98 100644
--- a/lldb/include/lldb/API/SBStream.h
+++ b/lldb/include/lldb/API/SBStream.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBStream_h_
-#define LLDB_SBStream_h_
+#ifndef LLDB_API_SBSTREAM_H
+#define LLDB_API_SBSTREAM_H
#include <stdio.h>
@@ -37,6 +37,8 @@ public:
void Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
+ void Print(const char *str);
+
void RedirectToFile(const char *path, bool append);
void RedirectToFile(lldb::SBFile file);
@@ -99,11 +101,12 @@ protected:
lldb_private::Stream &ref();
private:
- DISALLOW_COPY_AND_ASSIGN(SBStream);
+ SBStream(const SBStream &) = delete;
+ const SBStream &operator=(const SBStream &) = delete;
std::unique_ptr<lldb_private::Stream> m_opaque_up;
bool m_is_file;
};
} // namespace lldb
-#endif // LLDB_SBStream_h_
+#endif // LLDB_API_SBSTREAM_H
diff --git a/lldb/include/lldb/API/SBStringList.h b/lldb/include/lldb/API/SBStringList.h
index 1df1e45f96fe..4842c162bd6e 100644
--- a/lldb/include/lldb/API/SBStringList.h
+++ b/lldb/include/lldb/API/SBStringList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBStringList_h_
-#define LLDB_SBStringList_h_
+#ifndef LLDB_API_SBSTRINGLIST_H
+#define LLDB_API_SBSTRINGLIST_H
#include "lldb/API/SBDefines.h"
@@ -62,4 +62,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBStringList_h_
+#endif // LLDB_API_SBSTRINGLIST_H
diff --git a/lldb/include/lldb/API/SBStructuredData.h b/lldb/include/lldb/API/SBStructuredData.h
index 785e91047fdf..44a86bdabe25 100644
--- a/lldb/include/lldb/API/SBStructuredData.h
+++ b/lldb/include/lldb/API/SBStructuredData.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SBStructuredData_h
-#define SBStructuredData_h
+#ifndef LLDB_API_SBSTRUCTUREDDATA_H
+#define LLDB_API_SBSTRUCTUREDDATA_H
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBModule.h"
@@ -91,6 +91,7 @@ protected:
friend class SBTraceOptions;
friend class SBDebugger;
friend class SBTarget;
+ friend class SBProcess;
friend class SBThread;
friend class SBThreadPlan;
friend class SBBreakpoint;
@@ -101,4 +102,4 @@ protected:
};
} // namespace lldb
-#endif /* SBStructuredData_h */
+#endif // LLDB_API_SBSTRUCTUREDDATA_H
diff --git a/lldb/include/lldb/API/SBSymbol.h b/lldb/include/lldb/API/SBSymbol.h
index 52486b83d1a7..66f73c82a73a 100644
--- a/lldb/include/lldb/API/SBSymbol.h
+++ b/lldb/include/lldb/API/SBSymbol.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBSymbol_h_
-#define LLDB_SBSymbol_h_
+#ifndef LLDB_API_SBSYMBOL_H
+#define LLDB_API_SBSYMBOL_H
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBDefines.h"
@@ -83,4 +83,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBSymbol_h_
+#endif // LLDB_API_SBSYMBOL_H
diff --git a/lldb/include/lldb/API/SBSymbolContext.h b/lldb/include/lldb/API/SBSymbolContext.h
index 3d16d0989ca1..16ad29ea8730 100644
--- a/lldb/include/lldb/API/SBSymbolContext.h
+++ b/lldb/include/lldb/API/SBSymbolContext.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBSymbolContext_h_
-#define LLDB_SBSymbolContext_h_
+#ifndef LLDB_API_SBSYMBOLCONTEXT_H
+#define LLDB_API_SBSYMBOLCONTEXT_H
#include "lldb/API/SBBlock.h"
#include "lldb/API/SBCompileUnit.h"
@@ -80,4 +80,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBSymbolContext_h_
+#endif // LLDB_API_SBSYMBOLCONTEXT_H
diff --git a/lldb/include/lldb/API/SBSymbolContextList.h b/lldb/include/lldb/API/SBSymbolContextList.h
index 577993ce96dd..4026afc21357 100644
--- a/lldb/include/lldb/API/SBSymbolContextList.h
+++ b/lldb/include/lldb/API/SBSymbolContextList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBSymbolContextList_h_
-#define LLDB_SBSymbolContextList_h_
+#ifndef LLDB_API_SBSYMBOLCONTEXTLIST_H
+#define LLDB_API_SBSYMBOLCONTEXTLIST_H
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBSymbolContext.h"
@@ -55,4 +55,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBSymbolContextList_h_
+#endif // LLDB_API_SBSYMBOLCONTEXTLIST_H
diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 80a7fa00dbc5..fad842c9cb1c 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBTarget_h_
-#define LLDB_SBTarget_h_
+#ifndef LLDB_API_SBTARGET_H
+#define LLDB_API_SBTARGET_H
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBAttachInfo.h"
@@ -94,6 +94,15 @@ public:
/// A platform object.
lldb::SBPlatform GetPlatform();
+ /// Return the environment variables that would be used to launch a new
+ /// process.
+ ///
+ /// \return
+ /// An lldb::SBEnvironment object which is a copy of the target's
+ /// environment.
+
+ SBEnvironment GetEnvironment();
+
/// Install any binaries that need to be installed.
///
/// This function does nothing when debugging on the host system.
@@ -127,7 +136,9 @@ public:
/// The argument array.
///
/// \param[in] envp
- /// The environment array.
+ /// The environment array. If this is null, the default
+ /// environment values (provided through `settings set
+ /// target.env-vars`) will be used.
///
/// \param[in] stdin_path
/// The path to use when re-directing the STDIN of the new
@@ -175,7 +186,9 @@ public:
/// The argument array.
///
/// \param[in] envp
- /// The environment array.
+ /// The environment array. If this isn't provided, the default
+ /// environment values (provided through `settings set
+ /// target.env-vars`) will be used.
///
/// \param[in] working_directory
/// The working directory to have the child process run in
@@ -829,6 +842,7 @@ protected:
friend class SBFunction;
friend class SBInstruction;
friend class SBModule;
+ friend class SBPlatform;
friend class SBProcess;
friend class SBSection;
friend class SBSourceManager;
@@ -849,4 +863,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBTarget_h_
+#endif // LLDB_API_SBTARGET_H
diff --git a/lldb/include/lldb/API/SBThread.h b/lldb/include/lldb/API/SBThread.h
index b5f1794f9fe0..894120c6d986 100644
--- a/lldb/include/lldb/API/SBThread.h
+++ b/lldb/include/lldb/API/SBThread.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBThread_h_
-#define LLDB_SBThread_h_
+#ifndef LLDB_API_SBTHREAD_H
+#define LLDB_API_SBTHREAD_H
#include "lldb/API/SBDefines.h"
@@ -232,4 +232,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBThread_h_
+#endif // LLDB_API_SBTHREAD_H
diff --git a/lldb/include/lldb/API/SBThreadCollection.h b/lldb/include/lldb/API/SBThreadCollection.h
index 1c6b4639c6ef..fe57a6b95d90 100644
--- a/lldb/include/lldb/API/SBThreadCollection.h
+++ b/lldb/include/lldb/API/SBThreadCollection.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBThreadCollection_h_
-#define LLDB_SBThreadCollection_h_
+#ifndef LLDB_API_SBTHREADCOLLECTION_H
+#define LLDB_API_SBTHREADCOLLECTION_H
#include "lldb/API/SBDefines.h"
@@ -54,4 +54,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBThreadCollection_h_
+#endif // LLDB_API_SBTHREADCOLLECTION_H
diff --git a/lldb/include/lldb/API/SBThreadPlan.h b/lldb/include/lldb/API/SBThreadPlan.h
index dbe417e63749..8f16f4f5c4d2 100644
--- a/lldb/include/lldb/API/SBThreadPlan.h
+++ b/lldb/include/lldb/API/SBThreadPlan.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBThreadPlan_h_
-#define LLDB_SBThreadPlan_h_
+#ifndef LLDB_API_SBTHREADPLAN_H
+#define LLDB_API_SBTHREADPLAN_H
#include "lldb/API/SBDefines.h"
@@ -125,4 +125,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBThreadPlan_h_
+#endif // LLDB_API_SBTHREADPLAN_H
diff --git a/lldb/include/lldb/API/SBTrace.h b/lldb/include/lldb/API/SBTrace.h
index 87c67adac75b..053abaeada19 100644
--- a/lldb/include/lldb/API/SBTrace.h
+++ b/lldb/include/lldb/API/SBTrace.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBTrace_h_
-#define LLDB_SBTrace_h_
+#ifndef LLDB_API_SBTRACE_H
+#define LLDB_API_SBTRACE_H
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBError.h"
@@ -113,4 +113,4 @@ protected:
};
} // namespace lldb
-#endif // LLDB_SBTrace_h_
+#endif // LLDB_API_SBTRACE_H
diff --git a/lldb/include/lldb/API/SBTraceOptions.h b/lldb/include/lldb/API/SBTraceOptions.h
index 4c586bfd55c4..22d71fbd3828 100644
--- a/lldb/include/lldb/API/SBTraceOptions.h
+++ b/lldb/include/lldb/API/SBTraceOptions.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SBTRACEOPTIONS_H_
-#define SBTRACEOPTIONS_H_
+#ifndef LLDB_API_SBTRACEOPTIONS_H
+#define LLDB_API_SBTRACEOPTIONS_H
#include "lldb/API/SBDefines.h"
@@ -56,4 +56,4 @@ protected:
};
}
-#endif /* SBTRACEOPTIONS_H_ */
+#endif // LLDB_API_SBTRACEOPTIONS_H
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index b3f92b7bcd04..b0af43351192 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBType_h_
-#define LLDB_SBType_h_
+#ifndef LLDB_API_SBTYPE_H
+#define LLDB_API_SBTYPE_H
#include "lldb/API/SBDefines.h"
@@ -259,4 +259,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBType_h_
+#endif // LLDB_API_SBTYPE_H
diff --git a/lldb/include/lldb/API/SBTypeCategory.h b/lldb/include/lldb/API/SBTypeCategory.h
index c0f4cee1d268..ee1c0f6910ee 100644
--- a/lldb/include/lldb/API/SBTypeCategory.h
+++ b/lldb/include/lldb/API/SBTypeCategory.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBTypeCategory_h_
-#define LLDB_SBTypeCategory_h_
+#ifndef LLDB_API_SBTYPECATEGORY_H
+#define LLDB_API_SBTYPECATEGORY_H
#include "lldb/API/SBDefines.h"
@@ -113,4 +113,4 @@ protected:
} // namespace lldb
-#endif // LLDB_SBTypeCategory_h_
+#endif // LLDB_API_SBTYPECATEGORY_H
diff --git a/lldb/include/lldb/API/SBTypeEnumMember.h b/lldb/include/lldb/API/SBTypeEnumMember.h
index 2410dbcc2125..45f8cc6638b4 100644
--- a/lldb/include/lldb/API/SBTypeEnumMember.h
+++ b/lldb/include/lldb/API/SBTypeEnumMember.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBTypeEnumMember_h_
-#define LLDB_SBTypeEnumMember_h_
+#ifndef LLDB_API_SBTYPEENUMMEMBER_H
+#define LLDB_API_SBTYPEENUMMEMBER_H
#include "lldb/API/SBDefines.h"
@@ -80,4 +80,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBTypeEnumMember_h_
+#endif // LLDB_API_SBTYPEENUMMEMBER_H
diff --git a/lldb/include/lldb/API/SBTypeFilter.h b/lldb/include/lldb/API/SBTypeFilter.h
index 4a0de11d19c4..5f02e231d12f 100644
--- a/lldb/include/lldb/API/SBTypeFilter.h
+++ b/lldb/include/lldb/API/SBTypeFilter.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBTypeFilter_h_
-#define LLDB_SBTypeFilter_h_
+#ifndef LLDB_API_SBTYPEFILTER_H
+#define LLDB_API_SBTYPEFILTER_H
#include "lldb/API/SBDefines.h"
@@ -71,4 +71,4 @@ protected:
} // namespace lldb
-#endif // LLDB_SBTypeFilter_h_
+#endif // LLDB_API_SBTYPEFILTER_H
diff --git a/lldb/include/lldb/API/SBTypeFormat.h b/lldb/include/lldb/API/SBTypeFormat.h
index 8a0ac77a1e9d..b34045927032 100644
--- a/lldb/include/lldb/API/SBTypeFormat.h
+++ b/lldb/include/lldb/API/SBTypeFormat.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBTypeFormat_h_
-#define LLDB_SBTypeFormat_h_
+#ifndef LLDB_API_SBTYPEFORMAT_H
+#define LLDB_API_SBTYPEFORMAT_H
#include "lldb/API/SBDefines.h"
@@ -75,4 +75,4 @@ protected:
} // namespace lldb
-#endif // LLDB_SBTypeFormat_h_
+#endif // LLDB_API_SBTYPEFORMAT_H
diff --git a/lldb/include/lldb/API/SBTypeNameSpecifier.h b/lldb/include/lldb/API/SBTypeNameSpecifier.h
index 9fe449d029c6..eee424c1710a 100644
--- a/lldb/include/lldb/API/SBTypeNameSpecifier.h
+++ b/lldb/include/lldb/API/SBTypeNameSpecifier.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBTypeNameSpecifier_h_
-#define LLDB_SBTypeNameSpecifier_h_
+#ifndef LLDB_API_SBTYPENAMESPECIFIER_H
+#define LLDB_API_SBTYPENAMESPECIFIER_H
#include "lldb/API/SBDefines.h"
@@ -62,4 +62,4 @@ protected:
} // namespace lldb
-#endif // LLDB_SBTypeNameSpecifier_h_
+#endif // LLDB_API_SBTYPENAMESPECIFIER_H
diff --git a/lldb/include/lldb/API/SBTypeSummary.h b/lldb/include/lldb/API/SBTypeSummary.h
index bb7121f8ae40..929bfb6124b2 100644
--- a/lldb/include/lldb/API/SBTypeSummary.h
+++ b/lldb/include/lldb/API/SBTypeSummary.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBTypeSummary_h_
-#define LLDB_SBTypeSummary_h_
+#ifndef LLDB_API_SBTYPESUMMARY_H
+#define LLDB_API_SBTYPESUMMARY_H
#include "lldb/API/SBDefines.h"
@@ -136,4 +136,4 @@ protected:
} // namespace lldb
-#endif // LLDB_SBTypeSummary_h_
+#endif // LLDB_API_SBTYPESUMMARY_H
diff --git a/lldb/include/lldb/API/SBTypeSynthetic.h b/lldb/include/lldb/API/SBTypeSynthetic.h
index c190643c1ebb..9dab9d851f08 100644
--- a/lldb/include/lldb/API/SBTypeSynthetic.h
+++ b/lldb/include/lldb/API/SBTypeSynthetic.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBTypeSynthetic_h_
-#define LLDB_SBTypeSynthetic_h_
+#ifndef LLDB_API_SBTYPESYNTHETIC_H
+#define LLDB_API_SBTYPESYNTHETIC_H
#include "lldb/API/SBDefines.h"
@@ -77,4 +77,4 @@ protected:
} // namespace lldb
-#endif // LLDB_SBTypeSynthetic_h_
+#endif // LLDB_API_SBTYPESYNTHETIC_H
diff --git a/lldb/include/lldb/API/SBUnixSignals.h b/lldb/include/lldb/API/SBUnixSignals.h
index c7e99d1f63d1..9757eac7ee30 100644
--- a/lldb/include/lldb/API/SBUnixSignals.h
+++ b/lldb/include/lldb/API/SBUnixSignals.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBUnixSignals_h_
-#define LLDB_SBUnixSignals_h_
+#ifndef LLDB_API_SBUNIXSIGNALS_H
+#define LLDB_API_SBUNIXSIGNALS_H
#include "lldb/API/SBDefines.h"
@@ -68,4 +68,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBUnixSignals_h_
+#endif // LLDB_API_SBUNIXSIGNALS_H
diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h
index 5f8d17f8642f..69be02545b35 100644
--- a/lldb/include/lldb/API/SBValue.h
+++ b/lldb/include/lldb/API/SBValue.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBValue_h_
-#define LLDB_SBValue_h_
+#ifndef LLDB_API_SBVALUE_H
+#define LLDB_API_SBVALUE_H
#include "lldb/API/SBData.h"
#include "lldb/API/SBDefines.h"
@@ -430,4 +430,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBValue_h_
+#endif // LLDB_API_SBVALUE_H
diff --git a/lldb/include/lldb/API/SBValueList.h b/lldb/include/lldb/API/SBValueList.h
index d305b3564c2b..dc8389b75293 100644
--- a/lldb/include/lldb/API/SBValueList.h
+++ b/lldb/include/lldb/API/SBValueList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBValueList_h_
-#define LLDB_SBValueList_h_
+#ifndef LLDB_API_SBVALUELIST_H
+#define LLDB_API_SBVALUELIST_H
#include "lldb/API/SBDefines.h"
@@ -72,4 +72,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBValueList_h_
+#endif // LLDB_API_SBVALUELIST_H
diff --git a/lldb/include/lldb/API/SBVariablesOptions.h b/lldb/include/lldb/API/SBVariablesOptions.h
index e226ce4ae13b..53ab4b7e14f2 100644
--- a/lldb/include/lldb/API/SBVariablesOptions.h
+++ b/lldb/include/lldb/API/SBVariablesOptions.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBVariablesOptions_h_
-#define LLDB_SBVariablesOptions_h_
+#ifndef LLDB_API_SBVARIABLESOPTIONS_H
+#define LLDB_API_SBVARIABLESOPTIONS_H
#include "lldb/API/SBDefines.h"
@@ -79,4 +79,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBValue_h_
+#endif // LLDB_API_SBVARIABLESOPTIONS_H
diff --git a/lldb/include/lldb/API/SBWatchpoint.h b/lldb/include/lldb/API/SBWatchpoint.h
index 05ff0ca7e443..08c5faa3a928 100644
--- a/lldb/include/lldb/API/SBWatchpoint.h
+++ b/lldb/include/lldb/API/SBWatchpoint.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBWatchpoint_h_
-#define LLDB_SBWatchpoint_h_
+#ifndef LLDB_API_SBWATCHPOINT_H
+#define LLDB_API_SBWATCHPOINT_H
#include "lldb/API/SBDefines.h"
@@ -82,4 +82,4 @@ private:
} // namespace lldb
-#endif // LLDB_SBWatchpoint_h_
+#endif // LLDB_API_SBWATCHPOINT_H
diff --git a/lldb/include/lldb/Breakpoint/Breakpoint.h b/lldb/include/lldb/Breakpoint/Breakpoint.h
index 94411bd57a67..d29d21070fd7 100644
--- a/lldb/include/lldb/Breakpoint/Breakpoint.h
+++ b/lldb/include/lldb/Breakpoint/Breakpoint.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Breakpoint_h_
-#define liblldb_Breakpoint_h_
+#ifndef LLDB_BREAKPOINT_BREAKPOINT_H
+#define LLDB_BREAKPOINT_BREAKPOINT_H
#include <memory>
#include <string>
@@ -137,12 +137,14 @@ public:
lldb::BreakpointSP m_new_breakpoint_sp;
BreakpointLocationCollection m_locations;
- DISALLOW_COPY_AND_ASSIGN(BreakpointEventData);
+ BreakpointEventData(const BreakpointEventData &) = delete;
+ const BreakpointEventData &operator=(const BreakpointEventData &) = delete;
};
// Saving & restoring breakpoints:
static lldb::BreakpointSP CreateFromStructuredData(
- Target &target, StructuredData::ObjectSP &data_object_sp, Status &error);
+ lldb::TargetSP target_sp, StructuredData::ObjectSP &data_object_sp,
+ Status &error);
static bool
SerializedBreakpointMatchesNames(StructuredData::ObjectSP &bkpt_object_sp,
@@ -568,6 +570,11 @@ public:
return GetPermissions().GetAllowDelete();
}
+ // This one should only be used by Target to copy breakpoints from target to
+ // target - primarily from the dummy target to prime new targets.
+ static lldb::BreakpointSP CopyFromBreakpoint(lldb::TargetSP new_target,
+ const Breakpoint &bp_to_copy_from);
+
protected:
friend class Target;
// Protected Methods
@@ -625,9 +632,8 @@ protected:
}
private:
- // This one should only be used by Target to copy breakpoints from target to
- // target - primarily from the dummy target to prime new targets.
- Breakpoint(Target &new_target, Breakpoint &bp_to_copy_from);
+ // To call from CopyFromBreakpoint.
+ Breakpoint(Target &new_target, const Breakpoint &bp_to_copy_from);
// For Breakpoint only
bool m_being_created;
@@ -664,9 +670,10 @@ private:
void SendBreakpointChangedEvent(BreakpointEventData *data);
- DISALLOW_COPY_AND_ASSIGN(Breakpoint);
+ Breakpoint(const Breakpoint &) = delete;
+ const Breakpoint &operator=(const Breakpoint &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Breakpoint_h_
+#endif // LLDB_BREAKPOINT_BREAKPOINT_H
diff --git a/lldb/include/lldb/Breakpoint/BreakpointID.h b/lldb/include/lldb/Breakpoint/BreakpointID.h
index 9daa5b6c5e8d..64432f2d3cd5 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointID.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointID.h
@@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_BreakpointID_h_
-#define liblldb_BreakpointID_h_
-
+#ifndef LLDB_BREAKPOINT_BREAKPOINTID_H
+#define LLDB_BREAKPOINT_BREAKPOINTID_H
#include "lldb/lldb-private.h"
@@ -95,4 +94,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_BreakpointID_h_
+#endif // LLDB_BREAKPOINT_BREAKPOINTID_H
diff --git a/lldb/include/lldb/Breakpoint/BreakpointIDList.h b/lldb/include/lldb/Breakpoint/BreakpointIDList.h
index c6429220c7ff..924cb1f26b8b 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointIDList.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointIDList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_BreakpointIDList_h_
-#define liblldb_BreakpointIDList_h_
+#ifndef LLDB_BREAKPOINT_BREAKPOINTIDLIST_H
+#define LLDB_BREAKPOINT_BREAKPOINTIDLIST_H
#include <utility>
#include <vector>
@@ -68,9 +68,10 @@ private:
BreakpointIDArray m_breakpoint_ids;
BreakpointID m_invalid_id;
- DISALLOW_COPY_AND_ASSIGN(BreakpointIDList);
+ BreakpointIDList(const BreakpointIDList &) = delete;
+ const BreakpointIDList &operator=(const BreakpointIDList &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_BreakpointIDList_h_
+#endif // LLDB_BREAKPOINT_BREAKPOINTIDLIST_H
diff --git a/lldb/include/lldb/Breakpoint/BreakpointList.h b/lldb/include/lldb/Breakpoint/BreakpointList.h
index ad68151fefc7..346972ec3a1f 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointList.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_BreakpointList_h_
-#define liblldb_BreakpointList_h_
+#ifndef LLDB_BREAKPOINT_BREAKPOINTLIST_H
+#define LLDB_BREAKPOINT_BREAKPOINTLIST_H
#include <list>
#include <mutex>
@@ -168,9 +168,10 @@ public:
}
private:
- DISALLOW_COPY_AND_ASSIGN(BreakpointList);
+ BreakpointList(const BreakpointList &) = delete;
+ const BreakpointList &operator=(const BreakpointList &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_BreakpointList_h_
+#endif // LLDB_BREAKPOINT_BREAKPOINTLIST_H
diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocation.h b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
index 86bb164162c1..3fc571eaa292 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointLocation.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointLocation.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_BreakpointLocation_h_
-#define liblldb_BreakpointLocation_h_
+#ifndef LLDB_BREAKPOINT_BREAKPOINTLOCATION_H
+#define LLDB_BREAKPOINT_BREAKPOINTLOCATION_H
#include <memory>
#include <mutex>
@@ -345,9 +345,10 @@ private:
void SendBreakpointLocationChangedEvent(lldb::BreakpointEventType eventKind);
- DISALLOW_COPY_AND_ASSIGN(BreakpointLocation);
+ BreakpointLocation(const BreakpointLocation &) = delete;
+ const BreakpointLocation &operator=(const BreakpointLocation &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_BreakpointLocation_h_
+#endif // LLDB_BREAKPOINT_BREAKPOINTLOCATION_H
diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocationCollection.h b/lldb/include/lldb/Breakpoint/BreakpointLocationCollection.h
index be400636877e..ffdb81e363e0 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointLocationCollection.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointLocationCollection.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_BreakpointLocationCollection_h_
-#define liblldb_BreakpointLocationCollection_h_
+#ifndef LLDB_BREAKPOINT_BREAKPOINTLOCATIONCOLLECTION_H
+#define LLDB_BREAKPOINT_BREAKPOINTLOCATIONCOLLECTION_H
#include <mutex>
#include <vector>
@@ -175,4 +175,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_BreakpointLocationCollection_h_
+#endif // LLDB_BREAKPOINT_BREAKPOINTLOCATIONCOLLECTION_H
diff --git a/lldb/include/lldb/Breakpoint/BreakpointLocationList.h b/lldb/include/lldb/Breakpoint/BreakpointLocationList.h
index 89ad2f54c923..4b36c919ee3c 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointLocationList.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointLocationList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_BreakpointLocationList_h_
-#define liblldb_BreakpointLocationList_h_
+#ifndef LLDB_BREAKPOINT_BREAKPOINTLOCATIONLIST_H
+#define LLDB_BREAKPOINT_BREAKPOINTLOCATIONLIST_H
#include <map>
#include <mutex>
@@ -212,4 +212,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_BreakpointLocationList_h_
+#endif // LLDB_BREAKPOINT_BREAKPOINTLOCATIONLIST_H
diff --git a/lldb/include/lldb/Breakpoint/BreakpointName.h b/lldb/include/lldb/Breakpoint/BreakpointName.h
index 61020a628070..8786dbc9a163 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointName.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointName.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Breakpoint_Name_h_
-#define liblldb_Breakpoint_Name_h_
+#ifndef LLDB_BREAKPOINT_BREAKPOINTNAME_H
+#define LLDB_BREAKPOINT_BREAKPOINTNAME_H
#include <memory>
#include <string>
@@ -205,4 +205,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_Breakpoint_Name_h_
+#endif // LLDB_BREAKPOINT_BREAKPOINTNAME_H
diff --git a/lldb/include/lldb/Breakpoint/BreakpointOptions.h b/lldb/include/lldb/Breakpoint/BreakpointOptions.h
index 2c52170eb9f6..615b4eb77be4 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointOptions.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointOptions.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_BreakpointOptions_h_
-#define liblldb_BreakpointOptions_h_
+#ifndef LLDB_BREAKPOINT_BREAKPOINTOPTIONS_H
+#define LLDB_BREAKPOINT_BREAKPOINTOPTIONS_H
#include <memory>
#include <string>
@@ -406,4 +406,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_BreakpointOptions_h_
+#endif // LLDB_BREAKPOINT_BREAKPOINTOPTIONS_H
diff --git a/lldb/include/lldb/Breakpoint/BreakpointPrecondition.h b/lldb/include/lldb/Breakpoint/BreakpointPrecondition.h
index 2a9461b52fab..5f0c11b595bb 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointPrecondition.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointPrecondition.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_BreakpointPrecondition_h_
-#define liblldb_BreakpointPrecondition_h_
+#ifndef LLDB_BREAKPOINT_BREAKPOINTPRECONDITION_H
+#define LLDB_BREAKPOINT_BREAKPOINTPRECONDITION_H
#include "lldb/lldb-enumerations.h"
diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolver.h b/lldb/include/lldb/Breakpoint/BreakpointResolver.h
index c1dbf9ac0aee..d067b1eea6ff 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointResolver.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointResolver.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_BreakpointResolver_h_
-#define liblldb_BreakpointResolver_h_
+#ifndef LLDB_BREAKPOINT_BREAKPOINTRESOLVER_H
+#define LLDB_BREAKPOINT_BREAKPOINTRESOLVER_H
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Core/Address.h"
@@ -44,7 +44,8 @@ public:
/// The breakpoint that owns this resolver.
/// \param[in] resolverType
/// The concrete breakpoint resolver type for this breakpoint.
- BreakpointResolver(Breakpoint *bkpt, unsigned char resolverType,
+ BreakpointResolver(const lldb::BreakpointSP &bkpt,
+ unsigned char resolverType,
lldb::addr_t offset = 0);
/// The Destructor is virtual, all significant breakpoint resolvers derive
@@ -55,7 +56,15 @@ public:
///
/// \param[in] bkpt
/// The breakpoint that owns this resolver.
- void SetBreakpoint(Breakpoint *bkpt);
+ void SetBreakpoint(const lldb::BreakpointSP &bkpt);
+
+ /// This gets the breakpoint for this resolver.
+ lldb::BreakpointSP GetBreakpoint() const {
+ auto breakpoint_sp = m_breakpoint.expired() ? lldb::BreakpointSP() :
+ m_breakpoint.lock();
+ assert(breakpoint_sp);
+ return breakpoint_sp;
+ }
/// This updates the offset for this breakpoint. All the locations
/// currently set for this breakpoint will have their offset adjusted when
@@ -65,12 +74,6 @@ public:
/// The offset to add to all locations.
void SetOffset(lldb::addr_t offset);
- /// This updates the offset for this breakpoint. All the locations
- /// currently set for this breakpoint will have their offset adjusted when
- /// this is called.
- ///
- /// \param[in] offset
- /// The offset to add to all locations.
lldb::addr_t GetOffset() const { return m_offset; }
/// In response to this method the resolver scans all the modules in the
@@ -155,7 +158,7 @@ public:
static ResolverTy NameToResolverTy(llvm::StringRef name);
virtual lldb::BreakpointResolverSP
- CopyForBreakpoint(Breakpoint &breakpoint) = 0;
+ CopyForBreakpoint(lldb::BreakpointSP &breakpoint) = 0;
protected:
// Used for serializing resolver options:
@@ -208,20 +211,21 @@ protected:
lldb::BreakpointLocationSP AddLocation(Address loc_addr,
bool *new_location = nullptr);
- Breakpoint *m_breakpoint; // This is the breakpoint we add locations to.
- lldb::addr_t m_offset; // A random offset the user asked us to add to any
- // breakpoints we set.
-
private:
/// Helper for \p SetSCMatchesByLine.
void AddLocation(SearchFilter &filter, const SymbolContext &sc,
bool skip_prologue, llvm::StringRef log_ident);
+ lldb::BreakpointWP m_breakpoint; // This is the breakpoint we add locations to.
+ lldb::addr_t m_offset; // A random offset the user asked us to add to any
+ // breakpoints we set.
+
// Subclass identifier (for llvm isa/dyn_cast)
const unsigned char SubclassID;
- DISALLOW_COPY_AND_ASSIGN(BreakpointResolver);
+ BreakpointResolver(const BreakpointResolver &) = delete;
+ const BreakpointResolver &operator=(const BreakpointResolver &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_BreakpointResolver_h_
+#endif // LLDB_BREAKPOINT_BREAKPOINTRESOLVER_H
diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h b/lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
index 3df89641c711..5454487e51a2 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_BreakpointResolverAddress_h_
-#define liblldb_BreakpointResolverAddress_h_
+#ifndef LLDB_BREAKPOINT_BREAKPOINTRESOLVERADDRESS_H
+#define LLDB_BREAKPOINT_BREAKPOINTRESOLVERADDRESS_H
#include "lldb/Breakpoint/BreakpointResolver.h"
#include "lldb/Core/ModuleSpec.h"
@@ -21,15 +21,17 @@ namespace lldb_private {
class BreakpointResolverAddress : public BreakpointResolver {
public:
- BreakpointResolverAddress(Breakpoint *bkpt, const Address &addr);
+ BreakpointResolverAddress(const lldb::BreakpointSP &bkpt,
+ const Address &addr);
- BreakpointResolverAddress(Breakpoint *bkpt, const Address &addr,
+ BreakpointResolverAddress(const lldb::BreakpointSP &bkpt,
+ const Address &addr,
const FileSpec &module_spec);
- ~BreakpointResolverAddress() override;
+ ~BreakpointResolverAddress() override = default;
static BreakpointResolver *
- CreateFromStructuredData(Breakpoint *bkpt,
+ CreateFromStructuredData(const lldb::BreakpointSP &bkpt,
const StructuredData::Dictionary &options_dict,
Status &error);
@@ -56,11 +58,12 @@ public:
return V->getResolverID() == BreakpointResolver::AddressResolver;
}
- lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
+ lldb::BreakpointResolverSP
+ CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override;
protected:
- Address
- m_addr; // The address - may be Section Offset or may be just an offset
+ 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
@@ -68,9 +71,11 @@ protected:
// to a Section+Offset address in this module, whenever that module gets
// around to being loaded.
private:
- DISALLOW_COPY_AND_ASSIGN(BreakpointResolverAddress);
+ BreakpointResolverAddress(const BreakpointResolverAddress &) = delete;
+ const BreakpointResolverAddress &
+ operator=(const BreakpointResolverAddress &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_BreakpointResolverAddress_h_
+#endif // LLDB_BREAKPOINT_BREAKPOINTRESOLVERADDRESS_H
diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h b/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
index 9ca48ecf0dc0..222fc6fcd45d 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_BreakpointResolverFileLine_h_
-#define liblldb_BreakpointResolverFileLine_h_
+#ifndef LLDB_BREAKPOINT_BREAKPOINTRESOLVERFILELINE_H
+#define LLDB_BREAKPOINT_BREAKPOINTRESOLVERFILELINE_H
#include "lldb/Breakpoint/BreakpointResolver.h"
@@ -20,19 +20,20 @@ namespace lldb_private {
class BreakpointResolverFileLine : public BreakpointResolver {
public:
- BreakpointResolverFileLine(Breakpoint *bkpt, const FileSpec &resolver,
+ BreakpointResolverFileLine(const lldb::BreakpointSP &bkpt,
+ const FileSpec &resolver,
uint32_t line_no, uint32_t column,
lldb::addr_t m_offset, bool check_inlines,
bool skip_prologue, bool exact_match);
static BreakpointResolver *
- CreateFromStructuredData(Breakpoint *bkpt,
+ CreateFromStructuredData(const lldb::BreakpointSP &bkpt,
const StructuredData::Dictionary &data_dict,
Status &error);
StructuredData::ObjectSP SerializeToStructuredData() override;
- ~BreakpointResolverFileLine() override;
+ ~BreakpointResolverFileLine() override = default;
Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
SymbolContext &context,
@@ -52,7 +53,8 @@ public:
return V->getResolverID() == BreakpointResolver::FileLineResolver;
}
- lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
+ lldb::BreakpointResolverSP
+ CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override;
protected:
void FilterContexts(SymbolContextList &sc_list, bool is_relative);
@@ -67,9 +69,11 @@ protected:
bool m_exact_match;
private:
- DISALLOW_COPY_AND_ASSIGN(BreakpointResolverFileLine);
+ BreakpointResolverFileLine(const BreakpointResolverFileLine &) = delete;
+ const BreakpointResolverFileLine &
+ operator=(const BreakpointResolverFileLine &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_BreakpointResolverFileLine_h_
+#endif // LLDB_BREAKPOINT_BREAKPOINTRESOLVERFILELINE_H
diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h b/lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
index df4c13ed59e2..138d555e2230 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_BreakpointResolverFileRegex_h_
-#define liblldb_BreakpointResolverFileRegex_h_
+#ifndef LLDB_BREAKPOINT_BREAKPOINTRESOLVERFILEREGEX_H
+#define LLDB_BREAKPOINT_BREAKPOINTRESOLVERFILEREGEX_H
#include <set>
#include "lldb/Breakpoint/BreakpointResolver.h"
@@ -24,17 +24,17 @@ namespace lldb_private {
class BreakpointResolverFileRegex : public BreakpointResolver {
public:
BreakpointResolverFileRegex(
- Breakpoint *bkpt, RegularExpression regex,
+ const lldb::BreakpointSP &bkpt, RegularExpression regex,
const std::unordered_set<std::string> &func_name_set, bool exact_match);
static BreakpointResolver *
- CreateFromStructuredData(Breakpoint *bkpt,
+ CreateFromStructuredData(const lldb::BreakpointSP &bkpt,
const StructuredData::Dictionary &options_dict,
Status &error);
StructuredData::ObjectSP SerializeToStructuredData() override;
- ~BreakpointResolverFileRegex() override;
+ ~BreakpointResolverFileRegex() override = default;
Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
SymbolContext &context,
@@ -56,7 +56,8 @@ public:
return V->getResolverID() == BreakpointResolver::FileRegexResolver;
}
- lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
+ lldb::BreakpointResolverSP
+ CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override;
protected:
friend class Breakpoint;
@@ -69,9 +70,11 @@ protected:
// comp_unit passed in.
private:
- DISALLOW_COPY_AND_ASSIGN(BreakpointResolverFileRegex);
+ BreakpointResolverFileRegex(const BreakpointResolverFileRegex &) = delete;
+ const BreakpointResolverFileRegex &
+ operator=(const BreakpointResolverFileRegex &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_BreakpointResolverFileRegex_h_
+#endif // LLDB_BREAKPOINT_BREAKPOINTRESOLVERFILEREGEX_H
diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolverName.h b/lldb/include/lldb/Breakpoint/BreakpointResolverName.h
index 196d88db848c..7a9fc4660767 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointResolverName.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointResolverName.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_BreakpointResolverName_h_
-#define liblldb_BreakpointResolverName_h_
+#ifndef LLDB_BREAKPOINT_BREAKPOINTRESOLVERNAME_H
+#define LLDB_BREAKPOINT_BREAKPOINTRESOLVERNAME_H
#include <string>
#include <vector>
@@ -23,39 +23,41 @@ namespace lldb_private {
class BreakpointResolverName : public BreakpointResolver {
public:
- BreakpointResolverName(Breakpoint *bkpt, const char *name,
+ BreakpointResolverName(const lldb::BreakpointSP &bkpt, const char *name,
lldb::FunctionNameType name_type_mask,
lldb::LanguageType language,
Breakpoint::MatchType type, lldb::addr_t offset,
bool skip_prologue);
// This one takes an array of names. It is always MatchType = Exact.
- BreakpointResolverName(Breakpoint *bkpt, const char *names[],
+ BreakpointResolverName(const lldb::BreakpointSP &bkpt, const char *names[],
size_t num_names,
lldb::FunctionNameType name_type_mask,
lldb::LanguageType language, lldb::addr_t offset,
bool skip_prologue);
// This one takes a C++ array of names. It is always MatchType = Exact.
- BreakpointResolverName(Breakpoint *bkpt, std::vector<std::string> names,
+ BreakpointResolverName(const lldb::BreakpointSP &bkpt,
+ std::vector<std::string> names,
lldb::FunctionNameType name_type_mask,
lldb::LanguageType language, lldb::addr_t offset,
bool skip_prologue);
// Creates a function breakpoint by regular expression. Takes over control
// of the lifespan of func_regex.
- BreakpointResolverName(Breakpoint *bkpt, RegularExpression func_regex,
+ BreakpointResolverName(const lldb::BreakpointSP &bkpt,
+ RegularExpression func_regex,
lldb::LanguageType language, lldb::addr_t offset,
bool skip_prologue);
static BreakpointResolver *
- CreateFromStructuredData(Breakpoint *bkpt,
+ CreateFromStructuredData(const lldb::BreakpointSP &bkpt,
const StructuredData::Dictionary &data_dict,
Status &error);
StructuredData::ObjectSP SerializeToStructuredData() override;
- ~BreakpointResolverName() override;
+ ~BreakpointResolverName() override = default;
Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
SymbolContext &context,
@@ -73,7 +75,8 @@ public:
return V->getResolverID() == BreakpointResolver::NameResolver;
}
- lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
+ lldb::BreakpointResolverSP
+ CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override;
protected:
BreakpointResolverName(const BreakpointResolverName &rhs);
@@ -91,4 +94,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_BreakpointResolverName_h_
+#endif // LLDB_BREAKPOINT_BREAKPOINTRESOLVERNAME_H
diff --git a/lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h b/lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
index 89a7d03ce93f..26fd6f2f04d7 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_BreakpointResolverScripted_h_
-#define liblldb_BreakpointResolverScripted_h_
+#ifndef LLDB_BREAKPOINT_BREAKPOINTRESOLVERSCRIPTED_H
+#define LLDB_BREAKPOINT_BREAKPOINTRESOLVERSCRIPTED_H
#include "lldb/lldb-forward.h"
#include "lldb/Breakpoint/BreakpointResolver.h"
@@ -23,15 +23,15 @@ namespace lldb_private {
class BreakpointResolverScripted : public BreakpointResolver {
public:
- BreakpointResolverScripted(Breakpoint *bkpt,
+ BreakpointResolverScripted(const lldb::BreakpointSP &bkpt,
const llvm::StringRef class_name,
lldb::SearchDepth depth,
StructuredDataImpl *args_data);
- ~BreakpointResolverScripted() override;
+ ~BreakpointResolverScripted() override = default;
static BreakpointResolver *
- CreateFromStructuredData(Breakpoint *bkpt,
+ CreateFromStructuredData(const lldb::BreakpointSP &bkpt,
const StructuredData::Dictionary &options_dict,
Status &error);
@@ -53,12 +53,13 @@ public:
return V->getResolverID() == BreakpointResolver::PythonResolver;
}
- lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override;
+ lldb::BreakpointResolverSP
+ CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override;
protected:
void NotifyBreakpointSet() override;
private:
- void CreateImplementationIfNeeded();
+ void CreateImplementationIfNeeded(lldb::BreakpointSP bkpt);
ScriptInterpreter *GetScriptInterpreter();
std::string m_class_name;
@@ -69,9 +70,11 @@ private:
// SBStructuredData).
StructuredData::GenericSP m_implementation_sp;
- DISALLOW_COPY_AND_ASSIGN(BreakpointResolverScripted);
+ BreakpointResolverScripted(const BreakpointResolverScripted &) = delete;
+ const BreakpointResolverScripted &
+ operator=(const BreakpointResolverScripted &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_BreakpointResolverScripted_h_
+#endif // LLDB_BREAKPOINT_BREAKPOINTRESOLVERSCRIPTED_H
diff --git a/lldb/include/lldb/Breakpoint/BreakpointSite.h b/lldb/include/lldb/Breakpoint/BreakpointSite.h
index 5c9f79a9ab1c..5ce17f511db4 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointSite.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointSite.h
@@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_BreakpointSite_h_
-#define liblldb_BreakpointSite_h_
-
+#ifndef LLDB_BREAKPOINT_BREAKPOINTSITE_H
+#define LLDB_BREAKPOINT_BREAKPOINTSITE_H
#include <list>
#include <mutex>
@@ -61,6 +60,8 @@ public:
/// Sets the trap opcode
bool SetTrapOpcode(const uint8_t *trap_opcode, uint32_t trap_opcode_size);
+ void SetHardwareIndex(uint32_t index) override;
+
/// Gets the original instruction bytes that were overwritten by the trap
uint8_t *GetSavedOpcodeBytes();
@@ -224,9 +225,10 @@ private:
const lldb::BreakpointLocationSP &owner, lldb::addr_t m_addr,
bool use_hardware);
- DISALLOW_COPY_AND_ASSIGN(BreakpointSite);
+ BreakpointSite(const BreakpointSite &) = delete;
+ const BreakpointSite &operator=(const BreakpointSite &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_BreakpointSite_h_
+#endif // LLDB_BREAKPOINT_BREAKPOINTSITE_H
diff --git a/lldb/include/lldb/Breakpoint/BreakpointSiteList.h b/lldb/include/lldb/Breakpoint/BreakpointSiteList.h
index b10d119fcce6..98091bbaeb05 100644
--- a/lldb/include/lldb/Breakpoint/BreakpointSiteList.h
+++ b/lldb/include/lldb/Breakpoint/BreakpointSiteList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_BreakpointSiteList_h_
-#define liblldb_BreakpointSiteList_h_
+#ifndef LLDB_BREAKPOINT_BREAKPOINTSITELIST_H
+#define LLDB_BREAKPOINT_BREAKPOINTSITELIST_H
#include <functional>
#include <map>
@@ -170,4 +170,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_BreakpointSiteList_h_
+#endif // LLDB_BREAKPOINT_BREAKPOINTSITELIST_H
diff --git a/lldb/include/lldb/Breakpoint/Stoppoint.h b/lldb/include/lldb/Breakpoint/Stoppoint.h
index f20b10074051..36df77c4e91a 100644
--- a/lldb/include/lldb/Breakpoint/Stoppoint.h
+++ b/lldb/include/lldb/Breakpoint/Stoppoint.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Stoppoint_h_
-#define liblldb_Stoppoint_h_
+#ifndef LLDB_BREAKPOINT_STOPPOINT_H
+#define LLDB_BREAKPOINT_STOPPOINT_H
#include "lldb/Utility/UserID.h"
#include "lldb/lldb-private.h"
@@ -37,9 +37,10 @@ protected:
private:
// For Stoppoint only
- DISALLOW_COPY_AND_ASSIGN(Stoppoint);
+ Stoppoint(const Stoppoint &) = delete;
+ const Stoppoint &operator=(const Stoppoint &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Stoppoint_h_
+#endif // LLDB_BREAKPOINT_STOPPOINT_H
diff --git a/lldb/include/lldb/Breakpoint/StoppointCallbackContext.h b/lldb/include/lldb/Breakpoint/StoppointCallbackContext.h
index c1724a6b276f..db02ddd494fb 100644
--- a/lldb/include/lldb/Breakpoint/StoppointCallbackContext.h
+++ b/lldb/include/lldb/Breakpoint/StoppointCallbackContext.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_StoppointCallbackContext_h_
-#define liblldb_StoppointCallbackContext_h_
+#ifndef LLDB_BREAKPOINT_STOPPOINTCALLBACKCONTEXT_H
+#define LLDB_BREAKPOINT_STOPPOINTCALLBACKCONTEXT_H
#include "lldb/Target/ExecutionContext.h"
#include "lldb/lldb-private.h"
@@ -48,4 +48,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_StoppointCallbackContext_h_
+#endif // LLDB_BREAKPOINT_STOPPOINTCALLBACKCONTEXT_H
diff --git a/lldb/include/lldb/Breakpoint/StoppointLocation.h b/lldb/include/lldb/Breakpoint/StoppointLocation.h
index 3926f452e564..4d6ca044ccc4 100644
--- a/lldb/include/lldb/Breakpoint/StoppointLocation.h
+++ b/lldb/include/lldb/Breakpoint/StoppointLocation.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_StoppointLocation_h_
-#define liblldb_StoppointLocation_h_
+#ifndef LLDB_BREAKPOINT_STOPPOINTLOCATION_H
+#define LLDB_BREAKPOINT_STOPPOINTLOCATION_H
#include "lldb/Utility/UserID.h"
#include "lldb/lldb-private.h"
@@ -48,7 +48,7 @@ public:
virtual void Dump(Stream *stream) const {}
- void SetHardwareIndex(uint32_t index) { m_hardware_index = index; }
+ virtual void SetHardwareIndex(uint32_t index) { m_hardware_index = index; }
lldb::break_id_t GetID() const { return m_loc_id; }
@@ -77,10 +77,11 @@ protected:
private:
// For StoppointLocation only
- DISALLOW_COPY_AND_ASSIGN(StoppointLocation);
+ StoppointLocation(const StoppointLocation &) = delete;
+ const StoppointLocation &operator=(const StoppointLocation &) = delete;
StoppointLocation() = delete;
};
} // namespace lldb_private
-#endif // liblldb_StoppointLocation_h_
+#endif // LLDB_BREAKPOINT_STOPPOINTLOCATION_H
diff --git a/lldb/include/lldb/Breakpoint/Watchpoint.h b/lldb/include/lldb/Breakpoint/Watchpoint.h
index 2cc74bb4c632..bce15f0a85dd 100644
--- a/lldb/include/lldb/Breakpoint/Watchpoint.h
+++ b/lldb/include/lldb/Breakpoint/Watchpoint.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Watchpoint_h_
-#define liblldb_Watchpoint_h_
+#ifndef LLDB_BREAKPOINT_WATCHPOINT_H
+#define LLDB_BREAKPOINT_WATCHPOINT_H
#include <memory>
#include <string>
@@ -54,7 +54,8 @@ public:
lldb::WatchpointEventType m_watchpoint_event;
lldb::WatchpointSP m_new_watchpoint_sp;
- DISALLOW_COPY_AND_ASSIGN(WatchpointEventData);
+ WatchpointEventData(const WatchpointEventData &) = delete;
+ const WatchpointEventData &operator=(const WatchpointEventData &) = delete;
};
Watchpoint(Target &target, lldb::addr_t addr, uint32_t size,
@@ -160,8 +161,8 @@ private:
void ResetHitCount() { m_hit_count = 0; }
void ResetHistoricValues() {
- m_old_value_sp.reset(nullptr);
- m_new_value_sp.reset(nullptr);
+ m_old_value_sp.reset();
+ m_new_value_sp.reset();
}
Target &m_target;
@@ -204,9 +205,10 @@ private:
void SendWatchpointChangedEvent(WatchpointEventData *data);
- DISALLOW_COPY_AND_ASSIGN(Watchpoint);
+ Watchpoint(const Watchpoint &) = delete;
+ const Watchpoint &operator=(const Watchpoint &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Watchpoint_h_
+#endif // LLDB_BREAKPOINT_WATCHPOINT_H
diff --git a/lldb/include/lldb/Breakpoint/WatchpointList.h b/lldb/include/lldb/Breakpoint/WatchpointList.h
index bb73d4ab75da..283f991b178a 100644
--- a/lldb/include/lldb/Breakpoint/WatchpointList.h
+++ b/lldb/include/lldb/Breakpoint/WatchpointList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_WatchpointList_h_
-#define liblldb_WatchpointList_h_
+#ifndef LLDB_BREAKPOINT_WATCHPOINTLIST_H
+#define LLDB_BREAKPOINT_WATCHPOINTLIST_H
#include <list>
#include <mutex>
@@ -203,4 +203,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_WatchpointList_h_
+#endif // LLDB_BREAKPOINT_WATCHPOINTLIST_H
diff --git a/lldb/include/lldb/Breakpoint/WatchpointOptions.h b/lldb/include/lldb/Breakpoint/WatchpointOptions.h
index 0dc34d4ebef7..0a18c52d36d0 100644
--- a/lldb/include/lldb/Breakpoint/WatchpointOptions.h
+++ b/lldb/include/lldb/Breakpoint/WatchpointOptions.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_WatchpointOptions_h_
-#define liblldb_WatchpointOptions_h_
+#ifndef LLDB_BREAKPOINT_WATCHPOINTOPTIONS_H
+#define LLDB_BREAKPOINT_WATCHPOINTOPTIONS_H
#include <memory>
#include <string>
@@ -198,4 +198,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_WatchpointOptions_h_
+#endif // LLDB_BREAKPOINT_WATCHPOINTOPTIONS_H
diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h
index 70a7f790e40d..71e50b91d68e 100644
--- a/lldb/include/lldb/Core/Address.h
+++ b/lldb/include/lldb/Core/Address.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Address_h_
-#define liblldb_Address_h_
+#ifndef LLDB_CORE_ADDRESS_H
+#define LLDB_CORE_ADDRESS_H
#include "lldb/lldb-defines.h"
#include "lldb/lldb-forward.h"
@@ -515,4 +515,4 @@ bool operator!=(const Address &lhs, const Address &rhs);
} // namespace lldb_private
-#endif // liblldb_Address_h_
+#endif // LLDB_CORE_ADDRESS_H
diff --git a/lldb/include/lldb/Core/AddressRange.h b/lldb/include/lldb/Core/AddressRange.h
index ac748713a182..8ccf96a436a1 100644
--- a/lldb/include/lldb/Core/AddressRange.h
+++ b/lldb/include/lldb/Core/AddressRange.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_AddressRange_h_
-#define liblldb_AddressRange_h_
+#ifndef LLDB_CORE_ADDRESSRANGE_H
+#define LLDB_CORE_ADDRESSRANGE_H
#include "lldb/Core/Address.h"
#include "lldb/lldb-forward.h"
@@ -247,4 +247,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_AddressRange_h_
+#endif // LLDB_CORE_ADDRESSRANGE_H
diff --git a/lldb/include/lldb/Core/AddressResolver.h b/lldb/include/lldb/Core/AddressResolver.h
index cd95c7c31cd6..9ac058a97cd9 100644
--- a/lldb/include/lldb/Core/AddressResolver.h
+++ b/lldb/include/lldb/Core/AddressResolver.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_AddressResolver_h_
-#define liblldb_AddressResolver_h_
+#ifndef LLDB_CORE_ADDRESSRESOLVER_H
+#define LLDB_CORE_ADDRESSRESOLVER_H
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/SearchFilter.h"
@@ -55,9 +55,10 @@ protected:
std::vector<AddressRange> m_address_ranges;
private:
- DISALLOW_COPY_AND_ASSIGN(AddressResolver);
+ AddressResolver(const AddressResolver &) = delete;
+ const AddressResolver &operator=(const AddressResolver &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_AddressResolver_h_
+#endif // LLDB_CORE_ADDRESSRESOLVER_H
diff --git a/lldb/include/lldb/Core/AddressResolverFileLine.h b/lldb/include/lldb/Core/AddressResolverFileLine.h
index efbe3de1f294..46bf4155e865 100644
--- a/lldb/include/lldb/Core/AddressResolverFileLine.h
+++ b/lldb/include/lldb/Core/AddressResolverFileLine.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_AddressResolverFileLine_h_
-#define liblldb_AddressResolverFileLine_h_
+#ifndef LLDB_CORE_ADDRESSRESOLVERFILELINE_H
+#define LLDB_CORE_ADDRESSRESOLVERFILELINE_H
#include "lldb/Core/AddressResolver.h"
#include "lldb/Core/SearchFilter.h"
@@ -48,9 +48,11 @@ protected:
// functions or not.
private:
- DISALLOW_COPY_AND_ASSIGN(AddressResolverFileLine);
+ AddressResolverFileLine(const AddressResolverFileLine &) = delete;
+ const AddressResolverFileLine &
+ operator=(const AddressResolverFileLine &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_AddressResolverFileLine_h_
+#endif // LLDB_CORE_ADDRESSRESOLVERFILELINE_H
diff --git a/lldb/include/lldb/Core/AddressResolverName.h b/lldb/include/lldb/Core/AddressResolverName.h
index 8a039f9e1d92..0ec1ef05b0ec 100644
--- a/lldb/include/lldb/Core/AddressResolverName.h
+++ b/lldb/include/lldb/Core/AddressResolverName.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_AddressResolverName_h_
-#define liblldb_AddressResolverName_h_
+#ifndef LLDB_CORE_ADDRESSRESOLVERNAME_H
+#define LLDB_CORE_ADDRESSRESOLVERNAME_H
#include "lldb/Core/AddressResolver.h"
#include "lldb/Core/SearchFilter.h"
@@ -54,9 +54,10 @@ protected:
AddressResolver::MatchType m_match_type;
private:
- DISALLOW_COPY_AND_ASSIGN(AddressResolverName);
+ AddressResolverName(const AddressResolverName &) = delete;
+ const AddressResolverName &operator=(const AddressResolverName &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_AddressResolverName_h_
+#endif // LLDB_CORE_ADDRESSRESOLVERNAME_H
diff --git a/lldb/include/lldb/Core/ClangForward.h b/lldb/include/lldb/Core/ClangForward.h
deleted file mode 100644
index 0bc331438e5c..000000000000
--- a/lldb/include/lldb/Core/ClangForward.h
+++ /dev/null
@@ -1,133 +0,0 @@
-//===-- ClangForward.h ------------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_ClangForward_h_
-#define liblldb_ClangForward_h_
-
-
-#if defined(__cplusplus)
-
-namespace clang {
-namespace Builtin {
-class Context;
-}
-
-class ASTConsumer;
-class ASTContext;
-class ASTRecordLayout;
-class AddrLabelExpr;
-class AnalyzerOptions;
-class BinaryOperator;
-class ClassTemplateDecl;
-class ClassTemplateSpecializationDecl;
-class CodeGenOptions;
-class CodeGenerator;
-class CompilerInstance;
-class CompoundStmt;
-class CXXBaseSpecifier;
-class CXXBoolLiteralExpr;
-class CXXFunctionalCastExpr;
-class CXXMethodDecl;
-class CXXNamedCastExpr;
-class CXXRecordDecl;
-class CXXThisExpr;
-class CharacterLiteral;
-class CompoundAssignOperator;
-class Decl;
-class DeclarationName;
-class DeclaratorDecl;
-class DeclContext;
-class DeclRefExpr;
-class DeclStmt;
-class DependencyOutputOptions;
-class Diagnostic;
-class DiagnosticConsumer;
-class DiagnosticsEngine;
-class DiagnosticOptions;
-class EnumDecl;
-class EnumConstantDecl;
-class Expr;
-class ExternalASTSource;
-class ExtVectorElementExpr;
-class FieldDecl;
-class FileManager;
-class FileSystemOptions;
-class FloatingLiteral;
-class FrontendOptions;
-class FunctionDecl;
-class FunctionTemplateDecl;
-class FunctionTemplateSpecializationInfo;
-class GotoStmt;
-class HeaderSearchOptions;
-class IdentifierInfo;
-class IdentifierTable;
-class IntegerLiteral;
-class LabelStmt;
-class LangOptions;
-class MacroDirective;
-class MemberExpr;
-class Module;
-class NamedDecl;
-class NamespaceDecl;
-class NonTypeTemplateParmDecl;
-class ObjCEncodeExpr;
-class ObjCImplicitSetterGetterRefExpr;
-class ObjCInterfaceDecl;
-class ObjCIvarDecl;
-class ObjCIvarRefExpr;
-class ObjCMessageExpr;
-class ObjCMethodDecl;
-class ObjCPropertyRefExpr;
-class ObjCProtocolDecl;
-class ObjCProtocolExpr;
-class ObjCSelectorExpr;
-class ObjCSuperExpr;
-class ParenExpr;
-class ParmVarDecl;
-class PredefinedExpr;
-class PreprocessorOptions;
-class PreprocessorOutputOptions;
-class QualType;
-class QualifiedNameType;
-class RecordDecl;
-class SelectorTable;
-class SizeOfAlignOfExpr;
-class SourceLocation;
-class SourceManager;
-class Stmt;
-class StmtIteratorBase;
-class StringLiteral;
-class TagDecl;
-class TargetInfo;
-class TargetOptions;
-class TemplateArgument;
-class TemplateDecl;
-class TemplateParameterList;
-class TemplateTemplateParmDecl;
-class TemplateTypeParmDecl;
-class TextDiagnosticBuffer;
-class TranslationUnitDecl;
-class Type;
-class TypeDecl;
-class TypedefDecl;
-class TypesCompatibleExpr;
-class UnaryOperator;
-class ValueDecl;
-class VarDecl;
-struct PrintingPolicy;
-}
-
-namespace llvm {
-class APInt;
-class APSInt;
-class LLVMContext;
-class ExecutionEngine;
-}
-
-#endif // #if defined(__cplusplus)
-#endif // liblldb_ClangForward_h_
diff --git a/lldb/include/lldb/Core/Communication.h b/lldb/include/lldb/Core/Communication.h
index 901b8fdb8c8b..6b65974f9522 100644
--- a/lldb/include/lldb/Core/Communication.h
+++ b/lldb/include/lldb/Core/Communication.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Communication_h_
-#define liblldb_Communication_h_
+#ifndef LLDB_CORE_COMMUNICATION_H
+#define LLDB_CORE_COMMUNICATION_H
#include "lldb/Host/HostThread.h"
#include "lldb/Utility/Broadcaster.h"
@@ -221,7 +221,7 @@ public:
///
/// \see
/// class Connection
- void SetConnection(Connection *connection);
+ void SetConnection(std::unique_ptr<Connection> connection);
/// Starts a read thread whose sole purpose it to read bytes from the
/// current connection. This function will call connection's read function:
@@ -359,9 +359,10 @@ protected:
size_t GetCachedBytes(void *dst, size_t dst_len);
private:
- DISALLOW_COPY_AND_ASSIGN(Communication);
+ Communication(const Communication &) = delete;
+ const Communication &operator=(const Communication &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Communication_h_
+#endif // LLDB_CORE_COMMUNICATION_H
diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h
index a8048427c8f1..7bea0dbae082 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Debugger_h_
-#define liblldb_Debugger_h_
+#ifndef LLDB_CORE_DEBUGGER_H
+#define LLDB_CORE_DEBUGGER_H
#include <stdint.h>
@@ -190,13 +190,15 @@ public:
lldb::StreamFileSP &out,
lldb::StreamFileSP &err);
- void PushIOHandler(const lldb::IOHandlerSP &reader_sp,
- bool cancel_top_handler = true);
+ /// Run the given IO handler and return immediately.
+ void RunIOHandlerAsync(const lldb::IOHandlerSP &reader_sp,
+ bool cancel_top_handler = true);
- bool PopIOHandler(const lldb::IOHandlerSP &reader_sp);
+ /// Run the given IO handler and block until it's complete.
+ void RunIOHandlerSync(const lldb::IOHandlerSP &reader_sp);
- // Synchronously run an input reader until it is done
- void RunIOHandler(const lldb::IOHandlerSP &reader_sp);
+ /// Remove the given IO handler if it's currently active.
+ bool RemoveIOHandler(const lldb::IOHandlerSP &reader_sp);
bool IsTopIOHandler(const lldb::IOHandlerSP &reader_sp);
@@ -271,6 +273,10 @@ public:
bool SetUseColor(bool use_color);
+ bool GetUseSourceCache() const;
+
+ bool SetUseSourceCache(bool use_source_cache);
+
bool GetHighlightSource() const;
lldb::StopShowColumn GetStopShowColumn() const;
@@ -285,6 +291,10 @@ public:
uint32_t GetDisassemblyLineCount() const;
+ llvm::StringRef GetStopShowLineMarkerAnsiPrefix() const;
+
+ llvm::StringRef GetStopShowLineMarkerAnsiSuffix() const;
+
bool GetAutoOneLineSummaries() const;
bool GetAutoIndent() const;
@@ -307,7 +317,7 @@ public:
bool LoadPlugin(const FileSpec &spec, Status &error);
- void ExecuteIOHandlers();
+ void RunIOHandlers();
bool IsForwardingEvents();
@@ -339,6 +349,11 @@ protected:
static lldb::thread_result_t EventHandlerThread(lldb::thread_arg_t arg);
+ void PushIOHandler(const lldb::IOHandlerSP &reader_sp,
+ bool cancel_top_handler = true);
+
+ bool PopIOHandler(const lldb::IOHandlerSP &reader_sp);
+
bool HasIOHandlerThread();
bool StartIOHandlerThread();
@@ -402,7 +417,9 @@ protected:
std::array<lldb::ScriptInterpreterSP, lldb::eScriptLanguageUnknown>
m_script_interpreters;
- IOHandlerStack m_input_reader_stack;
+ IOHandlerStack m_io_handler_stack;
+ std::recursive_mutex m_io_handler_synchronous_mutex;
+
llvm::StringMap<std::weak_ptr<llvm::raw_ostream>> m_log_streams;
std::shared_ptr<llvm::raw_ostream> m_log_callback_stream_sp;
ConstString m_instance_name;
@@ -426,9 +443,10 @@ private:
// object
Debugger(lldb::LogOutputCallback m_log_callback, void *baton);
- DISALLOW_COPY_AND_ASSIGN(Debugger);
+ Debugger(const Debugger &) = delete;
+ const Debugger &operator=(const Debugger &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Debugger_h_
+#endif // LLDB_CORE_DEBUGGER_H
diff --git a/lldb/include/lldb/Core/Disassembler.h b/lldb/include/lldb/Core/Disassembler.h
index 7ece0eeb708c..926a74b933ef 100644
--- a/lldb/include/lldb/Core/Disassembler.h
+++ b/lldb/include/lldb/Core/Disassembler.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Disassembler_h_
-#define liblldb_Disassembler_h_
+#ifndef LLDB_CORE_DISASSEMBLER_H
+#define LLDB_CORE_DISASSEMBLER_H
#include "lldb/Core/Address.h"
#include "lldb/Core/EmulateInstruction.h"
@@ -349,7 +349,8 @@ public:
protected:
std::string m_description;
- DISALLOW_COPY_AND_ASSIGN(PseudoInstruction);
+ PseudoInstruction(const PseudoInstruction &) = delete;
+ const PseudoInstruction &operator=(const PseudoInstruction &) = delete;
};
class Disassembler : public std::enable_shared_from_this<Disassembler>,
@@ -379,13 +380,19 @@ public:
FindPlugin(const ArchSpec &arch, const char *flavor, const char *plugin_name);
// This version will use the value in the Target settings if flavor is NULL;
- static lldb::DisassemblerSP
- FindPluginForTarget(const lldb::TargetSP target_sp, const ArchSpec &arch,
- const char *flavor, const char *plugin_name);
+ static lldb::DisassemblerSP FindPluginForTarget(const Target &target,
+ const ArchSpec &arch,
+ const char *flavor,
+ const char *plugin_name);
+
+ struct Limit {
+ enum { Bytes, Instructions } kind;
+ lldb::addr_t value;
+ };
static lldb::DisassemblerSP
DisassembleRange(const ArchSpec &arch, const char *plugin_name,
- const char *flavor, const ExecutionContext &exe_ctx,
+ const char *flavor, Target &target,
const AddressRange &disasm_range, bool prefer_file_cache);
static lldb::DisassemblerSP
@@ -396,34 +403,11 @@ public:
static bool Disassemble(Debugger &debugger, const ArchSpec &arch,
const char *plugin_name, const char *flavor,
- const ExecutionContext &exe_ctx,
- const AddressRange &range, uint32_t num_instructions,
- bool mixed_source_and_assembly,
- uint32_t num_mixed_context_lines, uint32_t options,
- Stream &strm);
-
- static bool Disassemble(Debugger &debugger, const ArchSpec &arch,
- const char *plugin_name, const char *flavor,
const ExecutionContext &exe_ctx, const Address &start,
- uint32_t num_instructions,
- bool mixed_source_and_assembly,
+ Limit limit, bool mixed_source_and_assembly,
uint32_t num_mixed_context_lines, uint32_t options,
Stream &strm);
- static size_t
- Disassemble(Debugger &debugger, const ArchSpec &arch, const char *plugin_name,
- const char *flavor, const ExecutionContext &exe_ctx,
- SymbolContextList &sc_list, uint32_t num_instructions,
- bool mixed_source_and_assembly, uint32_t num_mixed_context_lines,
- uint32_t options, Stream &strm);
-
- static bool
- Disassemble(Debugger &debugger, const ArchSpec &arch, const char *plugin_name,
- const char *flavor, const ExecutionContext &exe_ctx,
- ConstString name, Module *module,
- uint32_t num_instructions, bool mixed_source_and_assembly,
- uint32_t num_mixed_context_lines, uint32_t options, Stream &strm);
-
static bool
Disassemble(Debugger &debugger, const ArchSpec &arch, const char *plugin_name,
const char *flavor, const ExecutionContext &exe_ctx,
@@ -434,25 +418,14 @@ public:
Disassembler(const ArchSpec &arch, const char *flavor);
~Disassembler() override;
- typedef const char *(*SummaryCallback)(const Instruction &inst,
- ExecutionContext *exe_context,
- void *user_data);
-
- static bool PrintInstructions(Disassembler *disasm_ptr, Debugger &debugger,
- const ArchSpec &arch,
- const ExecutionContext &exe_ctx,
- uint32_t num_instructions,
- bool mixed_source_and_assembly,
- uint32_t num_mixed_context_lines,
- uint32_t options, Stream &strm);
-
- size_t ParseInstructions(const ExecutionContext *exe_ctx,
- const AddressRange &range, Stream *error_strm_ptr,
- bool prefer_file_cache);
+ void PrintInstructions(Debugger &debugger, const ArchSpec &arch,
+ const ExecutionContext &exe_ctx,
+ bool mixed_source_and_assembly,
+ uint32_t num_mixed_context_lines, uint32_t options,
+ Stream &strm);
- size_t ParseInstructions(const ExecutionContext *exe_ctx,
- const Address &range, uint32_t num_instructions,
- bool prefer_file_cache);
+ size_t ParseInstructions(Target &target, Address address, Limit limit,
+ Stream *error_strm_ptr, bool prefer_file_cache);
virtual size_t DecodeInstructions(const Address &base_addr,
const DataExtractor &data,
@@ -548,9 +521,10 @@ protected:
private:
// For Disassembler only
- DISALLOW_COPY_AND_ASSIGN(Disassembler);
+ Disassembler(const Disassembler &) = delete;
+ const Disassembler &operator=(const Disassembler &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Disassembler_h_
+#endif // LLDB_CORE_DISASSEMBLER_H
diff --git a/lldb/include/lldb/Core/EmulateInstruction.h b/lldb/include/lldb/Core/EmulateInstruction.h
index 6b19c17e5491..a575488ba966 100644
--- a/lldb/include/lldb/Core/EmulateInstruction.h
+++ b/lldb/include/lldb/Core/EmulateInstruction.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_EmulateInstruction_h_
-#define lldb_EmulateInstruction_h_
+#ifndef LLDB_CORE_EMULATEINSTRUCTION_H
+#define LLDB_CORE_EMULATEINSTRUCTION_H
#include <string>
@@ -499,9 +499,10 @@ protected:
private:
// For EmulateInstruction only
- DISALLOW_COPY_AND_ASSIGN(EmulateInstruction);
+ EmulateInstruction(const EmulateInstruction &) = delete;
+ const EmulateInstruction &operator=(const EmulateInstruction &) = delete;
};
} // namespace lldb_private
-#endif // lldb_EmulateInstruction_h_
+#endif // LLDB_CORE_EMULATEINSTRUCTION_H
diff --git a/lldb/include/lldb/Core/FileLineResolver.h b/lldb/include/lldb/Core/FileLineResolver.h
index d6525b71bfdf..68e252e93bc9 100644
--- a/lldb/include/lldb/Core/FileLineResolver.h
+++ b/lldb/include/lldb/Core/FileLineResolver.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_FileLineResolver_h_
-#define liblldb_FileLineResolver_h_
+#ifndef LLDB_CORE_FILELINERESOLVER_H
+#define LLDB_CORE_FILELINERESOLVER_H
#include "lldb/Core/SearchFilter.h"
#include "lldb/Symbol/SymbolContext.h"
@@ -58,9 +58,10 @@ protected:
// functions or not.
private:
- DISALLOW_COPY_AND_ASSIGN(FileLineResolver);
+ FileLineResolver(const FileLineResolver &) = delete;
+ const FileLineResolver &operator=(const FileLineResolver &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_FileLineResolver_h_
+#endif // LLDB_CORE_FILELINERESOLVER_H
diff --git a/lldb/include/lldb/Core/FileSpecList.h b/lldb/include/lldb/Core/FileSpecList.h
index 8edc3280b01b..3e412a7e1a32 100644
--- a/lldb/include/lldb/Core/FileSpecList.h
+++ b/lldb/include/lldb/Core/FileSpecList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_FileSpecList_h_
-#define liblldb_FileSpecList_h_
+#ifndef LLDB_CORE_FILESPECLIST_H
+#define LLDB_CORE_FILESPECLIST_H
#if defined(__cplusplus)
#include "lldb/Utility/FileSpec.h"
@@ -204,4 +204,4 @@ protected:
} // namespace lldb_private
#endif // #if defined(__cplusplus)
-#endif // liblldb_FileSpecList_h_
+#endif // LLDB_CORE_FILESPECLIST_H
diff --git a/lldb/include/lldb/Core/FormatEntity.h b/lldb/include/lldb/Core/FormatEntity.h
index 8ee320b0ebb1..91999f64ab5f 100644
--- a/lldb/include/lldb/Core/FormatEntity.h
+++ b/lldb/include/lldb/Core/FormatEntity.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_FormatEntity_h_
-#define liblldb_FormatEntity_h_
+#ifndef LLDB_CORE_FORMATENTITY_H
+#define LLDB_CORE_FORMATENTITY_H
#include "lldb/Utility/CompletionRequest.h"
#include "lldb/Utility/FileSpec.h"
@@ -61,6 +61,7 @@ public:
ThreadName,
ThreadQueue,
ThreadStopReason,
+ ThreadStopReasonRaw,
ThreadReturnValue,
ThreadCompletedExpression,
ScriptThread,
@@ -218,4 +219,4 @@ protected:
};
} // namespace lldb_private
-#endif // liblldb_FormatEntity_h_
+#endif // LLDB_CORE_FORMATENTITY_H
diff --git a/lldb/include/lldb/Core/Highlighter.h b/lldb/include/lldb/Core/Highlighter.h
index 8a268ec1d6b1..b138e57af419 100644
--- a/lldb/include/lldb/Core/Highlighter.h
+++ b/lldb/include/lldb/Core/Highlighter.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Highlighter_h_
-#define liblldb_Highlighter_h_
+#ifndef LLDB_CORE_HIGHLIGHTER_H
+#define LLDB_CORE_HIGHLIGHTER_H
#include <utility>
#include <vector>
@@ -91,7 +91,8 @@ class Highlighter {
public:
Highlighter() = default;
virtual ~Highlighter() = default;
- DISALLOW_COPY_AND_ASSIGN(Highlighter);
+ Highlighter(const Highlighter &) = delete;
+ const Highlighter &operator=(const Highlighter &) = delete;
/// Returns a human readable name for the selected highlighter.
virtual llvm::StringRef GetName() const = 0;
@@ -152,4 +153,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_Highlighter_h_
+#endif // LLDB_CORE_HIGHLIGHTER_H
diff --git a/lldb/include/lldb/Core/IOHandler.h b/lldb/include/lldb/Core/IOHandler.h
index 9ab5eaaecb66..51592afbbabe 100644
--- a/lldb/include/lldb/Core/IOHandler.h
+++ b/lldb/include/lldb/Core/IOHandler.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_IOHandler_h_
-#define liblldb_IOHandler_h_
+#ifndef LLDB_CORE_IOHANDLER_H
+#define LLDB_CORE_IOHANDLER_H
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Host/Config.h"
@@ -95,6 +95,8 @@ public:
virtual void Deactivate() { m_active = false; }
+ virtual void TerminalSizeChanged() {}
+
virtual const char *GetPrompt() {
// Prompt support isn't mandatory
return nullptr;
@@ -178,7 +180,8 @@ protected:
bool m_active;
private:
- DISALLOW_COPY_AND_ASSIGN(IOHandler);
+ IOHandler(const IOHandler &) = delete;
+ const IOHandler &operator=(const IOHandler &) = delete;
};
/// A delegate class for use with IOHandler subclasses.
@@ -369,6 +372,8 @@ public:
void Deactivate() override;
+ void TerminalSizeChanged() override;
+
ConstString GetControlSequence(char ch) override {
return m_delegate.IOHandlerGetControlSequence(ch);
}
@@ -540,9 +545,10 @@ protected:
IOHandler *m_top = nullptr;
private:
- DISALLOW_COPY_AND_ASSIGN(IOHandlerStack);
+ IOHandlerStack(const IOHandlerStack &) = delete;
+ const IOHandlerStack &operator=(const IOHandlerStack &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_IOHandler_h_
+#endif // LLDB_CORE_IOHANDLER_H
diff --git a/lldb/include/lldb/Core/IOHandlerCursesGUI.h b/lldb/include/lldb/Core/IOHandlerCursesGUI.h
index afa435269725..fe62eaea643e 100644
--- a/lldb/include/lldb/Core/IOHandlerCursesGUI.h
+++ b/lldb/include/lldb/Core/IOHandlerCursesGUI.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_IOHandlerCursesGUI_h_
-#define liblldb_IOHandlerCursesGUI_h_
+#ifndef LLDB_CORE_IOHANDLERCURSESGUI_H
+#define LLDB_CORE_IOHANDLERCURSESGUI_H
#include "lldb/Core/IOHandler.h"
@@ -37,4 +37,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_IOHandlerCursesGUI_h_
+#endif // LLDB_CORE_IOHANDLERCURSESGUI_H
diff --git a/lldb/include/lldb/Core/LoadedModuleInfoList.h b/lldb/include/lldb/Core/LoadedModuleInfoList.h
index 04e58fcdf313..49400f7f4908 100644
--- a/lldb/include/lldb/Core/LoadedModuleInfoList.h
+++ b/lldb/include/lldb/Core/LoadedModuleInfoList.h
@@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_LoadedModuleInfoList_h_
-#define liblldb_LoadedModuleInfoList_h_
-
+#ifndef LLDB_CORE_LOADEDMODULEINFOLIST_H
+#define LLDB_CORE_LOADEDMODULEINFOLIST_H
#include <cassert>
#include <string>
@@ -113,4 +112,4 @@ public:
};
} // namespace lldb_private
-#endif // liblldb_LoadedModuleInfoList_h_
+#endif // LLDB_CORE_LOADEDMODULEINFOLIST_H
diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h
index 6af68c3f5857..c03fc1eb7599 100644
--- a/lldb/include/lldb/Core/Mangled.h
+++ b/lldb/include/lldb/Core/Mangled.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Mangled_h_
-#define liblldb_Mangled_h_
+#ifndef LLDB_CORE_MANGLED_H
+#define LLDB_CORE_MANGLED_H
#if defined(__cplusplus)
#include "lldb/lldb-enumerations.h"
@@ -132,13 +132,13 @@ public:
///
/// \return
/// A const reference to the demangled name string object.
- ConstString GetDemangledName(lldb::LanguageType language) const;
+ ConstString GetDemangledName() const;
/// Display demangled name get accessor.
///
/// \return
/// A const reference to the display demangled name string object.
- ConstString GetDisplayDemangledName(lldb::LanguageType language) const;
+ ConstString GetDisplayDemangledName() const;
void SetDemangledName(ConstString name) { m_demangled = name; }
@@ -165,8 +165,7 @@ public:
/// A const reference to the preferred name string object if this
/// object has a valid name of that kind, else a const reference to the
/// other name is returned.
- ConstString GetName(lldb::LanguageType language,
- NamePreference preference = ePreferDemangled) const;
+ ConstString GetName(NamePreference preference = ePreferDemangled) const;
/// Check if "name" matches either the mangled or demangled name.
///
@@ -175,13 +174,12 @@ public:
///
/// \return
/// \b True if \a name matches either name, \b false otherwise.
- bool NameMatches(ConstString name, lldb::LanguageType language) const {
+ bool NameMatches(ConstString name) const {
if (m_mangled == name)
return true;
- return GetDemangledName(language) == name;
+ return GetDemangledName() == name;
}
- bool NameMatches(const RegularExpression &regex,
- lldb::LanguageType language) const;
+ bool NameMatches(const RegularExpression &regex) const;
/// Get the memory cost of this object.
///
@@ -282,4 +280,4 @@ Stream &operator<<(Stream &s, const Mangled &obj);
} // namespace lldb_private
#endif // #if defined(__cplusplus)
-#endif // liblldb_Mangled_h_
+#endif // LLDB_CORE_MANGLED_H
diff --git a/lldb/include/lldb/Core/MappedHash.h b/lldb/include/lldb/Core/MappedHash.h
index 7dc9b5be3465..a27ec82b9b86 100644
--- a/lldb/include/lldb/Core/MappedHash.h
+++ b/lldb/include/lldb/Core/MappedHash.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_MappedHash_h_
-#define liblldb_MappedHash_h_
+#ifndef LLDB_CORE_MAPPEDHASH_H
+#define LLDB_CORE_MAPPEDHASH_H
#include <assert.h>
#include <stdint.h>
@@ -307,4 +307,4 @@ public:
};
};
-#endif // liblldb_MappedHash_h_
+#endif // LLDB_CORE_MAPPEDHASH_H
diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index 2af18c83f23a..8bd70ab16b5a 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -6,10 +6,11 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Module_h_
-#define liblldb_Module_h_
+#ifndef LLDB_CORE_MODULE_H
+#define LLDB_CORE_MODULE_H
#include "lldb/Core/Address.h"
+#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContextScope.h"
@@ -19,6 +20,7 @@
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Status.h"
+#include "lldb/Utility/XcodeSDK.h"
#include "lldb/Utility/UUID.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-enumerations.h"
@@ -301,7 +303,7 @@ public:
/// A symbol context list that gets filled in with all of the
/// matches.
void FindFunctions(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
+ const CompilerDeclContext &parent_decl_ctx,
lldb::FunctionNameType name_type_mask, bool symbols_ok,
bool inlines_ok, SymbolContextList &sc_list);
@@ -364,7 +366,7 @@ public:
/// A list of variables that gets the matches appended to.
///
void FindGlobalVariables(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
+ const CompilerDeclContext &parent_decl_ctx,
size_t max_matches, VariableList &variable_list);
/// Find global and static variables by regular expression.
@@ -443,7 +445,7 @@ public:
/// \param[out] type_list
/// A type list gets populated with any matches.
void FindTypesInNamespace(ConstString type_name,
- const CompilerDeclContext *parent_decl_ctx,
+ const CompilerDeclContext &parent_decl_ctx,
size_t max_matches, TypeList &type_list);
/// Get const accessor for the module architecture.
@@ -508,6 +510,11 @@ public:
m_mod_time = mod_time;
}
+ /// This callback will be called by SymbolFile implementations when
+ /// parsing a compile unit that contains SDK information.
+ /// \param sysroot will be added to the path remapping dictionary.
+ void RegisterXcodeSDK(llvm::StringRef sdk, llvm::StringRef sysroot);
+
/// Tells whether this module is capable of being the main executable for a
/// process.
///
@@ -951,6 +958,12 @@ protected:
///by \a m_file.
uint64_t m_object_offset;
llvm::sys::TimePoint<> m_object_mod_time;
+
+ /// DataBuffer containing the module image, if it was provided at
+ /// construction time. Otherwise the data will be retrieved by mapping
+ /// one of the FileSpec members above.
+ lldb::DataBufferSP m_data_sp;
+
lldb::ObjectFileSP m_objfile_sp; ///< A shared pointer to the object file
///parser for this module as it may or may
///not be shared with the SymbolFile
@@ -966,10 +979,11 @@ protected:
///references to them
TypeSystemMap m_type_system_map; ///< A map of any type systems associated
///with this module
- PathMappingList m_source_mappings; ///< Module specific source remappings for
- ///when you have debug info for a module
- ///that doesn't match where the sources
- ///currently are
+ /// Module specific source remappings for when you have debug info for a
+ /// module that doesn't match where the sources currently are.
+ PathMappingList m_source_mappings =
+ ModuleList::GetGlobalModuleListProperties().GetSymlinkMappings();
+
lldb::SectionListUP m_sections_up; ///< Unified section list for module that
/// is used by the ObjectFile and and
/// ObjectFile instances for the debug info
@@ -1036,14 +1050,15 @@ private:
Module(); // Only used internally by CreateJITModule ()
void FindTypes_Impl(
- ConstString name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext &parent_decl_ctx,
size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types);
- DISALLOW_COPY_AND_ASSIGN(Module);
+ Module(const Module &) = delete;
+ const Module &operator=(const Module &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Module_h_
+#endif // LLDB_CORE_MODULE_H
diff --git a/lldb/include/lldb/Core/ModuleChild.h b/lldb/include/lldb/Core/ModuleChild.h
index 0d59e4fb12ca..63eb1372ff68 100644
--- a/lldb/include/lldb/Core/ModuleChild.h
+++ b/lldb/include/lldb/Core/ModuleChild.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ModuleChild_h_
-#define liblldb_ModuleChild_h_
+#ifndef LLDB_CORE_MODULECHILD_H
+#define LLDB_CORE_MODULECHILD_H
#include "lldb/lldb-forward.h"
@@ -58,4 +58,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_ModuleChild_h_
+#endif // LLDB_CORE_MODULECHILD_H
diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h
index a6e80ed75c76..ae1f6fdb20a2 100644
--- a/lldb/include/lldb/Core/ModuleList.h
+++ b/lldb/include/lldb/Core/ModuleList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ModuleList_h_
-#define liblldb_ModuleList_h_
+#ifndef LLDB_CORE_MODULELIST_H
+#define LLDB_CORE_MODULELIST_H
#include "lldb/Core/Address.h"
#include "lldb/Core/ModuleSpec.h"
@@ -20,6 +20,7 @@
#include "lldb/lldb-types.h"
#include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/RWMutex.h"
#include <functional>
#include <list>
@@ -46,6 +47,11 @@ class UUID;
class VariableList;
class ModuleListProperties : public Properties {
+ mutable llvm::sys::RWMutex m_symlink_paths_mutex;
+ PathMappingList m_symlink_paths;
+
+ void UpdateSymlinkMappings();
+
public:
ModuleListProperties();
@@ -53,6 +59,8 @@ public:
bool SetClangModulesCachePath(llvm::StringRef path);
bool GetEnableExternalLookup() const;
bool SetEnableExternalLookup(bool new_value);
+
+ PathMappingList GetSymlinkMappings() const;
};
/// \class ModuleList ModuleList.h "lldb/Core/ModuleList.h"
@@ -489,4 +497,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_ModuleList_h_
+#endif // LLDB_CORE_MODULELIST_H
diff --git a/lldb/include/lldb/Core/ModuleSpec.h b/lldb/include/lldb/Core/ModuleSpec.h
index 6d024fe3434b..9dd398a05291 100644
--- a/lldb/include/lldb/Core/ModuleSpec.h
+++ b/lldb/include/lldb/Core/ModuleSpec.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ModuleSpec_h_
-#define liblldb_ModuleSpec_h_
+#ifndef LLDB_CORE_MODULESPEC_H
+#define LLDB_CORE_MODULESPEC_H
#include "lldb/Host/FileSystem.h"
#include "lldb/Target/PathMappingList.h"
@@ -30,11 +30,19 @@ public:
m_object_name(), m_object_offset(0), m_object_size(0),
m_source_mappings() {}
- ModuleSpec(const FileSpec &file_spec, const UUID &uuid = UUID())
+ /// If the \param data argument is passed, its contents will be used
+ /// as the module contents instead of trying to read them from
+ /// \param file_spec.
+ ModuleSpec(const FileSpec &file_spec, const UUID &uuid = UUID(),
+ lldb::DataBufferSP data = lldb::DataBufferSP())
: m_file(file_spec), m_platform_file(), m_symbol_file(), m_arch(),
- m_uuid(uuid), m_object_name(), m_object_offset(0),
- m_object_size(FileSystem::Instance().GetByteSize(file_spec)),
- m_source_mappings() {}
+ m_uuid(uuid), m_object_name(), m_object_offset(0), m_source_mappings(),
+ m_data(data) {
+ if (data)
+ m_object_size = data->GetByteSize();
+ else if (m_file)
+ m_object_size = FileSystem::Instance().GetByteSize(file_spec);
+ }
ModuleSpec(const FileSpec &file_spec, const ArchSpec &arch)
: m_file(file_spec), m_platform_file(), m_symbol_file(), m_arch(arch),
@@ -42,30 +50,6 @@ public:
m_object_size(FileSystem::Instance().GetByteSize(file_spec)),
m_source_mappings() {}
- ModuleSpec(const ModuleSpec &rhs)
- : m_file(rhs.m_file), m_platform_file(rhs.m_platform_file),
- m_symbol_file(rhs.m_symbol_file), m_arch(rhs.m_arch),
- m_uuid(rhs.m_uuid), m_object_name(rhs.m_object_name),
- m_object_offset(rhs.m_object_offset), m_object_size(rhs.m_object_size),
- m_object_mod_time(rhs.m_object_mod_time),
- m_source_mappings(rhs.m_source_mappings) {}
-
- ModuleSpec &operator=(const ModuleSpec &rhs) {
- if (this != &rhs) {
- m_file = rhs.m_file;
- m_platform_file = rhs.m_platform_file;
- m_symbol_file = rhs.m_symbol_file;
- m_arch = rhs.m_arch;
- m_uuid = rhs.m_uuid;
- m_object_name = rhs.m_object_name;
- m_object_offset = rhs.m_object_offset;
- m_object_size = rhs.m_object_size;
- m_object_mod_time = rhs.m_object_mod_time;
- m_source_mappings = rhs.m_source_mappings;
- }
- return *this;
- }
-
FileSpec *GetFileSpecPtr() { return (m_file ? &m_file : nullptr); }
const FileSpec *GetFileSpecPtr() const {
@@ -146,6 +130,8 @@ public:
PathMappingList &GetSourceMappingList() const { return m_source_mappings; }
+ lldb::DataBufferSP GetData() const { return m_data; }
+
void Clear() {
m_file.Clear();
m_platform_file.Clear();
@@ -289,6 +275,7 @@ protected:
uint64_t m_object_size;
llvm::sys::TimePoint<> m_object_mod_time;
mutable PathMappingList m_source_mappings;
+ lldb::DataBufferSP m_data = {};
};
class ModuleSpecList {
@@ -415,4 +402,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_ModuleSpec_h_
+#endif // LLDB_CORE_MODULESPEC_H
diff --git a/lldb/include/lldb/Core/Opcode.h b/lldb/include/lldb/Core/Opcode.h
index 1a30ce4834ac..a812ae23f6b7 100644
--- a/lldb/include/lldb/Core/Opcode.h
+++ b/lldb/include/lldb/Core/Opcode.h
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Opcode_h
-#define lldb_Opcode_h
+#ifndef LLDB_CORE_OPCODE_H
+#define LLDB_CORE_OPCODE_H
#include "lldb/Utility/Endian.h"
#include "lldb/lldb-enumerations.h"
-#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/SwapByteOrder.h"
#include <assert.h>
#include <stdint.h>
@@ -270,4 +270,4 @@ protected:
} // namespace lldb_private
-#endif // lldb_Opcode_h
+#endif // LLDB_CORE_OPCODE_H
diff --git a/lldb/include/lldb/Core/PluginInterface.h b/lldb/include/lldb/Core/PluginInterface.h
index 6e625a605917..17f6dc367155 100644
--- a/lldb/include/lldb/Core/PluginInterface.h
+++ b/lldb/include/lldb/Core/PluginInterface.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_PluginInterface_h_
-#define liblldb_PluginInterface_h_
+#ifndef LLDB_CORE_PLUGININTERFACE_H
+#define LLDB_CORE_PLUGININTERFACE_H
#include "lldb/lldb-private.h"
@@ -24,4 +24,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_PluginInterface_h_
+#endif // LLDB_CORE_PLUGININTERFACE_H
diff --git a/lldb/include/lldb/Core/PluginManager.h b/lldb/include/lldb/Core/PluginManager.h
index 5b859752b3c7..5e0c9395dae0 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_PluginManager_h_
-#define liblldb_PluginManager_h_
+#ifndef LLDB_CORE_PLUGINMANAGER_H
+#define LLDB_CORE_PLUGINMANAGER_H
#include "lldb/Core/Architecture.h"
#include "lldb/Symbol/TypeSystem.h"
@@ -22,6 +22,25 @@
#include <stddef.h>
#include <stdint.h>
+#define LLDB_PLUGIN_DEFINE_ADV(ClassName, PluginName) \
+ namespace lldb_private { \
+ void lldb_initialize_##PluginName() { ClassName::Initialize(); } \
+ void lldb_terminate_##PluginName() { ClassName::Terminate(); } \
+ }
+
+#define LLDB_PLUGIN_DEFINE(PluginName) \
+ LLDB_PLUGIN_DEFINE_ADV(PluginName, PluginName)
+
+// FIXME: Generate me with CMake
+#define LLDB_PLUGIN_DECLARE(PluginName) \
+ namespace lldb_private { \
+ extern void lldb_initialize_##PluginName(); \
+ extern void lldb_terminate_##PluginName(); \
+ }
+
+#define LLDB_PLUGIN_INITIALIZE(PluginName) lldb_initialize_##PluginName()
+#define LLDB_PLUGIN_TERMINATE(PluginName) lldb_terminate_##PluginName()
+
namespace lldb_private {
class CommandInterpreter;
class ConstString;
@@ -42,15 +61,8 @@ public:
static ABICreateInstance GetABICreateCallbackAtIndex(uint32_t idx);
- static ABICreateInstance
- GetABICreateCallbackForPluginName(ConstString name);
-
// Architecture
- using ArchitectureCreateInstance =
- std::unique_ptr<Architecture> (*)(const ArchSpec &);
-
- static void RegisterPlugin(ConstString name,
- llvm::StringRef description,
+ static void RegisterPlugin(ConstString name, llvm::StringRef description,
ArchitectureCreateInstance create_callback);
static void UnregisterPlugin(ArchitectureCreateInstance create_callback);
@@ -95,9 +107,6 @@ public:
static JITLoaderCreateInstance
GetJITLoaderCreateCallbackAtIndex(uint32_t idx);
- static JITLoaderCreateInstance
- GetJITLoaderCreateCallbackForPluginName(ConstString name);
-
// EmulateInstruction
static bool RegisterPlugin(ConstString name, const char *description,
EmulateInstructionCreateInstance create_callback);
@@ -132,9 +141,6 @@ public:
static LanguageCreateInstance GetLanguageCreateCallbackAtIndex(uint32_t idx);
- static LanguageCreateInstance
- GetLanguageCreateCallbackForPluginName(ConstString name);
-
// LanguageRuntime
static bool RegisterPlugin(
ConstString name, const char *description,
@@ -153,9 +159,6 @@ public:
static LanguageRuntimeGetExceptionPrecondition
GetLanguageRuntimeGetExceptionPreconditionAtIndex(uint32_t idx);
- static LanguageRuntimeCreateInstance
- GetLanguageRuntimeCreateCallbackForPluginName(ConstString name);
-
// SystemRuntime
static bool RegisterPlugin(ConstString name, const char *description,
SystemRuntimeCreateInstance create_callback);
@@ -165,9 +168,6 @@ public:
static SystemRuntimeCreateInstance
GetSystemRuntimeCreateCallbackAtIndex(uint32_t idx);
- static SystemRuntimeCreateInstance
- GetSystemRuntimeCreateCallbackForPluginName(ConstString name);
-
// ObjectFile
static bool
RegisterPlugin(ConstString name, const char *description,
@@ -187,9 +187,6 @@ public:
static ObjectFileGetModuleSpecifications
GetObjectFileGetModuleSpecificationsCallbackAtIndex(uint32_t idx);
- static ObjectFileCreateInstance
- GetObjectFileCreateCallbackForPluginName(ConstString name);
-
static ObjectFileCreateMemoryInstance
GetObjectFileCreateMemoryCallbackForPluginName(ConstString name);
@@ -207,9 +204,6 @@ public:
static ObjectContainerCreateInstance
GetObjectContainerCreateCallbackAtIndex(uint32_t idx);
- static ObjectContainerCreateInstance
- GetObjectContainerCreateCallbackForPluginName(ConstString name);
-
static ObjectFileGetModuleSpecifications
GetObjectContainerGetModuleSpecificationsCallbackAtIndex(uint32_t idx);
@@ -249,6 +243,9 @@ public:
static const char *GetProcessPluginDescriptionAtIndex(uint32_t idx);
+ static void AutoCompleteProcessName(llvm::StringRef partial_name,
+ CompletionRequest &request);
+
// ScriptInterpreter
static bool RegisterPlugin(ConstString name, const char *description,
lldb::ScriptLanguage script_lang,
@@ -309,9 +306,6 @@ public:
static StructuredDataPluginCreateInstance
GetStructuredDataPluginCreateCallbackAtIndex(uint32_t idx);
- static StructuredDataPluginCreateInstance
- GetStructuredDataPluginCreateCallbackForPluginName(ConstString name);
-
static StructuredDataFilterLaunchInfo
GetStructuredDataFilterCallbackAtIndex(uint32_t idx,
bool &iteration_complete);
@@ -327,9 +321,6 @@ public:
static SymbolFileCreateInstance
GetSymbolFileCreateCallbackAtIndex(uint32_t idx);
- static SymbolFileCreateInstance
- GetSymbolFileCreateCallbackForPluginName(ConstString name);
-
// SymbolVendor
static bool RegisterPlugin(ConstString name, const char *description,
SymbolVendorCreateInstance create_callback);
@@ -339,9 +330,6 @@ public:
static SymbolVendorCreateInstance
GetSymbolVendorCreateCallbackAtIndex(uint32_t idx);
- static SymbolVendorCreateInstance
- GetSymbolVendorCreateCallbackForPluginName(ConstString name);
-
// UnwindAssembly
static bool RegisterPlugin(ConstString name, const char *description,
UnwindAssemblyCreateInstance create_callback);
@@ -351,9 +339,6 @@ public:
static UnwindAssemblyCreateInstance
GetUnwindAssemblyCreateCallbackAtIndex(uint32_t idx);
- static UnwindAssemblyCreateInstance
- GetUnwindAssemblyCreateCallbackForPluginName(ConstString name);
-
// MemoryHistory
static bool RegisterPlugin(ConstString name, const char *description,
MemoryHistoryCreateInstance create_callback);
@@ -363,9 +348,6 @@ public:
static MemoryHistoryCreateInstance
GetMemoryHistoryCreateCallbackAtIndex(uint32_t idx);
- static MemoryHistoryCreateInstance
- GetMemoryHistoryCreateCallbackForPluginName(ConstString name);
-
// InstrumentationRuntime
static bool
RegisterPlugin(ConstString name, const char *description,
@@ -381,9 +363,6 @@ public:
static InstrumentationRuntimeCreateInstance
GetInstrumentationRuntimeCreateCallbackAtIndex(uint32_t idx);
- static InstrumentationRuntimeCreateInstance
- GetInstrumentationRuntimeCreateCallbackForPluginName(ConstString name);
-
// TypeSystem
static bool RegisterPlugin(ConstString name, const char *description,
TypeSystemCreateInstance create_callback,
@@ -395,9 +374,6 @@ public:
static TypeSystemCreateInstance
GetTypeSystemCreateCallbackAtIndex(uint32_t idx);
- static TypeSystemCreateInstance
- GetTypeSystemCreateCallbackForPluginName(ConstString name);
-
static LanguageSet GetAllTypeSystemSupportedLanguagesForTypes();
static LanguageSet GetAllTypeSystemSupportedLanguagesForExpressions();
@@ -411,9 +387,6 @@ public:
static REPLCreateInstance GetREPLCreateCallbackAtIndex(uint32_t idx);
- static REPLCreateInstance
- GetREPLCreateCallbackForPluginName(ConstString name);
-
static LanguageSet GetREPLAllTypeSystemSupportedLanguages();
// Some plug-ins might register a DebuggerInitializeCallback callback when
@@ -478,4 +451,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_PluginManager_h_
+#endif // LLDB_CORE_PLUGINMANAGER_H
diff --git a/lldb/include/lldb/Core/PropertiesBase.td b/lldb/include/lldb/Core/PropertiesBase.td
index 6e95ceb779ba..1be3b908ed41 100644
--- a/lldb/include/lldb/Core/PropertiesBase.td
+++ b/lldb/include/lldb/Core/PropertiesBase.td
@@ -49,3 +49,9 @@ class DefaultUnsignedValue<int value> {
class EnumValues<string enum> {
string EnumValues = enum;
}
+
+// Determines the element type for arrays and dictionaries.
+class ElementType<string value> {
+ string ElementType = value;
+ bit HasElementType = 1;
+}
diff --git a/lldb/include/lldb/Core/RichManglingContext.h b/lldb/include/lldb/Core/RichManglingContext.h
index e6fa2599e55a..68f80e73b724 100644
--- a/lldb/include/lldb/Core/RichManglingContext.h
+++ b/lldb/include/lldb/Core/RichManglingContext.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RichManglingContext_h_
-#define liblldb_RichManglingContext_h_
+#ifndef LLDB_CORE_RICHMANGLINGCONTEXT_H
+#define LLDB_CORE_RICHMANGLINGCONTEXT_H
#include "lldb/lldb-forward.h"
#include "lldb/lldb-private.h"
diff --git a/lldb/include/lldb/Core/SearchFilter.h b/lldb/include/lldb/Core/SearchFilter.h
index 74c4f3162a1c..54dc65e4410f 100644
--- a/lldb/include/lldb/Core/SearchFilter.h
+++ b/lldb/include/lldb/Core/SearchFilter.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_SearchFilter_h_
-#define liblldb_SearchFilter_h_
+#ifndef LLDB_CORE_SEARCHFILTER_H
+#define LLDB_CORE_SEARCHFILTER_H
#include "lldb/Core/FileSpecList.h"
#include "lldb/Utility/StructuredData.h"
@@ -98,6 +98,8 @@ public:
/// The file spec to check against the filter.
/// \return
/// \b true if \a spec passes, and \b false otherwise.
+ ///
+ /// \note the default implementation always returns \c true.
virtual bool ModulePasses(const FileSpec &spec);
/// Call this method with a Module to see if that module passes the filter.
@@ -107,6 +109,8 @@ public:
///
/// \return
/// \b true if \a module passes, and \b false otherwise.
+ ///
+ /// \note the default implementation always returns \c true.
virtual bool ModulePasses(const lldb::ModuleSP &module_sp);
/// Call this method with a Address to see if \a address passes the filter.
@@ -116,6 +120,8 @@ public:
///
/// \return
/// \b true if \a address passes, and \b false otherwise.
+ ///
+ /// \note the default implementation always returns \c true.
virtual bool AddressPasses(Address &addr);
/// Call this method with a FileSpec to see if \a file spec passes the
@@ -126,6 +132,8 @@ public:
///
/// \return
/// \b true if \a file spec passes, and \b false otherwise.
+ ///
+ /// \note the default implementation always returns \c true.
virtual bool CompUnitPasses(FileSpec &fileSpec);
/// Call this method with a CompileUnit to see if \a comp unit passes the
@@ -136,6 +144,8 @@ public:
///
/// \return
/// \b true if \a Comp Unit passes, and \b false otherwise.
+ ///
+ /// \note the default implementation always returns \c true.
virtual bool CompUnitPasses(CompileUnit &compUnit);
/// Call this method with a Function to see if \a function passes the
@@ -187,10 +197,10 @@ public:
/// Standard "Dump" method. At present it does nothing.
virtual void Dump(Stream *s) const;
- lldb::SearchFilterSP CopyForBreakpoint(Breakpoint &breakpoint);
+ lldb::SearchFilterSP CreateCopy(lldb::TargetSP& target_sp);
static lldb::SearchFilterSP
- CreateFromStructuredData(Target &target,
+ CreateFromStructuredData(const lldb::TargetSP& target_sp,
const StructuredData::Dictionary &data_dict,
Status &error);
@@ -261,13 +271,13 @@ protected:
const SymbolContext &context,
Searcher &searcher);
- virtual lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) = 0;
+ virtual lldb::SearchFilterSP DoCreateCopy() = 0;
void SetTarget(lldb::TargetSP &target_sp) { m_target_sp = target_sp; }
- lldb::TargetSP
- m_target_sp; // Every filter has to be associated with a target for
- // now since you need a starting place for the search.
+ lldb::TargetSP m_target_sp; // Every filter has to be associated with
+ // a target for now since you need a starting
+ // place for the search.
private:
unsigned char SubclassID;
};
@@ -288,14 +298,14 @@ public:
bool ModulePasses(const lldb::ModuleSP &module_sp) override;
static lldb::SearchFilterSP
- CreateFromStructuredData(Target &target,
+ CreateFromStructuredData(const lldb::TargetSP& target_sp,
const StructuredData::Dictionary &data_dict,
Status &error);
StructuredData::ObjectSP SerializeToStructuredData() override;
protected:
- lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
+ lldb::SearchFilterSP DoCreateCopy() override;
};
/// \class SearchFilterByModule SearchFilter.h "lldb/Core/SearchFilter.h" This
@@ -321,10 +331,6 @@ public:
bool AddressPasses(Address &address) override;
- bool CompUnitPasses(FileSpec &fileSpec) override;
-
- bool CompUnitPasses(CompileUnit &compUnit) override;
-
void GetDescription(Stream *s) override;
uint32_t GetFilterRequiredItems() override;
@@ -334,14 +340,14 @@ public:
void Search(Searcher &searcher) override;
static lldb::SearchFilterSP
- CreateFromStructuredData(Target &target,
+ CreateFromStructuredData(const lldb::TargetSP& target_sp,
const StructuredData::Dictionary &data_dict,
Status &error);
StructuredData::ObjectSP SerializeToStructuredData() override;
protected:
- lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
+ lldb::SearchFilterSP DoCreateCopy() override;
private:
FileSpec m_module_spec;
@@ -372,10 +378,6 @@ public:
bool AddressPasses(Address &address) override;
- bool CompUnitPasses(FileSpec &fileSpec) override;
-
- bool CompUnitPasses(CompileUnit &compUnit) override;
-
void GetDescription(Stream *s) override;
uint32_t GetFilterRequiredItems() override;
@@ -385,7 +387,7 @@ public:
void Search(Searcher &searcher) override;
static lldb::SearchFilterSP
- CreateFromStructuredData(Target &target,
+ CreateFromStructuredData(const lldb::TargetSP& target_sp,
const StructuredData::Dictionary &data_dict,
Status &error);
@@ -394,9 +396,8 @@ public:
void SerializeUnwrapped(StructuredData::DictionarySP &options_dict_sp);
protected:
- lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
+ lldb::SearchFilterSP DoCreateCopy() override;
-protected:
FileSpecList m_module_spec_list;
};
@@ -425,14 +426,14 @@ public:
void Search(Searcher &searcher) override;
static lldb::SearchFilterSP
- CreateFromStructuredData(Target &target,
+ CreateFromStructuredData(const lldb::TargetSP& target_sp,
const StructuredData::Dictionary &data_dict,
Status &error);
StructuredData::ObjectSP SerializeToStructuredData() override;
protected:
- lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
+ lldb::SearchFilterSP DoCreateCopy() override;
private:
FileSpecList m_cu_spec_list;
@@ -440,4 +441,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_SearchFilter_h_
+#endif // LLDB_CORE_SEARCHFILTER_H
diff --git a/lldb/include/lldb/Core/Section.h b/lldb/include/lldb/Core/Section.h
index 509a0767be1d..af2bb7896a5b 100644
--- a/lldb/include/lldb/Core/Section.h
+++ b/lldb/include/lldb/Core/Section.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Section_h_
-#define liblldb_Section_h_
+#ifndef LLDB_CORE_SECTION_H
+#define LLDB_CORE_SECTION_H
#include "lldb/Core/ModuleChild.h"
#include "lldb/Utility/ConstString.h"
@@ -29,7 +29,6 @@ class Address;
class DataExtractor;
class ObjectFile;
class Section;
-class Stream;
class Target;
class SectionList {
@@ -56,7 +55,8 @@ public:
bool ContainsSection(lldb::user_id_t sect_id) const;
- void Dump(Stream *s, Target *target, bool show_header, uint32_t depth) const;
+ void Dump(llvm::raw_ostream &s, unsigned indent, Target *target,
+ bool show_header, uint32_t depth) const;
lldb::SectionSP FindSectionByName(ConstString section_dstr) const;
@@ -127,9 +127,10 @@ public:
const SectionList &GetChildren() const { return m_children; }
- void Dump(Stream *s, Target *target, uint32_t depth) const;
+ void Dump(llvm::raw_ostream &s, unsigned indent, Target *target,
+ uint32_t depth) const;
- void DumpName(Stream *s) const;
+ void DumpName(llvm::raw_ostream &s) const;
lldb::addr_t GetLoadBaseAddress(Target *target) const;
@@ -267,9 +268,10 @@ protected:
// This is specified as
// as a multiple number of a host bytes
private:
- DISALLOW_COPY_AND_ASSIGN(Section);
+ Section(const Section &) = delete;
+ const Section &operator=(const Section &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Section_h_
+#endif // LLDB_CORE_SECTION_H
diff --git a/lldb/include/lldb/Core/SourceManager.h b/lldb/include/lldb/Core/SourceManager.h
index f1f56d0886c3..7549c308f33a 100644
--- a/lldb/include/lldb/Core/SourceManager.h
+++ b/lldb/include/lldb/Core/SourceManager.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_SourceManager_h_
-#define liblldb_SourceManager_h_
+#ifndef LLDB_CORE_SOURCEMANAGER_H
+#define LLDB_CORE_SOURCEMANAGER_H
#include "lldb/Utility/FileSpec.h"
#include "lldb/lldb-defines.h"
@@ -101,6 +101,9 @@ public:
void AddSourceFile(const FileSP &file_sp);
FileSP FindSourceFile(const FileSpec &file_spec) const;
+ // Removes all elements from the cache.
+ void Clear() { m_file_cache.clear(); }
+
protected:
typedef std::map<FileSpec, FileSP> FileCache;
FileCache m_file_cache;
@@ -116,7 +119,7 @@ public:
~SourceManager();
- FileSP GetLastFile() { return m_last_file_sp; }
+ FileSP GetLastFile() { return GetFile(m_last_file_spec); }
size_t
DisplaySourceLinesWithLineNumbers(const FileSpec &file, uint32_t line,
@@ -138,7 +141,9 @@ public:
bool GetDefaultFileAndLine(FileSpec &file_spec, uint32_t &line);
- bool DefaultFileAndLineSet() { return (m_last_file_sp.get() != nullptr); }
+ bool DefaultFileAndLineSet() {
+ return (GetFile(m_last_file_spec).get() != nullptr);
+ }
void FindLinesMatchingRegex(FileSpec &file_spec, RegularExpression &regex,
uint32_t start_line, uint32_t end_line,
@@ -147,7 +152,7 @@ public:
FileSP GetFile(const FileSpec &file_spec);
protected:
- FileSP m_last_file_sp;
+ FileSpec m_last_file_spec;
uint32_t m_last_line;
uint32_t m_last_count;
bool m_default_set;
@@ -155,11 +160,12 @@ protected:
lldb::DebuggerWP m_debugger_wp;
private:
- DISALLOW_COPY_AND_ASSIGN(SourceManager);
+ SourceManager(const SourceManager &) = delete;
+ const SourceManager &operator=(const SourceManager &) = delete;
};
bool operator==(const SourceManager::File &lhs, const SourceManager::File &rhs);
} // namespace lldb_private
-#endif // liblldb_SourceManager_h_
+#endif // LLDB_CORE_SOURCEMANAGER_H
diff --git a/lldb/include/lldb/Core/StreamAsynchronousIO.h b/lldb/include/lldb/Core/StreamAsynchronousIO.h
index 6237e12b7d1e..949a798955d1 100644
--- a/lldb/include/lldb/Core/StreamAsynchronousIO.h
+++ b/lldb/include/lldb/Core/StreamAsynchronousIO.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_StreamAsynchronousIO_h_
-#define liblldb_StreamAsynchronousIO_h_
+#ifndef LLDB_CORE_STREAMASYNCHRONOUSIO_H
+#define LLDB_CORE_STREAMASYNCHRONOUSIO_H
#include "lldb/Utility/Stream.h"
@@ -37,4 +37,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_StreamAsynchronousIO_h
+#endif // LLDB_CORE_STREAMASYNCHRONOUSIO_H
diff --git a/lldb/include/lldb/Core/StreamBuffer.h b/lldb/include/lldb/Core/StreamBuffer.h
index 6c516519781f..9c48ddb44d71 100644
--- a/lldb/include/lldb/Core/StreamBuffer.h
+++ b/lldb/include/lldb/Core/StreamBuffer.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_StreamBuffer_h_
-#define liblldb_StreamBuffer_h_
+#ifndef LLDB_CORE_STREAMBUFFER_H
+#define LLDB_CORE_STREAMBUFFER_H
#include "lldb/Utility/Stream.h"
#include "llvm/ADT/SmallVector.h"
@@ -51,4 +51,4 @@ protected:
} // namespace lldb_private
-#endif // #ifndef liblldb_StreamBuffer_h_
+#endif // LLDB_CORE_STREAMBUFFER_H
diff --git a/lldb/include/lldb/Core/StreamFile.h b/lldb/include/lldb/Core/StreamFile.h
index bd7d6e8e6ad3..e71e31eb1d04 100644
--- a/lldb/include/lldb/Core/StreamFile.h
+++ b/lldb/include/lldb/Core/StreamFile.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_StreamFile_h_
-#define liblldb_StreamFile_h_
+#ifndef LLDB_CORE_STREAMFILE_H
+#define LLDB_CORE_STREAMFILE_H
#include "lldb/Host/File.h"
#include "lldb/Utility/Stream.h"
@@ -48,9 +48,10 @@ protected:
size_t WriteImpl(const void *s, size_t length) override;
private:
- DISALLOW_COPY_AND_ASSIGN(StreamFile);
+ StreamFile(const StreamFile &) = delete;
+ const StreamFile &operator=(const StreamFile &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_StreamFile_h_
+#endif // LLDB_CORE_STREAMFILE_H
diff --git a/lldb/include/lldb/Core/StructuredDataImpl.h b/lldb/include/lldb/Core/StructuredDataImpl.h
index c66e4736dc26..9aea645a3ea6 100644
--- a/lldb/include/lldb/Core/StructuredDataImpl.h
+++ b/lldb/include/lldb/Core/StructuredDataImpl.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_StructuredDataImpl_h_
-#define liblldb_StructuredDataImpl_h_
+#ifndef LLDB_CORE_STRUCTUREDDATAIMPL_H
+#define LLDB_CORE_STRUCTUREDDATAIMPL_H
#include "lldb/Target/StructuredDataPlugin.h"
#include "lldb/Utility/Event.h"
diff --git a/lldb/include/lldb/Core/ThreadSafeDenseMap.h b/lldb/include/lldb/Core/ThreadSafeDenseMap.h
index 420cb5763586..2f6eb280e4a1 100644
--- a/lldb/include/lldb/Core/ThreadSafeDenseMap.h
+++ b/lldb/include/lldb/Core/ThreadSafeDenseMap.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadSafeDenseMap_h_
-#define liblldb_ThreadSafeDenseMap_h_
+#ifndef LLDB_CORE_THREADSAFEDENSEMAP_H
+#define LLDB_CORE_THREADSAFEDENSEMAP_H
#include <mutex>
@@ -62,4 +62,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_ThreadSafeDenseMap_h_
+#endif // LLDB_CORE_THREADSAFEDENSEMAP_H
diff --git a/lldb/include/lldb/Core/ThreadSafeValue.h b/lldb/include/lldb/Core/ThreadSafeValue.h
index 91f96814363f..38b8034fad53 100644
--- a/lldb/include/lldb/Core/ThreadSafeValue.h
+++ b/lldb/include/lldb/Core/ThreadSafeValue.h
@@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadSafeValue_h_
-#define liblldb_ThreadSafeValue_h_
-
+#ifndef LLDB_CORE_THREADSAFEVALUE_H
+#define LLDB_CORE_THREADSAFEVALUE_H
#include <mutex>
@@ -54,8 +53,9 @@ private:
mutable std::recursive_mutex m_mutex;
// For ThreadSafeValue only
- DISALLOW_COPY_AND_ASSIGN(ThreadSafeValue);
+ ThreadSafeValue(const ThreadSafeValue &) = delete;
+ const ThreadSafeValue &operator=(const ThreadSafeValue &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ThreadSafeValue_h_
+#endif // LLDB_CORE_THREADSAFEVALUE_H
diff --git a/lldb/include/lldb/Core/UniqueCStringMap.h b/lldb/include/lldb/Core/UniqueCStringMap.h
index 9949bd45f4fa..e37027a0150a 100644
--- a/lldb/include/lldb/Core/UniqueCStringMap.h
+++ b/lldb/include/lldb/Core/UniqueCStringMap.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_UniqueCStringMap_h_
-#define liblldb_UniqueCStringMap_h_
+#ifndef LLDB_CORE_UNIQUECSTRINGMAP_H
+#define LLDB_CORE_UNIQUECSTRINGMAP_H
#include <algorithm>
#include <vector>
@@ -32,6 +32,10 @@ public:
T value;
};
+ typedef std::vector<Entry> collection;
+ typedef typename collection::iterator iterator;
+ typedef typename collection::const_iterator const_iterator;
+
// Call this function multiple times to add a bunch of entries to this map,
// then later call UniqueCStringMap<T>::Sort() before doing any searches by
// name.
@@ -175,6 +179,18 @@ public:
}
}
+ iterator begin() { return m_map.begin(); }
+ iterator end() { return m_map.end(); }
+ const_iterator begin() const { return m_map.begin(); }
+ const_iterator end() const { return m_map.end(); }
+
+ // Range-based for loop for all entries of the specified ConstString name.
+ llvm::iterator_range<const_iterator>
+ equal_range(ConstString unique_cstr) const {
+ return llvm::make_range(
+ std::equal_range(m_map.begin(), m_map.end(), unique_cstr, Compare()));
+ };
+
protected:
struct Compare {
bool operator()(const Entry &lhs, const Entry &rhs) {
@@ -196,12 +212,9 @@ protected:
return uintptr_t(lhs.GetCString()) < uintptr_t(rhs.GetCString());
}
};
- typedef std::vector<Entry> collection;
- typedef typename collection::iterator iterator;
- typedef typename collection::const_iterator const_iterator;
collection m_map;
};
} // namespace lldb_private
-#endif // liblldb_UniqueCStringMap_h_
+#endif // LLDB_CORE_UNIQUECSTRINGMAP_H
diff --git a/lldb/include/lldb/Core/UserSettingsController.h b/lldb/include/lldb/Core/UserSettingsController.h
index 6ae3bdec1665..f40ad54ac4d6 100644
--- a/lldb/include/lldb/Core/UserSettingsController.h
+++ b/lldb/include/lldb/Core/UserSettingsController.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_UserSettingsController_h_
-#define liblldb_UserSettingsController_h_
+#ifndef LLDB_CORE_USERSETTINGSCONTROLLER_H
+#define LLDB_CORE_USERSETTINGSCONTROLLER_H
#include "lldb/Utility/Status.h"
#include "lldb/lldb-forward.h"
@@ -88,4 +88,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_UserSettingsController_h_
+#endif // LLDB_CORE_USERSETTINGSCONTROLLER_H
diff --git a/lldb/include/lldb/Core/Value.h b/lldb/include/lldb/Core/Value.h
index 7b4cc3b71c28..641a64a3bbbe 100644
--- a/lldb/include/lldb/Core/Value.h
+++ b/lldb/include/lldb/Core/Value.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Value_h_
-#define liblldb_Value_h_
+#ifndef LLDB_CORE_VALUE_H
+#define LLDB_CORE_VALUE_H
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Utility/DataBufferHeap.h"
@@ -258,4 +258,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_Value_h_
+#endif // LLDB_CORE_VALUE_H
diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h
index 1b000e617f0e..0080368fd996 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ValueObject_h_
-#define liblldb_ValueObject_h_
+#ifndef LLDB_CORE_VALUEOBJECT_H
+#define LLDB_CORE_VALUEOBJECT_H
#include "lldb/Core/Value.h"
#include "lldb/Symbol/CompilerType.h"
@@ -396,10 +396,8 @@ public:
bool IsIntegerType(bool &is_signed);
- virtual bool GetBaseClassPath(Stream &s);
-
virtual void GetExpressionPath(
- Stream &s, bool qualify_cxx_base_classes,
+ Stream &s,
GetExpressionPathFormat = eGetExpressionPathFormatDereferencePointers);
lldb::ValueObjectSP GetValueForExpressionPath(
@@ -577,7 +575,7 @@ public:
virtual lldb::ValueObjectSP GetNonSyntheticValue();
- lldb::ValueObjectSP GetSyntheticValue(bool use_synthetic = true);
+ lldb::ValueObjectSP GetSyntheticValue();
virtual bool HasSyntheticValue();
@@ -889,7 +887,6 @@ protected:
m_is_synthetic_children_generated : 1;
friend class ValueObjectChild;
- friend class ClangExpressionDeclMap; // For GetValue
friend class ExpressionVariable; // For SetName
friend class Target; // For SetName
friend class ValueObjectConstResultImpl;
@@ -905,7 +902,7 @@ protected:
// Use this constructor to create a "root variable object". The ValueObject
// will be locked to this context through-out its lifespan.
- ValueObject(ExecutionContextScope *exe_scope,
+ ValueObject(ExecutionContextScope *exe_scope, ValueObjectManager &manager,
AddressType child_ptr_or_ref_addr_type = eAddressTypeLoad);
// Use this constructor to create a ValueObject owned by another ValueObject.
@@ -929,7 +926,7 @@ protected:
virtual bool HasDynamicValueTypeInfo() { return false; }
- virtual void CalculateSyntheticValue(bool use_synthetic = true);
+ virtual void CalculateSyntheticValue();
// Should only be called by ValueObject::GetChildAtIndex() Returns a
// ValueObject managed by this ValueObject's manager.
@@ -966,9 +963,14 @@ protected:
void SetPreferredDisplayLanguageIfNeeded(lldb::LanguageType);
+protected:
+ virtual void DoUpdateChildrenAddressType(ValueObject &valobj) { return; };
+
private:
virtual CompilerType MaybeCalculateCompleteType();
- void UpdateChildrenAddressType();
+ void UpdateChildrenAddressType() {
+ GetRoot()->DoUpdateChildrenAddressType(*this);
+ }
lldb::ValueObjectSP GetValueForExpressionPath_Impl(
llvm::StringRef expression_cstr,
@@ -977,7 +979,8 @@ private:
const GetValueForExpressionPathOptions &options,
ExpressionPathAftermath *final_task_on_target);
- DISALLOW_COPY_AND_ASSIGN(ValueObject);
+ ValueObject(const ValueObject &) = delete;
+ const ValueObject &operator=(const ValueObject &) = delete;
};
// A value object manager class that is seeded with the static variable value
@@ -1023,4 +1026,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_ValueObject_h_
+#endif // LLDB_CORE_VALUEOBJECT_H
diff --git a/lldb/include/lldb/Core/ValueObjectCast.h b/lldb/include/lldb/Core/ValueObjectCast.h
index feee493dfafb..d91ca6a92be8 100644
--- a/lldb/include/lldb/Core/ValueObjectCast.h
+++ b/lldb/include/lldb/Core/ValueObjectCast.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ValueObjectCast_h_
-#define liblldb_ValueObjectCast_h_
+#ifndef LLDB_CORE_VALUEOBJECTCAST_H
+#define LLDB_CORE_VALUEOBJECTCAST_H
#include "lldb/Core/ValueObject.h"
#include "lldb/Symbol/CompilerType.h"
@@ -57,9 +57,10 @@ protected:
CompilerType m_cast_type;
private:
- DISALLOW_COPY_AND_ASSIGN(ValueObjectCast);
+ ValueObjectCast(const ValueObjectCast &) = delete;
+ const ValueObjectCast &operator=(const ValueObjectCast &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ValueObjectCast_h_
+#endif // LLDB_CORE_VALUEOBJECTCAST_H
diff --git a/lldb/include/lldb/Core/ValueObjectChild.h b/lldb/include/lldb/Core/ValueObjectChild.h
index 76209a22ec20..c6f44a29b059 100644
--- a/lldb/include/lldb/Core/ValueObjectChild.h
+++ b/lldb/include/lldb/Core/ValueObjectChild.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ValueObjectChild_h_
-#define liblldb_ValueObjectChild_h_
+#ifndef LLDB_CORE_VALUEOBJECTCHILD_H
+#define LLDB_CORE_VALUEOBJECTCHILD_H
#include "lldb/Core/ValueObject.h"
@@ -75,7 +75,6 @@ protected:
// void
// ReadValueFromMemory (ValueObject* parent, lldb::addr_t address);
-protected:
friend class ValueObject;
friend class ValueObjectConstResult;
friend class ValueObjectConstResultImpl;
@@ -88,9 +87,10 @@ protected:
AddressType child_ptr_or_ref_addr_type,
uint64_t language_flags);
- DISALLOW_COPY_AND_ASSIGN(ValueObjectChild);
+ ValueObjectChild(const ValueObjectChild &) = delete;
+ const ValueObjectChild &operator=(const ValueObjectChild &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ValueObjectChild_h_
+#endif // LLDB_CORE_VALUEOBJECTCHILD_H
diff --git a/lldb/include/lldb/Core/ValueObjectConstResult.h b/lldb/include/lldb/Core/ValueObjectConstResult.h
index 3bc957ef2b84..0e868c687e93 100644
--- a/lldb/include/lldb/Core/ValueObjectConstResult.h
+++ b/lldb/include/lldb/Core/ValueObjectConstResult.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ValueObjectConstResult_h_
-#define liblldb_ValueObjectConstResult_h_
+#ifndef LLDB_CORE_VALUEOBJECTCONSTRESULT_H
+#define LLDB_CORE_VALUEOBJECTCONSTRESULT_H
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObject.h"
@@ -121,34 +121,40 @@ private:
friend class ValueObjectConstResultImpl;
ValueObjectConstResult(ExecutionContextScope *exe_scope,
+ ValueObjectManager &manager,
lldb::ByteOrder byte_order, uint32_t addr_byte_size,
lldb::addr_t address);
ValueObjectConstResult(ExecutionContextScope *exe_scope,
- const CompilerType &compiler_type,
- ConstString name, const DataExtractor &data,
- lldb::addr_t address);
+ ValueObjectManager &manager,
+ const CompilerType &compiler_type, ConstString name,
+ const DataExtractor &data, lldb::addr_t address);
ValueObjectConstResult(ExecutionContextScope *exe_scope,
- const CompilerType &compiler_type,
- ConstString name,
+ ValueObjectManager &manager,
+ const CompilerType &compiler_type, ConstString name,
const lldb::DataBufferSP &result_data_sp,
lldb::ByteOrder byte_order, uint32_t addr_size,
lldb::addr_t address);
ValueObjectConstResult(ExecutionContextScope *exe_scope,
- const CompilerType &compiler_type,
- ConstString name, lldb::addr_t address,
- AddressType address_type, uint32_t addr_byte_size);
+ ValueObjectManager &manager,
+ const CompilerType &compiler_type, ConstString name,
+ lldb::addr_t address, AddressType address_type,
+ uint32_t addr_byte_size);
- ValueObjectConstResult(ExecutionContextScope *exe_scope, const Value &value,
+ ValueObjectConstResult(ExecutionContextScope *exe_scope,
+ ValueObjectManager &manager, const Value &value,
ConstString name, Module *module = nullptr);
- ValueObjectConstResult(ExecutionContextScope *exe_scope, const Status &error);
+ ValueObjectConstResult(ExecutionContextScope *exe_scope,
+ ValueObjectManager &manager, const Status &error);
- DISALLOW_COPY_AND_ASSIGN(ValueObjectConstResult);
+ ValueObjectConstResult(const ValueObjectConstResult &) = delete;
+ const ValueObjectConstResult &
+ operator=(const ValueObjectConstResult &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ValueObjectConstResult_h_
+#endif // LLDB_CORE_VALUEOBJECTCONSTRESULT_H
diff --git a/lldb/include/lldb/Core/ValueObjectConstResultCast.h b/lldb/include/lldb/Core/ValueObjectConstResultCast.h
index be9b12b4b57c..ba81785866c3 100644
--- a/lldb/include/lldb/Core/ValueObjectConstResultCast.h
+++ b/lldb/include/lldb/Core/ValueObjectConstResultCast.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ValueObjectConstResultCast_h_
-#define liblldb_ValueObjectConstResultCast_h_
+#ifndef LLDB_CORE_VALUEOBJECTCONSTRESULTCAST_H
+#define LLDB_CORE_VALUEOBJECTCONSTRESULTCAST_H
#include "lldb/Core/ValueObjectCast.h"
#include "lldb/Core/ValueObjectConstResultImpl.h"
@@ -61,9 +61,11 @@ private:
friend class ValueObjectConstResult;
friend class ValueObjectConstResultImpl;
- DISALLOW_COPY_AND_ASSIGN(ValueObjectConstResultCast);
+ ValueObjectConstResultCast(const ValueObjectConstResultCast &) = delete;
+ const ValueObjectConstResultCast &
+ operator=(const ValueObjectConstResultCast &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ValueObjectConstResultCast_h_
+#endif // LLDB_CORE_VALUEOBJECTCONSTRESULTCAST_H
diff --git a/lldb/include/lldb/Core/ValueObjectConstResultChild.h b/lldb/include/lldb/Core/ValueObjectConstResultChild.h
index 16fa74f71ed5..b3606bfde0ef 100644
--- a/lldb/include/lldb/Core/ValueObjectConstResultChild.h
+++ b/lldb/include/lldb/Core/ValueObjectConstResultChild.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ValueObjectConstResultChild_h_
-#define liblldb_ValueObjectConstResultChild_h_
+#ifndef LLDB_CORE_VALUEOBJECTCONSTRESULTCHILD_H
+#define LLDB_CORE_VALUEOBJECTCONSTRESULTCHILD_H
#include "lldb/Core/ValueObjectChild.h"
#include "lldb/Core/ValueObjectConstResultImpl.h"
@@ -70,9 +70,11 @@ private:
friend class ValueObjectConstResult;
friend class ValueObjectConstResultImpl;
- DISALLOW_COPY_AND_ASSIGN(ValueObjectConstResultChild);
+ ValueObjectConstResultChild(const ValueObjectConstResultChild &) = delete;
+ const ValueObjectConstResultChild &
+ operator=(const ValueObjectConstResultChild &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ValueObjectConstResultChild_h_
+#endif // LLDB_CORE_VALUEOBJECTCONSTRESULTCHILD_H
diff --git a/lldb/include/lldb/Core/ValueObjectConstResultImpl.h b/lldb/include/lldb/Core/ValueObjectConstResultImpl.h
index ffac98e12e61..1316bf66dfdb 100644
--- a/lldb/include/lldb/Core/ValueObjectConstResultImpl.h
+++ b/lldb/include/lldb/Core/ValueObjectConstResultImpl.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ValueObjectConstResultImpl_h_
-#define liblldb_ValueObjectConstResultImpl_h_
+#ifndef LLDB_CORE_VALUEOBJECTCONSTRESULTIMPL_H
+#define LLDB_CORE_VALUEOBJECTCONSTRESULTIMPL_H
#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-defines.h"
@@ -71,9 +71,11 @@ private:
lldb::ValueObjectSP m_load_addr_backend;
lldb::ValueObjectSP m_address_of_backend;
- DISALLOW_COPY_AND_ASSIGN(ValueObjectConstResultImpl);
+ ValueObjectConstResultImpl(const ValueObjectConstResultImpl &) = delete;
+ const ValueObjectConstResultImpl &
+ operator=(const ValueObjectConstResultImpl &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ValueObjectConstResultImpl_h_
+#endif // LLDB_CORE_VALUEOBJECTCONSTRESULTIMPL_H
diff --git a/lldb/include/lldb/Core/ValueObjectDynamicValue.h b/lldb/include/lldb/Core/ValueObjectDynamicValue.h
index f656d42e9a97..9f5304b55e93 100644
--- a/lldb/include/lldb/Core/ValueObjectDynamicValue.h
+++ b/lldb/include/lldb/Core/ValueObjectDynamicValue.h
@@ -6,15 +6,14 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ValueObjectDynamicValue_h_
-#define liblldb_ValueObjectDynamicValue_h_
+#ifndef LLDB_CORE_VALUEOBJECTDYNAMICVALUE_H
+#define LLDB_CORE_VALUEOBJECTDYNAMICVALUE_H
#include "lldb/Core/Address.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Utility/ConstString.h"
-#include "lldb/Utility/SharingPtr.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
@@ -128,9 +127,11 @@ private:
ValueObjectDynamicValue(ValueObject &parent,
lldb::DynamicValueType use_dynamic);
- DISALLOW_COPY_AND_ASSIGN(ValueObjectDynamicValue);
+ ValueObjectDynamicValue(const ValueObjectDynamicValue &) = delete;
+ const ValueObjectDynamicValue &
+ operator=(const ValueObjectDynamicValue &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ValueObjectDynamicValue_h_
+#endif // LLDB_CORE_VALUEOBJECTDYNAMICVALUE_H
diff --git a/lldb/include/lldb/Core/ValueObjectList.h b/lldb/include/lldb/Core/ValueObjectList.h
index 42d19676d5d3..f99fba41aa26 100644
--- a/lldb/include/lldb/Core/ValueObjectList.h
+++ b/lldb/include/lldb/Core/ValueObjectList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ValueObjectList_h_
-#define liblldb_ValueObjectList_h_
+#ifndef LLDB_CORE_VALUEOBJECTLIST_H
+#define LLDB_CORE_VALUEOBJECTLIST_H
#include "lldb/lldb-forward.h"
#include "lldb/lldb-types.h"
@@ -59,4 +59,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_ValueObjectList_h_
+#endif // LLDB_CORE_VALUEOBJECTLIST_H
diff --git a/lldb/include/lldb/Core/ValueObjectMemory.h b/lldb/include/lldb/Core/ValueObjectMemory.h
index df3557f14989..d1cd6ae41445 100644
--- a/lldb/include/lldb/Core/ValueObjectMemory.h
+++ b/lldb/include/lldb/Core/ValueObjectMemory.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ValueObjectMemory_h_
-#define liblldb_ValueObjectMemory_h_
+#ifndef LLDB_CORE_VALUEOBJECTMEMORY_H
+#define LLDB_CORE_VALUEOBJECTMEMORY_H
#include "lldb/Core/Address.h"
#include "lldb/Core/ValueObject.h"
@@ -64,15 +64,18 @@ protected:
CompilerType m_compiler_type;
private:
- ValueObjectMemory(ExecutionContextScope *exe_scope, llvm::StringRef name,
+ ValueObjectMemory(ExecutionContextScope *exe_scope,
+ ValueObjectManager &manager, llvm::StringRef name,
const Address &address, lldb::TypeSP &type_sp);
- ValueObjectMemory(ExecutionContextScope *exe_scope, llvm::StringRef name,
+ ValueObjectMemory(ExecutionContextScope *exe_scope,
+ ValueObjectManager &manager, llvm::StringRef name,
const Address &address, const CompilerType &ast_type);
// For ValueObject only
- DISALLOW_COPY_AND_ASSIGN(ValueObjectMemory);
+ ValueObjectMemory(const ValueObjectMemory &) = delete;
+ const ValueObjectMemory &operator=(const ValueObjectMemory &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ValueObjectMemory_h_
+#endif // LLDB_CORE_VALUEOBJECTMEMORY_H
diff --git a/lldb/include/lldb/Core/ValueObjectRegister.h b/lldb/include/lldb/Core/ValueObjectRegister.h
index e584be6e6057..41051d93b707 100644
--- a/lldb/include/lldb/Core/ValueObjectRegister.h
+++ b/lldb/include/lldb/Core/ValueObjectRegister.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ValueObjectRegister_h_
-#define liblldb_ValueObjectRegister_h_
+#ifndef LLDB_CORE_VALUEOBJECTREGISTER_H
+#define LLDB_CORE_VALUEOBJECTREGISTER_H
#include "lldb/Core/ValueObject.h"
#include "lldb/Symbol/CompilerType.h"
@@ -28,43 +28,6 @@ class ExecutionContextScope;
class Scalar;
class Stream;
-// A ValueObject that contains a root variable that may or may not
-// have children.
-class ValueObjectRegisterContext : public ValueObject {
-public:
- ~ValueObjectRegisterContext() override;
-
- uint64_t GetByteSize() override;
-
- lldb::ValueType GetValueType() const override {
- return lldb::eValueTypeRegisterSet;
- }
-
- ConstString GetTypeName() override;
-
- ConstString GetQualifiedTypeName() override;
-
- ConstString GetDisplayTypeName() override;
-
- size_t CalculateNumChildren(uint32_t max) override;
-
- ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
- int32_t synthetic_index) override;
-
-protected:
- bool UpdateValue() override;
-
- CompilerType GetCompilerTypeImpl() override;
-
- lldb::RegisterContextSP m_reg_ctx_sp;
-
-private:
- ValueObjectRegisterContext(ValueObject &parent,
- lldb::RegisterContextSP &reg_ctx_sp);
- // For ValueObject only
- DISALLOW_COPY_AND_ASSIGN(ValueObjectRegisterContext);
-};
-
class ValueObjectRegisterSet : public ValueObject {
public:
~ValueObjectRegisterSet() override;
@@ -106,10 +69,13 @@ private:
friend class ValueObjectRegisterContext;
ValueObjectRegisterSet(ExecutionContextScope *exe_scope,
+ ValueObjectManager &manager,
lldb::RegisterContextSP &reg_ctx_sp, uint32_t set_idx);
// For ValueObject only
- DISALLOW_COPY_AND_ASSIGN(ValueObjectRegisterSet);
+ ValueObjectRegisterSet(const ValueObjectRegisterSet &) = delete;
+ const ValueObjectRegisterSet &
+ operator=(const ValueObjectRegisterSet &) = delete;
};
class ValueObjectRegister : public ValueObject {
@@ -137,7 +103,7 @@ public:
bool ResolveValue(Scalar &scalar) override;
void
- GetExpressionPath(Stream &s, bool qualify_cxx_base_classes,
+ GetExpressionPath(Stream &s,
GetExpressionPathFormat epformat =
eGetExpressionPathFormatDereferencePointers) override;
@@ -160,12 +126,14 @@ private:
ValueObjectRegister(ValueObject &parent, lldb::RegisterContextSP &reg_ctx_sp,
uint32_t reg_num);
ValueObjectRegister(ExecutionContextScope *exe_scope,
+ ValueObjectManager &manager,
lldb::RegisterContextSP &reg_ctx_sp, uint32_t reg_num);
// For ValueObject only
- DISALLOW_COPY_AND_ASSIGN(ValueObjectRegister);
+ ValueObjectRegister(const ValueObjectRegister &) = delete;
+ const ValueObjectRegister &operator=(const ValueObjectRegister &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ValueObjectRegister_h_
+#endif // LLDB_CORE_VALUEOBJECTREGISTER_H
diff --git a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
index ec395095351d..cb471657aec9 100644
--- a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
+++ b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ValueObjectSyntheticFilter_h_
-#define liblldb_ValueObjectSyntheticFilter_h_
+#ifndef LLDB_CORE_VALUEOBJECTSYNTHETICFILTER_H
+#define LLDB_CORE_VALUEOBJECTSYNTHETICFILTER_H
#include "lldb/Core/ValueObject.h"
#include "lldb/Symbol/CompilerType.h"
@@ -66,7 +66,7 @@ public:
bool IsSynthetic() override { return true; }
- void CalculateSyntheticValue(bool use_synthetic) override {}
+ void CalculateSyntheticValue() override {}
bool IsDynamic() override {
return ((m_parent != nullptr) ? m_parent->IsDynamic() : false);
@@ -164,9 +164,10 @@ private:
void CopyValueData(ValueObject *source);
- DISALLOW_COPY_AND_ASSIGN(ValueObjectSynthetic);
+ ValueObjectSynthetic(const ValueObjectSynthetic &) = delete;
+ const ValueObjectSynthetic &operator=(const ValueObjectSynthetic &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ValueObjectSyntheticFilter_h_
+#endif // LLDB_CORE_VALUEOBJECTSYNTHETICFILTER_H
diff --git a/lldb/include/lldb/Core/ValueObjectVariable.h b/lldb/include/lldb/Core/ValueObjectVariable.h
index 86bb8ef90070..b7e262574a14 100644
--- a/lldb/include/lldb/Core/ValueObjectVariable.h
+++ b/lldb/include/lldb/Core/ValueObjectVariable.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ValueObjectVariable_h_
-#define liblldb_ValueObjectVariable_h_
+#ifndef LLDB_CORE_VALUEOBJECTVARIABLE_H
+#define LLDB_CORE_VALUEOBJECTVARIABLE_H
#include "lldb/Core/ValueObject.h"
@@ -67,6 +67,8 @@ public:
protected:
bool UpdateValue() override;
+
+ void DoUpdateChildrenAddressType(ValueObject &valobj) override;
CompilerType GetCompilerTypeImpl() override;
@@ -77,11 +79,13 @@ protected:
private:
ValueObjectVariable(ExecutionContextScope *exe_scope,
+ ValueObjectManager &manager,
const lldb::VariableSP &var_sp);
// For ValueObject only
- DISALLOW_COPY_AND_ASSIGN(ValueObjectVariable);
+ ValueObjectVariable(const ValueObjectVariable &) = delete;
+ const ValueObjectVariable &operator=(const ValueObjectVariable &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ValueObjectVariable_h_
+#endif // LLDB_CORE_VALUEOBJECTVARIABLE_H
diff --git a/lldb/include/lldb/Core/dwarf.h b/lldb/include/lldb/Core/dwarf.h
index 832109e55c70..cd9cf249bc63 100644
--- a/lldb/include/lldb/Core/dwarf.h
+++ b/lldb/include/lldb/Core/dwarf.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef DebugBase_dwarf_h_
-#define DebugBase_dwarf_h_
+#ifndef LLDB_CORE_DWARF_H
+#define LLDB_CORE_DWARF_H
#include "lldb/Utility/RangeMap.h"
#include <stdint.h>
@@ -71,6 +71,6 @@ typedef uint32_t dw_offset_t; // Dwarf Debug Information Entry offset for any
//#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;
+typedef lldb_private::RangeVector<dw_addr_t, dw_addr_t, 2> DWARFRangeList;
-#endif // DebugBase_dwarf_h_
+#endif // LLDB_CORE_DWARF_H
diff --git a/lldb/include/lldb/DataFormatters/CXXFunctionPointer.h b/lldb/include/lldb/DataFormatters/CXXFunctionPointer.h
index b5417895f7bf..e9742bc31d8c 100644
--- a/lldb/include/lldb/DataFormatters/CXXFunctionPointer.h
+++ b/lldb/include/lldb/DataFormatters/CXXFunctionPointer.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CXXFunctionPointer_h_
-#define liblldb_CXXFunctionPointer_h_
+#ifndef LLDB_DATAFORMATTERS_CXXFUNCTIONPOINTER_H
+#define LLDB_DATAFORMATTERS_CXXFUNCTIONPOINTER_H
#include "lldb/lldb-forward.h"
@@ -18,4 +18,4 @@ bool CXXFunctionPointerSummaryProvider(ValueObject &valobj, Stream &stream,
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_CXXFunctionPointer_h_
+#endif // LLDB_DATAFORMATTERS_CXXFUNCTIONPOINTER_H
diff --git a/lldb/include/lldb/DataFormatters/DataVisualization.h b/lldb/include/lldb/DataFormatters/DataVisualization.h
index f5c3487bcb3b..b053aa074d9e 100644
--- a/lldb/include/lldb/DataFormatters/DataVisualization.h
+++ b/lldb/include/lldb/DataFormatters/DataVisualization.h
@@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_DataVisualization_h_
-#define lldb_DataVisualization_h_
-
+#ifndef LLDB_DATAFORMATTERS_DATAVISUALIZATION_H
+#define LLDB_DATAFORMATTERS_DATAVISUALIZATION_H
#include "lldb/DataFormatters/FormatClasses.h"
#include "lldb/DataFormatters/FormatManager.h"
@@ -122,4 +121,4 @@ public:
} // namespace lldb_private
-#endif // lldb_DataVisualization_h_
+#endif // LLDB_DATAFORMATTERS_DATAVISUALIZATION_H
diff --git a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
index c37411539de6..2f3bdf80a6f1 100644
--- a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
+++ b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_DumpValueObjectOptions_h_
-#define lldb_DumpValueObjectOptions_h_
+#ifndef LLDB_DATAFORMATTERS_DUMPVALUEOBJECTOPTIONS_H
+#define LLDB_DATAFORMATTERS_DUMPVALUEOBJECTOPTIONS_H
#include <string>
@@ -127,7 +127,6 @@ public:
DumpValueObjectOptions &
SetPointerAsArray(const PointerAsArraySettings &ptr_array);
-public:
uint32_t m_max_depth = UINT32_MAX;
lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues;
uint32_t m_omit_summary_depth = 0;
@@ -157,4 +156,4 @@ public:
} // namespace lldb_private
-#endif // lldb_DumpValueObjectOptions_h_
+#endif // LLDB_DATAFORMATTERS_DUMPVALUEOBJECTOPTIONS_H
diff --git a/lldb/include/lldb/DataFormatters/FormatCache.h b/lldb/include/lldb/DataFormatters/FormatCache.h
index f9dbe414640d..e75aaee1a7bb 100644
--- a/lldb/include/lldb/DataFormatters/FormatCache.h
+++ b/lldb/include/lldb/DataFormatters/FormatCache.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_FormatCache_h_
-#define lldb_FormatCache_h_
+#ifndef LLDB_DATAFORMATTERS_FORMATCACHE_H
+#define LLDB_DATAFORMATTERS_FORMATCACHE_H
#include <map>
#include <mutex>
@@ -49,13 +49,13 @@ private:
CacheMap m_map;
std::recursive_mutex m_mutex;
- uint64_t m_cache_hits;
- uint64_t m_cache_misses;
+ uint64_t m_cache_hits = 0;
+ uint64_t m_cache_misses = 0;
Entry &GetEntry(ConstString type);
public:
- FormatCache();
+ FormatCache() = default;
template <typename ImplSP> bool Get(ConstString type, ImplSP &format_impl_sp);
void Set(ConstString type, lldb::TypeFormatImplSP &format_sp);
@@ -71,4 +71,4 @@ public:
} // namespace lldb_private
-#endif // lldb_FormatCache_h_
+#endif // LLDB_DATAFORMATTERS_FORMATCACHE_H
diff --git a/lldb/include/lldb/DataFormatters/FormatClasses.h b/lldb/include/lldb/DataFormatters/FormatClasses.h
index 91ce444244cc..e3989133a602 100644
--- a/lldb/include/lldb/DataFormatters/FormatClasses.h
+++ b/lldb/include/lldb/DataFormatters/FormatClasses.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_FormatClasses_h_
-#define lldb_FormatClasses_h_
+#ifndef LLDB_DATAFORMATTERS_FORMATCLASSES_H
+#define LLDB_DATAFORMATTERS_FORMATCLASSES_H
#include <functional>
#include <memory>
@@ -43,17 +43,15 @@ public:
class FormattersMatchCandidate {
public:
- FormattersMatchCandidate(ConstString name, uint32_t reason, bool strip_ptr,
+ FormattersMatchCandidate(ConstString name, bool strip_ptr,
bool strip_ref, bool strip_tydef)
- : m_type_name(name), m_reason(reason), m_stripped_pointer(strip_ptr),
+ : m_type_name(name), m_stripped_pointer(strip_ptr),
m_stripped_reference(strip_ref), m_stripped_typedef(strip_tydef) {}
~FormattersMatchCandidate() = default;
ConstString GetTypeName() const { return m_type_name; }
- uint32_t GetReason() const { return m_reason; }
-
bool DidStripPointer() const { return m_stripped_pointer; }
bool DidStripReference() const { return m_stripped_reference; }
@@ -75,7 +73,6 @@ public:
private:
ConstString m_type_name;
- uint32_t m_reason;
bool m_stripped_pointer;
bool m_stripped_reference;
bool m_stripped_typedef;
@@ -112,21 +109,21 @@ public:
TypeNameSpecifierImpl(llvm::StringRef name, bool is_regex)
: m_is_regex(is_regex), m_type() {
- m_type.m_type_name = name;
+ m_type.m_type_name = std::string(name);
}
// if constructing with a given type, is_regex cannot be true since we are
// giving an exact type to match
TypeNameSpecifierImpl(lldb::TypeSP type) : m_is_regex(false), m_type() {
if (type) {
- m_type.m_type_name = type->GetName().GetStringRef();
+ m_type.m_type_name = std::string(type->GetName().GetStringRef());
m_type.m_compiler_type = type->GetForwardCompilerType();
}
}
TypeNameSpecifierImpl(CompilerType type) : m_is_regex(false), m_type() {
if (type.IsValid()) {
- m_type.m_type_name.assign(type.GetConstTypeName().GetCString());
+ m_type.m_type_name.assign(type.GetTypeName().GetCString());
m_type.m_compiler_type = type;
}
}
@@ -154,10 +151,11 @@ private:
};
TypeOrName m_type;
-private:
- DISALLOW_COPY_AND_ASSIGN(TypeNameSpecifierImpl);
+ TypeNameSpecifierImpl(const TypeNameSpecifierImpl &) = delete;
+ const TypeNameSpecifierImpl &
+ operator=(const TypeNameSpecifierImpl &) = delete;
};
} // namespace lldb_private
-#endif // lldb_FormatClasses_h_
+#endif // LLDB_DATAFORMATTERS_FORMATCLASSES_H
diff --git a/lldb/include/lldb/DataFormatters/FormatManager.h b/lldb/include/lldb/DataFormatters/FormatManager.h
index dd522c487c8f..56a0303f9b02 100644
--- a/lldb/include/lldb/DataFormatters/FormatManager.h
+++ b/lldb/include/lldb/DataFormatters/FormatManager.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_FormatManager_h_
-#define lldb_FormatManager_h_
+#ifndef LLDB_DATAFORMATTERS_FORMATMANAGER_H
+#define LLDB_DATAFORMATTERS_FORMATMANAGER_H
#include <atomic>
#include <initializer_list>
@@ -170,7 +170,6 @@ public:
GetPossibleMatches(ValueObject &valobj, lldb::DynamicValueType use_dynamic) {
FormattersMatchVector matches;
GetPossibleMatches(valobj, valobj.GetCompilerType(),
- lldb_private::eFormatterChoiceCriterionDirectChoice,
use_dynamic, matches, false, false, false, true);
return matches;
}
@@ -184,7 +183,7 @@ public:
private:
static void GetPossibleMatches(ValueObject &valobj,
- CompilerType compiler_type, uint32_t reason,
+ CompilerType compiler_type,
lldb::DynamicValueType use_dynamic,
FormattersMatchVector &entries,
bool did_strip_ptr, bool did_strip_ref,
@@ -224,4 +223,4 @@ private:
} // namespace lldb_private
-#endif // lldb_FormatManager_h_
+#endif // LLDB_DATAFORMATTERS_FORMATMANAGER_H
diff --git a/lldb/include/lldb/DataFormatters/FormattersContainer.h b/lldb/include/lldb/DataFormatters/FormattersContainer.h
index 86023dd9bf0b..d414882bae19 100644
--- a/lldb/include/lldb/DataFormatters/FormattersContainer.h
+++ b/lldb/include/lldb/DataFormatters/FormattersContainer.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_FormattersContainer_h_
-#define lldb_FormattersContainer_h_
+#ifndef LLDB_DATAFORMATTERS_FORMATTERSCONTAINER_H
+#define LLDB_DATAFORMATTERS_FORMATTERSCONTAINER_H
#include <functional>
#include <map>
@@ -181,16 +181,13 @@ public:
}
bool Get(ValueObject &valobj, MapValueType &entry,
- lldb::DynamicValueType use_dynamic, uint32_t *why = nullptr) {
- uint32_t value = lldb_private::eFormatterChoiceCriterionDirectChoice;
+ lldb::DynamicValueType use_dynamic) {
CompilerType ast_type(valobj.GetCompilerType());
- bool ret = Get(valobj, ast_type, entry, use_dynamic, value);
+ bool ret = Get(valobj, ast_type, entry, use_dynamic);
if (ret)
entry = MapValueType(entry);
else
entry = MapValueType();
- if (why)
- *why = value;
return ret;
}
@@ -221,7 +218,8 @@ protected:
BackEndType m_format_map;
std::string m_name;
- DISALLOW_COPY_AND_ASSIGN(FormattersContainer);
+ FormattersContainer(const FormattersContainer &) = delete;
+ const FormattersContainer &operator=(const FormattersContainer &) = delete;
void Add_Impl(MapKeyType type, const MapValueType &entry,
RegularExpression *dummy) {
@@ -266,7 +264,7 @@ protected:
ConstString key = m_format_map.GetKeyAtIndex(index);
if (key)
return lldb::TypeNameSpecifierImplSP(
- new TypeNameSpecifierImpl(key.AsCString(), false));
+ new TypeNameSpecifierImpl(key.GetStringRef(), false));
else
return lldb::TypeNameSpecifierImplSP();
}
@@ -308,16 +306,13 @@ protected:
return false;
}
- bool Get(const FormattersMatchVector &candidates, MapValueType &entry,
- uint32_t *reason) {
+ bool Get(const FormattersMatchVector &candidates, MapValueType &entry) {
for (const FormattersMatchCandidate &candidate : candidates) {
if (Get(candidate.GetTypeName(), entry)) {
if (candidate.IsMatch(entry) == false) {
entry.reset();
continue;
} else {
- if (reason)
- *reason = candidate.GetReason();
return true;
}
}
@@ -328,4 +323,4 @@ protected:
} // namespace lldb_private
-#endif // lldb_FormattersContainer_h_
+#endif // LLDB_DATAFORMATTERS_FORMATTERSCONTAINER_H
diff --git a/lldb/include/lldb/DataFormatters/FormattersHelpers.h b/lldb/include/lldb/DataFormatters/FormattersHelpers.h
index 79bd376c76eb..a5b0da57e5d8 100644
--- a/lldb/include/lldb/DataFormatters/FormattersHelpers.h
+++ b/lldb/include/lldb/DataFormatters/FormattersHelpers.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_FormattersHelpers_h_
-#define lldb_FormattersHelpers_h_
+#ifndef LLDB_DATAFORMATTERS_FORMATTERSHELPERS_H
+#define LLDB_DATAFORMATTERS_FORMATTERSHELPERS_H
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
@@ -56,6 +56,8 @@ size_t ExtractIndexFromString(const char *item_name);
lldb::addr_t GetArrayAddressOrPointerValue(ValueObject &valobj);
+lldb::ValueObjectSP GetValueOfLibCXXCompressedPair(ValueObject &pair);
+
time_t GetOSXEpoch();
struct InferiorSizedWord {
@@ -184,4 +186,4 @@ private:
} // namespace formatters
} // namespace lldb_private
-#endif // lldb_FormattersHelpers_h_
+#endif // LLDB_DATAFORMATTERS_FORMATTERSHELPERS_H
diff --git a/lldb/include/lldb/DataFormatters/LanguageCategory.h b/lldb/include/lldb/DataFormatters/LanguageCategory.h
index 1cffff91c197..d7676730fbd6 100644
--- a/lldb/include/lldb/DataFormatters/LanguageCategory.h
+++ b/lldb/include/lldb/DataFormatters/LanguageCategory.h
@@ -7,9 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_LanguageCategory_h_
-#define lldb_LanguageCategory_h_
-
+#ifndef LLDB_DATAFORMATTERS_LANGUAGECATEGORY_H
+#define LLDB_DATAFORMATTERS_LANGUAGECATEGORY_H
#include "lldb/DataFormatters/FormatCache.h"
#include "lldb/DataFormatters/FormatClasses.h"
@@ -58,4 +57,4 @@ private:
} // namespace lldb_private
-#endif // lldb_LanguageCategory_h_
+#endif // LLDB_DATAFORMATTERS_LANGUAGECATEGORY_H
diff --git a/lldb/include/lldb/DataFormatters/StringPrinter.h b/lldb/include/lldb/DataFormatters/StringPrinter.h
index 43b92019e6fd..17c645f8637a 100644
--- a/lldb/include/lldb/DataFormatters/StringPrinter.h
+++ b/lldb/include/lldb/DataFormatters/StringPrinter.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_StringPrinter_h_
-#define liblldb_StringPrinter_h_
+#ifndef LLDB_DATAFORMATTERS_STRINGPRINTER_H
+#define LLDB_DATAFORMATTERS_STRINGPRINTER_H
#include <functional>
#include <string>
@@ -24,6 +24,8 @@ public:
enum class GetPrintableElementType { ASCII, UTF8 };
+ enum class EscapeStyle { CXX, Swift };
+
class DumpToStreamOptions {
public:
DumpToStreamOptions() = default;
@@ -68,9 +70,9 @@ public:
bool GetIgnoreMaxLength() const { return m_ignore_max_length; }
- void SetLanguage(lldb::LanguageType l) { m_language_type = l; }
+ void SetEscapeStyle(EscapeStyle style) { m_escape_style = style; }
- lldb::LanguageType GetLanguage() const { return m_language_type; }
+ EscapeStyle GetEscapeStyle() const { return m_escape_style; }
private:
/// The used output stream.
@@ -93,12 +95,8 @@ public:
/// True iff a zero bytes ('\0') should terminate the memory region that
/// is being dumped.
bool m_zero_is_terminator = true;
- /// The language that the generated string literal is supposed to be valid
- /// for. This changes for example what and how certain characters are
- /// escaped.
- /// For example, printing the a string containing only a quote (") char
- /// with eLanguageTypeC would escape the quote character.
- lldb::LanguageType m_language_type = lldb::eLanguageTypeUnknown;
+ /// The language-specific style for escaping special characters.
+ EscapeStyle m_escape_style = EscapeStyle::CXX;
};
class ReadStringAndDumpToStreamOptions : public DumpToStreamOptions {
@@ -115,9 +113,15 @@ public:
lldb::ProcessSP GetProcessSP() const { return m_process_sp; }
+ void SetHasSourceSize(bool e) { m_has_source_size = e; }
+
+ bool HasSourceSize() const { return m_has_source_size; }
+
private:
uint64_t m_location = 0;
lldb::ProcessSP m_process_sp;
+ /// True iff we know the source size of the string.
+ bool m_has_source_size = false;
};
class ReadBufferAndDumpToStreamOptions : public DumpToStreamOptions {
@@ -141,75 +145,6 @@ public:
bool m_is_truncated = false;
};
- // 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);
@@ -222,4 +157,4 @@ public:
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_StringPrinter_h_
+#endif // LLDB_DATAFORMATTERS_STRINGPRINTER_H
diff --git a/lldb/include/lldb/DataFormatters/TypeCategory.h b/lldb/include/lldb/DataFormatters/TypeCategory.h
index d5aab6dc3a52..820872a59bda 100644
--- a/lldb/include/lldb/DataFormatters/TypeCategory.h
+++ b/lldb/include/lldb/DataFormatters/TypeCategory.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_TypeCategory_h_
-#define lldb_TypeCategory_h_
+#ifndef LLDB_DATAFORMATTERS_TYPECATEGORY_H
+#define LLDB_DATAFORMATTERS_TYPECATEGORY_H
#include <initializer_list>
#include <memory>
@@ -285,13 +285,13 @@ public:
}
bool Get(lldb::LanguageType lang, const FormattersMatchVector &candidates,
- lldb::TypeFormatImplSP &entry, uint32_t *reason = nullptr);
+ lldb::TypeFormatImplSP &entry);
bool Get(lldb::LanguageType lang, const FormattersMatchVector &candidates,
- lldb::TypeSummaryImplSP &entry, uint32_t *reason = nullptr);
+ lldb::TypeSummaryImplSP &entry);
bool Get(lldb::LanguageType lang, const FormattersMatchVector &candidates,
- lldb::SyntheticChildrenSP &entry, uint32_t *reason = nullptr);
+ lldb::SyntheticChildrenSP &entry);
void Clear(FormatCategoryItems items = ALL_ITEM_TYPES);
@@ -366,4 +366,4 @@ private:
} // namespace lldb_private
-#endif // lldb_TypeCategory_h_
+#endif // LLDB_DATAFORMATTERS_TYPECATEGORY_H
diff --git a/lldb/include/lldb/DataFormatters/TypeCategoryMap.h b/lldb/include/lldb/DataFormatters/TypeCategoryMap.h
index ae577a334014..832652f7d745 100644
--- a/lldb/include/lldb/DataFormatters/TypeCategoryMap.h
+++ b/lldb/include/lldb/DataFormatters/TypeCategoryMap.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_TypeCategoryMap_h_
-#define lldb_TypeCategoryMap_h_
+#ifndef LLDB_DATAFORMATTERS_TYPECATEGORYMAP_H
+#define LLDB_DATAFORMATTERS_TYPECATEGORYMAP_H
#include <functional>
#include <list>
@@ -108,4 +108,4 @@ private:
};
} // namespace lldb_private
-#endif // lldb_TypeCategoryMap_h_
+#endif // LLDB_DATAFORMATTERS_TYPECATEGORYMAP_H
diff --git a/lldb/include/lldb/DataFormatters/TypeFormat.h b/lldb/include/lldb/DataFormatters/TypeFormat.h
index 77e8c0efc706..b8ed6a3443b3 100644
--- a/lldb/include/lldb/DataFormatters/TypeFormat.h
+++ b/lldb/include/lldb/DataFormatters/TypeFormat.h
@@ -7,9 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_TypeFormat_h_
-#define lldb_TypeFormat_h_
-
+#ifndef LLDB_DATAFORMATTERS_TYPEFORMAT_H
+#define LLDB_DATAFORMATTERS_TYPEFORMAT_H
#include <functional>
#include <string>
@@ -153,7 +152,8 @@ protected:
uint32_t m_my_revision;
private:
- DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl);
+ TypeFormatImpl(const TypeFormatImpl &) = delete;
+ const TypeFormatImpl &operator=(const TypeFormatImpl &) = delete;
};
class TypeFormatImpl_Format : public TypeFormatImpl {
@@ -181,7 +181,9 @@ protected:
lldb::Format m_format;
private:
- DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl_Format);
+ TypeFormatImpl_Format(const TypeFormatImpl_Format &) = delete;
+ const TypeFormatImpl_Format &
+ operator=(const TypeFormatImpl_Format &) = delete;
};
class TypeFormatImpl_EnumType : public TypeFormatImpl {
@@ -210,8 +212,10 @@ protected:
mutable std::unordered_map<void *, CompilerType> m_types;
private:
- DISALLOW_COPY_AND_ASSIGN(TypeFormatImpl_EnumType);
+ TypeFormatImpl_EnumType(const TypeFormatImpl_EnumType &) = delete;
+ const TypeFormatImpl_EnumType &
+ operator=(const TypeFormatImpl_EnumType &) = delete;
};
} // namespace lldb_private
-#endif // lldb_TypeFormat_h_
+#endif // LLDB_DATAFORMATTERS_TYPEFORMAT_H
diff --git a/lldb/include/lldb/DataFormatters/TypeSummary.h b/lldb/include/lldb/DataFormatters/TypeSummary.h
index 9c97b3606f25..6c3780f7276d 100644
--- a/lldb/include/lldb/DataFormatters/TypeSummary.h
+++ b/lldb/include/lldb/DataFormatters/TypeSummary.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_TypeSummary_h_
-#define lldb_TypeSummary_h_
+#ifndef LLDB_DATAFORMATTERS_TYPESUMMARY_H
+#define LLDB_DATAFORMATTERS_TYPESUMMARY_H
#include <stdint.h>
@@ -270,7 +270,8 @@ protected:
private:
Kind m_kind;
- DISALLOW_COPY_AND_ASSIGN(TypeSummaryImpl);
+ TypeSummaryImpl(const TypeSummaryImpl &) = delete;
+ const TypeSummaryImpl &operator=(const TypeSummaryImpl &) = delete;
};
// simple string-based summaries, using ${var to show data
@@ -297,7 +298,8 @@ struct StringSummaryFormat : public TypeSummaryImpl {
}
private:
- DISALLOW_COPY_AND_ASSIGN(StringSummaryFormat);
+ StringSummaryFormat(const StringSummaryFormat &) = delete;
+ const StringSummaryFormat &operator=(const StringSummaryFormat &) = delete;
};
// summaries implemented via a C++ function
@@ -341,7 +343,9 @@ struct CXXFunctionSummaryFormat : public TypeSummaryImpl {
typedef std::shared_ptr<CXXFunctionSummaryFormat> SharedPointer;
private:
- DISALLOW_COPY_AND_ASSIGN(CXXFunctionSummaryFormat);
+ CXXFunctionSummaryFormat(const CXXFunctionSummaryFormat &) = delete;
+ const CXXFunctionSummaryFormat &
+ operator=(const CXXFunctionSummaryFormat &) = delete;
};
// Python-based summaries, running script code to show data
@@ -387,8 +391,9 @@ struct ScriptSummaryFormat : public TypeSummaryImpl {
typedef std::shared_ptr<ScriptSummaryFormat> SharedPointer;
private:
- DISALLOW_COPY_AND_ASSIGN(ScriptSummaryFormat);
+ ScriptSummaryFormat(const ScriptSummaryFormat &) = delete;
+ const ScriptSummaryFormat &operator=(const ScriptSummaryFormat &) = delete;
};
} // namespace lldb_private
-#endif // lldb_TypeSummary_h_
+#endif // LLDB_DATAFORMATTERS_TYPESUMMARY_H
diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
index 93443cf7e84b..c852ff18bfa2 100644
--- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h
+++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_TypeSynthetic_h_
-#define lldb_TypeSynthetic_h_
+#ifndef LLDB_DATAFORMATTERS_TYPESYNTHETIC_H
+#define LLDB_DATAFORMATTERS_TYPESYNTHETIC_H
#include <stdint.h>
@@ -96,7 +96,9 @@ protected:
private:
bool m_valid;
- DISALLOW_COPY_AND_ASSIGN(SyntheticChildrenFrontEnd);
+ SyntheticChildrenFrontEnd(const SyntheticChildrenFrontEnd &) = delete;
+ const SyntheticChildrenFrontEnd &
+ operator=(const SyntheticChildrenFrontEnd &) = delete;
};
class SyntheticValueProviderFrontEnd : public SyntheticChildrenFrontEnd {
@@ -121,7 +123,10 @@ public:
lldb::ValueObjectSP GetSyntheticValue() override = 0;
private:
- DISALLOW_COPY_AND_ASSIGN(SyntheticValueProviderFrontEnd);
+ SyntheticValueProviderFrontEnd(const SyntheticValueProviderFrontEnd &) =
+ delete;
+ const SyntheticValueProviderFrontEnd &
+ operator=(const SyntheticValueProviderFrontEnd &) = delete;
};
class SyntheticChildren {
@@ -265,7 +270,8 @@ protected:
Flags m_flags;
private:
- DISALLOW_COPY_AND_ASSIGN(SyntheticChildren);
+ SyntheticChildren(const SyntheticChildren &) = delete;
+ const SyntheticChildren &operator=(const SyntheticChildren &) = delete;
};
class TypeFilterImpl : public SyntheticChildren {
@@ -333,7 +339,8 @@ public:
private:
TypeFilterImpl *filter;
- DISALLOW_COPY_AND_ASSIGN(FrontEnd);
+ FrontEnd(const FrontEnd &) = delete;
+ const FrontEnd &operator=(const FrontEnd &) = delete;
};
SyntheticChildrenFrontEnd::AutoPointer
@@ -344,7 +351,8 @@ public:
typedef std::shared_ptr<TypeFilterImpl> SharedPointer;
private:
- DISALLOW_COPY_AND_ASSIGN(TypeFilterImpl);
+ TypeFilterImpl(const TypeFilterImpl &) = delete;
+ const TypeFilterImpl &operator=(const TypeFilterImpl &) = delete;
};
class CXXSyntheticChildren : public SyntheticChildren {
@@ -372,7 +380,8 @@ protected:
std::string m_description;
private:
- DISALLOW_COPY_AND_ASSIGN(CXXSyntheticChildren);
+ CXXSyntheticChildren(const CXXSyntheticChildren &) = delete;
+ const CXXSyntheticChildren &operator=(const CXXSyntheticChildren &) = delete;
};
class ScriptedSyntheticChildren : public SyntheticChildren {
@@ -435,7 +444,8 @@ public:
StructuredData::ObjectSP m_wrapper_sp;
ScriptInterpreter *m_interpreter;
- DISALLOW_COPY_AND_ASSIGN(FrontEnd);
+ FrontEnd(const FrontEnd &) = delete;
+ const FrontEnd &operator=(const FrontEnd &) = delete;
};
SyntheticChildrenFrontEnd::AutoPointer
@@ -448,8 +458,10 @@ public:
}
private:
- DISALLOW_COPY_AND_ASSIGN(ScriptedSyntheticChildren);
+ ScriptedSyntheticChildren(const ScriptedSyntheticChildren &) = delete;
+ const ScriptedSyntheticChildren &
+ operator=(const ScriptedSyntheticChildren &) = delete;
};
} // namespace lldb_private
-#endif // lldb_TypeSynthetic_h_
+#endif // LLDB_DATAFORMATTERS_TYPESYNTHETIC_H
diff --git a/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h b/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
index 33813b38701c..f1301d8595b1 100644
--- a/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
+++ b/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
@@ -7,9 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_ValueObjectPrinter_h_
-#define lldb_ValueObjectPrinter_h_
-
+#ifndef LLDB_DATAFORMATTERS_VALUEOBJECTPRINTER_H
+#define LLDB_DATAFORMATTERS_VALUEOBJECTPRINTER_H
#include "lldb/lldb-private.h"
#include "lldb/lldb-public.h"
@@ -58,7 +57,7 @@ protected:
const char *GetDescriptionForDisplay();
- const char *GetRootNameForDisplay(const char *if_fail = nullptr);
+ const char *GetRootNameForDisplay();
bool ShouldPrintValueObject();
@@ -142,9 +141,10 @@ private:
friend struct StringSummaryFormat;
- DISALLOW_COPY_AND_ASSIGN(ValueObjectPrinter);
+ ValueObjectPrinter(const ValueObjectPrinter &) = delete;
+ const ValueObjectPrinter &operator=(const ValueObjectPrinter &) = delete;
};
} // namespace lldb_private
-#endif // lldb_ValueObjectPrinter_h_
+#endif // LLDB_DATAFORMATTERS_VALUEOBJECTPRINTER_H
diff --git a/lldb/include/lldb/DataFormatters/VectorIterator.h b/lldb/include/lldb/DataFormatters/VectorIterator.h
index cde4be498b0f..33650a3dac8f 100644
--- a/lldb/include/lldb/DataFormatters/VectorIterator.h
+++ b/lldb/include/lldb/DataFormatters/VectorIterator.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_VectorIterator_h_
-#define liblldb_VectorIterator_h_
+#ifndef LLDB_DATAFORMATTERS_VECTORITERATOR_H
+#define LLDB_DATAFORMATTERS_VECTORITERATOR_H
#include "lldb/lldb-forward.h"
@@ -42,4 +42,4 @@ private:
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_CF_h_
+#endif // LLDB_DATAFORMATTERS_VECTORITERATOR_H
diff --git a/lldb/include/lldb/DataFormatters/VectorType.h b/lldb/include/lldb/DataFormatters/VectorType.h
index b757f758e77f..6a66b1815c29 100644
--- a/lldb/include/lldb/DataFormatters/VectorType.h
+++ b/lldb/include/lldb/DataFormatters/VectorType.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_VectorType_h_
-#define liblldb_VectorType_h_
+#ifndef LLDB_DATAFORMATTERS_VECTORTYPE_H
+#define LLDB_DATAFORMATTERS_VECTORTYPE_H
#include "lldb/lldb-forward.h"
@@ -21,4 +21,4 @@ VectorTypeSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP);
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_VectorType_h_
+#endif // LLDB_DATAFORMATTERS_VECTORTYPE_H
diff --git a/lldb/include/lldb/Expression/DWARFExpression.h b/lldb/include/lldb/Expression/DWARFExpression.h
index bfae142d5e01..6b63b186e3e4 100644
--- a/lldb/include/lldb/Expression/DWARFExpression.h
+++ b/lldb/include/lldb/Expression/DWARFExpression.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DWARFExpression_h_
-#define liblldb_DWARFExpression_h_
+#ifndef LLDB_EXPRESSION_DWARFEXPRESSION_H
+#define LLDB_EXPRESSION_DWARFEXPRESSION_H
#include "lldb/Core/Address.h"
#include "lldb/Core/Disassembler.h"
@@ -217,14 +217,6 @@ public:
lldb::addr_t func_load_addr, lldb::addr_t address,
ABI *abi);
- static bool PrintDWARFExpression(Stream &s, const DataExtractor &data,
- int address_size, int dwarf_ref_size,
- bool location_expression);
-
- static void PrintDWARFLocationList(Stream &s, const DWARFUnit *cu,
- const DataExtractor &debug_loc_data,
- lldb::offset_t offset);
-
bool MatchesOperand(StackFrame &frame, const Instruction::Operand &op);
private:
@@ -233,11 +225,8 @@ private:
/// \param[in] s
/// The stream to use for pretty-printing.
///
- /// \param[in] offset
- /// The offset into the data buffer of the opcodes to be printed.
- ///
- /// \param[in] length
- /// The length in bytes of the opcodes to be printed.
+ /// \param[in] data
+ /// The data extractor.
///
/// \param[in] level
/// The level of detail to use in pretty-printing.
@@ -275,4 +264,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_DWARFExpression_h_
+#endif // LLDB_EXPRESSION_DWARFEXPRESSION_H
diff --git a/lldb/include/lldb/Expression/DiagnosticManager.h b/lldb/include/lldb/Expression/DiagnosticManager.h
index e5aecce08727..c0271c954ba3 100644
--- a/lldb/include/lldb/Expression/DiagnosticManager.h
+++ b/lldb/include/lldb/Expression/DiagnosticManager.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_DiagnosticManager_h
-#define lldb_DiagnosticManager_h
+#ifndef LLDB_EXPRESSION_DIAGNOSTICMANAGER_H
+#define LLDB_EXPRESSION_DIAGNOSTICMANAGER_H
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
@@ -78,7 +78,7 @@ public:
bool precede_with_newline = true) {
if (precede_with_newline)
m_message.push_back('\n');
- m_message.append(message);
+ m_message += message;
}
protected:
@@ -148,4 +148,4 @@ protected:
};
}
-#endif /* lldb_DiagnosticManager_h */
+#endif // LLDB_EXPRESSION_DIAGNOSTICMANAGER_H
diff --git a/lldb/include/lldb/Expression/DynamicCheckerFunctions.h b/lldb/include/lldb/Expression/DynamicCheckerFunctions.h
index 7be24b6ea962..02bce5abdf4c 100644
--- a/lldb/include/lldb/Expression/DynamicCheckerFunctions.h
+++ b/lldb/include/lldb/Expression/DynamicCheckerFunctions.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DynamicCheckerFunctions_h_
-#define liblldb_DynamicCheckerFunctions_h_
+#ifndef LLDB_EXPRESSION_DYNAMICCHECKERFUNCTIONS_H
+#define LLDB_EXPRESSION_DYNAMICCHECKERFUNCTIONS_H
#include "lldb/lldb-types.h"
@@ -59,4 +59,4 @@ private:
};
} // namespace lldb_private
-#endif // liblldb_DynamicCheckerFunctions_h_
+#endif // LLDB_EXPRESSION_DYNAMICCHECKERFUNCTIONS_H
diff --git a/lldb/include/lldb/Expression/Expression.h b/lldb/include/lldb/Expression/Expression.h
index e0ea7e99f4f9..aaac889e6ed2 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Expression_h_
-#define liblldb_Expression_h_
+#ifndef LLDB_EXPRESSION_EXPRESSION_H
+#define LLDB_EXPRESSION_EXPRESSION_H
#include <map>
#include <string>
@@ -51,7 +51,9 @@ public:
/// Return the language that should be used when parsing. To use the
/// default, return eLanguageTypeUnknown.
- virtual lldb::LanguageType Language() { return lldb::eLanguageTypeUnknown; }
+ virtual lldb::LanguageType Language() const {
+ return lldb::eLanguageTypeUnknown;
+ }
/// Return the Materializer that the parser should use when registering
/// external values.
@@ -101,4 +103,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_Expression_h_
+#endif // LLDB_EXPRESSION_EXPRESSION_H
diff --git a/lldb/include/lldb/Expression/ExpressionParser.h b/lldb/include/lldb/Expression/ExpressionParser.h
index 2e7b3075d509..71d2410ea7c3 100644
--- a/lldb/include/lldb/Expression/ExpressionParser.h
+++ b/lldb/include/lldb/Expression/ExpressionParser.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ExpressionParser_h_
-#define liblldb_ExpressionParser_h_
+#ifndef LLDB_EXPRESSION_EXPRESSIONPARSER_H
+#define LLDB_EXPRESSION_EXPRESSIONPARSER_H
#include "lldb/Utility/CompletionRequest.h"
#include "lldb/Utility/Status.h"
@@ -133,4 +133,4 @@ protected:
};
}
-#endif // liblldb_ExpressionParser_h_
+#endif // LLDB_EXPRESSION_EXPRESSIONPARSER_H
diff --git a/lldb/include/lldb/Expression/ExpressionSourceCode.h b/lldb/include/lldb/Expression/ExpressionSourceCode.h
index db8ef967ab15..a3be73997c26 100644
--- a/lldb/include/lldb/Expression/ExpressionSourceCode.h
+++ b/lldb/include/lldb/Expression/ExpressionSourceCode.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ExpressionSourceCode_h
-#define liblldb_ExpressionSourceCode_h
+#ifndef LLDB_EXPRESSION_EXPRESSIONSOURCECODE_H
+#define LLDB_EXPRESSION_EXPRESSIONSOURCECODE_H
#include "lldb/lldb-enumerations.h"
#include "llvm/ADT/ArrayRef.h"
diff --git a/lldb/include/lldb/Expression/ExpressionTypeSystemHelper.h b/lldb/include/lldb/Expression/ExpressionTypeSystemHelper.h
index 9c645532cdc1..1bba30ad8620 100644
--- a/lldb/include/lldb/Expression/ExpressionTypeSystemHelper.h
+++ b/lldb/include/lldb/Expression/ExpressionTypeSystemHelper.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef ExpressionTypeSystemHelper_h
-#define ExpressionTypeSystemHelper_h
+#ifndef LLDB_EXPRESSION_EXPRESSIONTYPESYSTEMHELPER_H
+#define LLDB_EXPRESSION_EXPRESSIONTYPESYSTEMHELPER_H
#include "llvm/Support/Casting.h"
@@ -44,4 +44,4 @@ protected:
} // namespace lldb_private
-#endif /* ExpressionTypeSystemHelper_h */
+#endif // LLDB_EXPRESSION_EXPRESSIONTYPESYSTEMHELPER_H
diff --git a/lldb/include/lldb/Expression/ExpressionVariable.h b/lldb/include/lldb/Expression/ExpressionVariable.h
index c20c2301bb54..60062d212bad 100644
--- a/lldb/include/lldb/Expression/ExpressionVariable.h
+++ b/lldb/include/lldb/Expression/ExpressionVariable.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ExpressionVariable_h_
-#define liblldb_ExpressionVariable_h_
+#ifndef LLDB_EXPRESSION_EXPRESSIONVARIABLE_H
+#define LLDB_EXPRESSION_EXPRESSIONVARIABLE_H
#include <memory>
#include <vector>
@@ -221,11 +221,7 @@ public:
uint32_t addr_byte_size) = 0;
/// Return a new persistent variable name with the specified prefix.
- ConstString GetNextPersistentVariableName(Target &target,
- llvm::StringRef prefix);
-
- virtual llvm::StringRef
- GetPersistentVariablePrefix(bool is_error = false) const = 0;
+ virtual ConstString GetNextPersistentVariableName(bool is_error = false) = 0;
virtual void
RemovePersistentVariable(lldb::ExpressionVariableSP variable) = 0;
@@ -237,6 +233,10 @@ public:
void RegisterExecutionUnit(lldb::IRExecutionUnitSP &execution_unit_sp);
+protected:
+ virtual llvm::StringRef
+ GetPersistentVariablePrefix(bool is_error = false) const = 0;
+
private:
LLVMCastKind m_kind;
@@ -251,4 +251,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ExpressionVariable_h_
+#endif // LLDB_EXPRESSION_EXPRESSIONVARIABLE_H
diff --git a/lldb/include/lldb/Expression/FunctionCaller.h b/lldb/include/lldb/Expression/FunctionCaller.h
index 1303655f449f..f35ee820edde 100644
--- a/lldb/include/lldb/Expression/FunctionCaller.h
+++ b/lldb/include/lldb/Expression/FunctionCaller.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_FunctionCaller_h_
-#define liblldb_FunctionCaller_h_
+#ifndef LLDB_EXPRESSION_FUNCTIONCALLER_H
+#define LLDB_EXPRESSION_FUNCTIONCALLER_H
#include <list>
#include <memory>
@@ -336,4 +336,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_FunctionCaller_h_
+#endif // LLDB_EXPRESSION_FUNCTIONCALLER_H
diff --git a/lldb/include/lldb/Expression/IRExecutionUnit.h b/lldb/include/lldb/Expression/IRExecutionUnit.h
index 05f2f8471ef8..ad3c7372e67d 100644
--- a/lldb/include/lldb/Expression/IRExecutionUnit.h
+++ b/lldb/include/lldb/Expression/IRExecutionUnit.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_IRExecutionUnit_h_
-#define liblldb_IRExecutionUnit_h_
+#ifndef LLDB_EXPRESSION_IREXECUTIONUNIT_H
+#define LLDB_EXPRESSION_IREXECUTIONUNIT_H
#include <atomic>
#include <memory>
@@ -71,7 +71,7 @@ public:
llvm::Module *GetModule() { return m_module; }
llvm::Function *GetFunction() {
- return ((m_module != nullptr) ? m_module->getFunction(m_name.AsCString())
+ return ((m_module != nullptr) ? m_module->getFunction(m_name.GetStringRef())
: nullptr);
}
@@ -406,4 +406,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_IRExecutionUnit_h_
+#endif // LLDB_EXPRESSION_IREXECUTIONUNIT_H
diff --git a/lldb/include/lldb/Expression/IRInterpreter.h b/lldb/include/lldb/Expression/IRInterpreter.h
index 6148093e718f..98ece967a923 100644
--- a/lldb/include/lldb/Expression/IRInterpreter.h
+++ b/lldb/include/lldb/Expression/IRInterpreter.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_IRInterpreter_h_
-#define liblldb_IRInterpreter_h_
+#ifndef LLDB_EXPRESSION_IRINTERPRETER_H
+#define LLDB_EXPRESSION_IRINTERPRETER_H
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/Stream.h"
@@ -22,7 +22,6 @@ class Module;
namespace lldb_private {
-class ClangExpressionDeclMap;
class IRMemoryMap;
}
diff --git a/lldb/include/lldb/Expression/IRMemoryMap.h b/lldb/include/lldb/Expression/IRMemoryMap.h
index d6a17a9848fb..abec5442793c 100644
--- a/lldb/include/lldb/Expression/IRMemoryMap.h
+++ b/lldb/include/lldb/Expression/IRMemoryMap.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_IRMemoryMap_h_
-#define lldb_IRMemoryMap_h_
+#ifndef LLDB_EXPRESSION_IRMEMORYMAP_H
+#define LLDB_EXPRESSION_IRMEMORYMAP_H
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/UserID.h"
@@ -107,7 +107,8 @@ private:
size_t size, uint32_t permissions, uint8_t alignment,
AllocationPolicy m_policy);
- DISALLOW_COPY_AND_ASSIGN(Allocation);
+ Allocation(const Allocation &) = delete;
+ const Allocation &operator=(const Allocation &) = delete;
};
static_assert(sizeof(Allocation) <=
diff --git a/lldb/include/lldb/Expression/LLVMUserExpression.h b/lldb/include/lldb/Expression/LLVMUserExpression.h
index 2679c01a4e00..244a28aec242 100644
--- a/lldb/include/lldb/Expression/LLVMUserExpression.h
+++ b/lldb/include/lldb/Expression/LLVMUserExpression.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_LLVMUserExpression_h
-#define liblldb_LLVMUserExpression_h
+#ifndef LLDB_EXPRESSION_LLVMUSEREXPRESSION_H
+#define LLDB_EXPRESSION_LLVMUSEREXPRESSION_H
#include <map>
#include <string>
@@ -71,8 +71,6 @@ public:
/// translation unit.
const char *Text() override { return m_transformed_text.c_str(); }
- lldb::ModuleSP GetJITModule() override;
-
protected:
lldb::ExpressionResults
DoExecute(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
diff --git a/lldb/include/lldb/Expression/Materializer.h b/lldb/include/lldb/Expression/Materializer.h
index 70f622e7850b..754e67c5dfa7 100644
--- a/lldb/include/lldb/Expression/Materializer.h
+++ b/lldb/include/lldb/Expression/Materializer.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Materializer_h
-#define liblldb_Materializer_h
+#ifndef LLDB_EXPRESSION_MATERIALIZER_H
+#define LLDB_EXPRESSION_MATERIALIZER_H
#include <memory>
#include <vector>
@@ -22,14 +22,12 @@ namespace lldb_private {
class Materializer {
public:
- Materializer();
+ Materializer() = default;
~Materializer();
class Dematerializer {
public:
- Dematerializer()
- : m_materializer(nullptr), m_map(nullptr),
- m_process_address(LLDB_INVALID_ADDRESS) {}
+ Dematerializer() = default;
~Dematerializer() { Wipe(); }
@@ -56,11 +54,11 @@ public:
}
}
- Materializer *m_materializer;
+ Materializer *m_materializer = nullptr;
lldb::ThreadWP m_thread_wp;
StackID m_stack_id;
- IRMemoryMap *m_map;
- lldb::addr_t m_process_address;
+ IRMemoryMap *m_map = nullptr;
+ lldb::addr_t m_process_address = LLDB_INVALID_ADDRESS;
};
typedef std::shared_ptr<Dematerializer> DematerializerSP;
@@ -128,10 +126,10 @@ private:
DematerializerWP m_dematerializer_wp;
EntityVector m_entities;
- uint32_t m_current_offset;
- uint32_t m_struct_alignment;
+ uint32_t m_current_offset = 0;
+ uint32_t m_struct_alignment = 8;
};
} // namespace lldb_private
-#endif // liblldb_Materializer_h
+#endif // LLDB_EXPRESSION_MATERIALIZER_H
diff --git a/lldb/include/lldb/Expression/REPL.h b/lldb/include/lldb/Expression/REPL.h
index 035ad63271e4..a0df53eb9b4c 100644
--- a/lldb/include/lldb/Expression/REPL.h
+++ b/lldb/include/lldb/Expression/REPL.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_REPL_h
-#define lldb_REPL_h
+#ifndef LLDB_EXPRESSION_REPL_H
+#define LLDB_EXPRESSION_REPL_H
#include <string>
@@ -130,8 +130,8 @@ protected:
lldb::ValueObjectSP &valobj_sp,
ExpressionVariable *var = nullptr) = 0;
- virtual int CompleteCode(const std::string &current_code,
- StringList &matches) = 0;
+ virtual void CompleteCode(const std::string &current_code,
+ CompletionRequest &request) = 0;
OptionGroupFormat m_format_options = OptionGroupFormat(lldb::eFormatDefault);
OptionGroupValueObjectDisplay m_varobj_options;
@@ -158,4 +158,4 @@ private:
} // namespace lldb_private
-#endif // lldb_REPL_h
+#endif // LLDB_EXPRESSION_REPL_H
diff --git a/lldb/include/lldb/Expression/UserExpression.h b/lldb/include/lldb/Expression/UserExpression.h
index 83122d8ba518..8236c417f73a 100644
--- a/lldb/include/lldb/Expression/UserExpression.h
+++ b/lldb/include/lldb/Expression/UserExpression.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_UserExpression_h_
-#define liblldb_UserExpression_h_
+#ifndef LLDB_EXPRESSION_USEREXPRESSION_H
+#define LLDB_EXPRESSION_USEREXPRESSION_H
#include <memory>
#include <string>
@@ -194,7 +194,7 @@ public:
/// Return the language that should be used when parsing. To use the
/// default, return eLanguageTypeUnknown.
- lldb::LanguageType Language() override { return m_language; }
+ lldb::LanguageType Language() const override { return m_language; }
/// Return the desired result type of the function, or eResultTypeAny if
/// indifferent.
@@ -213,8 +213,6 @@ public:
return lldb::ExpressionVariableSP();
}
- virtual lldb::ModuleSP GetJITModule() { return lldb::ModuleSP(); }
-
/// Evaluate one expression in the scratch context of the target passed in
/// the exe_ctx and return its result.
///
@@ -244,9 +242,6 @@ public:
/// If non-nullptr, the fixed expression is copied into the provided
/// string.
///
- /// \param[out] jit_module_sp_ptr
- /// If non-nullptr, used to persist the generated IR module.
- ///
/// \param[in] ctx_obj
/// If specified, then the expression will be evaluated in the context of
/// this object. It means that the context object's address will be
@@ -265,7 +260,6 @@ public:
llvm::StringRef expr_cstr, llvm::StringRef expr_prefix,
lldb::ValueObjectSP &result_valobj_sp, Status &error,
std::string *fixed_expression = nullptr,
- lldb::ModuleSP *jit_module_sp_ptr = nullptr,
ValueObject *ctx_obj = nullptr);
static const Status::ValueType kNoResult =
@@ -314,4 +308,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_UserExpression_h_
+#endif // LLDB_EXPRESSION_USEREXPRESSION_H
diff --git a/lldb/include/lldb/Expression/UtilityFunction.h b/lldb/include/lldb/Expression/UtilityFunction.h
index c3d185899b0f..5ebbc0ede1e3 100644
--- a/lldb/include/lldb/Expression/UtilityFunction.h
+++ b/lldb/include/lldb/Expression/UtilityFunction.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_UtilityFunction_h_
-#define liblldb_UtilityFunction_h_
+#ifndef LLDB_EXPRESSION_UTILITYFUNCTION_H
+#define LLDB_EXPRESSION_UTILITYFUNCTION_H
#include <memory>
#include <string>
@@ -118,4 +118,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_UtilityFunction_h_
+#endif // LLDB_EXPRESSION_UTILITYFUNCTION_H
diff --git a/lldb/include/lldb/Host/Config.h.cmake b/lldb/include/lldb/Host/Config.h.cmake
index e9065ed04caa..42f4ca1a26c6 100644
--- a/lldb/include/lldb/Host/Config.h.cmake
+++ b/lldb/include/lldb/Host/Config.h.cmake
@@ -46,6 +46,8 @@
#cmakedefine01 LLDB_ENABLE_PYTHON
+#cmakedefine01 LLDB_EMBED_PYTHON_HOME
+
#cmakedefine LLDB_PYTHON_HOME "${LLDB_PYTHON_HOME}"
#define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}"
diff --git a/lldb/include/lldb/Host/ConnectionFileDescriptor.h b/lldb/include/lldb/Host/ConnectionFileDescriptor.h
index 00444d011af3..ff6bcc4766ea 100644
--- a/lldb/include/lldb/Host/ConnectionFileDescriptor.h
+++ b/lldb/include/lldb/Host/ConnectionFileDescriptor.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Host_ConnectionFileDescriptor_h_
-#define liblldb_Host_ConnectionFileDescriptor_h_
+#ifndef LLDB_HOST_CONNECTIONFILEDESCRIPTOR_H
+#define LLDB_HOST_CONNECTIONFILEDESCRIPTOR_H
#include "lldb/Host/posix/ConnectionFileDescriptorPosix.h"
diff --git a/lldb/include/lldb/Host/Debug.h b/lldb/include/lldb/Host/Debug.h
index 036ce1ebccd5..402325c4c166 100644
--- a/lldb/include/lldb/Host/Debug.h
+++ b/lldb/include/lldb/Host/Debug.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Debug_h_
-#define liblldb_Debug_h_
+#ifndef LLDB_HOST_DEBUG_H
+#define LLDB_HOST_DEBUG_H
#include <vector>
@@ -148,4 +148,4 @@ struct ThreadStopInfo {
};
}
-#endif // liblldb_Debug_h_
+#endif // LLDB_HOST_DEBUG_H
diff --git a/lldb/include/lldb/Host/Editline.h b/lldb/include/lldb/Host/Editline.h
index db3d9e48cfbb..356e8f734732 100644
--- a/lldb/include/lldb/Host/Editline.h
+++ b/lldb/include/lldb/Host/Editline.h
@@ -19,17 +19,14 @@
// good amount of the text will
// disappear. It's still in the buffer, just invisible.
// b) The prompt printing logic for dealing with ANSI formatting characters is
-// broken, which is why we're
-// working around it here.
-// c) When resizing the terminal window, if the cursor moves between rows
-// libedit will get confused. d) The incremental search uses escape to cancel
-// input, so it's confused by
+// broken, which is why we're working around it here.
+// c) The incremental search uses escape to cancel input, so it's confused by
// ANSI sequences starting with escape.
-// e) Emoji support is fairly terrible, presumably it doesn't understand
+// d) Emoji support is fairly terrible, presumably it doesn't understand
// composed characters?
-#ifndef liblldb_Editline_h_
-#define liblldb_Editline_h_
+#ifndef LLDB_HOST_EDITLINE_H
+#define LLDB_HOST_EDITLINE_H
#if defined(__cplusplus)
#include "lldb/Host/Config.h"
@@ -50,6 +47,7 @@
#include <histedit.h>
#endif
+#include <csignal>
#include <mutex>
#include <string>
#include <vector>
@@ -171,9 +169,7 @@ public:
/// editing scenarios.
void SetContinuationPrompt(const char *continuation_prompt);
- /// Required to update the width of the terminal registered for I/O. It is
- /// critical that this
- /// be correct at all times.
+ /// Call when the terminal size changes
void TerminalSizeChanged();
/// Returns the prompt established by SetPrompt()
@@ -328,7 +324,8 @@ private:
bool CompleteCharacter(char ch, EditLineGetCharType &out);
-private:
+ void ApplyTerminalSizeChange();
+
#if LLDB_EDITLINE_USE_WCHAR
std::wstring_convert<std::codecvt_utf8<wchar_t>> m_utf8conv;
#endif
@@ -350,6 +347,7 @@ private:
std::string m_set_continuation_prompt;
std::string m_current_prompt;
bool m_needs_prompt_repaint = false;
+ volatile std::sig_atomic_t m_terminal_size_has_changed = 0;
std::string m_editor_name;
FILE *m_input_file;
FILE *m_output_file;
@@ -368,4 +366,4 @@ private:
}
#endif // #if defined(__cplusplus)
-#endif // liblldb_Editline_h_
+#endif // LLDB_HOST_EDITLINE_H
diff --git a/lldb/include/lldb/Host/File.h b/lldb/include/lldb/Host/File.h
index 9beb20556dcd..d205a3fe6911 100644
--- a/lldb/include/lldb/Host/File.h
+++ b/lldb/include/lldb/Host/File.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_File_h_
-#define liblldb_File_h_
+#ifndef LLDB_HOST_FILE_H
+#define LLDB_HOST_FILE_H
#include "lldb/Host/PosixApi.h"
#include "lldb/Utility/IOObject.h"
@@ -367,7 +367,8 @@ protected:
void CalculateInteractiveAndTerminal();
private:
- DISALLOW_COPY_AND_ASSIGN(File);
+ File(const File &) = delete;
+ const File &operator=(const File &) = delete;
};
class NativeFile : public File {
@@ -428,9 +429,10 @@ protected:
std::mutex offset_access_mutex;
private:
- DISALLOW_COPY_AND_ASSIGN(NativeFile);
+ NativeFile(const NativeFile &) = delete;
+ const NativeFile &operator=(const NativeFile &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_File_h_
+#endif // LLDB_HOST_FILE_H
diff --git a/lldb/include/lldb/Host/FileCache.h b/lldb/include/lldb/Host/FileCache.h
index c76916701ebb..df0d9a88c6df 100644
--- a/lldb/include/lldb/Host/FileCache.h
+++ b/lldb/include/lldb/Host/FileCache.h
@@ -5,8 +5,8 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Host_FileCache_h
-#define liblldb_Host_FileCache_h
+#ifndef LLDB_HOST_FILECACHE_H
+#define LLDB_HOST_FILECACHE_H
#include <map>
#include <stdint.h>
diff --git a/lldb/include/lldb/Host/FileSystem.h b/lldb/include/lldb/Host/FileSystem.h
index 528c43519a32..8dcff3402592 100644
--- a/lldb/include/lldb/Host/FileSystem.h
+++ b/lldb/include/lldb/Host/FileSystem.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Host_FileSystem_h
-#define liblldb_Host_FileSystem_h
+#ifndef LLDB_HOST_FILESYSTEM_H
+#define LLDB_HOST_FILESYSTEM_H
#include "lldb/Host/File.h"
#include "lldb/Utility/DataBufferLLVM.h"
@@ -186,6 +186,9 @@ public:
return m_fs;
}
+ void Collect(const FileSpec &file_spec);
+ void Collect(const llvm::Twine &file);
+
private:
static llvm::Optional<FileSystem> &InstanceImpl();
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> m_fs;
diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h
index 884c5cf63213..f19cb85d2329 100644
--- a/lldb/include/lldb/Host/Host.h
+++ b/lldb/include/lldb/Host/Host.h
@@ -27,8 +27,8 @@ namespace lldb_private {
class FileAction;
class ProcessLaunchInfo;
class ProcessInstanceInfo;
-class ProcessInstanceInfoList;
class ProcessInstanceInfoMatch;
+typedef std::vector<ProcessInstanceInfo> ProcessInstanceInfoList;
// Exit Type for inferior processes
struct WaitStatus {
@@ -232,6 +232,10 @@ public:
static std::unique_ptr<Connection>
CreateDefaultConnection(llvm::StringRef url);
+
+protected:
+ static uint32_t FindProcessesImpl(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &proc_infos);
};
} // namespace lldb_private
diff --git a/lldb/include/lldb/Host/HostGetOpt.h b/lldb/include/lldb/Host/HostGetOpt.h
index dedeb2e2fcc3..746e03e1bd1e 100644
--- a/lldb/include/lldb/Host/HostGetOpt.h
+++ b/lldb/include/lldb/Host/HostGetOpt.h
@@ -5,7 +5,9 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#pragma once
+
+#ifndef LLDB_HOST_HOSTGETOPT_H
+#define LLDB_HOST_HOSTGETOPT_H
#if !defined(_MSC_VER) && !defined(__NetBSD__)
@@ -21,3 +23,5 @@
#include <lldb/Host/common/GetOptInc.h>
#endif
+
+#endif // LLDB_HOST_HOSTGETOPT_H
diff --git a/lldb/include/lldb/Host/HostInfo.h b/lldb/include/lldb/Host/HostInfo.h
index 196127d40763..b7010d69d88e 100644
--- a/lldb/include/lldb/Host/HostInfo.h
+++ b/lldb/include/lldb/Host/HostInfo.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Host_HostInfo_h_
-#define lldb_Host_HostInfo_h_
+#ifndef LLDB_HOST_HOSTINFO_H
+#define LLDB_HOST_HOSTINFO_H
/// \class HostInfo HostInfo.h "lldb/Host/HostInfo.h"
/// A class that provides host computer information.
@@ -35,7 +35,7 @@
#if defined(_WIN32)
#include "lldb/Host/windows/HostInfoWindows.h"
#define HOST_INFO_TYPE HostInfoWindows
-#elif defined(__linux__)
+#elif defined(__linux__) || defined(__EMSCRIPTEN__)
#if defined(__ANDROID__)
#include "lldb/Host/android/HostInfoAndroid.h"
#define HOST_INFO_TYPE HostInfoAndroid
diff --git a/lldb/include/lldb/Host/HostInfoBase.h b/lldb/include/lldb/Host/HostInfoBase.h
index c59050cb34e9..70682c9b685e 100644
--- a/lldb/include/lldb/Host/HostInfoBase.h
+++ b/lldb/include/lldb/Host/HostInfoBase.h
@@ -6,12 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Host_HostInfoBase_h_
-#define lldb_Host_HostInfoBase_h_
+#ifndef LLDB_HOST_HOSTINFOBASE_H
+#define LLDB_HOST_HOSTINFOBASE_H
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/UserIDResolver.h"
+#include "lldb/Utility/XcodeSDK.h"
#include "lldb/lldb-enumerations.h"
#include "llvm/ADT/StringRef.h"
@@ -91,6 +92,12 @@ public:
static bool ComputePathRelativeToLibrary(FileSpec &file_spec,
llvm::StringRef dir);
+ static FileSpec GetXcodeContentsDirectory() { return {}; }
+ static FileSpec GetXcodeDeveloperDirectory() { return {}; }
+
+ /// Return the directory containing a specific Xcode SDK.
+ static llvm::StringRef GetXcodeSDKPath(XcodeSDK sdk) { return {}; }
+
protected:
static bool ComputeSharedLibraryDirectory(FileSpec &file_spec);
static bool ComputeSupportExeDirectory(FileSpec &file_spec);
diff --git a/lldb/include/lldb/Host/HostNativeProcess.h b/lldb/include/lldb/Host/HostNativeProcess.h
index c86a2aef38fc..d1e577dc3289 100644
--- a/lldb/include/lldb/Host/HostNativeProcess.h
+++ b/lldb/include/lldb/Host/HostNativeProcess.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Host_HostNativeProcess_h_
-#define lldb_Host_HostNativeProcess_h_
+#ifndef LLDB_HOST_HOSTNATIVEPROCESS_H
+#define LLDB_HOST_HOSTNATIVEPROCESS_H
#if defined(_WIN32)
#include "lldb/Host/windows/HostProcessWindows.h"
diff --git a/lldb/include/lldb/Host/HostNativeProcessBase.h b/lldb/include/lldb/Host/HostNativeProcessBase.h
index aaa517d53217..642c63443c20 100644
--- a/lldb/include/lldb/Host/HostNativeProcessBase.h
+++ b/lldb/include/lldb/Host/HostNativeProcessBase.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Host_HostNativeProcessBase_h_
-#define lldb_Host_HostNativeProcessBase_h_
+#ifndef LLDB_HOST_HOSTNATIVEPROCESSBASE_H
+#define LLDB_HOST_HOSTNATIVEPROCESSBASE_H
#include "lldb/Host/HostProcess.h"
#include "lldb/Utility/Status.h"
@@ -19,7 +19,9 @@ namespace lldb_private {
class HostThread;
class HostNativeProcessBase {
- DISALLOW_COPY_AND_ASSIGN(HostNativeProcessBase);
+ HostNativeProcessBase(const HostNativeProcessBase &) = delete;
+ const HostNativeProcessBase &
+ operator=(const HostNativeProcessBase &) = delete;
public:
HostNativeProcessBase() : m_process(LLDB_INVALID_PROCESS) {}
diff --git a/lldb/include/lldb/Host/HostNativeThread.h b/lldb/include/lldb/Host/HostNativeThread.h
index 8bf65849d880..cef08f0539a9 100644
--- a/lldb/include/lldb/Host/HostNativeThread.h
+++ b/lldb/include/lldb/Host/HostNativeThread.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Host_HostNativeThread_h_
-#define lldb_Host_HostNativeThread_h_
+#ifndef LLDB_HOST_HOSTNATIVETHREAD_H
+#define LLDB_HOST_HOSTNATIVETHREAD_H
#include "HostNativeThreadForward.h"
diff --git a/lldb/include/lldb/Host/HostNativeThreadBase.h b/lldb/include/lldb/Host/HostNativeThreadBase.h
index a196f0bc82ca..0dfd363cc8fb 100644
--- a/lldb/include/lldb/Host/HostNativeThreadBase.h
+++ b/lldb/include/lldb/Host/HostNativeThreadBase.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Host_HostNativeThreadBase_h_
-#define lldb_Host_HostNativeThreadBase_h_
+#ifndef LLDB_HOST_HOSTNATIVETHREADBASE_H
+#define LLDB_HOST_HOSTNATIVETHREADBASE_H
#include "lldb/Utility/Status.h"
#include "lldb/lldb-defines.h"
@@ -23,7 +23,8 @@ namespace lldb_private {
class HostNativeThreadBase {
friend class ThreadLauncher;
- DISALLOW_COPY_AND_ASSIGN(HostNativeThreadBase);
+ HostNativeThreadBase(const HostNativeThreadBase &) = delete;
+ const HostNativeThreadBase &operator=(const HostNativeThreadBase &) = delete;
public:
HostNativeThreadBase();
diff --git a/lldb/include/lldb/Host/HostNativeThreadForward.h b/lldb/include/lldb/Host/HostNativeThreadForward.h
index 261d3c7a836e..35b6e2f09e05 100644
--- a/lldb/include/lldb/Host/HostNativeThreadForward.h
+++ b/lldb/include/lldb/Host/HostNativeThreadForward.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Host_HostNativeThreadForward_h_
-#define lldb_Host_HostNativeThreadForward_h_
+#ifndef LLDB_HOST_HOSTNATIVETHREADFORWARD_H
+#define LLDB_HOST_HOSTNATIVETHREADFORWARD_H
namespace lldb_private {
#if defined(_WIN32)
diff --git a/lldb/include/lldb/Host/HostProcess.h b/lldb/include/lldb/Host/HostProcess.h
index fcea52a284d9..0b7c30364223 100644
--- a/lldb/include/lldb/Host/HostProcess.h
+++ b/lldb/include/lldb/Host/HostProcess.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Host_HostProcess_h_
-#define lldb_Host_HostProcess_h_
+#ifndef LLDB_HOST_HOSTPROCESS_H
+#define LLDB_HOST_HOSTPROCESS_H
#include "lldb/Host/Host.h"
#include "lldb/lldb-types.h"
diff --git a/lldb/include/lldb/Host/HostThread.h b/lldb/include/lldb/Host/HostThread.h
index 7bf2a1dc2db9..d3477e115e2d 100644
--- a/lldb/include/lldb/Host/HostThread.h
+++ b/lldb/include/lldb/Host/HostThread.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Host_HostThread_h_
-#define lldb_Host_HostThread_h_
+#ifndef LLDB_HOST_HOSTTHREAD_H
+#define LLDB_HOST_HOSTTHREAD_H
#include "lldb/Host/HostNativeThreadForward.h"
#include "lldb/Utility/Status.h"
diff --git a/lldb/include/lldb/Host/LZMA.h b/lldb/include/lldb/Host/LZMA.h
index c741cc3bbde1..5314dab53e44 100644
--- a/lldb/include/lldb/Host/LZMA.h
+++ b/lldb/include/lldb/Host/LZMA.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Host_LZMA_h_
-#define liblldb_Host_LZMA_h_
+#ifndef LLDB_HOST_LZMA_H
+#define LLDB_HOST_LZMA_H
#include "llvm/ADT/ArrayRef.h"
@@ -31,4 +31,4 @@ llvm::Error uncompress(llvm::ArrayRef<uint8_t> InputBuffer,
} // End of namespace lldb_private
-#endif // liblldb_Host_LZMA_h_
+#endif // LLDB_HOST_LZMA_H
diff --git a/lldb/include/lldb/Host/LockFile.h b/lldb/include/lldb/Host/LockFile.h
index 2a1cd3dbb8f7..ff09eb475f78 100644
--- a/lldb/include/lldb/Host/LockFile.h
+++ b/lldb/include/lldb/Host/LockFile.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Host_LockFile_h_
-#define liblldb_Host_LockFile_h_
+#ifndef LLDB_HOST_LOCKFILE_H
+#define LLDB_HOST_LOCKFILE_H
#if defined(_WIN32)
#include "lldb/Host/windows/LockFileWindows.h"
@@ -21,4 +21,4 @@ typedef LockFilePosix LockFile;
}
#endif
-#endif // liblldb_Host_LockFile_h_
+#endif // LLDB_HOST_LOCKFILE_H
diff --git a/lldb/include/lldb/Host/LockFileBase.h b/lldb/include/lldb/Host/LockFileBase.h
index be9e258c5c2d..6a5fd424869c 100644
--- a/lldb/include/lldb/Host/LockFileBase.h
+++ b/lldb/include/lldb/Host/LockFileBase.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Host_LockFileBase_h_
-#define liblldb_Host_LockFileBase_h_
+#ifndef LLDB_HOST_LOCKFILEBASE_H
+#define LLDB_HOST_LOCKFILEBASE_H
#include "lldb/Utility/Status.h"
diff --git a/lldb/include/lldb/Host/MainLoop.h b/lldb/include/lldb/Host/MainLoop.h
index d59aa28ccb0e..9ca5040b60a8 100644
--- a/lldb/include/lldb/Host/MainLoop.h
+++ b/lldb/include/lldb/Host/MainLoop.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Host_MainLoop_h_
-#define lldb_Host_MainLoop_h_
+#ifndef LLDB_HOST_MAINLOOP_H
+#define LLDB_HOST_MAINLOOP_H
#include "lldb/Host/Config.h"
#include "lldb/Host/MainLoopBase.h"
@@ -86,7 +86,8 @@ private:
int m_signo;
friend class MainLoop;
- DISALLOW_COPY_AND_ASSIGN(SignalHandle);
+ SignalHandle(const SignalHandle &) = delete;
+ const SignalHandle &operator=(const SignalHandle &) = delete;
};
struct SignalInfo {
@@ -108,4 +109,4 @@ private:
} // namespace lldb_private
-#endif // lldb_Host_MainLoop_h_
+#endif // LLDB_HOST_MAINLOOP_H
diff --git a/lldb/include/lldb/Host/MainLoopBase.h b/lldb/include/lldb/Host/MainLoopBase.h
index 3fee2b2c09d8..fa8cc77a94ba 100644
--- a/lldb/include/lldb/Host/MainLoopBase.h
+++ b/lldb/include/lldb/Host/MainLoopBase.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Host_posix_MainLoopBase_h_
-#define lldb_Host_posix_MainLoopBase_h_
+#ifndef LLDB_HOST_MAINLOOPBASE_H
+#define LLDB_HOST_MAINLOOPBASE_H
#include "lldb/Utility/IOObject.h"
#include "lldb/Utility/Status.h"
@@ -75,13 +75,14 @@ private:
IOObject::WaitableHandle m_handle;
friend class MainLoopBase;
- DISALLOW_COPY_AND_ASSIGN(ReadHandle);
+ ReadHandle(const ReadHandle &) = delete;
+ const ReadHandle &operator=(const ReadHandle &) = delete;
};
-private:
- DISALLOW_COPY_AND_ASSIGN(MainLoopBase);
+ MainLoopBase(const MainLoopBase &) = delete;
+ const MainLoopBase &operator=(const MainLoopBase &) = delete;
};
} // namespace lldb_private
-#endif // lldb_Host_posix_MainLoopBase_h_
+#endif // LLDB_HOST_MAINLOOPBASE_H
diff --git a/lldb/include/lldb/Host/MonitoringProcessLauncher.h b/lldb/include/lldb/Host/MonitoringProcessLauncher.h
index 59111a04fc98..e2fce42a228e 100644
--- a/lldb/include/lldb/Host/MonitoringProcessLauncher.h
+++ b/lldb/include/lldb/Host/MonitoringProcessLauncher.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Host_MonitoringProcessLauncher_h_
-#define lldb_Host_MonitoringProcessLauncher_h_
+#ifndef LLDB_HOST_MONITORINGPROCESSLAUNCHER_H
+#define LLDB_HOST_MONITORINGPROCESSLAUNCHER_H
#include <memory>
#include "lldb/Host/ProcessLauncher.h"
@@ -31,4 +31,4 @@ private:
} // namespace lldb_private
-#endif // lldb_Host_MonitoringProcessLauncher_h_
+#endif // LLDB_HOST_MONITORINGPROCESSLAUNCHER_H
diff --git a/lldb/include/lldb/Host/OptionParser.h b/lldb/include/lldb/Host/OptionParser.h
index b03eeb74ec4e..7c84c115ee05 100644
--- a/lldb/include/lldb/Host/OptionParser.h
+++ b/lldb/include/lldb/Host/OptionParser.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionParser_h_
-#define liblldb_OptionParser_h_
+#ifndef LLDB_HOST_OPTIONPARSER_H
+#define LLDB_HOST_OPTIONPARSER_H
#include <mutex>
#include <string>
@@ -51,4 +51,4 @@ public:
};
}
-#endif // liblldb_OptionParser_h_
+#endif // LLDB_HOST_OPTIONPARSER_H
diff --git a/lldb/include/lldb/Host/Pipe.h b/lldb/include/lldb/Host/Pipe.h
index ea75342e5427..06daf1f6dd90 100644
--- a/lldb/include/lldb/Host/Pipe.h
+++ b/lldb/include/lldb/Host/Pipe.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Host_Pipe_h_
-#define liblldb_Host_Pipe_h_
+#ifndef LLDB_HOST_PIPE_H
+#define LLDB_HOST_PIPE_H
#if defined(_WIN32)
#include "lldb/Host/windows/PipeWindows.h"
@@ -21,4 +21,4 @@ typedef PipePosix Pipe;
}
#endif
-#endif // liblldb_Host_Pipe_h_
+#endif // LLDB_HOST_PIPE_H
diff --git a/lldb/include/lldb/Host/PipeBase.h b/lldb/include/lldb/Host/PipeBase.h
index 1aa4db339b29..48c19b899cef 100644
--- a/lldb/include/lldb/Host/PipeBase.h
+++ b/lldb/include/lldb/Host/PipeBase.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Host_PipeBase_h_
-#define liblldb_Host_PipeBase_h_
+#ifndef LLDB_HOST_PIPEBASE_H
+#define LLDB_HOST_PIPEBASE_H
#include <chrono>
#include <string>
diff --git a/lldb/include/lldb/Host/PosixApi.h b/lldb/include/lldb/Host/PosixApi.h
index 04ca3a84983b..4cbbd628157a 100644
--- a/lldb/include/lldb/Host/PosixApi.h
+++ b/lldb/include/lldb/Host/PosixApi.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Host_PosixApi_h
-#define liblldb_Host_PosixApi_h
+#ifndef LLDB_HOST_POSIXAPI_H
+#define LLDB_HOST_POSIXAPI_H
// This file defines platform specific functions, macros, and types necessary
// to provide a minimum level of compatibility across all platforms to rely on
diff --git a/lldb/include/lldb/Host/ProcessLaunchInfo.h b/lldb/include/lldb/Host/ProcessLaunchInfo.h
index d068aa636bc7..e83d8396e9f2 100644
--- a/lldb/include/lldb/Host/ProcessLaunchInfo.h
+++ b/lldb/include/lldb/Host/ProcessLaunchInfo.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ProcessLaunch_Info_h
-#define liblldb_ProcessLaunch_Info_h
+#ifndef LLDB_HOST_PROCESSLAUNCHINFO_H
+#define LLDB_HOST_PROCESSLAUNCHINFO_H
// C++ Headers
#include <string>
@@ -165,4 +165,4 @@ protected:
};
}
-#endif // liblldb_ProcessLaunch_Info_h
+#endif // LLDB_HOST_PROCESSLAUNCHINFO_H
diff --git a/lldb/include/lldb/Host/ProcessLauncher.h b/lldb/include/lldb/Host/ProcessLauncher.h
index a5b6a6c76bba..9467b2c009b7 100644
--- a/lldb/include/lldb/Host/ProcessLauncher.h
+++ b/lldb/include/lldb/Host/ProcessLauncher.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Host_ProcessLauncher_h_
-#define lldb_Host_ProcessLauncher_h_
+#ifndef LLDB_HOST_PROCESSLAUNCHER_H
+#define LLDB_HOST_PROCESSLAUNCHER_H
namespace lldb_private {
diff --git a/lldb/include/lldb/Host/ProcessRunLock.h b/lldb/include/lldb/Host/ProcessRunLock.h
index 4927fbbf7821..43463d144de3 100644
--- a/lldb/include/lldb/Host/ProcessRunLock.h
+++ b/lldb/include/lldb/Host/ProcessRunLock.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ProcessRunLock_h_
-#define liblldb_ProcessRunLock_h_
+#ifndef LLDB_HOST_PROCESSRUNLOCK_H
+#define LLDB_HOST_PROCESSRUNLOCK_H
#include <stdint.h>
#include <time.h>
@@ -67,7 +67,8 @@ public:
ProcessRunLock *m_lock;
private:
- DISALLOW_COPY_AND_ASSIGN(ProcessRunLocker);
+ ProcessRunLocker(const ProcessRunLocker &) = delete;
+ const ProcessRunLocker &operator=(const ProcessRunLocker &) = delete;
};
protected:
@@ -75,9 +76,10 @@ protected:
bool m_running;
private:
- DISALLOW_COPY_AND_ASSIGN(ProcessRunLock);
+ ProcessRunLock(const ProcessRunLock &) = delete;
+ const ProcessRunLock &operator=(const ProcessRunLock &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ProcessRunLock_h_
+#endif // LLDB_HOST_PROCESSRUNLOCK_H
diff --git a/lldb/include/lldb/Host/PseudoTerminal.h b/lldb/include/lldb/Host/PseudoTerminal.h
index 18679b6fcdd9..8a5a233e7748 100644
--- a/lldb/include/lldb/Host/PseudoTerminal.h
+++ b/lldb/include/lldb/Host/PseudoTerminal.h
@@ -29,36 +29,37 @@ public:
/// Default constructor
///
- /// Constructs this object with invalid master and slave file descriptors.
+ /// Constructs this object with invalid primary and secondary file
+ /// descriptors.
PseudoTerminal();
/// Destructor
///
- /// The destructor will close the master and slave file descriptors if they
- /// are valid and ownership has not been released using one of: @li
- /// PseudoTerminal::ReleaseMasterFileDescriptor() @li
+ /// The destructor will close the primary and secondary file descriptors if
+ /// they are valid and ownership has not been released using one of: @li
+ /// PseudoTerminal::ReleasePrimaryFileDescriptor() @li
/// PseudoTerminal::ReleaseSaveFileDescriptor()
~PseudoTerminal();
- /// Close the master file descriptor if it is valid.
- void CloseMasterFileDescriptor();
+ /// Close the primary file descriptor if it is valid.
+ void ClosePrimaryFileDescriptor();
- /// Close the slave file descriptor if it is valid.
- void CloseSlaveFileDescriptor();
+ /// Close the secondary file descriptor if it is valid.
+ void CloseSecondaryFileDescriptor();
/// Fork a child process that uses pseudo terminals for its stdio.
///
/// In the parent process, a call to this function results in a pid being
- /// returned. If the pid is valid, the master file descriptor can be used
+ /// returned. If the pid is valid, the primary file descriptor can be used
/// for read/write access to stdio of the child process.
///
/// In the child process the stdin/stdout/stderr will already be routed to
- /// the slave pseudo terminal and the master file descriptor will be closed
- /// as it is no longer needed by the child process.
+ /// the secondary pseudo terminal and the primary file descriptor will be
+ /// closed as it is no longer needed by the child process.
///
- /// This class will close the file descriptors for the master/slave when the
- /// destructor is called. The file handles can be released using either: @li
- /// PseudoTerminal::ReleaseMasterFileDescriptor() @li
+ /// This class will close the file descriptors for the primary/secondary when
+ /// the destructor is called. The file handles can be released using either:
+ /// @li PseudoTerminal::ReleasePrimaryFileDescriptor() @li
/// PseudoTerminal::ReleaseSaveFileDescriptor()
///
/// \param[out] error_str
@@ -71,37 +72,37 @@ public:
/// \b Child process: zero.
lldb::pid_t Fork(char *error_str, size_t error_len);
- /// The master file descriptor accessor.
+ /// The primary file descriptor accessor.
///
- /// This object retains ownership of the master file descriptor when this
+ /// This object retains ownership of the primary file descriptor when this
/// accessor is used. Users can call the member function
- /// PseudoTerminal::ReleaseMasterFileDescriptor() if this object should
- /// release ownership of the slave file descriptor.
+ /// PseudoTerminal::ReleasePrimaryFileDescriptor() if this object should
+ /// release ownership of the secondary file descriptor.
///
/// \return
- /// The master file descriptor, or PseudoTerminal::invalid_fd
- /// if the master file descriptor is not currently valid.
+ /// The primary file descriptor, or PseudoTerminal::invalid_fd
+ /// if the primary file descriptor is not currently valid.
///
- /// \see PseudoTerminal::ReleaseMasterFileDescriptor()
- int GetMasterFileDescriptor() const;
+ /// \see PseudoTerminal::ReleasePrimaryFileDescriptor()
+ int GetPrimaryFileDescriptor() const;
- /// The slave file descriptor accessor.
+ /// The secondary file descriptor accessor.
///
- /// This object retains ownership of the slave file descriptor when this
+ /// This object retains ownership of the secondary file descriptor when this
/// accessor is used. Users can call the member function
- /// PseudoTerminal::ReleaseSlaveFileDescriptor() if this object should
- /// release ownership of the slave file descriptor.
+ /// PseudoTerminal::ReleaseSecondaryFileDescriptor() if this object should
+ /// release ownership of the secondary file descriptor.
///
/// \return
- /// The slave file descriptor, or PseudoTerminal::invalid_fd
- /// if the slave file descriptor is not currently valid.
+ /// The secondary file descriptor, or PseudoTerminal::invalid_fd
+ /// if the secondary file descriptor is not currently valid.
///
- /// \see PseudoTerminal::ReleaseSlaveFileDescriptor()
- int GetSlaveFileDescriptor() const;
+ /// \see PseudoTerminal::ReleaseSecondaryFileDescriptor()
+ int GetSecondaryFileDescriptor() const;
- /// Get the name of the slave pseudo terminal.
+ /// Get the name of the secondary pseudo terminal.
///
- /// A master pseudo terminal should already be valid prior to
+ /// A primary pseudo terminal should already be valid prior to
/// calling this function.
///
/// \param[out] error_str
@@ -109,27 +110,27 @@ public:
/// occur. This can be NULL if no error status is desired.
///
/// \return
- /// The name of the slave pseudo terminal as a NULL terminated
+ /// The name of the secondary pseudo terminal as a NULL terminated
/// C. This string that comes from static memory, so a copy of
/// the string should be made as subsequent calls can change
/// this value. NULL is returned if this object doesn't have
- /// a valid master pseudo terminal opened or if the call to
+ /// a valid primary pseudo terminal opened or if the call to
/// \c ptsname() fails.
///
- /// \see PseudoTerminal::OpenFirstAvailableMaster()
- const char *GetSlaveName(char *error_str, size_t error_len) const;
+ /// \see PseudoTerminal::OpenFirstAvailablePrimary()
+ const char *GetSecondaryName(char *error_str, size_t error_len) const;
/// Open the first available pseudo terminal.
///
/// Opens the first available pseudo terminal with \a oflag as the
- /// permissions. The opened master file descriptor is stored in this object
+ /// permissions. The opened primary file descriptor is stored in this object
/// and can be accessed by calling the
- /// PseudoTerminal::GetMasterFileDescriptor() accessor. Clients can call the
- /// PseudoTerminal::ReleaseMasterFileDescriptor() accessor function if they
- /// wish to use the master file descriptor beyond the lifespan of this
+ /// PseudoTerminal::GetPrimaryFileDescriptor() accessor. Clients can call the
+ /// PseudoTerminal::ReleasePrimaryFileDescriptor() accessor function if they
+ /// wish to use the primary file descriptor beyond the lifespan of this
/// object.
///
- /// If this object still has a valid master file descriptor when its
+ /// If this object still has a valid primary file descriptor when its
/// destructor is called, it will close it.
///
/// \param[in] oflag
@@ -141,25 +142,25 @@ public:
/// occur. This can be NULL if no error status is desired.
///
/// \return
- /// \b true when the master files descriptor is
+ /// \b true when the primary files descriptor is
/// successfully opened.
/// \b false if anything goes wrong.
///
- /// \see PseudoTerminal::GetMasterFileDescriptor() @see
- /// PseudoTerminal::ReleaseMasterFileDescriptor()
- bool OpenFirstAvailableMaster(int oflag, char *error_str, size_t error_len);
+ /// \see PseudoTerminal::GetPrimaryFileDescriptor() @see
+ /// PseudoTerminal::ReleasePrimaryFileDescriptor()
+ bool OpenFirstAvailablePrimary(int oflag, char *error_str, size_t error_len);
- /// Open the slave for the current master pseudo terminal.
+ /// Open the secondary for the current primary pseudo terminal.
///
- /// A master pseudo terminal should already be valid prior to
- /// calling this function. The opened slave file descriptor is stored in
+ /// A primary pseudo terminal should already be valid prior to
+ /// calling this function. The opened secondary file descriptor is stored in
/// this object and can be accessed by calling the
- /// PseudoTerminal::GetSlaveFileDescriptor() accessor. Clients can call the
- /// PseudoTerminal::ReleaseSlaveFileDescriptor() accessor function if they
- /// wish to use the slave file descriptor beyond the lifespan of this
+ /// PseudoTerminal::GetSecondaryFileDescriptor() accessor. Clients can call
+ /// the PseudoTerminal::ReleaseSecondaryFileDescriptor() accessor function if
+ /// they wish to use the secondary file descriptor beyond the lifespan of this
/// object.
///
- /// If this object still has a valid slave file descriptor when its
+ /// If this object still has a valid secondary file descriptor when its
/// destructor is called, it will close it.
///
/// \param[in] oflag
@@ -170,48 +171,49 @@ public:
/// occur. This can be NULL if no error status is desired.
///
/// \return
- /// \b true when the master files descriptor is
+ /// \b true when the primary files descriptor is
/// successfully opened.
/// \b false if anything goes wrong.
///
- /// \see PseudoTerminal::OpenFirstAvailableMaster() @see
- /// PseudoTerminal::GetSlaveFileDescriptor() @see
- /// PseudoTerminal::ReleaseSlaveFileDescriptor()
- bool OpenSlave(int oflag, char *error_str, size_t error_len);
+ /// \see PseudoTerminal::OpenFirstAvailablePrimary() @see
+ /// PseudoTerminal::GetSecondaryFileDescriptor() @see
+ /// PseudoTerminal::ReleaseSecondaryFileDescriptor()
+ bool OpenSecondary(int oflag, char *error_str, size_t error_len);
- /// Release the master file descriptor.
+ /// Release the primary file descriptor.
///
- /// Releases ownership of the master pseudo terminal file descriptor without
- /// closing it. The destructor for this class will close the master file
+ /// Releases ownership of the primary pseudo terminal file descriptor without
+ /// closing it. The destructor for this class will close the primary file
/// descriptor if the ownership isn't released using this call and the
- /// master file descriptor has been opened.
+ /// primary file descriptor has been opened.
///
/// \return
- /// The master file descriptor, or PseudoTerminal::invalid_fd
+ /// The primary file descriptor, or PseudoTerminal::invalid_fd
/// if the mast file descriptor is not currently valid.
- int ReleaseMasterFileDescriptor();
+ int ReleasePrimaryFileDescriptor();
- /// Release the slave file descriptor.
+ /// Release the secondary file descriptor.
///
- /// Release ownership of the slave pseudo terminal file descriptor without
- /// closing it. The destructor for this class will close the slave file
- /// descriptor if the ownership isn't released using this call and the slave
- /// file descriptor has been opened.
+ /// Release ownership of the secondary pseudo terminal file descriptor without
+ /// closing it. The destructor for this class will close the secondary file
+ /// descriptor if the ownership isn't released using this call and the
+ /// secondary file descriptor has been opened.
///
/// \return
- /// The slave file descriptor, or PseudoTerminal::invalid_fd
- /// if the slave file descriptor is not currently valid.
- int ReleaseSlaveFileDescriptor();
+ /// The secondary file descriptor, or PseudoTerminal::invalid_fd
+ /// if the secondary file descriptor is not currently valid.
+ int ReleaseSecondaryFileDescriptor();
protected:
// Member variables
- int m_master_fd; ///< The file descriptor for the master.
- int m_slave_fd; ///< The file descriptor for the slave.
+ int m_primary_fd; ///< The file descriptor for the primary.
+ int m_secondary_fd; ///< The file descriptor for the secondary.
private:
- DISALLOW_COPY_AND_ASSIGN(PseudoTerminal);
+ PseudoTerminal(const PseudoTerminal &) = delete;
+ const PseudoTerminal &operator=(const PseudoTerminal &) = delete;
};
} // namespace lldb_private
-#endif // #ifndef liblldb_PseudoTerminal_h_
+#endif // LLDB_HOST_PSEUDOTERMINAL_H
diff --git a/lldb/include/lldb/Host/SafeMachO.h b/lldb/include/lldb/Host/SafeMachO.h
index ec9887ececd5..d7c376d23a4a 100644
--- a/lldb/include/lldb/Host/SafeMachO.h
+++ b/lldb/include/lldb/Host/SafeMachO.h
@@ -5,8 +5,8 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_SafeMachO_h_
-#define liblldb_SafeMachO_h_
+#ifndef LLDB_HOST_SAFEMACHO_H
+#define LLDB_HOST_SAFEMACHO_H
// This header file is required to work around collisions between the defines
// in mach/machine.h, and enum members of the same name in llvm's MachO.h. If
@@ -112,4 +112,4 @@
#include "llvm/BinaryFormat/MachO.h"
-#endif // liblldb_SafeMachO_h_
+#endif // LLDB_HOST_SAFEMACHO_H
diff --git a/lldb/include/lldb/Host/Socket.h b/lldb/include/lldb/Host/Socket.h
index c6df5634e24e..36db0ec63e9d 100644
--- a/lldb/include/lldb/Host/Socket.h
+++ b/lldb/include/lldb/Host/Socket.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Host_Socket_h_
-#define liblldb_Host_Socket_h_
+#ifndef LLDB_HOST_SOCKET_H
+#define LLDB_HOST_SOCKET_H
#include <memory>
#include <string>
@@ -36,6 +36,8 @@ typedef SOCKET NativeSocket;
#else
typedef int NativeSocket;
#endif
+class TCPSocket;
+class UDPSocket;
class Socket : public IOObject {
public:
@@ -64,13 +66,16 @@ public:
// Initialize a Tcp Socket object in listening mode. listen and accept are
// implemented separately because the caller may wish to manipulate or query
// the socket after it is initialized, but before entering a blocking accept.
- static Status TcpListen(llvm::StringRef host_and_port,
- bool child_processes_inherit, Socket *&socket,
- Predicate<uint16_t> *predicate, int backlog = 5);
- static Status TcpConnect(llvm::StringRef host_and_port,
- bool child_processes_inherit, Socket *&socket);
- static Status UdpConnect(llvm::StringRef host_and_port,
- bool child_processes_inherit, Socket *&socket);
+ static llvm::Expected<std::unique_ptr<TCPSocket>>
+ TcpListen(llvm::StringRef host_and_port, bool child_processes_inherit,
+ Predicate<uint16_t> *predicate, int backlog = 5);
+
+ static llvm::Expected<std::unique_ptr<Socket>>
+ TcpConnect(llvm::StringRef host_and_port, bool child_processes_inherit);
+
+ static llvm::Expected<std::unique_ptr<UDPSocket>>
+ UdpConnect(llvm::StringRef host_and_port, bool child_processes_inherit);
+
static Status UnixDomainConnect(llvm::StringRef host_and_port,
bool child_processes_inherit,
Socket *&socket);
@@ -127,4 +132,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_Host_Socket_h_
+#endif // LLDB_HOST_SOCKET_H
diff --git a/lldb/include/lldb/Host/SocketAddress.h b/lldb/include/lldb/Host/SocketAddress.h
index 766303a3c1fd..862e1104a084 100644
--- a/lldb/include/lldb/Host/SocketAddress.h
+++ b/lldb/include/lldb/Host/SocketAddress.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_SocketAddress_h_
-#define liblldb_SocketAddress_h_
+#ifndef LLDB_HOST_SOCKETADDRESS_H
+#define LLDB_HOST_SOCKETADDRESS_H
#include <stdint.h>
@@ -185,4 +185,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_SocketAddress_h_
+#endif // LLDB_HOST_SOCKETADDRESS_H
diff --git a/lldb/include/lldb/Host/StringConvert.h b/lldb/include/lldb/Host/StringConvert.h
index 4b2c6901a96b..ad629ff30429 100644
--- a/lldb/include/lldb/Host/StringConvert.h
+++ b/lldb/include/lldb/Host/StringConvert.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_StringConvert_h_
-#define liblldb_StringConvert_h_
+#ifndef LLDB_HOST_STRINGCONVERT_H
+#define LLDB_HOST_STRINGCONVERT_H
#include <stdint.h>
diff --git a/lldb/include/lldb/Host/TaskPool.h b/lldb/include/lldb/Host/TaskPool.h
deleted file mode 100644
index 49805ce193ed..000000000000
--- a/lldb/include/lldb/Host/TaskPool.h
+++ /dev/null
@@ -1,92 +0,0 @@
-//===--------------------- TaskPool.h ---------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef utility_TaskPool_h_
-#define utility_TaskPool_h_
-
-#include "llvm/ADT/STLExtras.h"
-#include <functional>
-#include <future>
-#include <list>
-#include <memory>
-#include <mutex>
-#include <type_traits>
-
-namespace lldb_private {
-
-// Global TaskPool class for running tasks in parallel on a set of worker
-// thread created the first time the task pool is used. The TaskPool provide no
-// guarantee about the order the task will be run and about what tasks will run
-// in parallel. None of the task added to the task pool should block on
-// something (mutex, future, condition variable) what will be set only by the
-// completion of an other task on the task pool as they may run on the same
-// thread sequentally.
-class TaskPool {
-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);
-};
-
-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() {}
-};
-
-// Run 'func' on every value from begin .. end-1. Each worker will grab
-// 'batch_size' numbers at a time to work on, so for very fast functions, batch
-// should be large enough to avoid too much cache line contention.
-void TaskMapOverInt(size_t begin, size_t end,
- const llvm::function_ref<void(size_t)> &func);
-
-unsigned GetHardwareConcurrencyHint();
-
-} // namespace lldb_private
-
-#endif // #ifndef utility_TaskPool_h_
diff --git a/lldb/include/lldb/Host/Terminal.h b/lldb/include/lldb/Host/Terminal.h
index 671f8d63f89f..61993223ea06 100644
--- a/lldb/include/lldb/Host/Terminal.h
+++ b/lldb/include/lldb/Host/Terminal.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Terminal_h_
-#define liblldb_Terminal_h_
+#ifndef LLDB_HOST_TERMINAL_H
+#define LLDB_HOST_TERMINAL_H
#if defined(__cplusplus)
#include "lldb/Host/Config.h"
@@ -179,4 +179,4 @@ protected:
} // namespace lldb_private
#endif // #if defined(__cplusplus)
-#endif // #ifndef liblldb_Terminal_h_
+#endif // LLDB_HOST_TERMINAL_H
diff --git a/lldb/include/lldb/Host/ThreadLauncher.h b/lldb/include/lldb/Host/ThreadLauncher.h
index e45ffa9df757..00b42fa6a11d 100644
--- a/lldb/include/lldb/Host/ThreadLauncher.h
+++ b/lldb/include/lldb/Host/ThreadLauncher.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Host_ThreadLauncher_h_
-#define lldb_Host_ThreadLauncher_h_
+#ifndef LLDB_HOST_THREADLAUNCHER_H
+#define LLDB_HOST_THREADLAUNCHER_H
#include "lldb/Host/HostThread.h"
#include "lldb/lldb-types.h"
diff --git a/lldb/include/lldb/Host/Time.h b/lldb/include/lldb/Host/Time.h
index b27eb082167e..83b76ec0f9d1 100644
--- a/lldb/include/lldb/Host/Time.h
+++ b/lldb/include/lldb/Host/Time.h
@@ -8,8 +8,8 @@
// Include system time headers, adding missing functions as necessary
-#ifndef liblldb_Host_Time_h_
-#define liblldb_Host_Time_h_
+#ifndef LLDB_HOST_TIME_H
+#define LLDB_HOST_TIME_H
#ifdef __ANDROID__
#include <android/api-level.h>
@@ -22,4 +22,4 @@ extern time_t timegm(struct tm *t);
#include <time.h>
#endif
-#endif // liblldb_Host_Time_h_
+#endif // LLDB_HOST_TIME_H
diff --git a/lldb/include/lldb/Host/XML.h b/lldb/include/lldb/Host/XML.h
index ca51d304dc8f..a80f1e9e4d26 100644
--- a/lldb/include/lldb/Host/XML.h
+++ b/lldb/include/lldb/Host/XML.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_XML_h_
-#define liblldb_XML_h_
+#ifndef LLDB_HOST_XML_H
+#define LLDB_HOST_XML_H
#include "lldb/Host/Config.h"
@@ -179,4 +179,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_XML_h_
+#endif // LLDB_HOST_XML_H
diff --git a/lldb/include/lldb/Host/common/GetOptInc.h b/lldb/include/lldb/Host/common/GetOptInc.h
index c69f7227a5cf..3fb9add47954 100644
--- a/lldb/include/lldb/Host/common/GetOptInc.h
+++ b/lldb/include/lldb/Host/common/GetOptInc.h
@@ -1,4 +1,13 @@
-#pragma once
+//===-- GetOptInc.h ---------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_HOST_COMMON_GETOPTINC_H
+#define LLDB_HOST_COMMON_GETOPTINC_H
#include "lldb/lldb-defines.h"
@@ -50,3 +59,5 @@ int getopt_long(int argc, char *const *argv, const char *optstring,
int getopt_long_only(int argc, char *const *argv, const char *optstring,
const struct option *longopts, int *longindex);
#endif
+
+#endif // LLDB_HOST_COMMON_GETOPTINC_H
diff --git a/lldb/include/lldb/Host/common/NativeBreakpointList.h b/lldb/include/lldb/Host/common/NativeBreakpointList.h
index c2725b2df959..21d2f096370a 100644
--- a/lldb/include/lldb/Host/common/NativeBreakpointList.h
+++ b/lldb/include/lldb/Host/common/NativeBreakpointList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_NativeBreakpointList_h_
-#define liblldb_NativeBreakpointList_h_
+#ifndef LLDB_HOST_COMMON_NATIVEBREAKPOINTLIST_H
+#define LLDB_HOST_COMMON_NATIVEBREAKPOINTLIST_H
#include "lldb/lldb-private-forward.h"
#include "lldb/lldb-types.h"
@@ -23,4 +23,4 @@ struct HardwareBreakpoint {
using HardwareBreakpointMap = std::map<lldb::addr_t, HardwareBreakpoint>;
}
-#endif // ifndef liblldb_NativeBreakpointList_h_
+#endif // LLDB_HOST_COMMON_NATIVEBREAKPOINTLIST_H
diff --git a/lldb/include/lldb/Host/common/NativeProcessProtocol.h b/lldb/include/lldb/Host/common/NativeProcessProtocol.h
index 2d48717c4fbb..2faab6f587cd 100644
--- a/lldb/include/lldb/Host/common/NativeProcessProtocol.h
+++ b/lldb/include/lldb/Host/common/NativeProcessProtocol.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_NativeProcessProtocol_h_
-#define liblldb_NativeProcessProtocol_h_
+#ifndef LLDB_HOST_COMMON_NATIVEPROCESSPROTOCOL_H
+#define LLDB_HOST_COMMON_NATIVEPROCESSPROTOCOL_H
#include "NativeBreakpointList.h"
#include "NativeThreadProtocol.h"
@@ -379,16 +379,10 @@ public:
/// \param[in] traceid
/// The user id of the tracing instance.
///
- /// \param[in] config
- /// The thread id of the tracing instance, in case configuration
- /// for a specific thread is needed should be specified in the
- /// config.
- ///
- /// \param[out] error
- /// Status indicates what went wrong.
- ///
/// \param[out] config
- /// The actual configuration being used for tracing.
+ /// The configuration being used for tracing.
+ ///
+ /// \return A status indicating what went wrong.
virtual Status GetTraceConfig(lldb::user_id_t traceid, TraceOptions &config) {
return Status("Not implemented");
}
@@ -475,4 +469,4 @@ private:
};
} // namespace lldb_private
-#endif // #ifndef liblldb_NativeProcessProtocol_h_
+#endif // LLDB_HOST_COMMON_NATIVEPROCESSPROTOCOL_H
diff --git a/lldb/include/lldb/Host/common/NativeRegisterContext.h b/lldb/include/lldb/Host/common/NativeRegisterContext.h
index 6bba8f2a5d29..3b54d4ae1e05 100644
--- a/lldb/include/lldb/Host/common/NativeRegisterContext.h
+++ b/lldb/include/lldb/Host/common/NativeRegisterContext.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_NativeRegisterContext_h_
-#define liblldb_NativeRegisterContext_h_
+#ifndef LLDB_HOST_COMMON_NATIVEREGISTERCONTEXT_H
+#define LLDB_HOST_COMMON_NATIVEREGISTERCONTEXT_H
#include "lldb/Host/common/NativeWatchpointList.h"
#include "lldb/lldb-private.h"
@@ -170,9 +170,11 @@ protected:
private:
// For RegisterContext only
- DISALLOW_COPY_AND_ASSIGN(NativeRegisterContext);
+ NativeRegisterContext(const NativeRegisterContext &) = delete;
+ const NativeRegisterContext &
+ operator=(const NativeRegisterContext &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_NativeRegisterContext_h_
+#endif // LLDB_HOST_COMMON_NATIVEREGISTERCONTEXT_H
diff --git a/lldb/include/lldb/Host/common/NativeThreadProtocol.h b/lldb/include/lldb/Host/common/NativeThreadProtocol.h
index 36ae67933f53..8d4c03549bb9 100644
--- a/lldb/include/lldb/Host/common/NativeThreadProtocol.h
+++ b/lldb/include/lldb/Host/common/NativeThreadProtocol.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_NativeThreadProtocol_h_
-#define liblldb_NativeThreadProtocol_h_
+#ifndef LLDB_HOST_COMMON_NATIVETHREADPROTOCOL_H
+#define LLDB_HOST_COMMON_NATIVETHREADPROTOCOL_H
#include <memory>
@@ -53,4 +53,4 @@ protected:
};
}
-#endif // #ifndef liblldb_NativeThreadProtocol_h_
+#endif // LLDB_HOST_COMMON_NATIVETHREADPROTOCOL_H
diff --git a/lldb/include/lldb/Host/common/NativeWatchpointList.h b/lldb/include/lldb/Host/common/NativeWatchpointList.h
index c83ba1eaadca..66f93bf1c8f7 100644
--- a/lldb/include/lldb/Host/common/NativeWatchpointList.h
+++ b/lldb/include/lldb/Host/common/NativeWatchpointList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_NativeWatchpointList_h_
-#define liblldb_NativeWatchpointList_h_
+#ifndef LLDB_HOST_COMMON_NATIVEWATCHPOINTLIST_H
+#define LLDB_HOST_COMMON_NATIVEWATCHPOINTLIST_H
#include "lldb/Utility/Status.h"
#include "lldb/lldb-private-forward.h"
@@ -38,4 +38,4 @@ private:
};
}
-#endif // ifndef liblldb_NativeWatchpointList_h_
+#endif // LLDB_HOST_COMMON_NATIVEWATCHPOINTLIST_H
diff --git a/lldb/include/lldb/Host/common/TCPSocket.h b/lldb/include/lldb/Host/common/TCPSocket.h
index faf3bb693c32..b782c9e6096c 100644
--- a/lldb/include/lldb/Host/common/TCPSocket.h
+++ b/lldb/include/lldb/Host/common/TCPSocket.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_TCPSocket_h_
-#define liblldb_TCPSocket_h_
+#ifndef LLDB_HOST_COMMON_TCPSOCKET_H
+#define LLDB_HOST_COMMON_TCPSOCKET_H
#include "lldb/Host/Socket.h"
#include "lldb/Host/SocketAddress.h"
@@ -57,4 +57,4 @@ private:
};
}
-#endif // ifndef liblldb_TCPSocket_h_
+#endif // LLDB_HOST_COMMON_TCPSOCKET_H
diff --git a/lldb/include/lldb/Host/common/UDPSocket.h b/lldb/include/lldb/Host/common/UDPSocket.h
index b7b6db67d10d..bae707e345d8 100644
--- a/lldb/include/lldb/Host/common/UDPSocket.h
+++ b/lldb/include/lldb/Host/common/UDPSocket.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_UDPSocket_h_
-#define liblldb_UDPSocket_h_
+#ifndef LLDB_HOST_COMMON_UDPSOCKET_H
+#define LLDB_HOST_COMMON_UDPSOCKET_H
#include "lldb/Host/Socket.h"
@@ -16,8 +16,8 @@ class UDPSocket : public Socket {
public:
UDPSocket(bool should_close, bool child_processes_inherit);
- static Status Connect(llvm::StringRef name, bool child_processes_inherit,
- Socket *&socket);
+ static llvm::Expected<std::unique_ptr<UDPSocket>>
+ Connect(llvm::StringRef name, bool child_processes_inherit);
std::string GetRemoteConnectionURI() const override;
@@ -33,4 +33,4 @@ private:
};
}
-#endif // ifndef liblldb_UDPSocket_h_
+#endif // LLDB_HOST_COMMON_UDPSOCKET_H
diff --git a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
index b25fc47c56b6..3ee8f9d9133e 100644
--- a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
+++ b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Host_posix_ConnectionFileDescriptorPosix_h_
-#define liblldb_Host_posix_ConnectionFileDescriptorPosix_h_
+#ifndef LLDB_HOST_POSIX_CONNECTIONFILEDESCRIPTORPOSIX_H
+#define LLDB_HOST_POSIX_CONNECTIONFILEDESCRIPTORPOSIX_H
#include <atomic>
#include <memory>
@@ -116,9 +116,11 @@ protected:
private:
void InitializeSocket(Socket *socket);
- DISALLOW_COPY_AND_ASSIGN(ConnectionFileDescriptor);
+ ConnectionFileDescriptor(const ConnectionFileDescriptor &) = delete;
+ const ConnectionFileDescriptor &
+ operator=(const ConnectionFileDescriptor &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ConnectionFileDescriptor_h_
+#endif // LLDB_HOST_POSIX_CONNECTIONFILEDESCRIPTORPOSIX_H
diff --git a/lldb/include/lldb/Host/posix/DomainSocket.h b/lldb/include/lldb/Host/posix/DomainSocket.h
index e407ce16bbcb..35c33811f60d 100644
--- a/lldb/include/lldb/Host/posix/DomainSocket.h
+++ b/lldb/include/lldb/Host/posix/DomainSocket.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DomainSocket_h_
-#define liblldb_DomainSocket_h_
+#ifndef LLDB_HOST_POSIX_DOMAINSOCKET_H
+#define LLDB_HOST_POSIX_DOMAINSOCKET_H
#include "lldb/Host/Socket.h"
@@ -34,4 +34,4 @@ private:
};
}
-#endif // ifndef liblldb_DomainSocket_h_
+#endif // LLDB_HOST_POSIX_DOMAINSOCKET_H
diff --git a/lldb/include/lldb/Host/posix/HostInfoPosix.h b/lldb/include/lldb/Host/posix/HostInfoPosix.h
index 26910132f3c8..825c79f53ecb 100644
--- a/lldb/include/lldb/Host/posix/HostInfoPosix.h
+++ b/lldb/include/lldb/Host/posix/HostInfoPosix.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Host_posix_HostInfoPosix_h_
-#define lldb_Host_posix_HostInfoPosix_h_
+#ifndef LLDB_HOST_POSIX_HOSTINFOPOSIX_H
+#define LLDB_HOST_POSIX_HOSTINFOPOSIX_H
#include "lldb/Host/HostInfoBase.h"
#include "lldb/Utility/FileSpec.h"
diff --git a/lldb/include/lldb/Host/posix/HostProcessPosix.h b/lldb/include/lldb/Host/posix/HostProcessPosix.h
index a313358631b5..5def1b77eefe 100644
--- a/lldb/include/lldb/Host/posix/HostProcessPosix.h
+++ b/lldb/include/lldb/Host/posix/HostProcessPosix.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Host_HostProcesPosix_h_
-#define lldb_Host_HostProcesPosix_h_
+#ifndef LLDB_HOST_POSIX_HOSTPROCESSPOSIX_H
+#define LLDB_HOST_POSIX_HOSTPROCESSPOSIX_H
#include "lldb/Host/HostNativeProcessBase.h"
#include "lldb/Utility/Status.h"
@@ -39,4 +39,4 @@ public:
} // namespace lldb_private
-#endif // lldb_Host_HostProcesPosix_h_
+#endif // LLDB_HOST_POSIX_HOSTPROCESSPOSIX_H
diff --git a/lldb/include/lldb/Host/posix/HostThreadPosix.h b/lldb/include/lldb/Host/posix/HostThreadPosix.h
index 54012e15ad99..6c8e09fc1103 100644
--- a/lldb/include/lldb/Host/posix/HostThreadPosix.h
+++ b/lldb/include/lldb/Host/posix/HostThreadPosix.h
@@ -6,15 +6,16 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Host_posix_HostThreadPosix_h_
-#define lldb_Host_posix_HostThreadPosix_h_
+#ifndef LLDB_HOST_POSIX_HOSTTHREADPOSIX_H
+#define LLDB_HOST_POSIX_HOSTTHREADPOSIX_H
#include "lldb/Host/HostNativeThreadBase.h"
namespace lldb_private {
class HostThreadPosix : public HostNativeThreadBase {
- DISALLOW_COPY_AND_ASSIGN(HostThreadPosix);
+ HostThreadPosix(const HostThreadPosix &) = delete;
+ const HostThreadPosix &operator=(const HostThreadPosix &) = delete;
public:
HostThreadPosix();
@@ -29,4 +30,4 @@ public:
} // namespace lldb_private
-#endif // lldb_Host_posix_HostThreadPosix_h_
+#endif // LLDB_HOST_POSIX_HOSTTHREADPOSIX_H
diff --git a/lldb/include/lldb/Host/posix/LockFilePosix.h b/lldb/include/lldb/Host/posix/LockFilePosix.h
index 63333bff4cd3..870f9a2f525d 100644
--- a/lldb/include/lldb/Host/posix/LockFilePosix.h
+++ b/lldb/include/lldb/Host/posix/LockFilePosix.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Host_posix_LockFilePosix_h_
-#define liblldb_Host_posix_LockFilePosix_h_
+#ifndef LLDB_HOST_POSIX_LOCKFILEPOSIX_H
+#define LLDB_HOST_POSIX_LOCKFILEPOSIX_H
#include "lldb/Host/LockFileBase.h"
@@ -32,4 +32,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_Host_posix_LockFilePosix_h_
+#endif // LLDB_HOST_POSIX_LOCKFILEPOSIX_H
diff --git a/lldb/include/lldb/Host/posix/PipePosix.h b/lldb/include/lldb/Host/posix/PipePosix.h
index df341f2fc895..77c0e2f7ef49 100644
--- a/lldb/include/lldb/Host/posix/PipePosix.h
+++ b/lldb/include/lldb/Host/posix/PipePosix.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Host_posix_PipePosix_h_
-#define liblldb_Host_posix_PipePosix_h_
+#ifndef LLDB_HOST_POSIX_PIPEPOSIX_H
+#define LLDB_HOST_POSIX_PIPEPOSIX_H
#if defined(__cplusplus)
#include "lldb/Host/PipeBase.h"
@@ -77,4 +77,4 @@ private:
} // namespace lldb_private
#endif // #if defined(__cplusplus)
-#endif // liblldb_Host_posix_PipePosix_h_
+#endif // LLDB_HOST_POSIX_PIPEPOSIX_H
diff --git a/lldb/include/lldb/Host/posix/ProcessLauncherPosixFork.h b/lldb/include/lldb/Host/posix/ProcessLauncherPosixFork.h
index 15e2d6d23b8e..427fb5b4f483 100644
--- a/lldb/include/lldb/Host/posix/ProcessLauncherPosixFork.h
+++ b/lldb/include/lldb/Host/posix/ProcessLauncherPosixFork.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Host_posix_ProcessLauncherPosixFork_h_
-#define lldb_Host_posix_ProcessLauncherPosixFork_h_
+#ifndef LLDB_HOST_POSIX_PROCESSLAUNCHERPOSIXFORK_H
+#define LLDB_HOST_POSIX_PROCESSLAUNCHERPOSIXFORK_H
#include "lldb/Host/ProcessLauncher.h"
diff --git a/lldb/include/lldb/Initialization/SystemInitializer.h b/lldb/include/lldb/Initialization/SystemInitializer.h
index e616ad1ee811..4426bfb224e3 100644
--- a/lldb/include/lldb/Initialization/SystemInitializer.h
+++ b/lldb/include/lldb/Initialization/SystemInitializer.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_INITIALIZATION_SYSTEM_INITIALIZER_H
-#define LLDB_INITIALIZATION_SYSTEM_INITIALIZER_H
+#ifndef LLDB_INITIALIZATION_SYSTEMINITIALIZER_H
+#define LLDB_INITIALIZATION_SYSTEMINITIALIZER_H
#include "llvm/Support/Error.h"
diff --git a/lldb/include/lldb/Initialization/SystemInitializerCommon.h b/lldb/include/lldb/Initialization/SystemInitializerCommon.h
index ad7e58e50bbe..3a5081680879 100644
--- a/lldb/include/lldb/Initialization/SystemInitializerCommon.h
+++ b/lldb/include/lldb/Initialization/SystemInitializerCommon.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_INITIALIZATION_SYSTEM_INITIALIZER_COMMON_H
-#define LLDB_INITIALIZATION_SYSTEM_INITIALIZER_COMMON_H
+#ifndef LLDB_INITIALIZATION_SYSTEMINITIALIZERCOMMON_H
+#define LLDB_INITIALIZATION_SYSTEMINITIALIZERCOMMON_H
#include "SystemInitializer.h"
@@ -31,4 +31,4 @@ public:
} // namespace lldb_private
-#endif // LLDB_INITIALIZATION_SYSTEM_INITIALIZER_COMMON_H
+#endif // LLDB_INITIALIZATION_SYSTEMINITIALIZERCOMMON_H
diff --git a/lldb/include/lldb/Initialization/SystemLifetimeManager.h b/lldb/include/lldb/Initialization/SystemLifetimeManager.h
index 2e99b86dbdbd..27e1a22b19dd 100644
--- a/lldb/include/lldb/Initialization/SystemLifetimeManager.h
+++ b/lldb/include/lldb/Initialization/SystemLifetimeManager.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_INITIALIZATION_SYSTEM_LIFETIME_MANAGER_H
-#define LLDB_INITIALIZATION_SYSTEM_LIFETIME_MANAGER_H
+#ifndef LLDB_INITIALIZATION_SYSTEMLIFETIMEMANAGER_H
+#define LLDB_INITIALIZATION_SYSTEMLIFETIMEMANAGER_H
#include "lldb/Initialization/SystemInitializer.h"
#include "lldb/lldb-private-types.h"
diff --git a/lldb/include/lldb/Interpreter/CommandAlias.h b/lldb/include/lldb/Interpreter/CommandAlias.h
index 1e186d77f8e6..26826db62705 100644
--- a/lldb/include/lldb/Interpreter/CommandAlias.h
+++ b/lldb/include/lldb/Interpreter/CommandAlias.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandAlias_h_
-#define liblldb_CommandAlias_h_
+#ifndef LLDB_INTERPRETER_COMMANDALIAS_H
+#define LLDB_INTERPRETER_COMMANDALIAS_H
#include <memory>
@@ -81,4 +81,4 @@ private:
};
} // namespace lldb_private
-#endif // liblldb_CommandAlias_h_
+#endif // LLDB_INTERPRETER_COMMANDALIAS_H
diff --git a/lldb/include/lldb/Interpreter/CommandCompletions.h b/lldb/include/lldb/Interpreter/CommandCompletions.h
index 275cc7e7c145..39d1c98eaa39 100644
--- a/lldb/include/lldb/Interpreter/CommandCompletions.h
+++ b/lldb/include/lldb/Interpreter/CommandCompletions.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_CommandCompletions_h_
-#define lldb_CommandCompletions_h_
+#ifndef LLDB_INTERPRETER_COMMANDCOMPLETIONS_H
+#define LLDB_INTERPRETER_COMMANDCOMPLETIONS_H
#include <set>
@@ -23,13 +23,6 @@ namespace lldb_private {
class TildeExpressionResolver;
class CommandCompletions {
public:
- // This is the command completion callback that is used to complete the
- // argument of the option it is bound to (in the OptionDefinition table
- // below). Return the total number of matches.
- typedef void (*CompletionCallback)(CommandInterpreter &interpreter,
- CompletionRequest &request,
- // A search filter to limit the search...
- lldb_private::SearchFilter *searcher);
enum CommonCompletionTypes {
eNoCompletion = 0u,
eSourceFileCompletion = (1u << 0),
@@ -41,15 +34,13 @@ public:
ePlatformPluginCompletion = (1u << 6),
eArchitectureCompletion = (1u << 7),
eVariablePathCompletion = (1u << 8),
+ eRegisterCompletion = (1u << 9),
+ eBreakpointCompletion = (1u << 10),
+ eProcessPluginCompletion = (1u << 11),
// This item serves two purposes. It is the last element in the enum, so
// you can add custom enums starting from here in your Option class. Also
// if you & in this bit the base code will not process the option.
- eCustomCompletion = (1u << 9)
- };
-
- struct CommonCompletionElement {
- uint32_t type;
- CompletionCallback callback;
+ eCustomCompletion = (1u << 12)
};
static bool InvokeCommonCompletionCallbacks(
@@ -94,99 +85,17 @@ public:
static void VariablePath(CommandInterpreter &interpreter,
CompletionRequest &request, SearchFilter *searcher);
- // The Completer class is a convenient base class for building searchers that
- // go along with the SearchFilter passed to the standard Completer functions.
- class Completer : public Searcher {
- public:
- Completer(CommandInterpreter &interpreter, CompletionRequest &request);
-
- ~Completer() override;
-
- CallbackReturn SearchCallback(SearchFilter &filter, SymbolContext &context,
- Address *addr) override = 0;
-
- lldb::SearchDepth GetDepth() override = 0;
-
- virtual void DoCompletion(SearchFilter *filter) = 0;
-
- protected:
- CommandInterpreter &m_interpreter;
- CompletionRequest &m_request;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(Completer);
- };
-
- // SourceFileCompleter implements the source file completer
- class SourceFileCompleter : public Completer {
- public:
- SourceFileCompleter(CommandInterpreter &interpreter,
- bool include_support_files, CompletionRequest &request);
-
- lldb::SearchDepth GetDepth() override;
-
- Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
- SymbolContext &context,
- Address *addr) override;
-
- void DoCompletion(SearchFilter *filter) override;
-
- private:
- bool m_include_support_files;
- FileSpecList m_matching_files;
- const char *m_file_name;
- const char *m_dir_name;
-
- DISALLOW_COPY_AND_ASSIGN(SourceFileCompleter);
- };
-
- // ModuleCompleter implements the module completer
- class ModuleCompleter : public Completer {
- public:
- ModuleCompleter(CommandInterpreter &interpreter,
- CompletionRequest &request);
-
- lldb::SearchDepth GetDepth() override;
-
- Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
- SymbolContext &context,
- Address *addr) override;
-
- void DoCompletion(SearchFilter *filter) override;
-
- private:
- const char *m_file_name;
- const char *m_dir_name;
-
- DISALLOW_COPY_AND_ASSIGN(ModuleCompleter);
- };
-
- // SymbolCompleter implements the symbol completer
- class SymbolCompleter : public Completer {
- public:
- SymbolCompleter(CommandInterpreter &interpreter,
- CompletionRequest &request);
-
- lldb::SearchDepth GetDepth() override;
-
- Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
- SymbolContext &context,
- Address *addr) override;
-
- void DoCompletion(SearchFilter *filter) override;
-
- private:
- RegularExpression m_regex;
- typedef std::set<ConstString> collection;
- collection m_match_set;
+ static void Registers(CommandInterpreter &interpreter,
+ CompletionRequest &request, SearchFilter *searcher);
- DISALLOW_COPY_AND_ASSIGN(SymbolCompleter);
- };
+ static void Breakpoints(CommandInterpreter &interpreter,
+ CompletionRequest &request, SearchFilter *searcher);
-private:
- static CommonCompletionElement g_common_completions[];
+ static void ProcessPluginNames(CommandInterpreter &interpreter,
+ CompletionRequest &request,
+ SearchFilter *searcher);
};
} // namespace lldb_private
-#endif // lldb_CommandCompletions_h_
+#endif // LLDB_INTERPRETER_COMMANDCOMPLETIONS_H
diff --git a/lldb/include/lldb/Interpreter/CommandHistory.h b/lldb/include/lldb/Interpreter/CommandHistory.h
index c1386f84fe2e..fbb42247f11a 100644
--- a/lldb/include/lldb/Interpreter/CommandHistory.h
+++ b/lldb/include/lldb/Interpreter/CommandHistory.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandHistory_h_
-#define liblldb_CommandHistory_h_
+#ifndef LLDB_INTERPRETER_COMMANDHISTORY_H
+#define LLDB_INTERPRETER_COMMANDHISTORY_H
#include <mutex>
#include <string>
@@ -46,7 +46,8 @@ public:
static const char g_repeat_char = '!';
private:
- DISALLOW_COPY_AND_ASSIGN(CommandHistory);
+ CommandHistory(const CommandHistory &) = delete;
+ const CommandHistory &operator=(const CommandHistory &) = delete;
typedef std::vector<std::string> History;
mutable std::recursive_mutex m_mutex;
@@ -55,4 +56,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_CommandHistory_h_
+#endif // LLDB_INTERPRETER_COMMANDHISTORY_H
diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index d08951e608cb..8a9dce7a19bc 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandInterpreter_h_
-#define liblldb_CommandInterpreter_h_
+#ifndef LLDB_INTERPRETER_COMMANDINTERPRETER_H
+#define LLDB_INTERPRETER_COMMANDINTERPRETER_H
#include "lldb/Core/Debugger.h"
#include "lldb/Core/IOHandler.h"
@@ -26,6 +26,32 @@
#include <mutex>
namespace lldb_private {
+class CommandInterpreter;
+
+class CommandInterpreterRunResult {
+public:
+ CommandInterpreterRunResult()
+ : m_num_errors(0), m_result(lldb::eCommandInterpreterResultSuccess) {}
+
+ uint32_t GetNumErrors() const { return m_num_errors; }
+
+ lldb::CommandInterpreterResult GetResult() const { return m_result; }
+
+ bool IsResult(lldb::CommandInterpreterResult result) {
+ return m_result == result;
+ }
+
+protected:
+ friend CommandInterpreter;
+
+ void IncrementNumberOfErrors() { m_num_errors++; }
+
+ void SetResult(lldb::CommandInterpreterResult result) { m_result = result; }
+
+private:
+ int m_num_errors;
+ lldb::CommandInterpreterResult m_result;
+};
class CommandInterpreterRunOptions {
public:
@@ -144,6 +170,20 @@ public:
m_add_to_history = add_to_history ? eLazyBoolYes : eLazyBoolNo;
}
+ bool GetAutoHandleEvents() const {
+ return DefaultToYes(m_auto_handle_events);
+ }
+
+ void SetAutoHandleEvents(bool auto_handle_events) {
+ m_auto_handle_events = auto_handle_events ? eLazyBoolYes : eLazyBoolNo;
+ }
+
+ bool GetSpawnThread() const { return DefaultToNo(m_spawn_thread); }
+
+ void SetSpawnThread(bool spawn_thread) {
+ m_spawn_thread = spawn_thread ? eLazyBoolYes : eLazyBoolNo;
+ }
+
LazyBool m_stop_on_continue;
LazyBool m_stop_on_error;
LazyBool m_stop_on_crash;
@@ -152,6 +192,8 @@ public:
LazyBool m_print_results;
LazyBool m_print_errors;
LazyBool m_add_to_history;
+ LazyBool m_auto_handle_events;
+ LazyBool m_spawn_thread;
private:
static bool DefaultToYes(LazyBool flag) {
@@ -426,8 +468,8 @@ public:
bool IsActive();
- void RunCommandInterpreter(bool auto_handle_events, bool spawn_thread,
- CommandInterpreterRunOptions &options);
+ CommandInterpreterRunResult
+ RunCommandInterpreter(CommandInterpreterRunOptions &options);
void GetLLDBCommandsFromIOHandler(const char *prompt,
IOHandlerDelegate &delegate,
@@ -452,6 +494,10 @@ public:
bool GetEchoCommentCommands() const;
void SetEchoCommentCommands(bool enable);
+ const CommandObject::CommandMap &GetUserCommands() const {
+ return m_user_dict;
+ }
+
/// Specify if the command interpreter should allow that the user can
/// specify a custom exit code when calling 'quit'.
void AllowExitCodeOnQuit(bool allow);
@@ -474,16 +520,10 @@ public:
bool GetStopCmdSourceOnError() const;
- uint32_t GetNumErrors() const { return m_num_errors; }
-
- bool GetQuitRequested() const { return m_quit_requested; }
-
lldb::IOHandlerSP
GetIOHandler(bool force_create = false,
CommandInterpreterRunOptions *options = nullptr);
- bool GetStoppedForCrash() const { return m_stopped_for_crash; }
-
bool GetSpaceReplPrompts() const;
protected:
@@ -574,9 +614,7 @@ private:
// the user has been told
uint32_t m_command_source_depth;
std::vector<uint32_t> m_command_source_flags;
- uint32_t m_num_errors;
- bool m_quit_requested;
- bool m_stopped_for_crash;
+ CommandInterpreterRunResult m_result;
// The exit code the user has requested when calling the 'quit' command.
// No value means the user hasn't set a custom exit code so far.
@@ -587,4 +625,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_CommandInterpreter_h_
+#endif // LLDB_INTERPRETER_COMMANDINTERPRETER_H
diff --git a/lldb/include/lldb/Interpreter/CommandObject.h b/lldb/include/lldb/Interpreter/CommandObject.h
index f4dc2d606dda..cc4d40b23c31 100644
--- a/lldb/include/lldb/Interpreter/CommandObject.h
+++ b/lldb/include/lldb/Interpreter/CommandObject.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObject_h_
-#define liblldb_CommandObject_h_
+#ifndef LLDB_INTERPRETER_COMMANDOBJECT_H
+#define LLDB_INTERPRETER_COMMANDOBJECT_H
#include <map>
#include <string>
@@ -40,7 +40,7 @@ int AddNamesMatchingPartialString(
const bool add_all = cmd_str.empty();
for (auto iter = in_map.begin(), end = in_map.end(); iter != end; iter++) {
- if (add_all || (iter->first.find(cmd_str, 0) == 0)) {
+ if (add_all || (iter->first.find(std::string(cmd_str), 0) == 0)) {
++number_added;
matches.AppendString(iter->first.c_str());
if (descriptions)
@@ -411,4 +411,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_CommandObject_h_
+#endif // LLDB_INTERPRETER_COMMANDOBJECT_H
diff --git a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
index 72ec8a9c5ca9..6b383f8cfb34 100644
--- a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
+++ b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectMultiword_h_
-#define liblldb_CommandObjectMultiword_h_
+#ifndef LLDB_INTERPRETER_COMMANDOBJECTMULTIWORD_H
+#define LLDB_INTERPRETER_COMMANDOBJECTMULTIWORD_H
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Utility/CompletionRequest.h"
@@ -131,4 +131,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_CommandObjectMultiword_h_
+#endif // LLDB_INTERPRETER_COMMANDOBJECTMULTIWORD_H
diff --git a/lldb/include/lldb/Interpreter/CommandObjectRegexCommand.h b/lldb/include/lldb/Interpreter/CommandObjectRegexCommand.h
index 7800d5de1b38..01d7c6d118d4 100644
--- a/lldb/include/lldb/Interpreter/CommandObjectRegexCommand.h
+++ b/lldb/include/lldb/Interpreter/CommandObjectRegexCommand.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectRegexCommand_h_
-#define liblldb_CommandObjectRegexCommand_h_
+#ifndef LLDB_INTERPRETER_COMMANDOBJECTREGEXCOMMAND_H
+#define LLDB_INTERPRETER_COMMANDOBJECTREGEXCOMMAND_H
#include <list>
@@ -51,9 +51,11 @@ protected:
bool m_is_removable;
private:
- DISALLOW_COPY_AND_ASSIGN(CommandObjectRegexCommand);
+ CommandObjectRegexCommand(const CommandObjectRegexCommand &) = delete;
+ const CommandObjectRegexCommand &
+ operator=(const CommandObjectRegexCommand &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectRegexCommand_h_
+#endif // LLDB_INTERPRETER_COMMANDOBJECTREGEXCOMMAND_H
diff --git a/lldb/include/lldb/Interpreter/CommandOptionValidators.h b/lldb/include/lldb/Interpreter/CommandOptionValidators.h
index 5483c1509556..218cc87fdf22 100644
--- a/lldb/include/lldb/Interpreter/CommandOptionValidators.h
+++ b/lldb/include/lldb/Interpreter/CommandOptionValidators.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandOptionValidators_h_
-#define liblldb_CommandOptionValidators_h_
+#ifndef LLDB_INTERPRETER_COMMANDOPTIONVALIDATORS_H
+#define LLDB_INTERPRETER_COMMANDOPTIONVALIDATORS_H
#include "lldb/lldb-private-types.h"
@@ -25,4 +25,4 @@ class PosixPlatformCommandOptionValidator : public OptionValidator {
} // namespace lldb_private
-#endif // liblldb_CommandOptionValidators_h_
+#endif // LLDB_INTERPRETER_COMMANDOPTIONVALIDATORS_H
diff --git a/lldb/include/lldb/Interpreter/CommandReturnObject.h b/lldb/include/lldb/Interpreter/CommandReturnObject.h
index 8af76e07e5ae..a7c2eea57663 100644
--- a/lldb/include/lldb/Interpreter/CommandReturnObject.h
+++ b/lldb/include/lldb/Interpreter/CommandReturnObject.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandReturnObject_h_
-#define liblldb_CommandReturnObject_h_
+#ifndef LLDB_INTERPRETER_COMMANDRETURNOBJECT_H
+#define LLDB_INTERPRETER_COMMANDRETURNOBJECT_H
#include "lldb/Core/StreamFile.h"
#include "lldb/Utility/StreamString.h"
@@ -16,6 +16,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/WithColor.h"
#include <memory>
@@ -23,21 +24,21 @@ namespace lldb_private {
class CommandReturnObject {
public:
- CommandReturnObject();
+ CommandReturnObject(bool colors);
~CommandReturnObject();
llvm::StringRef GetOutputData() {
lldb::StreamSP stream_sp(m_out_stream.GetStreamAtIndex(eStreamStringIndex));
if (stream_sp)
- return static_pointer_cast<StreamString>(stream_sp)->GetString();
+ return std::static_pointer_cast<StreamString>(stream_sp)->GetString();
return llvm::StringRef();
}
llvm::StringRef GetErrorData() {
lldb::StreamSP stream_sp(m_err_stream.GetStreamAtIndex(eStreamStringIndex));
if (stream_sp)
- return static_pointer_cast<StreamString>(stream_sp)->GetString();
+ return std::static_pointer_cast<StreamString>(stream_sp)->GetString();
return llvm::StringRef();
}
@@ -45,7 +46,7 @@ public:
// Make sure we at least have our normal string stream output stream
lldb::StreamSP stream_sp(m_out_stream.GetStreamAtIndex(eStreamStringIndex));
if (!stream_sp) {
- stream_sp.reset(new StreamString());
+ stream_sp = std::make_shared<StreamString>();
m_out_stream.SetStreamAtIndex(eStreamStringIndex, stream_sp);
}
return m_out_stream;
@@ -55,7 +56,7 @@ public:
// Make sure we at least have our normal string stream output stream
lldb::StreamSP stream_sp(m_err_stream.GetStreamAtIndex(eStreamStringIndex));
if (!stream_sp) {
- stream_sp.reset(new StreamString());
+ stream_sp = std::make_shared<StreamString>();
m_err_stream.SetStreamAtIndex(eStreamStringIndex, stream_sp);
}
return m_err_stream;
@@ -157,4 +158,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_CommandReturnObject_h_
+#endif // LLDB_INTERPRETER_COMMANDRETURNOBJECT_H
diff --git a/lldb/include/lldb/Interpreter/OptionGroupArchitecture.h b/lldb/include/lldb/Interpreter/OptionGroupArchitecture.h
index 4b7f9fe92e35..1eadf45bae47 100644
--- a/lldb/include/lldb/Interpreter/OptionGroupArchitecture.h
+++ b/lldb/include/lldb/Interpreter/OptionGroupArchitecture.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionGroupArchitecture_h_
-#define liblldb_OptionGroupArchitecture_h_
+#ifndef LLDB_INTERPRETER_OPTIONGROUPARCHITECTURE_H
+#define LLDB_INTERPRETER_OPTIONGROUPARCHITECTURE_H
#include "lldb/Interpreter/Options.h"
#include "lldb/Utility/ArchSpec.h"
@@ -42,4 +42,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionGroupArchitecture_h_
+#endif // LLDB_INTERPRETER_OPTIONGROUPARCHITECTURE_H
diff --git a/lldb/include/lldb/Interpreter/OptionGroupBoolean.h b/lldb/include/lldb/Interpreter/OptionGroupBoolean.h
index 77490457528a..061e31340854 100644
--- a/lldb/include/lldb/Interpreter/OptionGroupBoolean.h
+++ b/lldb/include/lldb/Interpreter/OptionGroupBoolean.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionGroupBoolean_h_
-#define liblldb_OptionGroupBoolean_h_
+#ifndef LLDB_INTERPRETER_OPTIONGROUPBOOLEAN_H
+#define LLDB_INTERPRETER_OPTIONGROUPBOOLEAN_H
#include "lldb/Interpreter/OptionValueBoolean.h"
#include "lldb/Interpreter/Options.h"
@@ -48,4 +48,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionGroupBoolean_h_
+#endif // LLDB_INTERPRETER_OPTIONGROUPBOOLEAN_H
diff --git a/lldb/include/lldb/Interpreter/OptionGroupFile.h b/lldb/include/lldb/Interpreter/OptionGroupFile.h
index cce3714e98b9..374cf10ea30a 100644
--- a/lldb/include/lldb/Interpreter/OptionGroupFile.h
+++ b/lldb/include/lldb/Interpreter/OptionGroupFile.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionGroupFile_h_
-#define liblldb_OptionGroupFile_h_
+#ifndef LLDB_INTERPRETER_OPTIONGROUPFILE_H
+#define LLDB_INTERPRETER_OPTIONGROUPFILE_H
#include "lldb/Interpreter/OptionValueFileSpec.h"
#include "lldb/Interpreter/OptionValueFileSpecList.h"
@@ -78,4 +78,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionGroupFile_h_
+#endif // LLDB_INTERPRETER_OPTIONGROUPFILE_H
diff --git a/lldb/include/lldb/Interpreter/OptionGroupFormat.h b/lldb/include/lldb/Interpreter/OptionGroupFormat.h
index 1b5020a392c5..62c6f97c6214 100644
--- a/lldb/include/lldb/Interpreter/OptionGroupFormat.h
+++ b/lldb/include/lldb/Interpreter/OptionGroupFormat.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionGroupFormat_h_
-#define liblldb_OptionGroupFormat_h_
+#ifndef LLDB_INTERPRETER_OPTIONGROUPFORMAT_H
+#define LLDB_INTERPRETER_OPTIONGROUPFORMAT_H
#include "lldb/Interpreter/OptionValueFormat.h"
#include "lldb/Interpreter/OptionValueSInt64.h"
@@ -78,4 +78,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionGroupFormat_h_
+#endif // LLDB_INTERPRETER_OPTIONGROUPFORMAT_H
diff --git a/lldb/include/lldb/Interpreter/OptionGroupOutputFile.h b/lldb/include/lldb/Interpreter/OptionGroupOutputFile.h
index 82d68b7c164e..a71998f3bc1a 100644
--- a/lldb/include/lldb/Interpreter/OptionGroupOutputFile.h
+++ b/lldb/include/lldb/Interpreter/OptionGroupOutputFile.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionGroupOutputFile_h_
-#define liblldb_OptionGroupOutputFile_h_
+#ifndef LLDB_INTERPRETER_OPTIONGROUPOUTPUTFILE_H
+#define LLDB_INTERPRETER_OPTIONGROUPOUTPUTFILE_H
#include "lldb/Interpreter/OptionValueBoolean.h"
#include "lldb/Interpreter/OptionValueFileSpec.h"
@@ -45,4 +45,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionGroupOutputFile_h_
+#endif // LLDB_INTERPRETER_OPTIONGROUPOUTPUTFILE_H
diff --git a/lldb/include/lldb/Interpreter/OptionGroupPlatform.h b/lldb/include/lldb/Interpreter/OptionGroupPlatform.h
index ea5a3f39ef83..99945e5246fd 100644
--- a/lldb/include/lldb/Interpreter/OptionGroupPlatform.h
+++ b/lldb/include/lldb/Interpreter/OptionGroupPlatform.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionGroupPlatform_h_
-#define liblldb_OptionGroupPlatform_h_
+#ifndef LLDB_INTERPRETER_OPTIONGROUPPLATFORM_H
+#define LLDB_INTERPRETER_OPTIONGROUPPLATFORM_H
#include "lldb/Interpreter/Options.h"
#include "lldb/Utility/ConstString.h"
@@ -70,4 +70,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionGroupPlatform_h_
+#endif // LLDB_INTERPRETER_OPTIONGROUPPLATFORM_H
diff --git a/lldb/include/lldb/Interpreter/OptionGroupPythonClassWithDict.h b/lldb/include/lldb/Interpreter/OptionGroupPythonClassWithDict.h
index 2229c1aa08a2..d4c924a44157 100644
--- a/lldb/include/lldb/Interpreter/OptionGroupPythonClassWithDict.h
+++ b/lldb/include/lldb/Interpreter/OptionGroupPythonClassWithDict.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionGroupPythonClassWithDict_h_
-#define liblldb_OptionGroupPythonClassWithDict_h_
+#ifndef LLDB_INTERPRETER_OPTIONGROUPPYTHONCLASSWITHDICT_H
+#define LLDB_INTERPRETER_OPTIONGROUPPYTHONCLASSWITHDICT_H
#include "lldb/lldb-types.h"
#include "lldb/Interpreter/Options.h"
@@ -60,4 +60,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionGroupPythonClassWithDict_h_
+#endif // LLDB_INTERPRETER_OPTIONGROUPPYTHONCLASSWITHDICT_H
diff --git a/lldb/include/lldb/Interpreter/OptionGroupString.h b/lldb/include/lldb/Interpreter/OptionGroupString.h
index ce1058954054..1a3b5bdd88ed 100644
--- a/lldb/include/lldb/Interpreter/OptionGroupString.h
+++ b/lldb/include/lldb/Interpreter/OptionGroupString.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionGroupString_h_
-#define liblldb_OptionGroupString_h_
+#ifndef LLDB_INTERPRETER_OPTIONGROUPSTRING_H
+#define LLDB_INTERPRETER_OPTIONGROUPSTRING_H
#include "lldb/Interpreter/OptionValueString.h"
#include "lldb/Interpreter/Options.h"
@@ -45,4 +45,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionGroupString_h_
+#endif // LLDB_INTERPRETER_OPTIONGROUPSTRING_H
diff --git a/lldb/include/lldb/Interpreter/OptionGroupUInt64.h b/lldb/include/lldb/Interpreter/OptionGroupUInt64.h
index 12f08a38c533..783c4b632f00 100644
--- a/lldb/include/lldb/Interpreter/OptionGroupUInt64.h
+++ b/lldb/include/lldb/Interpreter/OptionGroupUInt64.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionGroupUInt64_h_
-#define liblldb_OptionGroupUInt64_h_
+#ifndef LLDB_INTERPRETER_OPTIONGROUPUINT64_H
+#define LLDB_INTERPRETER_OPTIONGROUPUINT64_H
#include "lldb/Interpreter/OptionValueUInt64.h"
#include "lldb/Interpreter/Options.h"
@@ -46,4 +46,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionGroupUInt64_h_
+#endif // LLDB_INTERPRETER_OPTIONGROUPUINT64_H
diff --git a/lldb/include/lldb/Interpreter/OptionGroupUUID.h b/lldb/include/lldb/Interpreter/OptionGroupUUID.h
index 22fc3a100c75..b1c779f7b5a4 100644
--- a/lldb/include/lldb/Interpreter/OptionGroupUUID.h
+++ b/lldb/include/lldb/Interpreter/OptionGroupUUID.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionGroupUUID_h_
-#define liblldb_OptionGroupUUID_h_
+#ifndef LLDB_INTERPRETER_OPTIONGROUPUUID_H
+#define LLDB_INTERPRETER_OPTIONGROUPUUID_H
#include "lldb/Interpreter/OptionValueUUID.h"
#include "lldb/Interpreter/Options.h"
@@ -38,4 +38,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionGroupUUID_h_
+#endif // LLDB_INTERPRETER_OPTIONGROUPUUID_H
diff --git a/lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h b/lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h
index 5a1bbc9e7b66..1ad53321d26e 100644
--- a/lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h
+++ b/lldb/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionGroupValueObjectDisplay_h_
-#define liblldb_OptionGroupValueObjectDisplay_h_
+#ifndef LLDB_INTERPRETER_OPTIONGROUPVALUEOBJECTDISPLAY_H
+#define LLDB_INTERPRETER_OPTIONGROUPVALUEOBJECTDISPLAY_H
#include "lldb/Core/ValueObject.h"
#include "lldb/Interpreter/Options.h"
@@ -55,4 +55,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_OptionGroupValueObjectDisplay_h_
+#endif // LLDB_INTERPRETER_OPTIONGROUPVALUEOBJECTDISPLAY_H
diff --git a/lldb/include/lldb/Interpreter/OptionGroupVariable.h b/lldb/include/lldb/Interpreter/OptionGroupVariable.h
index 0c042f4c1cdb..252ca3b42c5e 100644
--- a/lldb/include/lldb/Interpreter/OptionGroupVariable.h
+++ b/lldb/include/lldb/Interpreter/OptionGroupVariable.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionGroupVariable_h_
-#define liblldb_OptionGroupVariable_h_
+#ifndef LLDB_INTERPRETER_OPTIONGROUPVARIABLE_H
+#define LLDB_INTERPRETER_OPTIONGROUPVARIABLE_H
#include "lldb/Interpreter/OptionValueString.h"
#include "lldb/Interpreter/Options.h"
@@ -41,9 +41,10 @@ public:
OptionValueString summary_string; // a summary string
private:
- DISALLOW_COPY_AND_ASSIGN(OptionGroupVariable);
+ OptionGroupVariable(const OptionGroupVariable &) = delete;
+ const OptionGroupVariable &operator=(const OptionGroupVariable &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_OptionGroupVariable_h_
+#endif // LLDB_INTERPRETER_OPTIONGROUPVARIABLE_H
diff --git a/lldb/include/lldb/Interpreter/OptionGroupWatchpoint.h b/lldb/include/lldb/Interpreter/OptionGroupWatchpoint.h
index 3729c000b8e0..6a6c8638aede 100644
--- a/lldb/include/lldb/Interpreter/OptionGroupWatchpoint.h
+++ b/lldb/include/lldb/Interpreter/OptionGroupWatchpoint.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionGroupWatchpoint_h_
-#define liblldb_OptionGroupWatchpoint_h_
+#ifndef LLDB_INTERPRETER_OPTIONGROUPWATCHPOINT_H
+#define LLDB_INTERPRETER_OPTIONGROUPWATCHPOINT_H
#include "lldb/Interpreter/Options.h"
@@ -46,9 +46,11 @@ public:
bool watch_type_specified;
private:
- DISALLOW_COPY_AND_ASSIGN(OptionGroupWatchpoint);
+ OptionGroupWatchpoint(const OptionGroupWatchpoint &) = delete;
+ const OptionGroupWatchpoint &
+ operator=(const OptionGroupWatchpoint &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_OptionGroupWatchpoint_h_
+#endif // LLDB_INTERPRETER_OPTIONGROUPWATCHPOINT_H
diff --git a/lldb/include/lldb/Interpreter/OptionValue.h b/lldb/include/lldb/Interpreter/OptionValue.h
index 44c7f621a582..5b07427094bf 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValue_h_
-#define liblldb_OptionValue_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUE_H
+#define LLDB_INTERPRETER_OPTIONVALUE_H
#include "lldb/Core/FormatEntity.h"
#include "lldb/Utility/CompletionRequest.h"
@@ -326,4 +326,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValue_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUE_H
diff --git a/lldb/include/lldb/Interpreter/OptionValueArch.h b/lldb/include/lldb/Interpreter/OptionValueArch.h
index 3923e3d3dba4..7b63c68fddbf 100644
--- a/lldb/include/lldb/Interpreter/OptionValueArch.h
+++ b/lldb/include/lldb/Interpreter/OptionValueArch.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValueArch_h_
-#define liblldb_OptionValueArch_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUEARCH_H
+#define LLDB_INTERPRETER_OPTIONVALUEARCH_H
#include "lldb/Interpreter/OptionValue.h"
#include "lldb/Utility/ArchSpec.h"
@@ -81,4 +81,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueArch_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUEARCH_H
diff --git a/lldb/include/lldb/Interpreter/OptionValueArgs.h b/lldb/include/lldb/Interpreter/OptionValueArgs.h
index 0254b9aa7e14..25f7fdde0bf3 100644
--- a/lldb/include/lldb/Interpreter/OptionValueArgs.h
+++ b/lldb/include/lldb/Interpreter/OptionValueArgs.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValueArgs_h_
-#define liblldb_OptionValueArgs_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUEARGS_H
+#define LLDB_INTERPRETER_OPTIONVALUEARGS_H
#include "lldb/Interpreter/OptionValueArray.h"
@@ -28,4 +28,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_OptionValueArgs_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUEARGS_H
diff --git a/lldb/include/lldb/Interpreter/OptionValueArray.h b/lldb/include/lldb/Interpreter/OptionValueArray.h
index 10f3bf5f729f..000351c2f586 100644
--- a/lldb/include/lldb/Interpreter/OptionValueArray.h
+++ b/lldb/include/lldb/Interpreter/OptionValueArray.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValueArray_h_
-#define liblldb_OptionValueArray_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUEARRAY_H
+#define LLDB_INTERPRETER_OPTIONVALUEARRAY_H
#include <vector>
@@ -125,4 +125,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueArray_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUEARRAY_H
diff --git a/lldb/include/lldb/Interpreter/OptionValueBoolean.h b/lldb/include/lldb/Interpreter/OptionValueBoolean.h
index 42b2ca4d2845..d221f6d034c2 100644
--- a/lldb/include/lldb/Interpreter/OptionValueBoolean.h
+++ b/lldb/include/lldb/Interpreter/OptionValueBoolean.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValueBoolean_h_
-#define liblldb_OptionValueBoolean_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUEBOOLEAN_H
+#define LLDB_INTERPRETER_OPTIONVALUEBOOLEAN_H
#include "lldb/Interpreter/OptionValue.h"
@@ -85,4 +85,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueBoolean_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUEBOOLEAN_H
diff --git a/lldb/include/lldb/Interpreter/OptionValueChar.h b/lldb/include/lldb/Interpreter/OptionValueChar.h
index d8661363751b..8d0aa91d7076 100644
--- a/lldb/include/lldb/Interpreter/OptionValueChar.h
+++ b/lldb/include/lldb/Interpreter/OptionValueChar.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValueChar_h_
-#define liblldb_OptionValueChar_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUECHAR_H
+#define LLDB_INTERPRETER_OPTIONVALUECHAR_H
#include "lldb/Interpreter/OptionValue.h"
@@ -68,4 +68,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueChar_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUECHAR_H
diff --git a/lldb/include/lldb/Interpreter/OptionValueDictionary.h b/lldb/include/lldb/Interpreter/OptionValueDictionary.h
index 8785d38f5423..1bc45252607c 100644
--- a/lldb/include/lldb/Interpreter/OptionValueDictionary.h
+++ b/lldb/include/lldb/Interpreter/OptionValueDictionary.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValueDictionary_h_
-#define liblldb_OptionValueDictionary_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUEDICTIONARY_H
+#define LLDB_INTERPRETER_OPTIONVALUEDICTIONARY_H
#include <map>
@@ -81,4 +81,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueDictionary_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUEDICTIONARY_H
diff --git a/lldb/include/lldb/Interpreter/OptionValueEnumeration.h b/lldb/include/lldb/Interpreter/OptionValueEnumeration.h
index eb19737f8653..26ba7ad5f646 100644
--- a/lldb/include/lldb/Interpreter/OptionValueEnumeration.h
+++ b/lldb/include/lldb/Interpreter/OptionValueEnumeration.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValueEnumeration_h_
-#define liblldb_OptionValueEnumeration_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUEENUMERATION_H
+#define LLDB_INTERPRETER_OPTIONVALUEENUMERATION_H
#include "lldb/Core/UniqueCStringMap.h"
#include "lldb/Interpreter/OptionValue.h"
@@ -83,4 +83,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueEnumeration_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUEENUMERATION_H
diff --git a/lldb/include/lldb/Interpreter/OptionValueFileSpec.h b/lldb/include/lldb/Interpreter/OptionValueFileSpec.h
index a6df18149076..2b18c9533f91 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFileSpec.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFileSpec.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValueFileSpec_h_
-#define liblldb_OptionValueFileSpec_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUEFILESPEC_H
+#define LLDB_INTERPRETER_OPTIONVALUEFILESPEC_H
#include "lldb/Interpreter/OptionValue.h"
@@ -86,4 +86,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueFileSpec_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUEFILESPEC_H
diff --git a/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h b/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
index 5607437fd0dc..7b762bf6b309 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValueFileSpecList_h_
-#define liblldb_OptionValueFileSpecList_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUEFILESPECLIST_H
+#define LLDB_INTERPRETER_OPTIONVALUEFILESPECLIST_H
#include <mutex>
@@ -74,4 +74,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueFileSpecList_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUEFILESPECLIST_H
diff --git a/lldb/include/lldb/Interpreter/OptionValueFormat.h b/lldb/include/lldb/Interpreter/OptionValueFormat.h
index 020f4aeda17a..6904c93a2f33 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFormat.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFormat.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValueFormat_h_
-#define liblldb_OptionValueFormat_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUEFORMAT_H
+#define LLDB_INTERPRETER_OPTIONVALUEFORMAT_H
#include "lldb/Interpreter/OptionValue.h"
@@ -63,4 +63,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueFormat_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUEFORMAT_H
diff --git a/lldb/include/lldb/Interpreter/OptionValueFormatEntity.h b/lldb/include/lldb/Interpreter/OptionValueFormatEntity.h
index 419ff5c03e3a..beb5d6843a98 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFormatEntity.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFormatEntity.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValueFormatEntity_h_
-#define liblldb_OptionValueFormatEntity_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUEFORMATENTITY_H
+#define LLDB_INTERPRETER_OPTIONVALUEFORMATENTITY_H
#include "lldb/Core/FormatEntity.h"
#include "lldb/Interpreter/OptionValue.h"
@@ -64,4 +64,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueFormatEntity_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUEFORMATENTITY_H
diff --git a/lldb/include/lldb/Interpreter/OptionValueLanguage.h b/lldb/include/lldb/Interpreter/OptionValueLanguage.h
index 505dc89e9208..f4ca2fd69ab5 100644
--- a/lldb/include/lldb/Interpreter/OptionValueLanguage.h
+++ b/lldb/include/lldb/Interpreter/OptionValueLanguage.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValueLanguage_h_
-#define liblldb_OptionValueLanguage_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUELANGUAGE_H
+#define LLDB_INTERPRETER_OPTIONVALUELANGUAGE_H
#include "lldb/Interpreter/OptionValue.h"
#include "lldb/lldb-enumerations.h"
@@ -66,4 +66,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueLanguage_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUELANGUAGE_H
diff --git a/lldb/include/lldb/Interpreter/OptionValuePathMappings.h b/lldb/include/lldb/Interpreter/OptionValuePathMappings.h
index 35c2af45bc97..18f5cbaf4336 100644
--- a/lldb/include/lldb/Interpreter/OptionValuePathMappings.h
+++ b/lldb/include/lldb/Interpreter/OptionValuePathMappings.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValuePathMappings_h_
-#define liblldb_OptionValuePathMappings_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUEPATHMAPPINGS_H
+#define LLDB_INTERPRETER_OPTIONVALUEPATHMAPPINGS_H
#include "lldb/Interpreter/OptionValue.h"
#include "lldb/Target/PathMappingList.h"
@@ -58,4 +58,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValuePathMappings_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUEPATHMAPPINGS_H
diff --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h b/lldb/include/lldb/Interpreter/OptionValueProperties.h
index 980f01183ef5..76f09cc77123 100644
--- a/lldb/include/lldb/Interpreter/OptionValueProperties.h
+++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValueProperties_h_
-#define liblldb_OptionValueProperties_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUEPROPERTIES_H
+#define LLDB_INTERPRETER_OPTIONVALUEPROPERTIES_H
#include <vector>
@@ -218,4 +218,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueProperties_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUEPROPERTIES_H
diff --git a/lldb/include/lldb/Interpreter/OptionValueRegex.h b/lldb/include/lldb/Interpreter/OptionValueRegex.h
index 8c10dacb0313..b09b8414d5bf 100644
--- a/lldb/include/lldb/Interpreter/OptionValueRegex.h
+++ b/lldb/include/lldb/Interpreter/OptionValueRegex.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValueRegex_h_
-#define liblldb_OptionValueRegex_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUEREGEX_H
+#define LLDB_INTERPRETER_OPTIONVALUEREGEX_H
#include "lldb/Interpreter/OptionValue.h"
#include "lldb/Utility/RegularExpression.h"
@@ -17,7 +17,8 @@ namespace lldb_private {
class OptionValueRegex : public OptionValue {
public:
OptionValueRegex(const char *value = nullptr)
- : OptionValue(), m_regex(llvm::StringRef::withNullAsEmpty(value)) {}
+ : OptionValue(), m_regex(llvm::StringRef::withNullAsEmpty(value)),
+ m_default_regex_str(llvm::StringRef::withNullAsEmpty(value).str()) {}
~OptionValueRegex() override = default;
@@ -36,7 +37,7 @@ public:
VarSetOperationType = eVarSetOperationAssign) = delete;
bool Clear() override {
- m_regex = RegularExpression();
+ m_regex = RegularExpression(m_default_regex_str);
m_value_was_set = false;
return true;
}
@@ -59,8 +60,9 @@ public:
protected:
RegularExpression m_regex;
+ std::string m_default_regex_str;
};
} // namespace lldb_private
-#endif // liblldb_OptionValueRegex_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUEREGEX_H
diff --git a/lldb/include/lldb/Interpreter/OptionValueSInt64.h b/lldb/include/lldb/Interpreter/OptionValueSInt64.h
index c2e8ff43a99a..fbabaaeb2ff4 100644
--- a/lldb/include/lldb/Interpreter/OptionValueSInt64.h
+++ b/lldb/include/lldb/Interpreter/OptionValueSInt64.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValueSInt64_h_
-#define liblldb_OptionValueSInt64_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUESINT64_H
+#define LLDB_INTERPRETER_OPTIONVALUESINT64_H
#include "lldb/Interpreter/OptionValue.h"
@@ -102,4 +102,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueSInt64_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUESINT64_H
diff --git a/lldb/include/lldb/Interpreter/OptionValueString.h b/lldb/include/lldb/Interpreter/OptionValueString.h
index d9e76d8b58fe..cd371c567020 100644
--- a/lldb/include/lldb/Interpreter/OptionValueString.h
+++ b/lldb/include/lldb/Interpreter/OptionValueString.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValueString_h_
-#define liblldb_OptionValueString_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUESTRING_H
+#define LLDB_INTERPRETER_OPTIONVALUESTRING_H
#include <string>
@@ -136,4 +136,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueString_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUESTRING_H
diff --git a/lldb/include/lldb/Interpreter/OptionValueUInt64.h b/lldb/include/lldb/Interpreter/OptionValueUInt64.h
index 5978cdb4434f..0096e87de367 100644
--- a/lldb/include/lldb/Interpreter/OptionValueUInt64.h
+++ b/lldb/include/lldb/Interpreter/OptionValueUInt64.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValueUInt64_h_
-#define liblldb_OptionValueUInt64_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUEUINT64_H
+#define LLDB_INTERPRETER_OPTIONVALUEUINT64_H
#include "lldb/Interpreter/OptionValue.h"
@@ -79,4 +79,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueUInt64_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUEUINT64_H
diff --git a/lldb/include/lldb/Interpreter/OptionValueUUID.h b/lldb/include/lldb/Interpreter/OptionValueUUID.h
index 576440d80519..2fb8caa3aa53 100644
--- a/lldb/include/lldb/Interpreter/OptionValueUUID.h
+++ b/lldb/include/lldb/Interpreter/OptionValueUUID.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValueUUID_h_
-#define liblldb_OptionValueUUID_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUEUUID_H
+#define LLDB_INTERPRETER_OPTIONVALUEUUID_H
#include "lldb/Utility/UUID.h"
#include "lldb/Interpreter/OptionValue.h"
@@ -61,4 +61,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_OptionValueUUID_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUEUUID_H
diff --git a/lldb/include/lldb/Interpreter/OptionValues.h b/lldb/include/lldb/Interpreter/OptionValues.h
index d90b2867a4b0..36e7c192d60a 100644
--- a/lldb/include/lldb/Interpreter/OptionValues.h
+++ b/lldb/include/lldb/Interpreter/OptionValues.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OptionValues_h_
-#define liblldb_OptionValues_h_
+#ifndef LLDB_INTERPRETER_OPTIONVALUES_H
+#define LLDB_INTERPRETER_OPTIONVALUES_H
#include "lldb/Interpreter/OptionValue.h"
#include "lldb/Interpreter/OptionValueArch.h"
@@ -30,4 +30,4 @@
#include "lldb/Interpreter/OptionValueUInt64.h"
#include "lldb/Interpreter/OptionValueUUID.h"
-#endif // liblldb_OptionValues_h_
+#endif // LLDB_INTERPRETER_OPTIONVALUES_H
diff --git a/lldb/include/lldb/Interpreter/Options.h b/lldb/include/lldb/Interpreter/Options.h
index d07c2560ef2d..ebceaea8383d 100644
--- a/lldb/include/lldb/Interpreter/Options.h
+++ b/lldb/include/lldb/Interpreter/Options.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Options_h_
-#define liblldb_Options_h_
+#ifndef LLDB_INTERPRETER_OPTIONS_H
+#define LLDB_INTERPRETER_OPTIONS_H
#include <set>
#include <vector>
@@ -43,7 +43,7 @@ typedef std::vector<OptionArgElement> OptionElementVector;
static inline bool isprint8(int ch) {
if (ch & 0xffffff00u)
return false;
- return isprint(ch);
+ return llvm::isPrint(ch);
}
/// \class Options Options.h "lldb/Interpreter/Options.h"
@@ -328,4 +328,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_Options_h_
+#endif // LLDB_INTERPRETER_OPTIONS_H
diff --git a/lldb/include/lldb/Interpreter/Property.h b/lldb/include/lldb/Interpreter/Property.h
index 76264832705b..97ec7ca1d4af 100644
--- a/lldb/include/lldb/Interpreter/Property.h
+++ b/lldb/include/lldb/Interpreter/Property.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Property_h_
-#define liblldb_Property_h_
+#ifndef LLDB_INTERPRETER_PROPERTY_H
+#define LLDB_INTERPRETER_PROPERTY_H
#include "lldb/Interpreter/OptionValue.h"
#include "lldb/Utility/ConstString.h"
@@ -75,4 +75,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_Property_h_
+#endif // LLDB_INTERPRETER_PROPERTY_H
diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
index 1784c93adbac..491923e6a6c4 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
@@ -6,19 +6,19 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ScriptInterpreter_h_
-#define liblldb_ScriptInterpreter_h_
-
-#include "lldb/lldb-private.h"
+#ifndef LLDB_INTERPRETER_SCRIPTINTERPRETER_H
+#define LLDB_INTERPRETER_SCRIPTINTERPRETER_H
#include "lldb/Breakpoint/BreakpointOptions.h"
+#include "lldb/Core/Communication.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/SearchFilter.h"
+#include "lldb/Core/StreamFile.h"
+#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Utility/Broadcaster.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StructuredData.h"
-
-#include "lldb/Host/PseudoTerminal.h"
+#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -29,7 +29,38 @@ public:
virtual ~ScriptInterpreterLocker() = default;
private:
- DISALLOW_COPY_AND_ASSIGN(ScriptInterpreterLocker);
+ ScriptInterpreterLocker(const ScriptInterpreterLocker &) = delete;
+ const ScriptInterpreterLocker &
+ operator=(const ScriptInterpreterLocker &) = delete;
+};
+
+class ScriptInterpreterIORedirect {
+public:
+ /// Create an IO redirect. If IO is enabled, this will redirects the output
+ /// to the command return object if set or to the debugger otherwise. If IO
+ /// is disabled, it will redirect all IO to /dev/null.
+ static llvm::Expected<std::unique_ptr<ScriptInterpreterIORedirect>>
+ Create(bool enable_io, Debugger &debugger, CommandReturnObject *result);
+
+ ~ScriptInterpreterIORedirect();
+
+ lldb::FileSP GetInputFile() const { return m_input_file_sp; }
+ lldb::FileSP GetOutputFile() const { return m_output_file_sp->GetFileSP(); }
+ lldb::FileSP GetErrorFile() const { return m_error_file_sp->GetFileSP(); }
+
+ /// Flush our output and error file handles.
+ void Flush();
+
+private:
+ ScriptInterpreterIORedirect(std::unique_ptr<File> input,
+ std::unique_ptr<File> output);
+ ScriptInterpreterIORedirect(Debugger &debugger, CommandReturnObject *result);
+
+ lldb::FileSP m_input_file_sp;
+ lldb::StreamFileSP m_output_file_sp;
+ lldb::StreamFileSP m_error_file_sp;
+ Communication m_communication;
+ bool m_disconnect;
};
class ScriptInterpreter : public PluginInterface {
@@ -467,8 +498,6 @@ public:
const char *GetScriptInterpreterPtyName();
- int GetMasterFileDescriptor();
-
virtual llvm::Expected<unsigned>
GetMaxPositionalArgumentsForCallable(const llvm::StringRef &callable_name) {
return llvm::createStringError(
@@ -488,4 +517,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_ScriptInterpreter_h_
+#endif // LLDB_INTERPRETER_SCRIPTINTERPRETER_H
diff --git a/lldb/include/lldb/Symbol/ArmUnwindInfo.h b/lldb/include/lldb/Symbol/ArmUnwindInfo.h
index a74b4442df14..24f9f1a0a61f 100644
--- a/lldb/include/lldb/Symbol/ArmUnwindInfo.h
+++ b/lldb/include/lldb/Symbol/ArmUnwindInfo.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ArmUnwindInfo_h_
-#define liblldb_ArmUnwindInfo_h_
+#ifndef LLDB_SYMBOL_ARMUNWINDINFO_H
+#define LLDB_SYMBOL_ARMUNWINDINFO_H
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Utility/DataExtractor.h"
@@ -65,4 +65,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ArmUnwindInfo_h_
+#endif // LLDB_SYMBOL_ARMUNWINDINFO_H
diff --git a/lldb/include/lldb/Symbol/Block.h b/lldb/include/lldb/Symbol/Block.h
index c2760dddf45f..de94556d3f22 100644
--- a/lldb/include/lldb/Symbol/Block.h
+++ b/lldb/include/lldb/Symbol/Block.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Block_h_
-#define liblldb_Block_h_
+#ifndef LLDB_SYMBOL_BLOCK_H
+#define LLDB_SYMBOL_BLOCK_H
#include "lldb/Core/AddressRange.h"
#include "lldb/Symbol/CompilerType.h"
@@ -40,7 +40,7 @@ namespace lldb_private {
/// blocks.
class Block : public UserID, public SymbolContextScope {
public:
- typedef RangeArray<uint32_t, uint32_t, 1> RangeList;
+ typedef RangeVector<uint32_t, uint32_t, 1> RangeList;
typedef RangeList::Entry Range;
/// Construct with a User ID \a uid, \a depth.
@@ -376,9 +376,10 @@ protected:
Block *GetSiblingForChild(const Block *child_block) const;
private:
- DISALLOW_COPY_AND_ASSIGN(Block);
+ Block(const Block &) = delete;
+ const Block &operator=(const Block &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Block_h_
+#endif // LLDB_SYMBOL_BLOCK_H
diff --git a/lldb/include/lldb/Symbol/CallFrameInfo.h b/lldb/include/lldb/Symbol/CallFrameInfo.h
index 765ddb41ab0c..7db8722baaf5 100644
--- a/lldb/include/lldb/Symbol/CallFrameInfo.h
+++ b/lldb/include/lldb/Symbol/CallFrameInfo.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CallFrameInfo_h_
-#define liblldb_CallFrameInfo_h_
+#ifndef LLDB_SYMBOL_CALLFRAMEINFO_H
+#define LLDB_SYMBOL_CALLFRAMEINFO_H
#include "lldb/Core/Address.h"
@@ -25,4 +25,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_CallFrameInfo_h_
+#endif // LLDB_SYMBOL_CALLFRAMEINFO_H
diff --git a/lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h b/lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
deleted file mode 100644
index 290ecc9b9017..000000000000
--- a/lldb/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
+++ /dev/null
@@ -1,46 +0,0 @@
-//===-- ClangExternalASTSourceCallbacks.h -----------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_ClangExternalASTSourceCallbacks_h_
-#define liblldb_ClangExternalASTSourceCallbacks_h_
-
-#include "lldb/Symbol/ClangASTContext.h"
-#include "clang/AST/ExternalASTSource.h"
-
-namespace lldb_private {
-
-class ClangASTContext;
-
-class ClangExternalASTSourceCallbacks : public clang::ExternalASTSource {
-public:
- ClangExternalASTSourceCallbacks(ClangASTContext &ast) : m_ast(ast) {}
-
- void FindExternalLexicalDecls(
- const clang::DeclContext *DC,
- llvm::function_ref<bool(clang::Decl::Kind)> IsKindWeWant,
- llvm::SmallVectorImpl<clang::Decl *> &Result) override;
-
- void CompleteType(clang::TagDecl *tag_decl) override;
-
- void CompleteType(clang::ObjCInterfaceDecl *objc_decl) override;
-
- bool layoutRecordType(
- const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
- llvm::DenseMap<const clang::FieldDecl *, uint64_t> &FieldOffsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
- &BaseOffsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
- &VirtualBaseOffsets) override;
-
-private:
- ClangASTContext &m_ast;
-};
-
-} // namespace lldb_private
-
-#endif // liblldb_ClangExternalASTSourceCallbacks_h_
diff --git a/lldb/include/lldb/Symbol/CompactUnwindInfo.h b/lldb/include/lldb/Symbol/CompactUnwindInfo.h
index 2646661ec237..e622c5fde229 100644
--- a/lldb/include/lldb/Symbol/CompactUnwindInfo.h
+++ b/lldb/include/lldb/Symbol/CompactUnwindInfo.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CompactUnwindInfo_h_
-#define liblldb_CompactUnwindInfo_h_
+#ifndef LLDB_SYMBOL_COMPACTUNWINDINFO_H
+#define LLDB_SYMBOL_COMPACTUNWINDINFO_H
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/UnwindPlan.h"
@@ -164,4 +164,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_CompactUnwindInfo_h_
+#endif // LLDB_SYMBOL_COMPACTUNWINDINFO_H
diff --git a/lldb/include/lldb/Symbol/CompileUnit.h b/lldb/include/lldb/Symbol/CompileUnit.h
index aec5cc7c8743..256148f20d12 100644
--- a/lldb/include/lldb/Symbol/CompileUnit.h
+++ b/lldb/include/lldb/Symbol/CompileUnit.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CompUnit_h_
-#define liblldb_CompUnit_h_
+#ifndef LLDB_SYMBOL_COMPILEUNIT_H
+#define LLDB_SYMBOL_COMPILEUNIT_H
#include "lldb/Core/FileSpecList.h"
#include "lldb/Core/ModuleChild.h"
@@ -447,9 +447,10 @@ private:
(1u << 6) ///< Have we parsed the debug macros already?
};
- DISALLOW_COPY_AND_ASSIGN(CompileUnit);
+ CompileUnit(const CompileUnit &) = delete;
+ const CompileUnit &operator=(const CompileUnit &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_CompUnit_h_
+#endif // LLDB_SYMBOL_COMPILEUNIT_H
diff --git a/lldb/include/lldb/Symbol/CompilerDecl.h b/lldb/include/lldb/Symbol/CompilerDecl.h
index 4fd269d4730e..67290b9be066 100644
--- a/lldb/include/lldb/Symbol/CompilerDecl.h
+++ b/lldb/include/lldb/Symbol/CompilerDecl.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CompilerDecl_h_
-#define liblldb_CompilerDecl_h_
+#ifndef LLDB_SYMBOL_COMPILERDECL_H
+#define LLDB_SYMBOL_COMPILERDECL_H
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Utility/ConstString.h"
@@ -94,4 +94,4 @@ bool operator!=(const CompilerDecl &lhs, const CompilerDecl &rhs);
} // namespace lldb_private
-#endif // #ifndef liblldb_CompilerDecl_h_
+#endif // LLDB_SYMBOL_COMPILERDECL_H
diff --git a/lldb/include/lldb/Symbol/CompilerDeclContext.h b/lldb/include/lldb/Symbol/CompilerDeclContext.h
index 6db6f4d3f623..87d4ca30884e 100644
--- a/lldb/include/lldb/Symbol/CompilerDeclContext.h
+++ b/lldb/include/lldb/Symbol/CompilerDeclContext.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CompilerDeclContext_h_
-#define liblldb_CompilerDeclContext_h_
+#ifndef LLDB_SYMBOL_COMPILERDECLCONTEXT_H
+#define LLDB_SYMBOL_COMPILERDECLCONTEXT_H
#include <vector>
@@ -38,7 +38,7 @@ public:
/// This constructor should only be called from the respective TypeSystem
/// implementation.
///
- /// \see lldb_private::ClangASTContext::CreateDeclContext(clang::DeclContext*)
+ /// \see lldb_private::TypeSystemClang::CreateDeclContext(clang::DeclContext*)
CompilerDeclContext(TypeSystem *type_system, void *decl_ctx)
: m_type_system(type_system), m_opaque_decl_ctx(decl_ctx) {}
@@ -126,4 +126,4 @@ bool operator!=(const CompilerDeclContext &lhs, const CompilerDeclContext &rhs);
} // namespace lldb_private
-#endif // #ifndef liblldb_CompilerDeclContext_h_
+#endif // LLDB_SYMBOL_COMPILERDECLCONTEXT_H
diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h
index 37e826291c88..280966a327ec 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CompilerType_h_
-#define liblldb_CompilerType_h_
+#ifndef LLDB_SYMBOL_COMPILERTYPE_H
+#define LLDB_SYMBOL_COMPILERTYPE_H
#include <functional>
#include <string>
@@ -37,34 +37,37 @@ public:
/// This constructor should only be called from the respective TypeSystem
/// implementation.
///
- /// \see lldb_private::ClangASTContext::GetType(clang::QualType)
+ /// \see lldb_private::TypeSystemClang::GetType(clang::QualType)
CompilerType(TypeSystem *type_system, lldb::opaque_compiler_type_t type)
- : m_type(type), m_type_system(type_system) {}
+ : m_type(type), m_type_system(type_system) {
+ assert(Verify() && "verification failed");
+ }
CompilerType(const CompilerType &rhs)
: m_type(rhs.m_type), m_type_system(rhs.m_type_system) {}
CompilerType() = default;
- // Operators
-
+ /// Operators.
+ /// \{
const CompilerType &operator=(const CompilerType &rhs) {
m_type = rhs.m_type;
m_type_system = rhs.m_type_system;
return *this;
}
- // Tests
-
- explicit operator bool() const {
- return m_type != nullptr && m_type_system != nullptr;
- }
-
bool operator<(const CompilerType &rhs) const {
if (m_type_system == rhs.m_type_system)
return m_type < rhs.m_type;
return m_type_system < rhs.m_type_system;
}
+ /// \}
+
+ /// Tests.
+ /// \{
+ explicit operator bool() const {
+ return m_type != nullptr && m_type_system != nullptr;
+ }
bool IsValid() const { return m_type != nullptr && m_type_system != nullptr; }
@@ -115,8 +118,9 @@ public:
bool IsPolymorphicClass() const;
- bool IsPossibleDynamicType(CompilerType *target_type, // Can pass nullptr
- bool check_cplusplus, bool check_objc) const;
+ /// \param target_type Can pass nullptr.
+ bool IsPossibleDynamicType(CompilerType *target_type, bool check_cplusplus,
+ bool check_objc) const;
bool IsPointerToScalarType() const;
@@ -136,23 +140,22 @@ public:
bool IsTypedefType() const;
bool IsVoidType() const;
+ /// \}
- // Type Completion
-
+ /// Type Completion.
+ /// \{
bool GetCompleteType() const;
+ /// \}
- // AST related queries
-
+ /// AST related queries.
+ /// \{
size_t GetPointerByteSize() const;
+ /// \}
- // Accessors
-
+ /// Accessors.
+ /// \{
TypeSystem *GetTypeSystem() const { return m_type_system; }
- ConstString GetConstQualifiedTypeName() const;
-
- ConstString GetConstTypeName() const;
-
ConstString GetTypeName() const;
ConstString GetDisplayTypeName() const;
@@ -170,9 +173,10 @@ public:
lldb::opaque_compiler_type_t type);
unsigned GetTypeQualifiers() const;
+ /// \}
- // Creating related types
-
+ /// Creating related types.
+ /// \{
CompilerType GetArrayElementType(uint64_t *stride = nullptr) const;
CompilerType GetArrayType(uint64_t size) const;
@@ -181,8 +185,8 @@ public:
CompilerType GetFullyUnqualifiedType() const;
- // Returns -1 if this isn't a function of if the function doesn't have a
- // prototype Returns a value >= 0 if there is a prototype.
+ /// Returns -1 if this isn't a function of if the function doesn't
+ /// have a prototype Returns a value >= 0 if there is a prototype.
int GetFunctionArgumentCount() const;
CompilerType GetFunctionArgumentTypeAtIndex(size_t idx) const;
@@ -193,62 +197,65 @@ public:
TypeMemberFunctionImpl GetMemberFunctionAtIndex(size_t idx);
- // If this type is a reference to a type (L value or R value reference),
- // return a new type with the reference removed, else return the current type
- // itself.
+ /// If this type is a reference to a type (L value or R value reference),
+ /// return a new type with the reference removed, else return the current type
+ /// itself.
CompilerType GetNonReferenceType() const;
- // If this type is a pointer type, return the type that the pointer points
- // to, else return an invalid type.
+ /// If this type is a pointer type, return the type that the pointer points
+ /// to, else return an invalid type.
CompilerType GetPointeeType() const;
- // Return a new CompilerType that is a pointer to this type
+ /// Return a new CompilerType that is a pointer to this type
CompilerType GetPointerType() const;
- // Return a new CompilerType that is a L value reference to this type if this
- // type is valid and the type system supports L value references, else return
- // an invalid type.
+ /// 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.
+ /// 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.
+ /// 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.
+ /// 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 that is the atomic type of this type. If this
- // type is not valid or the type system doesn't support atomic types, this
- // returns an invalid type.
+ /// Return a new CompilerType that is the atomic type of this type. If this
+ /// type is not valid or the type system doesn't support atomic types, this
+ /// returns an invalid type.
CompilerType GetAtomicType() 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.
+ /// 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.
+ /// 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.
+ /// \param payload The typesystem-specific \p lldb::Type payload.
CompilerType CreateTypedef(const char *name,
- const CompilerDeclContext &decl_ctx) const;
+ const CompilerDeclContext &decl_ctx,
+ uint32_t payload) const;
- // If the current object represents a typedef type, get the underlying type
+ /// If the current object represents a typedef type, get the underlying type
CompilerType GetTypedefedType() const;
- // Create related types using the current type's AST
+ /// Create related types using the current type's AST
CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) const;
+ /// \}
- // Exploring the type
-
+ /// Exploring the type.
+ /// \{
struct IntegralTemplateArgument;
/// Return the size of the type in bytes.
@@ -260,7 +267,8 @@ public:
lldb::Format GetFormat() const;
- llvm::Optional<size_t> GetTypeBitAlign(ExecutionContextScope *exe_scope) const;
+ llvm::Optional<size_t>
+ GetTypeBitAlign(ExecutionContextScope *exe_scope) const;
uint32_t GetNumChildren(bool omit_empty_base_classes,
const ExecutionContext *exe_ctx) const;
@@ -269,12 +277,11 @@ public:
static lldb::BasicType GetBasicTypeEnumeration(ConstString name);
- // If this type is an enumeration, iterate through all of its enumerators
- // using a callback. If the callback returns true, keep iterating, else abort
- // the iteration.
+ /// 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,
- ConstString name,
+ std::function<bool(const CompilerType &integer_type, ConstString name,
const llvm::APSInt &value)> const &callback) const;
uint32_t GetNumFields() const;
@@ -309,17 +316,17 @@ public:
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.
+ /// Lookup a child given a name. This function will match base class names and
+ /// member member names in "clang_type" only, not descendants.
uint32_t GetIndexOfChildWithName(const char *name,
bool omit_empty_base_classes) const;
- // Lookup a child member given a name. This function will match member names
- // only and will descend into "clang_type" children in search for the first
- // member in this class, or any base class that matches "name".
- // TODO: Return all matches for a given name by returning a
- // vector<vector<uint32_t>>
- // so we catch all names that match a given child name, not just the first.
+ /// Lookup a child member given a name. This function will match member names
+ /// only and will descend into "clang_type" children in search for the first
+ /// member in this class, or any base class that matches "name".
+ /// TODO: Return all matches for a given name by returning a
+ /// vector<vector<uint32_t>>
+ /// so we catch all names that match a given child name, not just the first.
size_t
GetIndexOfChildMemberWithName(const char *name, bool omit_empty_base_classes,
std::vector<uint32_t> &child_indexes) const;
@@ -329,7 +336,7 @@ public:
lldb::TemplateArgumentKind GetTemplateArgumentKind(size_t idx) const;
CompilerType GetTypeTemplateArgument(size_t idx) const;
- // Returns the value of the template argument and its type.
+ /// Returns the value of the template argument and its type.
llvm::Optional<IntegralTemplateArgument>
GetIntegralTemplateArgument(size_t idx) const;
@@ -338,9 +345,10 @@ public:
LazyBool ShouldPrintAsOneLiner(ValueObject *valobj) const;
bool IsMeaninglessWithoutDynamicResolution() const;
+ /// \}
- // Dumping types
-
+ /// Dumping types.
+ /// \{
#ifndef NDEBUG
/// Convenience LLVM-style dump method for use in the debugger only.
/// Don't call this function from actual code.
@@ -362,19 +370,33 @@ public:
const DataExtractor &data, lldb::offset_t data_offset,
size_t data_byte_size);
- void DumpTypeDescription() const; // Dump to stdout
+ /// Dump to stdout.
+ void DumpTypeDescription(lldb::DescriptionLevel level =
+ lldb::eDescriptionLevelFull) const;
- void DumpTypeDescription(Stream *s) const;
+ /// Print a description of the type to a stream. The exact implementation
+ /// varies, but the expectation is that eDescriptionLevelFull returns a
+ /// source-like representation of the type, whereas eDescriptionLevelVerbose
+ /// does a dump of the underlying AST if applicable.
+ void DumpTypeDescription(Stream *s, lldb::DescriptionLevel level =
+ lldb::eDescriptionLevelFull) const;
+ /// \}
bool GetValueAsScalar(const DataExtractor &data, lldb::offset_t data_offset,
size_t data_byte_size, Scalar &value) const;
-
void Clear() {
m_type = nullptr;
m_type_system = nullptr;
}
private:
+#ifndef NDEBUG
+ /// If the type is valid, ask the TypeSystem to verify the integrity
+ /// of the type to catch CompilerTypes that mix and match invalid
+ /// TypeSystem/Opaque type pairs.
+ bool Verify() const;
+#endif
+
lldb::opaque_compiler_type_t m_type = nullptr;
TypeSystem *m_type_system = nullptr;
};
@@ -389,4 +411,4 @@ struct CompilerType::IntegralTemplateArgument {
} // namespace lldb_private
-#endif // liblldb_CompilerType_h_
+#endif // LLDB_SYMBOL_COMPILERTYPE_H
diff --git a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
index 104075f28df3..f85bc7e844a0 100644
--- a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
+++ b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DWARFCallFrameInfo_h_
-#define liblldb_DWARFCallFrameInfo_h_
+#ifndef LLDB_SYMBOL_DWARFCALLFRAMEINFO_H
+#define LLDB_SYMBOL_DWARFCALLFRAMEINFO_H
#include <map>
#include <mutex>
@@ -166,4 +166,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_DWARFCallFrameInfo_h_
+#endif // LLDB_SYMBOL_DWARFCALLFRAMEINFO_H
diff --git a/lldb/include/lldb/Symbol/DebugMacros.h b/lldb/include/lldb/Symbol/DebugMacros.h
index da46c8b23c1d..0ea70f5deb84 100644
--- a/lldb/include/lldb/Symbol/DebugMacros.h
+++ b/lldb/include/lldb/Symbol/DebugMacros.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DebugMacros_h_
-#define liblldb_DebugMacros_h_
+#ifndef LLDB_SYMBOL_DEBUGMACROS_H
+#define LLDB_SYMBOL_DEBUGMACROS_H
#include <memory>
#include <vector>
@@ -27,7 +27,6 @@ public:
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);
@@ -89,11 +88,12 @@ public:
}
private:
- DISALLOW_COPY_AND_ASSIGN(DebugMacros);
+ DebugMacros(const DebugMacros &) = delete;
+ const DebugMacros &operator=(const DebugMacros &) = delete;
std::vector<DebugMacroEntry> m_macro_entries;
};
} // namespace lldb_private
-#endif // liblldb_DebugMacros_h_
+#endif // LLDB_SYMBOL_DEBUGMACROS_H
diff --git a/lldb/include/lldb/Symbol/DeclVendor.h b/lldb/include/lldb/Symbol/DeclVendor.h
index 748c0c8ac961..67dcaf1734bd 100644
--- a/lldb/include/lldb/Symbol/DeclVendor.h
+++ b/lldb/include/lldb/Symbol/DeclVendor.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DeclVendor_h_
-#define liblldb_DeclVendor_h_
+#ifndef LLDB_SYMBOL_DECLVENDOR_H
+#define LLDB_SYMBOL_DECLVENDOR_H
#include "lldb/lldb-defines.h"
@@ -67,7 +67,8 @@ public:
private:
// For DeclVendor only
- DISALLOW_COPY_AND_ASSIGN(DeclVendor);
+ DeclVendor(const DeclVendor &) = delete;
+ const DeclVendor &operator=(const DeclVendor &) = delete;
const DeclVendorKind m_kind;
};
diff --git a/lldb/include/lldb/Symbol/Declaration.h b/lldb/include/lldb/Symbol/Declaration.h
index a751d6ba039f..7f19f45411a0 100644
--- a/lldb/include/lldb/Symbol/Declaration.h
+++ b/lldb/include/lldb/Symbol/Declaration.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Declaration_h_
-#define liblldb_Declaration_h_
+#ifndef LLDB_SYMBOL_DECLARATION_H
+#define LLDB_SYMBOL_DECLARATION_H
#include "lldb/Utility/FileSpec.h"
#include "lldb/lldb-private.h"
@@ -202,4 +202,4 @@ bool operator==(const Declaration &lhs, const Declaration &rhs);
} // namespace lldb_private
-#endif // liblldb_Declaration_h_
+#endif // LLDB_SYMBOL_DECLARATION_H
diff --git a/lldb/include/lldb/Symbol/FuncUnwinders.h b/lldb/include/lldb/Symbol/FuncUnwinders.h
index c49f6b0fa942..2e841b3b34bd 100644
--- a/lldb/include/lldb/Symbol/FuncUnwinders.h
+++ b/lldb/include/lldb/Symbol/FuncUnwinders.h
@@ -1,5 +1,5 @@
-#ifndef liblldb_FuncUnwinders_h
-#define liblldb_FuncUnwinders_h
+#ifndef LLDB_SYMBOL_FUNCUNWINDERS_H
+#define LLDB_SYMBOL_FUNCUNWINDERS_H
#include "lldb/Core/AddressRange.h"
#include "lldb/lldb-private-enumerations.h"
@@ -149,10 +149,11 @@ private:
Address m_first_non_prologue_insn;
- DISALLOW_COPY_AND_ASSIGN(FuncUnwinders);
+ FuncUnwinders(const FuncUnwinders &) = delete;
+ const FuncUnwinders &operator=(const FuncUnwinders &) = delete;
}; // class FuncUnwinders
} // namespace lldb_private
-#endif // liblldb_FuncUnwinders_h
+#endif // LLDB_SYMBOL_FUNCUNWINDERS_H
diff --git a/lldb/include/lldb/Symbol/Function.h b/lldb/include/lldb/Symbol/Function.h
index f675b5fdffa6..300d829219d4 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Function_h_
-#define liblldb_Function_h_
+#ifndef LLDB_SYMBOL_FUNCTION_H
+#define LLDB_SYMBOL_FUNCTION_H
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/Mangled.h"
@@ -17,6 +17,8 @@
#include "lldb/Utility/UserID.h"
#include "llvm/ADT/ArrayRef.h"
+#include <mutex>
+
namespace lldb_private {
class ExecutionContext;
@@ -113,10 +115,11 @@ public:
virtual size_t MemorySize() const;
protected:
- // Member variables.
- ConstString m_name; ///< Function method name (not a mangled name).
- Declaration m_declaration; ///< Information describing where this function
- ///information was defined.
+ /// Function method name (not a mangled name).
+ ConstString m_name;
+
+ /// Information describing where this function information was defined.
+ Declaration m_declaration;
};
/// \class InlineFunctionInfo Function.h "lldb/Symbol/Function.h"
@@ -199,11 +202,11 @@ public:
/// The stream to which to dump the object description.
void Dump(Stream *s, bool show_fullpaths) const;
- void DumpStopContext(Stream *s, lldb::LanguageType language) const;
+ void DumpStopContext(Stream *s) const;
- ConstString GetName(lldb::LanguageType language) const;
+ ConstString GetName() const;
- ConstString GetDisplayName(lldb::LanguageType language) const;
+ ConstString GetDisplayName() const;
/// Get accessor for the call site declaration information.
///
@@ -240,9 +243,10 @@ public:
size_t MemorySize() const override;
private:
- // Member variables.
- Mangled m_mangled; ///< Mangled inlined function name (can be empty if there
- ///is no mangled information).
+ /// Mangled inlined function name (can be empty if there is no mangled
+ /// information).
+ Mangled m_mangled;
+
Declaration m_call_decl;
};
@@ -266,6 +270,7 @@ using CallSiteParameterArray = llvm::SmallVector<CallSiteParameter, 0>;
/// in the call graph between two functions, or to evaluate DW_OP_entry_value.
class CallEdge {
public:
+ enum class AddrType : uint8_t { Call, AfterCall };
virtual ~CallEdge() {}
/// Get the callee's definition.
@@ -281,23 +286,50 @@ public:
/// made the call.
lldb::addr_t GetReturnPCAddress(Function &caller, Target &target) const;
- /// Like \ref GetReturnPCAddress, but returns an unslid function-local PC
- /// offset.
- lldb::addr_t GetUnresolvedReturnPCAddress() const { return return_pc; }
+ /// Return an address in the caller. This can either be the address of the
+ /// call instruction, or the address of the instruction after the call.
+ std::pair<AddrType, lldb::addr_t> GetCallerAddress(Function &caller,
+ Target &target) const {
+ return {caller_address_type,
+ GetLoadAddress(caller_address, caller, target)};
+ }
+
+ bool IsTailCall() const { return is_tail_call; }
/// Get the call site parameters available at this call edge.
llvm::ArrayRef<CallSiteParameter> GetCallSiteParameters() const {
return parameters;
}
+ /// Non-tail-calls go first, sorted by the return address. They are followed
+ /// by tail calls, which have no specific order.
+ std::pair<bool, lldb::addr_t> GetSortKey() const {
+ return {is_tail_call, GetUnresolvedReturnPCAddress()};
+ }
+
protected:
- CallEdge(lldb::addr_t return_pc, CallSiteParameterArray &&parameters)
- : return_pc(return_pc), parameters(std::move(parameters)) {}
+ CallEdge(AddrType caller_address_type, lldb::addr_t caller_address,
+ bool is_tail_call, CallSiteParameterArray &&parameters)
+ : caller_address(caller_address),
+ caller_address_type(caller_address_type), is_tail_call(is_tail_call),
+ parameters(std::move(parameters)) {}
+
+ /// Helper that finds the load address of \p unresolved_pc, a file address
+ /// which refers to an instruction within \p caller.
+ static lldb::addr_t GetLoadAddress(lldb::addr_t unresolved_pc,
+ Function &caller, Target &target);
+
+ /// Like \ref GetReturnPCAddress, but returns an unresolved file address.
+ lldb::addr_t GetUnresolvedReturnPCAddress() const {
+ return caller_address_type == AddrType::AfterCall && !is_tail_call
+ ? caller_address
+ : LLDB_INVALID_ADDRESS;
+ }
- /// An invalid address if this is a tail call. Otherwise, the function-local
- /// PC offset. Adding this PC offset to the function's base load address
- /// gives the return PC for the call.
- lldb::addr_t return_pc;
+private:
+ lldb::addr_t caller_address;
+ AddrType caller_address_type;
+ bool is_tail_call;
CallSiteParameterArray parameters;
};
@@ -309,9 +341,11 @@ class DirectCallEdge : public CallEdge {
public:
/// Construct a call edge using a symbol name to identify the callee, and a
/// return PC within the calling function to identify a specific call site.
- DirectCallEdge(const char *symbol_name, lldb::addr_t return_pc,
+ DirectCallEdge(const char *symbol_name, AddrType caller_address_type,
+ lldb::addr_t caller_address, bool is_tail_call,
CallSiteParameterArray &&parameters)
- : CallEdge(return_pc, std::move(parameters)) {
+ : CallEdge(caller_address_type, caller_address, is_tail_call,
+ std::move(parameters)) {
lazy_callee.symbol_name = symbol_name;
}
@@ -340,9 +374,11 @@ class IndirectCallEdge : public CallEdge {
public:
/// Construct a call edge using a DWARFExpression to identify the callee, and
/// a return PC within the calling function to identify a specific call site.
- IndirectCallEdge(DWARFExpression call_target, lldb::addr_t return_pc,
+ IndirectCallEdge(DWARFExpression call_target, AddrType caller_address_type,
+ lldb::addr_t caller_address, bool is_tail_call,
CallSiteParameterArray &&parameters)
- : CallEdge(return_pc, std::move(parameters)),
+ : CallEdge(caller_address_type, caller_address, is_tail_call,
+ std::move(parameters)),
call_target(std::move(call_target)) {}
Function *GetCallee(ModuleList &images, ExecutionContext &exe_ctx) override;
@@ -602,34 +638,55 @@ public:
protected:
enum {
- flagsCalculatedPrologueSize =
- (1 << 0) ///< Have we already tried to calculate the prologue size?
+ /// Whether we already tried to calculate the prologue size.
+ flagsCalculatedPrologueSize = (1 << 0)
};
- // Member variables.
- CompileUnit *m_comp_unit; ///< The compile unit that owns this function.
- lldb::user_id_t
- m_type_uid; ///< The user ID of for the prototype Type for this function.
- Type *m_type; ///< The function prototype type for this function that include
- ///the function info (FunctionInfo), return type and parameters.
- Mangled m_mangled; ///< The mangled function name if any, if empty, there is
- ///no mangled information.
- Block m_block; ///< All lexical blocks contained in this function.
- AddressRange m_range; ///< The function address range that covers the widest
- ///range needed to contain all blocks
- DWARFExpression m_frame_base; ///< The frame base expression for variables
- ///that are relative to the frame pointer.
+ /// The compile unit that owns this function.
+ CompileUnit *m_comp_unit;
+
+ /// The user ID of for the prototype Type for this function.
+ lldb::user_id_t m_type_uid;
+
+ /// The function prototype type for this function that includes the function
+ /// info (FunctionInfo), return type and parameters.
+ Type *m_type;
+
+ /// The mangled function name if any. If empty, there is no mangled
+ /// information.
+ Mangled m_mangled;
+
+ /// All lexical blocks contained in this function.
+ Block m_block;
+
+ /// The function address range that covers the widest range needed to contain
+ /// all blocks
+ AddressRange m_range;
+
+ /// The frame base expression for variables that are relative to the frame
+ /// pointer.
+ DWARFExpression m_frame_base;
+
Flags m_flags;
- uint32_t
- m_prologue_byte_size; ///< Compute the prologue size once and cache it
- bool m_call_edges_resolved = false; ///< Whether call site info has been
- /// parsed.
- std::vector<std::unique_ptr<CallEdge>> m_call_edges; ///< Outgoing call edges.
+ /// Compute the prologue size once and cache it.
+ uint32_t m_prologue_byte_size;
+
+ /// Exclusive lock that controls read/write access to m_call_edges and
+ /// m_call_edges_resolved.
+ std::mutex m_call_edges_lock;
+
+ /// Whether call site info has been parsed.
+ bool m_call_edges_resolved = false;
+
+ /// Outgoing call edges.
+ std::vector<std::unique_ptr<CallEdge>> m_call_edges;
+
private:
- DISALLOW_COPY_AND_ASSIGN(Function);
+ Function(const Function &) = delete;
+ const Function &operator=(const Function &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Function_h_
+#endif // LLDB_SYMBOL_FUNCTION_H
diff --git a/lldb/include/lldb/Symbol/LineEntry.h b/lldb/include/lldb/Symbol/LineEntry.h
index 32ffef72ee5e..7e56ef814765 100644
--- a/lldb/include/lldb/Symbol/LineEntry.h
+++ b/lldb/include/lldb/Symbol/LineEntry.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_LineEntry_h_
-#define liblldb_LineEntry_h_
+#ifndef LLDB_SYMBOL_LINEENTRY_H
+#define LLDB_SYMBOL_LINEENTRY_H
#include "lldb/Core/AddressRange.h"
#include "lldb/Utility/FileSpec.h"
@@ -118,7 +118,7 @@ struct LineEntry {
/// range.
///
/// If the initial LineEntry this method is called on is a line #0, only the
- /// range of contiuous LineEntries with line #0 will be included in the
+ /// range of continuous LineEntries with line #0 will be included in the
/// complete range.
///
/// @param[in] include_inlined_functions
@@ -173,4 +173,4 @@ bool operator<(const LineEntry &lhs, const LineEntry &rhs);
} // namespace lldb_private
-#endif // liblldb_LineEntry_h_
+#endif // LLDB_SYMBOL_LINEENTRY_H
diff --git a/lldb/include/lldb/Symbol/LineTable.h b/lldb/include/lldb/Symbol/LineTable.h
index 043f3eb895cb..d66b58ca4c6d 100644
--- a/lldb/include/lldb/Symbol/LineTable.h
+++ b/lldb/include/lldb/Symbol/LineTable.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_LineTable_h_
-#define liblldb_LineTable_h_
+#ifndef LLDB_SYMBOL_LINETABLE_H
+#define LLDB_SYMBOL_LINETABLE_H
#include "lldb/Core/ModuleChild.h"
#include "lldb/Core/Section.h"
@@ -29,7 +29,8 @@ public:
virtual void Clear() = 0;
private:
- DISALLOW_COPY_AND_ASSIGN(LineSequence);
+ LineSequence(const LineSequence &) = delete;
+ const LineSequence &operator=(const LineSequence &) = delete;
};
/// \class LineTable LineTable.h "lldb/Symbol/LineTable.h"
@@ -42,6 +43,13 @@ public:
/// The compile unit to which this line table belongs.
LineTable(CompileUnit *comp_unit);
+ /// Construct with entries found in \a sequences.
+ ///
+ /// \param[in] sequences
+ /// Unsorted list of line sequences.
+ LineTable(CompileUnit *comp_unit,
+ std::vector<std::unique_ptr<LineSequence>> &&sequences);
+
/// Destructor.
~LineTable();
@@ -64,11 +72,11 @@ public:
bool is_epilogue_begin, bool is_terminal_entry);
// Used to instantiate the LineSequence helper class
- LineSequence *CreateLineSequenceContainer();
+ static std::unique_ptr<LineSequence> CreateLineSequenceContainer();
// Append an entry to a caller-provided collection that will later be
// inserted in this line table.
- void AppendLineEntryToSequence(LineSequence *sequence, lldb::addr_t file_addr,
+ static void AppendLineEntryToSequence(LineSequence *sequence, lldb::addr_t file_addr,
uint32_t line, uint16_t column,
uint16_t file_idx, bool is_start_of_statement,
bool is_start_of_basic_block,
@@ -176,7 +184,7 @@ public:
/// The number of line table entries in this line table.
uint32_t GetSize() const;
- typedef lldb_private::RangeArray<lldb::addr_t, lldb::addr_t, 32>
+ typedef lldb_private::RangeVector<lldb::addr_t, lldb::addr_t, 32>
FileAddressRanges;
/// Gets all contiguous file address ranges for the entire line table.
@@ -259,6 +267,8 @@ protected:
public:
LessThanBinaryPredicate(LineTable *line_table);
bool operator()(const LineTable::Entry &, const LineTable::Entry &) const;
+ bool operator()(const std::unique_ptr<LineSequence> &,
+ const std::unique_ptr<LineSequence> &) const;
protected:
LineTable *m_line_table;
@@ -328,9 +338,10 @@ protected:
bool ConvertEntryAtIndexToLineEntry(uint32_t idx, LineEntry &line_entry);
private:
- DISALLOW_COPY_AND_ASSIGN(LineTable);
+ LineTable(const LineTable &) = delete;
+ const LineTable &operator=(const LineTable &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_LineTable_h_
+#endif // LLDB_SYMBOL_LINETABLE_H
diff --git a/lldb/include/lldb/Symbol/LocateSymbolFile.h b/lldb/include/lldb/Symbol/LocateSymbolFile.h
index 0ff834df9c40..93b76e53f41f 100644
--- a/lldb/include/lldb/Symbol/LocateSymbolFile.h
+++ b/lldb/include/lldb/Symbol/LocateSymbolFile.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Symbols_h_
-#define liblldb_Symbols_h_
+#ifndef LLDB_SYMBOL_LOCATESYMBOLFILE_H
+#define LLDB_SYMBOL_LOCATESYMBOLFILE_H
#include <stdint.h>
@@ -55,4 +55,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_Symbols_h_
+#endif // LLDB_SYMBOL_LOCATESYMBOLFILE_H
diff --git a/lldb/include/lldb/Symbol/ObjectContainer.h b/lldb/include/lldb/Symbol/ObjectContainer.h
index 9310fdc18d90..1e01e93da9d2 100644
--- a/lldb/include/lldb/Symbol/ObjectContainer.h
+++ b/lldb/include/lldb/Symbol/ObjectContainer.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ObjectContainer_h_
-#define liblldb_ObjectContainer_h_
+#ifndef LLDB_SYMBOL_OBJECTCONTAINER_H
+#define LLDB_SYMBOL_OBJECTCONTAINER_H
#include "lldb/Core/ModuleChild.h"
#include "lldb/Core/PluginInterface.h"
@@ -167,9 +167,10 @@ protected:
m_data; ///< The data for this object file so things can be parsed lazily.
private:
- DISALLOW_COPY_AND_ASSIGN(ObjectContainer);
+ ObjectContainer(const ObjectContainer &) = delete;
+ const ObjectContainer &operator=(const ObjectContainer &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ObjectContainer_h_
+#endif // LLDB_SYMBOL_OBJECTCONTAINER_H
diff --git a/lldb/include/lldb/Symbol/ObjectFile.h b/lldb/include/lldb/Symbol/ObjectFile.h
index 841a38e5b15a..e814015c0bf7 100644
--- a/lldb/include/lldb/Symbol/ObjectFile.h
+++ b/lldb/include/lldb/Symbol/ObjectFile.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ObjectFile_h_
-#define liblldb_ObjectFile_h_
+#ifndef LLDB_SYMBOL_OBJECTFILE_H
+#define LLDB_SYMBOL_OBJECTFILE_H
#include "lldb/Core/FileSpecList.h"
#include "lldb/Core/ModuleChild.h"
@@ -172,10 +172,10 @@ public:
lldb::addr_t header_addr,
lldb::DataBufferSP &file_data_sp);
- static size_t GetModuleSpecifications(const FileSpec &file,
- lldb::offset_t file_offset,
- lldb::offset_t file_size,
- ModuleSpecList &specs);
+ static size_t
+ GetModuleSpecifications(const FileSpec &file, lldb::offset_t file_offset,
+ lldb::offset_t file_size, ModuleSpecList &specs,
+ lldb::DataBufferSP data_sp = lldb::DataBufferSP());
static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
lldb::DataBufferSP &data_sp,
@@ -686,7 +686,8 @@ protected:
uint64_t Offset);
private:
- DISALLOW_COPY_AND_ASSIGN(ObjectFile);
+ ObjectFile(const ObjectFile &) = delete;
+ const ObjectFile &operator=(const ObjectFile &) = delete;
};
} // namespace lldb_private
@@ -703,4 +704,4 @@ template <> struct format_provider<lldb_private::ObjectFile::Strata> {
};
} // namespace llvm
-#endif // liblldb_ObjectFile_h_
+#endif // LLDB_SYMBOL_OBJECTFILE_H
diff --git a/lldb/include/lldb/Symbol/SourceModule.h b/lldb/include/lldb/Symbol/SourceModule.h
index b12ff01a5198..7799b6504b15 100644
--- a/lldb/include/lldb/Symbol/SourceModule.h
+++ b/lldb/include/lldb/Symbol/SourceModule.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_SourceModule_h_
-#define liblldb_SourceModule_h_
+#ifndef LLDB_SYMBOL_SOURCEMODULE_H
+#define LLDB_SYMBOL_SOURCEMODULE_H
#include "lldb/Utility/ConstString.h"
#include <vector>
diff --git a/lldb/include/lldb/Symbol/Symbol.h b/lldb/include/lldb/Symbol/Symbol.h
index 36f89c044ea9..3a235f260ba5 100644
--- a/lldb/include/lldb/Symbol/Symbol.h
+++ b/lldb/include/lldb/Symbol/Symbol.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Symbol_h_
-#define liblldb_Symbol_h_
+#ifndef LLDB_SYMBOL_SYMBOL_H
+#define LLDB_SYMBOL_SYMBOL_H
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/Mangled.h"
@@ -267,4 +267,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_Symbol_h_
+#endif // LLDB_SYMBOL_SYMBOL_H
diff --git a/lldb/include/lldb/Symbol/SymbolContext.h b/lldb/include/lldb/Symbol/SymbolContext.h
index 4c7b727fe618..cc49ce51c713 100644
--- a/lldb/include/lldb/Symbol/SymbolContext.h
+++ b/lldb/include/lldb/Symbol/SymbolContext.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_SymbolContext_h_
-#define liblldb_SymbolContext_h_
+#ifndef LLDB_SYMBOL_SYMBOLCONTEXT_H
+#define LLDB_SYMBOL_SYMBOLCONTEXT_H
#include <memory>
#include <string>
@@ -475,4 +475,4 @@ bool operator!=(const SymbolContextList &lhs, const SymbolContextList &rhs);
} // namespace lldb_private
-#endif // liblldb_SymbolContext_h_
+#endif // LLDB_SYMBOL_SYMBOLCONTEXT_H
diff --git a/lldb/include/lldb/Symbol/SymbolContextScope.h b/lldb/include/lldb/Symbol/SymbolContextScope.h
index a626302053df..3b244caed333 100644
--- a/lldb/include/lldb/Symbol/SymbolContextScope.h
+++ b/lldb/include/lldb/Symbol/SymbolContextScope.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_SymbolContextScope_h_
-#define liblldb_SymbolContextScope_h_
+#ifndef LLDB_SYMBOL_SYMBOLCONTEXTSCOPE_H
+#define LLDB_SYMBOL_SYMBOLCONTEXTSCOPE_H
#include "lldb/lldb-private.h"
@@ -100,4 +100,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_SymbolContextScope_h_
+#endif // LLDB_SYMBOL_SYMBOLCONTEXTSCOPE_H
diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h
index fdd812eb5167..9f5806915dcb 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_SymbolFile_h_
-#define liblldb_SymbolFile_h_
+#ifndef LLDB_SYMBOL_SYMBOLFILE_H
+#define LLDB_SYMBOL_SYMBOLFILE_H
#include "lldb/Core/PluginInterface.h"
#include "lldb/Symbol/CompilerDecl.h"
@@ -18,6 +18,7 @@
#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/TypeList.h"
#include "lldb/Symbol/TypeSystem.h"
+#include "lldb/Utility/XcodeSDK.h"
#include "lldb/lldb-private.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/Support/Errc.h"
@@ -128,6 +129,8 @@ public:
Symtab *GetSymtab();
virtual lldb::LanguageType ParseLanguage(CompileUnit &comp_unit) = 0;
+ /// Return the Xcode SDK comp_unit was compiled against.
+ virtual XcodeSDK ParseXcodeSDK(CompileUnit &comp_unit) { return {}; }
virtual size_t ParseFunctions(CompileUnit &comp_unit) = 0;
virtual bool ParseLineTable(CompileUnit &comp_unit) = 0;
virtual bool ParseDebugMacros(CompileUnit &comp_unit) = 0;
@@ -136,12 +139,16 @@ public:
/// \p comp_unit. Recursively also descends into the referenced external
/// modules of any encountered compilation unit.
///
+ /// This function can be used to traverse Clang -gmodules debug
+ /// information, which is stored in DWARF files separate from the
+ /// object files.
+ ///
/// \param comp_unit
/// When this SymbolFile consists of multiple auxilliary
/// SymbolFiles, for example, a Darwin debug map that references
/// multiple .o files, comp_unit helps choose the auxilliary
/// file. In most other cases comp_unit's symbol file is
- /// identiacal with *this.
+ /// identical with *this.
///
/// \param[in] lambda
/// The lambda that should be applied to every function. The lambda can
@@ -182,7 +189,7 @@ public:
};
/// If \c type_uid points to an array type, return its characteristics.
/// To support variable-length array types, this function takes an
- /// optional \p ExtecutionContext. If \c exe_ctx is non-null, the
+ /// optional \p ExecutionContext. If \c exe_ctx is non-null, the
/// dynamic characteristics for that context are returned.
virtual llvm::Optional<ArrayInfo>
GetDynamicArrayInfoForUID(lldb::user_id_t type_uid,
@@ -208,21 +215,21 @@ public:
SymbolContextList &sc_list);
virtual void DumpClangAST(Stream &s) {}
- virtual void
- FindGlobalVariables(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
- uint32_t max_matches, VariableList &variables);
+ virtual void FindGlobalVariables(ConstString name,
+ const CompilerDeclContext &parent_decl_ctx,
+ uint32_t max_matches,
+ VariableList &variables);
virtual void FindGlobalVariables(const RegularExpression &regex,
uint32_t max_matches,
VariableList &variables);
virtual void FindFunctions(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
+ const CompilerDeclContext &parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines, SymbolContextList &sc_list);
virtual void FindFunctions(const RegularExpression &regex,
bool include_inlines, SymbolContextList &sc_list);
virtual void
- FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx,
+ FindTypes(ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types);
@@ -251,8 +258,7 @@ public:
GetTypeSystemForLanguage(lldb::LanguageType language);
virtual CompilerDeclContext
- FindNamespace(ConstString name,
- const CompilerDeclContext *parent_decl_ctx) {
+ FindNamespace(ConstString name, const CompilerDeclContext &parent_decl_ctx) {
return CompilerDeclContext();
}
@@ -311,9 +317,10 @@ protected:
bool m_calculated_abilities;
private:
- DISALLOW_COPY_AND_ASSIGN(SymbolFile);
+ SymbolFile(const SymbolFile &) = delete;
+ const SymbolFile &operator=(const SymbolFile &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_SymbolFile_h_
+#endif // LLDB_SYMBOL_SYMBOLFILE_H
diff --git a/lldb/include/lldb/Symbol/SymbolVendor.h b/lldb/include/lldb/Symbol/SymbolVendor.h
index 96c6ea5c7332..c9c59a3fc1be 100644
--- a/lldb/include/lldb/Symbol/SymbolVendor.h
+++ b/lldb/include/lldb/Symbol/SymbolVendor.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_SymbolVendor_h_
-#define liblldb_SymbolVendor_h_
+#ifndef LLDB_SYMBOL_SYMBOLVENDOR_H
+#define LLDB_SYMBOL_SYMBOLVENDOR_H
#include <vector>
@@ -52,9 +52,10 @@ protected:
private:
// For SymbolVendor only
- DISALLOW_COPY_AND_ASSIGN(SymbolVendor);
+ SymbolVendor(const SymbolVendor &) = delete;
+ const SymbolVendor &operator=(const SymbolVendor &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_SymbolVendor_h_
+#endif // LLDB_SYMBOL_SYMBOLVENDOR_H
diff --git a/lldb/include/lldb/Symbol/Symtab.h b/lldb/include/lldb/Symbol/Symtab.h
index f121bef1bfbe..c232925eec75 100644
--- a/lldb/include/lldb/Symbol/Symtab.h
+++ b/lldb/include/lldb/Symbol/Symtab.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Symtab_h_
-#define liblldb_Symtab_h_
+#ifndef LLDB_SYMBOL_SYMTAB_H
+#define LLDB_SYMBOL_SYMTAB_H
#include "lldb/Core/UniqueCStringMap.h"
#include "lldb/Symbol/Symbol.h"
@@ -224,9 +224,10 @@ private:
const char *decl_context,
const std::set<const char *> &class_contexts);
- DISALLOW_COPY_AND_ASSIGN(Symtab);
+ Symtab(const Symtab &) = delete;
+ const Symtab &operator=(const Symtab &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Symtab_h_
+#endif // LLDB_SYMBOL_SYMTAB_H
diff --git a/lldb/include/lldb/Symbol/TaggedASTType.h b/lldb/include/lldb/Symbol/TaggedASTType.h
index 043a9138e07b..f02f99258a3f 100644
--- a/lldb/include/lldb/Symbol/TaggedASTType.h
+++ b/lldb/include/lldb/Symbol/TaggedASTType.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_TaggedASTType_h_
-#define liblldb_TaggedASTType_h_
+#ifndef LLDB_SYMBOL_TAGGEDASTTYPE_H
+#define LLDB_SYMBOL_TAGGEDASTTYPE_H
#include "lldb/Symbol/CompilerType.h"
diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index 95a3bc497517..8735d016bb22 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Type_h_
-#define liblldb_Type_h_
+#ifndef LLDB_SYMBOL_TYPE_H
+#define LLDB_SYMBOL_TYPE_H
#include "lldb/Symbol/CompilerDecl.h"
#include "lldb/Symbol/CompilerType.h"
@@ -97,13 +97,14 @@ public:
llvm::Optional<uint64_t> byte_size, SymbolContextScope *context,
lldb::user_id_t encoding_uid, EncodingDataType encoding_uid_type,
const Declaration &decl, const CompilerType &compiler_qual_type,
- ResolveState compiler_type_resolve_state);
+ ResolveState compiler_type_resolve_state, uint32_t opaque_payload = 0);
// This makes an invalid type. Used for functions that return a Type when
// they get an error.
Type();
- void Dump(Stream *s, bool show_context);
+ void Dump(Stream *s, bool show_context,
+ lldb::DescriptionLevel level = lldb::eDescriptionLevelFull);
void DumpTypeName(Stream *s);
@@ -196,11 +197,11 @@ public:
uint32_t GetEncodingMask();
- bool IsCompleteObjCClass() { return m_is_complete_objc_class; }
-
- void SetIsCompleteObjCClass(bool is_complete_objc_class) {
- m_is_complete_objc_class = is_complete_objc_class;
- }
+ typedef uint32_t Payload;
+ /// Return the language-specific payload.
+ Payload GetPayload() { return m_payload; }
+ /// Return the language-specific payload.
+ void SetPayload(Payload opaque_payload) { m_payload = opaque_payload; }
protected:
ConstString m_name;
@@ -215,11 +216,12 @@ protected:
Declaration m_decl;
CompilerType m_compiler_type;
ResolveState m_compiler_type_resolve_state;
- bool m_is_complete_objc_class;
+ /// Language-specific flags.
+ Payload m_payload;
Type *GetEncodingType();
- bool ResolveClangType(ResolveState compiler_type_resolve_state);
+ bool ResolveCompilerType(ResolveState compiler_type_resolve_state);
};
// the two classes here are used by the public API as a backend to the SBType
@@ -510,4 +512,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_Type_h_
+#endif // LLDB_SYMBOL_TYPE_H
diff --git a/lldb/include/lldb/Symbol/TypeList.h b/lldb/include/lldb/Symbol/TypeList.h
index 38342b6d6f4f..03390858025b 100644
--- a/lldb/include/lldb/Symbol/TypeList.h
+++ b/lldb/include/lldb/Symbol/TypeList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_TypeList_h_
-#define liblldb_TypeList_h_
+#ifndef LLDB_SYMBOL_TYPELIST_H
+#define LLDB_SYMBOL_TYPELIST_H
#include "lldb/Symbol/Type.h"
#include "lldb/Utility/Iterable.h"
@@ -63,9 +63,10 @@ private:
collection m_types;
- DISALLOW_COPY_AND_ASSIGN(TypeList);
+ TypeList(const TypeList &) = delete;
+ const TypeList &operator=(const TypeList &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_TypeList_h_
+#endif // LLDB_SYMBOL_TYPELIST_H
diff --git a/lldb/include/lldb/Symbol/TypeMap.h b/lldb/include/lldb/Symbol/TypeMap.h
index e7d2b254cbf3..ede54c1a09d4 100644
--- a/lldb/include/lldb/Symbol/TypeMap.h
+++ b/lldb/include/lldb/Symbol/TypeMap.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_TypeMap_h_
-#define liblldb_TypeMap_h_
+#ifndef LLDB_SYMBOL_TYPEMAP_H
+#define LLDB_SYMBOL_TYPEMAP_H
#include "lldb/Symbol/Type.h"
#include "lldb/Utility/Iterable.h"
@@ -26,7 +26,8 @@ public:
void Clear();
- void Dump(Stream *s, bool show_context);
+ void Dump(Stream *s, bool show_context,
+ lldb::DescriptionLevel level = lldb::eDescriptionLevelFull);
TypeMap FindTypes(ConstString name);
@@ -66,9 +67,10 @@ private:
collection m_types;
- DISALLOW_COPY_AND_ASSIGN(TypeMap);
+ TypeMap(const TypeMap &) = delete;
+ const TypeMap &operator=(const TypeMap &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_TypeMap_h_
+#endif // LLDB_SYMBOL_TYPEMAP_H
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h
index 91f751acf6c7..e188f29354b8 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_TypeSystem_h_
-#define liblldb_TypeSystem_h_
+#ifndef LLDB_SYMBOL_TYPESYSTEM_H
+#define LLDB_SYMBOL_TYPESYSTEM_H
#include <functional>
#include <map>
@@ -129,6 +129,11 @@ public:
void *other_opaque_decl_ctx) = 0;
// Tests
+#ifndef NDEBUG
+ /// Verify the integrity of the type to catch CompilerTypes that mix
+ /// and match invalid TypeSystem/Opaque type pairs.
+ virtual bool Verify(lldb::opaque_compiler_type_t type) = 0;
+#endif
virtual bool IsArrayType(lldb::opaque_compiler_type_t type,
CompilerType *element_type, uint64_t *size,
@@ -199,6 +204,8 @@ public:
virtual ConstString GetTypeName(lldb::opaque_compiler_type_t type) = 0;
+ virtual ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) = 0;
+
virtual uint32_t
GetTypeInfo(lldb::opaque_compiler_type_t type,
CompilerType *pointee_or_element_compiler_type) = 0;
@@ -252,9 +259,12 @@ public:
virtual CompilerType AddRestrictModifier(lldb::opaque_compiler_type_t type);
+ /// \param opaque_payload The m_payload field of Type, which may
+ /// carry TypeSystem-specific extra information.
virtual CompilerType CreateTypedef(lldb::opaque_compiler_type_t type,
const char *name,
- const CompilerDeclContext &decl_ctx);
+ const CompilerDeclContext &decl_ctx,
+ uint32_t opaque_payload);
// Exploring the type
@@ -364,11 +374,18 @@ public:
uint32_t bitfield_bit_offset,
ExecutionContextScope *exe_scope) = 0;
- virtual void
- DumpTypeDescription(lldb::opaque_compiler_type_t type) = 0; // Dump to stdout
+ /// Dump the type to stdout.
+ virtual void DumpTypeDescription(
+ lldb::opaque_compiler_type_t type,
+ lldb::DescriptionLevel level = lldb::eDescriptionLevelFull) = 0;
- virtual void DumpTypeDescription(lldb::opaque_compiler_type_t type,
- Stream *s) = 0;
+ /// Print a description of the type to a stream. The exact implementation
+ /// varies, but the expectation is that eDescriptionLevelFull returns a
+ /// source-like representation of the type, whereas eDescriptionLevelVerbose
+ /// does a dump of the underlying AST if applicable.
+ virtual void DumpTypeDescription(
+ lldb::opaque_compiler_type_t type, Stream *s,
+ lldb::DescriptionLevel level = lldb::eDescriptionLevelFull) = 0;
// TODO: These methods appear unused. Should they be removed?
@@ -380,7 +397,7 @@ public:
lldb::offset_t data_offset,
size_t data_byte_size) = 0;
- // TODO: Determine if these methods should move to ClangASTContext.
+ // TODO: Determine if these methods should move to TypeSystemClang.
virtual bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type,
CompilerType *pointee_type) = 0;
@@ -509,4 +526,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_TypeSystem_h_
+#endif // LLDB_SYMBOL_TYPESYSTEM_H
diff --git a/lldb/include/lldb/Symbol/UnwindPlan.h b/lldb/include/lldb/Symbol/UnwindPlan.h
index fa41ba5d056a..8902b5f4eaa7 100644
--- a/lldb/include/lldb/Symbol/UnwindPlan.h
+++ b/lldb/include/lldb/Symbol/UnwindPlan.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_UnwindPlan_h
-#define liblldb_UnwindPlan_h
+#ifndef LLDB_SYMBOL_UNWINDPLAN_H
+#define LLDB_SYMBOL_UNWINDPLAN_H
#include <map>
#include <memory>
@@ -320,7 +320,6 @@ public:
} m_value;
}; // class FAValue
- public:
Row();
Row(const UnwindPlan::Row &rhs) = default;
@@ -375,7 +374,6 @@ public:
collection m_register_locations;
}; // class Row
-public:
typedef std::shared_ptr<Row> RowSP;
UnwindPlan(lldb::RegisterKind reg_kind)
@@ -540,4 +538,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_UnwindPlan_h
+#endif // LLDB_SYMBOL_UNWINDPLAN_H
diff --git a/lldb/include/lldb/Symbol/UnwindTable.h b/lldb/include/lldb/Symbol/UnwindTable.h
index c1dc519c4b20..9548b1f3fcec 100644
--- a/lldb/include/lldb/Symbol/UnwindTable.h
+++ b/lldb/include/lldb/Symbol/UnwindTable.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_UnwindTable_h
-#define liblldb_UnwindTable_h
+#ifndef LLDB_SYMBOL_UNWINDTABLE_H
+#define LLDB_SYMBOL_UNWINDTABLE_H
#include <map>
#include <mutex>
@@ -79,9 +79,10 @@ private:
std::unique_ptr<CompactUnwindInfo> m_compact_unwind_up;
std::unique_ptr<ArmUnwindInfo> m_arm_unwind_up;
- DISALLOW_COPY_AND_ASSIGN(UnwindTable);
+ UnwindTable(const UnwindTable &) = delete;
+ const UnwindTable &operator=(const UnwindTable &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_UnwindTable_h
+#endif // LLDB_SYMBOL_UNWINDTABLE_H
diff --git a/lldb/include/lldb/Symbol/Variable.h b/lldb/include/lldb/Symbol/Variable.h
index 30f57f1f9110..66abdc0b3117 100644
--- a/lldb/include/lldb/Symbol/Variable.h
+++ b/lldb/include/lldb/Symbol/Variable.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Variable_h_
-#define liblldb_Variable_h_
+#ifndef LLDB_SYMBOL_VARIABLE_H
+#define LLDB_SYMBOL_VARIABLE_H
#include "lldb/Core/Mangled.h"
#include "lldb/Expression/DWARFExpression.h"
@@ -141,4 +141,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_Variable_h_
+#endif // LLDB_SYMBOL_VARIABLE_H
diff --git a/lldb/include/lldb/Symbol/VariableList.h b/lldb/include/lldb/Symbol/VariableList.h
index 87f98668a8a8..9fea628a81b6 100644
--- a/lldb/include/lldb/Symbol/VariableList.h
+++ b/lldb/include/lldb/Symbol/VariableList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_VariableList_h_
-#define liblldb_VariableList_h_
+#ifndef LLDB_SYMBOL_VARIABLELIST_H
+#define LLDB_SYMBOL_VARIABLELIST_H
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/Variable.h"
@@ -80,9 +80,10 @@ protected:
private:
// For VariableList only
- DISALLOW_COPY_AND_ASSIGN(VariableList);
+ VariableList(const VariableList &) = delete;
+ const VariableList &operator=(const VariableList &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_VariableList_h_
+#endif // LLDB_SYMBOL_VARIABLELIST_H
diff --git a/lldb/include/lldb/Target/ABI.h b/lldb/include/lldb/Target/ABI.h
index 1aff1e2f7817..b252e4b54f03 100644
--- a/lldb/include/lldb/Target/ABI.h
+++ b/lldb/include/lldb/Target/ABI.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ABI_h_
-#define liblldb_ABI_h_
+#ifndef LLDB_TARGET_ABI_H
+#define LLDB_TARGET_ABI_H
#include "lldb/Core/PluginInterface.h"
#include "lldb/Symbol/UnwindPlan.h"
@@ -126,7 +126,7 @@ public:
llvm::MCRegisterInfo &GetMCRegisterInfo() { return *m_mc_register_info_up; }
- virtual void AugmentRegisterInfo(RegisterInfo &info);
+ virtual void AugmentRegisterInfo(RegisterInfo &info) = 0;
virtual bool GetPointerReturnRegister(const char *&name) { return false; }
@@ -138,10 +138,6 @@ protected:
assert(m_mc_register_info_up && "ABI must have MCRegisterInfo");
}
- bool GetRegisterInfoByName(ConstString name, RegisterInfo &info);
-
- virtual const RegisterInfo *GetRegisterInfoArray(uint32_t &count) = 0;
-
/// Utility function to construct a MCRegisterInfo using the ArchSpec triple.
/// Plugins wishing to customize the construction can construct the
/// MCRegisterInfo themselves.
@@ -152,9 +148,44 @@ protected:
std::unique_ptr<llvm::MCRegisterInfo> m_mc_register_info_up;
private:
- DISALLOW_COPY_AND_ASSIGN(ABI);
+ ABI(const ABI &) = delete;
+ const ABI &operator=(const ABI &) = delete;
+};
+
+class RegInfoBasedABI : public ABI {
+public:
+ void AugmentRegisterInfo(RegisterInfo &info) override;
+
+protected:
+ using ABI::ABI;
+
+ bool GetRegisterInfoByName(ConstString name, RegisterInfo &info);
+
+ virtual const RegisterInfo *GetRegisterInfoArray(uint32_t &count) = 0;
+};
+
+class MCBasedABI : public ABI {
+public:
+ void AugmentRegisterInfo(RegisterInfo &info) override;
+
+ /// If the register name is of the form "<from_prefix>[<number>]" then change
+ /// the name to "<to_prefix>[<number>]". Otherwise, leave the name unchanged.
+ static void MapRegisterName(std::string &reg, llvm::StringRef from_prefix,
+ llvm::StringRef to_prefix);
+protected:
+ using ABI::ABI;
+
+ /// Return eh_frame and dwarf numbers for the given register.
+ virtual std::pair<uint32_t, uint32_t> GetEHAndDWARFNums(llvm::StringRef reg);
+
+ /// Return the generic number of the given register.
+ virtual uint32_t GetGenericNum(llvm::StringRef reg) = 0;
+
+ /// For the given (capitalized) lldb register name, return the name of this
+ /// register in the MCRegisterInfo struct.
+ virtual std::string GetMCName(std::string reg) { return reg; }
};
} // namespace lldb_private
-#endif // liblldb_ABI_h_
+#endif // LLDB_TARGET_ABI_H
diff --git a/lldb/include/lldb/Target/AssertFrameRecognizer.h b/lldb/include/lldb/Target/AssertFrameRecognizer.h
new file mode 100644
index 000000000000..2ecc957d2a28
--- /dev/null
+++ b/lldb/include/lldb/Target/AssertFrameRecognizer.h
@@ -0,0 +1,54 @@
+//===-- AssertFrameRecognizer.cpp -------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_TARGET_ASSERTFRAMERECOGNIZER_H
+#define LLDB_TARGET_ASSERTFRAMERECOGNIZER_H
+
+#include "lldb/Target/Process.h"
+#include "lldb/Target/StackFrameRecognizer.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/FileSpec.h"
+
+#include <tuple>
+
+namespace lldb_private {
+
+/// Registers the assert stack frame recognizer.
+///
+/// \param[in] process
+/// The process that is currently asserting. This will give us information on
+/// the target and the platform.
+void RegisterAssertFrameRecognizer(Process *process);
+
+/// \class AssertRecognizedStackFrame
+///
+/// Holds the stack frame where the assert is called from.
+class AssertRecognizedStackFrame : public RecognizedStackFrame {
+public:
+ AssertRecognizedStackFrame(lldb::StackFrameSP most_relevant_frame_sp);
+ lldb::StackFrameSP GetMostRelevantFrame() override;
+
+private:
+ lldb::StackFrameSP m_most_relevant_frame;
+};
+
+/// \class AssertFrameRecognizer
+///
+/// When a thread stops, it checks depending on the platform if the top frame is
+/// an abort stack frame. If so, it looks for an assert stack frame in the upper
+/// frames and set it as the most relavant frame when found.
+class AssertFrameRecognizer : public StackFrameRecognizer {
+public:
+ std::string GetName() override { return "Assert StackFrame Recognizer"; }
+ lldb::RecognizedStackFrameSP
+ RecognizeFrame(lldb::StackFrameSP frame_sp) override;
+};
+
+} // namespace lldb_private
+
+#endif // LLDB_TARGET_ASSERTFRAMERECOGNIZER_H
diff --git a/lldb/include/lldb/Target/DynamicLoader.h b/lldb/include/lldb/Target/DynamicLoader.h
index ac72b98e5e1a..d3ce1b05ed51 100644
--- a/lldb/include/lldb/Target/DynamicLoader.h
+++ b/lldb/include/lldb/Target/DynamicLoader.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DynamicLoader_h_
-#define liblldb_DynamicLoader_h_
+#ifndef LLDB_TARGET_DYNAMICLOADER_H
+#define LLDB_TARGET_DYNAMICLOADER_H
#include "lldb/Core/PluginInterface.h"
#include "lldb/Utility/FileSpec.h"
@@ -310,9 +310,10 @@ protected:
*m_process; ///< The process that this dynamic loader plug-in is tracking.
private:
- DISALLOW_COPY_AND_ASSIGN(DynamicLoader);
+ DynamicLoader(const DynamicLoader &) = delete;
+ const DynamicLoader &operator=(const DynamicLoader &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_DynamicLoader_h_
+#endif // LLDB_TARGET_DYNAMICLOADER_H
diff --git a/lldb/include/lldb/Target/ExecutionContext.h b/lldb/include/lldb/Target/ExecutionContext.h
index 0819357fab32..169d56ac9b64 100644
--- a/lldb/include/lldb/Target/ExecutionContext.h
+++ b/lldb/include/lldb/Target/ExecutionContext.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ExecutionContext_h_
-#define liblldb_ExecutionContext_h_
+#ifndef LLDB_TARGET_EXECUTIONCONTEXT_H
+#define LLDB_TARGET_EXECUTIONCONTEXT_H
#include <mutex>
@@ -565,4 +565,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_ExecutionContext_h_
+#endif // LLDB_TARGET_EXECUTIONCONTEXT_H
diff --git a/lldb/include/lldb/Target/ExecutionContextScope.h b/lldb/include/lldb/Target/ExecutionContextScope.h
index 0121ce61a1d7..d7003e9a572e 100644
--- a/lldb/include/lldb/Target/ExecutionContextScope.h
+++ b/lldb/include/lldb/Target/ExecutionContextScope.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ExecutionContextScope_h_
-#define liblldb_ExecutionContextScope_h_
+#ifndef LLDB_TARGET_EXECUTIONCONTEXTSCOPE_H
+#define LLDB_TARGET_EXECUTIONCONTEXTSCOPE_H
#include "lldb/lldb-private.h"
@@ -55,4 +55,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_ExecutionContextScope_h_
+#endif // LLDB_TARGET_EXECUTIONCONTEXTSCOPE_H
diff --git a/lldb/include/lldb/Target/InstrumentationRuntime.h b/lldb/include/lldb/Target/InstrumentationRuntime.h
index 4cee76d657bb..dd4da26c215e 100644
--- a/lldb/include/lldb/Target/InstrumentationRuntime.h
+++ b/lldb/include/lldb/Target/InstrumentationRuntime.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_InstrumentationRuntime_h_
-#define liblldb_InstrumentationRuntime_h_
+#ifndef LLDB_TARGET_INSTRUMENTATIONRUNTIME_H
+#define LLDB_TARGET_INSTRUMENTATIONRUNTIME_H
#include <map>
#include <vector>
@@ -92,4 +92,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_InstrumentationRuntime_h_
+#endif // LLDB_TARGET_INSTRUMENTATIONRUNTIME_H
diff --git a/lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h b/lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h
index 6c2a8ad87418..2cbf27d7b343 100644
--- a/lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h
+++ b/lldb/include/lldb/Target/InstrumentationRuntimeStopInfo.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_InstrumentationRuntimeStopInfo_h_
-#define liblldb_InstrumentationRuntimeStopInfo_h_
+#ifndef LLDB_TARGET_INSTRUMENTATIONRUNTIMESTOPINFO_H
+#define LLDB_TARGET_INSTRUMENTATIONRUNTIMESTOPINFO_H
#include <string>
@@ -39,4 +39,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_InstrumentationRuntimeStopInfo_h_
+#endif // LLDB_TARGET_INSTRUMENTATIONRUNTIMESTOPINFO_H
diff --git a/lldb/include/lldb/Target/JITLoader.h b/lldb/include/lldb/Target/JITLoader.h
index 1bafd828f78e..790fdfaf8548 100644
--- a/lldb/include/lldb/Target/JITLoader.h
+++ b/lldb/include/lldb/Target/JITLoader.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_JITLoader_h_
-#define liblldb_JITLoader_h_
+#ifndef LLDB_TARGET_JITLOADER_H
+#define LLDB_TARGET_JITLOADER_H
#include <vector>
@@ -65,4 +65,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_JITLoader_h_
+#endif // LLDB_TARGET_JITLOADER_H
diff --git a/lldb/include/lldb/Target/JITLoaderList.h b/lldb/include/lldb/Target/JITLoaderList.h
index 4cc3a9ecb91d..f8d34d21a808 100644
--- a/lldb/include/lldb/Target/JITLoaderList.h
+++ b/lldb/include/lldb/Target/JITLoaderList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_JITLoaderList_h_
-#define liblldb_JITLoaderList_h_
+#ifndef LLDB_TARGET_JITLOADERLIST_H
+#define LLDB_TARGET_JITLOADERLIST_H
#include <mutex>
#include <vector>
@@ -45,4 +45,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_JITLoaderList_h_
+#endif // LLDB_TARGET_JITLOADERLIST_H
diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h
index e00b042ac253..9dc9df363d79 100644
--- a/lldb/include/lldb/Target/Language.h
+++ b/lldb/include/lldb/Target/Language.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Language_h_
-#define liblldb_Language_h_
+#ifndef LLDB_TARGET_LANGUAGE_H
+#define LLDB_TARGET_LANGUAGE_H
#include <functional>
#include <memory>
@@ -180,10 +180,6 @@ public:
GetPossibleFormattersMatches(ValueObject &valobj,
lldb::DynamicValueType use_dynamic);
- virtual lldb_private::formatters::StringPrinter::EscapingHelper
- GetStringPrinterEscapingHelper(
- lldb_private::formatters::StringPrinter::GetPrintableElementType);
-
virtual std::unique_ptr<TypeScavenger> GetTypeScavenger();
virtual const char *GetLanguageSpecificTypeLookupHelp();
@@ -274,9 +270,10 @@ protected:
Language();
private:
- DISALLOW_COPY_AND_ASSIGN(Language);
+ Language(const Language &) = delete;
+ const Language &operator=(const Language &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Language_h_
+#endif // LLDB_TARGET_LANGUAGE_H
diff --git a/lldb/include/lldb/Target/LanguageRuntime.h b/lldb/include/lldb/Target/LanguageRuntime.h
index 73c8dfa3874d..b0b9b919911a 100644
--- a/lldb/include/lldb/Target/LanguageRuntime.h
+++ b/lldb/include/lldb/Target/LanguageRuntime.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_LanguageRuntime_h_
-#define liblldb_LanguageRuntime_h_
+#ifndef LLDB_TARGET_LANGUAGERUNTIME_H
+#define LLDB_TARGET_LANGUAGERUNTIME_H
#include "lldb/Breakpoint/BreakpointResolver.h"
#include "lldb/Breakpoint/BreakpointResolverName.h"
@@ -21,8 +21,6 @@
#include "lldb/lldb-private.h"
#include "lldb/lldb-public.h"
-#include "clang/Basic/TargetOptions.h"
-
namespace lldb_private {
class ExceptionSearchFilter : public SearchFilter {
@@ -53,7 +51,7 @@ protected:
LanguageRuntime *m_language_runtime;
lldb::SearchFilterSP m_filter_sp;
- lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
+ lldb::SearchFilterSP DoCreateCopy() override;
void UpdateModuleListIfNeeded();
};
@@ -136,7 +134,8 @@ public:
virtual DeclVendor *GetDeclVendor() { return nullptr; }
virtual lldb::BreakpointResolverSP
- CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, bool throw_bp) = 0;
+ CreateExceptionResolver(const lldb::BreakpointSP &bkpt,
+ bool catch_bp, bool throw_bp) = 0;
virtual lldb::SearchFilterSP CreateExceptionSearchFilter() {
return m_process->GetTarget().GetSearchFilterForModule(nullptr);
@@ -154,7 +153,7 @@ public:
/// Identify whether a name is a runtime value that should not be hidden by
/// from the user interface.
- virtual bool IsWhitelistedRuntimeValue(ConstString name) { return false; }
+ virtual bool IsAllowedRuntimeValue(ConstString name) { return false; }
virtual llvm::Optional<CompilerType> GetRuntimeType(CompilerType base_type) {
return llvm::None;
@@ -162,13 +161,6 @@ public:
virtual void ModulesDidLoad(const ModuleList &module_list) {}
- // Called by the Clang expression evaluation engine to allow runtimes to
- // alter the set of target options provided to the compiler. If the options
- // prototype is modified, runtimes must return true, false otherwise.
- virtual bool GetOverrideExprOptions(clang::TargetOptions &prototype) {
- return false;
- }
-
// Called by ClangExpressionParser::PrepareForExecution to query for any
// custom LLVM IR passes that need to be run before an expression is
// assembled and run.
@@ -193,9 +185,10 @@ protected:
Process *m_process;
private:
- DISALLOW_COPY_AND_ASSIGN(LanguageRuntime);
+ LanguageRuntime(const LanguageRuntime &) = delete;
+ const LanguageRuntime &operator=(const LanguageRuntime &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_LanguageRuntime_h_
+#endif // LLDB_TARGET_LANGUAGERUNTIME_H
diff --git a/lldb/include/lldb/Target/Memory.h b/lldb/include/lldb/Target/Memory.h
index e62b8ef9c773..b3ad22aff16b 100644
--- a/lldb/include/lldb/Target/Memory.h
+++ b/lldb/include/lldb/Target/Memory.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Memory_h_
-#define liblldb_Memory_h_
+#ifndef LLDB_TARGET_MEMORY_H
+#define LLDB_TARGET_MEMORY_H
#include "lldb/Utility/RangeMap.h"
#include "lldb/lldb-private.h"
@@ -45,7 +45,7 @@ public:
protected:
typedef std::map<lldb::addr_t, lldb::DataBufferSP> BlockMap;
- typedef RangeArray<lldb::addr_t, lldb::addr_t, 4> InvalidRanges;
+ typedef RangeVector<lldb::addr_t, lldb::addr_t, 4> InvalidRanges;
typedef Range<lldb::addr_t, lldb::addr_t> AddrRange;
// Classes that inherit from MemoryCache can see and modify these
std::recursive_mutex m_mutex;
@@ -59,7 +59,8 @@ protected:
uint32_t m_L2_cache_line_byte_size;
private:
- DISALLOW_COPY_AND_ASSIGN(MemoryCache);
+ MemoryCache(const MemoryCache &) = delete;
+ const MemoryCache &operator=(const MemoryCache &) = delete;
};
@@ -135,9 +136,10 @@ protected:
PermissionsToBlockMap m_memory_map;
private:
- DISALLOW_COPY_AND_ASSIGN(AllocatedMemoryCache);
+ AllocatedMemoryCache(const AllocatedMemoryCache &) = delete;
+ const AllocatedMemoryCache &operator=(const AllocatedMemoryCache &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Memory_h_
+#endif // LLDB_TARGET_MEMORY_H
diff --git a/lldb/include/lldb/Target/MemoryHistory.h b/lldb/include/lldb/Target/MemoryHistory.h
index 501751c55e80..db1e86805996 100644
--- a/lldb/include/lldb/Target/MemoryHistory.h
+++ b/lldb/include/lldb/Target/MemoryHistory.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_MemoryHistory_h_
-#define liblldb_MemoryHistory_h_
+#ifndef LLDB_TARGET_MEMORYHISTORY_H
+#define LLDB_TARGET_MEMORYHISTORY_H
#include <vector>
@@ -30,4 +30,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_MemoryHistory_h_
+#endif // LLDB_TARGET_MEMORYHISTORY_H
diff --git a/lldb/include/lldb/Target/MemoryRegionInfo.h b/lldb/include/lldb/Target/MemoryRegionInfo.h
index 07e50188843e..a22da8d72b83 100644
--- a/lldb/include/lldb/Target/MemoryRegionInfo.h
+++ b/lldb/include/lldb/Target/MemoryRegionInfo.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_MemoryRegionInfo_h
-#define lldb_MemoryRegionInfo_h
+#ifndef LLDB_TARGET_MEMORYREGIONINFO_H
+#define LLDB_TARGET_MEMORYREGIONINFO_H
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/RangeMap.h"
@@ -143,4 +143,4 @@ struct format_provider<lldb_private::MemoryRegionInfo::OptionalBool> {
};
}
-#endif // #ifndef lldb_MemoryRegionInfo_h
+#endif // LLDB_TARGET_MEMORYREGIONINFO_H
diff --git a/lldb/include/lldb/Target/ModuleCache.h b/lldb/include/lldb/Target/ModuleCache.h
index 119616911393..9dc0e0903196 100644
--- a/lldb/include/lldb/Target/ModuleCache.h
+++ b/lldb/include/lldb/Target/ModuleCache.h
@@ -71,4 +71,4 @@ private:
} // namespace lldb_private
-#endif // utility_ModuleCache_h_
+#endif // LLDB_TARGET_MODULECACHE_H
diff --git a/lldb/include/lldb/Target/OperatingSystem.h b/lldb/include/lldb/Target/OperatingSystem.h
index c75d1ca2e5f4..6db5c0a01f36 100644
--- a/lldb/include/lldb/Target/OperatingSystem.h
+++ b/lldb/include/lldb/Target/OperatingSystem.h
@@ -7,9 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_OperatingSystem_h_
-#define liblldb_OperatingSystem_h_
-
+#ifndef LLDB_TARGET_OPERATINGSYSTEM_H
+#define LLDB_TARGET_OPERATINGSYSTEM_H
#include "lldb/Core/PluginInterface.h"
#include "lldb/lldb-private.h"
@@ -70,9 +69,10 @@ protected:
Process
*m_process; ///< The process that this dynamic loader plug-in is tracking.
private:
- DISALLOW_COPY_AND_ASSIGN(OperatingSystem);
+ OperatingSystem(const OperatingSystem &) = delete;
+ const OperatingSystem &operator=(const OperatingSystem &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_OperatingSystem_h_
+#endif // LLDB_TARGET_OPERATINGSYSTEM_H
diff --git a/lldb/include/lldb/Target/PathMappingList.h b/lldb/include/lldb/Target/PathMappingList.h
index d1759667f1f5..9e1e6eb26eb9 100644
--- a/lldb/include/lldb/Target/PathMappingList.h
+++ b/lldb/include/lldb/Target/PathMappingList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_PathMappingList_h_
-#define liblldb_PathMappingList_h_
+#ifndef LLDB_TARGET_PATHMAPPINGLIST_H
+#define LLDB_TARGET_PATHMAPPINGLIST_H
#include <map>
#include <vector>
@@ -125,4 +125,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_PathMappingList_h_
+#endif // LLDB_TARGET_PATHMAPPINGLIST_H
diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h
index 72b6be21b770..6234b8244b3f 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Platform_h_
-#define liblldb_Platform_h_
+#ifndef LLDB_TARGET_PLATFORM_H
+#define LLDB_TARGET_PLATFORM_H
#include <functional>
#include <map>
@@ -23,6 +23,7 @@
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/StructuredData.h"
#include "lldb/Utility/Timeout.h"
#include "lldb/Utility/UserIDResolver.h"
#include "lldb/lldb-private-forward.h"
@@ -32,8 +33,8 @@
namespace lldb_private {
class ProcessInstanceInfo;
-class ProcessInstanceInfoList;
class ProcessInstanceInfoMatch;
+typedef std::vector<ProcessInstanceInfo> ProcessInstanceInfoList;
class ModuleCache;
enum MmapFlags { eMmapFlagsPrivate = 1, eMmapFlagsAnon = 2 };
@@ -49,6 +50,9 @@ public:
FileSpec GetModuleCacheDirectory() const;
bool SetModuleCacheDirectory(const FileSpec &dir_spec);
+
+private:
+ void SetDefaultModuleCacheDirectory(const FileSpec &dir_spec);
};
typedef std::shared_ptr<PlatformProperties> PlatformPropertiesSP;
@@ -368,9 +372,13 @@ public:
virtual lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
llvm::StringRef plugin_name,
- lldb_private::Debugger &debugger,
- lldb_private::Target *target,
- lldb_private::Status &error);
+ Debugger &debugger, Target *target,
+ Status &error);
+
+ virtual lldb::ProcessSP
+ ConnectProcessSynchronous(llvm::StringRef connect_url,
+ llvm::StringRef plugin_name, Debugger &debugger,
+ Stream &stream, Target *target, Status &error);
/// Attach to an existing process using a process ID.
///
@@ -823,7 +831,33 @@ public:
virtual size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
lldb_private::Status &error);
+ /// Gather all of crash informations into a structured data dictionary.
+ ///
+ /// If the platform have a crashed process with crash information entries,
+ /// gather all the entries into an structured data dictionary or return a
+ /// nullptr. This dictionary is generic and extensible, as it contains an
+ /// array for each different type of crash information.
+ ///
+ /// \param[in] process
+ /// The crashed process.
+ ///
+ /// \return
+ /// A structured data dictionary containing at each entry, the crash
+ /// information type as the entry key and the matching an array as the
+ /// entry value. \b nullptr if not implemented or if the process has no
+ /// crash information entry. \b error if an error occured.
+ virtual llvm::Expected<StructuredData::DictionarySP>
+ FetchExtendedCrashInformation(lldb_private::Process &process) {
+ return nullptr;
+ }
+
protected:
+ /// Private implementation of connecting to a process. If the stream is set
+ /// we connect synchronously.
+ lldb::ProcessSP DoConnectProcess(llvm::StringRef connect_url,
+ llvm::StringRef plugin_name,
+ Debugger &debugger, Stream *stream,
+ Target *target, Status &error);
bool m_is_host;
// Set to true when we are able to actually set the OS version while being
// connected. For remote platforms, we might set the version ahead of time
@@ -904,7 +938,8 @@ private:
FileSpec GetModuleCacheRoot();
- DISALLOW_COPY_AND_ASSIGN(Platform);
+ Platform(const Platform &) = delete;
+ const Platform &operator=(const Platform &) = delete;
};
class PlatformList {
@@ -971,7 +1006,8 @@ protected:
lldb::PlatformSP m_selected_platform_sp;
private:
- DISALLOW_COPY_AND_ASSIGN(PlatformList);
+ PlatformList(const PlatformList &) = delete;
+ const PlatformList &operator=(const PlatformList &) = delete;
};
class OptionGroupPlatformRSync : public lldb_private::OptionGroup {
@@ -996,7 +1032,9 @@ public:
bool m_ignores_remote_hostname;
private:
- DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformRSync);
+ OptionGroupPlatformRSync(const OptionGroupPlatformRSync &) = delete;
+ const OptionGroupPlatformRSync &
+ operator=(const OptionGroupPlatformRSync &) = delete;
};
class OptionGroupPlatformSSH : public lldb_private::OptionGroup {
@@ -1019,7 +1057,9 @@ public:
std::string m_ssh_opts;
private:
- DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformSSH);
+ OptionGroupPlatformSSH(const OptionGroupPlatformSSH &) = delete;
+ const OptionGroupPlatformSSH &
+ operator=(const OptionGroupPlatformSSH &) = delete;
};
class OptionGroupPlatformCaching : public lldb_private::OptionGroup {
@@ -1041,9 +1081,11 @@ public:
std::string m_cache_dir;
private:
- DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformCaching);
+ OptionGroupPlatformCaching(const OptionGroupPlatformCaching &) = delete;
+ const OptionGroupPlatformCaching &
+ operator=(const OptionGroupPlatformCaching &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Platform_h_
+#endif // LLDB_TARGET_PLATFORM_H
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index 2ba996d4995f..bf9b64547ed5 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Process_h_
-#define liblldb_Process_h_
+#ifndef LLDB_TARGET_PROCESS_H
+#define LLDB_TARGET_PROCESS_H
#include "lldb/Host/Config.h"
@@ -37,6 +37,7 @@
#include "lldb/Target/Memory.h"
#include "lldb/Target/QueueList.h"
#include "lldb/Target/ThreadList.h"
+#include "lldb/Target/ThreadPlanStack.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/Broadcaster.h"
#include "lldb/Utility/Event.h"
@@ -57,7 +58,11 @@ namespace lldb_private {
template <typename B, typename S> struct Range;
-// ProcessProperties
+class ProcessExperimentalProperties : public Properties {
+public:
+ ProcessExperimentalProperties();
+};
+
class ProcessProperties : public Properties {
public:
// Pass nullptr for "process" if the ProcessProperties are to be the global
@@ -81,11 +86,15 @@ public:
bool GetDetachKeepsStopped() const;
void SetDetachKeepsStopped(bool keep_stopped);
bool GetWarningsOptimization() const;
+ bool GetWarningsUnsupportedLanguage() const;
bool GetStopOnExec() const;
std::chrono::seconds GetUtilityExpressionTimeout() const;
+ bool GetOSPluginReportsAllThreads() const;
+ void SetOSPluginReportsAllThreads(bool does_report);
protected:
Process *m_process; // Can be nullptr for global ProcessProperties
+ std::unique_ptr<ProcessExperimentalProperties> m_experimental_properties_up;
};
typedef std::shared_ptr<ProcessProperties> ProcessPropertiesSP;
@@ -139,7 +148,9 @@ public:
return (m_plugin_name.empty() ? nullptr : m_plugin_name.c_str());
}
- void SetProcessPluginName(llvm::StringRef plugin) { m_plugin_name = plugin; }
+ void SetProcessPluginName(llvm::StringRef plugin) {
+ m_plugin_name = std::string(plugin);
+ }
void Clear() {
ProcessInstanceInfo::Clear();
@@ -380,7 +391,7 @@ public:
};
/// Process warning types.
- enum Warnings { eWarningsOptimization = 1 };
+ enum Warnings { eWarningsOptimization = 1, eWarningsUnsupportedLanguage = 2 };
typedef Range<lldb::addr_t, lldb::addr_t> LoadRange;
// We use a read/write lock to allow on or more clients to access the process
@@ -441,6 +452,8 @@ public:
void Dump(Stream *s) const override;
+ virtual bool ShouldStop(Event *event_ptr, bool &found_valid_stopinfo);
+
void DoOnRemoval(Event *event_ptr) override;
static const Process::ProcessEventData *
@@ -486,7 +499,8 @@ public:
int m_update_state;
bool m_interrupted;
- DISALLOW_COPY_AND_ASSIGN(ProcessEventData);
+ ProcessEventData(const ProcessEventData &) = delete;
+ const ProcessEventData &operator=(const ProcessEventData &) = delete;
};
/// Construct with a shared pointer to a target, and the Process listener.
@@ -723,7 +737,7 @@ public:
///
/// \return
/// Returns an error object.
- virtual Status ConnectRemote(Stream *strm, llvm::StringRef remote_url);
+ virtual Status ConnectRemote(llvm::StringRef remote_url);
bool GetShouldDetach() const { return m_should_detach; }
@@ -911,7 +925,7 @@ public:
///
/// \return
/// Returns an error object.
- virtual Status DoConnectRemote(Stream *strm, llvm::StringRef remote_url) {
+ virtual Status DoConnectRemote(llvm::StringRef remote_url) {
Status error;
error.SetErrorString("remote connections are not supported");
return error;
@@ -1265,7 +1279,7 @@ public:
/// LLDB_INVALID_ADDRESS.
///
/// \return
- /// A StructureDataSP object which, if non-empty, will contain the
+ /// A StructuredDataSP object which, if non-empty, will contain the
/// information the DynamicLoader needs to get the initial scan of
/// solibs resolved.
virtual lldb_private::StructuredData::ObjectSP
@@ -1309,9 +1323,14 @@ public:
/// pre-computed.
void PrintWarningOptimization(const SymbolContext &sc);
+ /// Print a user-visible warning about a function written in a
+ /// language that this version of LLDB doesn't support.
+ ///
+ /// \see PrintWarningOptimization
+ void PrintWarningUnsupportedLanguage(const SymbolContext &sc);
+
virtual bool GetProcessInfo(ProcessInstanceInfo &info);
-public:
/// Get the exit status for a process.
///
/// \return
@@ -2196,6 +2215,75 @@ public:
void SetDynamicCheckers(DynamicCheckerFunctions *dynamic_checkers);
+/// Prune ThreadPlanStacks for unreported threads.
+///
+/// \param[in] tid
+/// The tid whose Plan Stack we are seeking to prune.
+///
+/// \return
+/// \b true if the TID is found or \b false if not.
+bool PruneThreadPlansForTID(lldb::tid_t tid);
+
+/// Prune ThreadPlanStacks for all unreported threads.
+void PruneThreadPlans();
+
+ /// Find the thread plan stack associated with thread with \a tid.
+ ///
+ /// \param[in] tid
+ /// The tid whose Plan Stack we are seeking.
+ ///
+ /// \return
+ /// Returns a ThreadPlan if the TID is found or nullptr if not.
+ ThreadPlanStack *FindThreadPlans(lldb::tid_t tid);
+
+ /// Dump the thread plans associated with thread with \a tid.
+ ///
+ /// \param[in/out] strm
+ /// The stream to which to dump the output
+ ///
+ /// \param[in] tid
+ /// The tid whose Plan Stack we are dumping
+ ///
+ /// \param[in] desc_level
+ /// How much detail to dump
+ ///
+ /// \param[in] internal
+ /// If \b true dump all plans, if false only user initiated plans
+ ///
+ /// \param[in] condense_trivial
+ /// If true, only dump a header if the plan stack is just the base plan.
+ ///
+ /// \param[in] skip_unreported_plans
+ /// If true, only dump a plan if it is currently backed by an
+ /// lldb_private::Thread *.
+ ///
+ /// \return
+ /// Returns \b true if TID was found, \b false otherwise
+ bool DumpThreadPlansForTID(Stream &strm, lldb::tid_t tid,
+ lldb::DescriptionLevel desc_level, bool internal,
+ bool condense_trivial, bool skip_unreported_plans);
+
+ /// Dump all the thread plans for this process.
+ ///
+ /// \param[in/out] strm
+ /// The stream to which to dump the output
+ ///
+ /// \param[in] desc_level
+ /// How much detail to dump
+ ///
+ /// \param[in] internal
+ /// If \b true dump all plans, if false only user initiated plans
+ ///
+ /// \param[in] condense_trivial
+ /// If true, only dump a header if the plan stack is just the base plan.
+ ///
+ /// \param[in] skip_unreported_plans
+ /// If true, skip printing all thread plan stacks that don't currently
+ /// have a backing lldb_private::Thread *.
+ void DumpThreadPlans(Stream &strm, lldb::DescriptionLevel desc_level,
+ bool internal, bool condense_trivial,
+ bool skip_unreported_plans);
+
/// Call this to set the lldb in the mode where it breaks on new thread
/// creations, and then auto-restarts. This is useful when you are trying
/// to run only one thread, but either that thread or the kernel is creating
@@ -2665,6 +2753,10 @@ protected:
///see them. This is usually the same as
///< m_thread_list_real, but might be different if there is an OS plug-in
///creating memory threads
+ ThreadPlanStackMap m_thread_plans; ///< This is the list of thread plans for
+ /// threads in m_thread_list, as well as
+ /// threads we knew existed, but haven't
+ /// determined that they have died yet.
ThreadList m_extended_thread_list; ///< Owner for extended threads that may be
///generated, cleared on natural stops
uint32_t m_extended_thread_stop_id; ///< The natural stop id when
@@ -2843,10 +2935,11 @@ private:
void ControlPrivateStateThread(uint32_t signal);
- DISALLOW_COPY_AND_ASSIGN(Process);
+ Process(const Process &) = delete;
+ const Process &operator=(const Process &) = delete;
};
-/// RAII guard that should be aquired when an utility function is called within
+/// RAII guard that should be acquired when an utility function is called within
/// a given process.
class UtilityFunctionScope {
Process *m_process;
@@ -2864,4 +2957,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_Process_h_
+#endif // LLDB_TARGET_PROCESS_H
diff --git a/lldb/include/lldb/Target/ProcessStructReader.h b/lldb/include/lldb/Target/ProcessStructReader.h
index ade29c0a7cf7..0a91bef8048b 100644
--- a/lldb/include/lldb/Target/ProcessStructReader.h
+++ b/lldb/include/lldb/Target/ProcessStructReader.h
@@ -101,4 +101,4 @@ public:
};
}
-#endif // utility_ProcessStructReader_h_
+#endif // LLDB_TARGET_PROCESSSTRUCTREADER_H
diff --git a/lldb/include/lldb/Target/Queue.h b/lldb/include/lldb/Target/Queue.h
index 10b9e0242070..058d46a75a83 100644
--- a/lldb/include/lldb/Target/Queue.h
+++ b/lldb/include/lldb/Target/Queue.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Queue_h_
-#define liblldb_Queue_h_
+#ifndef LLDB_TARGET_QUEUE_H
+#define LLDB_TARGET_QUEUE_H
#include <string>
#include <vector>
@@ -144,9 +144,10 @@ private:
// dispatch_queue_t for this Queue
lldb::QueueKind m_kind;
- DISALLOW_COPY_AND_ASSIGN(Queue);
+ Queue(const Queue &) = delete;
+ const Queue &operator=(const Queue &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Queue_h_
+#endif // LLDB_TARGET_QUEUE_H
diff --git a/lldb/include/lldb/Target/QueueItem.h b/lldb/include/lldb/Target/QueueItem.h
index dfae3b847263..64d3d23b3986 100644
--- a/lldb/include/lldb/Target/QueueItem.h
+++ b/lldb/include/lldb/Target/QueueItem.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_QueueItem_h_
-#define liblldb_QueueItem_h_
+#ifndef LLDB_TARGET_QUEUEITEM_H
+#define LLDB_TARGET_QUEUEITEM_H
#include <memory>
#include <string>
@@ -159,9 +159,10 @@ protected:
std::string m_target_queue_label;
private:
- DISALLOW_COPY_AND_ASSIGN(QueueItem);
+ QueueItem(const QueueItem &) = delete;
+ const QueueItem &operator=(const QueueItem &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_QueueItem_h_
+#endif // LLDB_TARGET_QUEUEITEM_H
diff --git a/lldb/include/lldb/Target/QueueList.h b/lldb/include/lldb/Target/QueueList.h
index 761107e41def..7c74a6a99ac1 100644
--- a/lldb/include/lldb/Target/QueueList.h
+++ b/lldb/include/lldb/Target/QueueList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_QueueList_h_
-#define liblldb_QueueList_h_
+#ifndef LLDB_TARGET_QUEUELIST_H
+#define LLDB_TARGET_QUEUELIST_H
#include <mutex>
#include <vector>
@@ -107,4 +107,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_QueueList_h_
+#endif // LLDB_TARGET_QUEUELIST_H
diff --git a/lldb/include/lldb/Target/RegisterCheckpoint.h b/lldb/include/lldb/Target/RegisterCheckpoint.h
index 4f9654f76343..d2bcc614f587 100644
--- a/lldb/include/lldb/Target/RegisterCheckpoint.h
+++ b/lldb/include/lldb/Target/RegisterCheckpoint.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterCheckpoint_h_
-#define liblldb_RegisterCheckpoint_h_
+#ifndef LLDB_TARGET_REGISTERCHECKPOINT_H
+#define LLDB_TARGET_REGISTERCHECKPOINT_H
#include "lldb/Target/StackID.h"
#include "lldb/Utility/UserID.h"
@@ -45,9 +45,10 @@ protected:
Reason m_reason;
// Make RegisterCheckpointSP if you wish to share the data in this class.
- DISALLOW_COPY_AND_ASSIGN(RegisterCheckpoint);
+ RegisterCheckpoint(const RegisterCheckpoint &) = delete;
+ const RegisterCheckpoint &operator=(const RegisterCheckpoint &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_RegisterCheckpoint_h_
+#endif // LLDB_TARGET_REGISTERCHECKPOINT_H
diff --git a/lldb/include/lldb/Target/RegisterContext.h b/lldb/include/lldb/Target/RegisterContext.h
index d6212dd49dd6..5e795e59f941 100644
--- a/lldb/include/lldb/Target/RegisterContext.h
+++ b/lldb/include/lldb/Target/RegisterContext.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContext_h_
-#define liblldb_RegisterContext_h_
+#ifndef LLDB_TARGET_REGISTERCONTEXT_H
+#define LLDB_TARGET_REGISTERCONTEXT_H
#include "lldb/Target/ExecutionContextScope.h"
#include "lldb/lldb-private.h"
@@ -39,6 +39,8 @@ public:
virtual const RegisterSet *GetRegisterSet(size_t reg_set) = 0;
+ virtual lldb::ByteOrder GetByteOrder();
+
virtual bool ReadRegister(const RegisterInfo *reg_info,
RegisterValue &reg_value) = 0;
@@ -105,7 +107,7 @@ public:
/// The equivalent register number in the eRegisterKindLLDB
/// numbering scheme, if possible, else LLDB_INVALID_REGNUM.
virtual uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
- uint32_t num) = 0;
+ uint32_t num);
// Subclasses can override these functions if desired
virtual uint32_t NumSupportedHardwareBreakpoints();
@@ -201,9 +203,10 @@ protected:
uint32_t m_stop_id; // The stop ID that any data in this context is valid for
private:
// For RegisterContext only
- DISALLOW_COPY_AND_ASSIGN(RegisterContext);
+ RegisterContext(const RegisterContext &) = delete;
+ const RegisterContext &operator=(const RegisterContext &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_RegisterContext_h_
+#endif // LLDB_TARGET_REGISTERCONTEXT_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h b/lldb/include/lldb/Target/RegisterContextUnwind.h
index 114ac35591e7..fa96c3e42c78 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.h
+++ b/lldb/include/lldb/Target/RegisterContextUnwind.h
@@ -1,5 +1,4 @@
-//===-- RegisterContextLLDB.h --------------------------------------------*- C++
-//-*-===//
+//===-- RegisterContextUnwind.h ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,32 +6,33 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_RegisterContextLLDB_h_
-#define lldb_RegisterContextLLDB_h_
+#ifndef LLDB_TARGET_REGISTERCONTEXTUNWIND_H
+#define LLDB_TARGET_REGISTERCONTEXTUNWIND_H
#include <vector>
-#include "UnwindLLDB.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/RegisterNumber.h"
+#include "lldb/Target/UnwindLLDB.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
class UnwindLLDB;
-class RegisterContextLLDB : public lldb_private::RegisterContext {
+class RegisterContextUnwind : public lldb_private::RegisterContext {
public:
- typedef std::shared_ptr<RegisterContextLLDB> SharedPtr;
+ typedef std::shared_ptr<RegisterContextUnwind> SharedPtr;
- RegisterContextLLDB(lldb_private::Thread &thread, const SharedPtr &next_frame,
- lldb_private::SymbolContext &sym_ctx,
- uint32_t frame_number,
- lldb_private::UnwindLLDB &unwind_lldb);
+ RegisterContextUnwind(lldb_private::Thread &thread,
+ const SharedPtr &next_frame,
+ lldb_private::SymbolContext &sym_ctx,
+ uint32_t frame_number,
+ lldb_private::UnwindLLDB &unwind_lldb);
- ~RegisterContextLLDB() override = default;
+ ~RegisterContextUnwind() override = default;
void InvalidateAllRegisters() override;
@@ -247,13 +247,13 @@ private:
m_registers; // where to find reg values for this frame
lldb_private::UnwindLLDB &m_parent_unwind; // The UnwindLLDB that is creating
- // this RegisterContextLLDB
+ // this RegisterContextUnwind
- // For RegisterContextLLDB only
-
- DISALLOW_COPY_AND_ASSIGN(RegisterContextLLDB);
+ RegisterContextUnwind(const RegisterContextUnwind &) = delete;
+ const RegisterContextUnwind &
+ operator=(const RegisterContextUnwind &) = delete;
};
} // namespace lldb_private
-#endif // lldb_RegisterContextLLDB_h_
+#endif // LLDB_TARGET_REGISTERCONTEXTUNWIND_H
diff --git a/lldb/include/lldb/Target/RegisterNumber.h b/lldb/include/lldb/Target/RegisterNumber.h
index 0bef0c13f378..362812bcffd0 100644
--- a/lldb/include/lldb/Target/RegisterNumber.h
+++ b/lldb/include/lldb/Target/RegisterNumber.h
@@ -56,4 +56,4 @@ private:
const char *m_name;
};
-#endif // liblldb_RegisterNumber_h
+#endif // LLDB_TARGET_REGISTERNUMBER_H
diff --git a/lldb/include/lldb/Target/RemoteAwarePlatform.h b/lldb/include/lldb/Target/RemoteAwarePlatform.h
index 55d5ff673f1d..5741dbe027b7 100644
--- a/lldb/include/lldb/Target/RemoteAwarePlatform.h
+++ b/lldb/include/lldb/Target/RemoteAwarePlatform.h
@@ -22,6 +22,10 @@ public:
bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch,
ModuleSpec &module_spec) override;
+ Status
+ ResolveExecutable(const ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
+ const FileSpecList *module_search_paths_ptr) override;
+
lldb::user_id_t OpenFile(const FileSpec &file_spec, File::OpenOptions flags,
uint32_t mode, Status &error) override;
diff --git a/lldb/include/lldb/Target/SectionLoadHistory.h b/lldb/include/lldb/Target/SectionLoadHistory.h
index 71b5d0c42746..dd024301d0cf 100644
--- a/lldb/include/lldb/Target/SectionLoadHistory.h
+++ b/lldb/include/lldb/Target/SectionLoadHistory.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_SectionLoadHistory_h_
-#define liblldb_SectionLoadHistory_h_
+#ifndef LLDB_TARGET_SECTIONLOADHISTORY_H
+#define LLDB_TARGET_SECTIONLOADHISTORY_H
#include <map>
#include <mutex>
@@ -75,9 +75,10 @@ protected:
mutable std::recursive_mutex m_mutex;
private:
- DISALLOW_COPY_AND_ASSIGN(SectionLoadHistory);
+ SectionLoadHistory(const SectionLoadHistory &) = delete;
+ const SectionLoadHistory &operator=(const SectionLoadHistory &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_SectionLoadHistory_h_
+#endif // LLDB_TARGET_SECTIONLOADHISTORY_H
diff --git a/lldb/include/lldb/Target/SectionLoadList.h b/lldb/include/lldb/Target/SectionLoadList.h
index caefa00ec1da..e8535e7ac51a 100644
--- a/lldb/include/lldb/Target/SectionLoadList.h
+++ b/lldb/include/lldb/Target/SectionLoadList.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_SectionLoadList_h_
-#define liblldb_SectionLoadList_h_
+#ifndef LLDB_TARGET_SECTIONLOADLIST_H
+#define LLDB_TARGET_SECTIONLOADLIST_H
#include <map>
#include <mutex>
@@ -70,4 +70,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_SectionLoadList_h_
+#endif // LLDB_TARGET_SECTIONLOADLIST_H
diff --git a/lldb/include/lldb/Target/StackFrame.h b/lldb/include/lldb/Target/StackFrame.h
index 1c6a2b481160..905c56c91263 100644
--- a/lldb/include/lldb/Target/StackFrame.h
+++ b/lldb/include/lldb/Target/StackFrame.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_StackFrame_h_
-#define liblldb_StackFrame_h_
+#ifndef LLDB_TARGET_STACKFRAME_H
+#define LLDB_TARGET_STACKFRAME_H
#include <memory>
#include <mutex>
@@ -367,12 +367,6 @@ public:
/// may have limited support for inspecting variables.
bool IsArtificial() const;
- /// Query whether this frame behaves like the zeroth frame, in the sense
- /// that its pc value might not immediately follow a call (and thus might
- /// be the first address of its function). True for actual frame zero as
- /// well as any other frame with the same trait.
- bool BehavesLikeZerothFrame() const;
-
/// Query this frame to find what frame it is in this Thread's
/// StackFrameList.
///
@@ -517,6 +511,11 @@ private:
bool m_cfa_is_valid; // Does this frame have a CFA? Different from CFA ==
// LLDB_INVALID_ADDRESS
Kind m_stack_frame_kind;
+
+ // Whether this frame behaves like the zeroth frame, in the sense
+ // that its pc value might not immediately follow a call (and thus might
+ // be the first address of its function). True for actual frame zero as
+ // well as any other frame with the same trait.
bool m_behaves_like_zeroth_frame;
lldb::VariableListSP m_variable_list_sp;
ValueObjectList m_variable_list_value_objects; // Value objects for each
@@ -526,9 +525,10 @@ private:
StreamString m_disassembly;
std::recursive_mutex m_mutex;
- DISALLOW_COPY_AND_ASSIGN(StackFrame);
+ StackFrame(const StackFrame &) = delete;
+ const StackFrame &operator=(const StackFrame &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_StackFrame_h_
+#endif // LLDB_TARGET_STACKFRAME_H
diff --git a/lldb/include/lldb/Target/StackFrameList.h b/lldb/include/lldb/Target/StackFrameList.h
index 5eb791950172..1b0b986d7059 100644
--- a/lldb/include/lldb/Target/StackFrameList.h
+++ b/lldb/include/lldb/Target/StackFrameList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_StackFrameList_h_
-#define liblldb_StackFrameList_h_
+#ifndef LLDB_TARGET_STACKFRAMELIST_H
+#define LLDB_TARGET_STACKFRAMELIST_H
#include <memory>
#include <mutex>
@@ -94,7 +94,7 @@ protected:
void GetFramesUpTo(uint32_t end_idx);
- void GetOnlyConcreteFramesUpTo(uint32_t end_idx, Unwind *unwinder);
+ void GetOnlyConcreteFramesUpTo(uint32_t end_idx, Unwind &unwinder);
void SynthesizeTailCallFrames(StackFrame &next_frame);
@@ -155,9 +155,10 @@ protected:
const bool m_show_inlined_frames;
private:
- DISALLOW_COPY_AND_ASSIGN(StackFrameList);
+ StackFrameList(const StackFrameList &) = delete;
+ const StackFrameList &operator=(const StackFrameList &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_StackFrameList_h_
+#endif // LLDB_TARGET_STACKFRAMELIST_H
diff --git a/lldb/include/lldb/Target/StackFrameRecognizer.h b/lldb/include/lldb/Target/StackFrameRecognizer.h
index 2021ac5215f3..9c9105ac04e4 100644
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h
@@ -6,12 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_StackFrameRecognizer_h_
-#define liblldb_StackFrameRecognizer_h_
+#ifndef LLDB_TARGET_STACKFRAMERECOGNIZER_H
+#define LLDB_TARGET_STACKFRAMERECOGNIZER_H
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Symbol/VariableList.h"
+#include "lldb/Target/StopInfo.h"
#include "lldb/Utility/StructuredData.h"
#include "lldb/lldb-private-forward.h"
#include "lldb/lldb-public.h"
@@ -33,10 +34,14 @@ public:
virtual lldb::ValueObjectSP GetExceptionObject() {
return lldb::ValueObjectSP();
}
+ virtual lldb::StackFrameSP GetMostRelevantFrame() { return nullptr; };
virtual ~RecognizedStackFrame(){};
+ std::string GetStopDescription() { return m_stop_desc; }
+
protected:
lldb::ValueObjectListSP m_arguments;
+ std::string m_stop_desc;
};
/// \class StackFrameRecognizer
@@ -85,7 +90,9 @@ public:
lldb::StackFrameSP frame) override;
private:
- DISALLOW_COPY_AND_ASSIGN(ScriptedStackFrameRecognizer);
+ ScriptedStackFrameRecognizer(const ScriptedStackFrameRecognizer &) = delete;
+ const ScriptedStackFrameRecognizer &
+ operator=(const ScriptedStackFrameRecognizer &) = delete;
};
/// \class StackFrameRecognizerManager
@@ -97,7 +104,7 @@ class StackFrameRecognizerManager {
public:
static void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
ConstString module,
- ConstString symbol,
+ llvm::ArrayRef<ConstString> symbols,
bool first_instruction_only = true);
static void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
@@ -105,10 +112,11 @@ public:
lldb::RegularExpressionSP symbol,
bool first_instruction_only = true);
- static void ForEach(
- std::function<void(uint32_t recognizer_id, std::string recognizer_name,
- std::string module, std::string symbol,
- bool regexp)> const &callback);
+ static void
+ ForEach(std::function<void(uint32_t recognizer_id,
+ std::string recognizer_name, std::string module,
+ llvm::ArrayRef<ConstString> symbols,
+ bool regexp)> const &callback);
static bool RemoveRecognizerWithID(uint32_t recognizer_id);
@@ -158,4 +166,4 @@ class ValueObjectRecognizerSynthesizedValue : public ValueObject {
} // namespace lldb_private
-#endif // liblldb_StackFrameRecognizer_h_
+#endif // LLDB_TARGET_STACKFRAMERECOGNIZER_H
diff --git a/lldb/include/lldb/Target/StackID.h b/lldb/include/lldb/Target/StackID.h
index a649a4faa939..827ed1be7c0f 100644
--- a/lldb/include/lldb/Target/StackID.h
+++ b/lldb/include/lldb/Target/StackID.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_StackID_h_
-#define liblldb_StackID_h_
+#ifndef LLDB_TARGET_STACKID_H
+#define LLDB_TARGET_STACKID_H
#include "lldb/Core/AddressRange.h"
#include "lldb/lldb-private.h"
@@ -96,4 +96,4 @@ bool operator<(const StackID &lhs, const StackID &rhs);
} // namespace lldb_private
-#endif // liblldb_StackID_h_
+#endif // LLDB_TARGET_STACKID_H
diff --git a/lldb/include/lldb/Target/StopInfo.h b/lldb/include/lldb/Target/StopInfo.h
index 61e1fbd4bd46..4378d2d63799 100644
--- a/lldb/include/lldb/Target/StopInfo.h
+++ b/lldb/include/lldb/Target/StopInfo.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_StopInfo_h_
-#define liblldb_StopInfo_h_
+#ifndef LLDB_TARGET_STOPINFO_H
+#define LLDB_TARGET_STOPINFO_H
#include <string>
@@ -183,9 +183,10 @@ protected:
private:
friend class Thread;
- DISALLOW_COPY_AND_ASSIGN(StopInfo);
+ StopInfo(const StopInfo &) = delete;
+ const StopInfo &operator=(const StopInfo &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_StopInfo_h_
+#endif // LLDB_TARGET_STOPINFO_H
diff --git a/lldb/include/lldb/Target/StructuredDataPlugin.h b/lldb/include/lldb/Target/StructuredDataPlugin.h
index b20bdb3b263a..09241d5281fb 100644
--- a/lldb/include/lldb/Target/StructuredDataPlugin.h
+++ b/lldb/include/lldb/Target/StructuredDataPlugin.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef StructuredDataPlugin_h
-#define StructuredDataPlugin_h
+#ifndef LLDB_TARGET_STRUCTUREDDATAPLUGIN_H
+#define LLDB_TARGET_STRUCTUREDDATAPLUGIN_H
#include "lldb/Core/PluginInterface.h"
#include "lldb/Utility/StructuredData.h"
@@ -162,7 +162,8 @@ protected:
private:
lldb::ProcessWP m_process_wp;
- DISALLOW_COPY_AND_ASSIGN(StructuredDataPlugin);
+ StructuredDataPlugin(const StructuredDataPlugin &) = delete;
+ const StructuredDataPlugin &operator=(const StructuredDataPlugin &) = delete;
};
}
diff --git a/lldb/include/lldb/Target/SystemRuntime.h b/lldb/include/lldb/Target/SystemRuntime.h
index b45f882d36b0..4f07d7ab52e5 100644
--- a/lldb/include/lldb/Target/SystemRuntime.h
+++ b/lldb/include/lldb/Target/SystemRuntime.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_SystemRuntime_h_
-#define liblldb_SystemRuntime_h_
+#ifndef LLDB_TARGET_SYSTEMRUNTIME_H
+#define LLDB_TARGET_SYSTEMRUNTIME_H
#include <vector>
@@ -300,9 +300,10 @@ protected:
std::vector<ConstString> m_types;
private:
- DISALLOW_COPY_AND_ASSIGN(SystemRuntime);
+ SystemRuntime(const SystemRuntime &) = delete;
+ const SystemRuntime &operator=(const SystemRuntime &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_SystemRuntime_h_
+#endif // LLDB_TARGET_SYSTEMRUNTIME_H
diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h
index 1e9153c401ef..280ce6359c72 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Target_h_
-#define liblldb_Target_h_
+#ifndef LLDB_TARGET_TARGET_H
+#define LLDB_TARGET_TARGET_H
#include <list>
#include <map>
@@ -36,6 +36,8 @@
namespace lldb_private {
+class ClangModulesDeclVendor;
+
OptionEnumValues GetDynamicValueTypes();
enum InlineStrategy {
@@ -62,7 +64,6 @@ enum LoadDependentFiles {
eLoadDependentsNo,
};
-// TargetProperties
class TargetExperimentalProperties : public Properties {
public:
TargetExperimentalProperties();
@@ -133,6 +134,8 @@ public:
bool GetEnableAutoApplyFixIts() const;
+ uint64_t GetNumberOfRetriesWithFixits() const;
+
bool GetEnableNotifyAboutFixIts() const;
bool GetEnableSaveObjects() const;
@@ -202,11 +205,16 @@ public:
bool GetInjectLocalVariables(ExecutionContext *exe_ctx) const;
void SetInjectLocalVariables(ExecutionContext *exe_ctx, bool b);
-
+
void SetRequireHardwareBreakpoints(bool b);
bool GetRequireHardwareBreakpoints() const;
+ bool GetAutoInstallMainExecutable() const;
+
+ void UpdateLaunchInfoFromProperties();
+
+
private:
// Callbacks for m_launch_info.
void Arg0ValueChangedCallback();
@@ -219,9 +227,12 @@ private:
void DisableASLRValueChangedCallback();
void DisableSTDIOValueChangedCallback();
+ Environment ComputeEnvironment() const;
+
// Member variables.
ProcessLaunchInfo m_launch_info;
std::unique_ptr<TargetExperimentalProperties> m_experimental_properties_up;
+ Target *m_target;
};
class EvaluateExpressionOptions {
@@ -371,6 +382,12 @@ public:
bool GetAutoApplyFixIts() const { return m_auto_apply_fixits; }
+ void SetRetriesWithFixIts(uint64_t number_of_retries) {
+ m_retries_with_fixits = number_of_retries;
+ }
+
+ uint64_t GetRetriesWithFixIts() const { return m_retries_with_fixits; }
+
bool IsForUtilityExpr() const { return m_running_utility_expression; }
void SetIsForUtilityExpr(bool b) { m_running_utility_expression = b; }
@@ -392,6 +409,7 @@ private:
bool m_ansi_color_errors = false;
bool m_result_is_internal = false;
bool m_auto_apply_fixits = true;
+ uint64_t m_retries_with_fixits = 1;
/// True if the executed code should be treated as utility code that is only
/// used by LLDB internally.
bool m_running_utility_expression = false;
@@ -467,7 +485,8 @@ public:
lldb::TargetSP m_target_sp;
ModuleList m_module_list;
- DISALLOW_COPY_AND_ASSIGN(TargetEventData);
+ TargetEventData(const TargetEventData &) = delete;
+ const TargetEventData &operator=(const TargetEventData &) = delete;
};
~Target() override;
@@ -940,7 +959,7 @@ public:
///
/// \param[in] set_platform
/// If \b true, then the platform will be adjusted if the currently
- /// selected platform is not compatible with the archicture being set.
+ /// selected platform is not compatible with the architecture being set.
/// If \b false, then just the architecture will be set even if the
/// currently selected platform isn't compatible (in case it might be
/// manually set following this function call).
@@ -1054,8 +1073,6 @@ public:
const char *name,
Status &error);
- lldb::ClangASTImporterSP GetClangASTImporter();
-
// Install any files through the platform that need be to installed prior to
// launching or attaching.
Status Install(ProcessLaunchInfo *launch_info);
@@ -1093,11 +1110,6 @@ public:
lldb::ExpressionVariableSP GetPersistentVariable(ConstString name);
- /// Return the next available number for numbered persistent variables.
- unsigned GetNextPersistentVariableIndex() {
- return m_next_persistent_variable_index++;
- }
-
lldb::addr_t GetPersistentSymbol(ConstString name);
/// This method will return the address of the starting function for
@@ -1302,8 +1314,7 @@ protected:
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_up;
+ std::unique_ptr<ClangModulesDeclVendor> m_clang_modules_decl_vendor_up;
lldb::SourceManagerUP m_source_manager_up;
@@ -1359,9 +1370,10 @@ private:
void FinalizeFileActions(ProcessLaunchInfo &info);
- DISALLOW_COPY_AND_ASSIGN(Target);
+ Target(const Target &) = delete;
+ const Target &operator=(const Target &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Target_h_
+#endif // LLDB_TARGET_TARGET_H
diff --git a/lldb/include/lldb/Target/TargetList.h b/lldb/include/lldb/Target/TargetList.h
index 50a7a321ead1..5ed0344f175c 100644
--- a/lldb/include/lldb/Target/TargetList.h
+++ b/lldb/include/lldb/Target/TargetList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_TargetList_h_
-#define liblldb_TargetList_h_
+#ifndef LLDB_TARGET_TARGETLIST_H
+#define LLDB_TARGET_TARGETLIST_H
#include <mutex>
#include <vector>
@@ -206,9 +206,10 @@ private:
lldb::PlatformSP &platform_sp,
lldb::TargetSP &target_sp, bool is_dummy_target);
- DISALLOW_COPY_AND_ASSIGN(TargetList);
+ TargetList(const TargetList &) = delete;
+ const TargetList &operator=(const TargetList &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_TargetList_h_
+#endif // LLDB_TARGET_TARGETLIST_H
diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h
index cdc8d39251c6..205a0d965c63 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ b/lldb/include/lldb/Target/Thread.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Thread_h_
-#define liblldb_Thread_h_
+#ifndef LLDB_TARGET_THREAD_H
+#define LLDB_TARGET_THREAD_H
#include <memory>
#include <mutex>
@@ -28,6 +28,8 @@
namespace lldb_private {
+class ThreadPlanStack;
+
class ThreadProperties : public Properties {
public:
ThreadProperties(bool is_global);
@@ -111,7 +113,8 @@ public:
lldb::ThreadSP m_thread_sp;
StackID m_stack_id;
- DISALLOW_COPY_AND_ASSIGN(ThreadEventData);
+ ThreadEventData(const ThreadEventData &) = delete;
+ const ThreadEventData &operator=(const ThreadEventData &) = delete;
};
struct ThreadStateCheckpoint {
@@ -119,7 +122,7 @@ public:
// bit of data.
lldb::StopInfoSP stop_info_sp; // You have to restore the stop info or you
// might continue with the wrong signals.
- std::vector<lldb::ThreadPlanSP> m_completed_plan_stack;
+ size_t m_completed_plan_checkpoint;
lldb::RegisterCheckpointSP
register_backup_sp; // You need to restore the registers, of course...
uint32_t current_inlined_depth;
@@ -177,8 +180,6 @@ public:
/// to force the thread to run (e.g. the "thread continue" command, or are
/// resetting the state
/// (e.g. in SBThread::Resume()), then pass true to override_suspend.
- /// \return
- /// The User resume state for this thread.
void SetResumeState(lldb::StateType state, bool override_suspend = false) {
if (m_resume_state == lldb::eStateSuspended && !override_suspend)
return;
@@ -216,6 +217,12 @@ public:
virtual void RefreshStateAfterStop() = 0;
+ void SelectMostRelevantFrame();
+
+ std::string GetStopDescription();
+
+ std::string GetStopDescriptionRaw();
+
void WillStop();
bool ShouldStop(Event *event_ptr);
@@ -908,7 +915,7 @@ public:
///
/// \return
/// A pointer to the next executed plan.
- ThreadPlan *GetCurrentPlan();
+ ThreadPlan *GetCurrentPlan() const;
/// Unwinds the thread stack for the innermost expression plan currently
/// on the thread plan stack.
@@ -923,14 +930,14 @@ public:
///
/// \return
/// A pointer to the last completed plan.
- lldb::ThreadPlanSP GetCompletedPlan();
+ lldb::ThreadPlanSP GetCompletedPlan() const;
/// Gets the outer-most return value from the completed plans
///
/// \return
/// A ValueObjectSP, either empty if there is no return value,
/// or containing the return value.
- lldb::ValueObjectSP GetReturnValueObject();
+ lldb::ValueObjectSP GetReturnValueObject() const;
/// Gets the outer-most expression variable from the completed plans
///
@@ -938,7 +945,7 @@ public:
/// A ExpressionVariableSP, either empty if there is no
/// plan completed an expression during the current stop
/// or the expression variable that was made for the completed expression.
- lldb::ExpressionVariableSP GetExpressionVariable();
+ lldb::ExpressionVariableSP GetExpressionVariable() const;
/// Checks whether the given plan is in the completed plans for this
/// stop.
@@ -949,7 +956,7 @@ public:
/// \return
/// Returns true if the input plan is in the completed plan stack,
/// false otherwise.
- bool IsThreadPlanDone(ThreadPlan *plan);
+ bool IsThreadPlanDone(ThreadPlan *plan) const;
/// Checks whether the given plan is in the discarded plans for this
/// stop.
@@ -960,14 +967,14 @@ public:
/// \return
/// Returns true if the input plan is in the discarded plan stack,
/// false otherwise.
- bool WasThreadPlanDiscarded(ThreadPlan *plan);
+ bool WasThreadPlanDiscarded(ThreadPlan *plan) const;
/// Check if we have completed plan to override breakpoint stop reason
///
/// \return
/// Returns true if completed plan stack is not empty
/// false otherwise.
- bool CompletedPlanOverridesBreakpoint();
+ bool CompletedPlanOverridesBreakpoint() const;
/// Queues a generic thread plan.
///
@@ -1013,16 +1020,6 @@ public:
/// otherwise.
bool DiscardUserThreadPlansUpToIndex(uint32_t thread_index);
- /// Prints the current plan stack.
- ///
- /// \param[in] s
- /// The stream to which to dump the plan stack info.
- ///
- void DumpThreadPlans(
- Stream *s,
- lldb::DescriptionLevel desc_level = lldb::eDescriptionLevelVerbose,
- bool include_internal = true, bool ignore_boring = false) const;
-
virtual bool CheckpointThreadState(ThreadStateCheckpoint &saved_state);
virtual bool
@@ -1151,7 +1148,7 @@ public:
/// Some Thread subclasses may maintain a token to help with providing
/// an extended backtrace. The SystemRuntime plugin will set/request this.
///
- /// \param [in] token
+ /// \param [in] token The extended backtrace token.
virtual void SetExtendedBacktraceToken(uint64_t token) {}
/// Gets the extended backtrace token for this thread
@@ -1181,17 +1178,17 @@ protected:
// be called by classes that derive from Thread in their destructor.
virtual void DestroyThread();
- void PushPlan(lldb::ThreadPlanSP &plan_sp);
+ ThreadPlanStack &GetPlans() const;
+
+ void PushPlan(lldb::ThreadPlanSP plan_sp);
void PopPlan();
void DiscardPlan();
- ThreadPlan *GetPreviousPlan(ThreadPlan *plan);
+ ThreadPlan *GetPreviousPlan(ThreadPlan *plan) const;
- typedef std::vector<lldb::ThreadPlanSP> plan_stack;
-
- virtual lldb_private::Unwind *GetUnwinder();
+ virtual Unwind &GetUnwinder();
// Check to see whether the thread is still at the last breakpoint hit that
// stopped it.
@@ -1215,7 +1212,7 @@ protected:
m_temporary_resume_state = new_state;
}
- void FunctionOptimizationWarning(lldb_private::StackFrame *frame);
+ void FrameSelectedCallback(lldb_private::StackFrame *frame);
// Classes that inherit from Process can see and modify these
lldb::ProcessWP m_process_wp; ///< The process that owns this thread.
@@ -1234,13 +1231,6 @@ protected:
lldb::StateType m_state; ///< The state of our process.
mutable std::recursive_mutex
m_state_mutex; ///< Multithreaded protection for m_state.
- plan_stack m_plan_stack; ///< The stack of plans this thread is executing.
- plan_stack m_completed_plan_stack; ///< Plans that have been completed by this
- ///stop. They get deleted when the thread
- ///resumes.
- plan_stack m_discarded_plan_stack; ///< Plans that have been discarded by this
- ///stop. They get deleted when the thread
- ///resumes.
mutable std::recursive_mutex
m_frame_mutex; ///< Multithreaded protection for m_state.
lldb::StackFrameListSP m_curr_frames_sp; ///< The stack frames that get lazily
@@ -1261,20 +1251,19 @@ protected:
bool m_destroy_called; // This is used internally to make sure derived Thread
// classes call DestroyThread.
LazyBool m_override_should_notify;
+ mutable std::unique_ptr<ThreadPlanStack> m_null_plan_stack_up;
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
-private:
- bool PlanIsBasePlan(ThreadPlan *plan_ptr);
-
void BroadcastSelectedFrameChange(StackID &new_frame_id);
- DISALLOW_COPY_AND_ASSIGN(Thread);
+ Thread(const Thread &) = delete;
+ const Thread &operator=(const Thread &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Thread_h_
+#endif // LLDB_TARGET_THREAD_H
diff --git a/lldb/include/lldb/Target/ThreadCollection.h b/lldb/include/lldb/Target/ThreadCollection.h
index 29ea827203e5..40dc938976ff 100644
--- a/lldb/include/lldb/Target/ThreadCollection.h
+++ b/lldb/include/lldb/Target/ThreadCollection.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadCollection_h_
-#define liblldb_ThreadCollection_h_
+#ifndef LLDB_TARGET_THREADCOLLECTION_H
+#define LLDB_TARGET_THREADCOLLECTION_H
#include <mutex>
#include <vector>
@@ -56,4 +56,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_ThreadCollection_h_
+#endif // LLDB_TARGET_THREADCOLLECTION_H
diff --git a/lldb/include/lldb/Target/ThreadList.h b/lldb/include/lldb/Target/ThreadList.h
index 64ddf5aea504..6af04f8ffc37 100644
--- a/lldb/include/lldb/Target/ThreadList.h
+++ b/lldb/include/lldb/Target/ThreadList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadList_h_
-#define liblldb_ThreadList_h_
+#ifndef LLDB_TARGET_THREADLIST_H
+#define LLDB_TARGET_THREADLIST_H
#include <mutex>
#include <vector>
@@ -156,4 +156,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ThreadList_h_
+#endif // LLDB_TARGET_THREADLIST_H
diff --git a/lldb/include/lldb/Target/ThreadPlan.h b/lldb/include/lldb/Target/ThreadPlan.h
index ff87ed23cda5..8c2f9776eeb3 100644
--- a/lldb/include/lldb/Target/ThreadPlan.h
+++ b/lldb/include/lldb/Target/ThreadPlan.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadPlan_h_
-#define liblldb_ThreadPlan_h_
+#ifndef LLDB_TARGET_THREADPLAN_H
+#define LLDB_TARGET_THREADPLAN_H
#include <mutex>
#include <string>
@@ -251,7 +251,7 @@ namespace lldb_private {
// However, if the plan doesn't want to be
// the stop reason, then it can call SetPlanComplete and pass in "false" for
// the "success" parameter. In that case,
-// the real stop reason will be used instead. One exapmle of this is the
+// the real stop reason will be used instead. One example of this is the
// "StepRangeStepIn" thread plan. If it stops
// because of a crash or breakpoint hit, it wants to unship itself, because it
// isn't so useful to have step in keep going
@@ -369,16 +369,16 @@ public:
///
/// \return
/// A pointer to the thread plan's owning thread.
- Thread &GetThread() { return m_thread; }
+ Thread &GetThread();
- const Thread &GetThread() const { return m_thread; }
+ Target &GetTarget();
- Target &GetTarget() { return m_thread.GetProcess()->GetTarget(); }
-
- const Target &GetTarget() const { return m_thread.GetProcess()->GetTarget(); }
+ const Target &GetTarget() const;
/// Print a description of this thread to the stream \a s.
- /// \a thread.
+ /// \a thread. Don't expect that the result of GetThread is valid in
+ /// the description method. This might get called when the underlying
+ /// Thread has not been reported, so we only know the TID and not the thread.
///
/// \param[in] s
/// The stream to which to print the description.
@@ -461,8 +461,12 @@ public:
virtual void WillPop();
// This pushes a plan onto the plan stack of the current plan's thread.
+ // Also sets the plans to private and not master plans. A plan pushed by
+ // another thread plan is never either of the above.
void PushPlan(lldb::ThreadPlanSP &thread_plan_sp) {
- m_thread.PushPlan(thread_plan_sp);
+ GetThread().PushPlan(thread_plan_sp);
+ thread_plan_sp->SetPrivate(false);
+ thread_plan_sp->SetIsMasterPlan(false);
}
ThreadPlanKind GetKind() const { return m_kind; }
@@ -493,7 +497,9 @@ public:
// original stop reason so that stopping and calling a few functions won't
// lose the history of the run. This call can be implemented to get you back
// to the real stop info.
- virtual lldb::StopInfoSP GetRealStopInfo() { return m_thread.GetStopInfo(); }
+ virtual lldb::StopInfoSP GetRealStopInfo() {
+ return GetThread().GetStopInfo();
+ }
// If the completion of the thread plan stepped out of a function, the return
// value of the function might have been captured by the thread plan
@@ -556,17 +562,17 @@ protected:
// This is mostly a formal requirement, it allows us to make the Thread's
// GetPreviousPlan protected, but only friend ThreadPlan to thread.
- ThreadPlan *GetPreviousPlan() { return m_thread.GetPreviousPlan(this); }
+ ThreadPlan *GetPreviousPlan() { return GetThread().GetPreviousPlan(this); }
// This forwards the private Thread::GetPrivateStopInfo which is generally
// what ThreadPlan's need to know.
lldb::StopInfoSP GetPrivateStopInfo() {
- return m_thread.GetPrivateStopInfo();
+ return GetThread().GetPrivateStopInfo();
}
void SetStopInfo(lldb::StopInfoSP stop_reason_sp) {
- m_thread.SetStopInfo(stop_reason_sp);
+ GetThread().SetStopInfo(stop_reason_sp);
}
void CachePlanExplainsStop(bool does_explain) {
@@ -582,7 +588,8 @@ protected:
bool IsUsuallyUnexplainedStopReason(lldb::StopReason);
Status m_status;
- Thread &m_thread;
+ Process &m_process;
+ lldb::tid_t m_tid;
Vote m_stop_vote;
Vote m_run_vote;
bool m_takes_iteration_count;
@@ -593,6 +600,9 @@ private:
// For ThreadPlan only
static lldb::user_id_t GetNextID();
+ Thread *m_thread; // Stores a cached value of the thread, which is set to
+ // nullptr when the thread resumes. Don't use this anywhere
+ // but ThreadPlan::GetThread().
ThreadPlanKind m_kind;
std::string m_name;
std::recursive_mutex m_plan_complete_mutex;
@@ -605,8 +615,8 @@ private:
lldb::ThreadPlanTracerSP m_tracer_sp;
-private:
- DISALLOW_COPY_AND_ASSIGN(ThreadPlan);
+ ThreadPlan(const ThreadPlan &) = delete;
+ const ThreadPlan &operator=(const ThreadPlan &) = delete;
};
// ThreadPlanNull:
@@ -641,9 +651,10 @@ protected:
lldb::StateType GetPlanRunState() override;
- DISALLOW_COPY_AND_ASSIGN(ThreadPlanNull);
+ ThreadPlanNull(const ThreadPlanNull &) = delete;
+ const ThreadPlanNull &operator=(const ThreadPlanNull &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlan_h_
+#endif // LLDB_TARGET_THREADPLAN_H
diff --git a/lldb/include/lldb/Target/ThreadPlanBase.h b/lldb/include/lldb/Target/ThreadPlanBase.h
index bc92a06229a7..48058a9b40ab 100644
--- a/lldb/include/lldb/Target/ThreadPlanBase.h
+++ b/lldb/include/lldb/Target/ThreadPlanBase.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadPlanFundamental_h_
-#define liblldb_ThreadPlanFundamental_h_
+#ifndef LLDB_TARGET_THREADPLANBASE_H
+#define LLDB_TARGET_THREADPLANBASE_H
#include "lldb/Target/Process.h"
#include "lldb/Target/Thread.h"
@@ -47,9 +47,10 @@ private:
friend lldb::ThreadPlanSP
Thread::QueueFundamentalPlan(bool abort_other_plans);
- DISALLOW_COPY_AND_ASSIGN(ThreadPlanBase);
+ ThreadPlanBase(const ThreadPlanBase &) = delete;
+ const ThreadPlanBase &operator=(const ThreadPlanBase &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanFundamental_h_
+#endif // LLDB_TARGET_THREADPLANBASE_H
diff --git a/lldb/include/lldb/Target/ThreadPlanCallFunction.h b/lldb/include/lldb/Target/ThreadPlanCallFunction.h
index 685160a5678a..5b432e5e604a 100644
--- a/lldb/include/lldb/Target/ThreadPlanCallFunction.h
+++ b/lldb/include/lldb/Target/ThreadPlanCallFunction.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadPlanCallFunction_h_
-#define liblldb_ThreadPlanCallFunction_h_
+#ifndef LLDB_TARGET_THREADPLANCALLFUNCTION_H
+#define LLDB_TARGET_THREADPLANCALLFUNCTION_H
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
@@ -146,9 +146,11 @@ protected:
private:
CompilerType m_return_type;
- DISALLOW_COPY_AND_ASSIGN(ThreadPlanCallFunction);
+ ThreadPlanCallFunction(const ThreadPlanCallFunction &) = delete;
+ const ThreadPlanCallFunction &
+ operator=(const ThreadPlanCallFunction &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanCallFunction_h_
+#endif // LLDB_TARGET_THREADPLANCALLFUNCTION_H
diff --git a/lldb/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h b/lldb/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h
index c21e4d3cf3f7..af343d8a6635 100644
--- a/lldb/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h
+++ b/lldb/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadPlanCallFunctionUsingABI_h_
-#define liblldb_ThreadPlanCallFunctionUsingABI_h_
+#ifndef LLDB_TARGET_THREADPLANCALLFUNCTIONUSINGABI_H
+#define LLDB_TARGET_THREADPLANCALLFUNCTIONUSINGABI_H
#include "lldb/Target/ABI.h"
#include "lldb/Target/Thread.h"
@@ -44,9 +44,12 @@ protected:
private:
llvm::Type &m_return_type;
- DISALLOW_COPY_AND_ASSIGN(ThreadPlanCallFunctionUsingABI);
+ ThreadPlanCallFunctionUsingABI(const ThreadPlanCallFunctionUsingABI &) =
+ delete;
+ const ThreadPlanCallFunctionUsingABI &
+ operator=(const ThreadPlanCallFunctionUsingABI &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanCallFunctionUsingABI_h_
+#endif // LLDB_TARGET_THREADPLANCALLFUNCTIONUSINGABI_H
diff --git a/lldb/include/lldb/Target/ThreadPlanCallOnFunctionExit.h b/lldb/include/lldb/Target/ThreadPlanCallOnFunctionExit.h
index ad3ee6e0e8f9..1dd6a04408e5 100644
--- a/lldb/include/lldb/Target/ThreadPlanCallOnFunctionExit.h
+++ b/lldb/include/lldb/Target/ThreadPlanCallOnFunctionExit.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef ThreadPlanCallOnFunctionExit_h
-#define ThreadPlanCallOnFunctionExit_h
+#ifndef LLDB_TARGET_THREADPLANCALLONFUNCTIONEXIT_H
+#define LLDB_TARGET_THREADPLANCALLONFUNCTIONEXIT_H
#include "lldb/Target/ThreadPlan.h"
@@ -50,4 +50,4 @@ private:
};
}
-#endif /* ThreadPlanCallOnFunctionExit_h */
+#endif // LLDB_TARGET_THREADPLANCALLONFUNCTIONEXIT_H
diff --git a/lldb/include/lldb/Target/ThreadPlanCallUserExpression.h b/lldb/include/lldb/Target/ThreadPlanCallUserExpression.h
index 637215582410..adaea6c7056f 100644
--- a/lldb/include/lldb/Target/ThreadPlanCallUserExpression.h
+++ b/lldb/include/lldb/Target/ThreadPlanCallUserExpression.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadPlanCallUserExpression_h_
-#define liblldb_ThreadPlanCallUserExpression_h_
+#ifndef LLDB_TARGET_THREADPLANCALLUSEREXPRESSION_H
+#define LLDB_TARGET_THREADPLANCALLUSEREXPRESSION_H
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
@@ -56,9 +56,11 @@ private:
m_result_var_sp; // If we are left to manage the materialization,
// then stuff the result expression variable here.
- DISALLOW_COPY_AND_ASSIGN(ThreadPlanCallUserExpression);
+ ThreadPlanCallUserExpression(const ThreadPlanCallUserExpression &) = delete;
+ const ThreadPlanCallUserExpression &
+ operator=(const ThreadPlanCallUserExpression &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanCallUserExpression_h_
+#endif // LLDB_TARGET_THREADPLANCALLUSEREXPRESSION_H
diff --git a/lldb/include/lldb/Target/ThreadPlanPython.h b/lldb/include/lldb/Target/ThreadPlanPython.h
index 0ee559b12960..27bf3a560b1f 100644
--- a/lldb/include/lldb/Target/ThreadPlanPython.h
+++ b/lldb/include/lldb/Target/ThreadPlanPython.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadPlan_Python_h_
-#define liblldb_ThreadPlan_Python_h_
+#ifndef LLDB_TARGET_THREADPLANPYTHON_H
+#define LLDB_TARGET_THREADPLANPYTHON_H
#include <string>
@@ -55,6 +55,8 @@ protected:
bool DoPlanExplainsStop(Event *event_ptr) override;
lldb::StateType GetPlanRunState() override;
+
+ ScriptInterpreter *GetScriptInterpreter();
private:
std::string m_class_name;
@@ -66,9 +68,10 @@ private:
StructuredData::ObjectSP m_implementation_sp;
bool m_did_push;
- DISALLOW_COPY_AND_ASSIGN(ThreadPlanPython);
+ ThreadPlanPython(const ThreadPlanPython &) = delete;
+ const ThreadPlanPython &operator=(const ThreadPlanPython &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlan_Python_h_
+#endif // LLDB_TARGET_THREADPLANPYTHON_H
diff --git a/lldb/include/lldb/Target/ThreadPlanRunToAddress.h b/lldb/include/lldb/Target/ThreadPlanRunToAddress.h
index d82a9fad548a..10b8ec658cdd 100644
--- a/lldb/include/lldb/Target/ThreadPlanRunToAddress.h
+++ b/lldb/include/lldb/Target/ThreadPlanRunToAddress.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadPlanRunToAddress_h_
-#define liblldb_ThreadPlanRunToAddress_h_
+#ifndef LLDB_TARGET_THREADPLANRUNTOADDRESS_H
+#define LLDB_TARGET_THREADPLANRUNTOADDRESS_H
#include <vector>
@@ -59,9 +59,11 @@ 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);
+ ThreadPlanRunToAddress(const ThreadPlanRunToAddress &) = delete;
+ const ThreadPlanRunToAddress &
+ operator=(const ThreadPlanRunToAddress &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanRunToAddress_h_
+#endif // LLDB_TARGET_THREADPLANRUNTOADDRESS_H
diff --git a/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h b/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h
index dfcbbb355c54..54b30291c399 100644
--- a/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h
+++ b/lldb/include/lldb/Target/ThreadPlanShouldStopHere.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadPlanShouldStopHere_h_
-#define liblldb_ThreadPlanShouldStopHere_h_
+#ifndef LLDB_TARGET_THREADPLANSHOULDSTOPHERE_H
+#define LLDB_TARGET_THREADPLANSHOULDSTOPHERE_H
#include "lldb/Target/ThreadPlan.h"
@@ -130,9 +130,11 @@ protected:
lldb_private::Flags m_flags;
private:
- DISALLOW_COPY_AND_ASSIGN(ThreadPlanShouldStopHere);
+ ThreadPlanShouldStopHere(const ThreadPlanShouldStopHere &) = delete;
+ const ThreadPlanShouldStopHere &
+ operator=(const ThreadPlanShouldStopHere &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanShouldStopHere_h_
+#endif // LLDB_TARGET_THREADPLANSHOULDSTOPHERE_H
diff --git a/lldb/include/lldb/Target/ThreadPlanStack.h b/lldb/include/lldb/Target/ThreadPlanStack.h
new file mode 100644
index 000000000000..f1874136cad8
--- /dev/null
+++ b/lldb/include/lldb/Target/ThreadPlanStack.h
@@ -0,0 +1,173 @@
+//===-- ThreadPlanStack.h ---------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_TARGET_THREADPLANSTACK_H
+#define LLDB_TARGET_THREADPLANSTACK_H
+
+#include <mutex>
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
+#include "lldb/lldb-private-forward.h"
+#include "lldb/lldb-private.h"
+
+namespace lldb_private {
+
+// The ThreadPlans have a thread for use when they are asked all the ThreadPlan
+// state machine questions, but they should never cache any pointers from their
+// owning lldb_private::Thread. That's because we want to be able to detach
+// them from an owning thread, then reattach them by TID.
+// The ThreadPlanStack holds the ThreadPlans for a given TID. All its methods
+// are private, and it should only be accessed through the owning thread. When
+// it is detached from a thread, all you can do is reattach it or delete it.
+class ThreadPlanStack {
+ friend class lldb_private::Thread;
+
+public:
+ ThreadPlanStack(const Thread &thread, bool make_empty = false);
+ ~ThreadPlanStack() {}
+
+ enum StackKind { ePlans, eCompletedPlans, eDiscardedPlans };
+
+ using PlanStack = std::vector<lldb::ThreadPlanSP>;
+
+ void DumpThreadPlans(Stream &s, lldb::DescriptionLevel desc_level,
+ bool include_internal) const;
+
+ size_t CheckpointCompletedPlans();
+
+ void RestoreCompletedPlanCheckpoint(size_t checkpoint);
+
+ void DiscardCompletedPlanCheckpoint(size_t checkpoint);
+
+ void ThreadDestroyed(Thread *thread);
+
+ void EnableTracer(bool value, bool single_stepping);
+
+ void SetTracer(lldb::ThreadPlanTracerSP &tracer_sp);
+
+ void PushPlan(lldb::ThreadPlanSP new_plan_sp);
+
+ lldb::ThreadPlanSP PopPlan();
+
+ lldb::ThreadPlanSP DiscardPlan();
+
+ // 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.
+ void DiscardPlansUpToPlan(ThreadPlan *up_to_plan_ptr);
+
+ void DiscardAllPlans();
+
+ void DiscardConsultingMasterPlans();
+
+ lldb::ThreadPlanSP GetCurrentPlan() const;
+
+ lldb::ThreadPlanSP GetCompletedPlan(bool skip_private = true) const;
+
+ lldb::ThreadPlanSP GetPlanByIndex(uint32_t plan_idx,
+ bool skip_private = true) const;
+
+ lldb::ValueObjectSP GetReturnValueObject() const;
+
+ lldb::ExpressionVariableSP GetExpressionVariable() const;
+
+ bool AnyPlans() const;
+
+ bool AnyCompletedPlans() const;
+
+ bool AnyDiscardedPlans() const;
+
+ bool IsPlanDone(ThreadPlan *plan) const;
+
+ bool WasPlanDiscarded(ThreadPlan *plan) const;
+
+ ThreadPlan *GetPreviousPlan(ThreadPlan *current_plan) const;
+
+ ThreadPlan *GetInnermostExpression() const;
+
+ void WillResume();
+
+private:
+ const PlanStack &GetStackOfKind(ThreadPlanStack::StackKind kind) const;
+
+ void PrintOneStack(Stream &s, llvm::StringRef stack_name,
+ const PlanStack &stack, lldb::DescriptionLevel desc_level,
+ bool include_internal) const;
+
+ PlanStack m_plans; ///< The stack of plans this thread is executing.
+ PlanStack m_completed_plans; ///< Plans that have been completed by this
+ /// stop. They get deleted when the thread
+ /// resumes.
+ PlanStack m_discarded_plans; ///< Plans that have been discarded by this
+ /// stop. They get deleted when the thread
+ /// resumes.
+ size_t m_completed_plan_checkpoint = 0; // Monotonically increasing token for
+ // completed plan checkpoints.
+ std::unordered_map<size_t, PlanStack> m_completed_plan_store;
+};
+
+class ThreadPlanStackMap {
+public:
+ ThreadPlanStackMap(Process &process) : m_process(process) {}
+ ~ThreadPlanStackMap() {}
+
+ // Prune the map using the current_threads list.
+ void Update(ThreadList &current_threads, bool delete_missing,
+ bool check_for_new = true);
+
+ void AddThread(Thread &thread) {
+ lldb::tid_t tid = thread.GetID();
+ m_plans_list.emplace(tid, thread);
+ }
+
+ bool RemoveTID(lldb::tid_t tid) {
+ auto result = m_plans_list.find(tid);
+ if (result == m_plans_list.end())
+ return false;
+ result->second.ThreadDestroyed(nullptr);
+ m_plans_list.erase(result);
+ return true;
+ }
+
+ ThreadPlanStack *Find(lldb::tid_t tid) {
+ auto result = m_plans_list.find(tid);
+ if (result == m_plans_list.end())
+ return nullptr;
+ else
+ return &result->second;
+ }
+
+ void Clear() {
+ for (auto plan : m_plans_list)
+ plan.second.ThreadDestroyed(nullptr);
+ m_plans_list.clear();
+ }
+
+ // Implements Process::DumpThreadPlans
+ void DumpPlans(Stream &strm, lldb::DescriptionLevel desc_level, bool internal,
+ bool ignore_boring, bool skip_unreported);
+
+ // Implements Process::DumpThreadPlansForTID
+ bool DumpPlansForTID(Stream &strm, lldb::tid_t tid,
+ lldb::DescriptionLevel desc_level, bool internal,
+ bool ignore_boring, bool skip_unreported);
+
+ bool PrunePlansForTID(lldb::tid_t tid);
+
+private:
+ Process &m_process;
+ using PlansList = std::unordered_map<lldb::tid_t, ThreadPlanStack>;
+ PlansList m_plans_list;
+};
+
+} // namespace lldb_private
+
+#endif // LLDB_TARGET_THREADPLANSTACK_H
diff --git a/lldb/include/lldb/Target/ThreadPlanStepInRange.h b/lldb/include/lldb/Target/ThreadPlanStepInRange.h
index a120c98fb36e..59b5721998b5 100644
--- a/lldb/include/lldb/Target/ThreadPlanStepInRange.h
+++ b/lldb/include/lldb/Target/ThreadPlanStepInRange.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadPlanStepInRange_h_
-#define liblldb_ThreadPlanStepInRange_h_
+#ifndef LLDB_TARGET_THREADPLANSTEPINRANGE_H
+#define LLDB_TARGET_THREADPLANSTEPINRANGE_H
#include "lldb/Core/AddressRange.h"
#include "lldb/Target/StackID.h"
@@ -49,6 +49,12 @@ public:
bool IsVirtualStep() override;
+ // Plans that are implementing parts of a step in might need to follow the
+ // behavior of this plan w.r.t. StepThrough. They can get that from here.
+ static uint32_t GetDefaultFlagsValue() {
+ return s_default_flag_values;
+ }
+
protected:
static bool DefaultShouldStopHereCallback(ThreadPlan *current_plan,
Flags &flags,
@@ -99,9 +105,11 @@ 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);
+ ThreadPlanStepInRange(const ThreadPlanStepInRange &) = delete;
+ const ThreadPlanStepInRange &
+ operator=(const ThreadPlanStepInRange &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanStepInRange_h_
+#endif // LLDB_TARGET_THREADPLANSTEPINRANGE_H
diff --git a/lldb/include/lldb/Target/ThreadPlanStepInstruction.h b/lldb/include/lldb/Target/ThreadPlanStepInstruction.h
index 127de417f6eb..760bc4886faa 100644
--- a/lldb/include/lldb/Target/ThreadPlanStepInstruction.h
+++ b/lldb/include/lldb/Target/ThreadPlanStepInstruction.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadPlanStepInstruction_h_
-#define liblldb_ThreadPlanStepInstruction_h_
+#ifndef LLDB_TARGET_THREADPLANSTEPINSTRUCTION_H
+#define LLDB_TARGET_THREADPLANSTEPINSTRUCTION_H
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
@@ -49,9 +49,11 @@ private:
StackID m_stack_id;
StackID m_parent_frame_id;
- DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepInstruction);
+ ThreadPlanStepInstruction(const ThreadPlanStepInstruction &) = delete;
+ const ThreadPlanStepInstruction &
+ operator=(const ThreadPlanStepInstruction &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanStepInstruction_h_
+#endif // LLDB_TARGET_THREADPLANSTEPINSTRUCTION_H
diff --git a/lldb/include/lldb/Target/ThreadPlanStepOut.h b/lldb/include/lldb/Target/ThreadPlanStepOut.h
index 576b416c3f2c..5c39232fd2e8 100644
--- a/lldb/include/lldb/Target/ThreadPlanStepOut.h
+++ b/lldb/include/lldb/Target/ThreadPlanStepOut.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadPlanStepOut_h_
-#define liblldb_ThreadPlanStepOut_h_
+#ifndef LLDB_TARGET_THREADPLANSTEPOUT_H
+#define LLDB_TARGET_THREADPLANSTEPOUT_H
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
@@ -85,9 +85,10 @@ private:
void CalculateReturnValue();
- DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepOut);
+ ThreadPlanStepOut(const ThreadPlanStepOut &) = delete;
+ const ThreadPlanStepOut &operator=(const ThreadPlanStepOut &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanStepOut_h_
+#endif // LLDB_TARGET_THREADPLANSTEPOUT_H
diff --git a/lldb/include/lldb/Target/ThreadPlanStepOverBreakpoint.h b/lldb/include/lldb/Target/ThreadPlanStepOverBreakpoint.h
index 7df7049b568a..86f7798487c3 100644
--- a/lldb/include/lldb/Target/ThreadPlanStepOverBreakpoint.h
+++ b/lldb/include/lldb/Target/ThreadPlanStepOverBreakpoint.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadPlanStepOverBreakpoint_h_
-#define liblldb_ThreadPlanStepOverBreakpoint_h_
+#ifndef LLDB_TARGET_THREADPLANSTEPOVERBREAKPOINT_H
+#define LLDB_TARGET_THREADPLANSTEPOVERBREAKPOINT_H
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
@@ -47,9 +47,11 @@ private:
bool m_auto_continue;
bool m_reenabled_breakpoint_site;
- DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepOverBreakpoint);
+ ThreadPlanStepOverBreakpoint(const ThreadPlanStepOverBreakpoint &) = delete;
+ const ThreadPlanStepOverBreakpoint &
+ operator=(const ThreadPlanStepOverBreakpoint &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanStepOverBreakpoint_h_
+#endif // LLDB_TARGET_THREADPLANSTEPOVERBREAKPOINT_H
diff --git a/lldb/include/lldb/Target/ThreadPlanStepOverRange.h b/lldb/include/lldb/Target/ThreadPlanStepOverRange.h
index 30763e3861fa..8585ac62f09b 100644
--- a/lldb/include/lldb/Target/ThreadPlanStepOverRange.h
+++ b/lldb/include/lldb/Target/ThreadPlanStepOverRange.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadPlanStepOverRange_h_
-#define liblldb_ThreadPlanStepOverRange_h_
+#ifndef LLDB_TARGET_THREADPLANSTEPOVERRANGE_H
+#define LLDB_TARGET_THREADPLANSTEPOVERRANGE_H
#include "lldb/Core/AddressRange.h"
#include "lldb/Target/StackID.h"
@@ -45,9 +45,11 @@ private:
bool m_first_resume;
- DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepOverRange);
+ ThreadPlanStepOverRange(const ThreadPlanStepOverRange &) = delete;
+ const ThreadPlanStepOverRange &
+ operator=(const ThreadPlanStepOverRange &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanStepOverRange_h_
+#endif // LLDB_TARGET_THREADPLANSTEPOVERRANGE_H
diff --git a/lldb/include/lldb/Target/ThreadPlanStepRange.h b/lldb/include/lldb/Target/ThreadPlanStepRange.h
index 28209623a1e1..2fe885277100 100644
--- a/lldb/include/lldb/Target/ThreadPlanStepRange.h
+++ b/lldb/include/lldb/Target/ThreadPlanStepRange.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadPlanStepRange_h_
-#define liblldb_ThreadPlanStepRange_h_
+#ifndef LLDB_TARGET_THREADPLANSTEPRANGE_H
+#define LLDB_TARGET_THREADPLANSTEPRANGE_H
#include "lldb/Core/AddressRange.h"
#include "lldb/Target/StackID.h"
@@ -86,9 +86,10 @@ protected:
private:
std::vector<lldb::DisassemblerSP> m_instruction_ranges;
- DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepRange);
+ ThreadPlanStepRange(const ThreadPlanStepRange &) = delete;
+ const ThreadPlanStepRange &operator=(const ThreadPlanStepRange &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanStepRange_h_
+#endif // LLDB_TARGET_THREADPLANSTEPRANGE_H
diff --git a/lldb/include/lldb/Target/ThreadPlanStepThrough.h b/lldb/include/lldb/Target/ThreadPlanStepThrough.h
index 0d0621227b53..89262258e873 100644
--- a/lldb/include/lldb/Target/ThreadPlanStepThrough.h
+++ b/lldb/include/lldb/Target/ThreadPlanStepThrough.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadPlanStepThrough_h_
-#define liblldb_ThreadPlanStepThrough_h_
+#ifndef LLDB_TARGET_THREADPLANSTEPTHROUGH_H
+#define LLDB_TARGET_THREADPLANSTEPTHROUGH_H
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
@@ -53,9 +53,11 @@ private:
StackID m_return_stack_id;
bool m_stop_others;
- DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepThrough);
+ ThreadPlanStepThrough(const ThreadPlanStepThrough &) = delete;
+ const ThreadPlanStepThrough &
+ operator=(const ThreadPlanStepThrough &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanStepThrough_h_
+#endif // LLDB_TARGET_THREADPLANSTEPTHROUGH_H
diff --git a/lldb/include/lldb/Target/ThreadPlanStepUntil.h b/lldb/include/lldb/Target/ThreadPlanStepUntil.h
index 9a5934a36d7d..27e1f85e9cb9 100644
--- a/lldb/include/lldb/Target/ThreadPlanStepUntil.h
+++ b/lldb/include/lldb/Target/ThreadPlanStepUntil.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadPlanStepUntil_h_
-#define liblldb_ThreadPlanStepUntil_h_
+#ifndef LLDB_TARGET_THREADPLANSTEPUNTIL_H
+#define LLDB_TARGET_THREADPLANSTEPUNTIL_H
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
@@ -59,9 +59,10 @@ private:
// Need an appropriate marker for the current stack so we can tell step out
// from step in.
- DISALLOW_COPY_AND_ASSIGN(ThreadPlanStepUntil);
+ ThreadPlanStepUntil(const ThreadPlanStepUntil &) = delete;
+ const ThreadPlanStepUntil &operator=(const ThreadPlanStepUntil &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ThreadPlanStepUntil_h_
+#endif // LLDB_TARGET_THREADPLANSTEPUNTIL_H
diff --git a/lldb/include/lldb/Target/ThreadPlanTracer.h b/lldb/include/lldb/Target/ThreadPlanTracer.h
index 80b08078e975..677a2c0dd93c 100644
--- a/lldb/include/lldb/Target/ThreadPlanTracer.h
+++ b/lldb/include/lldb/Target/ThreadPlanTracer.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadPlanTracer_h_
-#define liblldb_ThreadPlanTracer_h_
+#ifndef LLDB_TARGET_THREADPLANTRACER_H
+#define LLDB_TARGET_THREADPLANTRACER_H
#include "lldb/Symbol/TaggedASTType.h"
#include "lldb/Target/Thread.h"
@@ -57,9 +57,12 @@ public:
}
bool SingleStepEnabled() { return m_single_step; }
+
+ Thread &GetThread();
protected:
- Thread &m_thread;
+ Process &m_process;
+ lldb::tid_t m_tid;
Stream *GetLogStream();
@@ -71,6 +74,7 @@ private:
bool m_single_step;
bool m_enabled;
lldb::StreamSP m_stream_sp;
+ Thread *m_thread;
};
class ThreadPlanAssemblyTracer : public ThreadPlanTracer {
@@ -96,4 +100,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ThreadPlanTracer_h_
+#endif // LLDB_TARGET_THREADPLANTRACER_H
diff --git a/lldb/include/lldb/Target/ThreadSpec.h b/lldb/include/lldb/Target/ThreadSpec.h
index 05e7dcdb38d3..8c22d53185ff 100644
--- a/lldb/include/lldb/Target/ThreadSpec.h
+++ b/lldb/include/lldb/Target/ThreadSpec.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadSpec_h_
-#define liblldb_ThreadSpec_h_
+#ifndef LLDB_TARGET_THREADSPEC_H
+#define LLDB_TARGET_THREADSPEC_H
#include "lldb/Utility/StructuredData.h"
#include "lldb/lldb-private.h"
@@ -46,9 +46,11 @@ public:
void SetTID(lldb::tid_t tid) { m_tid = tid; }
- void SetName(llvm::StringRef name) { m_name = name; }
+ void SetName(llvm::StringRef name) { m_name = std::string(name); }
- void SetQueueName(llvm::StringRef queue_name) { m_queue_name = queue_name; }
+ void SetQueueName(llvm::StringRef queue_name) {
+ m_queue_name = std::string(queue_name);
+ }
uint32_t GetIndex() const { return m_index; }
@@ -126,4 +128,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ThreadSpec_h_
+#endif // LLDB_TARGET_THREADSPEC_H
diff --git a/lldb/include/lldb/Target/UnixSignals.h b/lldb/include/lldb/Target/UnixSignals.h
index 120ffdd7ae25..cc24b76e4c3f 100644
--- a/lldb/include/lldb/Target/UnixSignals.h
+++ b/lldb/include/lldb/Target/UnixSignals.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_UnixSignals_h_
-#define lldb_UnixSignals_h_
+#ifndef LLDB_TARGET_UNIXSIGNALS_H
+#define LLDB_TARGET_UNIXSIGNALS_H
#include <map>
#include <string>
@@ -126,4 +126,4 @@ protected:
};
} // Namespace lldb
-#endif // lldb_UnixSignals_h_
+#endif // LLDB_TARGET_UNIXSIGNALS_H
diff --git a/lldb/include/lldb/Target/Unwind.h b/lldb/include/lldb/Target/Unwind.h
index 652918ddad43..783b7103e8fe 100644
--- a/lldb/include/lldb/Target/Unwind.h
+++ b/lldb/include/lldb/Target/Unwind.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Unwind_h_
-#define liblldb_Unwind_h_
+#ifndef LLDB_TARGET_UNWIND_H
+#define LLDB_TARGET_UNWIND_H
#include <mutex>
@@ -77,9 +77,10 @@ protected:
std::recursive_mutex m_unwind_mutex;
private:
- DISALLOW_COPY_AND_ASSIGN(Unwind);
+ Unwind(const Unwind &) = delete;
+ const Unwind &operator=(const Unwind &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Unwind_h_
+#endif // LLDB_TARGET_UNWIND_H
diff --git a/lldb/include/lldb/Target/UnwindAssembly.h b/lldb/include/lldb/Target/UnwindAssembly.h
index a70aef6e93c5..abfd38774399 100644
--- a/lldb/include/lldb/Target/UnwindAssembly.h
+++ b/lldb/include/lldb/Target/UnwindAssembly.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef utility_UnwindAssembly_h_
-#define utility_UnwindAssembly_h_
+#ifndef LLDB_TARGET_UNWINDASSEMBLY_H
+#define LLDB_TARGET_UNWINDASSEMBLY_H
#include "lldb/Core/PluginInterface.h"
#include "lldb/Utility/ArchSpec.h"
@@ -45,9 +45,10 @@ protected:
private:
UnwindAssembly() = delete;
- DISALLOW_COPY_AND_ASSIGN(UnwindAssembly);
+ UnwindAssembly(const UnwindAssembly &) = delete;
+ const UnwindAssembly &operator=(const UnwindAssembly &) = delete;
};
} // namespace lldb_private
-#endif // utility_UnwindAssembly_h_
+#endif // LLDB_TARGET_UNWINDASSEMBLY_H
diff --git a/lldb/source/Plugins/Process/Utility/UnwindLLDB.h b/lldb/include/lldb/Target/UnwindLLDB.h
index ff5db39730b5..c7c9cfbccbad 100644
--- a/lldb/source/Plugins/Process/Utility/UnwindLLDB.h
+++ b/lldb/include/lldb/Target/UnwindLLDB.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_UnwindLLDB_h_
-#define lldb_UnwindLLDB_h_
+#ifndef LLDB_TARGET_UNWINDLLDB_H
+#define LLDB_TARGET_UNWINDLLDB_H
#include <vector>
@@ -21,7 +21,7 @@
namespace lldb_private {
-class RegisterContextLLDB;
+class RegisterContextUnwind;
class UnwindLLDB : public lldb_private::Unwind {
public:
@@ -36,7 +36,7 @@ public:
};
protected:
- friend class lldb_private::RegisterContextLLDB;
+ friend class lldb_private::RegisterContextUnwind;
struct RegisterLocation {
enum RegisterLocationTypes {
@@ -79,17 +79,16 @@ protected:
lldb::RegisterContextSP
DoCreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
- typedef std::shared_ptr<RegisterContextLLDB> RegisterContextLLDBSP;
+ typedef std::shared_ptr<RegisterContextUnwind> RegisterContextLLDBSP;
// Needed to retrieve the "next" frame (e.g. frame 2 needs to retrieve frame
- // 1's RegisterContextLLDB)
+ // 1's RegisterContextUnwind)
// The RegisterContext for frame_num must already exist or this returns an
// empty shared pointer.
RegisterContextLLDBSP GetRegisterContextForFrameNum(uint32_t frame_num);
- // Iterate over the RegisterContextLLDB's in our m_frames vector, look for the
- // first one that
- // has a saved location for this reg.
+ // Iterate over the RegisterContextUnwind's in our m_frames vector, look for
+ // the first one that has a saved location for this reg.
bool SearchForSavedLocationForRegister(
uint32_t lldb_regnum, lldb_private::UnwindLLDB::RegisterLocation &regloc,
uint32_t starting_frame_num, bool pc_register);
@@ -116,14 +115,15 @@ private:
lldb_private::SymbolContext sctx; // A symbol context we'll contribute to &
// provide to the StackFrame creation
RegisterContextLLDBSP
- reg_ctx_lldb_sp; // These are all RegisterContextLLDB's
+ reg_ctx_lldb_sp; // These are all RegisterContextUnwind's
Cursor()
: start_pc(LLDB_INVALID_ADDRESS), cfa(LLDB_INVALID_ADDRESS), sctx(),
reg_ctx_lldb_sp() {}
private:
- DISALLOW_COPY_AND_ASSIGN(Cursor);
+ Cursor(const Cursor &) = delete;
+ const Cursor &operator=(const Cursor &) = delete;
};
typedef std::shared_ptr<Cursor> CursorSP;
@@ -150,9 +150,10 @@ private:
bool AddFirstFrame();
// For UnwindLLDB only
- DISALLOW_COPY_AND_ASSIGN(UnwindLLDB);
+ UnwindLLDB(const UnwindLLDB &) = delete;
+ const UnwindLLDB &operator=(const UnwindLLDB &) = delete;
};
} // namespace lldb_private
-#endif // lldb_UnwindLLDB_h_
+#endif // LLDB_TARGET_UNWINDLLDB_H
diff --git a/lldb/include/lldb/Utility/AnsiTerminal.h b/lldb/include/lldb/Utility/AnsiTerminal.h
index 21375e3821ca..c391adb2cf89 100644
--- a/lldb/include/lldb/Utility/AnsiTerminal.h
+++ b/lldb/include/lldb/Utility/AnsiTerminal.h
@@ -1,3 +1,7 @@
+#ifndef LLDB_UTILITY_ANSITERMINAL_H
+
+#define LLDB_UTILITY_ANSITERMINAL_H
+
//===---------------------AnsiTerminal.h ------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
@@ -111,7 +115,7 @@ inline std::string FormatAnsiTerminalCodes(llvm::StringRef format,
llvm::StringRef left, right;
std::tie(left, right) = format.split(tok_hdr);
- fmt.append(left);
+ fmt += left;
if (left == format && right.empty()) {
// The header was not found. Just exit.
@@ -138,3 +142,5 @@ inline std::string FormatAnsiTerminalCodes(llvm::StringRef format,
}
}
} // namespace lldb_private
+
+#endif
diff --git a/lldb/include/lldb/Utility/ArchSpec.h b/lldb/include/lldb/Utility/ArchSpec.h
index 15e2fdb10c32..5466e573c1a5 100644
--- a/lldb/include/lldb/Utility/ArchSpec.h
+++ b/lldb/include/lldb/Utility/ArchSpec.h
@@ -16,6 +16,7 @@
#include "lldb/lldb-private-enumerations.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
+#include "llvm/Support/YAMLTraits.h"
#include <cstddef>
#include <cstdint>
#include <string>
@@ -188,6 +189,10 @@ public:
eCore_arc, // little endian ARC
+ eCore_avr,
+
+ eCore_wasm32,
+
kNumCores,
kCore_invalid,
@@ -537,4 +542,16 @@ bool ParseMachCPUDashSubtypeTriple(llvm::StringRef triple_str, ArchSpec &arch);
} // namespace lldb_private
-#endif // #ifndef LLDB_UTILITY_ARCHSPEC_H
+namespace llvm {
+namespace yaml {
+template <> struct ScalarTraits<lldb_private::ArchSpec> {
+ static void output(const lldb_private::ArchSpec &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, lldb_private::ArchSpec &);
+ static QuotingType mustQuote(StringRef S) { return QuotingType::Double; }
+};
+} // namespace yaml
+} // namespace llvm
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(lldb_private::ArchSpec)
+
+#endif // LLDB_UTILITY_ARCHSPEC_H
diff --git a/lldb/include/lldb/Utility/Args.h b/lldb/include/lldb/Utility/Args.h
index 1308f4038dbd..2cce7d0c697c 100644
--- a/lldb/include/lldb/Utility/Args.h
+++ b/lldb/include/lldb/Utility/Args.h
@@ -14,6 +14,7 @@
#include "lldb/lldb-types.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/YAMLTraits.h"
#include <string>
#include <utility>
#include <vector>
@@ -34,6 +35,9 @@ public:
struct ArgEntry {
private:
friend class Args;
+ friend struct llvm::yaml::MappingTraits<Args>;
+ friend struct llvm::yaml::MappingTraits<Args::ArgEntry>;
+
std::unique_ptr<char[]> ptr;
char quote;
@@ -283,6 +287,8 @@ public:
char quote_char);
private:
+ friend struct llvm::yaml::MappingTraits<Args>;
+
std::vector<ArgEntry> m_entries;
std::vector<char *> m_argv;
};
@@ -373,4 +379,28 @@ private:
} // namespace lldb_private
+namespace llvm {
+namespace yaml {
+template <> struct MappingTraits<lldb_private::Args::ArgEntry> {
+ class NormalizedArgEntry {
+ public:
+ NormalizedArgEntry(IO &) {}
+ NormalizedArgEntry(IO &, lldb_private::Args::ArgEntry &entry)
+ : value(entry.ref()), quote(entry.quote) {}
+ lldb_private::Args::ArgEntry denormalize(IO &) {
+ return lldb_private::Args::ArgEntry(value, quote);
+ }
+ StringRef value;
+ uint8_t quote;
+ };
+ static void mapping(IO &io, lldb_private::Args::ArgEntry &v);
+};
+template <> struct MappingTraits<lldb_private::Args> {
+ static void mapping(IO &io, lldb_private::Args &v);
+};
+} // namespace yaml
+} // namespace llvm
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(lldb_private::Args::ArgEntry)
+
#endif // LLDB_UTILITY_ARGS_H
diff --git a/lldb/include/lldb/Utility/Baton.h b/lldb/include/lldb/Utility/Baton.h
index c42867489c65..010f8da43868 100644
--- a/lldb/include/lldb/Utility/Baton.h
+++ b/lldb/include/lldb/Utility/Baton.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Baton_h_
-#define lldb_Baton_h_
+#ifndef LLDB_UTILITY_BATON_H
+#define LLDB_UTILITY_BATON_H
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-public.h"
@@ -76,4 +76,4 @@ protected:
} // namespace lldb_private
-#endif // lldb_Baton_h_
+#endif // LLDB_UTILITY_BATON_H
diff --git a/lldb/include/lldb/Utility/Broadcaster.h b/lldb/include/lldb/Utility/Broadcaster.h
index ead597d626d7..03995454ecb0 100644
--- a/lldb/include/lldb/Utility/Broadcaster.h
+++ b/lldb/include/lldb/Utility/Broadcaster.h
@@ -259,19 +259,6 @@ public:
void CheckInWithManager();
/// Broadcast an event which has no associated data.
- ///
- /// \param[in] event_type
- /// The element from the enum defining this broadcaster's events
- /// that is being broadcast.
- ///
- /// \param[in] event_data
- /// User event data that will be owned by the lldb::Event that
- /// is created internally.
- ///
- /// \param[in] unique
- /// If true, then only add an event of this type if there isn't
- /// one already in the queue.
- ///
void BroadcastEvent(lldb::EventSP &event_sp) {
m_broadcaster_sp->BroadcastEvent(event_sp);
}
@@ -308,7 +295,7 @@ public:
/// different from what is requested in \a event_mask, and to track this the
/// actual event bits that are acquired get returned.
///
- /// \param[in] listener
+ /// \param[in] listener_sp
/// The Listener object that wants to monitor the events that
/// get broadcast by this object.
///
@@ -347,9 +334,6 @@ public:
/// \param[in] event_mask
/// A bit mask that indicates which events the listener is
/// asking to monitor.
- ///
- /// \return
- /// The NULL terminated C string name of this Broadcaster.
void SetEventName(uint32_t event_mask, const char *name) {
m_broadcaster_sp->SetEventName(event_mask, name);
}
@@ -367,7 +351,7 @@ public:
/// (assuming \a listener was listening to this object) for other listener
/// objects to use.
///
- /// \param[in] listener
+ /// \param[in] listener_sp
/// A Listener object that previously called AddListener.
///
/// \param[in] event_mask
@@ -389,7 +373,7 @@ public:
/// now go to the hijacking listener. Only one hijack can occur at a time.
/// If we need more than this we will have to implement a Listener stack.
///
- /// \param[in] listener
+ /// \param[in] listener_sp
/// A Listener object. You do not need to call StartListeningForEvents
/// for this broadcaster (that would fail anyway since the event bits
/// would most likely be taken by the listener(s) you are usurping.
@@ -530,7 +514,8 @@ protected:
std::vector<uint32_t> m_hijacking_masks;
private:
- DISALLOW_COPY_AND_ASSIGN(BroadcasterImpl);
+ BroadcasterImpl(const BroadcasterImpl &) = delete;
+ const BroadcasterImpl &operator=(const BroadcasterImpl &) = delete;
};
typedef std::shared_ptr<BroadcasterImpl> BroadcasterImplSP;
@@ -549,7 +534,8 @@ private:
/// The name of this broadcaster object.
const ConstString m_broadcaster_name;
- DISALLOW_COPY_AND_ASSIGN(Broadcaster);
+ Broadcaster(const Broadcaster &) = delete;
+ const Broadcaster &operator=(const Broadcaster &) = delete;
};
} // namespace lldb_private
diff --git a/lldb/include/lldb/Utility/CompletionRequest.h b/lldb/include/lldb/Utility/CompletionRequest.h
index 570f626ac54e..1fbc96944e82 100644
--- a/lldb/include/lldb/Utility/CompletionRequest.h
+++ b/lldb/include/lldb/Utility/CompletionRequest.h
@@ -17,16 +17,21 @@
namespace lldb_private {
enum class CompletionMode {
- // The current token has been completed.
+ /// The current token has been completed. The client should indicate this
+ /// to the user (usually this is done by adding a trailing space behind the
+ /// token).
+ /// Example: "command sub" -> "command subcommand " (note the trailing space).
Normal,
- // The current token has been partially completed. This means that we found
- // a completion, but that the completed token is still incomplete. Examples
- // for this are file paths, where we want to complete "/bi" to "/bin/", but
- // the file path token is still incomplete after the completion. Clients
- // should not indicate to the user that this is a full completion (e.g. by
- // not inserting the usual trailing space after a successful completion).
+ /// The current token has been partially completed. This means that we found
+ /// a completion, but that the token is still incomplete. Examples
+ /// for this are file paths, where we want to complete "/bi" to "/bin/", but
+ /// the file path token is still incomplete after the completion. Clients
+ /// should not indicate to the user that this is a full completion (e.g. by
+ /// not inserting the usual trailing space after a successful completion).
+ /// Example: "file /us" -> "file /usr/" (note the missing trailing space).
Partial,
- // The full line has been rewritten by the completion.
+ /// The full line has been rewritten by the completion.
+ /// Example: "alias name" -> "other_command full_name".
RewriteLine,
};
@@ -35,7 +40,12 @@ public:
/// A single completion and all associated data.
class Completion {
+ /// The actual text that should be completed. The meaning of this text
+ /// is defined by the CompletionMode.
+ /// \see m_mode
std::string m_completion;
+ /// The description that should be displayed to the user alongside the
+ /// completion text.
std::string m_descripton;
CompletionMode m_mode;
@@ -53,9 +63,12 @@ public:
};
private:
+ /// List of found completions.
std::vector<Completion> m_results;
- /// List of added completions so far. Used to filter out duplicates.
+ /// A set of the unique keys of all found completions so far. Used to filter
+ /// out duplicates.
+ /// \see CompletionResult::Completion::GetUniqueKey
llvm::StringSet<> m_added_values;
public:
@@ -102,7 +115,19 @@ public:
CompletionRequest(llvm::StringRef command_line, unsigned raw_cursor_pos,
CompletionResult &result);
- llvm::StringRef GetRawLine() const { return m_command; }
+ /// Returns the raw user input used to create this CompletionRequest cut off
+ /// at the cursor position. The cursor will be at the end of the raw line.
+ llvm::StringRef GetRawLine() const {
+ return m_command.substr(0, GetRawCursorPos());
+ }
+
+ /// Returns the full raw user input used to create this CompletionRequest.
+ /// This string is not cut off at the cursor position and will include
+ /// characters behind the cursor position.
+ ///
+ /// You should most likely *not* use this function unless the characters
+ /// behind the cursor position influence the completion.
+ llvm::StringRef GetRawLineWithUnusedSuffix() const { return m_command; }
unsigned GetRawCursorPos() const { return m_raw_cursor_pos; }
@@ -135,8 +160,8 @@ public:
/// the suggested completion is stored, so the given string can be free'd
/// afterwards.
///
- /// \param match The suggested completion.
- /// \param completion An optional description of the completion string. The
+ /// \param completion The suggested completion.
+ /// \param description An optional description of the completion string. The
/// description will be displayed to the user alongside the completion.
/// \param mode The CompletionMode for this completion.
void AddCompletion(llvm::StringRef completion,
@@ -148,7 +173,7 @@ public:
/// Adds a possible completion string if the completion would complete the
/// current argument.
///
- /// \param match The suggested completion.
+ /// \param completion The suggested completion.
/// \param description An optional description of the completion string. The
/// description will be displayed to the user alongside the completion.
template <CompletionMode M = CompletionMode::Normal>
@@ -178,7 +203,7 @@ public:
/// The number of completions and descriptions must be identical.
///
/// \param completions The list of completions.
- /// \param completions The list of descriptions.
+ /// \param descriptions The list of descriptions.
///
/// \see AddCompletion
void AddCompletions(const StringList &completions,
diff --git a/lldb/include/lldb/Utility/Connection.h b/lldb/include/lldb/Utility/Connection.h
index 9e66dee1363b..39e6e40191b0 100644
--- a/lldb/include/lldb/Utility/Connection.h
+++ b/lldb/include/lldb/Utility/Connection.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Connection_h_
-#define liblldb_Connection_h_
+#ifndef LLDB_UTILITY_CONNECTION_H
+#define LLDB_UTILITY_CONNECTION_H
#include "lldb/lldb-defines.h"
#include "lldb/lldb-enumerations.h"
@@ -125,7 +125,7 @@ public:
/// Subclasses must override this function.
///
/// \param[in] dst
- /// A desination buffer that must be at least \a dst_len bytes
+ /// A destination buffer that must be at least \a dst_len bytes
/// long.
///
/// \param[in] dst_len
@@ -175,9 +175,10 @@ public:
private:
// For Connection only
- DISALLOW_COPY_AND_ASSIGN(Connection);
+ Connection(const Connection &) = delete;
+ const Connection &operator=(const Connection &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Connection_h_
+#endif // LLDB_UTILITY_CONNECTION_H
diff --git a/lldb/include/lldb/Utility/ConstString.h b/lldb/include/lldb/Utility/ConstString.h
index 74750459d16f..1e55b2ebb957 100644
--- a/lldb/include/lldb/Utility/ConstString.h
+++ b/lldb/include/lldb/Utility/ConstString.h
@@ -6,12 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ConstString_h_
-#define liblldb_ConstString_h_
+#ifndef LLDB_UTILITY_CONSTSTRING_H
+#define LLDB_UTILITY_CONSTSTRING_H
-#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/DenseMapInfo.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/YAMLTraits.h"
#include <stddef.h>
@@ -481,6 +482,21 @@ template <> struct DenseMapInfo<lldb_private::ConstString> {
}
};
/// \}
+
+namespace yaml {
+template <> struct ScalarTraits<lldb_private::ConstString> {
+ static void output(const lldb_private::ConstString &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, lldb_private::ConstString &);
+ static QuotingType mustQuote(StringRef S) { return QuotingType::Double; }
+};
+} // namespace yaml
+
+inline raw_ostream &operator<<(raw_ostream &os, lldb_private::ConstString s) {
+ os << s.GetStringRef();
+ return os;
}
+} // namespace llvm
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(lldb_private::ConstString)
-#endif // liblldb_ConstString_h_
+#endif // LLDB_UTILITY_CONSTSTRING_H
diff --git a/lldb/include/lldb/Utility/DataBuffer.h b/lldb/include/lldb/Utility/DataBuffer.h
index 523569301e84..302b13307958 100644
--- a/lldb/include/lldb/Utility/DataBuffer.h
+++ b/lldb/include/lldb/Utility/DataBuffer.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DataBuffer_h_
-#define liblldb_DataBuffer_h_
+#ifndef LLDB_UTILITY_DATABUFFER_H
+#define LLDB_UTILITY_DATABUFFER_H
#if defined(__cplusplus)
#include <stdint.h>
@@ -79,7 +79,21 @@ public:
}
};
+class DataBufferUnowned : public DataBuffer {
+public:
+ DataBufferUnowned(uint8_t *bytes, lldb::offset_t size)
+ : m_bytes(bytes), m_size(size) {}
+
+ uint8_t *GetBytes() override { return m_bytes; }
+ const uint8_t *GetBytes() const override { return m_bytes; }
+ lldb::offset_t GetByteSize() const override { return m_size; }
+
+private:
+ uint8_t *m_bytes;
+ lldb::offset_t m_size;
+};
+
} // namespace lldb_private
#endif /// #if defined(__cplusplus)
-#endif /// lldb_DataBuffer_h_
+#endif // LLDB_UTILITY_DATABUFFER_H
diff --git a/lldb/include/lldb/Utility/DataBufferHeap.h b/lldb/include/lldb/Utility/DataBufferHeap.h
index 2a64694d7f29..ace526bf0a47 100644
--- a/lldb/include/lldb/Utility/DataBufferHeap.h
+++ b/lldb/include/lldb/Utility/DataBufferHeap.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DataBufferHeap_h_
-#define liblldb_DataBufferHeap_h_
+#ifndef LLDB_UTILITY_DATABUFFERHEAP_H
+#define LLDB_UTILITY_DATABUFFERHEAP_H
#include "lldb/Utility/DataBuffer.h"
#include "lldb/lldb-types.h"
@@ -109,4 +109,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_DataBufferHeap_h_
+#endif // LLDB_UTILITY_DATABUFFERHEAP_H
diff --git a/lldb/include/lldb/Utility/DataBufferLLVM.h b/lldb/include/lldb/Utility/DataBufferLLVM.h
index d4c110743068..4dc800c348c5 100644
--- a/lldb/include/lldb/Utility/DataBufferLLVM.h
+++ b/lldb/include/lldb/Utility/DataBufferLLVM.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_CORE_DATABUFFERLLVM_H
-#define LLDB_CORE_DATABUFFERLLVM_H
+#ifndef LLDB_UTILITY_DATABUFFERLLVM_H
+#define LLDB_UTILITY_DATABUFFERLLVM_H
#include "lldb/Utility/DataBuffer.h"
#include "lldb/lldb-types.h"
diff --git a/lldb/include/lldb/Utility/DataEncoder.h b/lldb/include/lldb/Utility/DataEncoder.h
index f4964b250b9d..8edec54c36f5 100644
--- a/lldb/include/lldb/Utility/DataEncoder.h
+++ b/lldb/include/lldb/Utility/DataEncoder.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DataEncoder_h_
-#define liblldb_DataEncoder_h_
+#ifndef LLDB_UTILITY_DATAENCODER_H
+#define LLDB_UTILITY_DATAENCODER_H
#if defined(__cplusplus)
@@ -225,7 +225,6 @@ private:
/// The total number of bytes of data this object refers to.
size_t GetByteSize() const { return m_end - m_start; }
-private:
/// A pointer to the first byte of data.
uint8_t *m_start;
@@ -243,10 +242,11 @@ private:
/// be shared among multiple instances
mutable lldb::DataBufferSP m_data_sp;
- DISALLOW_COPY_AND_ASSIGN(DataEncoder);
+ DataEncoder(const DataEncoder &) = delete;
+ const DataEncoder &operator=(const DataEncoder &) = delete;
};
} // namespace lldb_private
#endif // #if defined (__cplusplus)
-#endif // #ifndef liblldb_DataEncoder_h_
+#endif // LLDB_UTILITY_DATAENCODER_H
diff --git a/lldb/include/lldb/Utility/DataExtractor.h b/lldb/include/lldb/Utility/DataExtractor.h
index bf0d1055cf43..0210af5cf6d1 100644
--- a/lldb/include/lldb/Utility/DataExtractor.h
+++ b/lldb/include/lldb/Utility/DataExtractor.h
@@ -9,12 +9,14 @@
#ifndef LLDB_UTILITY_DATAEXTRACTOR_H
#define LLDB_UTILITY_DATAEXTRACTOR_H
+#include "lldb/Utility/Endian.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
#include "lldb/lldb-types.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Support/DataExtractor.h"
+#include "llvm/Support/SwapByteOrder.h"
#include <cassert>
#include <stdint.h>
@@ -535,13 +537,13 @@ public:
uint32_t bitfield_bit_size,
uint32_t bitfield_bit_offset) const;
- /// Extract an signed integer of size \a byte_size from \a *offset_ptr, then
- /// extract and signe extend the bitfield from this value if \a
+ /// Extract an signed integer of size \a size from \a *offset_ptr, then
+ /// extract and sign-extend the bitfield from this value if \a
/// bitfield_bit_size is non-zero.
///
- /// Extract a single signed integer value (sign extending if required) and
+ /// Extract a single signed integer value (sign-extending if required) and
/// update the offset pointed to by \a offset_ptr. The size of the extracted
- /// integer is specified by the \a byte_size argument. \a byte_size must
+ /// integer is specified by the \a size argument. \a size must
/// have a value greater than or equal to one and less than or equal to
/// eight since the return value is 64 bits wide.
///
@@ -573,24 +575,6 @@ public:
uint32_t bitfield_bit_size,
uint32_t bitfield_bit_offset) const;
- /// Extract an pointer from \a *offset_ptr.
- ///
- /// Extract a single pointer from the data and update the offset pointed to
- /// by \a offset_ptr. The size of the extracted pointer comes from the \a
- /// m_addr_size member variable and should be set correctly prior to
- /// extracting any pointer values.
- ///
- /// \param[in,out] offset_ptr
- /// A pointer to an offset within the data that will be advanced
- /// by the appropriate number of bytes if the value is extracted
- /// correctly. If the offset is out of bounds or there are not
- /// enough bytes to extract this value, the offset will be left
- /// unmodified.
- ///
- /// \return
- /// The extracted pointer value as a 64 integer.
- uint64_t GetPointer(lldb::offset_t *offset_ptr) const;
-
/// Get the current byte order value.
///
/// \return
@@ -997,19 +981,33 @@ public:
}
protected:
+ template <typename T> T Get(lldb::offset_t *offset_ptr, T fail_value) const {
+ constexpr size_t src_size = sizeof(T);
+ T val = fail_value;
+
+ const T *src = static_cast<const T *>(GetData(offset_ptr, src_size));
+ if (!src)
+ return val;
+
+ memcpy(&val, src, src_size);
+ if (m_byte_order != endian::InlHostByteOrder())
+ llvm::sys::swapByteOrder(val);
+
+ return val;
+ }
+
// Member variables
const uint8_t *m_start; ///< A pointer to the first byte of data.
const uint8_t
*m_end; ///< A pointer to the byte that is past the end of the data.
lldb::ByteOrder
m_byte_order; ///< The byte order of the data we are extracting from.
- uint32_t m_addr_size; ///< The address size to use when extracting pointers or
- /// addresses
- mutable lldb::DataBufferSP m_data_sp; ///< The shared pointer to data that can
- /// be shared among multiple instances
+ uint32_t m_addr_size; ///< The address size to use when extracting addresses.
+ /// The shared pointer to data that can be shared among multiple instances
+ lldb::DataBufferSP m_data_sp;
const uint32_t m_target_byte_size;
};
} // namespace lldb_private
-#endif // liblldb_DataExtractor_h_
+#endif // LLDB_UTILITY_DATAEXTRACTOR_H
diff --git a/lldb/include/lldb/Utility/Endian.h b/lldb/include/lldb/Utility/Endian.h
index cead5f8603d2..1d1f8fa333b8 100644
--- a/lldb/include/lldb/Utility/Endian.h
+++ b/lldb/include/lldb/Utility/Endian.h
@@ -30,4 +30,4 @@ inline lldb::ByteOrder InlHostByteOrder() {
}
}
-#endif // liblldb_host_endian_h_
+#endif // LLDB_UTILITY_ENDIAN_H
diff --git a/lldb/include/lldb/Utility/Environment.h b/lldb/include/lldb/Utility/Environment.h
index 398b3bae3106..e2af2eb2463d 100644
--- a/lldb/include/lldb/Utility/Environment.h
+++ b/lldb/include/lldb/Utility/Environment.h
@@ -50,6 +50,7 @@ public:
using Base::erase;
using Base::find;
using Base::insert;
+ using Base::insert_or_assign;
using Base::lookup;
using Base::size;
using Base::try_emplace;
@@ -68,7 +69,8 @@ public:
}
std::pair<iterator, bool> insert(llvm::StringRef KeyEqValue) {
- return insert(KeyEqValue.split('='));
+ auto Split = KeyEqValue.split('=');
+ return insert(std::make_pair(Split.first, std::string(Split.second)));
}
void insert(const_iterator first, const_iterator last);
@@ -92,4 +94,4 @@ template <> struct format_provider<lldb_private::Environment> {
};
} // namespace llvm
-#endif // #ifndef LLDB_UTILITY_ENVIRONMENT_H
+#endif // LLDB_UTILITY_ENVIRONMENT_H
diff --git a/lldb/include/lldb/Utility/Event.h b/lldb/include/lldb/Utility/Event.h
index dd5d08024cef..06c02629d448 100644
--- a/lldb/include/lldb/Utility/Event.h
+++ b/lldb/include/lldb/Utility/Event.h
@@ -48,7 +48,8 @@ public:
private:
virtual void DoOnRemoval(Event *event_ptr) {}
- DISALLOW_COPY_AND_ASSIGN(EventData);
+ EventData(const EventData &) = delete;
+ const EventData &operator=(const EventData &) = delete;
};
// lldb::EventDataBytes
@@ -92,7 +93,8 @@ public:
private:
std::string m_bytes;
- DISALLOW_COPY_AND_ASSIGN(EventDataBytes);
+ EventDataBytes(const EventDataBytes &) = delete;
+ const EventDataBytes &operator=(const EventDataBytes &) = delete;
};
class EventDataReceipt : public EventData {
@@ -169,7 +171,9 @@ private:
StructuredData::ObjectSP m_object_sp;
lldb::StructuredDataPluginSP m_plugin_sp;
- DISALLOW_COPY_AND_ASSIGN(EventDataStructuredData);
+ EventDataStructuredData(const EventDataStructuredData &) = delete;
+ const EventDataStructuredData &
+ operator=(const EventDataStructuredData &) = delete;
};
// lldb::Event
@@ -242,7 +246,8 @@ private:
uint32_t m_type; // The bit describing this event
lldb::EventDataSP m_data_sp; // User specific data for this event
- DISALLOW_COPY_AND_ASSIGN(Event);
+ Event(const Event &) = delete;
+ const Event &operator=(const Event &) = delete;
Event() = delete;
};
diff --git a/lldb/include/lldb/Utility/FileSpec.h b/lldb/include/lldb/Utility/FileSpec.h
index 533426671cc6..f7cbeb247100 100644
--- a/lldb/include/lldb/Utility/FileSpec.h
+++ b/lldb/include/lldb/Utility/FileSpec.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_FileSpec_h_
-#define liblldb_FileSpec_h_
+#ifndef LLDB_UTILITY_FILESPEC_H
+#define LLDB_UTILITY_FILESPEC_H
#include <functional>
#include <string>
@@ -18,6 +18,7 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/Path.h"
+#include "llvm/Support/YAMLTraits.h"
#include <stddef.h>
#include <stdint.h>
@@ -397,6 +398,8 @@ public:
ConstString GetLastPathComponent() const;
protected:
+ friend struct llvm::yaml::MappingTraits<FileSpec>;
+
// Convenience method for setting the file without changing the style.
void SetFile(llvm::StringRef path);
@@ -410,6 +413,8 @@ protected:
/// Dump a FileSpec object to a stream
Stream &operator<<(Stream &s, const FileSpec &f);
+/// Prevent ODR violations with traits for llvm::sys::path::Style.
+LLVM_YAML_STRONG_TYPEDEF(FileSpec::Style, FileSpecStyle)
} // namespace lldb_private
namespace llvm {
@@ -436,6 +441,16 @@ template <> struct format_provider<lldb_private::FileSpec> {
static void format(const lldb_private::FileSpec &F, llvm::raw_ostream &Stream,
StringRef Style);
};
+
+namespace yaml {
+template <> struct ScalarEnumerationTraits<lldb_private::FileSpecStyle> {
+ static void enumeration(IO &io, lldb_private::FileSpecStyle &style);
+};
+
+template <> struct MappingTraits<lldb_private::FileSpec> {
+ static void mapping(IO &io, lldb_private::FileSpec &f);
+};
+} // namespace yaml
} // namespace llvm
-#endif // liblldb_FileSpec_h_
+#endif // LLDB_UTILITY_FILESPEC_H
diff --git a/lldb/include/lldb/Utility/Flags.h b/lldb/include/lldb/Utility/Flags.h
index 254a5ec443c3..19f750639e94 100644
--- a/lldb/include/lldb/Utility/Flags.h
+++ b/lldb/include/lldb/Utility/Flags.h
@@ -29,7 +29,7 @@ public:
/// Constructs this object with \a mask as the initial value for all of the
/// flags.
///
- /// \param[in] mask
+ /// \param[in] flags
/// The initial value for all flags.
Flags(ValueType flags = 0) : m_flags(flags) {}
@@ -116,4 +116,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_Flags_h_
+#endif // LLDB_UTILITY_FLAGS_H
diff --git a/lldb/include/lldb/Utility/GDBRemote.h b/lldb/include/lldb/Utility/GDBRemote.h
index 21b2c8cd73cd..f5749b7e6eaf 100644
--- a/lldb/include/lldb/Utility/GDBRemote.h
+++ b/lldb/include/lldb/Utility/GDBRemote.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_GDBRemote_h_
-#define liblldb_GDBRemote_h_
+#ifndef LLDB_UTILITY_GDBREMOTE_H
+#define LLDB_UTILITY_GDBREMOTE_H
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Reproducer.h"
@@ -155,4 +155,4 @@ template <> struct MappingTraits<lldb_private::GDBRemotePacket> {
} // namespace yaml
} // namespace llvm
-#endif // liblldb_GDBRemote_h_
+#endif // LLDB_UTILITY_GDBREMOTE_H
diff --git a/lldb/include/lldb/Utility/IOObject.h b/lldb/include/lldb/Utility/IOObject.h
index 16ed580abf71..9b2b9cfcfec0 100644
--- a/lldb/include/lldb/Utility/IOObject.h
+++ b/lldb/include/lldb/Utility/IOObject.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Host_Common_IOObject_h_
-#define liblldb_Host_Common_IOObject_h_
+#ifndef LLDB_UTILITY_IOOBJECT_H
+#define LLDB_UTILITY_IOOBJECT_H
#include <stdarg.h>
#include <stdio.h>
@@ -45,7 +45,8 @@ protected:
FDType m_fd_type;
private:
- DISALLOW_COPY_AND_ASSIGN(IOObject);
+ IOObject(const IOObject &) = delete;
+ const IOObject &operator=(const IOObject &) = delete;
};
} // namespace lldb_private
diff --git a/lldb/include/lldb/Utility/Iterable.h b/lldb/include/lldb/Utility/Iterable.h
index d9c61aa958cc..3f9b8b1e4c57 100644
--- a/lldb/include/lldb/Utility/Iterable.h
+++ b/lldb/include/lldb/Utility/Iterable.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Iterable_h_
-#define liblldb_Iterable_h_
+#ifndef LLDB_UTILITY_ITERABLE_H
+#define LLDB_UTILITY_ITERABLE_H
#include <utility>
@@ -194,4 +194,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_Iterable_h_
+#endif // LLDB_UTILITY_ITERABLE_H
diff --git a/lldb/include/lldb/Utility/LLDBAssert.h b/lldb/include/lldb/Utility/LLDBAssert.h
index 7008dd82496d..845af1d4cc2a 100644
--- a/lldb/include/lldb/Utility/LLDBAssert.h
+++ b/lldb/include/lldb/Utility/LLDBAssert.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef utility_LLDBAssert_h_
-#define utility_LLDBAssert_h_
+#ifndef LLDB_UTILITY_LLDBASSERT_H
+#define LLDB_UTILITY_LLDBASSERT_H
#ifdef LLDB_CONFIGURATION_DEBUG
#define lldbassert(x) assert(x)
@@ -22,4 +22,4 @@ void lldb_assert(bool expression, const char *expr_text, const char *func,
const char *file, unsigned int line);
}
-#endif // utility_LLDBAssert_h_
+#endif // LLDB_UTILITY_LLDBASSERT_H
diff --git a/lldb/include/lldb/Utility/Listener.h b/lldb/include/lldb/Utility/Listener.h
index 17fc47880e8f..9d96e36c5abc 100644
--- a/lldb/include/lldb/Utility/Listener.h
+++ b/lldb/include/lldb/Utility/Listener.h
@@ -145,7 +145,8 @@ private:
// bool exact);
// For Listener only
- DISALLOW_COPY_AND_ASSIGN(Listener);
+ Listener(const Listener &) = delete;
+ const Listener &operator=(const Listener &) = delete;
};
} // namespace lldb_private
diff --git a/lldb/include/lldb/Utility/Predicate.h b/lldb/include/lldb/Utility/Predicate.h
index cbccc3e91a8b..a17ac05f6e56 100644
--- a/lldb/include/lldb/Utility/Predicate.h
+++ b/lldb/include/lldb/Utility/Predicate.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Predicate_h_
-#define liblldb_Predicate_h_
+#ifndef LLDB_UTILITY_PREDICATE_H
+#define LLDB_UTILITY_PREDICATE_H
#include <stdint.h>
#include <time.h>
@@ -221,9 +221,10 @@ private:
m_condition.notify_all();
}
- DISALLOW_COPY_AND_ASSIGN(Predicate);
+ Predicate(const Predicate &) = delete;
+ const Predicate &operator=(const Predicate &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Predicate_h_
+#endif // LLDB_UTILITY_PREDICATE_H
diff --git a/lldb/include/lldb/Utility/ProcessInfo.h b/lldb/include/lldb/Utility/ProcessInfo.h
index 9188bf3b7090..ec91060cda54 100644
--- a/lldb/include/lldb/Utility/ProcessInfo.h
+++ b/lldb/include/lldb/Utility/ProcessInfo.h
@@ -9,13 +9,13 @@
#ifndef LLDB_UTILITY_PROCESSINFO_H
#define LLDB_UTILITY_PROCESSINFO_H
-// LLDB headers
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/Args.h"
#include "lldb/Utility/Environment.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/NameMatches.h"
-
+#include "lldb/Utility/Reproducer.h"
+#include "llvm/Support/YAMLTraits.h"
#include <vector>
namespace lldb_private {
@@ -89,6 +89,7 @@ public:
const Environment &GetEnvironment() const { return m_environment; }
protected:
+ template <class T> friend struct llvm::yaml::MappingTraits;
FileSpec m_executable;
std::string m_arg0; // argv[0] if supported. If empty, then use m_executable.
// Not all process plug-ins support specifying an argv[0] that differs from
@@ -150,46 +151,13 @@ public:
bool verbose) const;
protected:
+ friend struct llvm::yaml::MappingTraits<ProcessInstanceInfo>;
uint32_t m_euid;
uint32_t m_egid;
lldb::pid_t m_parent_pid;
};
-class ProcessInstanceInfoList {
-public:
- ProcessInstanceInfoList() = default;
-
- void Clear() { m_infos.clear(); }
-
- size_t GetSize() { return m_infos.size(); }
-
- void Append(const ProcessInstanceInfo &info) { m_infos.push_back(info); }
-
- llvm::StringRef GetProcessNameAtIndex(size_t idx) {
- return ((idx < m_infos.size()) ? m_infos[idx].GetNameAsStringRef() : "");
- }
-
- lldb::pid_t GetProcessIDAtIndex(size_t idx) {
- return ((idx < m_infos.size()) ? m_infos[idx].GetProcessID() : 0);
- }
-
- bool GetInfoAtIndex(size_t idx, ProcessInstanceInfo &info) {
- if (idx < m_infos.size()) {
- info = m_infos[idx];
- return true;
- }
- return false;
- }
-
- // You must ensure "idx" is valid before calling this function
- const ProcessInstanceInfo &GetProcessInfoAtIndex(size_t idx) const {
- assert(idx < m_infos.size());
- return m_infos[idx];
- }
-
-protected:
- std::vector<ProcessInstanceInfo> m_infos;
-};
+typedef std::vector<ProcessInstanceInfo> ProcessInstanceInfoList;
// ProcessInstanceInfoMatch
//
@@ -248,6 +216,52 @@ protected:
bool m_match_all_users;
};
+namespace repro {
+class ProcessInfoRecorder : public AbstractRecorder {
+public:
+ ProcessInfoRecorder(const FileSpec &filename, std::error_code &ec)
+ : AbstractRecorder(filename, ec) {}
+
+ static llvm::Expected<std::unique_ptr<ProcessInfoRecorder>>
+ Create(const FileSpec &filename);
+
+ void Record(const ProcessInstanceInfoList &process_infos);
+};
+
+class ProcessInfoProvider : public repro::Provider<ProcessInfoProvider> {
+public:
+ struct Info {
+ static const char *name;
+ static const char *file;
+ };
+
+ ProcessInfoProvider(const FileSpec &directory) : Provider(directory) {}
+
+ ProcessInfoRecorder *GetNewProcessInfoRecorder();
+
+ void Keep() override;
+ void Discard() override;
+
+ static char ID;
+
+private:
+ std::unique_ptr<llvm::raw_fd_ostream> m_stream_up;
+ std::vector<std::unique_ptr<ProcessInfoRecorder>> m_process_info_recorders;
+};
+
+llvm::Optional<ProcessInstanceInfoList> GetReplayProcessInstanceInfoList();
+
+} // namespace repro
} // namespace lldb_private
-#endif // #ifndef LLDB_UTILITY_PROCESSINFO_H
+LLVM_YAML_IS_SEQUENCE_VECTOR(lldb_private::ProcessInstanceInfo)
+
+namespace llvm {
+namespace yaml {
+template <> struct MappingTraits<lldb_private::ProcessInstanceInfo> {
+ static void mapping(IO &io, lldb_private::ProcessInstanceInfo &PII);
+};
+} // namespace yaml
+} // namespace llvm
+
+#endif // LLDB_UTILITY_PROCESSINFO_H
diff --git a/lldb/include/lldb/Utility/RangeMap.h b/lldb/include/lldb/Utility/RangeMap.h
index 9e0307351836..fb24c5a43479 100644
--- a/lldb/include/lldb/Utility/RangeMap.h
+++ b/lldb/include/lldb/Utility/RangeMap.h
@@ -122,220 +122,13 @@ template <typename B, typename S> struct Range {
}
};
-// A range array class where you get to define the type of the ranges
-// that the collection contains.
-
-template <typename B, typename S, unsigned N> class RangeArray {
+template <typename B, typename S, unsigned N = 0> class RangeVector {
public:
typedef B BaseType;
typedef S SizeType;
typedef Range<B, S> Entry;
typedef llvm::SmallVector<Entry, N> Collection;
- RangeArray() = default;
-
- ~RangeArray() = default;
-
- void Append(const Entry &entry) { m_entries.push_back(entry); }
-
- void Append(B base, S size) { m_entries.emplace_back(base, size); }
-
- bool RemoveEntrtAtIndex(uint32_t idx) {
- if (idx < m_entries.size()) {
- m_entries.erase(m_entries.begin() + idx);
- return true;
- }
- return false;
- }
-
- void Sort() {
- if (m_entries.size() > 1)
- std::stable_sort(m_entries.begin(), m_entries.end());
- }
-
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- bool IsSorted() const {
- typename Collection::const_iterator pos, end, prev;
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end;
- prev = pos++) {
- if (prev != end && *pos < *prev)
- return false;
- }
- return true;
- }
-#endif
-
- void CombineConsecutiveRanges() {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert(IsSorted());
-#endif
- // Can't combine if ranges if we have zero or one range
- if (m_entries.size() > 1) {
- // The list should be sorted prior to calling this function
- typename Collection::iterator pos;
- typename Collection::iterator end;
- typename Collection::iterator prev;
- bool can_combine = false;
- // First we determine if we can combine any of the Entry objects so we
- // don't end up allocating and making a new collection for no reason
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end;
- pos != end; prev = pos++) {
- if (prev != end && prev->DoesAdjoinOrIntersect(*pos)) {
- can_combine = true;
- break;
- }
- }
-
- // We we can combine at least one entry, then we make a new collection
- // and populate it accordingly, and then swap it into place.
- if (can_combine) {
- Collection minimal_ranges;
- for (pos = m_entries.begin(), end = m_entries.end(), prev = end;
- pos != end; prev = pos++) {
- if (prev != end && prev->DoesAdjoinOrIntersect(*pos))
- minimal_ranges.back().SetRangeEnd(
- std::max<BaseType>(prev->GetRangeEnd(), pos->GetRangeEnd()));
- else
- minimal_ranges.push_back(*pos);
- }
- // Use the swap technique in case our new vector is much smaller. We
- // must swap when using the STL because std::vector objects never
- // release or reduce the memory once it has been allocated/reserved.
- m_entries.swap(minimal_ranges);
- }
- }
- }
-
- BaseType GetMinRangeBase(BaseType fail_value) const {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert(IsSorted());
-#endif
- if (m_entries.empty())
- return fail_value;
- // m_entries must be sorted, so if we aren't empty, we grab the first
- // range's base
- return m_entries.front().GetRangeBase();
- }
-
- BaseType GetMaxRangeEnd(BaseType fail_value) const {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert(IsSorted());
-#endif
- if (m_entries.empty())
- return fail_value;
- // m_entries must be sorted, so if we aren't empty, we grab the last
- // range's end
- return m_entries.back().GetRangeEnd();
- }
-
- void Slide(BaseType slide) {
- typename Collection::iterator pos, end;
- for (pos = m_entries.begin(), end = m_entries.end(); pos != end; ++pos)
- pos->Slide(slide);
- }
-
- void Clear() { m_entries.clear(); }
-
- bool IsEmpty() const { return m_entries.empty(); }
-
- size_t GetSize() const { return m_entries.size(); }
-
- const Entry *GetEntryAtIndex(size_t i) const {
- return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
- }
-
- // Clients must ensure that "i" is a valid index prior to calling this
- // function
- const Entry &GetEntryRef(size_t i) const { return m_entries[i]; }
-
- Entry *Back() { return (m_entries.empty() ? nullptr : &m_entries.back()); }
-
- const Entry *Back() const {
- return (m_entries.empty() ? nullptr : &m_entries.back());
- }
-
- static bool BaseLessThan(const Entry &lhs, const Entry &rhs) {
- return lhs.GetRangeBase() < rhs.GetRangeBase();
- }
-
- uint32_t FindEntryIndexThatContains(B addr) const {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert(IsSorted());
-#endif
- if (!m_entries.empty()) {
- Entry entry(addr, 1);
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos =
- std::lower_bound(begin, end, entry, BaseLessThan);
-
- if (pos != end && pos->Contains(addr)) {
- return std::distance(begin, pos);
- } else if (pos != begin) {
- --pos;
- if (pos->Contains(addr))
- return std::distance(begin, pos);
- }
- }
- return UINT32_MAX;
- }
-
- const Entry *FindEntryThatContains(B addr) const {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert(IsSorted());
-#endif
- if (!m_entries.empty()) {
- Entry entry(addr, 1);
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos =
- std::lower_bound(begin, end, entry, BaseLessThan);
-
- if (pos != end && pos->Contains(addr)) {
- return &(*pos);
- } else if (pos != begin) {
- --pos;
- if (pos->Contains(addr)) {
- return &(*pos);
- }
- }
- }
- return nullptr;
- }
-
- const Entry *FindEntryThatContains(const Entry &range) const {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
- assert(IsSorted());
-#endif
- if (!m_entries.empty()) {
- typename Collection::const_iterator begin = m_entries.begin();
- typename Collection::const_iterator end = m_entries.end();
- typename Collection::const_iterator pos =
- std::lower_bound(begin, end, range, BaseLessThan);
-
- if (pos != end && pos->Contains(range)) {
- return &(*pos);
- } else if (pos != begin) {
- --pos;
- if (pos->Contains(range)) {
- return &(*pos);
- }
- }
- }
- return nullptr;
- }
-
-protected:
- Collection m_entries;
-};
-
-template <typename B, typename S> class RangeVector {
-public:
- typedef B BaseType;
- typedef S SizeType;
- typedef Range<B, S> Entry;
- typedef std::vector<Entry> Collection;
-
RangeVector() = default;
~RangeVector() = default;
@@ -601,19 +394,31 @@ struct RangeData : public Range<B, S> {
RangeData(B base, S size, DataType d) : Range<B, S>(base, size), data(d) {}
};
+// We can treat the vector as a flattened Binary Search Tree, augmenting it
+// with upper bounds (max of range endpoints) for every index allows us to
+// query for range containment quicker.
+template <typename B, typename S, typename T>
+struct AugmentedRangeData : public RangeData<B, S, T> {
+ B upper_bound;
+
+ AugmentedRangeData(const RangeData<B, S, T> &rd)
+ : RangeData<B, S, T>(rd), upper_bound() {}
+};
+
template <typename B, typename S, typename T, unsigned N = 0,
class Compare = std::less<T>>
class RangeDataVector {
public:
typedef lldb_private::Range<B, S> Range;
typedef RangeData<B, S, T> Entry;
- typedef llvm::SmallVector<Entry, N> Collection;
+ typedef AugmentedRangeData<B, S, T> AugmentedEntry;
+ typedef llvm::SmallVector<AugmentedEntry, N> Collection;
RangeDataVector(Compare compare = Compare()) : m_compare(compare) {}
~RangeDataVector() = default;
- void Append(const Entry &entry) { m_entries.push_back(entry); }
+ void Append(const Entry &entry) { m_entries.emplace_back(entry); }
void Sort() {
if (m_entries.size() > 1)
@@ -625,13 +430,13 @@ public:
return a.size < b.size;
return compare(a.data, b.data);
});
+ if (!m_entries.empty())
+ ComputeUpperBounds(0, m_entries.size());
}
#ifdef ASSERT_RANGEMAP_ARE_SORTED
bool IsSorted() const {
typename Collection::const_iterator pos, end, prev;
- // First we determine if we can combine any of the Entry objects so we
- // don't end up allocating and making a new collection for no reason
for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end;
prev = pos++) {
if (prev != end && *pos < *prev)
@@ -701,26 +506,20 @@ public:
}
uint32_t FindEntryIndexThatContains(B addr) const {
- const Entry *entry = FindEntryThatContains(addr);
+ const AugmentedEntry *entry =
+ static_cast<const AugmentedEntry *>(FindEntryThatContains(addr));
if (entry)
return std::distance(m_entries.begin(), entry);
return UINT32_MAX;
}
- uint32_t FindEntryIndexesThatContain(B addr,
- std::vector<uint32_t> &indexes) const {
+ uint32_t FindEntryIndexesThatContain(B addr, std::vector<uint32_t> &indexes) {
#ifdef ASSERT_RANGEMAP_ARE_SORTED
assert(IsSorted());
#endif
- // Search the entries until the first entry that has a larger base address
- // than `addr`. As m_entries is sorted by their base address, all following
- // entries can't contain `addr` as their base address is already larger.
- for (const auto &entry : m_entries) {
- if (entry.Contains(addr))
- indexes.push_back(entry.data);
- else if (entry.GetRangeBase() > addr)
- break;
- }
+ if (!m_entries.empty())
+ FindEntryIndexesThatContain(addr, 0, m_entries.size(), indexes);
+
return indexes.size();
}
@@ -806,6 +605,54 @@ public:
protected:
Collection m_entries;
Compare m_compare;
+
+private:
+ // Compute extra information needed for search
+ B ComputeUpperBounds(size_t lo, size_t hi) {
+ size_t mid = (lo + hi) / 2;
+ AugmentedEntry &entry = m_entries[mid];
+
+ entry.upper_bound = entry.base + entry.size;
+
+ if (lo < mid)
+ entry.upper_bound =
+ std::max(entry.upper_bound, ComputeUpperBounds(lo, mid));
+
+ if (mid + 1 < hi)
+ entry.upper_bound =
+ std::max(entry.upper_bound, ComputeUpperBounds(mid + 1, hi));
+
+ return entry.upper_bound;
+ }
+
+ // This is based on the augmented tree implementation found at
+ // https://en.wikipedia.org/wiki/Interval_tree#Augmented_tree
+ void FindEntryIndexesThatContain(B addr, size_t lo, size_t hi,
+ std::vector<uint32_t> &indexes) {
+ size_t mid = (lo + hi) / 2;
+ const AugmentedEntry &entry = m_entries[mid];
+
+ // addr is greater than the rightmost point of any interval below mid
+ // so there are cannot be any matches.
+ if (addr > entry.upper_bound)
+ return;
+
+ // Recursively search left subtree
+ if (lo < mid)
+ FindEntryIndexesThatContain(addr, lo, mid, indexes);
+
+ // If addr is smaller than the start of the current interval it
+ // cannot contain it nor can any of its right subtree.
+ if (addr < entry.base)
+ return;
+
+ if (entry.Contains(addr))
+ indexes.push_back(entry.data);
+
+ // Recursively search right subtree
+ if (mid + 1 < hi)
+ FindEntryIndexesThatContain(addr, mid + 1, hi, indexes);
+ }
};
// A simple range with data class where you get to define the type of
diff --git a/lldb/include/lldb/Utility/RegisterValue.h b/lldb/include/lldb/Utility/RegisterValue.h
index eeb3ce52a82b..c9f295a8d95a 100644
--- a/lldb/include/lldb/Utility/RegisterValue.h
+++ b/lldb/include/lldb/Utility/RegisterValue.h
@@ -26,7 +26,8 @@ struct RegisterInfo;
class RegisterValue {
public:
- enum { kMaxRegisterByteSize = 64u };
+ // big enough to support up to 256 byte AArch64 SVE
+ enum { kMaxRegisterByteSize = 256u };
enum Type {
eTypeInvalid,
@@ -259,9 +260,10 @@ protected:
Scalar m_scalar;
struct {
- uint8_t bytes[kMaxRegisterByteSize]; // This must be big enough to hold any
- // register for any supported target.
- uint8_t length;
+ mutable uint8_t
+ bytes[kMaxRegisterByteSize]; // This must be big enough to hold any
+ // register for any supported target.
+ uint16_t length;
lldb::ByteOrder byte_order;
} buffer;
};
diff --git a/lldb/include/lldb/Utility/RegularExpression.h b/lldb/include/lldb/Utility/RegularExpression.h
index 6acc203d8e7c..415f1b58b111 100644
--- a/lldb/include/lldb/Utility/RegularExpression.h
+++ b/lldb/include/lldb/Utility/RegularExpression.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegularExpression_h_
-#define liblldb_RegularExpression_h_
+#ifndef LLDB_UTILITY_REGULAREXPRESSION_H
+#define LLDB_UTILITY_REGULAREXPRESSION_H
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
@@ -91,4 +91,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_RegularExpression_h_
+#endif // LLDB_UTILITY_REGULAREXPRESSION_H
diff --git a/lldb/include/lldb/Utility/Reproducer.h b/lldb/include/lldb/Utility/Reproducer.h
index 0d23fe8571ff..ab673e5e0019 100644
--- a/lldb/include/lldb/Utility/Reproducer.h
+++ b/lldb/include/lldb/Utility/Reproducer.h
@@ -27,6 +27,7 @@ class Reproducer;
enum class ReproducerMode {
Capture,
Replay,
+ PassiveReplay,
Off,
};
@@ -98,6 +99,8 @@ public:
return m_collector;
}
+ void recordInterestingDirectory(const llvm::Twine &dir);
+
void Keep() override {
auto mapping = GetRoot().CopyByAppendingPathComponent(Info::file);
// Temporary files that are removed during execution can cause copy errors.
@@ -132,7 +135,7 @@ public:
static char ID;
};
-/// Provider for the LLDB current working directroy.
+/// Provider for the LLDB current working directory.
///
/// When the reproducer is kept, it writes lldb's current working directory to
/// a file named cwd.txt in the reproducer root.
@@ -142,8 +145,11 @@ public:
llvm::SmallString<128> cwd;
if (std::error_code EC = llvm::sys::fs::current_path(cwd))
return;
- m_cwd = cwd.str();
+ m_cwd = std::string(cwd.str());
}
+
+ void Update(llvm::StringRef path) { m_cwd = std::string(path); }
+
struct Info {
static const char *name;
static const char *file;
@@ -153,6 +159,9 @@ public:
static char ID;
};
+/// The recorder is a small object handed out by a provider to record data. It
+/// is commonly used in combination with a MultiProvider which is meant to
+/// record information for multiple instances of the same source of data.
class AbstractRecorder {
protected:
AbstractRecorder(const FileSpec &filename, std::error_code &ec)
@@ -175,6 +184,7 @@ protected:
bool m_record;
};
+/// Recorder that records its data as text to a file.
class DataRecorder : public AbstractRecorder {
public:
DataRecorder(const FileSpec &filename, std::error_code &ec)
@@ -193,24 +203,88 @@ public:
}
};
-class CommandProvider : public Provider<CommandProvider> {
+/// Recorder that records its data as YAML to a file.
+class YamlRecorder : public AbstractRecorder {
+public:
+ YamlRecorder(const FileSpec &filename, std::error_code &ec)
+ : AbstractRecorder(filename, ec) {}
+
+ static llvm::Expected<std::unique_ptr<YamlRecorder>>
+ Create(const FileSpec &filename);
+
+ template <typename T> void Record(const T &t) {
+ if (!m_record)
+ return;
+ llvm::yaml::Output yout(m_os);
+ // The YAML traits are defined as non-const because they are used for
+ // serialization and deserialization. The cast is safe because
+ // serialization doesn't modify the object.
+ yout << const_cast<T &>(t);
+ m_os.flush();
+ }
+};
+
+/// The MultiProvider is a provider that hands out recorder which can be used
+/// to capture data for different instances of the same object. The recorders
+/// can be passed around or stored as an instance member.
+///
+/// The Info::file for the MultiProvider contains an index of files for every
+/// recorder. Use the MultiLoader to read the index and get the individual
+/// files.
+template <typename T, typename V>
+class MultiProvider : public repro::Provider<V> {
+public:
+ MultiProvider(const FileSpec &directory) : Provider<V>(directory) {}
+
+ T *GetNewRecorder() {
+ std::size_t i = m_recorders.size() + 1;
+ std::string filename = (llvm::Twine(V::Info::name) + llvm::Twine("-") +
+ llvm::Twine(i) + llvm::Twine(".yaml"))
+ .str();
+ auto recorder_or_error =
+ T::Create(this->GetRoot().CopyByAppendingPathComponent(filename));
+ if (!recorder_or_error) {
+ llvm::consumeError(recorder_or_error.takeError());
+ return nullptr;
+ }
+
+ m_recorders.push_back(std::move(*recorder_or_error));
+ return m_recorders.back().get();
+ }
+
+ void Keep() override {
+ std::vector<std::string> files;
+ for (auto &recorder : m_recorders) {
+ recorder->Stop();
+ files.push_back(recorder->GetFilename().GetPath());
+ }
+
+ FileSpec file = this->GetRoot().CopyByAppendingPathComponent(V::Info::file);
+ std::error_code ec;
+ llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::OF_Text);
+ if (ec)
+ return;
+ llvm::yaml::Output yout(os);
+ yout << files;
+ }
+
+ void Discard() override { m_recorders.clear(); }
+
+private:
+ std::vector<std::unique_ptr<T>> m_recorders;
+};
+
+class CommandProvider : public MultiProvider<DataRecorder, CommandProvider> {
public:
struct Info {
static const char *name;
static const char *file;
};
- CommandProvider(const FileSpec &directory) : Provider(directory) {}
-
- DataRecorder *GetNewDataRecorder();
-
- void Keep() override;
- void Discard() override;
+ CommandProvider(const FileSpec &directory)
+ : MultiProvider<DataRecorder, CommandProvider>(directory) {}
static char ID;
-
-private:
- std::vector<std::unique_ptr<DataRecorder>> m_data_recorders;
};
/// The generator is responsible for the logic needed to generate a
@@ -231,6 +305,12 @@ public:
/// might need to clean up files already written to disk.
void Discard();
+ /// Enable or disable auto generate.
+ void SetAutoGenerate(bool b);
+
+ /// Return whether auto generate is enabled.
+ bool IsAutoGenerate() const;
+
/// Create and register a new provider.
template <typename T> T *Create() {
std::unique_ptr<ProviderBase> provider = std::make_unique<T>(m_root);
@@ -272,11 +352,14 @@ private:
/// Flag to ensure that we never call both keep and discard.
bool m_done = false;
+
+ /// Flag to auto generate a reproducer when it would otherwise be discarded.
+ bool m_auto_generate = false;
};
class Loader final {
public:
- Loader(FileSpec root);
+ Loader(FileSpec root, bool passive = false);
template <typename T> FileSpec GetFile() {
if (!HasFile(T::file))
@@ -298,12 +381,15 @@ public:
const FileSpec &GetRoot() const { return m_root; }
+ bool IsPassiveReplay() const { return m_passive_replay; }
+
private:
bool HasFile(llvm::StringRef file);
FileSpec m_root;
std::vector<std::string> m_files;
bool m_loaded;
+ bool m_passive_replay;
};
/// The reproducer enables clients to obtain access to the Generator and
@@ -331,7 +417,7 @@ public:
protected:
llvm::Error SetCapture(llvm::Optional<FileSpec> root);
- llvm::Error SetReplay(llvm::Optional<FileSpec> root);
+ llvm::Error SetReplay(llvm::Optional<FileSpec> root, bool passive = false);
private:
static llvm::Optional<Reproducer> &InstanceImpl();
@@ -342,6 +428,8 @@ private:
mutable std::mutex m_mutex;
};
+/// Loader for data captured with the MultiProvider. It will read the index and
+/// return the path to the files in the index.
template <typename T> class MultiLoader {
public:
MultiLoader(std::vector<std::string> files) : m_files(files) {}
diff --git a/lldb/include/lldb/Utility/ReproducerInstrumentation.h b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
index 75d66045758f..5fc33ad1a17b 100644
--- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h
+++ b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
@@ -5,8 +5,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_UTILITY_REPRODUCER_INSTRUMENTATION_H
-#define LLDB_UTILITY_REPRODUCER_INSTRUMENTATION_H
+#ifndef LLDB_UTILITY_REPRODUCERINSTRUMENTATION_H
+#define LLDB_UTILITY_REPRODUCERINSTRUMENTATION_H
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Log.h"
@@ -16,7 +16,6 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ErrorHandling.h"
-#include <iostream>
#include <map>
#include <type_traits>
@@ -33,6 +32,11 @@ inline void stringify_append(llvm::raw_string_ostream &ss, const T &t) {
}
template <typename T>
+inline void stringify_append(llvm::raw_string_ostream &ss, T *t) {
+ ss << reinterpret_cast<void *>(t);
+}
+
+template <typename T>
inline void stringify_append(llvm::raw_string_ostream &ss, const T *t) {
ss << reinterpret_cast<const void *>(t);
}
@@ -43,6 +47,12 @@ inline void stringify_append<char>(llvm::raw_string_ostream &ss,
ss << '\"' << t << '\"';
}
+template <>
+inline void stringify_append<std::nullptr_t>(llvm::raw_string_ostream &ss,
+ const std::nullptr_t &t) {
+ ss << "\"nullptr\"";
+}
+
template <typename Head>
inline void stringify_helper(llvm::raw_string_ostream &ss, const Head &head) {
stringify_append(ss, head);
@@ -69,120 +79,146 @@ template <typename... Ts> inline std::string stringify_args(const Ts &... ts) {
// #define LLDB_REPRO_INSTR_TRACE
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature) \
- R.Register<Class * Signature>(&construct<Class Signature>::doit, "", #Class, \
- #Class, #Signature)
+ R.Register<Class * Signature>(&construct<Class Signature>::record, "", \
+ #Class, #Class, #Signature)
+
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature) \
R.Register( \
- &invoke<Result(Class::*) Signature>::method<(&Class::Method)>::doit, \
+ &invoke<Result(Class::*) Signature>::method<(&Class::Method)>::record, \
#Result, #Class, #Method, #Signature)
+
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature) \
- R.Register(&invoke<Result(Class::*) Signature const>::method_const<( \
- &Class::Method)>::doit, \
+ R.Register(&invoke<Result(Class::*) \
+ Signature const>::method<(&Class::Method)>::record, \
#Result, #Class, #Method, #Signature)
+
#define LLDB_REGISTER_STATIC_METHOD(Result, Class, Method, Signature) \
- R.Register<Result Signature>( \
- static_cast<Result(*) Signature>(&Class::Method), #Result, #Class, \
- #Method, #Signature)
+ R.Register(&invoke<Result(*) Signature>::method<(&Class::Method)>::record, \
+ #Result, #Class, #Method, #Signature)
+
+#define LLDB_REGISTER_CHAR_PTR_METHOD_STATIC(Result, Class, Method) \
+ R.Register( \
+ &invoke<Result (*)(char *, size_t)>::method<(&Class::Method)>::record, \
+ &invoke_char_ptr<Result (*)(char *, \
+ size_t)>::method<(&Class::Method)>::record, \
+ #Result, #Class, #Method, "(char*, size_t");
+
+#define LLDB_REGISTER_CHAR_PTR_METHOD(Result, Class, Method) \
+ R.Register(&invoke<Result (Class::*)(char *, size_t)>::method<( \
+ &Class::Method)>::record, \
+ &invoke_char_ptr<Result (Class::*)(char *, size_t)>::method<( \
+ &Class::Method)>::record, \
+ #Result, #Class, #Method, "(char*, size_t");
+
+#define LLDB_REGISTER_CHAR_PTR_METHOD_CONST(Result, Class, Method) \
+ R.Register(&invoke<Result (Class::*)(char *, size_t) \
+ const>::method<(&Class::Method)>::record, \
+ &invoke_char_ptr<Result (Class::*)(char *, size_t) \
+ const>::method<(&Class::Method)>::record, \
+ #Result, #Class, #Method, "(char*, size_t");
+
+#define LLDB_CONSTRUCT_(T, Class, ...) \
+ lldb_private::repro::Recorder _recorder(LLVM_PRETTY_FUNCTION); \
+ lldb_private::repro::construct<T>::handle(LLDB_GET_INSTRUMENTATION_DATA(), \
+ _recorder, Class, __VA_ARGS__);
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature, ...) \
- lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION, \
- stringify_args(__VA_ARGS__)); \
- if (lldb_private::repro::InstrumentationData data = \
- LLDB_GET_INSTRUMENTATION_DATA()) { \
- sb_recorder.Record(data.GetSerializer(), data.GetRegistry(), \
- &lldb_private::repro::construct<Class Signature>::doit, \
- __VA_ARGS__); \
- sb_recorder.RecordResult(this); \
- }
+ LLDB_CONSTRUCT_(Class Signature, this, __VA_ARGS__)
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class) \
- lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION); \
- if (lldb_private::repro::InstrumentationData data = \
+ LLDB_CONSTRUCT_(Class(), this, lldb_private::repro::EmptyArg())
+
+#define LLDB_RECORD_(T1, T2, ...) \
+ lldb_private::repro::Recorder _recorder(LLVM_PRETTY_FUNCTION, \
+ stringify_args(__VA_ARGS__)); \
+ if (lldb_private::repro::InstrumentationData _data = \
LLDB_GET_INSTRUMENTATION_DATA()) { \
- sb_recorder.Record(data.GetSerializer(), data.GetRegistry(), \
- &lldb_private::repro::construct<Class()>::doit); \
- sb_recorder.RecordResult(this); \
+ if (lldb_private::repro::Serializer *_serializer = \
+ _data.GetSerializer()) { \
+ _recorder.Record(*_serializer, _data.GetRegistry(), \
+ &lldb_private::repro::invoke<T1>::method<T2>::record, \
+ __VA_ARGS__); \
+ } else if (lldb_private::repro::Deserializer *_deserializer = \
+ _data.GetDeserializer()) { \
+ if (_recorder.ShouldCapture()) { \
+ return lldb_private::repro::invoke<T1>::method<T2>::replay( \
+ _recorder, *_deserializer, _data.GetRegistry()); \
+ } \
+ } \
}
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature, ...) \
- lldb_private::repro::Recorder sb_recorder( \
- LLVM_PRETTY_FUNCTION, stringify_args(*this, __VA_ARGS__)); \
- if (lldb_private::repro::InstrumentationData data = \
- LLDB_GET_INSTRUMENTATION_DATA()) { \
- sb_recorder.Record( \
- data.GetSerializer(), data.GetRegistry(), \
- &lldb_private::repro::invoke<Result(Class::*) Signature>::method<( \
- &Class::Method)>::doit, \
- this, __VA_ARGS__); \
- }
+ LLDB_RECORD_(Result(Class::*) Signature, (&Class::Method), this, __VA_ARGS__)
#define LLDB_RECORD_METHOD_CONST(Result, Class, Method, Signature, ...) \
- lldb_private::repro::Recorder sb_recorder( \
- LLVM_PRETTY_FUNCTION, stringify_args(*this, __VA_ARGS__)); \
- if (lldb_private::repro::InstrumentationData data = \
- LLDB_GET_INSTRUMENTATION_DATA()) { \
- sb_recorder.Record( \
- data.GetSerializer(), data.GetRegistry(), \
- &lldb_private::repro::invoke<Result( \
- Class::*) Signature const>::method_const<(&Class::Method)>::doit, \
- this, __VA_ARGS__); \
- }
+ LLDB_RECORD_(Result(Class::*) Signature const, (&Class::Method), this, \
+ __VA_ARGS__)
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method) \
- lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION, \
- stringify_args(*this)); \
- if (lldb_private::repro::InstrumentationData data = \
- LLDB_GET_INSTRUMENTATION_DATA()) { \
- sb_recorder.Record(data.GetSerializer(), data.GetRegistry(), \
- &lldb_private::repro::invoke<Result ( \
- Class::*)()>::method<(&Class::Method)>::doit, \
- this); \
- }
+ LLDB_RECORD_(Result (Class::*)(), (&Class::Method), this)
#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method) \
- lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION, \
- stringify_args(*this)); \
- if (lldb_private::repro::InstrumentationData data = \
- LLDB_GET_INSTRUMENTATION_DATA()) { \
- sb_recorder.Record( \
- data.GetSerializer(), data.GetRegistry(), \
- &lldb_private::repro::invoke<Result ( \
- Class::*)() const>::method_const<(&Class::Method)>::doit, \
- this); \
- }
+ LLDB_RECORD_(Result (Class::*)() const, (&Class::Method), this)
#define LLDB_RECORD_STATIC_METHOD(Result, Class, Method, Signature, ...) \
- lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION, \
- stringify_args(__VA_ARGS__)); \
- if (lldb_private::repro::InstrumentationData data = \
- LLDB_GET_INSTRUMENTATION_DATA()) { \
- sb_recorder.Record(data.GetSerializer(), data.GetRegistry(), \
- static_cast<Result(*) Signature>(&Class::Method), \
- __VA_ARGS__); \
- }
+ LLDB_RECORD_(Result(*) Signature, (&Class::Method), __VA_ARGS__)
#define LLDB_RECORD_STATIC_METHOD_NO_ARGS(Result, Class, Method) \
- lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION); \
- if (lldb_private::repro::InstrumentationData data = \
+ LLDB_RECORD_(Result (*)(), (&Class::Method), lldb_private::repro::EmptyArg())
+
+#define LLDB_RECORD_CHAR_PTR_(T1, T2, StrOut, ...) \
+ lldb_private::repro::Recorder _recorder(LLVM_PRETTY_FUNCTION, \
+ stringify_args(__VA_ARGS__)); \
+ if (lldb_private::repro::InstrumentationData _data = \
LLDB_GET_INSTRUMENTATION_DATA()) { \
- sb_recorder.Record(data.GetSerializer(), data.GetRegistry(), \
- static_cast<Result (*)()>(&Class::Method)); \
+ if (lldb_private::repro::Serializer *_serializer = \
+ _data.GetSerializer()) { \
+ _recorder.Record(*_serializer, _data.GetRegistry(), \
+ &lldb_private::repro::invoke<T1>::method<(T2)>::record, \
+ __VA_ARGS__); \
+ } else if (lldb_private::repro::Deserializer *_deserializer = \
+ _data.GetDeserializer()) { \
+ if (_recorder.ShouldCapture()) { \
+ return lldb_private::repro::invoke_char_ptr<T1>::method<T2>::replay( \
+ _recorder, *_deserializer, _data.GetRegistry(), StrOut); \
+ } \
+ } \
}
-#define LLDB_RECORD_RESULT(Result) sb_recorder.RecordResult(Result);
+#define LLDB_RECORD_CHAR_PTR_METHOD(Result, Class, Method, Signature, StrOut, \
+ ...) \
+ LLDB_RECORD_CHAR_PTR_(Result(Class::*) Signature, (&Class::Method), StrOut, \
+ this, __VA_ARGS__)
+
+#define LLDB_RECORD_CHAR_PTR_METHOD_CONST(Result, Class, Method, Signature, \
+ StrOut, ...) \
+ LLDB_RECORD_CHAR_PTR_(Result(Class::*) Signature const, (&Class::Method), \
+ StrOut, this, __VA_ARGS__)
+
+#define LLDB_RECORD_CHAR_PTR_STATIC_METHOD(Result, Class, Method, Signature, \
+ StrOut, ...) \
+ LLDB_RECORD_CHAR_PTR_(Result(*) Signature, (&Class::Method), StrOut, \
+ __VA_ARGS__)
+
+#define LLDB_RECORD_RESULT(Result) _recorder.RecordResult(Result, true);
/// The LLDB_RECORD_DUMMY macro is special because it doesn't actually record
/// anything. It's used to track API boundaries when we cannot record for
/// technical reasons.
#define LLDB_RECORD_DUMMY(Result, Class, Method, Signature, ...) \
- lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION, \
- stringify_args(__VA_ARGS__));
+ lldb_private::repro::Recorder _recorder;
+
#define LLDB_RECORD_DUMMY_NO_ARGS(Result, Class, Method) \
- lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION);
+ lldb_private::repro::Recorder _recorder;
namespace lldb_private {
namespace repro {
+template <class T>
+struct is_trivially_serializable
+ : std::integral_constant<bool, std::is_fundamental<T>::value ||
+ std::is_enum<T>::value> {};
+
/// Mapping between serialized indices and their corresponding objects.
///
/// This class is used during replay to map indices back to in-memory objects.
@@ -205,19 +241,24 @@ public:
}
/// Adds a pointer to an object to the mapping for the given index.
- template <typename T> void AddObjectForIndex(unsigned idx, T *object) {
+ template <typename T> T *AddObjectForIndex(unsigned idx, T *object) {
AddObjectForIndexImpl(
idx, static_cast<void *>(
const_cast<typename std::remove_const<T>::type *>(object)));
+ return object;
}
/// Adds a reference to an object to the mapping for the given index.
- template <typename T> void AddObjectForIndex(unsigned idx, T &object) {
+ template <typename T> T &AddObjectForIndex(unsigned idx, T &object) {
AddObjectForIndexImpl(
idx, static_cast<void *>(
const_cast<typename std::remove_const<T>::type *>(&object)));
+ return object;
}
+ /// Get all objects sorted by their index.
+ std::vector<void *> GetAllObjects() const;
+
private:
/// Helper method that does the actual lookup. The void* result is later cast
/// by the caller.
@@ -238,11 +279,11 @@ struct ReferenceTag {};
struct ValueTag {};
struct FundamentalPointerTag {};
struct FundamentalReferenceTag {};
-struct NotImplementedTag {};
/// Return the deserialization tag for the given type T.
template <class T> struct serializer_tag {
- typedef typename std::conditional<std::is_trivially_copyable<T>::value, ValueTag, NotImplementedTag>::type type;
+ typedef typename std::conditional<std::is_trivially_copyable<T>::value,
+ ValueTag, ReferenceTag>::type type;
};
template <class T> struct serializer_tag<T *> {
typedef
@@ -275,27 +316,37 @@ public:
/// Deserialize and interpret value as T.
template <typename T> T Deserialize() {
+ T t = Read<T>(typename serializer_tag<T>::type());
#ifdef LLDB_REPRO_INSTR_TRACE
- llvm::errs() << "Deserializing with " << LLVM_PRETTY_FUNCTION << "\n";
+ llvm::errs() << "Deserializing with " << LLVM_PRETTY_FUNCTION << " -> "
+ << stringify_args(t) << "\n";
#endif
- return Read<T>(typename serializer_tag<T>::type());
+ return t;
+ }
+
+ template <typename T> const T &HandleReplayResult(const T &t) {
+ unsigned result = Deserialize<unsigned>();
+ if (is_trivially_serializable<T>::value)
+ return t;
+ // We need to make a copy as the original object might go out of scope.
+ return *m_index_to_object.AddObjectForIndex(result, new T(t));
}
/// Store the returned value in the index-to-object mapping.
- template <typename T> void HandleReplayResult(const T &t) {
+ template <typename T> T &HandleReplayResult(T &t) {
unsigned result = Deserialize<unsigned>();
- if (std::is_fundamental<T>::value)
- return;
+ if (is_trivially_serializable<T>::value)
+ return t;
// We need to make a copy as the original object might go out of scope.
- m_index_to_object.AddObjectForIndex(result, new T(t));
+ return *m_index_to_object.AddObjectForIndex(result, new T(t));
}
/// Store the returned value in the index-to-object mapping.
- template <typename T> void HandleReplayResult(T *t) {
+ template <typename T> T *HandleReplayResult(T *t) {
unsigned result = Deserialize<unsigned>();
- if (std::is_fundamental<T>::value)
- return;
- m_index_to_object.AddObjectForIndex(result, t);
+ if (is_trivially_serializable<T>::value)
+ return t;
+ return m_index_to_object.AddObjectForIndex(result, t);
}
/// All returned types are recorded, even when the function returns a void.
@@ -306,12 +357,11 @@ public:
(void)result;
}
-private:
- template <typename T> T Read(NotImplementedTag) {
- m_buffer = m_buffer.drop_front(sizeof(T));
- return T();
+ std::vector<void *> GetAllObjects() const {
+ return m_index_to_object.GetAllObjects();
}
+private:
template <typename T> T Read(ValueTag) {
assert(HasData(sizeof(T)));
T t;
@@ -362,7 +412,11 @@ private:
/// Partial specialization for C-style strings. We read the string value
/// instead of treating it as pointer.
template <> const char *Deserializer::Deserialize<const char *>();
+template <> const char **Deserializer::Deserialize<const char **>();
+template <> const uint8_t *Deserializer::Deserialize<const uint8_t *>();
+template <> const void *Deserializer::Deserialize<const void *>();
template <> char *Deserializer::Deserialize<char *>();
+template <> void *Deserializer::Deserialize<void *>();
/// Helpers to auto-synthesize function replay code. It deserializes the replay
/// function's arguments one by one and finally calls the corresponding
@@ -404,7 +458,11 @@ struct DefaultReplayer<Result(Args...)> : public Replayer {
DefaultReplayer(Result (*f)(Args...)) : Replayer(), f(f) {}
void operator()(Deserializer &deserializer) const override {
- deserializer.HandleReplayResult(
+ Replay(deserializer);
+ }
+
+ Result Replay(Deserializer &deserializer) const {
+ return deserializer.HandleReplayResult(
DeserializationHelper<Args...>::template deserialized<Result>::doit(
deserializer, f));
}
@@ -419,6 +477,10 @@ struct DefaultReplayer<void(Args...)> : public Replayer {
DefaultReplayer(void (*f)(Args...)) : Replayer(), f(f) {}
void operator()(Deserializer &deserializer) const override {
+ Replay(deserializer);
+ }
+
+ void Replay(Deserializer &deserializer) const {
DeserializationHelper<Args...>::template deserialized<void>::doit(
deserializer, f);
deserializer.HandleReplayResultVoid();
@@ -474,18 +536,25 @@ public:
/// Replay functions from a buffer.
bool Replay(llvm::StringRef buffer);
+ /// Replay functions from a deserializer.
+ bool Replay(Deserializer &deserializer);
+
/// Returns the ID for a given function address.
unsigned GetID(uintptr_t addr);
+ /// Get the replayer matching the given ID.
+ Replayer *GetReplayer(unsigned id);
+
+ std::string GetSignature(unsigned id);
+
+ void CheckID(unsigned expected, unsigned actual);
+
protected:
/// Register the given replayer for a function (and the ID mapping).
void DoRegister(uintptr_t RunID, std::unique_ptr<Replayer> replayer,
SignatureStr signature);
private:
- std::string GetSignature(unsigned id);
- Replayer *GetReplayer(unsigned id);
-
/// Mapping of function addresses to replayers and their ID.
std::map<uintptr_t, std::pair<std::unique_ptr<Replayer>, unsigned>>
m_replayers;
@@ -494,37 +563,6 @@ private:
std::map<unsigned, std::pair<Replayer *, SignatureStr>> m_ids;
};
-/// To be used as the "Runtime ID" of a constructor. It also invokes the
-/// constructor when called.
-template <typename Signature> struct construct;
-template <typename Class, typename... Args> struct construct<Class(Args...)> {
- static Class *doit(Args... args) { return new Class(args...); }
-};
-
-/// To be used as the "Runtime ID" of a member function. It also invokes the
-/// member function when called.
-template <typename Signature> struct invoke;
-template <typename Result, typename Class, typename... Args>
-struct invoke<Result (Class::*)(Args...)> {
- template <Result (Class::*m)(Args...)> struct method {
- static Result doit(Class *c, Args... args) { return (c->*m)(args...); }
- };
-};
-
-template <typename Result, typename Class, typename... Args>
-struct invoke<Result (Class::*)(Args...) const> {
- template <Result (Class::*m)(Args...) const> struct method_const {
- static Result doit(Class *c, Args... args) { return (c->*m)(args...); }
- };
-};
-
-template <typename Class, typename... Args>
-struct invoke<void (Class::*)(Args...)> {
- template <void (Class::*m)(Args...)> struct method {
- static void doit(Class *c, Args... args) { (c->*m)(args...); }
- };
-};
-
/// Maps an object to an index for serialization. Indices are unique and
/// incremented for every new object.
///
@@ -561,6 +599,10 @@ private:
/// fundamental types (in which case we serialize its value) and pointer to
/// objects (in which case we serialize their index).
template <typename T> void Serialize(T *t) {
+#ifdef LLDB_REPRO_INSTR_TRACE
+ llvm::errs() << "Serializing with " << LLVM_PRETTY_FUNCTION << " -> "
+ << stringify_args(t) << "\n";
+#endif
if (std::is_fundamental<T>::value) {
Serialize(*t);
} else {
@@ -573,7 +615,11 @@ private:
/// fundamental types (in which case we serialize its value) and references
/// to objects (in which case we serialize their index).
template <typename T> void Serialize(T &t) {
- if (std::is_fundamental<T>::value) {
+#ifdef LLDB_REPRO_INSTR_TRACE
+ llvm::errs() << "Serializing with " << LLVM_PRETTY_FUNCTION << " -> "
+ << stringify_args(t) << "\n";
+#endif
+ if (is_trivially_serializable<T>::value) {
m_stream.write(reinterpret_cast<const char *>(&t), sizeof(T));
} else {
unsigned idx = m_tracker.GetIndexForObject(&t);
@@ -581,14 +627,43 @@ private:
}
}
+ void Serialize(const void *v) {
+ // FIXME: Support void*
+ }
+
void Serialize(void *v) {
// FIXME: Support void*
- llvm_unreachable("void* is currently unsupported.");
}
void Serialize(const char *t) {
- m_stream << t;
- m_stream.write(0x0);
+#ifdef LLDB_REPRO_INSTR_TRACE
+ llvm::errs() << "Serializing with " << LLVM_PRETTY_FUNCTION << " -> "
+ << stringify_args(t) << "\n";
+#endif
+ const size_t size = t ? strlen(t) : std::numeric_limits<size_t>::max();
+ Serialize(size);
+ if (t) {
+ m_stream << t;
+ m_stream.write(0x0);
+ }
+ }
+
+ void Serialize(const char **t) {
+ size_t size = 0;
+ if (!t) {
+ Serialize(size);
+ return;
+ }
+
+ // Compute the size of the array.
+ const char *const *temp = t;
+ while (*temp++)
+ size++;
+ Serialize(size);
+
+ // Serialize the content of the array.
+ while (*t)
+ Serialize(*t++);
}
/// Serialization stream.
@@ -596,24 +671,46 @@ private:
/// Mapping of objects to indices.
ObjectToIndex m_tracker;
-};
+}; // namespace repro
class InstrumentationData {
public:
- InstrumentationData() : m_serializer(nullptr), m_registry(nullptr){};
- InstrumentationData(Serializer &serializer, Registry &registry)
- : m_serializer(&serializer), m_registry(&registry){};
-
- Serializer &GetSerializer() { return *m_serializer; }
+ Serializer *GetSerializer() { return m_serializer; }
+ Deserializer *GetDeserializer() { return m_deserializer; }
Registry &GetRegistry() { return *m_registry; }
- operator bool() { return m_serializer != nullptr && m_registry != nullptr; }
+ operator bool() {
+ return (m_serializer != nullptr || m_deserializer != nullptr) &&
+ m_registry != nullptr;
+ }
+
+ static void Initialize(Serializer &serializer, Registry &registry);
+ static void Initialize(Deserializer &serializer, Registry &registry);
+ static InstrumentationData &Instance();
+
+protected:
+ friend llvm::optional_detail::OptionalStorage<InstrumentationData, true>;
+ friend llvm::Optional<InstrumentationData>;
+
+ InstrumentationData()
+ : m_serializer(nullptr), m_deserializer(nullptr), m_registry(nullptr) {}
+ InstrumentationData(Serializer &serializer, Registry &registry)
+ : m_serializer(&serializer), m_deserializer(nullptr),
+ m_registry(&registry) {}
+ InstrumentationData(Deserializer &deserializer, Registry &registry)
+ : m_serializer(nullptr), m_deserializer(&deserializer),
+ m_registry(&registry) {}
private:
+ static llvm::Optional<InstrumentationData> &InstanceImpl();
+
Serializer *m_serializer;
+ Deserializer *m_deserializer;
Registry *m_registry;
};
+struct EmptyArg {};
+
/// RAII object that records function invocations and their return value.
///
/// API calls are only captured when the API boundary is crossed. Once we're in
@@ -628,7 +725,8 @@ private:
/// this class is also used for logging.
class Recorder {
public:
- Recorder(llvm::StringRef pretty_func = {}, std::string &&pretty_args = {});
+ Recorder();
+ Recorder(llvm::StringRef pretty_func, std::string &&pretty_args = {});
~Recorder();
/// Records a single function call.
@@ -679,9 +777,26 @@ public:
m_result_recorded = true;
}
+ /// Specializations for the no-argument methods. These are passed an empty
+ /// dummy argument so the same variadic macro can be used. These methods
+ /// strip the arguments before forwarding them.
+ template <typename Result>
+ void Record(Serializer &serializer, Registry &registry, Result (*f)(),
+ const EmptyArg &arg) {
+ Record(serializer, registry, f);
+ }
+
/// Record the result of a function call.
- template <typename Result> Result RecordResult(Result &&r) {
- UpdateBoundary();
+ template <typename Result>
+ Result RecordResult(Result &&r, bool update_boundary) {
+ // When recording the result from the LLDB_RECORD_RESULT macro, we need to
+ // update the boundary so we capture the copy constructor. However, when
+ // called to record the this pointer of the (copy) constructor, the
+ // boundary should not be toggled, because it is called from the
+ // LLDB_RECORD_CONSTRUCTOR macro, which might be followed by other API
+ // calls.
+ if (update_boundary)
+ UpdateBoundary();
if (m_serializer && ShouldCapture()) {
assert(!m_result_recorded);
m_serializer->SerializeAll(r);
@@ -690,14 +805,41 @@ public:
return std::forward<Result>(r);
}
+ template <typename Result, typename T>
+ Result Replay(Deserializer &deserializer, Registry &registry, uintptr_t addr,
+ bool update_boundary) {
+ unsigned actual_id = registry.GetID(addr);
+ unsigned id = deserializer.Deserialize<unsigned>();
+ registry.CheckID(id, actual_id);
+ return ReplayResult<Result>(
+ static_cast<DefaultReplayer<T> *>(registry.GetReplayer(id))
+ ->Replay(deserializer),
+ update_boundary);
+ }
+
+ void Replay(Deserializer &deserializer, Registry &registry, uintptr_t addr) {
+ unsigned actual_id = registry.GetID(addr);
+ unsigned id = deserializer.Deserialize<unsigned>();
+ registry.CheckID(id, actual_id);
+ registry.GetReplayer(id)->operator()(deserializer);
+ }
+
+ template <typename Result>
+ Result ReplayResult(Result &&r, bool update_boundary) {
+ if (update_boundary)
+ UpdateBoundary();
+ return std::forward<Result>(r);
+ }
+
+ bool ShouldCapture() { return m_local_boundary; }
+
private:
+ template <typename T> friend struct replay;
void UpdateBoundary() {
if (m_local_boundary)
g_global_boundary = false;
}
- bool ShouldCapture() { return m_local_boundary; }
-
#ifdef LLDB_REPRO_INSTR_TRACE
void Log(unsigned id) {
llvm::errs() << "Recording " << id << ": " << m_pretty_func << " ("
@@ -721,7 +863,197 @@ private:
static bool g_global_boundary;
};
+/// To be used as the "Runtime ID" of a constructor. It also invokes the
+/// constructor when called.
+template <typename Signature> struct construct;
+template <typename Class, typename... Args> struct construct<Class(Args...)> {
+ static Class *handle(lldb_private::repro::InstrumentationData data,
+ lldb_private::repro::Recorder &recorder, Class *c,
+ const EmptyArg &) {
+ return handle(data, recorder, c);
+ }
+
+ static Class *handle(lldb_private::repro::InstrumentationData data,
+ lldb_private::repro::Recorder &recorder, Class *c,
+ Args... args) {
+ if (!data)
+ return nullptr;
+
+ if (Serializer *serializer = data.GetSerializer()) {
+ recorder.Record(*serializer, data.GetRegistry(), &record, args...);
+ recorder.RecordResult(c, false);
+ } else if (Deserializer *deserializer = data.GetDeserializer()) {
+ if (recorder.ShouldCapture()) {
+ replay(recorder, *deserializer, data.GetRegistry());
+ }
+ }
+
+ return nullptr;
+ }
+
+ static Class *record(Args... args) { return new Class(args...); }
+
+ static Class *replay(Recorder &recorder, Deserializer &deserializer,
+ Registry &registry) {
+ return recorder.Replay<Class *, Class *(Args...)>(
+ deserializer, registry, uintptr_t(&record), false);
+ }
+};
+
+/// To be used as the "Runtime ID" of a member function. It also invokes the
+/// member function when called.
+template <typename Signature> struct invoke;
+template <typename Result, typename Class, typename... Args>
+struct invoke<Result (Class::*)(Args...)> {
+ template <Result (Class::*m)(Args...)> struct method {
+ static Result record(Class *c, Args... args) { return (c->*m)(args...); }
+
+ static Result replay(Recorder &recorder, Deserializer &deserializer,
+ Registry &registry) {
+ return recorder.Replay<Result, Result(Class *, Args...)>(
+ deserializer, registry, uintptr_t(&record), true);
+ }
+ };
+};
+
+template <typename Class, typename... Args>
+struct invoke<void (Class::*)(Args...)> {
+ template <void (Class::*m)(Args...)> struct method {
+ static void record(Class *c, Args... args) { (c->*m)(args...); }
+ static void replay(Recorder &recorder, Deserializer &deserializer,
+ Registry &registry) {
+ recorder.Replay(deserializer, registry, uintptr_t(&record));
+ }
+ };
+};
+
+template <typename Result, typename Class, typename... Args>
+struct invoke<Result (Class::*)(Args...) const> {
+ template <Result (Class::*m)(Args...) const> struct method {
+ static Result record(Class *c, Args... args) { return (c->*m)(args...); }
+ static Result replay(Recorder &recorder, Deserializer &deserializer,
+ Registry &registry) {
+ return recorder.Replay<Result, Result(Class *, Args...)>(
+ deserializer, registry, uintptr_t(&record), true);
+ }
+ };
+};
+
+template <typename Class, typename... Args>
+struct invoke<void (Class::*)(Args...) const> {
+ template <void (Class::*m)(Args...) const> struct method {
+ static void record(Class *c, Args... args) { return (c->*m)(args...); }
+ static void replay(Recorder &recorder, Deserializer &deserializer,
+ Registry &registry) {
+ recorder.Replay(deserializer, registry, uintptr_t(&record));
+ }
+ };
+};
+
+template <typename Signature> struct replay;
+
+template <typename Result, typename Class, typename... Args>
+struct replay<Result (Class::*)(Args...)> {
+ template <Result (Class::*m)(Args...)> struct method {};
+};
+
+template <typename Result, typename... Args>
+struct invoke<Result (*)(Args...)> {
+ template <Result (*m)(Args...)> struct method {
+ static Result record(Args... args) { return (*m)(args...); }
+ static Result replay(Recorder &recorder, Deserializer &deserializer,
+ Registry &registry) {
+ return recorder.Replay<Result, Result(Args...)>(deserializer, registry,
+ uintptr_t(&record), true);
+ }
+ };
+};
+
+template <typename... Args> struct invoke<void (*)(Args...)> {
+ template <void (*m)(Args...)> struct method {
+ static void record(Args... args) { return (*m)(args...); }
+ static void replay(Recorder &recorder, Deserializer &deserializer,
+ Registry &registry) {
+ recorder.Replay(deserializer, registry, uintptr_t(&record));
+ }
+ };
+};
+
+/// Special handling for functions returning strings as (char*, size_t).
+/// {
+
+/// For inline replay, we ignore the arguments and use the ones from the
+/// serializer instead. This doesn't work for methods that use a char* and a
+/// size to return a string. For one these functions have a custom replayer to
+/// prevent override the input buffer. Furthermore, the template-generated
+/// deserialization is not easy to hook into.
+///
+/// The specializations below hand-implement the serialization logic for the
+/// inline replay. Instead of using the function from the registry, it uses the
+/// one passed into the macro.
+template <typename Signature> struct invoke_char_ptr;
+template <typename Result, typename Class, typename... Args>
+struct invoke_char_ptr<Result (Class::*)(Args...) const> {
+ template <Result (Class::*m)(Args...) const> struct method {
+ static Result record(Class *c, char *s, size_t l) {
+ char *buffer = reinterpret_cast<char *>(calloc(l, sizeof(char)));
+ return (c->*m)(buffer, l);
+ }
+
+ static Result replay(Recorder &recorder, Deserializer &deserializer,
+ Registry &registry, char *str) {
+ deserializer.Deserialize<unsigned>();
+ Class *c = deserializer.Deserialize<Class *>();
+ deserializer.Deserialize<const char *>();
+ size_t l = deserializer.Deserialize<size_t>();
+ return recorder.ReplayResult(
+ std::move(deserializer.HandleReplayResult((c->*m)(str, l))), true);
+ }
+ };
+};
+
+template <typename Signature> struct invoke_char_ptr;
+template <typename Result, typename Class, typename... Args>
+struct invoke_char_ptr<Result (Class::*)(Args...)> {
+ template <Result (Class::*m)(Args...)> struct method {
+ static Result record(Class *c, char *s, size_t l) {
+ char *buffer = reinterpret_cast<char *>(calloc(l, sizeof(char)));
+ return (c->*m)(buffer, l);
+ }
+
+ static Result replay(Recorder &recorder, Deserializer &deserializer,
+ Registry &registry, char *str) {
+ deserializer.Deserialize<unsigned>();
+ Class *c = deserializer.Deserialize<Class *>();
+ deserializer.Deserialize<const char *>();
+ size_t l = deserializer.Deserialize<size_t>();
+ return recorder.ReplayResult(
+ std::move(deserializer.HandleReplayResult((c->*m)(str, l))), true);
+ }
+ };
+};
+
+template <typename Result, typename... Args>
+struct invoke_char_ptr<Result (*)(Args...)> {
+ template <Result (*m)(Args...)> struct method {
+ static Result record(char *s, size_t l) {
+ char *buffer = reinterpret_cast<char *>(calloc(l, sizeof(char)));
+ return (*m)(buffer, l);
+ }
+
+ static Result replay(Recorder &recorder, Deserializer &deserializer,
+ Registry &registry, char *str) {
+ deserializer.Deserialize<unsigned>();
+ deserializer.Deserialize<const char *>();
+ size_t l = deserializer.Deserialize<size_t>();
+ return recorder.ReplayResult(
+ std::move(deserializer.HandleReplayResult((*m)(str, l))), true);
+ }
+ };
+};
+/// }
+
} // namespace repro
} // namespace lldb_private
-#endif // LLDB_UTILITY_REPRODUCER_INSTRUMENTATION_H
+#endif // LLDB_UTILITY_REPRODUCERINSTRUMENTATION_H
diff --git a/lldb/include/lldb/Utility/Scalar.h b/lldb/include/lldb/Utility/Scalar.h
index 69c948ec6222..f215fa71c84c 100644
--- a/lldb/include/lldb/Utility/Scalar.h
+++ b/lldb/include/lldb/Utility/Scalar.h
@@ -83,20 +83,11 @@ public:
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(static_cast<float>(0)),
- m_ieee_quad(ieee_quad) {
- if (ieee_quad)
- m_float =
- llvm::APFloat(llvm::APFloat::IEEEquad(),
- llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
- (reinterpret_cast<type128 *>(&v))->x));
- else
- m_float =
- llvm::APFloat(llvm::APFloat::x87DoubleExtended(),
- llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
- (reinterpret_cast<type128 *>(&v))->x));
- }
+ Scalar(long double v)
+ : m_type(e_long_double),
+ m_float(llvm::APFloat::x87DoubleExtended(),
+ llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
+ (reinterpret_cast<type128 *>(&v))->x)) {}
Scalar(llvm::APInt v) : m_type(), m_float(static_cast<float>(0)) {
m_integer = llvm::APInt(v);
m_type = GetBestTypeForBitSize(m_integer.getBitWidth(), true);
@@ -115,7 +106,10 @@ public:
bool ClearBit(uint32_t bit);
- const void *GetBytes() const;
+ /// Store the binary representation of this value into the given storage.
+ /// Exactly GetByteSize() bytes will be stored, and the buffer must be large
+ /// enough to hold this data.
+ void GetBytes(llvm::MutableArrayRef<uint8_t> storage) const;
size_t GetByteSize() const;
@@ -131,7 +125,7 @@ public:
m_integer.clearAllBits();
}
- const char *GetTypeAsCString() const;
+ const char *GetTypeAsCString() const { return GetValueTypeAsCString(m_type); }
void GetValue(Stream *s, bool show_type) const;
@@ -139,8 +133,8 @@ public:
return (m_type >= e_sint) && (m_type <= e_long_double);
}
- /// Convert integer to \p type, limited to \p bits size.
- void TruncOrExtendTo(Scalar::Type type, uint16_t bits);
+ /// Convert to an integer with \p bits and the given signedness.
+ void TruncOrExtendTo(uint16_t bits, bool sign);
bool Promote(Scalar::Type type);
@@ -162,16 +156,6 @@ public:
// automagically by the compiler, so no temporary objects will need to be
// created. As a result, we currently don't need a variety of overloaded set
// value accessors.
- Scalar &operator=(const int i);
- Scalar &operator=(unsigned int v);
- Scalar &operator=(long v);
- Scalar &operator=(unsigned long v);
- Scalar &operator=(long long v);
- Scalar &operator=(unsigned long long v);
- Scalar &operator=(float v);
- Scalar &operator=(double v);
- Scalar &operator=(long double v);
- Scalar &operator=(llvm::APInt v);
Scalar &operator+=(const Scalar &rhs);
Scalar &operator<<=(const Scalar &rhs); // Shift left
Scalar &operator>>=(const Scalar &rhs); // Shift right (arithmetic)
@@ -204,7 +188,7 @@ public:
unsigned char UChar(unsigned char fail_value = 0) const;
- signed char SChar(char fail_value = 0) const;
+ signed char SChar(signed char fail_value = 0) const;
unsigned short UShort(unsigned short fail_value = 0) const;
@@ -220,7 +204,7 @@ public:
unsigned long long ULongLong(unsigned long long fail_value = 0) const;
- llvm::APInt SInt128(llvm::APInt &fail_value) const;
+ llvm::APInt SInt128(const llvm::APInt &fail_value) const;
llvm::APInt UInt128(const llvm::APInt &fail_value) const;
@@ -282,7 +266,8 @@ protected:
Scalar::Type m_type;
llvm::APInt m_integer;
llvm::APFloat m_float;
- bool m_ieee_quad = false;
+
+ template <typename T> T GetAs(T fail_value) const;
private:
friend const Scalar operator+(const Scalar &lhs, const Scalar &rhs);
diff --git a/lldb/include/lldb/Utility/SelectHelper.h b/lldb/include/lldb/Utility/SelectHelper.h
index ec37f194d329..63f1fe6421cf 100644
--- a/lldb/include/lldb/Utility/SelectHelper.h
+++ b/lldb/include/lldb/Utility/SelectHelper.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_SelectHelper_h_
-#define liblldb_SelectHelper_h_
+#ifndef LLDB_UTILITY_SELECTHELPER_H
+#define LLDB_UTILITY_SELECTHELPER_H
#include "lldb/Utility/Status.h"
#include "lldb/lldb-types.h"
@@ -68,4 +68,4 @@ protected:
llvm::Optional<std::chrono::steady_clock::time_point> m_end_time;
};
-#endif // liblldb_SelectHelper_h_
+#endif // LLDB_UTILITY_SELECTHELPER_H
diff --git a/lldb/include/lldb/Utility/SharedCluster.h b/lldb/include/lldb/Utility/SharedCluster.h
index 71bbb334cff3..375c1c131a09 100644
--- a/lldb/include/lldb/Utility/SharedCluster.h
+++ b/lldb/include/lldb/Utility/SharedCluster.h
@@ -6,90 +6,54 @@
//
//===----------------------------------------------------------------------===//
-#ifndef utility_SharedCluster_h_
-#define utility_SharedCluster_h_
+#ifndef LLDB_UTILITY_SHAREDCLUSTER_H
+#define LLDB_UTILITY_SHAREDCLUSTER_H
#include "lldb/Utility/LLDBAssert.h"
-#include "lldb/Utility/SharingPtr.h"
-
-#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
+#include <memory>
#include <mutex>
namespace lldb_private {
-namespace imp {
-template <typename T>
-class shared_ptr_refcount : public lldb_private::imp::shared_count {
-public:
- template <class Y>
- shared_ptr_refcount(Y *in) : shared_count(0), manager(in) {}
-
- shared_ptr_refcount() : shared_count(0) {}
-
- ~shared_ptr_refcount() override {}
-
- void on_zero_shared() override { manager->DecrementRefCount(); }
-
-private:
- T *manager;
-};
-
-} // namespace imp
-
-template <class T> class ClusterManager {
+template <class T>
+class ClusterManager : public std::enable_shared_from_this<ClusterManager<T>> {
public:
- ClusterManager() : m_objects(), m_external_ref(0), m_mutex() {}
+ static std::shared_ptr<ClusterManager> Create() {
+ return std::shared_ptr<ClusterManager>(new ClusterManager());
+ }
~ClusterManager() {
- for (typename llvm::SmallPtrSet<T *, 16>::iterator pos = m_objects.begin(),
- end = m_objects.end();
- pos != end; ++pos) {
- T *object = *pos;
- delete object;
- }
-
- // Decrement refcount should have been called on this ClusterManager, and
- // it should have locked the mutex, now we will unlock it before we destroy
- // it...
- m_mutex.unlock();
+ for (T *obj : m_objects)
+ delete obj;
}
void ManageObject(T *new_object) {
std::lock_guard<std::mutex> guard(m_mutex);
- m_objects.insert(new_object);
+ assert(!llvm::is_contained(m_objects, new_object) &&
+ "ManageObject called twice for the same object?");
+ m_objects.push_back(new_object);
}
- typename lldb_private::SharingPtr<T> GetSharedPointer(T *desired_object) {
- {
- std::lock_guard<std::mutex> guard(m_mutex);
- m_external_ref++;
- if (0 == m_objects.count(desired_object)) {
- lldbassert(false && "object not found in shared cluster when expected");
- desired_object = nullptr;
- }
+ std::shared_ptr<T> GetSharedPointer(T *desired_object) {
+ std::lock_guard<std::mutex> guard(m_mutex);
+ auto this_sp = this->shared_from_this();
+ if (!llvm::is_contained(m_objects, desired_object)) {
+ lldbassert(false && "object not found in shared cluster when expected");
+ desired_object = nullptr;
}
- return typename lldb_private::SharingPtr<T>(
- desired_object, new imp::shared_ptr_refcount<ClusterManager>(this));
+ return {std::move(this_sp), desired_object};
}
private:
- void DecrementRefCount() {
- m_mutex.lock();
- m_external_ref--;
- if (m_external_ref == 0)
- delete this;
- else
- m_mutex.unlock();
- }
-
- friend class imp::shared_ptr_refcount<ClusterManager>;
+ ClusterManager() : m_objects(), m_mutex() {}
- llvm::SmallPtrSet<T *, 16> m_objects;
- int m_external_ref;
+ llvm::SmallVector<T *, 16> m_objects;
std::mutex m_mutex;
};
} // namespace lldb_private
-#endif // utility_SharedCluster_h_
+#endif // LLDB_UTILITY_SHAREDCLUSTER_H
diff --git a/lldb/include/lldb/Utility/SharingPtr.h b/lldb/include/lldb/Utility/SharingPtr.h
deleted file mode 100644
index e4ab3d27a69b..000000000000
--- a/lldb/include/lldb/Utility/SharingPtr.h
+++ /dev/null
@@ -1,609 +0,0 @@
-//===---------------------SharingPtr.h --------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef utility_SharingPtr_h_
-#define utility_SharingPtr_h_
-
-#include <memory>
-
-// Microsoft Visual C++ currently does not enable std::atomic to work in CLR
-// mode - as such we need to "hack around it" for MSVC++ builds only using
-// Windows specific intrinsics instead of the C++11 atomic support
-#ifdef _MSC_VER
-#include <intrin.h>
-#else
-#include <atomic>
-#endif
-
-#include <stddef.h>
-
-
-//#define ENABLE_SP_LOGGING 1 // DON'T CHECK THIS LINE IN UNLESS COMMENTED OUT
-#if defined(ENABLE_SP_LOGGING)
-
-extern "C" void track_sp(void *sp_this, void *ptr, long count);
-
-#endif
-
-namespace lldb_private {
-
-namespace imp {
-
-class shared_count {
- shared_count(const shared_count &) = delete;
- shared_count &operator=(const shared_count &) = delete;
-
-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_;
-#else
- std::atomic<long> shared_owners_;
-#endif
- virtual ~shared_count();
-
-private:
- virtual void on_zero_shared() = 0;
-};
-
-template <class T> class shared_ptr_pointer : public shared_count {
- T data_;
-
-public:
- shared_ptr_pointer(T p) : data_(p) {}
-
-private:
- void on_zero_shared() override;
-
- shared_ptr_pointer(const shared_ptr_pointer &) = delete;
- shared_ptr_pointer &operator=(const shared_ptr_pointer &) = delete;
-};
-
-template <class T> void shared_ptr_pointer<T>::on_zero_shared() {
- delete data_;
-}
-
-template <class T> class shared_ptr_emplace : public shared_count {
- T data_;
-
-public:
- shared_ptr_emplace() : data_() {}
-
- template <class A0> shared_ptr_emplace(A0 &a0) : data_(a0) {}
-
- template <class A0, class A1>
- shared_ptr_emplace(A0 &a0, A1 &a1) : data_(a0, a1) {}
-
- template <class A0, class A1, class A2>
- shared_ptr_emplace(A0 &a0, A1 &a1, A2 &a2) : data_(a0, a1, a2) {}
-
- template <class A0, class A1, class A2, class A3>
- shared_ptr_emplace(A0 &a0, A1 &a1, A2 &a2, A3 &a3) : data_(a0, a1, a2, a3) {}
-
- template <class A0, class A1, class A2, class A3, class A4>
- shared_ptr_emplace(A0 &a0, A1 &a1, A2 &a2, A3 &a3, A4 &a4)
- : data_(a0, a1, a2, a3, a4) {}
-
-private:
- void on_zero_shared() override;
-
-public:
- T *get() { return &data_; }
-};
-
-template <class T> void shared_ptr_emplace<T>::on_zero_shared() {}
-
-} // 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);
- template <class Y> explicit SharingPtr(Y *p);
- template <class Y> explicit SharingPtr(Y *p, imp::shared_count *ctrl_block);
- template <class Y> SharingPtr(const SharingPtr<Y> &r, element_type *p);
- SharingPtr(const SharingPtr &r);
- template <class Y> SharingPtr(const SharingPtr<Y> &r);
-
- ~SharingPtr();
-
- SharingPtr &operator=(const SharingPtr &r);
- template <class Y> SharingPtr &operator=(const SharingPtr<Y> &r);
-
- void swap(SharingPtr &r);
- void reset();
- template <class Y> void reset(Y *p);
- void reset(std::nullptr_t);
-
- element_type *get() const { return ptr_; }
- element_type &operator*() const { return *ptr_; }
- element_type *operator->() const { return ptr_; }
- long use_count() const { return cntrl_ ? cntrl_->use_count() : 0; }
- bool unique() const { return use_count() == 1; }
- bool empty() const { return cntrl_ == nullptr; }
- operator nat *() const { return (nat *)get(); }
-
- static SharingPtr<T> make_shared();
-
- template <class A0> static SharingPtr<T> make_shared(A0 &);
-
- template <class A0, class A1> static SharingPtr<T> make_shared(A0 &, A1 &);
-
- template <class A0, class A1, class A2>
- static SharingPtr<T> make_shared(A0 &, A1 &, A2 &);
-
- template <class A0, class A1, class A2, class A3>
- static SharingPtr<T> make_shared(A0 &, A1 &, A2 &, A3 &);
-
- template <class A0, class A1, class A2, class A3, class A4>
- 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_(nullptr), cntrl_(nullptr) {}
-
-template <class T>
-inline SharingPtr<T>::SharingPtr(std::nullptr_t)
- : ptr_(nullptr), cntrl_(nullptr) {}
-
-template <class T>
-template <class Y>
-SharingPtr<T>::SharingPtr(Y *p) : ptr_(p), cntrl_(nullptr) {
- std::unique_ptr<Y> hold(p);
- typedef imp::shared_ptr_pointer<Y *> _CntrlBlk;
- cntrl_ = new _CntrlBlk(p);
- hold.release();
-}
-
-template <class T>
-template <class Y>
-SharingPtr<T>::SharingPtr(Y *p, imp::shared_count *cntrl_block)
- : ptr_(p), cntrl_(cntrl_block) {}
-
-template <class T>
-template <class Y>
-inline SharingPtr<T>::SharingPtr(const SharingPtr<Y> &r, element_type *p)
- : ptr_(p), cntrl_(r.cntrl_) {
- if (cntrl_)
- cntrl_->add_shared();
-}
-
-template <class T>
-inline SharingPtr<T>::SharingPtr(const SharingPtr &r)
- : ptr_(r.ptr_), cntrl_(r.cntrl_) {
- if (cntrl_)
- cntrl_->add_shared();
-}
-
-template <class T>
-template <class Y>
-inline SharingPtr<T>::SharingPtr(const SharingPtr<Y> &r)
- : ptr_(r.ptr_), cntrl_(r.cntrl_) {
- if (cntrl_)
- cntrl_->add_shared();
-}
-
-template <class T> SharingPtr<T>::~SharingPtr() {
- if (cntrl_)
- cntrl_->release_shared();
-}
-
-template <class T>
-inline SharingPtr<T> &SharingPtr<T>::operator=(const SharingPtr &r) {
- SharingPtr(r).swap(*this);
- return *this;
-}
-
-template <class T>
-template <class Y>
-inline SharingPtr<T> &SharingPtr<T>::operator=(const SharingPtr<Y> &r) {
- SharingPtr(r).swap(*this);
- return *this;
-}
-
-template <class T> inline void SharingPtr<T>::swap(SharingPtr &r) {
- std::swap(ptr_, r.ptr_);
- std::swap(cntrl_, r.cntrl_);
-}
-
-template <class T> inline void SharingPtr<T>::reset() {
- SharingPtr().swap(*this);
-}
-
-template <class T> inline void SharingPtr<T>::reset(std::nullptr_t p) {
- reset();
-}
-
-template <class T> template <class Y> inline void SharingPtr<T>::reset(Y *p) {
- SharingPtr(p).swap(*this);
-}
-
-template <class T> SharingPtr<T> SharingPtr<T>::make_shared() {
- typedef imp::shared_ptr_emplace<T> CntrlBlk;
- SharingPtr<T> r;
- r.cntrl_ = new CntrlBlk();
- r.ptr_ = static_cast<CntrlBlk *>(r.cntrl_)->get();
- return r;
-}
-
-template <class T>
-template <class A0>
-SharingPtr<T> SharingPtr<T>::make_shared(A0 &a0) {
- typedef imp::shared_ptr_emplace<T> CntrlBlk;
- SharingPtr<T> r;
- r.cntrl_ = new CntrlBlk(a0);
- r.ptr_ = static_cast<CntrlBlk *>(r.cntrl_)->get();
- return r;
-}
-
-template <class T>
-template <class A0, class A1>
-SharingPtr<T> SharingPtr<T>::make_shared(A0 &a0, A1 &a1) {
- typedef imp::shared_ptr_emplace<T> CntrlBlk;
- SharingPtr<T> r;
- r.cntrl_ = new CntrlBlk(a0, a1);
- r.ptr_ = static_cast<CntrlBlk *>(r.cntrl_)->get();
- return r;
-}
-
-template <class T>
-template <class A0, class A1, class A2>
-SharingPtr<T> SharingPtr<T>::make_shared(A0 &a0, A1 &a1, A2 &a2) {
- typedef imp::shared_ptr_emplace<T> CntrlBlk;
- SharingPtr<T> r;
- r.cntrl_ = new CntrlBlk(a0, a1, a2);
- r.ptr_ = static_cast<CntrlBlk *>(r.cntrl_)->get();
- return r;
-}
-
-template <class T>
-template <class A0, class A1, class A2, class A3>
-SharingPtr<T> SharingPtr<T>::make_shared(A0 &a0, A1 &a1, A2 &a2, A3 &a3) {
- typedef imp::shared_ptr_emplace<T> CntrlBlk;
- SharingPtr<T> r;
- r.cntrl_ = new CntrlBlk(a0, a1, a2, a3);
- r.ptr_ = static_cast<CntrlBlk *>(r.cntrl_)->get();
- return r;
-}
-
-template <class T>
-template <class A0, class A1, class A2, class A3, class A4>
-SharingPtr<T> SharingPtr<T>::make_shared(A0 &a0, A1 &a1, A2 &a2, A3 &a3,
- A4 &a4) {
- typedef imp::shared_ptr_emplace<T> CntrlBlk;
- SharingPtr<T> r;
- r.cntrl_ = new CntrlBlk(a0, a1, a2, a3, a4);
- r.ptr_ = static_cast<CntrlBlk *>(r.cntrl_)->get();
- return r;
-}
-
-template <class T> inline SharingPtr<T> make_shared() {
- return SharingPtr<T>::make_shared();
-}
-
-template <class T, class A0> inline SharingPtr<T> make_shared(A0 &a0) {
- return SharingPtr<T>::make_shared(a0);
-}
-
-template <class T, class A0, class A1>
-inline SharingPtr<T> make_shared(A0 &a0, A1 &a1) {
- return SharingPtr<T>::make_shared(a0, a1);
-}
-
-template <class T, class A0, class A1, class A2>
-inline SharingPtr<T> make_shared(A0 &a0, A1 &a1, A2 &a2) {
- return SharingPtr<T>::make_shared(a0, a1, a2);
-}
-
-template <class T, class A0, class A1, class A2, class A3>
-inline SharingPtr<T> make_shared(A0 &a0, A1 &a1, A2 &a2, A3 &a3) {
- return SharingPtr<T>::make_shared(a0, a1, a2, a3);
-}
-
-template <class T, class A0, class A1, class A2, class A3, class A4>
-inline SharingPtr<T> make_shared(A0 &a0, A1 &a1, A2 &a2, A3 &a3, A4 &a4) {
- return SharingPtr<T>::make_shared(a0, a1, a2, a3, a4);
-}
-
-template <class T, class U>
-inline bool operator==(const SharingPtr<T> &__x, const SharingPtr<U> &__y) {
- return __x.get() == __y.get();
-}
-
-template <class T, class U>
-inline bool operator!=(const SharingPtr<T> &__x, const SharingPtr<U> &__y) {
- return !(__x == __y);
-}
-
-template <class T, class U>
-inline bool operator<(const SharingPtr<T> &__x, const SharingPtr<U> &__y) {
- return __x.get() < __y.get();
-}
-
-template <class T> inline void swap(SharingPtr<T> &__x, SharingPtr<T> &__y) {
- __x.swap(__y);
-}
-
-template <class T, class U>
-inline SharingPtr<T> static_pointer_cast(const SharingPtr<U> &r) {
- return SharingPtr<T>(r, static_cast<T *>(r.get()));
-}
-
-template <class T, class U>
-SharingPtr<T> const_pointer_cast(const SharingPtr<U> &r) {
- return SharingPtr<T>(r, const_cast<T *>(r.get()));
-}
-
-template <class T> class LoggingSharingPtr : public SharingPtr<T> {
- typedef SharingPtr<T> base;
-
-public:
- typedef void (*Callback)(void *, const LoggingSharingPtr &, bool action);
- // action: false means increment just happened
- // true means decrement is about to happen
-
- LoggingSharingPtr() : cb_(0), baton_(nullptr) {}
-
- LoggingSharingPtr(Callback cb, void *baton) : cb_(cb), baton_(baton) {
- if (cb_)
- cb_(baton_, *this, false);
- }
-
- template <class Y>
- LoggingSharingPtr(Y *p) : base(p), cb_(0), baton_(nullptr) {}
-
- template <class Y>
- LoggingSharingPtr(Y *p, Callback cb, void *baton)
- : base(p), cb_(cb), baton_(baton) {
- if (cb_)
- cb_(baton_, *this, false);
- }
-
- ~LoggingSharingPtr() {
- if (cb_)
- cb_(baton_, *this, true);
- }
-
- LoggingSharingPtr(const LoggingSharingPtr &p)
- : base(p), cb_(p.cb_), baton_(p.baton_) {
- if (cb_)
- cb_(baton_, *this, false);
- }
-
- LoggingSharingPtr &operator=(const LoggingSharingPtr &p) {
- if (cb_)
- cb_(baton_, *this, true);
- base::operator=(p);
- cb_ = p.cb_;
- baton_ = p.baton_;
- if (cb_)
- cb_(baton_, *this, false);
- return *this;
- }
-
- void reset() {
- if (cb_)
- cb_(baton_, *this, true);
- base::reset();
- }
-
- template <class Y> void reset(Y *p) {
- if (cb_)
- cb_(baton_, *this, true);
- base::reset(p);
- if (cb_)
- cb_(baton_, *this, false);
- }
-
- void SetCallback(Callback cb, void *baton) {
- cb_ = cb;
- baton_ = baton;
- }
-
- void ClearCallback() {
- cb_ = 0;
- baton_ = 0;
- }
-
-private:
- Callback cb_;
- void *baton_;
-};
-
-template <class T> class IntrusiveSharingPtr;
-
-template <class T> class ReferenceCountedBase {
-public:
- explicit ReferenceCountedBase() : shared_owners_(-1) {}
-
- void add_shared();
-
- void release_shared();
-
- long use_count() const { return shared_owners_ + 1; }
-
-protected:
- long shared_owners_;
-
- friend class IntrusiveSharingPtr<T>;
-
-private:
- ReferenceCountedBase(const ReferenceCountedBase &) = delete;
- ReferenceCountedBase &operator=(const ReferenceCountedBase &) = delete;
-};
-
-template <class T> void lldb_private::ReferenceCountedBase<T>::add_shared() {
-#ifdef _MSC_VER
- _InterlockedIncrement(&shared_owners_);
-#else
- ++shared_owners_;
-#endif
-}
-
-template <class T>
-void lldb_private::ReferenceCountedBase<T>::release_shared() {
-#ifdef _MSC_VER
- if (_InterlockedDecrement(&shared_owners_) == -1)
-#else
- if (--shared_owners_ == -1)
-#endif
- delete static_cast<T *>(this);
-}
-
-template <class T>
-class ReferenceCountedBaseVirtual : public imp::shared_count {
-public:
- explicit ReferenceCountedBaseVirtual() : imp::shared_count(-1) {}
-
- ~ReferenceCountedBaseVirtual() override = default;
-
- void on_zero_shared() override;
-};
-
-template <class T> void ReferenceCountedBaseVirtual<T>::on_zero_shared() {}
-
-template <typename T> class IntrusiveSharingPtr {
-public:
- typedef T element_type;
-
- explicit IntrusiveSharingPtr() : ptr_(0) {}
-
- explicit IntrusiveSharingPtr(T *ptr) : ptr_(ptr) { add_shared(); }
-
- IntrusiveSharingPtr(const IntrusiveSharingPtr &rhs) : ptr_(rhs.ptr_) {
- add_shared();
- }
-
- template <class X>
- IntrusiveSharingPtr(const IntrusiveSharingPtr<X> &rhs) : ptr_(rhs.get()) {
- add_shared();
- }
-
- IntrusiveSharingPtr &operator=(const IntrusiveSharingPtr &rhs) {
- reset(rhs.get());
- return *this;
- }
-
- template <class X>
- IntrusiveSharingPtr &operator=(const IntrusiveSharingPtr<X> &rhs) {
- reset(rhs.get());
- return *this;
- }
-
- IntrusiveSharingPtr &operator=(T *ptr) {
- reset(ptr);
- return *this;
- }
-
- ~IntrusiveSharingPtr() {
- release_shared();
- ptr_ = nullptr;
- }
-
- T &operator*() const { return *ptr_; }
-
- T *operator->() const { return ptr_; }
-
- T *get() const { return ptr_; }
-
- explicit operator bool() const { return ptr_ != 0; }
-
- void swap(IntrusiveSharingPtr &rhs) {
- std::swap(ptr_, rhs.ptr_);
-#if defined(ENABLE_SP_LOGGING)
- track_sp(this, ptr_, use_count());
- track_sp(&rhs, rhs.ptr_, rhs.use_count());
-#endif
- }
-
- void reset(T *ptr = nullptr) { IntrusiveSharingPtr(ptr).swap(*this); }
-
- long use_count() const {
- if (ptr_)
- return ptr_->use_count();
- return 0;
- }
-
- bool unique() const { return use_count() == 1; }
-
-private:
- element_type *ptr_;
-
- void add_shared() {
- if (ptr_) {
- ptr_->add_shared();
-#if defined(ENABLE_SP_LOGGING)
- track_sp(this, ptr_, ptr_->use_count());
-#endif
- }
- }
- void release_shared() {
- if (ptr_) {
-#if defined(ENABLE_SP_LOGGING)
- track_sp(this, nullptr, ptr_->use_count() - 1);
-#endif
- ptr_->release_shared();
- }
- }
-};
-
-template <class T, class U>
-inline bool operator==(const IntrusiveSharingPtr<T> &lhs,
- const IntrusiveSharingPtr<U> &rhs) {
- return lhs.get() == rhs.get();
-}
-
-template <class T, class U>
-inline bool operator!=(const IntrusiveSharingPtr<T> &lhs,
- const IntrusiveSharingPtr<U> &rhs) {
- return lhs.get() != rhs.get();
-}
-
-template <class T, class U>
-inline bool operator==(const IntrusiveSharingPtr<T> &lhs, U *rhs) {
- return lhs.get() == rhs;
-}
-
-template <class T, class U>
-inline bool operator!=(const IntrusiveSharingPtr<T> &lhs, U *rhs) {
- return lhs.get() != rhs;
-}
-
-template <class T, class U>
-inline bool operator==(T *lhs, const IntrusiveSharingPtr<U> &rhs) {
- return lhs == rhs.get();
-}
-
-template <class T, class U>
-inline bool operator!=(T *lhs, const IntrusiveSharingPtr<U> &rhs) {
- return lhs != rhs.get();
-}
-
-} // namespace lldb_private
-
-#endif // utility_SharingPtr_h_
diff --git a/lldb/include/lldb/Utility/Status.h b/lldb/include/lldb/Utility/Status.h
index 36f52922c9bc..9babad18edc0 100644
--- a/lldb/include/lldb/Utility/Status.h
+++ b/lldb/include/lldb/Utility/Status.h
@@ -111,7 +111,7 @@ public:
/// Set accessor from a kern_return_t.
///
- /// Set accesssor for the error value to \a err and the error type to \c
+ /// Set accessor for the error value to \a err and the error type to \c
/// MachKernel.
///
/// \param[in] err
@@ -123,9 +123,9 @@ public:
int SetExpressionErrorWithFormat(lldb::ExpressionResults, const char *format,
...) __attribute__((format(printf, 3, 4)));
- /// Set accesssor with an error value and type.
+ /// Set accessor with an error value and type.
///
- /// Set accesssor for the error value to \a err and the error type to \a
+ /// Set accessor for the error value to \a err and the error type to \a
/// type.
///
/// \param[in] err
@@ -217,4 +217,4 @@ template <> struct format_provider<lldb_private::Status> {
} \
} while (0);
-#endif // #ifndef LLDB_UTILITY_STATUS_H
+#endif // LLDB_UTILITY_STATUS_H
diff --git a/lldb/include/lldb/Utility/Stream.h b/lldb/include/lldb/Utility/Stream.h
index 18a16a3461c1..e7f065a1fc7b 100644
--- a/lldb/include/lldb/Utility/Stream.h
+++ b/lldb/include/lldb/Utility/Stream.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Stream_h_
-#define liblldb_Stream_h_
+#ifndef LLDB_UTILITY_STREAM_H
+#define LLDB_UTILITY_STREAM_H
#include "lldb/Utility/Flags.h"
#include "lldb/lldb-defines.h"
@@ -56,12 +56,13 @@ public:
///
/// Construct with dump flags \a flags and the default address size. \a
/// flags can be any of the above enumeration logical OR'ed together.
- Stream(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order);
+ Stream(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order,
+ bool colors = false);
/// Construct a default Stream, not binary, host byte order and host addr
/// size.
///
- Stream();
+ Stream(bool colors = false);
// FIXME: Streams should not be copyable.
Stream(const Stream &other) : m_forwarder(*this) { (*this) = other; }
@@ -270,10 +271,8 @@ public:
/// optional string following the indentation spaces.
///
/// \param[in] s
- /// A C string to print following the indentation. If nullptr, just
- /// output the indentation characters.
- size_t Indent(const char *s = nullptr);
- size_t Indent(llvm::StringRef s);
+ /// A string to print following the indentation.
+ size_t Indent(llvm::StringRef s = "");
/// Decrement the current indentation level.
void IndentLess(unsigned amount = 2);
@@ -405,8 +404,10 @@ protected:
}
public:
- RawOstreamForward(Stream &target)
- : llvm::raw_ostream(/*unbuffered*/ true), m_target(target) {}
+ RawOstreamForward(Stream &target, bool colors = false)
+ : llvm::raw_ostream(/*unbuffered*/ true), m_target(target) {
+ enable_colors(colors);
+ }
};
RawOstreamForward m_forwarder;
};
@@ -461,4 +462,4 @@ void DumpAddressRange(llvm::raw_ostream &s, uint64_t lo_addr, uint64_t hi_addr,
} // namespace lldb_private
-#endif // liblldb_Stream_h_
+#endif // LLDB_UTILITY_STREAM_H
diff --git a/lldb/include/lldb/Utility/StreamCallback.h b/lldb/include/lldb/Utility/StreamCallback.h
index 6dbee67ecca2..d6d74fb84799 100644
--- a/lldb/include/lldb/Utility/StreamCallback.h
+++ b/lldb/include/lldb/Utility/StreamCallback.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_StreamCallback_h_
-#define liblldb_StreamCallback_h_
+#ifndef LLDB_UTILITY_STREAMCALLBACK_H
+#define LLDB_UTILITY_STREAMCALLBACK_H
#include "lldb/lldb-types.h"
#include "llvm/Support/raw_ostream.h"
@@ -32,4 +32,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_StreamCallback_h
+#endif // LLDB_UTILITY_STREAMCALLBACK_H
diff --git a/lldb/include/lldb/Utility/StreamString.h b/lldb/include/lldb/Utility/StreamString.h
index 581e102d4e80..b0be0f7dd76a 100644
--- a/lldb/include/lldb/Utility/StreamString.h
+++ b/lldb/include/lldb/Utility/StreamString.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_StreamString_h_
-#define liblldb_StreamString_h_
+#ifndef LLDB_UTILITY_STREAMSTRING_H
+#define LLDB_UTILITY_STREAMSTRING_H
#include "lldb/Utility/Stream.h"
#include "lldb/lldb-enumerations.h"
@@ -51,4 +51,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_StreamString_h_
+#endif // LLDB_UTILITY_STREAMSTRING_H
diff --git a/lldb/include/lldb/Utility/StreamTee.h b/lldb/include/lldb/Utility/StreamTee.h
index 92e94d4494f6..2995bc07f42a 100644
--- a/lldb/include/lldb/Utility/StreamTee.h
+++ b/lldb/include/lldb/Utility/StreamTee.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_StreamTee_h_
-#define liblldb_StreamTee_h_
+#ifndef LLDB_UTILITY_STREAMTEE_H
+#define LLDB_UTILITY_STREAMTEE_H
#include <limits.h>
@@ -19,7 +19,8 @@ namespace lldb_private {
class StreamTee : public Stream {
public:
- StreamTee() : Stream(), m_streams_mutex(), m_streams() {}
+ StreamTee(bool colors = false)
+ : Stream(colors), m_streams_mutex(), m_streams() {}
StreamTee(lldb::StreamSP &stream_sp)
: Stream(), m_streams_mutex(), m_streams() {
@@ -137,4 +138,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_StreamTee_h_
+#endif // LLDB_UTILITY_STREAMTEE_H
diff --git a/lldb/include/lldb/Utility/StringExtractor.h b/lldb/include/lldb/Utility/StringExtractor.h
index 293fef2fbe6b..6a5bb24779a4 100644
--- a/lldb/include/lldb/Utility/StringExtractor.h
+++ b/lldb/include/lldb/Utility/StringExtractor.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef utility_StringExtractor_h_
-#define utility_StringExtractor_h_
+#ifndef LLDB_UTILITY_STRINGEXTRACTOR_H
+#define LLDB_UTILITY_STRINGEXTRACTOR_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
@@ -26,7 +26,7 @@ public:
virtual ~StringExtractor();
void Reset(llvm::StringRef str) {
- m_packet = str;
+ m_packet = std::string(str);
m_index = 0;
}
@@ -118,4 +118,4 @@ protected:
uint64_t m_index;
};
-#endif // utility_StringExtractor_h_
+#endif // LLDB_UTILITY_STRINGEXTRACTOR_H
diff --git a/lldb/include/lldb/Utility/StringLexer.h b/lldb/include/lldb/Utility/StringLexer.h
index 533fd4fb896e..52f98e860da2 100644
--- a/lldb/include/lldb/Utility/StringLexer.h
+++ b/lldb/include/lldb/Utility/StringLexer.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef utility_StringLexer_h_
-#define utility_StringLexer_h_
+#ifndef LLDB_UTILITY_STRINGLEXER_H
+#define LLDB_UTILITY_STRINGLEXER_H
#include <initializer_list>
#include <string>
@@ -53,4 +53,4 @@ private:
} // namespace lldb_private
-#endif // #ifndef utility_StringLexer_h_
+#endif // LLDB_UTILITY_STRINGLEXER_H
diff --git a/lldb/include/lldb/Utility/StringList.h b/lldb/include/lldb/Utility/StringList.h
index 0b1d955678b3..591a15861593 100644
--- a/lldb/include/lldb/Utility/StringList.h
+++ b/lldb/include/lldb/Utility/StringList.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_StringList_h_
-#define liblldb_StringList_h_
+#ifndef LLDB_UTILITY_STRINGLIST_H
+#define LLDB_UTILITY_STRINGLIST_H
#include "llvm/ADT/StringRef.h"
@@ -132,4 +132,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_StringList_h_
+#endif // LLDB_UTILITY_STRINGLIST_H
diff --git a/lldb/include/lldb/Utility/StructuredData.h b/lldb/include/lldb/Utility/StructuredData.h
index 01b14fc3d4d3..14c82e669676 100644
--- a/lldb/include/lldb/Utility/StructuredData.h
+++ b/lldb/include/lldb/Utility/StructuredData.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_StructuredData_h_
-#define liblldb_StructuredData_h_
+#ifndef LLDB_UTILITY_STRUCTUREDDATA_H
+#define LLDB_UTILITY_STRUCTUREDDATA_H
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/JSON.h"
@@ -339,7 +339,7 @@ public:
explicit String(llvm::StringRef S)
: Object(lldb::eStructuredDataTypeString), m_value(S) {}
- void SetValue(llvm::StringRef S) { m_value = S; }
+ void SetValue(llvm::StringRef S) { m_value = std::string(S); }
llvm::StringRef GetValue() { return m_value; }
@@ -553,4 +553,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_StructuredData_h_
+#endif // LLDB_UTILITY_STRUCTUREDDATA_H
diff --git a/lldb/include/lldb/Utility/TildeExpressionResolver.h b/lldb/include/lldb/Utility/TildeExpressionResolver.h
index 196fdfcf9ab4..3253767ffd75 100644
--- a/lldb/include/lldb/Utility/TildeExpressionResolver.h
+++ b/lldb/include/lldb/Utility/TildeExpressionResolver.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_UTILITY_TILDE_EXPRESSION_RESOLVER_H
-#define LLDB_UTILITY_TILDE_EXPRESSION_RESOLVER_H
+#ifndef LLDB_UTILITY_TILDEEXPRESSIONRESOLVER_H
+#define LLDB_UTILITY_TILDEEXPRESSIONRESOLVER_H
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
@@ -61,4 +61,4 @@ public:
};
}
-#endif // #ifndef LLDB_UTILITY_TILDE_EXPRESSION_RESOLVER_H
+#endif // LLDB_UTILITY_TILDEEXPRESSIONRESOLVER_H
diff --git a/lldb/include/lldb/Utility/Timeout.h b/lldb/include/lldb/Utility/Timeout.h
index 202b747fd480..80e201515577 100644
--- a/lldb/include/lldb/Utility/Timeout.h
+++ b/lldb/include/lldb/Utility/Timeout.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Timeout_h_
-#define liblldb_Timeout_h_
+#ifndef LLDB_UTILITY_TIMEOUT_H
+#define LLDB_UTILITY_TIMEOUT_H
#include "llvm/ADT/Optional.h"
#include "llvm/Support/Chrono.h"
@@ -67,4 +67,4 @@ struct format_provider<lldb_private::Timeout<Ratio>, void> {
};
}
-#endif // liblldb_Timeout_h_
+#endif // LLDB_UTILITY_TIMEOUT_H
diff --git a/lldb/include/lldb/Utility/Timer.h b/lldb/include/lldb/Utility/Timer.h
index ad9421a75b15..f97315b2db0f 100644
--- a/lldb/include/lldb/Utility/Timer.h
+++ b/lldb/include/lldb/Utility/Timer.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Timer_h_
-#define liblldb_Timer_h_
+#ifndef LLDB_UTILITY_TIMER_H
+#define LLDB_UTILITY_TIMER_H
#include "lldb/lldb-defines.h"
#include "llvm/Support/Chrono.h"
@@ -34,7 +34,8 @@ public:
std::atomic<uint64_t> m_count;
std::atomic<Category *> m_next;
- DISALLOW_COPY_AND_ASSIGN(Category);
+ Category(const Category &) = delete;
+ const Category &operator=(const Category &) = delete;
};
/// Default constructor.
@@ -66,9 +67,10 @@ protected:
static std::atomic<unsigned> g_display_depth;
private:
- DISALLOW_COPY_AND_ASSIGN(Timer);
+ Timer(const Timer &) = delete;
+ const Timer &operator=(const Timer &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_Timer_h_
+#endif // LLDB_UTILITY_TIMER_H
diff --git a/lldb/include/lldb/Utility/TraceOptions.h b/lldb/include/lldb/Utility/TraceOptions.h
index d5e21ccd8ba3..97aad33899be 100644
--- a/lldb/include/lldb/Utility/TraceOptions.h
+++ b/lldb/include/lldb/Utility/TraceOptions.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_TraceOptions_h_
-#define liblldb_TraceOptions_h_
+#ifndef LLDB_UTILITY_TRACEOPTIONS_H
+#define LLDB_UTILITY_TRACEOPTIONS_H
#include "lldb/lldb-defines.h"
#include "lldb/lldb-enumerations.h"
@@ -57,4 +57,4 @@ private:
};
}
-#endif // liblldb_TraceOptions_h_
+#endif // LLDB_UTILITY_TRACEOPTIONS_H
diff --git a/lldb/include/lldb/Utility/UUID.h b/lldb/include/lldb/Utility/UUID.h
index 0284357be44a..5327719094c0 100644
--- a/lldb/include/lldb/Utility/UUID.h
+++ b/lldb/include/lldb/Utility/UUID.h
@@ -63,18 +63,13 @@ public:
std::string GetAsString(llvm::StringRef separator = "-") const;
- size_t SetFromStringRef(llvm::StringRef str, uint32_t num_uuid_bytes = 16);
+ bool SetFromStringRef(llvm::StringRef str);
// Same as SetFromStringRef, but if the resultant UUID is all 0 bytes, set the
// UUID to invalid.
- size_t SetFromOptionalStringRef(llvm::StringRef str,
- uint32_t num_uuid_bytes = 16);
-
- // Decode as many UUID bytes (up to 16) as possible from the C string "cstr"
- // This is used for auto completion where a partial UUID might have been
- // typed in. It
- /// Decode as many UUID bytes (up to 16) as possible from the C
- /// string \a cstr.
+ bool SetFromOptionalStringRef(llvm::StringRef str);
+
+ /// Decode as many UUID bytes as possible from the C string \a cstr.
///
/// \param[in] str
/// An llvm::StringRef that points at a UUID string value (no leading
@@ -88,8 +83,7 @@ public:
/// The original string, with all decoded bytes removed.
static llvm::StringRef
DecodeUUIDBytesFromString(llvm::StringRef str,
- llvm::SmallVectorImpl<uint8_t> &uuid_bytes,
- uint32_t num_uuid_bytes = 16);
+ llvm::SmallVectorImpl<uint8_t> &uuid_bytes);
private:
UUID(llvm::ArrayRef<uint8_t> bytes) : m_bytes(bytes.begin(), bytes.end()) {}
diff --git a/lldb/include/lldb/Utility/UriParser.h b/lldb/include/lldb/Utility/UriParser.h
index 4a3f01230e1a..6a64c3d747b5 100644
--- a/lldb/include/lldb/Utility/UriParser.h
+++ b/lldb/include/lldb/Utility/UriParser.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef utility_UriParser_h_
-#define utility_UriParser_h_
+#ifndef LLDB_UTILITY_URIPARSER_H
+#define LLDB_UTILITY_URIPARSER_H
#include "llvm/ADT/StringRef.h"
@@ -28,4 +28,4 @@ public:
};
}
-#endif // utility_UriParser_h_
+#endif // LLDB_UTILITY_URIPARSER_H
diff --git a/lldb/include/lldb/Utility/UserID.h b/lldb/include/lldb/Utility/UserID.h
index 2dc5cdb23d0e..9fc6985a5a99 100644
--- a/lldb/include/lldb/Utility/UserID.h
+++ b/lldb/include/lldb/Utility/UserID.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_UserID_h_
-#define liblldb_UserID_h_
+#ifndef LLDB_UTILITY_USERID_H
+#define LLDB_UTILITY_USERID_H
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
@@ -90,4 +90,4 @@ Stream &operator<<(Stream &strm, const UserID &uid);
} // namespace lldb_private
-#endif // liblldb_UserID_h_
+#endif // LLDB_UTILITY_USERID_H
diff --git a/lldb/include/lldb/Utility/UserIDResolver.h b/lldb/include/lldb/Utility/UserIDResolver.h
index bca82a11b660..e0f7b69cc075 100644
--- a/lldb/include/lldb/Utility/UserIDResolver.h
+++ b/lldb/include/lldb/Utility/UserIDResolver.h
@@ -53,4 +53,4 @@ private:
} // namespace lldb_private
-#endif // #ifndef LLDB_HOST_USERIDRESOLVER_H
+#endif // LLDB_UTILITY_USERIDRESOLVER_H
diff --git a/lldb/include/lldb/Utility/VASPrintf.h b/lldb/include/lldb/Utility/VASPrintf.h
index 582645fd2292..a4b5f7ddae2c 100644
--- a/lldb/include/lldb/Utility/VASPrintf.h
+++ b/lldb/include/lldb/Utility/VASPrintf.h
@@ -17,4 +17,4 @@ namespace lldb_private {
bool VASprintf(llvm::SmallVectorImpl<char> &buf, const char *fmt, va_list args);
}
-#endif // #ifdef LLDB_UTILITY_VASPRINTF_H
+#endif // LLDB_UTILITY_VASPRINTF_H
diff --git a/lldb/include/lldb/Utility/VMRange.h b/lldb/include/lldb/Utility/VMRange.h
index 72f859b67582..4b01cd86da2c 100644
--- a/lldb/include/lldb/Utility/VMRange.h
+++ b/lldb/include/lldb/Utility/VMRange.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_VMRange_h_
-#define liblldb_VMRange_h_
+#ifndef LLDB_UTILITY_VMRANGE_H
+#define LLDB_UTILITY_VMRANGE_H
#include "lldb/lldb-types.h"
#include "llvm/Support/raw_ostream.h"
@@ -101,4 +101,4 @@ bool operator>=(const VMRange &lhs, const VMRange &rhs);
} // namespace lldb_private
-#endif // liblldb_VMRange_h_
+#endif // LLDB_UTILITY_VMRANGE_H
diff --git a/lldb/include/lldb/Utility/XcodeSDK.h b/lldb/include/lldb/Utility/XcodeSDK.h
new file mode 100644
index 000000000000..307fe7f46798
--- /dev/null
+++ b/lldb/include/lldb/Utility/XcodeSDK.h
@@ -0,0 +1,96 @@
+//===-- XcodeSDK.h ----------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_UTILITY_SDK_H
+#define LLDB_UTILITY_SDK_H
+
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/VersionTuple.h"
+#include <tuple>
+
+namespace llvm {
+class Triple;
+}
+
+namespace lldb_private {
+
+/// An abstraction for Xcode-style SDKs that works like \ref ArchSpec.
+class XcodeSDK {
+ std::string m_name;
+
+public:
+ /// Different types of Xcode SDKs.
+ enum Type : int {
+ MacOSX = 0,
+ iPhoneSimulator,
+ iPhoneOS,
+ AppleTVSimulator,
+ AppleTVOS,
+ WatchSimulator,
+ watchOS,
+ bridgeOS,
+ Linux,
+ unknown = -1
+ };
+ static constexpr int numSDKTypes = Linux + 1;
+
+ /// A parsed SDK directory name.
+ struct Info {
+ Type type = unknown;
+ llvm::VersionTuple version;
+ bool internal = false;
+
+ Info() = default;
+ bool operator<(const Info &other) const;
+ bool operator==(const Info &other) const;
+ };
+
+
+ /// Default constructor, constructs an empty string.
+ XcodeSDK() = default;
+ /// Construct an XcodeSDK object from a specification.
+ XcodeSDK(Info info);
+ /// Initialize an XcodeSDK object with an SDK name. The SDK name is the last
+ /// directory component of a path one would pass to clang's -isysroot
+ /// parameter. For example, "MacOSX.10.14.sdk".
+ XcodeSDK(std::string &&name) : m_name(std::move(name)) {}
+ static XcodeSDK GetAnyMacOS() { return XcodeSDK("MacOSX.sdk"); }
+
+ /// The merge function follows a strict order to maintain monotonicity:
+ /// 1. SDK with the higher SDKType wins.
+ /// 2. The newer SDK wins.
+ void Merge(XcodeSDK other);
+
+ XcodeSDK &operator=(XcodeSDK other);
+ XcodeSDK(const XcodeSDK&) = default;
+ bool operator==(XcodeSDK other);
+
+ /// Return parsed SDK type and version number.
+ Info Parse() const;
+ bool IsAppleInternalSDK() const;
+ llvm::VersionTuple GetVersion() const;
+ Type GetType() const;
+ llvm::StringRef GetString() const;
+ /// Whether this Xcode SDK supports Swift.
+ bool SupportsSwift() const;
+
+ /// Whether LLDB feels confident importing Clang modules from this SDK.
+ static bool SDKSupportsModules(Type type, llvm::VersionTuple version);
+ static bool SDKSupportsModules(Type desired_type, const FileSpec &sdk_path);
+ /// Return the canonical SDK name, such as "macosx" for the macOS SDK.
+ static std::string GetCanonicalName(Info info);
+ /// Return the best-matching SDK type for a specific triple.
+ static XcodeSDK::Type GetSDKTypeForTriple(const llvm::Triple &triple);
+
+ static std::string FindXcodeContentsDirectoryInPath(llvm::StringRef path);
+};
+
+} // namespace lldb_private
+
+#endif
diff --git a/lldb/include/lldb/lldb-defines.h b/lldb/include/lldb/lldb-defines.h
index b87964403f7e..fea8079779a1 100644
--- a/lldb/include/lldb/lldb-defines.h
+++ b/lldb/include/lldb/lldb-defines.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_lldb_defines_h_
-#define LLDB_lldb_defines_h_
+#ifndef LLDB_LLDB_DEFINES_H
+#define LLDB_LLDB_DEFINES_H
#include "lldb/lldb-types.h"
@@ -133,15 +133,4 @@
#define UNUSED_IF_ASSERT_DISABLED(x) ((void)(x))
-#if defined(__cplusplus)
-
-/// \def DISALLOW_COPY_AND_ASSIGN(TypeName)
-/// Macro definition for easily disallowing copy constructor and
-/// assignment operators in C++ classes.
-#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
- TypeName(const TypeName &) = delete; \
- const TypeName &operator=(const TypeName &) = delete
-
-#endif // #if defined(__cplusplus)
-
-#endif // LLDB_lldb_defines_h_
+#endif // LLDB_LLDB_DEFINES_H
diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h
index 8cbb459ee1ea..b3e8d604913f 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_lldb_enumerations_h_
-#define LLDB_lldb_enumerations_h_
+#ifndef LLDB_LLDB_ENUMERATIONS_H
+#define LLDB_LLDB_ENUMERATIONS_H
#include <type_traits>
@@ -269,7 +269,8 @@ enum ExpressionResults {
eExpressionHitBreakpoint,
eExpressionTimedOut,
eExpressionResultUnavailable,
- eExpressionStoppedForDebug
+ eExpressionStoppedForDebug,
+ eExpressionThreadVanished
};
enum SearchDepth {
@@ -590,6 +591,7 @@ enum CommandArgumentType {
eArgTypeWatchType,
eArgRawInput,
eArgTypeCommand,
+ eArgTypeColumnNum,
eArgTypeLastArg // Always keep this entry as the last entry in this
// enumeration!!
};
@@ -694,6 +696,7 @@ enum SectionType {
eSectionTypeDWARFDebugRngListsDwo,
eSectionTypeDWARFDebugLocDwo,
eSectionTypeDWARFDebugLocListsDwo,
+ eSectionTypeDWARFDebugTuIndex,
};
FLAGS_ENUM(EmulateInstructionOptions){
@@ -1079,6 +1082,20 @@ enum TypeSummaryCapping {
eTypeSummaryCapped = true,
eTypeSummaryUncapped = false
};
+
+/// The result from a command interpreter run.
+enum CommandInterpreterResult {
+ /// Command interpreter finished successfully.
+ eCommandInterpreterResultSuccess,
+ /// Stopped because the corresponding option was set and the inferior
+ /// crashed.
+ eCommandInterpreterResultInferiorCrash,
+ /// Stopped because the corresponding option was set and a command returned
+ /// an error.
+ eCommandInterpreterResultCommandError,
+ /// Stopped because quit was requested.
+ eCommandInterpreterResultQuitRequested,
+};
} // namespace lldb
-#endif // LLDB_lldb_enumerations_h_
+#endif // LLDB_LLDB_ENUMERATIONS_H
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index d2371f94f4b8..4fd2a07dd616 100644
--- a/lldb/include/lldb/lldb-forward.h
+++ b/lldb/include/lldb/lldb-forward.h
@@ -6,25 +6,26 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_lldb_forward_h_
-#define LLDB_lldb_forward_h_
+#ifndef LLDB_LLDB_FORWARD_H
+#define LLDB_LLDB_FORWARD_H
#if defined(__cplusplus)
-#include "lldb/Utility/SharingPtr.h"
+#include <memory>
// lldb forward declarations
namespace lldb_private {
class ABI;
+class ASTResultSynthesizer;
+class ASTStructExtractor;
class Address;
class AddressRange;
class AddressResolver;
class ArchSpec;
-class ArmUnwindInfo;
+class Architecture;
class Args;
-class ASTResultSynthesizer;
-class ASTStructExtractor;
+class ArmUnwindInfo;
class Baton;
class Block;
class Breakpoint;
@@ -44,16 +45,8 @@ class BreakpointSiteList;
class BroadcastEventSpec;
class Broadcaster;
class BroadcasterManager;
+class CXXSyntheticChildren;
class CallFrameInfo;
-class ClangASTContext;
-class ClangASTImporter;
-class ClangASTMetadata;
-class ClangASTSource;
-class ClangExpressionDeclMap;
-class ClangExpressionParser;
-class ClangExpressionVariable;
-class ClangModulesDeclVendor;
-class ClangPersistentVariables;
class CommandInterpreter;
class CommandInterpreterRunOptions;
class CommandObject;
@@ -61,15 +54,13 @@ class CommandObjectMultiword;
class CommandReturnObject;
class Communication;
class CompactUnwindInfo;
-struct CompilerContext;
+class CompileUnit;
class CompilerDecl;
class CompilerDeclContext;
class CompilerType;
-class CompileUnit;
class Connection;
class ConnectionFileDescriptor;
class ConstString;
-class CXXSyntheticChildren;
class DWARFCallFrameInfo;
class DWARFDataExtractor;
class DWARFExpression;
@@ -85,7 +76,7 @@ class DynamicCheckerFunctions;
class DynamicLoader;
class Editline;
class EmulateInstruction;
-class Status;
+class Environment;
class EvaluateExpressionOptions;
class Event;
class EventData;
@@ -94,26 +85,26 @@ class ExecutionContext;
class ExecutionContextRef;
class ExecutionContextScope;
class Expression;
+class ExpressionTypeSystemHelper;
class ExpressionVariable;
class ExpressionVariableList;
-class ExpressionTypeSystemHelper;
class File;
class FileSpec;
class FileSpecList;
class Flags;
-class TypeCategoryImpl;
class FormatManager;
class FormattersMatchCandidate;
class FuncUnwinders;
class Function;
+class FunctionCaller;
class FunctionInfo;
+class IOHandler;
+class IOObject;
+class IRExecutionUnit;
class InlineFunctionInfo;
class Instruction;
class InstructionList;
class InstrumentationRuntime;
-class IOHandler;
-class IOObject;
-class IRExecutionUnit;
class JITLoader;
class JITLoaderList;
class Language;
@@ -131,15 +122,13 @@ class Module;
class ModuleList;
class ModuleSpec;
class ModuleSpecList;
-struct NameSearchContext;
class ObjectContainer;
-class OptionGroup;
-class OptionGroupOptions;
-class OptionGroupPlatform;
class ObjectFile;
class ObjectFileJITDelegate;
class OperatingSystem;
-class Options;
+class OptionGroup;
+class OptionGroupOptions;
+class OptionGroupPlatform;
class OptionValue;
class OptionValueArch;
class OptionValueArgs;
@@ -151,8 +140,8 @@ class OptionValueEnumeration;
class OptionValueFileSpec;
class OptionValueFileSpecList;
class OptionValueFormat;
-class OptionValueLanguage;
class OptionValueFormatEntity;
+class OptionValueLanguage;
class OptionValuePathMappings;
class OptionValueProperties;
class OptionValueRegex;
@@ -160,31 +149,32 @@ class OptionValueSInt64;
class OptionValueString;
class OptionValueUInt64;
class OptionValueUUID;
+class Options;
class PathMappingList;
-class FunctionCaller;
class PersistentExpressionState;
class Platform;
class Process;
class ProcessAttachInfo;
-class ProcessModID;
class ProcessInfo;
class ProcessInstanceInfo;
-class ProcessInstanceInfoList;
class ProcessInstanceInfoMatch;
class ProcessLaunchInfo;
+class ProcessModID;
class Property;
-struct PropertyDefinition;
+class Queue;
+class QueueImpl;
+class QueueItem;
+class REPL;
class RecognizedStackFrame;
class RegisterCheckpoint;
class RegisterContext;
class RegisterValue;
class RegularExpression;
-class REPL;
class RichManglingContext;
class Scalar;
class ScriptInterpreter;
class ScriptInterpreterLocker;
-struct ScriptSummaryFormat;
+class ScriptedSyntheticChildren;
class SearchFilter;
class Section;
class SectionList;
@@ -198,21 +188,17 @@ class StackFrameList;
class StackFrameRecognizer;
class StackFrameRecognizerManager;
class StackID;
+class Status;
class StopInfo;
class Stoppoint;
class StoppointCallbackContext;
class StoppointLocation;
class Stream;
-template <unsigned N> class StreamBuffer;
class StreamFile;
class StreamString;
class StringList;
-struct StringSummaryFormat;
class StructuredDataImpl;
class StructuredDataPlugin;
-class SystemRuntime;
-class TypeSummaryImpl;
-class TypeSummaryOptions;
class Symbol;
class SymbolContext;
class SymbolContextList;
@@ -224,12 +210,7 @@ class SymbolVendor;
class Symtab;
class SyntheticChildren;
class SyntheticChildrenFrontEnd;
-class TypeFilterImpl;
-class TypeSystem;
-class ScriptedSyntheticChildren;
-class Queue;
-class QueueItem;
-class QueueImpl;
+class SystemRuntime;
class Target;
class TargetList;
class TargetProperties;
@@ -249,17 +230,22 @@ class ThreadSpec;
class TraceOptions;
class Type;
class TypeAndOrName;
+class TypeCategoryImpl;
class TypeCategoryMap;
+class TypeEnumMemberImpl;
+class TypeEnumMemberListImpl;
+class TypeFilterImpl;
+class TypeFormatImpl;
class TypeImpl;
class TypeList;
-class TypeMap;
class TypeListImpl;
-class TypeMemberImpl;
+class TypeMap;
class TypeMemberFunctionImpl;
-class TypeEnumMemberImpl;
-class TypeEnumMemberListImpl;
-class TypeFormatImpl;
+class TypeMemberImpl;
class TypeNameSpecifierImpl;
+class TypeSummaryImpl;
+class TypeSummaryOptions;
+class TypeSystem;
class UUID;
class UnixSignals;
class Unwind;
@@ -283,7 +269,12 @@ class VariableList;
class Watchpoint;
class WatchpointList;
class WatchpointOptions;
+struct CompilerContext;
struct LineEntry;
+struct PropertyDefinition;
+struct ScriptSummaryFormat;
+struct StringSummaryFormat;
+template <unsigned N> class StreamBuffer;
} // namespace lldb_private
@@ -299,17 +290,12 @@ typedef std::shared_ptr<lldb_private::BreakpointSite> BreakpointSiteSP;
typedef std::weak_ptr<lldb_private::BreakpointSite> BreakpointSiteWP;
typedef std::shared_ptr<lldb_private::BreakpointLocation> BreakpointLocationSP;
typedef std::weak_ptr<lldb_private::BreakpointLocation> BreakpointLocationWP;
-typedef std::shared_ptr<lldb_private::BreakpointPrecondition> BreakpointPreconditionSP;
+typedef std::shared_ptr<lldb_private::BreakpointPrecondition>
+ BreakpointPreconditionSP;
typedef std::shared_ptr<lldb_private::BreakpointResolver> BreakpointResolverSP;
typedef std::shared_ptr<lldb_private::Broadcaster> BroadcasterSP;
typedef std::shared_ptr<lldb_private::BroadcasterManager> BroadcasterManagerSP;
typedef std::weak_ptr<lldb_private::BroadcasterManager> BroadcasterManagerWP;
-typedef std::unique_ptr<lldb_private::ClangASTContext> ClangASTContextUP;
-typedef std::shared_ptr<lldb_private::ClangASTImporter> ClangASTImporterSP;
-typedef std::unique_ptr<lldb_private::ClangModulesDeclVendor>
- ClangModulesDeclVendorUP;
-typedef std::unique_ptr<lldb_private::ClangPersistentVariables>
- ClangPersistentVariablesUP;
typedef std::shared_ptr<lldb_private::UserExpression> UserExpressionSP;
typedef std::shared_ptr<lldb_private::CommandObject> CommandObjectSP;
typedef std::shared_ptr<lldb_private::Communication> CommunicationSP;
@@ -467,7 +453,7 @@ 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::ValueObject> ValueObjectSP;
typedef std::shared_ptr<lldb_private::Value> ValueSP;
typedef std::shared_ptr<lldb_private::ValueList> ValueListSP;
typedef std::shared_ptr<lldb_private::Variable> VariableSP;
@@ -477,13 +463,5 @@ typedef std::shared_ptr<lldb_private::Watchpoint> WatchpointSP;
} // namespace lldb
-// llvm forward declarations
-namespace llvm {
-
-struct ItaniumPartialDemangler;
-class StringRef;
-
-} // namespace llvm
-
#endif // #if defined(__cplusplus)
-#endif // LLDB_lldb_forward_h_
+#endif // LLDB_LLDB_FORWARD_H
diff --git a/lldb/include/lldb/lldb-private-defines.h b/lldb/include/lldb/lldb-private-defines.h
index 737d9ef2434e..d66e6ef1518d 100644
--- a/lldb/include/lldb/lldb-private-defines.h
+++ b/lldb/include/lldb/lldb-private-defines.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_lldb_private_defines_h_
-#define liblldb_lldb_private_defines_h_
+#ifndef LLDB_LLDB_PRIVATE_DEFINES_H
+#define LLDB_LLDB_PRIVATE_DEFINES_H
#if defined(__cplusplus)
@@ -33,4 +33,4 @@
#endif // #if defined(__cplusplus)
-#endif // liblldb_lldb_private_defines_h_
+#endif // LLDB_LLDB_PRIVATE_DEFINES_H
diff --git a/lldb/include/lldb/lldb-private-enumerations.h b/lldb/include/lldb/lldb-private-enumerations.h
index 9b7879c05f9e..7009d1b4fba7 100644
--- a/lldb/include/lldb/lldb-private-enumerations.h
+++ b/lldb/include/lldb/lldb-private-enumerations.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_lldb_private_enumerations_h_
-#define LLDB_lldb_private_enumerations_h_
+#ifndef LLDB_LLDB_PRIVATE_ENUMERATIONS_H
+#define LLDB_LLDB_PRIVATE_ENUMERATIONS_H
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FormatProviders.h"
@@ -148,18 +148,6 @@ enum ExecutionPolicy {
eExecutionPolicyTopLevel // used for top-level code
};
-// Ways that the FormatManager picks a particular format for a type
-enum FormatterChoiceCriterion {
- eFormatterChoiceCriterionDirectChoice = 0x00000000,
- eFormatterChoiceCriterionStrippedPointerReference = 0x00000001,
- eFormatterChoiceCriterionNavigatedTypedefs = 0x00000002,
- eFormatterChoiceCriterionRegularExpressionSummary = 0x00000004,
- eFormatterChoiceCriterionRegularExpressionFilter = 0x00000004,
- eFormatterChoiceCriterionLanguagePlugin = 0x00000008,
- eFormatterChoiceCriterionStrippedBitField = 0x00000010,
- eFormatterChoiceCriterionWentToStaticValue = 0x00000020
-};
-
// Synchronicity behavior of scripted commands
enum ScriptedCommandSynchronicity {
eScriptedCommandSynchronicitySynchronous,
@@ -267,4 +255,4 @@ template <> struct format_provider<lldb_private::Vote> {
};
}
-#endif // LLDB_lldb_private_enumerations_h_
+#endif // LLDB_LLDB_PRIVATE_ENUMERATIONS_H
diff --git a/lldb/include/lldb/lldb-private-forward.h b/lldb/include/lldb/lldb-private-forward.h
index 330070745adb..b5944cba8f27 100644
--- a/lldb/include/lldb/lldb-private-forward.h
+++ b/lldb/include/lldb/lldb-private-forward.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_lldb_private_forward_h_
-#define LLDB_lldb_private_forward_h_
+#ifndef LLDB_LLDB_PRIVATE_FORWARD_H
+#define LLDB_LLDB_PRIVATE_FORWARD_H
namespace lldb_private {
// forward decls.
@@ -18,4 +18,4 @@ class ResumeActionList;
class UnixSignals;
}
-#endif // #ifndef LLDB_lldb_private_forward_h_
+#endif // LLDB_LLDB_PRIVATE_FORWARD_H
diff --git a/lldb/include/lldb/lldb-private-interfaces.h b/lldb/include/lldb/lldb-private-interfaces.h
index 27a2c4c3f27f..1568e7a3cb51 100644
--- a/lldb/include/lldb/lldb-private-interfaces.h
+++ b/lldb/include/lldb/lldb-private-interfaces.h
@@ -6,21 +6,23 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_lldb_private_interfaces_h_
-#define liblldb_lldb_private_interfaces_h_
+#ifndef LLDB_LLDB_PRIVATE_INTERFACES_H
+#define LLDB_LLDB_PRIVATE_INTERFACES_H
#if defined(__cplusplus)
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
-#include "lldb/lldb-types.h"
-
#include "lldb/lldb-private-enumerations.h"
-
+#include "lldb/lldb-types.h"
+#include <memory>
#include <set>
namespace lldb_private {
-typedef lldb::ABISP (*ABICreateInstance)(lldb::ProcessSP process_sp, const ArchSpec &arch);
+typedef lldb::ABISP (*ABICreateInstance)(lldb::ProcessSP process_sp,
+ const ArchSpec &arch);
+typedef std::unique_ptr<Architecture> (*ArchitectureCreateInstance)(
+ const ArchSpec &arch);
typedef Disassembler *(*DisassemblerCreateInstance)(const ArchSpec &arch,
const char *flavor);
typedef DynamicLoader *(*DynamicLoaderCreateInstance)(Process *process,
@@ -107,4 +109,4 @@ typedef void (*DebuggerInitializeCallback)(Debugger &debugger);
#endif // #if defined(__cplusplus)
-#endif // liblldb_lldb_private_interfaces_h_
+#endif // LLDB_LLDB_PRIVATE_INTERFACES_H
diff --git a/lldb/include/lldb/lldb-private-types.h b/lldb/include/lldb/lldb-private-types.h
index bff471177214..fb8c2db2e21c 100644
--- a/lldb/include/lldb/lldb-private-types.h
+++ b/lldb/include/lldb/lldb-private-types.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_lldb_private_types_h_
-#define liblldb_lldb_private_types_h_
+#ifndef LLDB_LLDB_PRIVATE_TYPES_H
+#define LLDB_LLDB_PRIVATE_TYPES_H
#if defined(__cplusplus)
@@ -28,38 +28,42 @@ class ExecutionContext;
typedef llvm::sys::DynamicLibrary (*LoadPluginCallbackType)(
const lldb::DebuggerSP &debugger_sp, const FileSpec &spec, Status &error);
-// Every register is described in detail including its name, alternate name
-// (optional), encoding, size in bytes and the default display format.
+/// Every register is described in detail including its name, alternate name
+/// (optional), encoding, size in bytes and the default display format.
struct RegisterInfo {
- const char *name; // Name of this register, can't be NULL
- const char *alt_name; // Alternate name of this register, can be NULL
- uint32_t byte_size; // Size in bytes of the register
- uint32_t byte_offset; // The byte offset in the register context data where
- // this register's value is found.
- // This is optional, and can be 0 if a particular RegisterContext does not
- // need to address its registers by byte offset.
- lldb::Encoding encoding; // Encoding of the register bits
- lldb::Format format; // Default display format
- uint32_t kinds[lldb::kNumRegisterKinds]; // Holds all of the various register
- // numbers for all register kinds
- uint32_t *value_regs; // List of registers (terminated with
- // LLDB_INVALID_REGNUM). If this value is not null,
- // all registers in this list will be read first, at
- // which point the value for this register will be
- // valid. For example, the value list for ah would be
- // eax (x86) or rax (x64).
- uint32_t *invalidate_regs; // List of registers (terminated with
- // LLDB_INVALID_REGNUM). If this value is not
- // null, all registers in this list will be
- // invalidated when the value of this register
- // changes. For example, the invalidate list for
- // eax would be rax ax, ah, and al.
- const uint8_t *dynamic_size_dwarf_expr_bytes; // A DWARF expression that when
- // evaluated gives
- // the byte size of this register.
- size_t dynamic_size_dwarf_len; // The length of the DWARF expression in bytes
- // in the dynamic_size_dwarf_expr_bytes
- // member.
+ /// Name of this register, can't be NULL.
+ const char *name;
+ /// Alternate name of this register, can be NULL.
+ const char *alt_name;
+ /// Size in bytes of the register.
+ uint32_t byte_size;
+ /// The byte offset in the register context data where this register's
+ /// value is found.
+ /// This is optional, and can be 0 if a particular RegisterContext does not
+ /// need to address its registers by byte offset.
+ uint32_t byte_offset;
+ /// Encoding of the register bits.
+ lldb::Encoding encoding;
+ /// Default display format.
+ lldb::Format format;
+ /// Holds all of the various register numbers for all register kinds.
+ uint32_t kinds[lldb::kNumRegisterKinds]; //
+ /// List of registers (terminated with LLDB_INVALID_REGNUM). If this value is
+ /// not null, all registers in this list will be read first, at which point
+ /// the value for this register will be valid. For example, the value list
+ /// for ah would be eax (x86) or rax (x64).
+ uint32_t *value_regs; //
+ /// List of registers (terminated with LLDB_INVALID_REGNUM). If this value is
+ /// not null, all registers in this list will be invalidated when the value of
+ /// this register changes. For example, the invalidate list for eax would be
+ /// rax ax, ah, and al.
+ uint32_t *invalidate_regs;
+ /// A DWARF expression that when evaluated gives the byte size of this
+ /// register.
+ const uint8_t *dynamic_size_dwarf_expr_bytes;
+ /// The length of the DWARF expression in bytes in the
+ /// dynamic_size_dwarf_expr_bytes member.
+ size_t dynamic_size_dwarf_len;
llvm::ArrayRef<uint8_t> data(const uint8_t *context_base) const {
return llvm::ArrayRef<uint8_t>(context_base + byte_offset, byte_size);
@@ -71,17 +75,20 @@ struct RegisterInfo {
}
};
-// Registers are grouped into register sets
+/// Registers are grouped into register sets
struct RegisterSet {
- const char *name; // Name of this register set
- const char *short_name; // A short name for this register set
- size_t num_registers; // The number of registers in REGISTERS array below
- const uint32_t *registers; // An array of register indices in this set. The
- // values in this array are
- // *indices* (not register numbers) into a particular RegisterContext's
- // register array. For example, if eax is defined at index 4 for a
- // particular RegisterContext, eax would be included in this RegisterSet by
- // adding the value 4. Not by adding the value lldb_eax_i386.
+ /// Name of this register set.
+ const char *name;
+ /// A short name for this register set.
+ const char *short_name;
+ /// The number of registers in REGISTERS array below.
+ size_t num_registers;
+ /// An array of register indices in this set. The values in this array are
+ /// *indices* (not register numbers) into a particular RegisterContext's
+ /// register array. For example, if eax is defined at index 4 for a
+ /// particular RegisterContext, eax would be included in this RegisterSet by
+ /// adding the value 4. Not by adding the value lldb_eax_i386.
+ const uint32_t *registers;
};
struct OptionEnumValueElement {
@@ -101,22 +108,30 @@ struct OptionValidator {
};
struct OptionDefinition {
- uint32_t usage_mask; // Used to mark options that can be used together. If (1
- // << n & usage_mask) != 0
- // then this option belongs to option set n.
- bool required; // This option is required (in the current usage level)
- const char *long_option; // Full name for this option.
- int short_option; // Single character for this option.
- int option_has_arg; // no_argument, required_argument or optional_argument
- OptionValidator *validator; // If non-NULL, option is valid iff
- // |validator->IsValid()|, otherwise always valid.
- OptionEnumValues enum_values; // If not empty, an array of enum values.
- uint32_t completion_type; // Cookie the option class can use to do define the
- // argument completion.
- lldb::CommandArgumentType argument_type; // Type of argument this option takes
- const char *usage_text; // Full text explaining what this options does and
- // what (if any) argument to
- // pass it.
+ /// Used to mark options that can be used together. If
+ /// `(1 << n & usage_mask) != 0` then this option belongs to option set n.
+ uint32_t usage_mask;
+ /// This option is required (in the current usage level).
+ bool required;
+ /// Full name for this option.
+ const char *long_option;
+ /// Single character for this option.
+ int short_option;
+ /// no_argument, required_argument or optional_argument
+ int option_has_arg;
+ /// If non-NULL, option is valid iff |validator->IsValid()|, otherwise
+ /// always valid.
+ OptionValidator *validator;
+ /// If not empty, an array of enum values.
+ OptionEnumValues enum_values;
+ /// The kind of completion for this option.
+ /// Contains values of the CommandCompletions::CommonCompletionTypes enum.
+ uint32_t completion_type;
+ /// Type of argument this option takes.
+ lldb::CommandArgumentType argument_type;
+ /// Full text explaining what this options does and what (if any) argument to
+ /// pass it.
+ const char *usage_text;
};
typedef struct type128 { uint64_t x[2]; } type128;
@@ -126,4 +141,4 @@ typedef struct type256 { uint64_t x[4]; } type256;
#endif // #if defined(__cplusplus)
-#endif // liblldb_lldb_private_types_h_
+#endif // LLDB_LLDB_PRIVATE_TYPES_H
diff --git a/lldb/include/lldb/lldb-private.h b/lldb/include/lldb/lldb-private.h
index 24954ad2a1f5..d65773aecd6d 100644
--- a/lldb/include/lldb/lldb-private.h
+++ b/lldb/include/lldb/lldb-private.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_lldb_private_h_
-#define lldb_lldb_private_h_
+#ifndef LLDB_LLDB_PRIVATE_H
+#define LLDB_LLDB_PRIVATE_H
#if defined(__cplusplus)
@@ -25,4 +25,4 @@ const char *GetVersion();
#endif // defined(__cplusplus)
-#endif // lldb_lldb_private_h_
+#endif // LLDB_LLDB_PRIVATE_H
diff --git a/lldb/include/lldb/lldb-public.h b/lldb/include/lldb/lldb-public.h
index 449062f832f6..840edc6603e4 100644
--- a/lldb/include/lldb/lldb-public.h
+++ b/lldb/include/lldb/lldb-public.h
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_lldb_h_
-#define LLDB_lldb_h_
+#ifndef LLDB_LLDB_PUBLIC_H
+#define LLDB_LLDB_PUBLIC_H
#include "lldb/lldb-defines.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
#include "lldb/lldb-types.h"
-#endif // LLDB_lldb_h_
+#endif // LLDB_LLDB_PUBLIC_H
diff --git a/lldb/include/lldb/lldb-types.h b/lldb/include/lldb/lldb-types.h
index 414a9f308052..c3e2f07acc45 100644
--- a/lldb/include/lldb/lldb-types.h
+++ b/lldb/include/lldb/lldb-types.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_lldb_types_h_
-#define LLDB_lldb_types_h_
+#ifndef LLDB_LLDB_TYPES_H
+#define LLDB_LLDB_TYPES_H
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
@@ -91,4 +91,4 @@ typedef void *opaque_compiler_type_t;
typedef uint64_t queue_id_t;
} // namespace lldb
-#endif // LLDB_lldb_types_h_
+#endif // LLDB_LLDB_TYPES_H
diff --git a/lldb/include/lldb/lldb-versioning.h b/lldb/include/lldb/lldb-versioning.h
index 702ebd19a3ee..d9a0e6bf2832 100644
--- a/lldb/include/lldb/lldb-versioning.h
+++ b/lldb/include/lldb/lldb-versioning.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_lldb_versioning_h_
-#define LLDB_lldb_versioning_h_
+#ifndef LLDB_LLDB_VERSIONING_H
+#define LLDB_LLDB_VERSIONING_H
// LLDB API version
#define LLDB_API_MAJOR_VERSION 1
@@ -1539,4 +1539,4 @@
// defined(LLDB_API_MINOR_VERSION_WANTED) && defined
// (LLDB_API_MAJOR_VERSION)
-#endif // LLDB_lldb_versioning_h_
+#endif // LLDB_LLDB_VERSIONING_H
diff --git a/lldb/include/lldb/module.modulemap b/lldb/include/lldb/module.modulemap
index e040df8f913b..7feea8ee99c3 100644
--- a/lldb/include/lldb/module.modulemap
+++ b/lldb/include/lldb/module.modulemap
@@ -49,12 +49,16 @@ module lldb_Host {
module SocketAddress { header "Host/SocketAddress.h" export * }
module Socket { header "Host/Socket.h" export * }
module StringConvert { textual header "Host/StringConvert.h" export * }
- module TaskPool { header "Host/TaskPool.h" export * }
module Terminal { header "Host/Terminal.h" export * }
module ThreadLauncher { header "Host/ThreadLauncher.h" export * }
module Time { header "Host/Time.h" export * }
module XML { header "Host/XML.h" export * }
+ module common {
+ umbrella "Host/common"
+ module * { export * }
+ }
+
export *
}
diff --git a/lldb/source/API/SBAddress.cpp b/lldb/source/API/SBAddress.cpp
index dcde25b77917..6444a006c0ff 100644
--- a/lldb/source/API/SBAddress.cpp
+++ b/lldb/source/API/SBAddress.cpp
@@ -1,4 +1,4 @@
-//===-- SBAddress.cpp -------------------------------------------*- C++ -*-===//
+//===-- SBAddress.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -52,7 +52,7 @@ SBAddress::SBAddress(lldb::addr_t load_addr, lldb::SBTarget &target)
SetLoadAddress(load_addr, target);
}
-SBAddress::~SBAddress() {}
+SBAddress::~SBAddress() = default;
const SBAddress &SBAddress::operator=(const SBAddress &rhs) {
LLDB_RECORD_METHOD(const lldb::SBAddress &,
@@ -89,7 +89,7 @@ SBAddress::operator bool() const {
void SBAddress::Clear() {
LLDB_RECORD_METHOD_NO_ARGS(void, SBAddress, Clear);
- m_opaque_up.reset(new Address());
+ m_opaque_up = std::make_unique<Address>();
}
void SBAddress::SetAddress(lldb::SBSection section, lldb::addr_t offset) {
@@ -105,7 +105,7 @@ void SBAddress::SetAddress(const Address *lldb_object_ptr) {
if (lldb_object_ptr)
ref() = *lldb_object_ptr;
else
- m_opaque_up.reset(new Address());
+ m_opaque_up = std::make_unique<Address>();
}
lldb::addr_t SBAddress::GetFileAddress() const {
@@ -187,7 +187,7 @@ const Address *SBAddress::operator->() const { return m_opaque_up.get(); }
Address &SBAddress::ref() {
if (m_opaque_up == nullptr)
- m_opaque_up.reset(new Address());
+ m_opaque_up = std::make_unique<Address>();
return *m_opaque_up;
}
diff --git a/lldb/source/API/SBAttachInfo.cpp b/lldb/source/API/SBAttachInfo.cpp
index 838385c104ae..b21589cf2708 100644
--- a/lldb/source/API/SBAttachInfo.cpp
+++ b/lldb/source/API/SBAttachInfo.cpp
@@ -1,4 +1,4 @@
-//===-- SBAttachInfo.cpp ----------------------------------------*- C++ -*-===//
+//===-- SBAttachInfo.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -54,7 +54,7 @@ SBAttachInfo::SBAttachInfo(const SBAttachInfo &rhs)
m_opaque_sp = clone(rhs.m_opaque_sp);
}
-SBAttachInfo::~SBAttachInfo() {}
+SBAttachInfo::~SBAttachInfo() = default;
lldb_private::ProcessAttachInfo &SBAttachInfo::ref() { return *m_opaque_sp; }
diff --git a/lldb/source/API/SBBlock.cpp b/lldb/source/API/SBBlock.cpp
index f333d1d7b5f3..a5fee445d5c6 100644
--- a/lldb/source/API/SBBlock.cpp
+++ b/lldb/source/API/SBBlock.cpp
@@ -1,4 +1,4 @@
-//===-- SBBlock.cpp ---------------------------------------------*- C++ -*-===//
+//===-- SBBlock.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -71,13 +71,7 @@ const char *SBBlock::GetInlinedName() const {
const InlineFunctionInfo *inlined_info =
m_opaque_ptr->GetInlinedFunctionInfo();
if (inlined_info) {
- Function *function = m_opaque_ptr->CalculateSymbolContextFunction();
- LanguageType language;
- if (function)
- language = function->GetLanguage();
- else
- language = lldb::eLanguageTypeUnknown;
- return inlined_info->GetName(language).AsCString(nullptr);
+ return inlined_info->GetName().AsCString(nullptr);
}
}
return nullptr;
diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp
index 8159b851d58c..eb75bf8b33f4 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -1,4 +1,4 @@
-//===-- SBBreakpoint.cpp ----------------------------------------*- C++ -*-===//
+//===-- SBBreakpoint.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -652,19 +652,28 @@ SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) {
bool SBBreakpoint::AddName(const char *new_name) {
LLDB_RECORD_METHOD(bool, SBBreakpoint, AddName, (const char *), new_name);
+ SBError status = AddNameWithErrorHandling(new_name);
+ return status.Success();
+}
+
+SBError SBBreakpoint::AddNameWithErrorHandling(const char *new_name) {
+ LLDB_RECORD_METHOD(SBError, SBBreakpoint, AddNameWithErrorHandling,
+ (const char *), new_name);
+
BreakpointSP bkpt_sp = GetSP();
+ SBError status;
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
bkpt_sp->GetTarget().GetAPIMutex());
- Status error; // Think I'm just going to swallow the error here, it's
- // probably more annoying to have to provide it.
+ Status error;
bkpt_sp->GetTarget().AddNameToBreakpoint(bkpt_sp, new_name, error);
- if (error.Fail())
- return false;
+ status.SetError(error);
+ } else {
+ status.SetErrorString("invalid breakpoint");
}
- return true;
+ return LLDB_RECORD_RESULT(status);
}
void SBBreakpoint::RemoveName(const char *name_to_remove) {
@@ -873,7 +882,7 @@ SBBreakpointList::SBBreakpointList(SBTarget &target)
LLDB_RECORD_CONSTRUCTOR(SBBreakpointList, (lldb::SBTarget &), target);
}
-SBBreakpointList::~SBBreakpointList() {}
+SBBreakpointList::~SBBreakpointList() = default;
size_t SBBreakpointList::GetSize() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBBreakpointList, GetSize);
@@ -1015,6 +1024,8 @@ void RegisterMethods<SBBreakpoint>(Registry &R) {
LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, SetScriptCallbackBody,
(const char *));
LLDB_REGISTER_METHOD(bool, SBBreakpoint, AddName, (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, AddNameWithErrorHandling,
+ (const char *));
LLDB_REGISTER_METHOD(void, SBBreakpoint, RemoveName, (const char *));
LLDB_REGISTER_METHOD(bool, SBBreakpoint, MatchesName, (const char *));
LLDB_REGISTER_METHOD(void, SBBreakpoint, GetNames, (lldb::SBStringList &));
diff --git a/lldb/source/API/SBBreakpointLocation.cpp b/lldb/source/API/SBBreakpointLocation.cpp
index 2b62a69a21ef..e29f3fd9c50e 100644
--- a/lldb/source/API/SBBreakpointLocation.cpp
+++ b/lldb/source/API/SBBreakpointLocation.cpp
@@ -1,4 +1,4 @@
-//===-- SBBreakpointLocation.cpp --------------------------------*- C++ -*-===//
+//===-- SBBreakpointLocation.cpp ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -59,7 +59,7 @@ operator=(const SBBreakpointLocation &rhs) {
return LLDB_RECORD_RESULT(*this);
}
-SBBreakpointLocation::~SBBreakpointLocation() {}
+SBBreakpointLocation::~SBBreakpointLocation() = default;
BreakpointLocationSP SBBreakpointLocation::GetSP() const {
return m_opaque_wp.lock();
diff --git a/lldb/source/API/SBBreakpointName.cpp b/lldb/source/API/SBBreakpointName.cpp
index 5bd7732ebb60..3995defcf97c 100644
--- a/lldb/source/API/SBBreakpointName.cpp
+++ b/lldb/source/API/SBBreakpointName.cpp
@@ -1,4 +1,4 @@
-//===-- SBBreakpointName.cpp ----------------------------------------*- C++ -*-===//
+//===-- SBBreakpointName.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -115,7 +115,7 @@ SBBreakpointName::SBBreakpointName(SBTarget &sb_target, const char *name) {
LLDB_RECORD_CONSTRUCTOR(SBBreakpointName, (lldb::SBTarget &, const char *),
sb_target, name);
- m_impl_up.reset(new SBBreakpointNameImpl(sb_target, name));
+ m_impl_up = std::make_unique<SBBreakpointNameImpl>(sb_target, name);
// Call FindBreakpointName here to make sure the name is valid, reset if not:
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
@@ -133,7 +133,8 @@ SBBreakpointName::SBBreakpointName(SBBreakpoint &sb_bkpt, const char *name) {
BreakpointSP bkpt_sp = sb_bkpt.GetSP();
Target &target = bkpt_sp->GetTarget();
- m_impl_up.reset(new SBBreakpointNameImpl(target.shared_from_this(), name));
+ m_impl_up =
+ std::make_unique<SBBreakpointNameImpl>(target.shared_from_this(), name);
// Call FindBreakpointName here to make sure the name is valid, reset if not:
BreakpointName *bp_name = GetBreakpointName();
@@ -154,8 +155,8 @@ SBBreakpointName::SBBreakpointName(const SBBreakpointName &rhs) {
if (!rhs.m_impl_up)
return;
else
- m_impl_up.reset(new SBBreakpointNameImpl(rhs.m_impl_up->GetTarget(),
- rhs.m_impl_up->GetName()));
+ m_impl_up = std::make_unique<SBBreakpointNameImpl>(
+ rhs.m_impl_up->GetTarget(), rhs.m_impl_up->GetName());
}
SBBreakpointName::~SBBreakpointName() = default;
@@ -171,8 +172,8 @@ operator=(const SBBreakpointName &rhs) {
return LLDB_RECORD_RESULT(*this);
}
- m_impl_up.reset(new SBBreakpointNameImpl(rhs.m_impl_up->GetTarget(),
- rhs.m_impl_up->GetName()));
+ m_impl_up = std::make_unique<SBBreakpointNameImpl>(rhs.m_impl_up->GetTarget(),
+ rhs.m_impl_up->GetName());
return LLDB_RECORD_RESULT(*this);
}
diff --git a/lldb/source/API/SBBreakpointOptionCommon.cpp b/lldb/source/API/SBBreakpointOptionCommon.cpp
index 870b4b941ada..2ee47ff7795c 100644
--- a/lldb/source/API/SBBreakpointOptionCommon.cpp
+++ b/lldb/source/API/SBBreakpointOptionCommon.cpp
@@ -1,4 +1,4 @@
-//===-- SBBreakpointOptionCommon.cpp --------------------------------*- C++ -*-===//
+//===-- SBBreakpointOptionCommon.cpp --------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/API/SBBreakpointOptionCommon.h b/lldb/source/API/SBBreakpointOptionCommon.h
index 52049e4e7588..0ceb90290de5 100644
--- a/lldb/source/API/SBBreakpointOptionCommon.h
+++ b/lldb/source/API/SBBreakpointOptionCommon.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SBBreakpointOptionCommons_h_
-#define LLDB_SBBreakpointOptionCommons_h_
+#ifndef LLDB_SOURCE_API_SBBREAKPOINTOPTIONCOMMON_H
+#define LLDB_SOURCE_API_SBBREAKPOINTOPTIONCOMMON_H
#include "lldb/API/SBDefines.h"
#include "lldb/Utility/Baton.h"
@@ -33,4 +33,4 @@ public:
};
} // namespace lldb
-#endif // LLDB_SBBreakpointOptionCommons_h_
+#endif // LLDB_SOURCE_API_SBBREAKPOINTOPTIONCOMMON_H
diff --git a/lldb/source/API/SBBroadcaster.cpp b/lldb/source/API/SBBroadcaster.cpp
index e1efdf7baf61..d42d7ce2a536 100644
--- a/lldb/source/API/SBBroadcaster.cpp
+++ b/lldb/source/API/SBBroadcaster.cpp
@@ -1,4 +1,4 @@
-//===-- SBBroadcaster.cpp ---------------------------------------*- C++ -*-===//
+//===-- SBBroadcaster.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp
index 6e5ebe6a7ded..f4f19577b36c 100644
--- a/lldb/source/API/SBCommandInterpreter.cpp
+++ b/lldb/source/API/SBCommandInterpreter.cpp
@@ -1,4 +1,4 @@
-//===-- SBCommandInterpreter.cpp --------------------------------*- C++ -*-===//
+//===-- SBCommandInterpreter.cpp ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -17,6 +17,7 @@
#include "lldb/API/SBBroadcaster.h"
#include "lldb/API/SBCommandInterpreter.h"
+#include "lldb/API/SBCommandInterpreterRunOptions.h"
#include "lldb/API/SBCommandReturnObject.h"
#include "lldb/API/SBEvent.h"
#include "lldb/API/SBExecutionContext.h"
@@ -31,122 +32,6 @@
using namespace lldb;
using namespace lldb_private;
-SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions() {
- LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommandInterpreterRunOptions);
-
- m_opaque_up.reset(new CommandInterpreterRunOptions());
-}
-
-SBCommandInterpreterRunOptions::~SBCommandInterpreterRunOptions() = default;
-
-bool SBCommandInterpreterRunOptions::GetStopOnContinue() const {
- LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
- GetStopOnContinue);
-
- return m_opaque_up->GetStopOnContinue();
-}
-
-void SBCommandInterpreterRunOptions::SetStopOnContinue(bool stop_on_continue) {
- LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnContinue,
- (bool), stop_on_continue);
-
- m_opaque_up->SetStopOnContinue(stop_on_continue);
-}
-
-bool SBCommandInterpreterRunOptions::GetStopOnError() const {
- LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
- GetStopOnError);
-
- return m_opaque_up->GetStopOnError();
-}
-
-void SBCommandInterpreterRunOptions::SetStopOnError(bool stop_on_error) {
- LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnError,
- (bool), stop_on_error);
-
- m_opaque_up->SetStopOnError(stop_on_error);
-}
-
-bool SBCommandInterpreterRunOptions::GetStopOnCrash() const {
- LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
- GetStopOnCrash);
-
- return m_opaque_up->GetStopOnCrash();
-}
-
-void SBCommandInterpreterRunOptions::SetStopOnCrash(bool stop_on_crash) {
- LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnCrash,
- (bool), stop_on_crash);
-
- m_opaque_up->SetStopOnCrash(stop_on_crash);
-}
-
-bool SBCommandInterpreterRunOptions::GetEchoCommands() const {
- LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
- GetEchoCommands);
-
- return m_opaque_up->GetEchoCommands();
-}
-
-void SBCommandInterpreterRunOptions::SetEchoCommands(bool echo_commands) {
- LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetEchoCommands,
- (bool), echo_commands);
-
- m_opaque_up->SetEchoCommands(echo_commands);
-}
-
-bool SBCommandInterpreterRunOptions::GetEchoCommentCommands() const {
- LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
- GetEchoCommentCommands);
-
- return m_opaque_up->GetEchoCommentCommands();
-}
-
-void SBCommandInterpreterRunOptions::SetEchoCommentCommands(bool echo) {
- LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions,
- SetEchoCommentCommands, (bool), echo);
-
- m_opaque_up->SetEchoCommentCommands(echo);
-}
-
-bool SBCommandInterpreterRunOptions::GetPrintResults() const {
- LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
- GetPrintResults);
-
- return m_opaque_up->GetPrintResults();
-}
-
-void SBCommandInterpreterRunOptions::SetPrintResults(bool print_results) {
- LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetPrintResults,
- (bool), print_results);
-
- m_opaque_up->SetPrintResults(print_results);
-}
-
-bool SBCommandInterpreterRunOptions::GetAddToHistory() const {
- LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
- GetAddToHistory);
-
- return m_opaque_up->GetAddToHistory();
-}
-
-void SBCommandInterpreterRunOptions::SetAddToHistory(bool add_to_history) {
- LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetAddToHistory,
- (bool), add_to_history);
-
- m_opaque_up->SetAddToHistory(add_to_history);
-}
-
-lldb_private::CommandInterpreterRunOptions *
-SBCommandInterpreterRunOptions::get() const {
- return m_opaque_up.get();
-}
-
-lldb_private::CommandInterpreterRunOptions &
-SBCommandInterpreterRunOptions::ref() const {
- return *m_opaque_up;
-}
-
class CommandPluginInterfaceImplementation : public CommandObjectParsed {
public:
CommandPluginInterfaceImplementation(CommandInterpreter &interpreter,
@@ -154,22 +39,41 @@ public:
lldb::SBCommandPluginInterface *backend,
const char *help = nullptr,
const char *syntax = nullptr,
- uint32_t flags = 0)
+ uint32_t flags = 0,
+ const char *auto_repeat_command = "")
: CommandObjectParsed(interpreter, name, help, syntax, flags),
- m_backend(backend) {}
+ m_backend(backend) {
+ m_auto_repeat_command =
+ auto_repeat_command == nullptr
+ ? llvm::None
+ : llvm::Optional<std::string>(auto_repeat_command);
+ }
bool IsRemovable() const override { return true; }
+ /// More documentation is available in lldb::CommandObject::GetRepeatCommand,
+ /// but in short, if nullptr is returned, the previous command will be
+ /// repeated, and if an empty string is returned, no commands will be
+ /// executed.
+ const char *GetRepeatCommand(Args &current_command_args,
+ uint32_t index) override {
+ if (!m_auto_repeat_command)
+ return nullptr;
+ else
+ return m_auto_repeat_command->c_str();
+ }
+
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
SBCommandReturnObject sb_return(result);
SBCommandInterpreter sb_interpreter(&m_interpreter);
SBDebugger debugger_sb(m_interpreter.GetDebugger().shared_from_this());
bool ret = m_backend->DoExecute(
- debugger_sb, (char **)command.GetArgumentVector(), sb_return);
+ debugger_sb, command.GetArgumentVector(), sb_return);
return ret;
}
std::shared_ptr<lldb::SBCommandPluginInterface> m_backend;
+ llvm::Optional<std::string> m_auto_repeat_command;
};
SBCommandInterpreter::SBCommandInterpreter(CommandInterpreter *interpreter)
@@ -681,14 +585,8 @@ lldb::SBCommand SBCommandInterpreter::AddCommand(
(const char *, lldb::SBCommandPluginInterface *, const char *), name,
impl, help);
- lldb::CommandObjectSP new_command_sp;
- new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>(
- *m_opaque_ptr, name, impl, help);
-
- if (new_command_sp &&
- m_opaque_ptr->AddUserCommand(name, new_command_sp, true))
- return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp));
- return LLDB_RECORD_RESULT(lldb::SBCommand());
+ return LLDB_RECORD_RESULT(AddCommand(name, impl, help, /*syntax=*/nullptr,
+ /*auto_repeat_command=*/""))
}
lldb::SBCommand
@@ -699,10 +597,22 @@ SBCommandInterpreter::AddCommand(const char *name,
(const char *, lldb::SBCommandPluginInterface *,
const char *, const char *),
name, impl, help, syntax);
+ return LLDB_RECORD_RESULT(
+ AddCommand(name, impl, help, syntax, /*auto_repeat_command=*/""))
+}
+
+lldb::SBCommand SBCommandInterpreter::AddCommand(
+ const char *name, lldb::SBCommandPluginInterface *impl, const char *help,
+ const char *syntax, const char *auto_repeat_command) {
+ LLDB_RECORD_METHOD(lldb::SBCommand, SBCommandInterpreter, AddCommand,
+ (const char *, lldb::SBCommandPluginInterface *,
+ const char *, const char *, const char *),
+ name, impl, help, syntax, auto_repeat_command);
lldb::CommandObjectSP new_command_sp;
new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>(
- *m_opaque_ptr, name, impl, help, syntax);
+ *m_opaque_ptr, name, impl, help, syntax, /*flags=*/0,
+ auto_repeat_command);
if (new_command_sp &&
m_opaque_ptr->AddUserCommand(name, new_command_sp, true))
@@ -783,17 +693,8 @@ lldb::SBCommand SBCommand::AddCommand(const char *name,
lldb::SBCommand, SBCommand, AddCommand,
(const char *, lldb::SBCommandPluginInterface *, const char *), name,
impl, help);
-
- if (!IsValid())
- return LLDB_RECORD_RESULT(lldb::SBCommand());
- if (!m_opaque_sp->IsMultiwordObject())
- return LLDB_RECORD_RESULT(lldb::SBCommand());
- lldb::CommandObjectSP new_command_sp;
- new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>(
- m_opaque_sp->GetCommandInterpreter(), name, impl, help);
- if (new_command_sp && m_opaque_sp->LoadSubCommand(name, new_command_sp))
- return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp));
- return LLDB_RECORD_RESULT(lldb::SBCommand());
+ return LLDB_RECORD_RESULT(AddCommand(name, impl, help, /*syntax=*/nullptr,
+ /*auto_repeat_command=*/""))
}
lldb::SBCommand SBCommand::AddCommand(const char *name,
@@ -803,6 +704,18 @@ lldb::SBCommand SBCommand::AddCommand(const char *name,
(const char *, lldb::SBCommandPluginInterface *,
const char *, const char *),
name, impl, help, syntax);
+ return LLDB_RECORD_RESULT(
+ AddCommand(name, impl, help, syntax, /*auto_repeat_command=*/""))
+}
+
+lldb::SBCommand SBCommand::AddCommand(const char *name,
+ lldb::SBCommandPluginInterface *impl,
+ const char *help, const char *syntax,
+ const char *auto_repeat_command) {
+ LLDB_RECORD_METHOD(lldb::SBCommand, SBCommand, AddCommand,
+ (const char *, lldb::SBCommandPluginInterface *,
+ const char *, const char *, const char *),
+ name, impl, help, syntax, auto_repeat_command);
if (!IsValid())
return LLDB_RECORD_RESULT(lldb::SBCommand());
@@ -810,7 +723,8 @@ lldb::SBCommand SBCommand::AddCommand(const char *name,
return LLDB_RECORD_RESULT(lldb::SBCommand());
lldb::CommandObjectSP new_command_sp;
new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>(
- m_opaque_sp->GetCommandInterpreter(), name, impl, help, syntax);
+ m_opaque_sp->GetCommandInterpreter(), name, impl, help, syntax,
+ /*flags=*/0, auto_repeat_command);
if (new_command_sp && m_opaque_sp->LoadSubCommand(name, new_command_sp))
return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp));
return LLDB_RECORD_RESULT(lldb::SBCommand());
@@ -832,37 +746,7 @@ void SBCommand::SetFlags(uint32_t flags) {
namespace lldb_private {
namespace repro {
-template <>
-void RegisterMethods<SBCommandInterpreterRunOptions>(Registry &R) {
- LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunOptions, ());
- LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
- GetStopOnContinue, ());
- LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions,
- SetStopOnContinue, (bool));
- LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
- GetStopOnError, ());
- LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnError,
- (bool));
- LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
- GetStopOnCrash, ());
- LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnCrash,
- (bool));
- LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
- GetEchoCommands, ());
- LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetEchoCommands,
- (bool));
- LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
- GetEchoCommentCommands, ());
- LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions,
- SetEchoCommentCommands, (bool));
- LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
- GetPrintResults, ());
- LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetPrintResults,
- (bool));
- LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
- GetAddToHistory, ());
- LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetAddToHistory,
- (bool));
+template <> void RegisterMethods<SBCommandInterpreter>(Registry &R) {
LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreter,
(lldb_private::CommandInterpreter *));
LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreter,
@@ -946,6 +830,9 @@ void RegisterMethods<SBCommandInterpreterRunOptions>(Registry &R) {
LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommandInterpreter, AddCommand,
(const char *, lldb::SBCommandPluginInterface *,
const char *, const char *));
+ LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommandInterpreter, AddCommand,
+ (const char *, lldb::SBCommandPluginInterface *,
+ const char *, const char *, const char *));
LLDB_REGISTER_CONSTRUCTOR(SBCommand, ());
LLDB_REGISTER_METHOD(bool, SBCommand, IsValid, ());
LLDB_REGISTER_METHOD_CONST(bool, SBCommand, operator bool, ());
@@ -962,9 +849,11 @@ void RegisterMethods<SBCommandInterpreterRunOptions>(Registry &R) {
LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommand, AddCommand,
(const char *, lldb::SBCommandPluginInterface *,
const char *, const char *));
+ LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommand, AddCommand,
+ (const char *, lldb::SBCommandPluginInterface *,
+ const char *, const char *, const char *));
LLDB_REGISTER_METHOD(uint32_t, SBCommand, GetFlags, ());
LLDB_REGISTER_METHOD(void, SBCommand, SetFlags, (uint32_t));
}
-
}
}
diff --git a/lldb/source/API/SBCommandInterpreterRunOptions.cpp b/lldb/source/API/SBCommandInterpreterRunOptions.cpp
new file mode 100644
index 000000000000..fcfbf5e5401a
--- /dev/null
+++ b/lldb/source/API/SBCommandInterpreterRunOptions.cpp
@@ -0,0 +1,272 @@
+//===-- SBCommandInterpreterRunOptions.cpp --------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/lldb-types.h"
+
+#include "SBReproducerPrivate.h"
+
+#include "lldb/API/SBCommandInterpreterRunOptions.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+
+#include <memory>
+
+using namespace lldb;
+using namespace lldb_private;
+
+SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommandInterpreterRunOptions);
+
+ m_opaque_up = std::make_unique<CommandInterpreterRunOptions>();
+}
+
+SBCommandInterpreterRunOptions::~SBCommandInterpreterRunOptions() = default;
+
+bool SBCommandInterpreterRunOptions::GetStopOnContinue() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
+ GetStopOnContinue);
+
+ return m_opaque_up->GetStopOnContinue();
+}
+
+void SBCommandInterpreterRunOptions::SetStopOnContinue(bool stop_on_continue) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnContinue,
+ (bool), stop_on_continue);
+
+ m_opaque_up->SetStopOnContinue(stop_on_continue);
+}
+
+bool SBCommandInterpreterRunOptions::GetStopOnError() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
+ GetStopOnError);
+
+ return m_opaque_up->GetStopOnError();
+}
+
+void SBCommandInterpreterRunOptions::SetStopOnError(bool stop_on_error) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnError,
+ (bool), stop_on_error);
+
+ m_opaque_up->SetStopOnError(stop_on_error);
+}
+
+bool SBCommandInterpreterRunOptions::GetStopOnCrash() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
+ GetStopOnCrash);
+
+ return m_opaque_up->GetStopOnCrash();
+}
+
+void SBCommandInterpreterRunOptions::SetStopOnCrash(bool stop_on_crash) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnCrash,
+ (bool), stop_on_crash);
+
+ m_opaque_up->SetStopOnCrash(stop_on_crash);
+}
+
+bool SBCommandInterpreterRunOptions::GetEchoCommands() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
+ GetEchoCommands);
+
+ return m_opaque_up->GetEchoCommands();
+}
+
+void SBCommandInterpreterRunOptions::SetEchoCommands(bool echo_commands) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetEchoCommands,
+ (bool), echo_commands);
+
+ m_opaque_up->SetEchoCommands(echo_commands);
+}
+
+bool SBCommandInterpreterRunOptions::GetEchoCommentCommands() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
+ GetEchoCommentCommands);
+
+ return m_opaque_up->GetEchoCommentCommands();
+}
+
+void SBCommandInterpreterRunOptions::SetEchoCommentCommands(bool echo) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions,
+ SetEchoCommentCommands, (bool), echo);
+
+ m_opaque_up->SetEchoCommentCommands(echo);
+}
+
+bool SBCommandInterpreterRunOptions::GetPrintResults() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
+ GetPrintResults);
+
+ return m_opaque_up->GetPrintResults();
+}
+
+void SBCommandInterpreterRunOptions::SetPrintResults(bool print_results) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetPrintResults,
+ (bool), print_results);
+
+ m_opaque_up->SetPrintResults(print_results);
+}
+
+bool SBCommandInterpreterRunOptions::GetAddToHistory() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
+ GetAddToHistory);
+
+ return m_opaque_up->GetAddToHistory();
+}
+
+void SBCommandInterpreterRunOptions::SetAddToHistory(bool add_to_history) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetAddToHistory,
+ (bool), add_to_history);
+
+ m_opaque_up->SetAddToHistory(add_to_history);
+}
+
+bool SBCommandInterpreterRunOptions::GetAutoHandleEvents() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
+ GetAutoHandleEvents);
+
+ return m_opaque_up->GetAutoHandleEvents();
+}
+
+void SBCommandInterpreterRunOptions::SetAutoHandleEvents(
+ bool auto_handle_events) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetAutoHandleEvents,
+ (bool), auto_handle_events);
+
+ m_opaque_up->SetAutoHandleEvents(auto_handle_events);
+}
+
+bool SBCommandInterpreterRunOptions::GetSpawnThread() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
+ GetSpawnThread);
+
+ return m_opaque_up->GetSpawnThread();
+}
+
+void SBCommandInterpreterRunOptions::SetSpawnThread(bool spawn_thread) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetSpawnThread,
+ (bool), spawn_thread);
+
+ m_opaque_up->SetSpawnThread(spawn_thread);
+}
+
+lldb_private::CommandInterpreterRunOptions *
+SBCommandInterpreterRunOptions::get() const {
+ return m_opaque_up.get();
+}
+
+lldb_private::CommandInterpreterRunOptions &
+SBCommandInterpreterRunOptions::ref() const {
+ return *m_opaque_up;
+}
+
+SBCommandInterpreterRunResult::SBCommandInterpreterRunResult()
+ : m_opaque_up(new CommandInterpreterRunResult())
+
+{
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommandInterpreterRunResult);
+}
+
+SBCommandInterpreterRunResult::SBCommandInterpreterRunResult(
+ const SBCommandInterpreterRunResult &rhs)
+ : m_opaque_up(new CommandInterpreterRunResult()) {
+ LLDB_RECORD_CONSTRUCTOR(SBCommandInterpreterRunResult,
+ (const lldb::SBCommandInterpreterRunResult &), rhs);
+
+ *m_opaque_up = *rhs.m_opaque_up;
+}
+
+SBCommandInterpreterRunResult::SBCommandInterpreterRunResult(
+ const CommandInterpreterRunResult &rhs)
+ : m_opaque_up() {
+ m_opaque_up = std::make_unique<CommandInterpreterRunResult>(rhs);
+}
+
+SBCommandInterpreterRunResult::~SBCommandInterpreterRunResult() = default;
+
+SBCommandInterpreterRunResult &SBCommandInterpreterRunResult::operator=(
+ const SBCommandInterpreterRunResult &rhs) {
+ LLDB_RECORD_METHOD(lldb::SBCommandInterpreterRunResult &,
+ SBCommandInterpreterRunResult,
+ operator=,(const lldb::SBCommandInterpreterRunResult &),
+ rhs);
+
+ if (this == &rhs)
+ return *this;
+ *m_opaque_up = *rhs.m_opaque_up;
+ return LLDB_RECORD_RESULT(*this);
+}
+
+int SBCommandInterpreterRunResult::GetNumberOfErrors() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(int, SBCommandInterpreterRunResult,
+ GetNumberOfErrors);
+
+ return m_opaque_up->GetNumErrors();
+}
+
+lldb::CommandInterpreterResult
+SBCommandInterpreterRunResult::GetResult() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::CommandInterpreterResult,
+ SBCommandInterpreterRunResult, GetResult);
+
+ return m_opaque_up->GetResult();
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <> void RegisterMethods<SBCommandInterpreterRunOptions>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunOptions, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
+ GetStopOnContinue, ());
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnContinue,
+ (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
+ GetStopOnError, ());
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnError,
+ (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
+ GetStopOnCrash, ());
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnCrash,
+ (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
+ GetEchoCommands, ());
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetEchoCommands,
+ (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
+ GetEchoCommentCommands, ());
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions,
+ SetEchoCommentCommands, (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
+ GetPrintResults, ());
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetPrintResults,
+ (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
+ GetAddToHistory, ());
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetAddToHistory,
+ (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
+ GetAutoHandleEvents, ());
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions,
+ SetAutoHandleEvents, (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
+ GetSpawnThread, ());
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetSpawnThread,
+ (bool));
+ LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunResult, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunResult,
+ (const lldb::SBCommandInterpreterRunResult &));
+ LLDB_REGISTER_METHOD(lldb::SBCommandInterpreterRunResult &,
+ SBCommandInterpreterRunResult,
+ operator=,(const lldb::SBCommandInterpreterRunResult &));
+ LLDB_REGISTER_METHOD_CONST(int, SBCommandInterpreterRunResult,
+ GetNumberOfErrors, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::CommandInterpreterResult,
+ SBCommandInterpreterRunResult, GetResult, ());
+}
+
+} // namespace repro
+} // namespace lldb_private
diff --git a/lldb/source/API/SBCommandReturnObject.cpp b/lldb/source/API/SBCommandReturnObject.cpp
index eec1383df875..fddf90b66481 100644
--- a/lldb/source/API/SBCommandReturnObject.cpp
+++ b/lldb/source/API/SBCommandReturnObject.cpp
@@ -1,4 +1,4 @@
-//===-- SBCommandReturnObject.cpp -------------------------------*- C++ -*-===//
+//===-- SBCommandReturnObject.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -22,7 +22,7 @@ using namespace lldb_private;
class lldb_private::SBCommandReturnObjectImpl {
public:
SBCommandReturnObjectImpl()
- : m_ptr(new CommandReturnObject()), m_owned(true) {}
+ : m_ptr(new CommandReturnObject(false)), m_owned(true) {}
SBCommandReturnObjectImpl(CommandReturnObject &ref)
: m_ptr(&ref), m_owned(false) {}
SBCommandReturnObjectImpl(const SBCommandReturnObjectImpl &rhs)
diff --git a/lldb/source/API/SBCommunication.cpp b/lldb/source/API/SBCommunication.cpp
index 90df70bde72f..d55ecd35b557 100644
--- a/lldb/source/API/SBCommunication.cpp
+++ b/lldb/source/API/SBCommunication.cpp
@@ -1,4 +1,4 @@
-//===-- SBCommunication.cpp -------------------------------------*- C++ -*-===//
+//===-- SBCommunication.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -63,7 +63,7 @@ ConnectionStatus SBCommunication::Connect(const char *url) {
if (m_opaque) {
if (!m_opaque->HasConnection())
- m_opaque->SetConnection(Host::CreateDefaultConnection(url).release());
+ m_opaque->SetConnection(Host::CreateDefaultConnection(url));
return m_opaque->Connect(url, nullptr);
}
return eConnectionStatusNoConnection;
@@ -79,7 +79,8 @@ ConnectionStatus SBCommunication::AdoptFileDesriptor(int fd, bool owns_fd) {
if (m_opaque->IsConnected())
m_opaque->Disconnect();
}
- m_opaque->SetConnection(new ConnectionFileDescriptor(fd, owns_fd));
+ m_opaque->SetConnection(
+ std::make_unique<ConnectionFileDescriptor>(fd, owns_fd));
if (m_opaque->IsConnected())
status = eConnectionStatusSuccess;
else
diff --git a/lldb/source/API/SBCompileUnit.cpp b/lldb/source/API/SBCompileUnit.cpp
index d52040d850a9..765957d680c9 100644
--- a/lldb/source/API/SBCompileUnit.cpp
+++ b/lldb/source/API/SBCompileUnit.cpp
@@ -1,4 +1,4 @@
-//===-- SBCompileUnit.cpp ---------------------------------------*- C++ -*-===//
+//===-- SBCompileUnit.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/API/SBData.cpp b/lldb/source/API/SBData.cpp
index 528cd8d43ecc..daf313ad55c9 100644
--- a/lldb/source/API/SBData.cpp
+++ b/lldb/source/API/SBData.cpp
@@ -1,4 +1,4 @@
-//===-- SBData.cpp ----------------------------------------------*- C++ -*-===//
+//===-- SBData.cpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -41,7 +41,7 @@ const SBData &SBData::operator=(const SBData &rhs) {
return LLDB_RECORD_RESULT(*this);
}
-SBData::~SBData() {}
+SBData::~SBData() = default;
void SBData::SetOpaque(const lldb::DataExtractorSP &data_sp) {
m_opaque_sp = data_sp;
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index b7ac8047f8e5..5f62987f37da 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1,4 +1,4 @@
-//===-- SBDebugger.cpp ------------------------------------------*- C++ -*-===//
+//===-- SBDebugger.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -15,6 +15,7 @@
#include "lldb/API/SBBroadcaster.h"
#include "lldb/API/SBCommandInterpreter.h"
+#include "lldb/API/SBCommandInterpreterRunOptions.h"
#include "lldb/API/SBCommandReturnObject.h"
#include "lldb/API/SBError.h"
#include "lldb/API/SBEvent.h"
@@ -312,7 +313,7 @@ SBError SBDebugger::SetInputFile(SBFile file) {
repro::DataRecorder *recorder = nullptr;
if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator())
- recorder = g->GetOrCreate<repro::CommandProvider>().GetNewDataRecorder();
+ recorder = g->GetOrCreate<repro::CommandProvider>().GetNewRecorder();
FileSP file_sp = file.m_opaque_sp;
@@ -596,8 +597,9 @@ SBSourceManager SBDebugger::GetSourceManager() {
}
bool SBDebugger::GetDefaultArchitecture(char *arch_name, size_t arch_name_len) {
- LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, GetDefaultArchitecture,
- (char *, size_t), "", arch_name_len);
+ LLDB_RECORD_CHAR_PTR_STATIC_METHOD(bool, SBDebugger, GetDefaultArchitecture,
+ (char *, size_t), arch_name, "",
+ arch_name_len);
if (arch_name && arch_name_len) {
ArchSpec default_arch = Target::GetDefaultArchitecture();
@@ -1165,9 +1167,9 @@ void SBDebugger::RunCommandInterpreter(bool auto_handle_events,
if (m_opaque_sp) {
CommandInterpreterRunOptions options;
-
- m_opaque_sp->GetCommandInterpreter().RunCommandInterpreter(
- auto_handle_events, spawn_thread, options);
+ options.SetAutoHandleEvents(auto_handle_events);
+ options.SetSpawnThread(spawn_thread);
+ m_opaque_sp->GetCommandInterpreter().RunCommandInterpreter(options);
}
}
@@ -1185,15 +1187,35 @@ void SBDebugger::RunCommandInterpreter(bool auto_handle_events,
quit_requested, stopped_for_crash);
if (m_opaque_sp) {
+ options.SetAutoHandleEvents(auto_handle_events);
+ options.SetSpawnThread(spawn_thread);
CommandInterpreter &interp = m_opaque_sp->GetCommandInterpreter();
- interp.RunCommandInterpreter(auto_handle_events, spawn_thread,
- options.ref());
- num_errors = interp.GetNumErrors();
- quit_requested = interp.GetQuitRequested();
- stopped_for_crash = interp.GetStoppedForCrash();
+ CommandInterpreterRunResult result =
+ interp.RunCommandInterpreter(options.ref());
+ num_errors = result.GetNumErrors();
+ quit_requested =
+ result.IsResult(lldb::eCommandInterpreterResultQuitRequested);
+ stopped_for_crash =
+ result.IsResult(lldb::eCommandInterpreterResultInferiorCrash);
}
}
+SBCommandInterpreterRunResult SBDebugger::RunCommandInterpreter(
+ const SBCommandInterpreterRunOptions &options) {
+ LLDB_RECORD_METHOD(lldb::SBCommandInterpreterRunResult, SBDebugger,
+ RunCommandInterpreter,
+ (const lldb::SBCommandInterpreterRunOptions &), options);
+
+ if (!m_opaque_sp)
+ return LLDB_RECORD_RESULT(SBCommandInterpreterRunResult());
+
+ CommandInterpreter &interp = m_opaque_sp->GetCommandInterpreter();
+ CommandInterpreterRunResult result =
+ interp.RunCommandInterpreter(options.ref());
+
+ return LLDB_RECORD_RESULT(SBCommandInterpreterRunResult(result));
+}
+
SBError SBDebugger::RunREPL(lldb::LanguageType language,
const char *repl_options) {
LLDB_RECORD_METHOD(lldb::SBError, SBDebugger, RunREPL,
@@ -1282,7 +1304,7 @@ SBDebugger::GetInternalVariableValue(const char *var_name,
if (value_sp) {
StreamString value_strm;
value_sp->DumpValue(&exe_ctx, value_strm, OptionValue::eDumpOptionValue);
- const std::string &value_str = value_strm.GetString();
+ const std::string &value_str = std::string(value_strm.GetString());
if (!value_str.empty()) {
StringList string_list;
string_list.SplitIntoLines(value_str);
@@ -1374,6 +1396,18 @@ bool SBDebugger::GetUseColor() const {
return (m_opaque_sp ? m_opaque_sp->GetUseColor() : false);
}
+bool SBDebugger::SetUseSourceCache(bool value) {
+ LLDB_RECORD_METHOD(bool, SBDebugger, SetUseSourceCache, (bool), value);
+
+ return (m_opaque_sp ? m_opaque_sp->SetUseSourceCache(value) : false);
+}
+
+bool SBDebugger::GetUseSourceCache() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, GetUseSourceCache);
+
+ return (m_opaque_sp ? m_opaque_sp->GetUseSourceCache() : false);
+}
+
bool SBDebugger::GetDescription(SBStream &description) {
LLDB_RECORD_METHOD(bool, SBDebugger, GetDescription, (lldb::SBStream &),
description);
@@ -1627,46 +1661,38 @@ static SBError SetFileRedirect(SBDebugger *, SBFile file) { return SBError(); }
static SBError SetFileRedirect(SBDebugger *, FileSP file) { return SBError(); }
-static bool GetDefaultArchitectureRedirect(char *arch_name,
- size_t arch_name_len) {
- // The function is writing to its argument. Without the redirect it would
- // write into the replay buffer.
- char buffer[1024];
- return SBDebugger::GetDefaultArchitecture(buffer, arch_name_len);
-}
-
template <> void RegisterMethods<SBDebugger>(Registry &R) {
// Custom implementation.
- R.Register(&invoke<void (SBDebugger::*)(
- FILE *, bool)>::method<&SBDebugger::SetErrorFileHandle>::doit,
+ R.Register(&invoke<void (SBDebugger::*)(FILE *, bool)>::method<
+ &SBDebugger::SetErrorFileHandle>::record,
&SetFileHandleRedirect);
- R.Register(&invoke<void (SBDebugger::*)(
- FILE *, bool)>::method<&SBDebugger::SetOutputFileHandle>::doit,
+ R.Register(&invoke<void (SBDebugger::*)(FILE *, bool)>::method<
+ &SBDebugger::SetOutputFileHandle>::record,
&SetFileHandleRedirect);
- R.Register<bool(char *, size_t)>(static_cast<bool (*)(char *, size_t)>(
- &SBDebugger::GetDefaultArchitecture),
- &GetDefaultArchitectureRedirect);
R.Register(&invoke<SBError (SBDebugger::*)(
- SBFile)>::method<&SBDebugger::SetInputFile>::doit,
+ SBFile)>::method<&SBDebugger::SetInputFile>::record,
&SetFileRedirect);
R.Register(&invoke<SBError (SBDebugger::*)(
- SBFile)>::method<&SBDebugger::SetOutputFile>::doit,
+ SBFile)>::method<&SBDebugger::SetOutputFile>::record,
&SetFileRedirect);
R.Register(&invoke<SBError (SBDebugger::*)(
- SBFile)>::method<&SBDebugger::SetErrorFile>::doit,
+ SBFile)>::method<&SBDebugger::SetErrorFile>::record,
&SetFileRedirect);
R.Register(&invoke<SBError (SBDebugger::*)(
- FileSP)>::method<&SBDebugger::SetInputFile>::doit,
+ FileSP)>::method<&SBDebugger::SetInputFile>::record,
&SetFileRedirect);
R.Register(&invoke<SBError (SBDebugger::*)(
- FileSP)>::method<&SBDebugger::SetOutputFile>::doit,
+ FileSP)>::method<&SBDebugger::SetOutputFile>::record,
&SetFileRedirect);
R.Register(&invoke<SBError (SBDebugger::*)(
- FileSP)>::method<&SBDebugger::SetErrorFile>::doit,
+ FileSP)>::method<&SBDebugger::SetErrorFile>::record,
&SetFileRedirect);
+ LLDB_REGISTER_CHAR_PTR_METHOD_STATIC(bool, SBDebugger,
+ GetDefaultArchitecture);
+
LLDB_REGISTER_CONSTRUCTOR(SBDebugger, ());
LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::DebuggerSP &));
LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::SBDebugger &));
@@ -1816,6 +1842,9 @@ template <> void RegisterMethods<SBDebugger>(Registry &R) {
(lldb::SBTypeNameSpecifier));
LLDB_REGISTER_METHOD(bool, SBDebugger, EnableLog,
(const char *, const char **));
+ LLDB_REGISTER_METHOD(lldb::SBCommandInterpreterRunResult, SBDebugger,
+ RunCommandInterpreter,
+ (const lldb::SBCommandInterpreterRunOptions &));
}
} // namespace repro
diff --git a/lldb/source/API/SBDeclaration.cpp b/lldb/source/API/SBDeclaration.cpp
index 50db1770c612..f1066d63c06a 100644
--- a/lldb/source/API/SBDeclaration.cpp
+++ b/lldb/source/API/SBDeclaration.cpp
@@ -1,4 +1,4 @@
-//===-- SBDeclaration.cpp ----------------------------------------*- C++-*-===//
+//===-- SBDeclaration.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -50,7 +50,7 @@ void SBDeclaration::SetDeclaration(
ref() = lldb_object_ref;
}
-SBDeclaration::~SBDeclaration() {}
+SBDeclaration::~SBDeclaration() = default;
bool SBDeclaration::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDeclaration, IsValid);
@@ -148,7 +148,7 @@ const lldb_private::Declaration *SBDeclaration::operator->() const {
lldb_private::Declaration &SBDeclaration::ref() {
if (m_opaque_up == nullptr)
- m_opaque_up.reset(new lldb_private::Declaration());
+ m_opaque_up = std::make_unique<lldb_private::Declaration>();
return *m_opaque_up;
}
diff --git a/lldb/source/API/SBEnvironment.cpp b/lldb/source/API/SBEnvironment.cpp
new file mode 100644
index 000000000000..d4de89c32567
--- /dev/null
+++ b/lldb/source/API/SBEnvironment.cpp
@@ -0,0 +1,155 @@
+//===-- SBEnvironment.cpp -------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/API/SBEnvironment.h"
+#include "SBReproducerPrivate.h"
+#include "Utils.h"
+#include "lldb/API/SBStringList.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Environment.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+SBEnvironment::SBEnvironment() : m_opaque_up(new Environment()) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBEnvironment);
+}
+
+SBEnvironment::SBEnvironment(const SBEnvironment &rhs)
+ : m_opaque_up(clone(rhs.m_opaque_up)) {
+ LLDB_RECORD_CONSTRUCTOR(SBEnvironment, (const lldb::SBEnvironment &), rhs);
+}
+
+SBEnvironment::SBEnvironment(Environment rhs)
+ : m_opaque_up(new Environment(std::move(rhs))) {}
+
+SBEnvironment::~SBEnvironment() = default;
+
+const SBEnvironment &SBEnvironment::operator=(const SBEnvironment &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBEnvironment &,
+ SBEnvironment, operator=,(const lldb::SBEnvironment &),
+ rhs);
+
+ if (this != &rhs)
+ m_opaque_up = clone(rhs.m_opaque_up);
+ return LLDB_RECORD_RESULT(*this);
+}
+
+size_t SBEnvironment::GetNumValues() {
+ LLDB_RECORD_METHOD_NO_ARGS(size_t, SBEnvironment, GetNumValues);
+
+ return m_opaque_up->size();
+}
+
+const char *SBEnvironment::Get(const char *name) {
+ LLDB_RECORD_METHOD(const char *, SBEnvironment, Get, (const char *), name);
+
+ auto entry = m_opaque_up->find(name);
+ if (entry == m_opaque_up->end()) {
+ return nullptr;
+ }
+ return ConstString(entry->second).AsCString("");
+}
+
+const char *SBEnvironment::GetNameAtIndex(size_t index) {
+ LLDB_RECORD_METHOD(const char *, SBEnvironment, GetNameAtIndex, (size_t),
+ index);
+
+ if (index >= GetNumValues())
+ return nullptr;
+ return ConstString(std::next(m_opaque_up->begin(), index)->first())
+ .AsCString("");
+}
+
+const char *SBEnvironment::GetValueAtIndex(size_t index) {
+ LLDB_RECORD_METHOD(const char *, SBEnvironment, GetValueAtIndex, (size_t),
+ index);
+
+ if (index >= GetNumValues())
+ return nullptr;
+ return ConstString(std::next(m_opaque_up->begin(), index)->second)
+ .AsCString("");
+}
+
+bool SBEnvironment::Set(const char *name, const char *value, bool overwrite) {
+ LLDB_RECORD_METHOD(bool, SBEnvironment, Set,
+ (const char *, const char *, bool), name, value,
+ overwrite);
+
+ if (overwrite) {
+ m_opaque_up->insert_or_assign(name, std::string(value));
+ return true;
+ }
+ return m_opaque_up->try_emplace(name, std::string(value)).second;
+}
+
+bool SBEnvironment::Unset(const char *name) {
+ LLDB_RECORD_METHOD(bool, SBEnvironment, Unset, (const char *), name);
+
+ return m_opaque_up->erase(name);
+}
+
+SBStringList SBEnvironment::GetEntries() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBStringList, SBEnvironment, GetEntries);
+
+ SBStringList entries;
+ for (const auto &KV : *m_opaque_up) {
+ entries.AppendString(Environment::compose(KV).c_str());
+ }
+ return LLDB_RECORD_RESULT(entries);
+}
+
+void SBEnvironment::PutEntry(const char *name_and_value) {
+ LLDB_RECORD_METHOD(void, SBEnvironment, PutEntry, (const char *),
+ name_and_value);
+
+ auto split = llvm::StringRef(name_and_value).split('=');
+ m_opaque_up->insert_or_assign(split.first.str(), split.second.str());
+}
+
+void SBEnvironment::SetEntries(const SBStringList &entries, bool append) {
+ LLDB_RECORD_METHOD(void, SBEnvironment, SetEntries,
+ (const lldb::SBStringList &, bool), entries, append);
+
+ if (!append)
+ m_opaque_up->clear();
+ for (size_t i = 0; i < entries.GetSize(); i++) {
+ PutEntry(entries.GetStringAtIndex(i));
+ }
+}
+
+void SBEnvironment::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBEnvironment, Clear);
+
+ m_opaque_up->clear();
+}
+
+Environment &SBEnvironment::ref() const { return *m_opaque_up; }
+
+namespace lldb_private {
+namespace repro {
+template <> void RegisterMethods<SBEnvironment>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBEnvironment, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBEnvironment, (const lldb::SBEnvironment &));
+ LLDB_REGISTER_METHOD(const lldb::SBEnvironment &,
+ SBEnvironment, operator=,(const lldb::SBEnvironment &));
+ LLDB_REGISTER_METHOD(size_t, SBEnvironment, GetNumValues, ());
+ LLDB_REGISTER_METHOD(const char *, SBEnvironment, Get, (const char *));
+ LLDB_REGISTER_METHOD(const char *, SBEnvironment, GetNameAtIndex, (size_t));
+ LLDB_REGISTER_METHOD(const char *, SBEnvironment, GetValueAtIndex, (size_t));
+ LLDB_REGISTER_METHOD(bool, SBEnvironment, Set,
+ (const char *, const char *, bool));
+ LLDB_REGISTER_METHOD(bool, SBEnvironment, Unset, (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBStringList, SBEnvironment, GetEntries, ());
+ LLDB_REGISTER_METHOD(void, SBEnvironment, PutEntry, (const char *));
+ LLDB_REGISTER_METHOD(void, SBEnvironment, SetEntries,
+ (const lldb::SBStringList &, bool));
+ LLDB_REGISTER_METHOD(void, SBEnvironment, Clear, ());
+}
+} // namespace repro
+} // namespace lldb_private
diff --git a/lldb/source/API/SBError.cpp b/lldb/source/API/SBError.cpp
index 7256e8e55de9..67c7663d3583 100644
--- a/lldb/source/API/SBError.cpp
+++ b/lldb/source/API/SBError.cpp
@@ -1,4 +1,4 @@
-//===-- SBError.cpp ---------------------------------------------*- C++ -*-===//
+//===-- SBError.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -25,7 +25,7 @@ SBError::SBError(const SBError &rhs) : m_opaque_up() {
m_opaque_up = clone(rhs.m_opaque_up);
}
-SBError::~SBError() {}
+SBError::~SBError() = default;
const SBError &SBError::operator=(const SBError &rhs) {
LLDB_RECORD_METHOD(const lldb::SBError &,
@@ -149,7 +149,7 @@ SBError::operator bool() const {
void SBError::CreateIfNeeded() {
if (m_opaque_up == nullptr)
- m_opaque_up.reset(new Status());
+ m_opaque_up = std::make_unique<Status>();
}
lldb_private::Status *SBError::operator->() { return m_opaque_up.get(); }
diff --git a/lldb/source/API/SBEvent.cpp b/lldb/source/API/SBEvent.cpp
index fb2ad10ddcf9..2776ec49c092 100644
--- a/lldb/source/API/SBEvent.cpp
+++ b/lldb/source/API/SBEvent.cpp
@@ -1,4 +1,4 @@
-//===-- SBEvent.cpp ---------------------------------------------*- C++ -*-===//
+//===-- SBEvent.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -58,7 +58,7 @@ const SBEvent &SBEvent::operator=(const SBEvent &rhs) {
return LLDB_RECORD_RESULT(*this);
}
-SBEvent::~SBEvent() {}
+SBEvent::~SBEvent() = default;
const char *SBEvent::GetDataFlavor() {
LLDB_RECORD_METHOD_NO_ARGS(const char *, SBEvent, GetDataFlavor);
diff --git a/lldb/source/API/SBExecutionContext.cpp b/lldb/source/API/SBExecutionContext.cpp
index 1224c2abe989..caf02b4164ea 100644
--- a/lldb/source/API/SBExecutionContext.cpp
+++ b/lldb/source/API/SBExecutionContext.cpp
@@ -1,5 +1,4 @@
-//===-- SBExecutionContext.cpp ------------------------------------*- C++
-//-*-===//
+//===-- SBExecutionContext.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -66,7 +65,7 @@ SBExecutionContext::SBExecutionContext(const lldb::SBFrame &frame)
m_exe_ctx_sp->SetFrameSP(frame.GetFrameSP());
}
-SBExecutionContext::~SBExecutionContext() {}
+SBExecutionContext::~SBExecutionContext() = default;
const SBExecutionContext &SBExecutionContext::
operator=(const lldb::SBExecutionContext &rhs) {
diff --git a/lldb/source/API/SBExpressionOptions.cpp b/lldb/source/API/SBExpressionOptions.cpp
index 8c34194abf1e..217e8ad5c21b 100644
--- a/lldb/source/API/SBExpressionOptions.cpp
+++ b/lldb/source/API/SBExpressionOptions.cpp
@@ -1,5 +1,4 @@
-//===-- SBExpressionOptions.cpp ---------------------------------------------*-
-//C++ -*-===//
+//===-- SBExpressionOptions.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -40,7 +39,7 @@ operator=(const SBExpressionOptions &rhs) {
return LLDB_RECORD_RESULT(*this);
}
-SBExpressionOptions::~SBExpressionOptions() {}
+SBExpressionOptions::~SBExpressionOptions() = default;
bool SBExpressionOptions::GetCoerceResultToId() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions,
@@ -238,6 +237,20 @@ void SBExpressionOptions::SetAutoApplyFixIts(bool b) {
return m_opaque_up->SetAutoApplyFixIts(b);
}
+uint64_t SBExpressionOptions::GetRetriesWithFixIts() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBExpressionOptions,
+ GetRetriesWithFixIts);
+
+ return m_opaque_up->GetRetriesWithFixIts();
+}
+
+void SBExpressionOptions::SetRetriesWithFixIts(uint64_t retries) {
+ LLDB_RECORD_METHOD(void, SBExpressionOptions, SetRetriesWithFixIts,
+ (uint64_t), retries);
+
+ return m_opaque_up->SetRetriesWithFixIts(retries);
+}
+
bool SBExpressionOptions::GetTopLevel() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetTopLevel);
@@ -330,6 +343,9 @@ void RegisterMethods<SBExpressionOptions>(Registry &R) {
LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTopLevel, (bool));
LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetAllowJIT, ());
LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetAllowJIT, (bool));
+ LLDB_REGISTER_METHOD(uint64_t, SBExpressionOptions, GetRetriesWithFixIts, ());
+ LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetRetriesWithFixIts,
+ (uint64_t));
}
}
diff --git a/lldb/source/API/SBFile.cpp b/lldb/source/API/SBFile.cpp
index 277402f31abf..41ccdbe76b91 100644
--- a/lldb/source/API/SBFile.cpp
+++ b/lldb/source/API/SBFile.cpp
@@ -1,4 +1,4 @@
-//===-- SBFile.cpp ------------------------------------------*- C++ -*-===//
+//===-- SBFile.cpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -14,22 +14,39 @@
using namespace lldb;
using namespace lldb_private;
-SBFile::~SBFile() {}
+SBFile::~SBFile() = default;
SBFile::SBFile(FileSP file_sp) : m_opaque_sp(file_sp) {
- LLDB_RECORD_DUMMY(void, SBfile, SBFile, (FileSP), file_sp);
+ // We have no way to capture the incoming FileSP as the class isn't
+ // instrumented, so pretend that it's always null.
+ LLDB_RECORD_CONSTRUCTOR(SBFile, (lldb::FileSP), nullptr);
+}
+
+SBFile::SBFile(const SBFile &rhs) : m_opaque_sp(rhs.m_opaque_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBFile, (const lldb::SBFile&), rhs);
+}
+
+SBFile &SBFile ::operator=(const SBFile &rhs) {
+ LLDB_RECORD_METHOD(lldb::SBFile &,
+ SBFile, operator=,(const lldb::SBFile &), rhs);
+
+ if (this != &rhs)
+ m_opaque_sp = rhs.m_opaque_sp;
+ return LLDB_RECORD_RESULT(*this);
}
SBFile::SBFile() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFile); }
SBFile::SBFile(FILE *file, bool transfer_ownership) {
- LLDB_RECORD_DUMMY(void, SBFile, (FILE *, bool), file, transfer_ownership);
+ LLDB_RECORD_CONSTRUCTOR(SBFile, (FILE *, bool), file, transfer_ownership);
+
m_opaque_sp = std::make_shared<NativeFile>(file, transfer_ownership);
}
SBFile::SBFile(int fd, const char *mode, bool transfer_owndership) {
- LLDB_RECORD_DUMMY(void, SBFile, (int, const char *, bool), fd, mode,
- transfer_owndership);
+ LLDB_RECORD_CONSTRUCTOR(SBFile, (int, const char *, bool), fd, mode,
+ transfer_owndership);
+
auto options = File::GetOptionsFromMode(mode);
if (!options) {
llvm::consumeError(options.takeError());
@@ -40,8 +57,9 @@ SBFile::SBFile(int fd, const char *mode, bool transfer_owndership) {
}
SBError SBFile::Read(uint8_t *buf, size_t num_bytes, size_t *bytes_read) {
- LLDB_RECORD_DUMMY(lldb::SBError, SBFile, Read, (uint8_t *, size_t, size_t *),
- buf, num_bytes, bytes_read);
+ LLDB_RECORD_METHOD(lldb::SBError, SBFile, Read, (uint8_t *, size_t, size_t *),
+ buf, num_bytes, bytes_read);
+
SBError error;
if (!m_opaque_sp) {
error.SetErrorString("invalid SBFile");
@@ -56,9 +74,10 @@ SBError SBFile::Read(uint8_t *buf, size_t num_bytes, size_t *bytes_read) {
SBError SBFile::Write(const uint8_t *buf, size_t num_bytes,
size_t *bytes_written) {
- LLDB_RECORD_DUMMY(lldb::SBError, SBFile, Write,
- (const uint8_t *, size_t, size_t *), buf, num_bytes,
- bytes_written);
+ LLDB_RECORD_METHOD(lldb::SBError, SBFile, Write,
+ (const uint8_t *, size_t, size_t *), buf, num_bytes,
+ bytes_written);
+
SBError error;
if (!m_opaque_sp) {
error.SetErrorString("invalid SBFile");
@@ -73,6 +92,7 @@ SBError SBFile::Write(const uint8_t *buf, size_t num_bytes,
SBError SBFile::Flush() {
LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBFile, Flush);
+
SBError error;
if (!m_opaque_sp) {
error.SetErrorString("invalid SBFile");
@@ -119,9 +139,15 @@ namespace repro {
template <> void RegisterMethods<SBFile>(Registry &R) {
LLDB_REGISTER_CONSTRUCTOR(SBFile, ());
LLDB_REGISTER_CONSTRUCTOR(SBFile, (FileSP));
+ LLDB_REGISTER_CONSTRUCTOR(SBFile, (const SBFile&));
LLDB_REGISTER_CONSTRUCTOR(SBFile, (FILE *, bool));
LLDB_REGISTER_CONSTRUCTOR(SBFile, (int, const char *, bool));
+ LLDB_REGISTER_METHOD(SBFile&, SBFile, operator=,(const SBFile&));
LLDB_REGISTER_METHOD(lldb::SBError, SBFile, Flush, ());
+ LLDB_REGISTER_METHOD(lldb::SBError, SBFile, Read,
+ (uint8_t *, size_t, size_t *));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBFile, Write,
+ (const uint8_t *, size_t, size_t *));
LLDB_REGISTER_METHOD_CONST(bool, SBFile, IsValid, ());
LLDB_REGISTER_METHOD_CONST(bool, SBFile, operator bool,());
LLDB_REGISTER_METHOD_CONST(bool, SBFile, operator!,());
diff --git a/lldb/source/API/SBFileSpec.cpp b/lldb/source/API/SBFileSpec.cpp
index 2e7eba42bc90..7bfb665df4fb 100644
--- a/lldb/source/API/SBFileSpec.cpp
+++ b/lldb/source/API/SBFileSpec.cpp
@@ -1,4 +1,4 @@
-//===-- SBFileSpec.cpp ------------------------------------------*- C++ -*-===//
+//===-- SBFileSpec.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -51,7 +51,7 @@ SBFileSpec::SBFileSpec(const char *path, bool resolve)
FileSystem::Instance().Resolve(*m_opaque_up);
}
-SBFileSpec::~SBFileSpec() {}
+SBFileSpec::~SBFileSpec() = default;
const SBFileSpec &SBFileSpec::operator=(const SBFileSpec &rhs) {
LLDB_RECORD_METHOD(const lldb::SBFileSpec &,
@@ -143,8 +143,8 @@ void SBFileSpec::SetDirectory(const char *directory) {
}
uint32_t SBFileSpec::GetPath(char *dst_path, size_t dst_len) const {
- LLDB_RECORD_DUMMY(uint32_t, SBFileSpec, GetPath, (char *, size_t),
- dst_path, dst_len);
+ LLDB_RECORD_CHAR_PTR_METHOD_CONST(uint32_t, SBFileSpec, GetPath,
+ (char *, size_t), dst_path, "", dst_len);
uint32_t result = m_opaque_up->GetPath(dst_path, dst_len);
@@ -213,10 +213,10 @@ void RegisterMethods<SBFileSpec>(Registry &R) {
LLDB_REGISTER_METHOD_CONST(const char *, SBFileSpec, GetDirectory, ());
LLDB_REGISTER_METHOD(void, SBFileSpec, SetFilename, (const char *));
LLDB_REGISTER_METHOD(void, SBFileSpec, SetDirectory, (const char *));
- LLDB_REGISTER_METHOD_CONST(uint32_t, SBFileSpec, GetPath, (char *, size_t));
LLDB_REGISTER_METHOD_CONST(bool, SBFileSpec, GetDescription,
(lldb::SBStream &));
LLDB_REGISTER_METHOD(void, SBFileSpec, AppendPathComponent, (const char *));
+ LLDB_REGISTER_CHAR_PTR_METHOD_CONST(uint32_t, SBFileSpec, GetPath);
}
}
diff --git a/lldb/source/API/SBFileSpecList.cpp b/lldb/source/API/SBFileSpecList.cpp
index 3143964b38cb..7afa34363271 100644
--- a/lldb/source/API/SBFileSpecList.cpp
+++ b/lldb/source/API/SBFileSpecList.cpp
@@ -1,4 +1,4 @@
-//===-- SBFileSpecList.cpp --------------------------------------*- C++ -*-===//
+//===-- SBFileSpecList.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -32,7 +32,7 @@ SBFileSpecList::SBFileSpecList(const SBFileSpecList &rhs) : m_opaque_up() {
m_opaque_up = clone(rhs.m_opaque_up);
}
-SBFileSpecList::~SBFileSpecList() {}
+SBFileSpecList::~SBFileSpecList() = default;
const SBFileSpecList &SBFileSpecList::operator=(const SBFileSpecList &rhs) {
LLDB_RECORD_METHOD(const lldb::SBFileSpecList &,
diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp
index af42be9ac75e..81782dbf838f 100644
--- a/lldb/source/API/SBFrame.cpp
+++ b/lldb/source/API/SBFrame.cpp
@@ -1,4 +1,4 @@
-//===-- SBFrame.cpp ---------------------------------------------*- C++ -*-===//
+//===-- SBFrame.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -354,15 +354,15 @@ bool SBFrame::SetPC(addr_t new_pc) {
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process) {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process->GetRunLock())) {
- frame = exe_ctx.GetFramePtr();
- if (frame) {
- ret_val = frame->GetRegisterContext()->SetPC(new_pc);
+ if (StackFrame *frame = exe_ctx.GetFramePtr()) {
+ if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext()) {
+ ret_val = reg_ctx_sp->SetPC(new_pc);
+ }
}
}
}
@@ -377,15 +377,15 @@ addr_t SBFrame::GetSP() const {
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process) {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process->GetRunLock())) {
- frame = exe_ctx.GetFramePtr();
- if (frame) {
- addr = frame->GetRegisterContext()->GetSP();
+ if (StackFrame *frame = exe_ctx.GetFramePtr()) {
+ if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext()) {
+ addr = reg_ctx_sp->GetSP();
+ }
}
}
}
@@ -400,15 +400,16 @@ addr_t SBFrame::GetFP() const {
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process) {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process->GetRunLock())) {
- frame = exe_ctx.GetFramePtr();
- if (frame)
- addr = frame->GetRegisterContext()->GetFP();
+ if (StackFrame *frame = exe_ctx.GetFramePtr()) {
+ if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext()) {
+ addr = reg_ctx_sp->GetFP();
+ }
+ }
}
}
@@ -1225,8 +1226,7 @@ const char *SBFrame::GetFunctionName() const {
if (inlined_block) {
const InlineFunctionInfo *inlined_info =
inlined_block->GetInlinedFunctionInfo();
- name =
- inlined_info->GetName(sc.function->GetLanguage()).AsCString();
+ name = inlined_info->GetName().AsCString();
}
}
@@ -1269,8 +1269,7 @@ const char *SBFrame::GetDisplayFunctionName() {
if (inlined_block) {
const InlineFunctionInfo *inlined_info =
inlined_block->GetInlinedFunctionInfo();
- name = inlined_info->GetDisplayName(sc.function->GetLanguage())
- .AsCString();
+ name = inlined_info->GetDisplayName().AsCString();
}
}
diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp
index 1770bede2f42..e49513bd0da5 100644
--- a/lldb/source/API/SBFunction.cpp
+++ b/lldb/source/API/SBFunction.cpp
@@ -1,4 +1,4 @@
-//===-- SBFunction.cpp ------------------------------------------*- C++ -*-===//
+//===-- SBFunction.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -69,9 +69,7 @@ const char *SBFunction::GetDisplayName() const {
const char *cstr = nullptr;
if (m_opaque_ptr)
- cstr = m_opaque_ptr->GetMangled()
- .GetDisplayDemangledName(m_opaque_ptr->GetLanguage())
- .AsCString();
+ cstr = m_opaque_ptr->GetMangled().GetDisplayDemangledName().AsCString();
return cstr;
}
@@ -128,20 +126,15 @@ SBInstructionList SBFunction::GetInstructions(SBTarget target,
SBInstructionList sb_instructions;
if (m_opaque_ptr) {
- ExecutionContext exe_ctx;
TargetSP target_sp(target.GetSP());
std::unique_lock<std::recursive_mutex> lock;
- if (target_sp) {
- lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
- target_sp->CalculateExecutionContext(exe_ctx);
- exe_ctx.SetProcessSP(target_sp->GetProcessSP());
- }
ModuleSP module_sp(
m_opaque_ptr->GetAddressRange().GetBaseAddress().GetModule());
- if (module_sp) {
+ if (target_sp && module_sp) {
+ lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
const bool prefer_file_cache = false;
sb_instructions.SetDisassembler(Disassembler::DisassembleRange(
- module_sp->GetArchitecture(), nullptr, flavor, exe_ctx,
+ module_sp->GetArchitecture(), nullptr, flavor, *target_sp,
m_opaque_ptr->GetAddressRange(), prefer_file_cache));
}
}
diff --git a/lldb/source/API/SBHostOS.cpp b/lldb/source/API/SBHostOS.cpp
index 6ac8717237e7..9d3d119e4c2a 100644
--- a/lldb/source/API/SBHostOS.cpp
+++ b/lldb/source/API/SBHostOS.cpp
@@ -1,4 +1,4 @@
-//===-- SBHostOS.cpp --------------------------------------------*- C++ -*-===//
+//===-- SBHostOS.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/API/SBInstruction.cpp b/lldb/source/API/SBInstruction.cpp
index a9ef9fb59d24..207e81272e50 100644
--- a/lldb/source/API/SBInstruction.cpp
+++ b/lldb/source/API/SBInstruction.cpp
@@ -1,4 +1,4 @@
-//===-- SBInstruction.cpp ---------------------------------------*- C++ -*-===//
+//===-- SBInstruction.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -89,7 +89,7 @@ const SBInstruction &SBInstruction::operator=(const SBInstruction &rhs) {
return LLDB_RECORD_RESULT(*this);
}
-SBInstruction::~SBInstruction() {}
+SBInstruction::~SBInstruction() = default;
bool SBInstruction::IsValid() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBInstruction, IsValid);
diff --git a/lldb/source/API/SBInstructionList.cpp b/lldb/source/API/SBInstructionList.cpp
index 8b3855c0883b..a0c6fbe7e338 100644
--- a/lldb/source/API/SBInstructionList.cpp
+++ b/lldb/source/API/SBInstructionList.cpp
@@ -1,4 +1,4 @@
-//===-- SBInstructionList.cpp -----------------------------------*- C++ -*-===//
+//===-- SBInstructionList.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -42,7 +42,7 @@ operator=(const SBInstructionList &rhs) {
return LLDB_RECORD_RESULT(*this);
}
-SBInstructionList::~SBInstructionList() {}
+SBInstructionList::~SBInstructionList() = default;
bool SBInstructionList::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBInstructionList, IsValid);
diff --git a/lldb/source/API/SBLanguageRuntime.cpp b/lldb/source/API/SBLanguageRuntime.cpp
index 04bd08fb739e..33c900d20c31 100644
--- a/lldb/source/API/SBLanguageRuntime.cpp
+++ b/lldb/source/API/SBLanguageRuntime.cpp
@@ -1,4 +1,4 @@
-//===-- SBLanguageRuntime.cpp -----------------------------------*- C++ -*-===//
+//===-- SBLanguageRuntime.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/API/SBLaunchInfo.cpp b/lldb/source/API/SBLaunchInfo.cpp
index 5c5e69704c7c..ba13072e8f9b 100644
--- a/lldb/source/API/SBLaunchInfo.cpp
+++ b/lldb/source/API/SBLaunchInfo.cpp
@@ -1,4 +1,4 @@
-//===-- SBLaunchInfo.cpp ----------------------------------------*- C++ -*-===//
+//===-- SBLaunchInfo.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,6 +9,7 @@
#include "lldb/API/SBLaunchInfo.h"
#include "SBReproducerPrivate.h"
+#include "lldb/API/SBEnvironment.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBListener.h"
#include "lldb/Host/ProcessLaunchInfo.h"
@@ -43,7 +44,21 @@ SBLaunchInfo::SBLaunchInfo(const char **argv)
m_opaque_sp->GetArguments().SetArguments(argv);
}
-SBLaunchInfo::~SBLaunchInfo() {}
+SBLaunchInfo::SBLaunchInfo(const SBLaunchInfo &rhs) {
+ LLDB_RECORD_CONSTRUCTOR(SBLaunchInfo, (const lldb::SBLaunchInfo &), rhs);
+
+ m_opaque_sp = rhs.m_opaque_sp;
+}
+
+SBLaunchInfo &SBLaunchInfo::operator=(const SBLaunchInfo &rhs) {
+ LLDB_RECORD_METHOD(SBLaunchInfo &,
+ SBLaunchInfo, operator=,(const lldb::SBLaunchInfo &), rhs);
+
+ m_opaque_sp = rhs.m_opaque_sp;
+ return LLDB_RECORD_RESULT(*this);
+}
+
+SBLaunchInfo::~SBLaunchInfo() = default;
const lldb_private::ProcessLaunchInfo &SBLaunchInfo::ref() const {
return *m_opaque_sp;
@@ -168,15 +183,26 @@ const char *SBLaunchInfo::GetEnvironmentEntryAtIndex(uint32_t idx) {
void SBLaunchInfo::SetEnvironmentEntries(const char **envp, bool append) {
LLDB_RECORD_METHOD(void, SBLaunchInfo, SetEnvironmentEntries,
(const char **, bool), envp, append);
+ SetEnvironment(SBEnvironment(Environment(envp)), append);
+}
- Environment env(envp);
+void SBLaunchInfo::SetEnvironment(const SBEnvironment &env, bool append) {
+ LLDB_RECORD_METHOD(void, SBLaunchInfo, SetEnvironment,
+ (const lldb::SBEnvironment &, bool), env, append);
+ Environment &refEnv = env.ref();
if (append)
- m_opaque_sp->GetEnvironment().insert(env.begin(), env.end());
+ m_opaque_sp->GetEnvironment().insert(refEnv.begin(), refEnv.end());
else
- m_opaque_sp->GetEnvironment() = env;
+ m_opaque_sp->GetEnvironment() = refEnv;
m_opaque_sp->RegenerateEnvp();
}
+SBEnvironment SBLaunchInfo::GetEnvironment() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBEnvironment, SBLaunchInfo, GetEnvironment);
+ return LLDB_RECORD_RESULT(
+ SBEnvironment(Environment(m_opaque_sp->GetEnvironment())));
+}
+
void SBLaunchInfo::Clear() {
LLDB_RECORD_METHOD_NO_ARGS(void, SBLaunchInfo, Clear);
@@ -322,6 +348,9 @@ namespace repro {
template <>
void RegisterMethods<SBLaunchInfo>(Registry &R) {
LLDB_REGISTER_CONSTRUCTOR(SBLaunchInfo, (const char **));
+ LLDB_REGISTER_CONSTRUCTOR(SBLaunchInfo, (const lldb::SBLaunchInfo &));
+ LLDB_REGISTER_METHOD(SBLaunchInfo &,
+ SBLaunchInfo, operator=,(const lldb::SBLaunchInfo &));
LLDB_REGISTER_METHOD(lldb::pid_t, SBLaunchInfo, GetProcessID, ());
LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetUserID, ());
LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetGroupID, ());
@@ -373,6 +402,9 @@ void RegisterMethods<SBLaunchInfo>(Registry &R) {
());
LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetDetachOnError, (bool));
LLDB_REGISTER_METHOD_CONST(bool, SBLaunchInfo, GetDetachOnError, ());
+ LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetEnvironment,
+ (const lldb::SBEnvironment &, bool));
+ LLDB_REGISTER_METHOD(lldb::SBEnvironment, SBLaunchInfo, GetEnvironment, ());
}
}
diff --git a/lldb/source/API/SBLineEntry.cpp b/lldb/source/API/SBLineEntry.cpp
index 66884f763398..cefbe3ee1a1e 100644
--- a/lldb/source/API/SBLineEntry.cpp
+++ b/lldb/source/API/SBLineEntry.cpp
@@ -1,4 +1,4 @@
-//===-- SBLineEntry.cpp -----------------------------------------*- C++ -*-===//
+//===-- SBLineEntry.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -48,7 +48,7 @@ void SBLineEntry::SetLineEntry(const lldb_private::LineEntry &lldb_object_ref) {
m_opaque_up = std::make_unique<LineEntry>(lldb_object_ref);
}
-SBLineEntry::~SBLineEntry() {}
+SBLineEntry::~SBLineEntry() = default;
SBAddress SBLineEntry::GetStartAddress() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBLineEntry,
@@ -163,7 +163,7 @@ const lldb_private::LineEntry *SBLineEntry::operator->() const {
lldb_private::LineEntry &SBLineEntry::ref() {
if (m_opaque_up == nullptr)
- m_opaque_up.reset(new lldb_private::LineEntry());
+ m_opaque_up = std::make_unique<lldb_private::LineEntry>();
return *m_opaque_up;
}
diff --git a/lldb/source/API/SBListener.cpp b/lldb/source/API/SBListener.cpp
index 4fe90f6f6862..f3463268b3b5 100644
--- a/lldb/source/API/SBListener.cpp
+++ b/lldb/source/API/SBListener.cpp
@@ -1,4 +1,4 @@
-//===-- SBListener.cpp ------------------------------------------*- C++ -*-===//
+//===-- SBListener.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -48,7 +48,7 @@ const lldb::SBListener &SBListener::operator=(const lldb::SBListener &rhs) {
SBListener::SBListener(const lldb::ListenerSP &listener_sp)
: m_opaque_sp(listener_sp), m_unused_ptr(nullptr) {}
-SBListener::~SBListener() {}
+SBListener::~SBListener() = default;
bool SBListener::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBListener, IsValid);
diff --git a/lldb/source/API/SBMemoryRegionInfo.cpp b/lldb/source/API/SBMemoryRegionInfo.cpp
index d25570f51ce5..2a28b99c72d7 100644
--- a/lldb/source/API/SBMemoryRegionInfo.cpp
+++ b/lldb/source/API/SBMemoryRegionInfo.cpp
@@ -1,4 +1,4 @@
-//===-- SBMemoryRegionInfo.cpp ----------------------------------*- C++ -*-===//
+//===-- SBMemoryRegionInfo.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -46,7 +46,7 @@ operator=(const SBMemoryRegionInfo &rhs) {
return LLDB_RECORD_RESULT(*this);
}
-SBMemoryRegionInfo::~SBMemoryRegionInfo() {}
+SBMemoryRegionInfo::~SBMemoryRegionInfo() = default;
void SBMemoryRegionInfo::Clear() {
LLDB_RECORD_METHOD_NO_ARGS(void, SBMemoryRegionInfo, Clear);
diff --git a/lldb/source/API/SBMemoryRegionInfoList.cpp b/lldb/source/API/SBMemoryRegionInfoList.cpp
index 32a3afb84af0..0f3f9c1b8177 100644
--- a/lldb/source/API/SBMemoryRegionInfoList.cpp
+++ b/lldb/source/API/SBMemoryRegionInfoList.cpp
@@ -1,4 +1,4 @@
-//===-- SBMemoryRegionInfoList.cpp ------------------------------*- C++ -*-===//
+//===-- SBMemoryRegionInfoList.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -82,7 +82,7 @@ SBMemoryRegionInfoList::SBMemoryRegionInfoList(
(const lldb::SBMemoryRegionInfoList &), rhs);
}
-SBMemoryRegionInfoList::~SBMemoryRegionInfoList() {}
+SBMemoryRegionInfoList::~SBMemoryRegionInfoList() = default;
const SBMemoryRegionInfoList &SBMemoryRegionInfoList::
operator=(const SBMemoryRegionInfoList &rhs) {
diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index 4e9dfb0c1e62..c30529b37eb1 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -1,4 +1,4 @@
-//===-- SBModule.cpp --------------------------------------------*- C++ -*-===//
+//===-- SBModule.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -75,7 +75,7 @@ const SBModule &SBModule::operator=(const SBModule &rhs) {
return LLDB_RECORD_RESULT(*this);
}
-SBModule::~SBModule() {}
+SBModule::~SBModule() = default;
bool SBModule::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModule, IsValid);
@@ -401,8 +401,8 @@ lldb::SBSymbolContextList SBModule::FindFunctions(const char *name,
const bool symbols_ok = true;
const bool inlines_ok = true;
FunctionNameType type = static_cast<FunctionNameType>(name_type_mask);
- module_sp->FindFunctions(ConstString(name), nullptr, type, symbols_ok,
- inlines_ok, *sb_sc_list);
+ module_sp->FindFunctions(ConstString(name), CompilerDeclContext(), type,
+ symbols_ok, inlines_ok, *sb_sc_list);
}
return LLDB_RECORD_RESULT(sb_sc_list);
}
@@ -417,8 +417,8 @@ SBValueList SBModule::FindGlobalVariables(SBTarget &target, const char *name,
ModuleSP module_sp(GetSP());
if (name && module_sp) {
VariableList variable_list;
- module_sp->FindGlobalVariables(ConstString(name), nullptr, max_matches,
- variable_list);
+ module_sp->FindGlobalVariables(ConstString(name), CompilerDeclContext(),
+ max_matches, variable_list);
for (const VariableSP &var_sp : variable_list) {
lldb::ValueObjectSP valobj_sp;
TargetSP target_sp(target.GetSP());
@@ -683,6 +683,13 @@ lldb::SBAddress SBModule::GetObjectFileEntryPointAddress() const {
return LLDB_RECORD_RESULT(sb_addr);
}
+uint32_t SBModule::GetNumberAllocatedModules() {
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(uint32_t, SBModule,
+ GetNumberAllocatedModules);
+
+ return Module::GetNumberAllocatedModules();
+}
+
namespace lldb_private {
namespace repro {
@@ -757,6 +764,8 @@ void RegisterMethods<SBModule>(Registry &R) {
GetObjectFileHeaderAddress, ());
LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule,
GetObjectFileEntryPointAddress, ());
+ LLDB_REGISTER_STATIC_METHOD(uint32_t, SBModule, GetNumberAllocatedModules,
+ ());
}
}
diff --git a/lldb/source/API/SBModuleSpec.cpp b/lldb/source/API/SBModuleSpec.cpp
index a5e9ad26fac1..5d88272a399b 100644
--- a/lldb/source/API/SBModuleSpec.cpp
+++ b/lldb/source/API/SBModuleSpec.cpp
@@ -1,4 +1,4 @@
-//===-- SBModuleSpec.cpp ----------------------------------------*- C++ -*-===//
+//===-- SBModuleSpec.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -38,7 +38,7 @@ const SBModuleSpec &SBModuleSpec::operator=(const SBModuleSpec &rhs) {
return LLDB_RECORD_RESULT(*this);
}
-SBModuleSpec::~SBModuleSpec() {}
+SBModuleSpec::~SBModuleSpec() = default;
bool SBModuleSpec::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModuleSpec, IsValid);
@@ -169,7 +169,7 @@ SBModuleSpecList &SBModuleSpecList::operator=(const SBModuleSpecList &rhs) {
return LLDB_RECORD_RESULT(*this);
}
-SBModuleSpecList::~SBModuleSpecList() {}
+SBModuleSpecList::~SBModuleSpecList() = default;
SBModuleSpecList SBModuleSpecList::GetModuleSpecifications(const char *path) {
LLDB_RECORD_STATIC_METHOD(lldb::SBModuleSpecList, SBModuleSpecList,
diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp
index f3708d8e084f..7ac852488ffb 100644
--- a/lldb/source/API/SBPlatform.cpp
+++ b/lldb/source/API/SBPlatform.cpp
@@ -1,4 +1,4 @@
-//===-- SBPlatform.cpp ------------------------------------------*- C++ -*-===//
+//===-- SBPlatform.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,9 +8,11 @@
#include "lldb/API/SBPlatform.h"
#include "SBReproducerPrivate.h"
+#include "lldb/API/SBEnvironment.h"
#include "lldb/API/SBError.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBLaunchInfo.h"
+#include "lldb/API/SBPlatform.h"
#include "lldb/API/SBUnixSignals.h"
#include "lldb/Host/File.h"
#include "lldb/Target/Platform.h"
@@ -36,7 +38,7 @@ struct PlatformConnectOptions {
m_url = url;
}
- ~PlatformConnectOptions() {}
+ ~PlatformConnectOptions() = default;
std::string m_url;
std::string m_rsync_options;
@@ -54,7 +56,7 @@ struct PlatformShellCommand {
m_command = shell_command;
}
- ~PlatformShellCommand() {}
+ ~PlatformShellCommand() = default;
std::string m_command;
std::string m_working_dir;
@@ -80,14 +82,16 @@ SBPlatformConnectOptions::SBPlatformConnectOptions(
SBPlatformConnectOptions::~SBPlatformConnectOptions() { delete m_opaque_ptr; }
-void SBPlatformConnectOptions::operator=(const SBPlatformConnectOptions &rhs) {
+SBPlatformConnectOptions &SBPlatformConnectOptions::
+operator=(const SBPlatformConnectOptions &rhs) {
LLDB_RECORD_METHOD(
- void,
+ SBPlatformConnectOptions &,
SBPlatformConnectOptions, operator=,(
const lldb::SBPlatformConnectOptions &),
rhs);
*m_opaque_ptr = *rhs.m_opaque_ptr;
+ return LLDB_RECORD_RESULT(*this);
}
const char *SBPlatformConnectOptions::GetURL() {
@@ -174,6 +178,18 @@ SBPlatformShellCommand::SBPlatformShellCommand(
*m_opaque_ptr = *rhs.m_opaque_ptr;
}
+SBPlatformShellCommand &SBPlatformShellCommand::
+operator=(const SBPlatformShellCommand &rhs) {
+
+ LLDB_RECORD_METHOD(
+ SBPlatformShellCommand &,
+ SBPlatformShellCommand, operator=,(const lldb::SBPlatformShellCommand &),
+ rhs);
+
+ *m_opaque_ptr = *rhs.m_opaque_ptr;
+ return LLDB_RECORD_RESULT(*this);
+}
+
SBPlatformShellCommand::~SBPlatformShellCommand() { delete m_opaque_ptr; }
void SBPlatformShellCommand::Clear() {
@@ -273,7 +289,30 @@ SBPlatform::SBPlatform(const char *platform_name) : m_opaque_sp() {
m_opaque_sp = Platform::Create(ConstString(platform_name), error);
}
-SBPlatform::~SBPlatform() {}
+SBPlatform::SBPlatform(const SBPlatform &rhs) {
+ LLDB_RECORD_CONSTRUCTOR(SBPlatform, (const lldb::SBPlatform &), rhs);
+
+ m_opaque_sp = rhs.m_opaque_sp;
+}
+
+SBPlatform &SBPlatform::operator=(const SBPlatform &rhs) {
+ LLDB_RECORD_METHOD(SBPlatform &,
+ SBPlatform, operator=,(const lldb::SBPlatform &), rhs);
+
+ m_opaque_sp = rhs.m_opaque_sp;
+ return LLDB_RECORD_RESULT(*this);
+}
+
+SBPlatform::~SBPlatform() = default;
+
+SBPlatform SBPlatform::GetHostPlatform() {
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBPlatform, SBPlatform,
+ GetHostPlatform);
+
+ SBPlatform host_platform;
+ host_platform.m_opaque_sp = Platform::GetHostPlatform();
+ return LLDB_RECORD_RESULT(host_platform);
+}
bool SBPlatform::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBPlatform, IsValid);
@@ -615,6 +654,17 @@ SBUnixSignals SBPlatform::GetUnixSignals() const {
return LLDB_RECORD_RESULT(SBUnixSignals());
}
+SBEnvironment SBPlatform::GetEnvironment() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBEnvironment, SBPlatform, GetEnvironment);
+ PlatformSP platform_sp(GetSP());
+
+ if (platform_sp) {
+ return LLDB_RECORD_RESULT(SBEnvironment(platform_sp->GetEnvironment()));
+ }
+
+ return LLDB_RECORD_RESULT(SBEnvironment());
+}
+
namespace lldb_private {
namespace repro {
@@ -624,7 +674,7 @@ void RegisterMethods<SBPlatformConnectOptions>(Registry &R) {
LLDB_REGISTER_CONSTRUCTOR(SBPlatformConnectOptions,
(const lldb::SBPlatformConnectOptions &));
LLDB_REGISTER_METHOD(
- void,
+ SBPlatformConnectOptions &,
SBPlatformConnectOptions, operator=,(
const lldb::SBPlatformConnectOptions &));
LLDB_REGISTER_METHOD(const char *, SBPlatformConnectOptions, GetURL, ());
@@ -645,6 +695,9 @@ void RegisterMethods<SBPlatformShellCommand>(Registry &R) {
LLDB_REGISTER_CONSTRUCTOR(SBPlatformShellCommand, (const char *));
LLDB_REGISTER_CONSTRUCTOR(SBPlatformShellCommand,
(const lldb::SBPlatformShellCommand &));
+ LLDB_REGISTER_METHOD(
+ SBPlatformShellCommand &,
+ SBPlatformShellCommand, operator=,(const lldb::SBPlatformShellCommand &));
LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, Clear, ());
LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand, GetCommand, ());
LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetCommand,
@@ -666,6 +719,9 @@ template <>
void RegisterMethods<SBPlatform>(Registry &R) {
LLDB_REGISTER_CONSTRUCTOR(SBPlatform, ());
LLDB_REGISTER_CONSTRUCTOR(SBPlatform, (const char *));
+ LLDB_REGISTER_CONSTRUCTOR(SBPlatform, (const lldb::SBPlatform &));
+ LLDB_REGISTER_METHOD(SBPlatform &,
+ SBPlatform, operator=,(const lldb::SBPlatform &));
LLDB_REGISTER_METHOD_CONST(bool, SBPlatform, IsValid, ());
LLDB_REGISTER_METHOD_CONST(bool, SBPlatform, operator bool, ());
LLDB_REGISTER_METHOD(void, SBPlatform, Clear, ());
@@ -700,8 +756,11 @@ void RegisterMethods<SBPlatform>(Registry &R) {
(const char *));
LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, SetFilePermissions,
(const char *, uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBEnvironment, SBPlatform, GetEnvironment, ());
LLDB_REGISTER_METHOD_CONST(lldb::SBUnixSignals, SBPlatform, GetUnixSignals,
());
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBPlatform, SBPlatform, GetHostPlatform,
+ ());
}
}
diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp
index 45aaa0bd2d8a..d7b7fd7cacad 100644
--- a/lldb/source/API/SBProcess.cpp
+++ b/lldb/source/API/SBProcess.cpp
@@ -1,4 +1,4 @@
-//===-- SBProcess.cpp -------------------------------------------*- C++ -*-===//
+//===-- SBProcess.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -18,6 +18,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/StreamFile.h"
+#include "lldb/Core/StructuredDataImpl.h"
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
@@ -74,7 +75,7 @@ const SBProcess &SBProcess::operator=(const SBProcess &rhs) {
}
// Destructor
-SBProcess::~SBProcess() {}
+SBProcess::~SBProcess() = default;
const char *SBProcess::GetBroadcasterClassName() {
LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBProcess,
@@ -270,8 +271,8 @@ size_t SBProcess::PutSTDIN(const char *src, size_t src_len) {
}
size_t SBProcess::GetSTDOUT(char *dst, size_t dst_len) const {
- LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetSTDOUT, (char *, size_t), dst,
- dst_len);
+ LLDB_RECORD_CHAR_PTR_METHOD_CONST(size_t, SBProcess, GetSTDOUT,
+ (char *, size_t), dst, "", dst_len);
size_t bytes_read = 0;
ProcessSP process_sp(GetSP());
@@ -284,8 +285,8 @@ size_t SBProcess::GetSTDOUT(char *dst, size_t dst_len) const {
}
size_t SBProcess::GetSTDERR(char *dst, size_t dst_len) const {
- LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetSTDERR, (char *, size_t), dst,
- dst_len);
+ LLDB_RECORD_CHAR_PTR_METHOD_CONST(size_t, SBProcess, GetSTDERR,
+ (char *, size_t), dst, "", dst_len);
size_t bytes_read = 0;
ProcessSP process_sp(GetSP());
@@ -298,8 +299,8 @@ size_t SBProcess::GetSTDERR(char *dst, size_t dst_len) const {
}
size_t SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const {
- LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetAsyncProfileData,
- (char *, size_t), dst, dst_len);
+ LLDB_RECORD_CHAR_PTR_METHOD_CONST(size_t, SBProcess, GetAsyncProfileData,
+ (char *, size_t), dst, "", dst_len);
size_t bytes_read = 0;
ProcessSP process_sp(GetSP());
@@ -1010,6 +1011,30 @@ bool SBProcess::GetDescription(SBStream &description) {
return true;
}
+SBStructuredData SBProcess::GetExtendedCrashInformation() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBStructuredData, SBProcess,
+ GetExtendedCrashInformation);
+ SBStructuredData data;
+ ProcessSP process_sp(GetSP());
+ if (!process_sp)
+ return LLDB_RECORD_RESULT(data);
+
+ PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
+
+ if (!platform_sp)
+ return LLDB_RECORD_RESULT(data);
+
+ auto expected_data =
+ platform_sp->FetchExtendedCrashInformation(*process_sp.get());
+
+ if (!expected_data)
+ return LLDB_RECORD_RESULT(data);
+
+ StructuredData::ObjectSP fetched_data = *expected_data;
+ data.m_impl_up->SetObjectSP(fetched_data);
+ return LLDB_RECORD_RESULT(data);
+}
+
uint32_t
SBProcess::GetNumSupportedHardwareWatchpoints(lldb::SBError &sb_error) const {
LLDB_RECORD_METHOD_CONST(uint32_t, SBProcess,
@@ -1313,10 +1338,6 @@ void RegisterMethods<SBProcess>(Registry &R) {
(lldb::tid_t, lldb::addr_t));
LLDB_REGISTER_METHOD_CONST(lldb::SBTarget, SBProcess, GetTarget, ());
LLDB_REGISTER_METHOD(size_t, SBProcess, PutSTDIN, (const char *, size_t));
- LLDB_REGISTER_METHOD_CONST(size_t, SBProcess, GetSTDOUT, (char *, size_t));
- LLDB_REGISTER_METHOD_CONST(size_t, SBProcess, GetSTDERR, (char *, size_t));
- LLDB_REGISTER_METHOD_CONST(size_t, SBProcess, GetAsyncProfileData,
- (char *, size_t));
LLDB_REGISTER_METHOD(lldb::SBTrace, SBProcess, StartTrace,
(lldb::SBTraceOptions &, lldb::SBError &));
LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState,
@@ -1389,6 +1410,8 @@ void RegisterMethods<SBProcess>(Registry &R) {
LLDB_REGISTER_METHOD(lldb::addr_t, SBProcess, ReadPointerFromMemory,
(lldb::addr_t, lldb::SBError &));
LLDB_REGISTER_METHOD(bool, SBProcess, GetDescription, (lldb::SBStream &));
+ LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBProcess,
+ GetExtendedCrashInformation, ());
LLDB_REGISTER_METHOD_CONST(uint32_t, SBProcess,
GetNumSupportedHardwareWatchpoints,
(lldb::SBError &));
@@ -1416,6 +1439,10 @@ void RegisterMethods<SBProcess>(Registry &R) {
LLDB_REGISTER_METHOD(lldb::SBMemoryRegionInfoList, SBProcess,
GetMemoryRegions, ());
LLDB_REGISTER_METHOD(lldb::SBProcessInfo, SBProcess, GetProcessInfo, ());
+
+ LLDB_REGISTER_CHAR_PTR_METHOD_CONST(size_t, SBProcess, GetSTDOUT);
+ LLDB_REGISTER_CHAR_PTR_METHOD_CONST(size_t, SBProcess, GetSTDERR);
+ LLDB_REGISTER_CHAR_PTR_METHOD_CONST(size_t, SBProcess, GetAsyncProfileData);
}
}
diff --git a/lldb/source/API/SBProcessInfo.cpp b/lldb/source/API/SBProcessInfo.cpp
index be242ec5872d..29a9c7b24b5a 100644
--- a/lldb/source/API/SBProcessInfo.cpp
+++ b/lldb/source/API/SBProcessInfo.cpp
@@ -1,4 +1,4 @@
-//===-- SBProcessInfo.cpp ---------------------------------------*- C++ -*-===//
+//===-- SBProcessInfo.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -25,7 +25,7 @@ SBProcessInfo::SBProcessInfo(const SBProcessInfo &rhs) : m_opaque_up() {
m_opaque_up = clone(rhs.m_opaque_up);
}
-SBProcessInfo::~SBProcessInfo() {}
+SBProcessInfo::~SBProcessInfo() = default;
SBProcessInfo &SBProcessInfo::operator=(const SBProcessInfo &rhs) {
LLDB_RECORD_METHOD(lldb::SBProcessInfo &,
@@ -39,7 +39,7 @@ SBProcessInfo &SBProcessInfo::operator=(const SBProcessInfo &rhs) {
ProcessInstanceInfo &SBProcessInfo::ref() {
if (m_opaque_up == nullptr) {
- m_opaque_up.reset(new ProcessInstanceInfo());
+ m_opaque_up = std::make_unique<ProcessInstanceInfo>();
}
return *m_opaque_up;
}
diff --git a/lldb/source/API/SBQueue.cpp b/lldb/source/API/SBQueue.cpp
index 7d1581c42f60..2e6571392ea1 100644
--- a/lldb/source/API/SBQueue.cpp
+++ b/lldb/source/API/SBQueue.cpp
@@ -1,4 +1,4 @@
-//===-- SBQueue.cpp ---------------------------------------------*- C++ -*-===//
+//===-- SBQueue.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -47,7 +47,7 @@ public:
m_pending_items_fetched = rhs.m_pending_items_fetched;
}
- ~QueueImpl() {}
+ ~QueueImpl() = default;
bool IsValid() { return m_queue_wp.lock() != nullptr; }
@@ -243,7 +243,7 @@ const lldb::SBQueue &SBQueue::operator=(const lldb::SBQueue &rhs) {
return LLDB_RECORD_RESULT(*this);
}
-SBQueue::~SBQueue() {}
+SBQueue::~SBQueue() = default;
bool SBQueue::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBQueue, IsValid);
diff --git a/lldb/source/API/SBQueueItem.cpp b/lldb/source/API/SBQueueItem.cpp
index 5f2cbd1bdbfb..0f92e2e04126 100644
--- a/lldb/source/API/SBQueueItem.cpp
+++ b/lldb/source/API/SBQueueItem.cpp
@@ -1,4 +1,4 @@
-//===-- SBQueueItem.cpp -----------------------------------------*- C++ -*-===//
+//===-- SBQueueItem.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/API/SBReproducer.cpp b/lldb/source/API/SBReproducer.cpp
index 3d2de0727444..0eb3429c4fef 100644
--- a/lldb/source/API/SBReproducer.cpp
+++ b/lldb/source/API/SBReproducer.cpp
@@ -1,4 +1,4 @@
-//===-- SBReproducer.cpp ----------------------------------------*- C++ -*-===//
+//===-- SBReproducer.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -15,6 +15,7 @@
#include "lldb/API/SBBlock.h"
#include "lldb/API/SBBreakpoint.h"
#include "lldb/API/SBCommandInterpreter.h"
+#include "lldb/API/SBCommandInterpreterRunOptions.h"
#include "lldb/API/SBData.h"
#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBDeclaration.h"
@@ -40,14 +41,15 @@ SBRegistry::SBRegistry() {
RegisterMethods<SBBreakpointLocation>(R);
RegisterMethods<SBBreakpointName>(R);
RegisterMethods<SBBroadcaster>(R);
+ RegisterMethods<SBCommandInterpreter>(R);
RegisterMethods<SBCommandInterpreterRunOptions>(R);
RegisterMethods<SBCommandReturnObject>(R);
RegisterMethods<SBCommunication>(R);
RegisterMethods<SBCompileUnit>(R);
RegisterMethods<SBData>(R);
- RegisterMethods<SBInputReader>(R);
RegisterMethods<SBDebugger>(R);
RegisterMethods<SBDeclaration>(R);
+ RegisterMethods<SBEnvironment>(R);
RegisterMethods<SBError>(R);
RegisterMethods<SBEvent>(R);
RegisterMethods<SBExecutionContext>(R);
@@ -58,6 +60,7 @@ SBRegistry::SBRegistry() {
RegisterMethods<SBFrame>(R);
RegisterMethods<SBFunction>(R);
RegisterMethods<SBHostOS>(R);
+ RegisterMethods<SBInputReader>(R);
RegisterMethods<SBInstruction>(R);
RegisterMethods<SBInstructionList>(R);
RegisterMethods<SBLanguageRuntime>(R);
@@ -68,9 +71,9 @@ SBRegistry::SBRegistry() {
RegisterMethods<SBMemoryRegionInfoList>(R);
RegisterMethods<SBModule>(R);
RegisterMethods<SBModuleSpec>(R);
+ RegisterMethods<SBPlatform>(R);
RegisterMethods<SBPlatformConnectOptions>(R);
RegisterMethods<SBPlatformShellCommand>(R);
- RegisterMethods<SBPlatform>(R);
RegisterMethods<SBProcess>(R);
RegisterMethods<SBProcessInfo>(R);
RegisterMethods<SBQueue>(R);
@@ -95,8 +98,8 @@ SBRegistry::SBRegistry() {
RegisterMethods<SBTypeFilter>(R);
RegisterMethods<SBTypeFormat>(R);
RegisterMethods<SBTypeNameSpecifier>(R);
- RegisterMethods<SBTypeSummaryOptions>(R);
RegisterMethods<SBTypeSummary>(R);
+ RegisterMethods<SBTypeSummaryOptions>(R);
RegisterMethods<SBTypeSynthetic>(R);
RegisterMethods<SBUnixSignals>(R);
RegisterMethods<SBValue>(R);
@@ -111,6 +114,12 @@ const char *SBReproducer::Capture() {
error = llvm::toString(std::move(e));
return error.c_str();
}
+
+ if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) {
+ auto &p = g->GetOrCreate<SBProvider>();
+ InstrumentationData::Initialize(p.GetSerializer(), p.GetRegistry());
+ }
+
return nullptr;
}
@@ -121,6 +130,35 @@ const char *SBReproducer::Capture(const char *path) {
error = llvm::toString(std::move(e));
return error.c_str();
}
+
+ if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) {
+ auto &p = g->GetOrCreate<SBProvider>();
+ InstrumentationData::Initialize(p.GetSerializer(), p.GetRegistry());
+ }
+
+ return nullptr;
+}
+
+const char *SBReproducer::PassiveReplay(const char *path) {
+ static std::string error;
+ if (auto e = Reproducer::Initialize(ReproducerMode::PassiveReplay,
+ FileSpec(path))) {
+ error = llvm::toString(std::move(e));
+ return error.c_str();
+ }
+
+ if (auto *l = lldb_private::repro::Reproducer::Instance().GetLoader()) {
+ FileSpec file = l->GetFile<SBProvider::Info>();
+ auto error_or_file = llvm::MemoryBuffer::getFile(file.GetPath());
+ if (!error_or_file) {
+ error =
+ "unable to read SB API data: " + error_or_file.getError().message();
+ return error.c_str();
+ }
+ static ReplayData r(std::move(*error_or_file));
+ InstrumentationData::Initialize(r.GetDeserializer(), r.GetRegistry());
+ }
+
return nullptr;
}
@@ -178,6 +216,15 @@ bool SBReproducer::Generate() {
return false;
}
+bool SBReproducer::SetAutoGenerate(bool b) {
+ auto &r = Reproducer::Instance();
+ if (auto generator = r.GetGenerator()) {
+ generator->SetAutoGenerate(b);
+ return true;
+ }
+ return false;
+}
+
const char *SBReproducer::GetPath() {
static std::string path;
auto &r = Reproducer::Instance();
@@ -185,6 +232,12 @@ const char *SBReproducer::GetPath() {
return path.c_str();
}
+void SBReproducer::SetWorkingDirectory(const char *path) {
+ if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) {
+ g->GetOrCreate<WorkingDirectoryProvider>().Update(path);
+ }
+}
+
char lldb_private::repro::SBProvider::ID = 0;
const char *SBProvider::Info::name = "sbapi";
const char *SBProvider::Info::file = "sbapi.bin";
diff --git a/lldb/source/API/SBReproducerPrivate.h b/lldb/source/API/SBReproducerPrivate.h
index edd06941398f..a4c6eb94627b 100644
--- a/lldb/source/API/SBReproducerPrivate.h
+++ b/lldb/source/API/SBReproducerPrivate.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_API_SBREPRODUCER_PRIVATE_H
-#define LLDB_API_SBREPRODUCER_PRIVATE_H
+#ifndef LLDB_SOURCE_API_SBREPRODUCERPRIVATE_H
+#define LLDB_SOURCE_API_SBREPRODUCERPRIVATE_H
#include "lldb/API/SBReproducer.h"
@@ -20,7 +20,7 @@
#include "llvm/ADT/DenseMap.h"
#define LLDB_GET_INSTRUMENTATION_DATA() \
- lldb_private::repro::GetInstrumentationData()
+ lldb_private::repro::InstrumentationData::Instance()
namespace lldb_private {
namespace repro {
@@ -55,17 +55,19 @@ private:
SBRegistry m_registry;
};
-inline InstrumentationData GetInstrumentationData() {
- if (!lldb_private::repro::Reproducer::Initialized())
- return {};
-
- if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) {
- auto &p = g->GetOrCreate<SBProvider>();
- return {p.GetSerializer(), p.GetRegistry()};
- }
+class ReplayData {
+public:
+ ReplayData(std::unique_ptr<llvm::MemoryBuffer> memory_buffer)
+ : m_memory_buffer(std::move(memory_buffer)), m_registry(),
+ m_deserializer(m_memory_buffer->getBuffer()) {}
+ Deserializer &GetDeserializer() { return m_deserializer; }
+ Registry &GetRegistry() { return m_registry; }
- return {};
-}
+private:
+ std::unique_ptr<llvm::MemoryBuffer> m_memory_buffer;
+ SBRegistry m_registry;
+ Deserializer m_deserializer;
+};
template <typename T> void RegisterMethods(Registry &R);
diff --git a/lldb/source/API/SBSection.cpp b/lldb/source/API/SBSection.cpp
index 14e1e14f59aa..bb56fa18d9ca 100644
--- a/lldb/source/API/SBSection.cpp
+++ b/lldb/source/API/SBSection.cpp
@@ -1,4 +1,4 @@
-//===-- SBSection.cpp -------------------------------------------*- C++ -*-===//
+//===-- SBSection.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -44,7 +44,7 @@ const SBSection &SBSection::operator=(const SBSection &rhs) {
return LLDB_RECORD_RESULT(*this);
}
-SBSection::~SBSection() {}
+SBSection::~SBSection() = default;
bool SBSection::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSection, IsValid);
@@ -281,7 +281,7 @@ bool SBSection::GetDescription(SBStream &description) {
const addr_t file_addr = section_sp->GetFileAddress();
strm.Printf("[0x%16.16" PRIx64 "-0x%16.16" PRIx64 ") ", file_addr,
file_addr + section_sp->GetByteSize());
- section_sp->DumpName(&strm);
+ section_sp->DumpName(strm.AsRawOstream());
} else {
strm.PutCString("No value");
}
diff --git a/lldb/source/API/SBSourceManager.cpp b/lldb/source/API/SBSourceManager.cpp
index 9c4ce3c7f4e3..43c3443672f7 100644
--- a/lldb/source/API/SBSourceManager.cpp
+++ b/lldb/source/API/SBSourceManager.cpp
@@ -1,4 +1,4 @@
-//===-- SBSourceManager.cpp -------------------------------------*- C++ -*-===//
+//===-- SBSourceManager.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -75,13 +75,13 @@ SBSourceManager::SBSourceManager(const SBDebugger &debugger) {
LLDB_RECORD_CONSTRUCTOR(SBSourceManager, (const lldb::SBDebugger &),
debugger);
- m_opaque_up.reset(new SourceManagerImpl(debugger.get_sp()));
+ m_opaque_up = std::make_unique<SourceManagerImpl>(debugger.get_sp());
}
SBSourceManager::SBSourceManager(const SBTarget &target) {
LLDB_RECORD_CONSTRUCTOR(SBSourceManager, (const lldb::SBTarget &), target);
- m_opaque_up.reset(new SourceManagerImpl(target.GetSP()));
+ m_opaque_up = std::make_unique<SourceManagerImpl>(target.GetSP());
}
SBSourceManager::SBSourceManager(const SBSourceManager &rhs) {
@@ -91,7 +91,7 @@ SBSourceManager::SBSourceManager(const SBSourceManager &rhs) {
if (&rhs == this)
return;
- m_opaque_up.reset(new SourceManagerImpl(*(rhs.m_opaque_up.get())));
+ m_opaque_up = std::make_unique<SourceManagerImpl>(*(rhs.m_opaque_up.get()));
}
const lldb::SBSourceManager &SBSourceManager::
@@ -100,11 +100,11 @@ operator=(const lldb::SBSourceManager &rhs) {
SBSourceManager, operator=,(const lldb::SBSourceManager &),
rhs);
- m_opaque_up.reset(new SourceManagerImpl(*(rhs.m_opaque_up.get())));
+ m_opaque_up = std::make_unique<SourceManagerImpl>(*(rhs.m_opaque_up.get()));
return LLDB_RECORD_RESULT(*this);
}
-SBSourceManager::~SBSourceManager() {}
+SBSourceManager::~SBSourceManager() = default;
size_t SBSourceManager::DisplaySourceLinesWithLineNumbers(
const SBFileSpec &file, uint32_t line, uint32_t context_before,
diff --git a/lldb/source/API/SBStream.cpp b/lldb/source/API/SBStream.cpp
index d57634d2947c..eb81153084e8 100644
--- a/lldb/source/API/SBStream.cpp
+++ b/lldb/source/API/SBStream.cpp
@@ -1,4 +1,4 @@
-//===-- SBStream.cpp ----------------------------------------*- C++ -*-===//
+//===-- SBStream.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -26,7 +26,7 @@ SBStream::SBStream() : m_opaque_up(new StreamString()), m_is_file(false) {
SBStream::SBStream(SBStream &&rhs)
: m_opaque_up(std::move(rhs.m_opaque_up)), m_is_file(rhs.m_is_file) {}
-SBStream::~SBStream() {}
+SBStream::~SBStream() = default;
bool SBStream::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStream, IsValid);
@@ -60,6 +60,12 @@ size_t SBStream::GetSize() {
return static_cast<StreamString *>(m_opaque_up.get())->GetSize();
}
+void SBStream::Print(const char *str) {
+ LLDB_RECORD_METHOD(void, SBStream, Print, (const char *), str);
+
+ Printf("%s", str);
+}
+
void SBStream::Printf(const char *format, ...) {
if (!format)
return;
@@ -81,7 +87,8 @@ void SBStream::RedirectToFile(const char *path, bool append) {
// See if we have any locally backed data. If so, copy it so we can then
// redirect it to the file so we don't lose the data
if (!m_is_file)
- local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString();
+ local_data = std::string(
+ static_cast<StreamString *>(m_opaque_up.get())->GetString());
}
auto open_options = File::eOpenOptionWrite | File::eOpenOptionCanCreate;
if (append)
@@ -129,7 +136,8 @@ void SBStream::RedirectToFile(FileSP file_sp) {
// See if we have any locally backed data. If so, copy it so we can then
// redirect it to the file so we don't lose the data
if (!m_is_file)
- local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString();
+ local_data = std::string(
+ static_cast<StreamString *>(m_opaque_up.get())->GetString());
}
m_opaque_up = std::make_unique<StreamFile>(file_sp);
@@ -150,7 +158,8 @@ void SBStream::RedirectToFileDescriptor(int fd, bool transfer_fh_ownership) {
// See if we have any locally backed data. If so, copy it so we can then
// redirect it to the file so we don't lose the data
if (!m_is_file)
- local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString();
+ local_data = std::string(
+ static_cast<StreamString *>(m_opaque_up.get())->GetString());
}
m_opaque_up = std::make_unique<StreamFile>(fd, transfer_fh_ownership);
@@ -168,7 +177,7 @@ lldb_private::Stream *SBStream::get() { return m_opaque_up.get(); }
lldb_private::Stream &SBStream::ref() {
if (m_opaque_up == nullptr)
- m_opaque_up.reset(new StreamString());
+ m_opaque_up = std::make_unique<StreamString>();
return *m_opaque_up;
}
@@ -201,6 +210,7 @@ void RegisterMethods<SBStream>(Registry &R) {
LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileHandle, (FILE *, bool));
LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileDescriptor, (int, bool));
LLDB_REGISTER_METHOD(void, SBStream, Clear, ());
+ LLDB_REGISTER_METHOD(void, SBStream, Print, (const char *));
}
}
diff --git a/lldb/source/API/SBStringList.cpp b/lldb/source/API/SBStringList.cpp
index ac07b8faac4d..d9b03692ec0e 100644
--- a/lldb/source/API/SBStringList.cpp
+++ b/lldb/source/API/SBStringList.cpp
@@ -1,4 +1,4 @@
-//===-- SBStringList.cpp ----------------------------------------*- C++ -*-===//
+//===-- SBStringList.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -39,7 +39,7 @@ const SBStringList &SBStringList::operator=(const SBStringList &rhs) {
return LLDB_RECORD_RESULT(*this);
}
-SBStringList::~SBStringList() {}
+SBStringList::~SBStringList() = default;
const lldb_private::StringList *SBStringList::operator->() const {
return m_opaque_up.get();
@@ -66,7 +66,7 @@ void SBStringList::AppendString(const char *str) {
if (IsValid())
m_opaque_up->AppendString(str);
else
- m_opaque_up.reset(new lldb_private::StringList(str));
+ m_opaque_up = std::make_unique<lldb_private::StringList>(str);
}
}
@@ -78,7 +78,7 @@ void SBStringList::AppendList(const char **strv, int strc) {
if (IsValid())
m_opaque_up->AppendList(strv, strc);
else
- m_opaque_up.reset(new lldb_private::StringList(strv, strc));
+ m_opaque_up = std::make_unique<lldb_private::StringList>(strv, strc);
}
}
@@ -88,14 +88,14 @@ void SBStringList::AppendList(const SBStringList &strings) {
if (strings.IsValid()) {
if (!IsValid())
- m_opaque_up.reset(new lldb_private::StringList());
+ m_opaque_up = std::make_unique<lldb_private::StringList>();
m_opaque_up->AppendList(*(strings.m_opaque_up));
}
}
void SBStringList::AppendList(const StringList &strings) {
if (!IsValid())
- m_opaque_up.reset(new lldb_private::StringList());
+ m_opaque_up = std::make_unique<lldb_private::StringList>();
m_opaque_up->AppendList(strings);
}
diff --git a/lldb/source/API/SBStructuredData.cpp b/lldb/source/API/SBStructuredData.cpp
index 6b973e82c858..2ae3005fd8d1 100644
--- a/lldb/source/API/SBStructuredData.cpp
+++ b/lldb/source/API/SBStructuredData.cpp
@@ -1,4 +1,4 @@
-//===-- SBStructuredData.cpp ------------------------------------*- C++ -*-===//
+//===-- SBStructuredData.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -45,7 +45,7 @@ SBStructuredData::SBStructuredData(lldb_private::StructuredDataImpl *impl)
(lldb_private::StructuredDataImpl *), impl);
}
-SBStructuredData::~SBStructuredData() {}
+SBStructuredData::~SBStructuredData() = default;
SBStructuredData &SBStructuredData::
operator=(const lldb::SBStructuredData &rhs) {
@@ -126,10 +126,10 @@ bool SBStructuredData::GetKeys(lldb::SBStringList &keys) const {
if (!m_impl_up)
return false;
-
+
if (GetType() != eStructuredDataTypeDictionary)
return false;
-
+
StructuredData::ObjectSP obj_sp = m_impl_up->GetObjectSP();
if (!obj_sp)
return false;
@@ -141,7 +141,7 @@ bool SBStructuredData::GetKeys(lldb::SBStringList &keys) const {
StructuredData::ObjectSP array_sp = dict->GetKeys();
StructuredData::Array *key_arr = array_sp->GetAsArray();
assert(key_arr);
-
+
key_arr->ForEach([&keys] (StructuredData::Object *object) -> bool {
llvm::StringRef key = object->GetStringValue("");
keys.AppendString(key.str().c_str());
@@ -196,8 +196,8 @@ bool SBStructuredData::GetBooleanValue(bool fail_value) const {
}
size_t SBStructuredData::GetStringValue(char *dst, size_t dst_len) const {
- LLDB_RECORD_METHOD_CONST(size_t, SBStructuredData, GetStringValue,
- (char *, size_t), dst, dst_len);
+ LLDB_RECORD_CHAR_PTR_METHOD_CONST(size_t, SBStructuredData, GetStringValue,
+ (char *, size_t), dst, "", dst_len);
return (m_impl_up ? m_impl_up->GetStringValue(dst, dst_len) : 0);
}
@@ -205,11 +205,9 @@ size_t SBStructuredData::GetStringValue(char *dst, size_t dst_len) const {
namespace lldb_private {
namespace repro {
-template <>
-void RegisterMethods<SBStructuredData>(Registry &R) {
+template <> void RegisterMethods<SBStructuredData>(Registry &R) {
LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, ());
- LLDB_REGISTER_CONSTRUCTOR(SBStructuredData,
- (const lldb::SBStructuredData &));
+ LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, (const lldb::SBStructuredData &));
LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, (const lldb::EventSP &));
LLDB_REGISTER_CONSTRUCTOR(SBStructuredData,
(lldb_private::StructuredDataImpl *));
@@ -236,12 +234,10 @@ void RegisterMethods<SBStructuredData>(Registry &R) {
GetItemAtIndex, (size_t));
LLDB_REGISTER_METHOD_CONST(uint64_t, SBStructuredData, GetIntegerValue,
(uint64_t));
- LLDB_REGISTER_METHOD_CONST(double, SBStructuredData, GetFloatValue,
- (double));
+ LLDB_REGISTER_METHOD_CONST(double, SBStructuredData, GetFloatValue, (double));
LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, GetBooleanValue, (bool));
- LLDB_REGISTER_METHOD_CONST(size_t, SBStructuredData, GetStringValue,
- (char *, size_t));
+ LLDB_REGISTER_CHAR_PTR_METHOD_CONST(size_t, SBStructuredData, GetStringValue);
}
-}
-}
+} // namespace repro
+} // namespace lldb_private
diff --git a/lldb/source/API/SBSymbol.cpp b/lldb/source/API/SBSymbol.cpp
index 6cc90e0ee368..e4f2f3518270 100644
--- a/lldb/source/API/SBSymbol.cpp
+++ b/lldb/source/API/SBSymbol.cpp
@@ -1,4 +1,4 @@
-//===-- SBSymbol.cpp --------------------------------------------*- C++ -*-===//
+//===-- SBSymbol.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -68,9 +68,7 @@ const char *SBSymbol::GetDisplayName() const {
const char *name = nullptr;
if (m_opaque_ptr)
- name = m_opaque_ptr->GetMangled()
- .GetDisplayDemangledName(m_opaque_ptr->GetLanguage())
- .AsCString();
+ name = m_opaque_ptr->GetMangled().GetDisplayDemangledName().AsCString();
return name;
}
@@ -126,22 +124,17 @@ SBInstructionList SBSymbol::GetInstructions(SBTarget target,
SBInstructionList sb_instructions;
if (m_opaque_ptr) {
- ExecutionContext exe_ctx;
TargetSP target_sp(target.GetSP());
std::unique_lock<std::recursive_mutex> lock;
- if (target_sp) {
+ if (target_sp && m_opaque_ptr->ValueIsAddress()) {
lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
-
- target_sp->CalculateExecutionContext(exe_ctx);
- }
- if (m_opaque_ptr->ValueIsAddress()) {
const Address &symbol_addr = m_opaque_ptr->GetAddressRef();
ModuleSP module_sp = symbol_addr.GetModule();
if (module_sp) {
AddressRange symbol_range(symbol_addr, m_opaque_ptr->GetByteSize());
const bool prefer_file_cache = false;
sb_instructions.SetDisassembler(Disassembler::DisassembleRange(
- module_sp->GetArchitecture(), nullptr, flavor_string, exe_ctx,
+ module_sp->GetArchitecture(), nullptr, flavor_string, *target_sp,
symbol_range, prefer_file_cache));
}
}
diff --git a/lldb/source/API/SBSymbolContext.cpp b/lldb/source/API/SBSymbolContext.cpp
index 6e01e5535c32..488d49884903 100644
--- a/lldb/source/API/SBSymbolContext.cpp
+++ b/lldb/source/API/SBSymbolContext.cpp
@@ -1,4 +1,4 @@
-//===-- SBSymbolContext.cpp -------------------------------------*- C++ -*-===//
+//===-- SBSymbolContext.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -37,7 +37,7 @@ SBSymbolContext::SBSymbolContext(const SBSymbolContext &rhs) : m_opaque_up() {
m_opaque_up = clone(rhs.m_opaque_up);
}
-SBSymbolContext::~SBSymbolContext() {}
+SBSymbolContext::~SBSymbolContext() = default;
const SBSymbolContext &SBSymbolContext::operator=(const SBSymbolContext &rhs) {
LLDB_RECORD_METHOD(const lldb::SBSymbolContext &,
@@ -185,13 +185,13 @@ const lldb_private::SymbolContext &SBSymbolContext::operator*() const {
lldb_private::SymbolContext &SBSymbolContext::operator*() {
if (m_opaque_up == nullptr)
- m_opaque_up.reset(new SymbolContext);
+ m_opaque_up = std::make_unique<SymbolContext>();
return *m_opaque_up;
}
lldb_private::SymbolContext &SBSymbolContext::ref() {
if (m_opaque_up == nullptr)
- m_opaque_up.reset(new SymbolContext);
+ m_opaque_up = std::make_unique<SymbolContext>();
return *m_opaque_up;
}
diff --git a/lldb/source/API/SBSymbolContextList.cpp b/lldb/source/API/SBSymbolContextList.cpp
index 915d04a0282a..9db84dc1bf4b 100644
--- a/lldb/source/API/SBSymbolContextList.cpp
+++ b/lldb/source/API/SBSymbolContextList.cpp
@@ -1,4 +1,4 @@
-//===-- SBSymbolContextList.cpp ---------------------------------*- C++ -*-===//
+//===-- SBSymbolContextList.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -28,7 +28,7 @@ SBSymbolContextList::SBSymbolContextList(const SBSymbolContextList &rhs)
m_opaque_up = clone(rhs.m_opaque_up);
}
-SBSymbolContextList::~SBSymbolContextList() {}
+SBSymbolContextList::~SBSymbolContextList() = default;
const SBSymbolContextList &SBSymbolContextList::
operator=(const SBSymbolContextList &rhs) {
diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index 312e4df75863..b84e9f10fafe 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -1,4 +1,4 @@
-//===-- SBTarget.cpp --------------------------------------------*- C++ -*-===//
+//===-- SBTarget.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -13,6 +13,7 @@
#include "lldb/API/SBBreakpoint.h"
#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBEnvironment.h"
#include "lldb/API/SBEvent.h"
#include "lldb/API/SBExpressionOptions.h"
#include "lldb/API/SBFileSpec.h"
@@ -118,7 +119,7 @@ const SBTarget &SBTarget::operator=(const SBTarget &rhs) {
}
// Destructor
-SBTarget::~SBTarget() {}
+SBTarget::~SBTarget() = default;
bool SBTarget::EventIsTargetEvent(const SBEvent &event) {
LLDB_RECORD_STATIC_METHOD(bool, SBTarget, EventIsTargetEvent,
@@ -371,10 +372,19 @@ SBProcess SBTarget::Launch(SBListener &listener, char const **argv,
Module *exe_module = target_sp->GetExecutableModulePointer();
if (exe_module)
launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
- if (argv)
+ if (argv) {
launch_info.GetArguments().AppendArguments(argv);
- if (envp)
+ } else {
+ auto default_launch_info = target_sp->GetProcessLaunchInfo();
+ launch_info.GetArguments().AppendArguments(
+ default_launch_info.GetArguments());
+ }
+ if (envp) {
launch_info.GetEnvironment() = Environment(envp);
+ } else {
+ auto default_launch_info = target_sp->GetProcessLaunchInfo();
+ launch_info.GetEnvironment() = default_launch_info.GetEnvironment();
+ }
if (listener.IsValid())
launch_info.SetListener(listener.GetSP());
@@ -556,7 +566,7 @@ lldb::SBProcess SBTarget::ConnectRemote(SBListener &listener, const char *url,
if (process_sp) {
sb_process.SetSP(process_sp);
- error.SetError(process_sp->ConnectRemote(nullptr, url));
+ error.SetError(process_sp->ConnectRemote(url));
} else {
error.SetErrorString("unable to create lldb_private::Process");
}
@@ -677,9 +687,9 @@ SBTarget::ResolveSymbolContextForAddress(const SBAddress &addr,
size_t SBTarget::ReadMemory(const SBAddress addr, void *buf, size_t size,
lldb::SBError &error) {
- LLDB_RECORD_DUMMY(size_t, SBTarget, ReadMemory,
- (const lldb::SBAddress, void *, size_t, lldb::SBError &),
- addr, buf, size, error);
+ LLDB_RECORD_METHOD(size_t, SBTarget, ReadMemory,
+ (const lldb::SBAddress, void *, size_t, lldb::SBError &),
+ addr, buf, size, error);
SBError sb_error;
size_t bytes_read = 0;
@@ -2054,21 +2064,22 @@ lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr,
lldb::SBInstructionList SBTarget::GetInstructions(lldb::SBAddress base_addr,
const void *buf,
size_t size) {
- LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, GetInstructions,
- (lldb::SBAddress, const void *, size_t), base_addr, buf,
- size);
+ LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, GetInstructions,
+ (lldb::SBAddress, const void *, size_t), base_addr, buf,
+ size);
- return GetInstructionsWithFlavor(base_addr, nullptr, buf, size);
+ return LLDB_RECORD_RESULT(
+ GetInstructionsWithFlavor(base_addr, nullptr, buf, size));
}
lldb::SBInstructionList
SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr,
const char *flavor_string, const void *buf,
size_t size) {
- LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget,
- GetInstructionsWithFlavor,
- (lldb::SBAddress, const char *, const void *, size_t),
- base_addr, flavor_string, buf, size);
+ LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget,
+ GetInstructionsWithFlavor,
+ (lldb::SBAddress, const char *, const void *, size_t),
+ base_addr, flavor_string, buf, size);
SBInstructionList sb_instructions;
@@ -2086,30 +2097,31 @@ SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr,
UINT32_MAX, data_from_file));
}
- return sb_instructions;
+ return LLDB_RECORD_RESULT(sb_instructions);
}
lldb::SBInstructionList SBTarget::GetInstructions(lldb::addr_t base_addr,
const void *buf,
size_t size) {
- LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, GetInstructions,
- (lldb::addr_t, const void *, size_t), base_addr, buf, size);
+ LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, GetInstructions,
+ (lldb::addr_t, const void *, size_t), base_addr, buf,
+ size);
- return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), nullptr, buf,
- size);
+ return LLDB_RECORD_RESULT(GetInstructionsWithFlavor(
+ ResolveLoadAddress(base_addr), nullptr, buf, size));
}
lldb::SBInstructionList
SBTarget::GetInstructionsWithFlavor(lldb::addr_t base_addr,
const char *flavor_string, const void *buf,
size_t size) {
- LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget,
- GetInstructionsWithFlavor,
- (lldb::addr_t, const char *, const void *, size_t),
- base_addr, flavor_string, buf, size);
+ LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget,
+ GetInstructionsWithFlavor,
+ (lldb::addr_t, const char *, const void *, size_t),
+ base_addr, flavor_string, buf, size);
- return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), flavor_string,
- buf, size);
+ return LLDB_RECORD_RESULT(GetInstructionsWithFlavor(
+ ResolveLoadAddress(base_addr), flavor_string, buf, size));
}
SBError SBTarget::SetSectionLoadAddress(lldb::SBSection section,
@@ -2328,16 +2340,6 @@ lldb::SBValue SBTarget::EvaluateExpression(const char *expr,
Target *target = exe_ctx.GetTargetPtr();
if (target) {
-#ifdef LLDB_CONFIGURATION_DEBUG
- StreamString frame_description;
- if (frame)
- frame->DumpUsingSettingsFormat(&frame_description);
- llvm::PrettyStackTraceFormat stack_trace(
- "SBTarget::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = "
- "%u) %s",
- expr, options.GetFetchDynamicValue(),
- frame_description.GetString().str().c_str());
-#endif
target->EvaluateExpression(expr, frame, expr_value_sp, options.ref());
expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
@@ -2386,6 +2388,17 @@ void SBTarget::SetLaunchInfo(const lldb::SBLaunchInfo &launch_info) {
m_opaque_sp->SetProcessLaunchInfo(launch_info.ref());
}
+SBEnvironment SBTarget::GetEnvironment() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBEnvironment, SBTarget, GetEnvironment);
+ TargetSP target_sp(GetSP());
+
+ if (target_sp) {
+ return LLDB_RECORD_RESULT(SBEnvironment(target_sp->GetEnvironment()));
+ }
+
+ return LLDB_RECORD_RESULT(SBEnvironment());
+}
+
namespace lldb_private {
namespace repro {
@@ -2628,6 +2641,20 @@ void RegisterMethods<SBTarget>(Registry &R) {
LLDB_REGISTER_METHOD_CONST(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo, ());
LLDB_REGISTER_METHOD(void, SBTarget, SetLaunchInfo,
(const lldb::SBLaunchInfo &));
+ LLDB_REGISTER_METHOD(
+ size_t, SBTarget, ReadMemory,
+ (const lldb::SBAddress, void *, size_t, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, GetInstructions,
+ (lldb::SBAddress, const void *, size_t));
+ LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget,
+ GetInstructionsWithFlavor,
+ (lldb::SBAddress, const char *, const void *, size_t));
+ LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, GetInstructions,
+ (lldb::addr_t, const void *, size_t));
+ LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget,
+ GetInstructionsWithFlavor,
+ (lldb::addr_t, const char *, const void *, size_t));
+ LLDB_REGISTER_METHOD(lldb::SBEnvironment, SBTarget, GetEnvironment, ());
}
}
diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp
index f7f748f56832..0d50aceee5e4 100644
--- a/lldb/source/API/SBThread.cpp
+++ b/lldb/source/API/SBThread.cpp
@@ -1,4 +1,4 @@
-//===-- SBThread.cpp --------------------------------------------*- C++ -*-===//
+//===-- SBThread.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -40,7 +40,6 @@
#include "lldb/Target/ThreadPlanStepInstruction.h"
#include "lldb/Target/ThreadPlanStepOut.h"
#include "lldb/Target/ThreadPlanStepRange.h"
-#include "lldb/Target/UnixSignals.h"
#include "lldb/Utility/State.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StructuredData.h"
@@ -86,7 +85,7 @@ const lldb::SBThread &SBThread::operator=(const SBThread &rhs) {
}
// Destructor
-SBThread::~SBThread() {}
+SBThread::~SBThread() = default;
lldb::SBQueue SBThread::GetQueue() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBQueue, SBThread, GetQueue);
@@ -292,14 +291,13 @@ SBThread::GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type) {
GetStopReasonExtendedBacktraces,
(lldb::InstrumentationRuntimeType), type);
- ThreadCollectionSP threads;
- threads = std::make_shared<ThreadCollection>();
+ SBThreadCollection threads;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (!exe_ctx.HasThreadScope())
- return LLDB_RECORD_RESULT(threads);
+ return LLDB_RECORD_RESULT(SBThreadCollection());
ProcessSP process_sp = exe_ctx.GetProcessSP();
@@ -308,105 +306,38 @@ SBThread::GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type) {
if (!info)
return LLDB_RECORD_RESULT(threads);
- return LLDB_RECORD_RESULT(process_sp->GetInstrumentationRuntime(type)
- ->GetBacktracesFromExtendedStopInfo(info));
+ threads = process_sp->GetInstrumentationRuntime(type)
+ ->GetBacktracesFromExtendedStopInfo(info);
+ return LLDB_RECORD_RESULT(threads);
}
size_t SBThread::GetStopDescription(char *dst, size_t dst_len) {
- LLDB_RECORD_METHOD(size_t, SBThread, GetStopDescription, (char *, size_t),
- dst, dst_len);
+ LLDB_RECORD_CHAR_PTR_METHOD(size_t, SBThread, GetStopDescription,
+ (char *, size_t), dst, "", dst_len);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- if (exe_ctx.HasThreadScope()) {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+ if (dst)
+ *dst = 0;
- StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo();
- if (stop_info_sp) {
- const char *stop_desc = stop_info_sp->GetDescription();
- if (stop_desc) {
- if (dst)
- return ::snprintf(dst, dst_len, "%s", stop_desc);
- else {
- // NULL dst passed in, return the length needed to contain the
- // description
- return ::strlen(stop_desc) + 1; // Include the NULL byte for size
- }
- } else {
- size_t stop_desc_len = 0;
- switch (stop_info_sp->GetStopReason()) {
- case eStopReasonTrace:
- case eStopReasonPlanComplete: {
- static char trace_desc[] = "step";
- stop_desc = trace_desc;
- stop_desc_len =
- sizeof(trace_desc); // Include the NULL byte for size
- } break;
-
- case eStopReasonBreakpoint: {
- static char bp_desc[] = "breakpoint hit";
- stop_desc = bp_desc;
- stop_desc_len = sizeof(bp_desc); // Include the NULL byte for size
- } break;
-
- case eStopReasonWatchpoint: {
- static char wp_desc[] = "watchpoint hit";
- stop_desc = wp_desc;
- stop_desc_len = sizeof(wp_desc); // Include the NULL byte for size
- } break;
-
- case eStopReasonSignal: {
- stop_desc =
- exe_ctx.GetProcessPtr()->GetUnixSignals()->GetSignalAsCString(
- stop_info_sp->GetValue());
- if (stop_desc == nullptr || stop_desc[0] == '\0') {
- static char signal_desc[] = "signal";
- stop_desc = signal_desc;
- stop_desc_len =
- sizeof(signal_desc); // Include the NULL byte for size
- }
- } break;
-
- case eStopReasonException: {
- char exc_desc[] = "exception";
- stop_desc = exc_desc;
- stop_desc_len = sizeof(exc_desc); // Include the NULL byte for size
- } break;
-
- case eStopReasonExec: {
- char exc_desc[] = "exec";
- stop_desc = exc_desc;
- stop_desc_len = sizeof(exc_desc); // Include the NULL byte for size
- } break;
-
- case eStopReasonThreadExiting: {
- char limbo_desc[] = "thread exiting";
- stop_desc = limbo_desc;
- stop_desc_len = sizeof(limbo_desc);
- } break;
- default:
- break;
- }
+ if (!exe_ctx.HasThreadScope())
+ return 0;
- if (stop_desc && stop_desc[0]) {
- if (dst)
- return ::snprintf(dst, dst_len, "%s", stop_desc) +
- 1; // Include the NULL byte
+ Process::StopLocker stop_locker;
+ if (!stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
+ return 0;
- if (stop_desc_len == 0)
- stop_desc_len = ::strlen(stop_desc) + 1; // Include the NULL byte
+ std::string thread_stop_desc = exe_ctx.GetThreadPtr()->GetStopDescription();
+ if (thread_stop_desc.empty())
+ return 0;
- return stop_desc_len;
- }
- }
- }
- }
- }
if (dst)
- *dst = 0;
- return 0;
+ return ::snprintf(dst, dst_len, "%s", thread_stop_desc.c_str()) + 1;
+
+ // NULL dst passed in, return the length needed to contain the
+ // description.
+ return thread_stop_desc.size() + 1; // Include the NULL byte for size
}
SBValue SBThread::GetStopReturnValue() {
@@ -970,23 +901,20 @@ SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name) {
SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
bool resume_immediately) {
LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
- (const char *, bool), script_class_name,
+ (const char *, bool), script_class_name,
resume_immediately);
lldb::SBStructuredData no_data;
- return LLDB_RECORD_RESULT(
- StepUsingScriptedThreadPlan(script_class_name,
- no_data,
- resume_immediately));
+ return LLDB_RECORD_RESULT(StepUsingScriptedThreadPlan(
+ script_class_name, no_data, resume_immediately));
}
SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
SBStructuredData &args_data,
bool resume_immediately) {
LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
- (const char *, lldb::SBStructuredData &, bool),
- script_class_name, args_data,
- resume_immediately);
+ (const char *, lldb::SBStructuredData &, bool),
+ script_class_name, args_data, resume_immediately);
SBError error;
@@ -1444,8 +1372,6 @@ void RegisterMethods<SBThread>(Registry &R) {
LLDB_REGISTER_METHOD(lldb::SBThreadCollection, SBThread,
GetStopReasonExtendedBacktraces,
(lldb::InstrumentationRuntimeType));
- LLDB_REGISTER_METHOD(size_t, SBThread, GetStopDescription,
- (char *, size_t));
LLDB_REGISTER_METHOD(lldb::SBValue, SBThread, GetStopReturnValue, ());
LLDB_REGISTER_METHOD_CONST(lldb::tid_t, SBThread, GetThreadID, ());
LLDB_REGISTER_METHOD_CONST(uint32_t, SBThread, GetIndexID, ());
@@ -1522,6 +1448,7 @@ void RegisterMethods<SBThread>(Registry &R) {
LLDB_REGISTER_METHOD(lldb::SBThread, SBThread, GetCurrentExceptionBacktrace,
());
LLDB_REGISTER_METHOD(bool, SBThread, SafeToCallFunctions, ());
+ LLDB_REGISTER_CHAR_PTR_METHOD(size_t, SBThread, GetStopDescription);
}
}
diff --git a/lldb/source/API/SBThreadCollection.cpp b/lldb/source/API/SBThreadCollection.cpp
index 3c1cf9865062..bfca864d6bcd 100644
--- a/lldb/source/API/SBThreadCollection.cpp
+++ b/lldb/source/API/SBThreadCollection.cpp
@@ -1,4 +1,4 @@
-//===-- SBThreadCollection.cpp ----------------------------------*- C++ -*-===//
+//===-- SBThreadCollection.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -38,7 +38,7 @@ operator=(const SBThreadCollection &rhs) {
SBThreadCollection::SBThreadCollection(const ThreadCollectionSP &threads)
: m_opaque_sp(threads) {}
-SBThreadCollection::~SBThreadCollection() {}
+SBThreadCollection::~SBThreadCollection() = default;
void SBThreadCollection::SetOpaque(const lldb::ThreadCollectionSP &threads) {
m_opaque_sp = threads;
diff --git a/lldb/source/API/SBThreadPlan.cpp b/lldb/source/API/SBThreadPlan.cpp
index eed4d1bfb9c4..1a947bbc2608 100644
--- a/lldb/source/API/SBThreadPlan.cpp
+++ b/lldb/source/API/SBThreadPlan.cpp
@@ -1,4 +1,4 @@
-//===-- SBThreadPlan.cpp ----------------------------------------*- C++ -*-===//
+//===-- SBThreadPlan.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -96,7 +96,7 @@ const lldb::SBThreadPlan &SBThreadPlan::operator=(const SBThreadPlan &rhs) {
return LLDB_RECORD_RESULT(*this);
}
// Destructor
-SBThreadPlan::~SBThreadPlan() {}
+SBThreadPlan::~SBThreadPlan() = default;
lldb_private::ThreadPlan *SBThreadPlan::get() { return m_opaque_sp.get(); }
@@ -237,7 +237,9 @@ SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange(
if (plan_status.Fail())
error.SetErrorString(plan_status.AsCString());
-
+ else
+ plan.m_opaque_sp->SetPrivate(true);
+
return LLDB_RECORD_RESULT(plan);
} else {
return LLDB_RECORD_RESULT(SBThreadPlan());
@@ -281,6 +283,8 @@ SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address,
if (plan_status.Fail())
error.SetErrorString(plan_status.AsCString());
+ else
+ plan.m_opaque_sp->SetPrivate(true);
return LLDB_RECORD_RESULT(plan);
} else {
@@ -321,6 +325,8 @@ SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
if (plan_status.Fail())
error.SetErrorString(plan_status.AsCString());
+ else
+ plan.m_opaque_sp->SetPrivate(true);
return LLDB_RECORD_RESULT(plan);
} else {
@@ -356,6 +362,8 @@ SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address,
if (plan_status.Fail())
error.SetErrorString(plan_status.AsCString());
+ else
+ plan.m_opaque_sp->SetPrivate(true);
return LLDB_RECORD_RESULT(plan);
} else {
@@ -390,6 +398,8 @@ SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name,
if (plan_status.Fail())
error.SetErrorString(plan_status.AsCString());
+ else
+ plan.m_opaque_sp->SetPrivate(true);
return LLDB_RECORD_RESULT(plan);
} else {
@@ -415,6 +425,8 @@ SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name,
if (plan_status.Fail())
error.SetErrorString(plan_status.AsCString());
+ else
+ plan.m_opaque_sp->SetPrivate(true);
return LLDB_RECORD_RESULT(plan);
} else {
diff --git a/lldb/source/API/SBTrace.cpp b/lldb/source/API/SBTrace.cpp
index 9b871e6781d9..3fdabaa29ac2 100644
--- a/lldb/source/API/SBTrace.cpp
+++ b/lldb/source/API/SBTrace.cpp
@@ -1,4 +1,4 @@
-//===-- SBTrace.cpp ---------------------------------------------*- C++ -*-===//
+//===-- SBTrace.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/API/SBTraceOptions.cpp b/lldb/source/API/SBTraceOptions.cpp
index a24cdd59af0b..f1f5a63edf06 100644
--- a/lldb/source/API/SBTraceOptions.cpp
+++ b/lldb/source/API/SBTraceOptions.cpp
@@ -1,4 +1,4 @@
-//===-- SBTraceOptions.cpp --------------------------------------*- C++ -*-===//
+//===-- SBTraceOptions.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp
index 33b67ad4c004..852630f2d01a 100644
--- a/lldb/source/API/SBType.cpp
+++ b/lldb/source/API/SBType.cpp
@@ -1,4 +1,4 @@
-//===-- SBType.cpp ----------------------------------------------*- C++ -*-===//
+//===-- SBType.cpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -89,7 +89,7 @@ SBType &SBType::operator=(const SBType &rhs) {
return LLDB_RECORD_RESULT(*this);
}
-SBType::~SBType() {}
+SBType::~SBType() = default;
TypeImpl &SBType::ref() {
if (m_opaque_sp.get() == nullptr)
@@ -589,7 +589,7 @@ SBTypeList &SBTypeList::operator=(const SBTypeList &rhs) {
SBTypeList, operator=,(const lldb::SBTypeList &), rhs);
if (this != &rhs) {
- m_opaque_up.reset(new TypeListImpl());
+ m_opaque_up = std::make_unique<TypeListImpl>();
for (uint32_t i = 0, rhs_size = const_cast<SBTypeList &>(rhs).GetSize();
i < rhs_size; i++)
Append(const_cast<SBTypeList &>(rhs).GetTypeAtIndex(i));
@@ -619,20 +619,20 @@ uint32_t SBTypeList::GetSize() {
return m_opaque_up->GetSize();
}
-SBTypeList::~SBTypeList() {}
+SBTypeList::~SBTypeList() = default;
SBTypeMember::SBTypeMember() : m_opaque_up() {
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeMember);
}
-SBTypeMember::~SBTypeMember() {}
+SBTypeMember::~SBTypeMember() = default;
SBTypeMember::SBTypeMember(const SBTypeMember &rhs) : m_opaque_up() {
LLDB_RECORD_CONSTRUCTOR(SBTypeMember, (const lldb::SBTypeMember &), rhs);
if (this != &rhs) {
if (rhs.IsValid())
- m_opaque_up.reset(new TypeMemberImpl(rhs.ref()));
+ m_opaque_up = std::make_unique<TypeMemberImpl>(rhs.ref());
}
}
@@ -642,7 +642,7 @@ lldb::SBTypeMember &SBTypeMember::operator=(const lldb::SBTypeMember &rhs) {
if (this != &rhs) {
if (rhs.IsValid())
- m_opaque_up.reset(new TypeMemberImpl(rhs.ref()));
+ m_opaque_up = std::make_unique<TypeMemberImpl>(rhs.ref());
}
return LLDB_RECORD_RESULT(*this);
}
@@ -746,7 +746,7 @@ void SBTypeMember::reset(TypeMemberImpl *type_member_impl) {
TypeMemberImpl &SBTypeMember::ref() {
if (m_opaque_up == nullptr)
- m_opaque_up.reset(new TypeMemberImpl());
+ m_opaque_up = std::make_unique<TypeMemberImpl>();
return *m_opaque_up;
}
@@ -756,7 +756,7 @@ SBTypeMemberFunction::SBTypeMemberFunction() : m_opaque_sp() {
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeMemberFunction);
}
-SBTypeMemberFunction::~SBTypeMemberFunction() {}
+SBTypeMemberFunction::~SBTypeMemberFunction() = default;
SBTypeMemberFunction::SBTypeMemberFunction(const SBTypeMemberFunction &rhs)
: m_opaque_sp(rhs.m_opaque_sp) {
@@ -802,7 +802,7 @@ const char *SBTypeMemberFunction::GetDemangledName() {
ConstString mangled_str = m_opaque_sp->GetMangledName();
if (mangled_str) {
Mangled mangled(mangled_str);
- return mangled.GetDemangledName(mangled.GuessLanguage()).GetCString();
+ return mangled.GetDemangledName().GetCString();
}
}
return nullptr;
diff --git a/lldb/source/API/SBTypeCategory.cpp b/lldb/source/API/SBTypeCategory.cpp
index 1e4496575098..9ce1a57ec4f7 100644
--- a/lldb/source/API/SBTypeCategory.cpp
+++ b/lldb/source/API/SBTypeCategory.cpp
@@ -1,5 +1,4 @@
-//===-- SBTypeCategory.cpp ----------------------------------------*- C++
-//-*-===//
+//===-- SBTypeCategory.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -40,7 +39,7 @@ SBTypeCategory::SBTypeCategory(const lldb::SBTypeCategory &rhs)
LLDB_RECORD_CONSTRUCTOR(SBTypeCategory, (const lldb::SBTypeCategory &), rhs);
}
-SBTypeCategory::~SBTypeCategory() {}
+SBTypeCategory::~SBTypeCategory() = default;
bool SBTypeCategory::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeCategory, IsValid);
diff --git a/lldb/source/API/SBTypeEnumMember.cpp b/lldb/source/API/SBTypeEnumMember.cpp
index bd0755a140c3..43a4891b54b1 100644
--- a/lldb/source/API/SBTypeEnumMember.cpp
+++ b/lldb/source/API/SBTypeEnumMember.cpp
@@ -1,4 +1,4 @@
-//===-- SBTypeEnumMember.cpp ---------------------------------- -*- C++ -*-===//
+//===-- SBTypeEnumMember.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -25,7 +25,7 @@ SBTypeEnumMember::SBTypeEnumMember() : m_opaque_sp() {
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeEnumMember);
}
-SBTypeEnumMember::~SBTypeEnumMember() {}
+SBTypeEnumMember::~SBTypeEnumMember() = default;
SBTypeEnumMember::SBTypeEnumMember(
const lldb::TypeEnumMemberImplSP &enum_member_sp)
@@ -141,7 +141,7 @@ operator=(const SBTypeEnumMemberList &rhs) {
rhs);
if (this != &rhs) {
- m_opaque_up.reset(new TypeEnumMemberListImpl());
+ m_opaque_up = std::make_unique<TypeEnumMemberListImpl>();
for (uint32_t i = 0,
rhs_size = const_cast<SBTypeEnumMemberList &>(rhs).GetSize();
i < rhs_size; i++)
@@ -176,7 +176,7 @@ uint32_t SBTypeEnumMemberList::GetSize() {
return m_opaque_up->GetSize();
}
-SBTypeEnumMemberList::~SBTypeEnumMemberList() {}
+SBTypeEnumMemberList::~SBTypeEnumMemberList() = default;
bool SBTypeEnumMember::GetDescription(
lldb::SBStream &description, lldb::DescriptionLevel description_level) {
diff --git a/lldb/source/API/SBTypeFilter.cpp b/lldb/source/API/SBTypeFilter.cpp
index d40301b4c153..5f91a194f16b 100644
--- a/lldb/source/API/SBTypeFilter.cpp
+++ b/lldb/source/API/SBTypeFilter.cpp
@@ -1,5 +1,4 @@
-//===-- SBTypeFilter.cpp ------------------------------------------*- C++
-//-*-===//
+//===-- SBTypeFilter.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -31,7 +30,7 @@ SBTypeFilter::SBTypeFilter(const lldb::SBTypeFilter &rhs)
LLDB_RECORD_CONSTRUCTOR(SBTypeFilter, (const lldb::SBTypeFilter &), rhs);
}
-SBTypeFilter::~SBTypeFilter() {}
+SBTypeFilter::~SBTypeFilter() = default;
bool SBTypeFilter::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeFilter, IsValid);
diff --git a/lldb/source/API/SBTypeFormat.cpp b/lldb/source/API/SBTypeFormat.cpp
index 6024631e7054..70289bef8db5 100644
--- a/lldb/source/API/SBTypeFormat.cpp
+++ b/lldb/source/API/SBTypeFormat.cpp
@@ -1,5 +1,4 @@
-//===-- SBTypeFormat.cpp ------------------------------------------*- C++
-//-*-===//
+//===-- SBTypeFormat.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -40,7 +39,7 @@ SBTypeFormat::SBTypeFormat(const lldb::SBTypeFormat &rhs)
LLDB_RECORD_CONSTRUCTOR(SBTypeFormat, (const lldb::SBTypeFormat &), rhs);
}
-SBTypeFormat::~SBTypeFormat() {}
+SBTypeFormat::~SBTypeFormat() = default;
bool SBTypeFormat::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeFormat, IsValid);
diff --git a/lldb/source/API/SBTypeNameSpecifier.cpp b/lldb/source/API/SBTypeNameSpecifier.cpp
index 895f69775659..3673a5024530 100644
--- a/lldb/source/API/SBTypeNameSpecifier.cpp
+++ b/lldb/source/API/SBTypeNameSpecifier.cpp
@@ -1,5 +1,4 @@
-//===-- SBTypeNameSpecifier.cpp ------------------------------------*- C++
-//-*-===//
+//===-- SBTypeNameSpecifier.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -45,7 +44,7 @@ SBTypeNameSpecifier::SBTypeNameSpecifier(const lldb::SBTypeNameSpecifier &rhs)
(const lldb::SBTypeNameSpecifier &), rhs);
}
-SBTypeNameSpecifier::~SBTypeNameSpecifier() {}
+SBTypeNameSpecifier::~SBTypeNameSpecifier() = default;
bool SBTypeNameSpecifier::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeNameSpecifier, IsValid);
diff --git a/lldb/source/API/SBTypeSummary.cpp b/lldb/source/API/SBTypeSummary.cpp
index 8ffb23435757..3800ae940c70 100644
--- a/lldb/source/API/SBTypeSummary.cpp
+++ b/lldb/source/API/SBTypeSummary.cpp
@@ -1,5 +1,4 @@
-//===-- SBTypeSummary.cpp -----------------------------------------*- C++
-//-*-===//
+//===-- SBTypeSummary.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -22,7 +21,7 @@ using namespace lldb_private;
SBTypeSummaryOptions::SBTypeSummaryOptions() {
LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeSummaryOptions);
- m_opaque_up.reset(new TypeSummaryOptions());
+ m_opaque_up = std::make_unique<TypeSummaryOptions>();
}
SBTypeSummaryOptions::SBTypeSummaryOptions(
@@ -33,7 +32,7 @@ SBTypeSummaryOptions::SBTypeSummaryOptions(
m_opaque_up = clone(rhs.m_opaque_up);
}
-SBTypeSummaryOptions::~SBTypeSummaryOptions() {}
+SBTypeSummaryOptions::~SBTypeSummaryOptions() = default;
bool SBTypeSummaryOptions::IsValid() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSummaryOptions, IsValid);
@@ -112,9 +111,9 @@ SBTypeSummaryOptions::SBTypeSummaryOptions(
void SBTypeSummaryOptions::SetOptions(
const lldb_private::TypeSummaryOptions *lldb_object_ptr) {
if (lldb_object_ptr)
- m_opaque_up.reset(new TypeSummaryOptions(*lldb_object_ptr));
+ m_opaque_up = std::make_unique<TypeSummaryOptions>(*lldb_object_ptr);
else
- m_opaque_up.reset(new TypeSummaryOptions());
+ m_opaque_up = std::make_unique<TypeSummaryOptions>();
}
SBTypeSummary::SBTypeSummary() : m_opaque_sp() {
@@ -193,7 +192,7 @@ SBTypeSummary::SBTypeSummary(const lldb::SBTypeSummary &rhs)
LLDB_RECORD_CONSTRUCTOR(SBTypeSummary, (const lldb::SBTypeSummary &), rhs);
}
-SBTypeSummary::~SBTypeSummary() {}
+SBTypeSummary::~SBTypeSummary() = default;
bool SBTypeSummary::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSummary, IsValid);
diff --git a/lldb/source/API/SBTypeSynthetic.cpp b/lldb/source/API/SBTypeSynthetic.cpp
index df6fce1269f0..af5e167b9c24 100644
--- a/lldb/source/API/SBTypeSynthetic.cpp
+++ b/lldb/source/API/SBTypeSynthetic.cpp
@@ -1,5 +1,4 @@
-//===-- SBTypeSynthetic.cpp -----------------------------------------*- C++
-//-*-===//
+//===-- SBTypeSynthetic.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -51,7 +50,7 @@ SBTypeSynthetic::SBTypeSynthetic(const lldb::SBTypeSynthetic &rhs)
rhs);
}
-SBTypeSynthetic::~SBTypeSynthetic() {}
+SBTypeSynthetic::~SBTypeSynthetic() = default;
bool SBTypeSynthetic::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSynthetic, IsValid);
diff --git a/lldb/source/API/SBUnixSignals.cpp b/lldb/source/API/SBUnixSignals.cpp
index 277a92d21ae9..a933f6d22333 100644
--- a/lldb/source/API/SBUnixSignals.cpp
+++ b/lldb/source/API/SBUnixSignals.cpp
@@ -1,5 +1,4 @@
-//===-- SBUnixSignals.cpp -------------------------------------------*- C++
-//-*-===//
+//===-- SBUnixSignals.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -43,7 +42,7 @@ const SBUnixSignals &SBUnixSignals::operator=(const SBUnixSignals &rhs) {
return LLDB_RECORD_RESULT(*this);
}
-SBUnixSignals::~SBUnixSignals() {}
+SBUnixSignals::~SBUnixSignals() = default;
UnixSignalsSP SBUnixSignals::GetSP() const { return m_opaque_wp.lock(); }
diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index 396a9d3ea10c..7485b0ee1838 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -1,4 +1,4 @@
-//===-- SBValue.cpp ---------------------------------------------*- C++ -*-===//
+//===-- SBValue.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -53,7 +53,7 @@ using namespace lldb_private;
class ValueImpl {
public:
- ValueImpl() {}
+ ValueImpl() = default;
ValueImpl(lldb::ValueObjectSP in_valobj_sp,
lldb::DynamicValueType use_dynamic, bool use_synthetic,
@@ -137,7 +137,7 @@ public:
}
if (m_use_synthetic) {
- ValueObjectSP synthetic_sp = value_sp->GetSyntheticValue(m_use_synthetic);
+ ValueObjectSP synthetic_sp = value_sp->GetSyntheticValue();
if (synthetic_sp)
value_sp = synthetic_sp;
}
@@ -201,7 +201,7 @@ private:
class ValueLocker {
public:
- ValueLocker() {}
+ ValueLocker() = default;
ValueObjectSP GetLockedSP(ValueImpl &in_value) {
return in_value.GetSP(m_stop_locker, m_lock, m_lock_error);
@@ -239,7 +239,7 @@ SBValue &SBValue::operator=(const SBValue &rhs) {
return LLDB_RECORD_RESULT(*this);
}
-SBValue::~SBValue() {}
+SBValue::~SBValue() = default;
bool SBValue::IsValid() {
LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsValid);
@@ -1154,7 +1154,7 @@ bool SBValue::GetExpressionPath(SBStream &description) {
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp) {
- value_sp->GetExpressionPath(description.ref(), false);
+ value_sp->GetExpressionPath(description.ref());
return true;
}
return false;
@@ -1168,7 +1168,7 @@ bool SBValue::GetExpressionPath(SBStream &description,
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp) {
- value_sp->GetExpressionPath(description.ref(), qualify_cxx_base_classes);
+ value_sp->GetExpressionPath(description.ref());
return true;
}
return false;
@@ -1493,7 +1493,7 @@ lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write,
StreamString ss;
// True to show fullpath for declaration file.
decl.DumpStopContext(&ss, true);
- watchpoint_sp->SetDeclInfo(ss.GetString());
+ watchpoint_sp->SetDeclInfo(std::string(ss.GetString()));
}
}
}
diff --git a/lldb/source/API/SBValueList.cpp b/lldb/source/API/SBValueList.cpp
index 7e909df260d7..0fd2a591c321 100644
--- a/lldb/source/API/SBValueList.cpp
+++ b/lldb/source/API/SBValueList.cpp
@@ -1,4 +1,4 @@
-//===-- SBValueList.cpp -----------------------------------------*- C++ -*-===//
+//===-- SBValueList.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -75,15 +75,15 @@ SBValueList::SBValueList(const SBValueList &rhs) : m_opaque_up() {
LLDB_RECORD_CONSTRUCTOR(SBValueList, (const lldb::SBValueList &), rhs);
if (rhs.IsValid())
- m_opaque_up.reset(new ValueListImpl(*rhs));
+ m_opaque_up = std::make_unique<ValueListImpl>(*rhs);
}
SBValueList::SBValueList(const ValueListImpl *lldb_object_ptr) : m_opaque_up() {
if (lldb_object_ptr)
- m_opaque_up.reset(new ValueListImpl(*lldb_object_ptr));
+ m_opaque_up = std::make_unique<ValueListImpl>(*lldb_object_ptr);
}
-SBValueList::~SBValueList() {}
+SBValueList::~SBValueList() = default;
bool SBValueList::IsValid() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBValueList, IsValid);
@@ -107,7 +107,7 @@ const SBValueList &SBValueList::operator=(const SBValueList &rhs) {
if (this != &rhs) {
if (rhs.IsValid())
- m_opaque_up.reset(new ValueListImpl(*rhs));
+ m_opaque_up = std::make_unique<ValueListImpl>(*rhs);
else
m_opaque_up.reset();
}
@@ -173,7 +173,7 @@ uint32_t SBValueList::GetSize() const {
void SBValueList::CreateIfNeeded() {
if (m_opaque_up == nullptr)
- m_opaque_up.reset(new ValueListImpl());
+ m_opaque_up = std::make_unique<ValueListImpl>();
}
SBValue SBValueList::FindValueObjectByUID(lldb::user_id_t uid) {
diff --git a/lldb/source/API/SBVariablesOptions.cpp b/lldb/source/API/SBVariablesOptions.cpp
index bf0197cd960b..4ef16364e628 100644
--- a/lldb/source/API/SBVariablesOptions.cpp
+++ b/lldb/source/API/SBVariablesOptions.cpp
@@ -1,5 +1,4 @@
-//===-- SBVariablesOptions.cpp --------------------------------------*- C++
-//-*-===//
+//===-- SBVariablesOptions.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -98,7 +97,7 @@ operator=(const SBVariablesOptions &options) {
SBVariablesOptions, operator=,(const lldb::SBVariablesOptions &),
options);
- m_opaque_up.reset(new VariablesOptionsImpl(options.ref()));
+ m_opaque_up = std::make_unique<VariablesOptionsImpl>(options.ref());
return LLDB_RECORD_RESULT(*this);
}
diff --git a/lldb/source/API/SBWatchpoint.cpp b/lldb/source/API/SBWatchpoint.cpp
index d0a36b71e5c1..eba75dea8f8d 100644
--- a/lldb/source/API/SBWatchpoint.cpp
+++ b/lldb/source/API/SBWatchpoint.cpp
@@ -1,4 +1,4 @@
-//===-- SBWatchpoint.cpp --------------------------------*- C++ -*-===//
+//===-- SBWatchpoint.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -46,7 +46,7 @@ const SBWatchpoint &SBWatchpoint::operator=(const SBWatchpoint &rhs) {
return LLDB_RECORD_RESULT(*this);
}
-SBWatchpoint::~SBWatchpoint() {}
+SBWatchpoint::~SBWatchpoint() = default;
watch_id_t SBWatchpoint::GetID() {
LLDB_RECORD_METHOD_NO_ARGS(lldb::watch_id_t, SBWatchpoint, GetID);
diff --git a/lldb/source/API/SystemInitializerFull.cpp b/lldb/source/API/SystemInitializerFull.cpp
index 06f1a6cd3b75..7f95e7acf62a 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -1,4 +1,4 @@
-//===-- SystemInitializerFull.cpp -------------------------------*- C++ -*-===//
+//===-- SystemInitializerFull.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,119 +8,13 @@
#include "SystemInitializerFull.h"
#include "lldb/API/SBCommandInterpreter.h"
-#include "lldb/Host/Config.h"
-
-#if LLDB_ENABLE_PYTHON
-#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h"
-#endif
-
-#if LLDB_ENABLE_LUA
-#include "Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h"
-#endif
-
#include "lldb/Core/Debugger.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Host/Config.h"
#include "lldb/Host/Host.h"
#include "lldb/Initialization/SystemInitializerCommon.h"
#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Utility/Timer.h"
-
-#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h"
-#include "Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h"
-#include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h"
-#include "Plugins/ABI/SysV-arc/ABISysV_arc.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-mips/ABISysV_mips.h"
-#include "Plugins/ABI/SysV-mips64/ABISysV_mips64.h"
-#include "Plugins/ABI/SysV-ppc/ABISysV_ppc.h"
-#include "Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h"
-#include "Plugins/ABI/SysV-s390x/ABISysV_s390x.h"
-#include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h"
-#include "Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h"
-#include "Plugins/Architecture/Arm/ArchitectureArm.h"
-#include "Plugins/Architecture/Mips/ArchitectureMips.h"
-#include "Plugins/Architecture/PPC64/ArchitecturePPC64.h"
-#include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h"
-#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h"
-#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
-#include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
-#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
-#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
-#include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
-#include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
-#include "Plugins/Instruction/MIPS/EmulateInstructionMIPS.h"
-#include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
-#include "Plugins/Instruction/PPC64/EmulateInstructionPPC64.h"
-#include "Plugins/InstrumentationRuntime/ASan/ASanRuntime.h"
-#include "Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h"
-#include "Plugins/InstrumentationRuntime/TSan/TSanRuntime.h"
-#include "Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h"
-#include "Plugins/JITLoader/GDB/JITLoaderGDB.h"
-#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.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/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h"
-#include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h"
-#include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
-#include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h"
-#include "Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h"
-#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
-#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
-#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h"
-#include "Plugins/OperatingSystem/Python/OperatingSystemPython.h"
-#include "Plugins/Platform/Android/PlatformAndroid.h"
-#include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h"
-#include "Plugins/Platform/Linux/PlatformLinux.h"
-#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
-#include "Plugins/Platform/NetBSD/PlatformNetBSD.h"
-#include "Plugins/Platform/OpenBSD/PlatformOpenBSD.h"
-#include "Plugins/Platform/Windows/PlatformWindows.h"
-#include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
-#include "Plugins/Process/elf-core/ProcessElfCore.h"
-#include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
-#include "Plugins/Process/mach-core/ProcessMachCore.h"
-#include "Plugins/Process/minidump/ProcessMinidump.h"
-#include "Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h"
-#include "Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h"
-#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
-#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h"
-#include "Plugins/SymbolFile/PDB/SymbolFilePDB.h"
-#include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h"
-#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
-#include "Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h"
-#include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h"
-#include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h"
-
-#if defined(__APPLE__)
-#include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h"
-#include "Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h"
-#include "Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h"
-#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h"
-#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h"
-#include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h"
-#include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h"
-#endif
-#include "Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h"
-
-#if defined(__FreeBSD__)
-#include "Plugins/Process/FreeBSD/ProcessFreeBSD.h"
-#endif
-
-#if defined(_WIN32)
-#include "Plugins/Process/Windows/Common/ProcessWindows.h"
-#include "lldb/Host/windows/windows.h"
-#endif
-
#include "llvm/Support/TargetSelect.h"
#pragma clang diagnostic push
@@ -130,174 +24,32 @@
#include <string>
-using namespace lldb_private;
-
-SystemInitializerFull::SystemInitializerFull() {}
-
-SystemInitializerFull::~SystemInitializerFull() {}
+#define LLDB_PLUGIN(p) LLDB_PLUGIN_DECLARE(p)
+#include "Plugins/Plugins.def"
-#define LLDB_PROCESS_AArch64(op) \
- ABIMacOSX_arm64::op(); \
- ABISysV_arm64::op();
-#define LLDB_PROCESS_ARM(op) \
- ABIMacOSX_arm::op(); \
- ABISysV_arm::op();
-#define LLDB_PROCESS_ARC(op) \
- ABISysV_arc::op();
-#define LLDB_PROCESS_Hexagon(op) ABISysV_hexagon::op();
-#define LLDB_PROCESS_Mips(op) \
- ABISysV_mips::op(); \
- ABISysV_mips64::op();
-#define LLDB_PROCESS_PowerPC(op) \
- ABISysV_ppc::op(); \
- ABISysV_ppc64::op();
-#define LLDB_PROCESS_SystemZ(op) ABISysV_s390x::op();
-#define LLDB_PROCESS_X86(op) \
- ABIMacOSX_i386::op(); \
- ABISysV_i386::op(); \
- ABISysV_x86_64::op(); \
- ABIWindows_x86_64::op();
+using namespace lldb_private;
-#define LLDB_PROCESS_AMDGPU(op)
-#define LLDB_PROCESS_AVR(op)
-#define LLDB_PROCESS_BPF(op)
-#define LLDB_PROCESS_Lanai(op)
-#define LLDB_PROCESS_MSP430(op)
-#define LLDB_PROCESS_NVPTX(op)
-#define LLDB_PROCESS_RISCV(op)
-#define LLDB_PROCESS_Sparc(op)
-#define LLDB_PROCESS_WebAssembly(op)
-#define LLDB_PROCESS_XCore(op)
+SystemInitializerFull::SystemInitializerFull() = default;
+SystemInitializerFull::~SystemInitializerFull() = default;
llvm::Error SystemInitializerFull::Initialize() {
if (auto e = SystemInitializerCommon::Initialize())
return e;
- breakpad::ObjectFileBreakpad::Initialize();
- ObjectFileELF::Initialize();
- ObjectFileMachO::Initialize();
- ObjectFilePECOFF::Initialize();
-
- ObjectContainerBSDArchive::Initialize();
- ObjectContainerUniversalMachO::Initialize();
-
- ScriptInterpreterNone::Initialize();
-
-#if LLDB_ENABLE_PYTHON
- OperatingSystemPython::Initialize();
-#endif
-
-#if LLDB_ENABLE_PYTHON
- ScriptInterpreterPython::Initialize();
-#endif
-
-#if LLDB_ENABLE_LUA
- ScriptInterpreterLua::Initialize();
-#endif
-
- platform_freebsd::PlatformFreeBSD::Initialize();
- platform_linux::PlatformLinux::Initialize();
- platform_netbsd::PlatformNetBSD::Initialize();
- platform_openbsd::PlatformOpenBSD::Initialize();
- PlatformWindows::Initialize();
- platform_android::PlatformAndroid::Initialize();
- PlatformRemoteiOS::Initialize();
- PlatformMacOSX::Initialize();
-#if defined(__APPLE__)
- PlatformiOSSimulator::Initialize();
- PlatformDarwinKernel::Initialize();
-#endif
-
// Initialize LLVM and Clang
llvm::InitializeAllTargets();
llvm::InitializeAllAsmPrinters();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllDisassemblers();
- ClangASTContext::Initialize();
-
-#define LLVM_TARGET(t) LLDB_PROCESS_ ## t(Initialize)
-#include "llvm/Config/Targets.def"
-
- ArchitectureArm::Initialize();
- ArchitectureMips::Initialize();
- ArchitecturePPC64::Initialize();
-
- DisassemblerLLVMC::Initialize();
-
- JITLoaderGDB::Initialize();
- ProcessElfCore::Initialize();
- ProcessMachCore::Initialize();
- minidump::ProcessMinidump::Initialize();
- MemoryHistoryASan::Initialize();
- AddressSanitizerRuntime::Initialize();
- ThreadSanitizerRuntime::Initialize();
- UndefinedBehaviorSanitizerRuntime::Initialize();
- MainThreadCheckerRuntime::Initialize();
-
- SymbolVendorELF::Initialize();
- breakpad::SymbolFileBreakpad::Initialize();
- SymbolFileDWARF::Initialize();
- SymbolFilePDB::Initialize();
- SymbolFileSymtab::Initialize();
- UnwindAssemblyInstEmulation::Initialize();
- UnwindAssembly_x86::Initialize();
-
- EmulateInstructionARM::Initialize();
- EmulateInstructionARM64::Initialize();
- EmulateInstructionMIPS::Initialize();
- EmulateInstructionMIPS64::Initialize();
- EmulateInstructionPPC64::Initialize();
-
- SymbolFileDWARFDebugMap::Initialize();
- ItaniumABILanguageRuntime::Initialize();
- AppleObjCRuntimeV2::Initialize();
- AppleObjCRuntimeV1::Initialize();
- SystemRuntimeMacOSX::Initialize();
- RenderScriptRuntime::Initialize();
-
- CPlusPlusLanguage::Initialize();
- ObjCLanguage::Initialize();
- ObjCPlusPlusLanguage::Initialize();
-
-#if defined(_WIN32)
- ProcessWindows::Initialize();
-#endif
-#if defined(__FreeBSD__)
- ProcessFreeBSD::Initialize();
-#endif
-#if defined(__APPLE__)
- SymbolVendorMacOSX::Initialize();
- ProcessKDP::Initialize();
- PlatformAppleTVSimulator::Initialize();
- PlatformAppleWatchSimulator::Initialize();
- PlatformRemoteAppleTV::Initialize();
- PlatformRemoteAppleWatch::Initialize();
- PlatformRemoteAppleBridge::Initialize();
- DynamicLoaderDarwinKernel::Initialize();
-#endif
-
- // This plugin is valid on any host that talks to a Darwin remote. It
- // shouldn't be limited to __APPLE__.
- StructuredDataDarwinLog::Initialize();
-
- // Platform agnostic plugins
- platform_gdb_server::PlatformRemoteGDBServer::Initialize();
-
- process_gdb_remote::ProcessGDBRemote::Initialize();
- DynamicLoaderMacOSXDYLD::Initialize();
- DynamicLoaderMacOS::Initialize();
- DynamicLoaderPOSIXDYLD::Initialize();
- DynamicLoaderStatic::Initialize();
- DynamicLoaderWindowsDYLD::Initialize();
+#define LLDB_PLUGIN(p) LLDB_PLUGIN_INITIALIZE(p);
+#include "Plugins/Plugins.def"
// Scan for any system or user LLDB plug-ins
PluginManager::Initialize();
// The process settings need to know about installed plug-ins, so the
- // Settings must be initialized
- // AFTER PluginManager::Initialize is called.
-
+ // Settings must be initialized AFTER PluginManager::Initialize is called.
Debugger::SettingsInitialize();
return llvm::Error::success();
@@ -312,101 +64,8 @@ void SystemInitializerFull::Terminate() {
// Terminate and unload and loaded system or user LLDB plug-ins
PluginManager::Terminate();
- ClangASTContext::Terminate();
-
- ArchitectureArm::Terminate();
- ArchitectureMips::Terminate();
- ArchitecturePPC64::Terminate();
-
-#define LLVM_TARGET(t) LLDB_PROCESS_ ## t(Terminate)
-#include "llvm/Config/Targets.def"
-
- DisassemblerLLVMC::Terminate();
-
- JITLoaderGDB::Terminate();
- ProcessElfCore::Terminate();
- ProcessMachCore::Terminate();
- minidump::ProcessMinidump::Terminate();
- MemoryHistoryASan::Terminate();
- AddressSanitizerRuntime::Terminate();
- ThreadSanitizerRuntime::Terminate();
- UndefinedBehaviorSanitizerRuntime::Terminate();
- MainThreadCheckerRuntime::Terminate();
- SymbolVendorELF::Terminate();
- breakpad::SymbolFileBreakpad::Terminate();
- SymbolFileDWARF::Terminate();
- SymbolFilePDB::Terminate();
- SymbolFileSymtab::Terminate();
- UnwindAssembly_x86::Terminate();
- UnwindAssemblyInstEmulation::Terminate();
-
- EmulateInstructionARM::Terminate();
- EmulateInstructionARM64::Terminate();
- EmulateInstructionMIPS::Terminate();
- EmulateInstructionMIPS64::Terminate();
- EmulateInstructionPPC64::Terminate();
-
- SymbolFileDWARFDebugMap::Terminate();
- ItaniumABILanguageRuntime::Terminate();
- AppleObjCRuntimeV2::Terminate();
- AppleObjCRuntimeV1::Terminate();
- SystemRuntimeMacOSX::Terminate();
- RenderScriptRuntime::Terminate();
-
- CPlusPlusLanguage::Terminate();
- ObjCLanguage::Terminate();
- ObjCPlusPlusLanguage::Terminate();
-
-#if defined(__APPLE__)
- DynamicLoaderDarwinKernel::Terminate();
- ProcessKDP::Terminate();
- SymbolVendorMacOSX::Terminate();
- PlatformAppleTVSimulator::Terminate();
- PlatformAppleWatchSimulator::Terminate();
- PlatformRemoteAppleTV::Terminate();
- PlatformRemoteAppleWatch::Terminate();
- PlatformRemoteAppleBridge::Terminate();
-#endif
-
-#if defined(__FreeBSD__)
- ProcessFreeBSD::Terminate();
-#endif
- Debugger::SettingsTerminate();
-
- platform_gdb_server::PlatformRemoteGDBServer::Terminate();
- process_gdb_remote::ProcessGDBRemote::Terminate();
- StructuredDataDarwinLog::Terminate();
-
- DynamicLoaderMacOSXDYLD::Terminate();
- DynamicLoaderMacOS::Terminate();
- DynamicLoaderPOSIXDYLD::Terminate();
- DynamicLoaderStatic::Terminate();
- DynamicLoaderWindowsDYLD::Terminate();
-
-#if LLDB_ENABLE_PYTHON
- OperatingSystemPython::Terminate();
-#endif
-
- platform_freebsd::PlatformFreeBSD::Terminate();
- platform_linux::PlatformLinux::Terminate();
- platform_netbsd::PlatformNetBSD::Terminate();
- platform_openbsd::PlatformOpenBSD::Terminate();
- PlatformWindows::Terminate();
- platform_android::PlatformAndroid::Terminate();
- PlatformMacOSX::Terminate();
- PlatformRemoteiOS::Terminate();
-#if defined(__APPLE__)
- PlatformiOSSimulator::Terminate();
- PlatformDarwinKernel::Terminate();
-#endif
-
- breakpad::ObjectFileBreakpad::Terminate();
- ObjectFileELF::Terminate();
- ObjectFileMachO::Terminate();
- ObjectFilePECOFF::Terminate();
-
- ObjectContainerBSDArchive::Terminate();
- ObjectContainerUniversalMachO::Terminate();
+#define LLDB_PLUGIN(p) LLDB_PLUGIN_TERMINATE(p);
+#include "Plugins/Plugins.def"
// Now shutdown the common parts, in reverse order.
SystemInitializerCommon::Terminate();
diff --git a/lldb/source/API/SystemInitializerFull.h b/lldb/source/API/SystemInitializerFull.h
index cd88bae97858..7cab6cb97533 100644
--- a/lldb/source/API/SystemInitializerFull.h
+++ b/lldb/source/API/SystemInitializerFull.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_API_SYSTEM_INITIALIZER_FULL_H
-#define LLDB_API_SYSTEM_INITIALIZER_FULL_H
+#ifndef LLDB_SOURCE_API_SYSTEMINITIALIZERFULL_H
+#define LLDB_SOURCE_API_SYSTEMINITIALIZERFULL_H
#include "lldb/Initialization/SystemInitializerCommon.h"
@@ -29,4 +29,4 @@ public:
} // namespace lldb_private
-#endif // LLDB_API_SYSTEM_INITIALIZER_FULL_H
+#endif // LLDB_SOURCE_API_SYSTEMINITIALIZERFULL_H
diff --git a/lldb/source/API/Utils.h b/lldb/source/API/Utils.h
index ed81534d2d12..4201e825c446 100644
--- a/lldb/source/API/Utils.h
+++ b/lldb/source/API/Utils.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_API_UTILS_H
-#define LLDB_API_UTILS_H
+#ifndef LLDB_SOURCE_API_UTILS_H
+#define LLDB_SOURCE_API_UTILS_H
#include "llvm/ADT/STLExtras.h"
#include <memory>
diff --git a/lldb/source/Breakpoint/Breakpoint.cpp b/lldb/source/Breakpoint/Breakpoint.cpp
index 13acf4bb92e2..317dfa231094 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -1,4 +1,4 @@
-//===-- Breakpoint.cpp ------------------------------------------*- C++ -*-===//
+//===-- Breakpoint.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -55,21 +55,29 @@ Breakpoint::Breakpoint(Target &target, SearchFilterSP &filter_sp,
m_being_created = false;
}
-Breakpoint::Breakpoint(Target &new_target, Breakpoint &source_bp)
+Breakpoint::Breakpoint(Target &new_target, const Breakpoint &source_bp)
: m_being_created(true), m_hardware(source_bp.m_hardware),
m_target(new_target), m_name_list(source_bp.m_name_list),
m_options_up(new BreakpointOptions(*source_bp.m_options_up)),
m_locations(*this),
m_resolve_indirect_symbols(source_bp.m_resolve_indirect_symbols),
- m_hit_count(0) {
- // Now go through and copy the filter & resolver:
- m_resolver_sp = source_bp.m_resolver_sp->CopyForBreakpoint(*this);
- m_filter_sp = source_bp.m_filter_sp->CopyForBreakpoint(*this);
-}
+ m_hit_count(0) {}
// Destructor
Breakpoint::~Breakpoint() = default;
+BreakpointSP Breakpoint::CopyFromBreakpoint(TargetSP new_target,
+ const Breakpoint& bp_to_copy_from) {
+ if (!new_target)
+ return BreakpointSP();
+
+ BreakpointSP bp(new Breakpoint(*new_target, bp_to_copy_from));
+ // Now go through and copy the filter & resolver:
+ bp->m_resolver_sp = bp_to_copy_from.m_resolver_sp->CopyForBreakpoint(bp);
+ bp->m_filter_sp = bp_to_copy_from.m_filter_sp->CreateCopy(new_target);
+ return bp;
+}
+
// Serialization
StructuredData::ObjectSP Breakpoint::SerializeToStructuredData() {
// Serialize the resolver:
@@ -120,8 +128,10 @@ StructuredData::ObjectSP Breakpoint::SerializeToStructuredData() {
}
lldb::BreakpointSP Breakpoint::CreateFromStructuredData(
- Target &target, StructuredData::ObjectSP &object_data, Status &error) {
+ TargetSP target_sp, StructuredData::ObjectSP &object_data, Status &error) {
BreakpointSP result_sp;
+ if (!target_sp)
+ return result_sp;
StructuredData::Dictionary *breakpoint_dict = object_data->GetAsDictionary();
@@ -155,11 +165,11 @@ lldb::BreakpointSP Breakpoint::CreateFromStructuredData(
SearchFilter::GetSerializationKey(), filter_dict);
SearchFilterSP filter_sp;
if (!success)
- filter_sp = std::make_shared<SearchFilterForUnconstrainedSearches>(
- target.shared_from_this());
+ filter_sp =
+ std::make_shared<SearchFilterForUnconstrainedSearches>(target_sp);
else {
- filter_sp = SearchFilter::CreateFromStructuredData(target, *filter_dict,
- create_error);
+ filter_sp = SearchFilter::CreateFromStructuredData(target_sp, *filter_dict,
+ create_error);
if (create_error.Fail()) {
error.SetErrorStringWithFormat(
"Error creating breakpoint filter from data: %s.",
@@ -170,6 +180,7 @@ lldb::BreakpointSP Breakpoint::CreateFromStructuredData(
std::unique_ptr<BreakpointOptions> options_up;
StructuredData::Dictionary *options_dict;
+ Target& target = *target_sp;
success = breakpoint_dict->GetValueForKeyAsDictionary(
BreakpointOptions::GetSerializationKey(), options_dict);
if (success) {
@@ -187,8 +198,8 @@ lldb::BreakpointSP Breakpoint::CreateFromStructuredData(
success = breakpoint_dict->GetValueForKeyAsBoolean(
Breakpoint::GetKey(OptionNames::Hardware), hardware);
- result_sp =
- target.CreateBreakpoint(filter_sp, resolver_sp, false, hardware, true);
+ result_sp = target.CreateBreakpoint(filter_sp, resolver_sp, false,
+ hardware, true);
if (result_sp && options_up) {
result_sp->m_options_up = std::move(options_up);
diff --git a/lldb/source/Breakpoint/BreakpointID.cpp b/lldb/source/Breakpoint/BreakpointID.cpp
index dc2e57cb085d..293baf4ad1c7 100644
--- a/lldb/source/Breakpoint/BreakpointID.cpp
+++ b/lldb/source/Breakpoint/BreakpointID.cpp
@@ -1,4 +1,4 @@
-//===-- BreakpointID.cpp ----------------------------------------*- C++ -*-===//
+//===-- BreakpointID.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -112,7 +112,7 @@ bool BreakpointID::StringIsBreakpointName(llvm::StringRef str, Status &error) {
// Cannot contain ., -, or space.
if (str.find_first_of(".- ") != llvm::StringRef::npos) {
error.SetErrorStringWithFormat("Breakpoint names cannot contain "
- "'.' or '-': \"%s\"",
+ "'.' or '-' or spaces: \"%s\"",
str.str().c_str());
return false;
}
diff --git a/lldb/source/Breakpoint/BreakpointIDList.cpp b/lldb/source/Breakpoint/BreakpointIDList.cpp
index de68c44ec6a4..705bc5ee1c8d 100644
--- a/lldb/source/Breakpoint/BreakpointIDList.cpp
+++ b/lldb/source/Breakpoint/BreakpointIDList.cpp
@@ -1,4 +1,4 @@
-//===-- BreakpointIDList.cpp ------------------------------------*- C++ -*-===//
+//===-- BreakpointIDList.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -144,7 +144,7 @@ void BreakpointIDList::FindAndReplaceIDRanges(Args &old_args, Target *target,
result.SetStatus(eReturnStatusFailed);
return;
} else
- names_found.insert(current_arg);
+ names_found.insert(std::string(current_arg));
} else if ((i + 2 < old_args.size()) &&
BreakpointID::IsRangeIdentifier(old_args[i + 1].ref()) &&
BreakpointID::IsValidIDExpression(current_arg) &&
diff --git a/lldb/source/Breakpoint/BreakpointList.cpp b/lldb/source/Breakpoint/BreakpointList.cpp
index 5b23c633d14c..a962703b9518 100644
--- a/lldb/source/Breakpoint/BreakpointList.cpp
+++ b/lldb/source/Breakpoint/BreakpointList.cpp
@@ -1,4 +1,4 @@
-//===-- BreakpointList.cpp --------------------------------------*- C++ -*-===//
+//===-- BreakpointList.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Breakpoint/BreakpointLocation.cpp b/lldb/source/Breakpoint/BreakpointLocation.cpp
index 7f08b08c6055..93d54c051ee5 100644
--- a/lldb/source/Breakpoint/BreakpointLocation.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocation.cpp
@@ -1,4 +1,4 @@
-//===-- BreakpointLocation.cpp ----------------------------------*- C++ -*-===//
+//===-- BreakpointLocation.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -369,7 +369,7 @@ BreakpointOptions *BreakpointLocation::GetLocationOptions() {
// potentially expensive and we don't want to do that for the simple case
// where someone is just disabling the location.
if (m_options_up == nullptr)
- m_options_up.reset(new BreakpointOptions(false));
+ m_options_up = std::make_unique<BreakpointOptions>(false);
return m_options_up.get();
}
@@ -597,7 +597,8 @@ void BreakpointLocation::GetDescription(Stream *s,
s->EOL();
s->Indent();
s->Printf("resolved = %s\n", IsResolved() ? "true" : "false");
-
+ s->Indent();
+ s->Printf("hardware = %s\n", IsHardware() ? "true" : "false");
s->Indent();
s->Printf("hit count = %-4u\n", GetHitCount());
@@ -608,8 +609,8 @@ void BreakpointLocation::GetDescription(Stream *s,
}
s->IndentLess();
} else if (level != eDescriptionLevelInitial) {
- s->Printf(", %sresolved, hit count = %u ", (IsResolved() ? "" : "un"),
- GetHitCount());
+ s->Printf(", %sresolved, %shit count = %u ", (IsResolved() ? "" : "un"),
+ (IsHardware() ? "hardware, " : ""), GetHitCount());
if (m_options_up) {
m_options_up->GetDescription(s, level);
}
diff --git a/lldb/source/Breakpoint/BreakpointLocationCollection.cpp b/lldb/source/Breakpoint/BreakpointLocationCollection.cpp
index 76084adbd2aa..1eb13cb12ba3 100644
--- a/lldb/source/Breakpoint/BreakpointLocationCollection.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocationCollection.cpp
@@ -1,4 +1,4 @@
-//===-- BreakpointLocationCollection.cpp ------------------------*- C++ -*-===//
+//===-- BreakpointLocationCollection.cpp ----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Breakpoint/BreakpointLocationList.cpp b/lldb/source/Breakpoint/BreakpointLocationList.cpp
index ee586127ee78..6d271864c445 100644
--- a/lldb/source/Breakpoint/BreakpointLocationList.cpp
+++ b/lldb/source/Breakpoint/BreakpointLocationList.cpp
@@ -1,4 +1,4 @@
-//===-- BreakpointLocationList.cpp ------------------------------*- C++ -*-===//
+//===-- BreakpointLocationList.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Breakpoint/BreakpointName.cpp b/lldb/source/Breakpoint/BreakpointName.cpp
index 749fa86bca9d..37903a002363 100644
--- a/lldb/source/Breakpoint/BreakpointName.cpp
+++ b/lldb/source/Breakpoint/BreakpointName.cpp
@@ -1,4 +1,4 @@
-//===-- BreakpointName.cpp --------------------------------------*- C++ -*-===//
+//===-- BreakpointName.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp b/lldb/source/Breakpoint/BreakpointOptions.cpp
index 8fd16f420c04..0ce7b0f852e8 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -1,4 +1,4 @@
-//===-- BreakpointOptions.cpp -----------------------------------*- C++ -*-===//
+//===-- BreakpointOptions.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -154,7 +154,7 @@ BreakpointOptions::BreakpointOptions(const BreakpointOptions &rhs)
m_ignore_count(rhs.m_ignore_count), m_thread_spec_up(),
m_auto_continue(rhs.m_auto_continue), m_set_flags(rhs.m_set_flags) {
if (rhs.m_thread_spec_up != nullptr)
- m_thread_spec_up.reset(new ThreadSpec(*rhs.m_thread_spec_up));
+ m_thread_spec_up = std::make_unique<ThreadSpec>(*rhs.m_thread_spec_up);
m_condition_text = rhs.m_condition_text;
m_condition_text_hash = rhs.m_condition_text_hash;
}
@@ -170,7 +170,7 @@ operator=(const BreakpointOptions &rhs) {
m_one_shot = rhs.m_one_shot;
m_ignore_count = rhs.m_ignore_count;
if (rhs.m_thread_spec_up != nullptr)
- m_thread_spec_up.reset(new ThreadSpec(*rhs.m_thread_spec_up));
+ m_thread_spec_up = std::make_unique<ThreadSpec>(*rhs.m_thread_spec_up);
m_condition_text = rhs.m_condition_text;
m_condition_text_hash = rhs.m_condition_text_hash;
m_auto_continue = rhs.m_auto_continue;
@@ -223,7 +223,8 @@ void BreakpointOptions::CopyOverSetOptions(const BreakpointOptions &incoming)
}
if (incoming.m_set_flags.Test(eThreadSpec) && incoming.m_thread_spec_up) {
if (!m_thread_spec_up)
- m_thread_spec_up.reset(new ThreadSpec(*incoming.m_thread_spec_up));
+ m_thread_spec_up =
+ std::make_unique<ThreadSpec>(*incoming.m_thread_spec_up);
else
*m_thread_spec_up = *incoming.m_thread_spec_up;
m_set_flags.Set(eThreadSpec);
@@ -509,7 +510,7 @@ const ThreadSpec *BreakpointOptions::GetThreadSpecNoCreate() const {
ThreadSpec *BreakpointOptions::GetThreadSpec() {
if (m_thread_spec_up == nullptr) {
m_set_flags.Set(eThreadSpec);
- m_thread_spec_up.reset(new ThreadSpec());
+ m_thread_spec_up = std::make_unique<ThreadSpec>();
}
return m_thread_spec_up.get();
@@ -630,11 +631,11 @@ bool BreakpointOptions::BreakpointOptionsCallbackFunction(
ExecutionContext exe_ctx(context->exe_ctx_ref);
Target *target = exe_ctx.GetTargetPtr();
if (target) {
- CommandReturnObject result;
Debugger &debugger = target->GetDebugger();
+ CommandReturnObject result(debugger.GetUseColor());
+
// Rig up the results secondary output stream to the debugger's, so the
// output will come out synchronously if the debugger is set up that way.
-
StreamSP output_stream(debugger.GetAsyncOutputStream());
StreamSP error_stream(debugger.GetAsyncErrorStream());
result.SetImmediateOutputStream(output_stream);
diff --git a/lldb/source/Breakpoint/BreakpointPrecondition.cpp b/lldb/source/Breakpoint/BreakpointPrecondition.cpp
index a387c75c8356..24a38f0767fe 100644
--- a/lldb/source/Breakpoint/BreakpointPrecondition.cpp
+++ b/lldb/source/Breakpoint/BreakpointPrecondition.cpp
@@ -1,4 +1,4 @@
-//===-- BreakpointPrecondition.cpp ------------------------------*- C++ -*-===//
+//===-- BreakpointPrecondition.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Breakpoint/BreakpointResolver.cpp b/lldb/source/Breakpoint/BreakpointResolver.cpp
index e0a4e6ac6712..7c03a0745ac6 100644
--- a/lldb/source/Breakpoint/BreakpointResolver.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolver.cpp
@@ -1,4 +1,4 @@
-//===-- BreakpointResolver.cpp ----------------------------------*- C++ -*-===//
+//===-- BreakpointResolver.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -60,7 +60,7 @@ BreakpointResolver::NameToResolverTy(llvm::StringRef name) {
return UnknownResolver;
}
-BreakpointResolver::BreakpointResolver(Breakpoint *bkpt,
+BreakpointResolver::BreakpointResolver(const BreakpointSP &bkpt,
const unsigned char resolverTy,
lldb::addr_t offset)
: m_breakpoint(bkpt), m_offset(offset), SubclassID(resolverTy) {}
@@ -163,7 +163,8 @@ StructuredData::DictionarySP BreakpointResolver::WrapOptionsDict(
return type_dict_sp;
}
-void BreakpointResolver::SetBreakpoint(Breakpoint *bkpt) {
+void BreakpointResolver::SetBreakpoint(const BreakpointSP &bkpt) {
+ assert(bkpt);
m_breakpoint = bkpt;
NotifyBreakpointSet();
}
@@ -327,7 +328,7 @@ void BreakpointResolver::AddLocation(SearchFilter &filter,
}
BreakpointLocationSP bp_loc_sp(AddLocation(line_start));
- if (log && bp_loc_sp && !m_breakpoint->IsInternal()) {
+ if (log && bp_loc_sp && !GetBreakpoint()->IsInternal()) {
StreamString s;
bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
LLDB_LOGF(log, "Added location (skipped prologue: %s): %s \n",
@@ -338,7 +339,7 @@ void BreakpointResolver::AddLocation(SearchFilter &filter,
BreakpointLocationSP BreakpointResolver::AddLocation(Address loc_addr,
bool *new_location) {
loc_addr.Slide(m_offset);
- return m_breakpoint->AddLocation(loc_addr, new_location);
+ return GetBreakpoint()->AddLocation(loc_addr, new_location);
}
void BreakpointResolver::SetOffset(lldb::addr_t offset) {
diff --git a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
index b98568098b4b..2c56912b56af 100644
--- a/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverAddress.cpp
@@ -1,4 +1,4 @@
-//===-- BreakpointResolverAddress.cpp ---------------------------*- C++ -*-===//
+//===-- BreakpointResolverAddress.cpp -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -22,21 +22,19 @@ using namespace lldb_private;
// BreakpointResolverAddress:
BreakpointResolverAddress::BreakpointResolverAddress(
- Breakpoint *bkpt, const Address &addr, const FileSpec &module_spec)
+ const BreakpointSP &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,
+BreakpointResolverAddress::BreakpointResolverAddress(const BreakpointSP &bkpt,
const Address &addr)
: BreakpointResolver(bkpt, BreakpointResolver::AddressResolver),
m_addr(addr), m_resolved_addr(LLDB_INVALID_ADDRESS), m_module_filespec() {
}
-BreakpointResolverAddress::~BreakpointResolverAddress() {}
-
BreakpointResolver *BreakpointResolverAddress::CreateFromStructuredData(
- Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
+ const BreakpointSP &bkpt, const StructuredData::Dictionary &options_dict,
Status &error) {
llvm::StringRef module_name;
lldb::addr_t addr_offset;
@@ -100,7 +98,7 @@ void BreakpointResolverAddress::ResolveBreakpoint(SearchFilter &filter) {
bool re_resolve = false;
if (m_addr.GetSection() || m_module_filespec)
re_resolve = true;
- else if (m_breakpoint->GetNumLocations() == 0)
+ else if (GetBreakpoint()->GetNumLocations() == 0)
re_resolve = true;
if (re_resolve)
@@ -113,7 +111,7 @@ void BreakpointResolverAddress::ResolveBreakpointInModules(
bool re_resolve = false;
if (m_addr.GetSection())
re_resolve = true;
- else if (m_breakpoint->GetNumLocations() == 0)
+ else if (GetBreakpoint()->GetNumLocations() == 0)
re_resolve = true;
if (re_resolve)
@@ -122,15 +120,16 @@ void BreakpointResolverAddress::ResolveBreakpointInModules(
Searcher::CallbackReturn BreakpointResolverAddress::SearchCallback(
SearchFilter &filter, SymbolContext &context, Address *addr) {
- assert(m_breakpoint != nullptr);
+ BreakpointSP breakpoint_sp = GetBreakpoint();
+ Breakpoint &breakpoint = *breakpoint_sp;
if (filter.AddressPasses(m_addr)) {
- if (m_breakpoint->GetNumLocations() == 0) {
+ if (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();
+ Target &target = breakpoint.GetTarget();
ModuleSpec module_spec(m_module_filespec);
ModuleSP module_sp = target.GetImages().FindFirstModule(module_spec);
if (module_sp) {
@@ -140,9 +139,9 @@ Searcher::CallbackReturn BreakpointResolverAddress::SearchCallback(
}
}
- m_resolved_addr = m_addr.GetLoadAddress(&m_breakpoint->GetTarget());
+ m_resolved_addr = m_addr.GetLoadAddress(&breakpoint.GetTarget());
BreakpointLocationSP bp_loc_sp(AddLocation(m_addr));
- if (bp_loc_sp && !m_breakpoint->IsInternal()) {
+ if (bp_loc_sp && !breakpoint.IsInternal()) {
StreamString s;
bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
Log *log(
@@ -150,9 +149,9 @@ Searcher::CallbackReturn BreakpointResolverAddress::SearchCallback(
LLDB_LOGF(log, "Added location: %s\n", s.GetData());
}
} else {
- BreakpointLocationSP loc_sp = m_breakpoint->GetLocationAtIndex(0);
+ BreakpointLocationSP loc_sp = breakpoint.GetLocationAtIndex(0);
lldb::addr_t cur_load_location =
- m_addr.GetLoadAddress(&m_breakpoint->GetTarget());
+ m_addr.GetLoadAddress(&breakpoint.GetTarget());
if (cur_load_location != m_resolved_addr) {
m_resolved_addr = cur_load_location;
loc_sp->ClearBreakpointSite();
@@ -169,7 +168,7 @@ lldb::SearchDepth BreakpointResolverAddress::GetDepth() {
void BreakpointResolverAddress::GetDescription(Stream *s) {
s->PutCString("address = ");
- m_addr.Dump(s, m_breakpoint->GetTarget().GetProcessSP().get(),
+ m_addr.Dump(s, GetBreakpoint()->GetTarget().GetProcessSP().get(),
Address::DumpStyleModuleWithFileAddress,
Address::DumpStyleLoadAddress);
}
@@ -177,8 +176,8 @@ void BreakpointResolverAddress::GetDescription(Stream *s) {
void BreakpointResolverAddress::Dump(Stream *s) const {}
lldb::BreakpointResolverSP
-BreakpointResolverAddress::CopyForBreakpoint(Breakpoint &breakpoint) {
+BreakpointResolverAddress::CopyForBreakpoint(BreakpointSP &breakpoint) {
lldb::BreakpointResolverSP ret_sp(
- new BreakpointResolverAddress(&breakpoint, m_addr));
+ new BreakpointResolverAddress(breakpoint, m_addr));
return ret_sp;
}
diff --git a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
index 2b26f65816bd..22a4b4ae33ae 100644
--- a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -1,4 +1,4 @@
-//===-- BreakpointResolverFileLine.cpp --------------------------*- C++ -*-===//
+//===-- BreakpointResolverFileLine.cpp ------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -20,7 +20,7 @@ using namespace lldb_private;
// BreakpointResolverFileLine:
BreakpointResolverFileLine::BreakpointResolverFileLine(
- Breakpoint *bkpt, const FileSpec &file_spec, uint32_t line_no,
+ const BreakpointSP &bkpt, const FileSpec &file_spec, uint32_t line_no,
uint32_t column, lldb::addr_t offset, bool check_inlines,
bool skip_prologue, bool exact_match)
: BreakpointResolver(bkpt, BreakpointResolver::FileLineResolver, offset),
@@ -28,10 +28,8 @@ BreakpointResolverFileLine::BreakpointResolverFileLine(
m_inlines(check_inlines), m_skip_prologue(skip_prologue),
m_exact_match(exact_match) {}
-BreakpointResolverFileLine::~BreakpointResolverFileLine() {}
-
BreakpointResolver *BreakpointResolverFileLine::CreateFromStructuredData(
- Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
+ const BreakpointSP &bkpt, const StructuredData::Dictionary &options_dict,
Status &error) {
llvm::StringRef filename;
uint32_t line_no;
@@ -202,8 +200,6 @@ Searcher::CallbackReturn BreakpointResolverFileLine::SearchCallback(
SearchFilter &filter, SymbolContext &context, Address *addr) {
SymbolContextList sc_list;
- assert(m_breakpoint != nullptr);
-
// There is a tricky bit here. You can have two compilation units that
// #include the same file, and in one of them the function at m_line_number
// is used (and so code and a line entry for it is generated) but in the
@@ -263,9 +259,9 @@ void BreakpointResolverFileLine::GetDescription(Stream *s) {
void BreakpointResolverFileLine::Dump(Stream *s) const {}
lldb::BreakpointResolverSP
-BreakpointResolverFileLine::CopyForBreakpoint(Breakpoint &breakpoint) {
+BreakpointResolverFileLine::CopyForBreakpoint(BreakpointSP &breakpoint) {
lldb::BreakpointResolverSP ret_sp(new BreakpointResolverFileLine(
- &breakpoint, m_file_spec, m_line_number, m_column, m_offset, m_inlines,
+ breakpoint, m_file_spec, m_line_number, m_column, GetOffset(), m_inlines,
m_skip_prologue, m_exact_match));
return ret_sp;
diff --git a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
index 6b600a7cf128..62462b2f5441 100644
--- a/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
@@ -1,4 +1,4 @@
-//===-- BreakpointResolverFileRegex.cpp -------------------------*- C++-*-===//
+//===-- BreakpointResolverFileRegex.cpp -----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -20,16 +20,14 @@ using namespace lldb_private;
// BreakpointResolverFileRegex:
BreakpointResolverFileRegex::BreakpointResolverFileRegex(
- Breakpoint *bkpt, RegularExpression regex,
+ const lldb::BreakpointSP &bkpt, RegularExpression regex,
const std::unordered_set<std::string> &func_names, bool exact_match)
: BreakpointResolver(bkpt, BreakpointResolver::FileRegexResolver),
m_regex(std::move(regex)), m_exact_match(exact_match),
m_function_names(func_names) {}
-BreakpointResolverFileRegex::~BreakpointResolverFileRegex() {}
-
BreakpointResolver *BreakpointResolverFileRegex::CreateFromStructuredData(
- Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
+ const lldb::BreakpointSP &bkpt, const StructuredData::Dictionary &options_dict,
Status &error) {
bool success;
@@ -65,7 +63,7 @@ BreakpointResolver *BreakpointResolverFileRegex::CreateFromStructuredData(
"BRFR::CFSD: Malformed element %zu in the names array.", i);
return nullptr;
}
- names_set.insert(name);
+ names_set.insert(std::string(name));
}
}
@@ -97,7 +95,6 @@ BreakpointResolverFileRegex::SerializeToStructuredData() {
Searcher::CallbackReturn BreakpointResolverFileRegex::SearchCallback(
SearchFilter &filter, SymbolContext &context, Address *addr) {
- assert(m_breakpoint != nullptr);
if (!context.target_sp)
return eCallbackReturnContinue;
@@ -144,7 +141,6 @@ Searcher::CallbackReturn BreakpointResolverFileRegex::SearchCallback(
BreakpointResolver::SetSCMatchesByLine(filter, sc_list, skip_prologue,
m_regex.GetText());
}
- assert(m_breakpoint != nullptr);
return Searcher::eCallbackReturnContinue;
}
@@ -161,9 +157,9 @@ void BreakpointResolverFileRegex::GetDescription(Stream *s) {
void BreakpointResolverFileRegex::Dump(Stream *s) const {}
lldb::BreakpointResolverSP
-BreakpointResolverFileRegex::CopyForBreakpoint(Breakpoint &breakpoint) {
+BreakpointResolverFileRegex::CopyForBreakpoint(BreakpointSP &breakpoint) {
lldb::BreakpointResolverSP ret_sp(new BreakpointResolverFileRegex(
- &breakpoint, m_regex, m_function_names, m_exact_match));
+ breakpoint, m_regex, m_function_names, m_exact_match));
return ret_sp;
}
diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp b/lldb/source/Breakpoint/BreakpointResolverName.cpp
index ba9c88c7eae8..25f5bb3f6eed 100644
--- a/lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -1,4 +1,4 @@
-//===-- BreakpointResolverName.cpp ------------------------------*- C++ -*-===//
+//===-- BreakpointResolverName.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -23,8 +23,8 @@
using namespace lldb;
using namespace lldb_private;
-BreakpointResolverName::BreakpointResolverName(
- Breakpoint *bkpt, const char *name_cstr, FunctionNameType name_type_mask,
+BreakpointResolverName::BreakpointResolverName(const BreakpointSP &bkpt,
+ const char *name_cstr, FunctionNameType name_type_mask,
LanguageType language, Breakpoint::MatchType type, lldb::addr_t offset,
bool skip_prologue)
: BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
@@ -45,7 +45,7 @@ BreakpointResolverName::BreakpointResolverName(
}
BreakpointResolverName::BreakpointResolverName(
- Breakpoint *bkpt, const char *names[], size_t num_names,
+ const BreakpointSP &bkpt, const char *names[], size_t num_names,
FunctionNameType name_type_mask, LanguageType language, lldb::addr_t offset,
bool skip_prologue)
: BreakpointResolver(bkpt, BreakpointResolver::NameResolver, offset),
@@ -56,7 +56,7 @@ BreakpointResolverName::BreakpointResolverName(
}
}
-BreakpointResolverName::BreakpointResolverName(Breakpoint *bkpt,
+BreakpointResolverName::BreakpointResolverName(const BreakpointSP &bkpt,
std::vector<std::string> names,
FunctionNameType name_type_mask,
LanguageType language,
@@ -70,7 +70,7 @@ BreakpointResolverName::BreakpointResolverName(Breakpoint *bkpt,
}
}
-BreakpointResolverName::BreakpointResolverName(Breakpoint *bkpt,
+BreakpointResolverName::BreakpointResolverName(const BreakpointSP &bkpt,
RegularExpression func_regex,
lldb::LanguageType language,
lldb::addr_t offset,
@@ -80,18 +80,16 @@ BreakpointResolverName::BreakpointResolverName(Breakpoint *bkpt,
m_match_type(Breakpoint::Regexp), m_language(language),
m_skip_prologue(skip_prologue) {}
-BreakpointResolverName::~BreakpointResolverName() = default;
-
BreakpointResolverName::BreakpointResolverName(
const BreakpointResolverName &rhs)
- : BreakpointResolver(rhs.m_breakpoint, BreakpointResolver::NameResolver,
- rhs.m_offset),
+ : BreakpointResolver(rhs.GetBreakpoint(), BreakpointResolver::NameResolver,
+ rhs.GetOffset()),
m_lookups(rhs.m_lookups), 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) {}
BreakpointResolver *BreakpointResolverName::CreateFromStructuredData(
- Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
+ const BreakpointSP &bkpt, const StructuredData::Dictionary &options_dict,
Status &error) {
LanguageType language = eLanguageTypeUnknown;
llvm::StringRef language_name;
@@ -173,7 +171,7 @@ BreakpointResolver *BreakpointResolverName::CreateFromStructuredData(
error.SetErrorString("BRN::CFSD: name mask entry is not an integer.");
return nullptr;
}
- names.push_back(name);
+ names.push_back(std::string(name));
name_masks.push_back(static_cast<FunctionNameType>(fnt));
}
@@ -199,7 +197,7 @@ StructuredData::ObjectSP BreakpointResolverName::SerializeToStructuredData() {
StructuredData::ArraySP name_masks_sp(new StructuredData::Array());
for (auto lookup : m_lookups) {
names_sp->AddItem(StructuredData::StringSP(
- new StructuredData::String(lookup.GetName().AsCString())));
+ new StructuredData::String(lookup.GetName().GetStringRef())));
name_masks_sp->AddItem(StructuredData::IntegerSP(
new StructuredData::Integer(lookup.GetNameTypeMask())));
}
@@ -251,14 +249,6 @@ void BreakpointResolverName::AddNameLookup(ConstString name,
Searcher::CallbackReturn
BreakpointResolverName::SearchCallback(SearchFilter &filter,
SymbolContext &context, Address *addr) {
- SymbolContextList func_list;
- // SymbolContextList sym_list;
-
- uint32_t i;
- bool new_location;
- Address break_addr;
- assert(m_breakpoint != nullptr);
-
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
if (m_class_name) {
@@ -266,6 +256,8 @@ BreakpointResolverName::SearchCallback(SearchFilter &filter,
log->Warning("Class/method function specification not supported yet.\n");
return Searcher::eCallbackReturnStop;
}
+
+ SymbolContextList func_list;
bool filter_by_cu =
(filter.GetFilterRequiredItems() & eSymbolContextCompUnit) != 0;
bool filter_by_language = (m_language != eLanguageTypeUnknown);
@@ -278,8 +270,9 @@ BreakpointResolverName::SearchCallback(SearchFilter &filter,
for (const auto &lookup : m_lookups) {
const size_t start_func_idx = func_list.GetSize();
context.module_sp->FindFunctions(
- lookup.GetLookupName(), nullptr, lookup.GetNameTypeMask(),
- include_symbols, include_inlines, func_list);
+ lookup.GetLookupName(), CompilerDeclContext(),
+ lookup.GetNameTypeMask(), include_symbols, include_inlines,
+ func_list);
const size_t end_func_idx = func_list.GetSize();
@@ -333,66 +326,72 @@ BreakpointResolverName::SearchCallback(SearchFilter &filter,
}
}
+ BreakpointSP breakpoint_sp = GetBreakpoint();
+ Breakpoint &breakpoint = *breakpoint_sp;
+ Address break_addr;
+
// Remove any duplicates between the function list and the symbol list
SymbolContext sc;
- if (func_list.GetSize()) {
- for (i = 0; i < func_list.GetSize(); i++) {
- if (func_list.GetContextAtIndex(i, sc)) {
- bool is_reexported = false;
-
- if (sc.block && sc.block->GetInlinedFunctionInfo()) {
- if (!sc.block->GetStartAddress(break_addr))
- break_addr.Clear();
- } else if (sc.function) {
- break_addr = sc.function->GetAddressRange().GetBaseAddress();
- if (m_skip_prologue && break_addr.IsValid()) {
- const uint32_t prologue_byte_size =
- sc.function->GetPrologueByteSize();
- if (prologue_byte_size)
- break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
- }
- } else if (sc.symbol) {
- if (sc.symbol->GetType() == eSymbolTypeReExported) {
- const Symbol *actual_symbol =
- sc.symbol->ResolveReExportedSymbol(m_breakpoint->GetTarget());
- if (actual_symbol) {
- is_reexported = true;
- break_addr = actual_symbol->GetAddress();
- }
- } else {
- break_addr = sc.symbol->GetAddress();
- }
-
- if (m_skip_prologue && break_addr.IsValid()) {
- const uint32_t prologue_byte_size =
- sc.symbol->GetPrologueByteSize();
- if (prologue_byte_size)
- break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
- else {
- const Architecture *arch =
- m_breakpoint->GetTarget().GetArchitecturePlugin();
- if (arch)
- arch->AdjustBreakpointAddress(*sc.symbol, break_addr);
- }
- }
+ if (!func_list.GetSize())
+ return Searcher::eCallbackReturnContinue;
+
+ for (uint32_t i = 0; i < func_list.GetSize(); i++) {
+ if (!func_list.GetContextAtIndex(i, sc))
+ continue;
+
+ bool is_reexported = false;
+
+ if (sc.block && sc.block->GetInlinedFunctionInfo()) {
+ if (!sc.block->GetStartAddress(break_addr))
+ break_addr.Clear();
+ } else if (sc.function) {
+ break_addr = sc.function->GetAddressRange().GetBaseAddress();
+ if (m_skip_prologue && break_addr.IsValid()) {
+ const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize();
+ if (prologue_byte_size)
+ break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
+ }
+ } else if (sc.symbol) {
+ if (sc.symbol->GetType() == eSymbolTypeReExported) {
+ const Symbol *actual_symbol =
+ sc.symbol->ResolveReExportedSymbol(breakpoint.GetTarget());
+ if (actual_symbol) {
+ is_reexported = true;
+ break_addr = actual_symbol->GetAddress();
}
+ } else {
+ break_addr = sc.symbol->GetAddress();
+ }
- if (break_addr.IsValid()) {
- if (filter.AddressPasses(break_addr)) {
- BreakpointLocationSP bp_loc_sp(
- AddLocation(break_addr, &new_location));
- bp_loc_sp->SetIsReExported(is_reexported);
- if (bp_loc_sp && new_location && !m_breakpoint->IsInternal()) {
- if (log) {
- StreamString s;
- bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
- LLDB_LOGF(log, "Added location: %s\n", s.GetData());
- }
- }
- }
+ if (m_skip_prologue && break_addr.IsValid()) {
+ const uint32_t prologue_byte_size = sc.symbol->GetPrologueByteSize();
+ if (prologue_byte_size)
+ break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
+ else {
+ const Architecture *arch =
+ breakpoint.GetTarget().GetArchitecturePlugin();
+ if (arch)
+ arch->AdjustBreakpointAddress(*sc.symbol, break_addr);
}
}
}
+
+ if (!break_addr.IsValid())
+ continue;
+
+ if (!filter.AddressPasses(break_addr))
+ continue;
+
+ bool new_location;
+ BreakpointLocationSP bp_loc_sp(AddLocation(break_addr, &new_location));
+ bp_loc_sp->SetIsReExported(is_reexported);
+ if (bp_loc_sp && new_location && !breakpoint.IsInternal()) {
+ if (log) {
+ StreamString s;
+ bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose);
+ LLDB_LOGF(log, "Added location: %s\n", s.GetData());
+ }
+ }
}
return Searcher::eCallbackReturnContinue;
@@ -426,8 +425,8 @@ void BreakpointResolverName::GetDescription(Stream *s) {
void BreakpointResolverName::Dump(Stream *s) const {}
lldb::BreakpointResolverSP
-BreakpointResolverName::CopyForBreakpoint(Breakpoint &breakpoint) {
+BreakpointResolverName::CopyForBreakpoint(BreakpointSP &breakpoint) {
lldb::BreakpointResolverSP ret_sp(new BreakpointResolverName(*this));
- ret_sp->SetBreakpoint(&breakpoint);
+ ret_sp->SetBreakpoint(breakpoint);
return ret_sp;
}
diff --git a/lldb/source/Breakpoint/BreakpointResolverScripted.cpp b/lldb/source/Breakpoint/BreakpointResolverScripted.cpp
index 288fd37c1c79..92297fbc7c4b 100644
--- a/lldb/source/Breakpoint/BreakpointResolverScripted.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverScripted.cpp
@@ -1,4 +1,4 @@
-//===-- BreakpointResolverScripted.cpp ---------------------------*- C++ -*-===//
+//===-- BreakpointResolverScripted.cpp ------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -26,43 +26,42 @@ using namespace lldb_private;
// BreakpointResolverScripted:
BreakpointResolverScripted::BreakpointResolverScripted(
- Breakpoint *bkpt,
- const llvm::StringRef class_name,
- lldb::SearchDepth depth,
- StructuredDataImpl *args_data)
+ const BreakpointSP &bkpt, const llvm::StringRef class_name,
+ lldb::SearchDepth depth, StructuredDataImpl *args_data)
: BreakpointResolver(bkpt, BreakpointResolver::PythonResolver),
- m_class_name(class_name), m_depth(depth), m_args_ptr(args_data) {
- CreateImplementationIfNeeded();
+ m_class_name(std::string(class_name)), m_depth(depth),
+ m_args_ptr(args_data) {
+ CreateImplementationIfNeeded(bkpt);
}
-void BreakpointResolverScripted::CreateImplementationIfNeeded() {
+void BreakpointResolverScripted::CreateImplementationIfNeeded(
+ BreakpointSP breakpoint_sp) {
if (m_implementation_sp)
return;
-
+
if (m_class_name.empty())
return;
-
- if (m_breakpoint) {
- TargetSP target_sp = m_breakpoint->GetTargetSP();
- ScriptInterpreter *script_interp = target_sp->GetDebugger()
- .GetScriptInterpreter();
- if (!script_interp)
- return;
- lldb::BreakpointSP bkpt_sp(m_breakpoint->shared_from_this());
- m_implementation_sp = script_interp->CreateScriptedBreakpointResolver(
- m_class_name.c_str(), m_args_ptr, bkpt_sp);
- }
+
+ if (!breakpoint_sp)
+ return;
+
+ TargetSP target_sp = breakpoint_sp->GetTargetSP();
+ ScriptInterpreter *script_interp = target_sp->GetDebugger()
+ .GetScriptInterpreter();
+ if (!script_interp)
+ return;
+
+ m_implementation_sp = script_interp->CreateScriptedBreakpointResolver(
+ m_class_name.c_str(), m_args_ptr, breakpoint_sp);
}
void BreakpointResolverScripted::NotifyBreakpointSet() {
- CreateImplementationIfNeeded();
+ CreateImplementationIfNeeded(GetBreakpoint());
}
-BreakpointResolverScripted::~BreakpointResolverScripted() {}
-
BreakpointResolver *
BreakpointResolverScripted::CreateFromStructuredData(
- Breakpoint *bkpt, const StructuredData::Dictionary &options_dict,
+ const BreakpointSP &bkpt, const StructuredData::Dictionary &options_dict,
Status &error) {
llvm::StringRef class_name;
bool success;
@@ -103,29 +102,27 @@ BreakpointResolverScripted::SerializeToStructuredData() {
}
ScriptInterpreter *BreakpointResolverScripted::GetScriptInterpreter() {
- return m_breakpoint->GetTarget().GetDebugger().GetScriptInterpreter();
+ return GetBreakpoint()->GetTarget().GetDebugger().GetScriptInterpreter();
}
Searcher::CallbackReturn BreakpointResolverScripted::SearchCallback(
SearchFilter &filter, SymbolContext &context, Address *addr) {
- assert(m_breakpoint != nullptr);
bool should_continue = true;
if (!m_implementation_sp)
return Searcher::eCallbackReturnStop;
-
+
ScriptInterpreter *interp = GetScriptInterpreter();
should_continue = interp->ScriptedBreakpointResolverSearchCallback(
m_implementation_sp,
&context);
if (should_continue)
return Searcher::eCallbackReturnContinue;
- else
- return Searcher::eCallbackReturnStop;
+
+ return Searcher::eCallbackReturnStop;
}
lldb::SearchDepth
BreakpointResolverScripted::GetDepth() {
- assert(m_breakpoint != nullptr);
lldb::SearchDepth depth = lldb::eSearchDepthModule;
if (m_implementation_sp) {
ScriptInterpreter *interp = GetScriptInterpreter();
@@ -153,11 +150,11 @@ void BreakpointResolverScripted::GetDescription(Stream *s) {
void BreakpointResolverScripted::Dump(Stream *s) const {}
lldb::BreakpointResolverSP
-BreakpointResolverScripted::CopyForBreakpoint(Breakpoint &breakpoint) {
+BreakpointResolverScripted::CopyForBreakpoint(BreakpointSP &breakpoint) {
// FIXME: Have to make a copy of the arguments from the m_args_ptr and then
// pass that to the new resolver.
lldb::BreakpointResolverSP ret_sp(
- new BreakpointResolverScripted(&breakpoint, m_class_name, m_depth,
+ new BreakpointResolverScripted(breakpoint, m_class_name, m_depth,
nullptr));
return ret_sp;
}
diff --git a/lldb/source/Breakpoint/BreakpointSite.cpp b/lldb/source/Breakpoint/BreakpointSite.cpp
index a757a01824c7..a33fd0a1c462 100644
--- a/lldb/source/Breakpoint/BreakpointSite.cpp
+++ b/lldb/source/Breakpoint/BreakpointSite.cpp
@@ -1,4 +1,4 @@
-//===-- BreakpointSite.cpp --------------------------------------*- C++ -*-===//
+//===-- BreakpointSite.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -156,6 +156,13 @@ void BreakpointSite::BumpHitCounts() {
}
}
+void BreakpointSite::SetHardwareIndex(uint32_t index) {
+ std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
+ for (BreakpointLocationSP loc_sp : m_owners.BreakpointLocations()) {
+ loc_sp->SetHardwareIndex(index);
+ }
+}
+
bool BreakpointSite::IntersectsRange(lldb::addr_t addr, size_t size,
lldb::addr_t *intersect_addr,
size_t *intersect_size,
diff --git a/lldb/source/Breakpoint/BreakpointSiteList.cpp b/lldb/source/Breakpoint/BreakpointSiteList.cpp
index 7a986fd83983..873ba6236a72 100644
--- a/lldb/source/Breakpoint/BreakpointSiteList.cpp
+++ b/lldb/source/Breakpoint/BreakpointSiteList.cpp
@@ -1,4 +1,4 @@
-//===-- BreakpointSiteList.cpp ----------------------------------*- C++ -*-===//
+//===-- BreakpointSiteList.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Breakpoint/Stoppoint.cpp b/lldb/source/Breakpoint/Stoppoint.cpp
index 4cab975fe320..b5c8334333cf 100644
--- a/lldb/source/Breakpoint/Stoppoint.cpp
+++ b/lldb/source/Breakpoint/Stoppoint.cpp
@@ -1,4 +1,4 @@
-//===-- Stoppoint.cpp -------------------------------------------*- C++ -*-===//
+//===-- Stoppoint.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Breakpoint/StoppointCallbackContext.cpp b/lldb/source/Breakpoint/StoppointCallbackContext.cpp
index 584bf0060a4a..640db8bb9c96 100644
--- a/lldb/source/Breakpoint/StoppointCallbackContext.cpp
+++ b/lldb/source/Breakpoint/StoppointCallbackContext.cpp
@@ -1,4 +1,4 @@
-//===-- StoppointCallbackContext.cpp ----------------------------*- C++ -*-===//
+//===-- StoppointCallbackContext.cpp --------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Breakpoint/StoppointLocation.cpp b/lldb/source/Breakpoint/StoppointLocation.cpp
index 8cc6791fa680..5bb4c7854840 100644
--- a/lldb/source/Breakpoint/StoppointLocation.cpp
+++ b/lldb/source/Breakpoint/StoppointLocation.cpp
@@ -1,4 +1,4 @@
-//===-- StoppointLocation.cpp -----------------------------------*- C++ -*-===//
+//===-- StoppointLocation.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Breakpoint/Watchpoint.cpp b/lldb/source/Breakpoint/Watchpoint.cpp
index 17dcda13e9b9..df73c6a17230 100644
--- a/lldb/source/Breakpoint/Watchpoint.cpp
+++ b/lldb/source/Breakpoint/Watchpoint.cpp
@@ -1,4 +1,4 @@
-//===-- Watchpoint.cpp ------------------------------------------*- C++ -*-===//
+//===-- Watchpoint.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Breakpoint/WatchpointList.cpp b/lldb/source/Breakpoint/WatchpointList.cpp
index b1c1e6f253eb..a6f651e84955 100644
--- a/lldb/source/Breakpoint/WatchpointList.cpp
+++ b/lldb/source/Breakpoint/WatchpointList.cpp
@@ -1,4 +1,4 @@
-//===-- WatchpointList.cpp --------------------------------------*- C++ -*-===//
+//===-- WatchpointList.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Breakpoint/WatchpointOptions.cpp b/lldb/source/Breakpoint/WatchpointOptions.cpp
index 026bf2f746ae..f01f5ad3dd27 100644
--- a/lldb/source/Breakpoint/WatchpointOptions.cpp
+++ b/lldb/source/Breakpoint/WatchpointOptions.cpp
@@ -1,4 +1,4 @@
-//===-- WatchpointOptions.cpp -----------------------------------*- C++ -*-===//
+//===-- WatchpointOptions.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -36,7 +36,7 @@ WatchpointOptions::WatchpointOptions(const WatchpointOptions &rhs)
m_callback_is_synchronous(rhs.m_callback_is_synchronous),
m_thread_spec_up() {
if (rhs.m_thread_spec_up != nullptr)
- m_thread_spec_up.reset(new ThreadSpec(*rhs.m_thread_spec_up));
+ m_thread_spec_up = std::make_unique<ThreadSpec>(*rhs.m_thread_spec_up);
}
// WatchpointOptions assignment operator
@@ -46,7 +46,7 @@ operator=(const WatchpointOptions &rhs) {
m_callback_baton_sp = rhs.m_callback_baton_sp;
m_callback_is_synchronous = rhs.m_callback_is_synchronous;
if (rhs.m_thread_spec_up != nullptr)
- m_thread_spec_up.reset(new ThreadSpec(*rhs.m_thread_spec_up));
+ m_thread_spec_up = std::make_unique<ThreadSpec>(*rhs.m_thread_spec_up);
return *this;
}
@@ -108,7 +108,7 @@ const ThreadSpec *WatchpointOptions::GetThreadSpecNoCreate() const {
ThreadSpec *WatchpointOptions::GetThreadSpec() {
if (m_thread_spec_up == nullptr)
- m_thread_spec_up.reset(new ThreadSpec());
+ m_thread_spec_up = std::make_unique<ThreadSpec>();
return m_thread_spec_up.get();
}
diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp
index d9bee66b442a..48df77357201 100644
--- a/lldb/source/Commands/CommandCompletions.cpp
+++ b/lldb/source/Commands/CommandCompletions.cpp
@@ -1,4 +1,4 @@
-//===-- CommandCompletions.cpp ----------------------------------*- C++ -*-===//
+//===-- CommandCompletions.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -18,6 +18,7 @@
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Variable.h"
+#include "lldb/Target/RegisterContext.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/TildeExpressionResolver.h"
@@ -27,19 +28,17 @@
using namespace lldb_private;
-CommandCompletions::CommonCompletionElement
- CommandCompletions::g_common_completions[] = {
- {eCustomCompletion, nullptr},
- {eSourceFileCompletion, CommandCompletions::SourceFiles},
- {eDiskFileCompletion, CommandCompletions::DiskFiles},
- {eDiskDirectoryCompletion, CommandCompletions::DiskDirectories},
- {eSymbolCompletion, CommandCompletions::Symbols},
- {eModuleCompletion, CommandCompletions::Modules},
- {eSettingsNameCompletion, CommandCompletions::SettingsNames},
- {ePlatformPluginCompletion, CommandCompletions::PlatformPluginNames},
- {eArchitectureCompletion, CommandCompletions::ArchitectureNames},
- {eVariablePathCompletion, CommandCompletions::VariablePath},
- {eNoCompletion, nullptr} // This one has to be last in the list.
+// This is the command completion callback that is used to complete the
+// argument of the option it is bound to (in the OptionDefinition table
+// below).
+typedef void (*CompletionCallback)(CommandInterpreter &interpreter,
+ CompletionRequest &request,
+ // A search filter to limit the search...
+ lldb_private::SearchFilter *searcher);
+
+struct CommonCompletionElement {
+ uint32_t type;
+ CompletionCallback callback;
};
bool CommandCompletions::InvokeCommonCompletionCallbacks(
@@ -47,27 +46,245 @@ bool CommandCompletions::InvokeCommonCompletionCallbacks(
CompletionRequest &request, SearchFilter *searcher) {
bool handled = false;
- if (completion_mask & eCustomCompletion)
- return false;
+ const CommonCompletionElement common_completions[] = {
+ {eSourceFileCompletion, CommandCompletions::SourceFiles},
+ {eDiskFileCompletion, CommandCompletions::DiskFiles},
+ {eDiskDirectoryCompletion, CommandCompletions::DiskDirectories},
+ {eSymbolCompletion, CommandCompletions::Symbols},
+ {eModuleCompletion, CommandCompletions::Modules},
+ {eSettingsNameCompletion, CommandCompletions::SettingsNames},
+ {ePlatformPluginCompletion, CommandCompletions::PlatformPluginNames},
+ {eArchitectureCompletion, CommandCompletions::ArchitectureNames},
+ {eVariablePathCompletion, CommandCompletions::VariablePath},
+ {eRegisterCompletion, CommandCompletions::Registers},
+ {eBreakpointCompletion, CommandCompletions::Breakpoints},
+ {eProcessPluginCompletion, CommandCompletions::ProcessPluginNames},
+ {eNoCompletion, nullptr} // This one has to be last in the list.
+ };
for (int i = 0;; i++) {
- if (g_common_completions[i].type == eNoCompletion)
+ if (common_completions[i].type == eNoCompletion)
break;
- else if ((g_common_completions[i].type & completion_mask) ==
- g_common_completions[i].type &&
- g_common_completions[i].callback != nullptr) {
+ else if ((common_completions[i].type & completion_mask) ==
+ common_completions[i].type &&
+ common_completions[i].callback != nullptr) {
handled = true;
- g_common_completions[i].callback(interpreter, request, searcher);
+ common_completions[i].callback(interpreter, request, searcher);
}
}
return handled;
}
+namespace {
+// The Completer class is a convenient base class for building searchers that
+// go along with the SearchFilter passed to the standard Completer functions.
+class Completer : public Searcher {
+public:
+ Completer(CommandInterpreter &interpreter, CompletionRequest &request)
+ : m_interpreter(interpreter), m_request(request) {}
+
+ ~Completer() override = default;
+
+ CallbackReturn SearchCallback(SearchFilter &filter, SymbolContext &context,
+ Address *addr) override = 0;
+
+ lldb::SearchDepth GetDepth() override = 0;
+
+ virtual void DoCompletion(SearchFilter *filter) = 0;
+
+protected:
+ CommandInterpreter &m_interpreter;
+ CompletionRequest &m_request;
+
+private:
+ Completer(const Completer &) = delete;
+ const Completer &operator=(const Completer &) = delete;
+};
+} // namespace
+
+// SourceFileCompleter implements the source file completer
+namespace {
+class SourceFileCompleter : public Completer {
+public:
+ SourceFileCompleter(CommandInterpreter &interpreter,
+ CompletionRequest &request)
+ : Completer(interpreter, request), m_matching_files() {
+ FileSpec partial_spec(m_request.GetCursorArgumentPrefix());
+ m_file_name = partial_spec.GetFilename().GetCString();
+ m_dir_name = partial_spec.GetDirectory().GetCString();
+ }
+
+ lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthCompUnit; }
+
+ Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address *addr) override {
+ if (context.comp_unit != nullptr) {
+ const char *cur_file_name =
+ context.comp_unit->GetPrimaryFile().GetFilename().GetCString();
+ const char *cur_dir_name =
+ context.comp_unit->GetPrimaryFile().GetDirectory().GetCString();
+
+ bool match = false;
+ if (m_file_name && cur_file_name &&
+ strstr(cur_file_name, m_file_name) == cur_file_name)
+ match = true;
+
+ if (match && m_dir_name && cur_dir_name &&
+ strstr(cur_dir_name, m_dir_name) != cur_dir_name)
+ match = false;
+
+ if (match) {
+ m_matching_files.AppendIfUnique(context.comp_unit->GetPrimaryFile());
+ }
+ }
+ return Searcher::eCallbackReturnContinue;
+ }
+
+ void DoCompletion(SearchFilter *filter) override {
+ filter->Search(*this);
+ // Now convert the filelist to completions:
+ for (size_t i = 0; i < m_matching_files.GetSize(); i++) {
+ m_request.AddCompletion(
+ m_matching_files.GetFileSpecAtIndex(i).GetFilename().GetCString());
+ }
+ }
+
+private:
+ FileSpecList m_matching_files;
+ const char *m_file_name;
+ const char *m_dir_name;
+
+ SourceFileCompleter(const SourceFileCompleter &) = delete;
+ const SourceFileCompleter &operator=(const SourceFileCompleter &) = delete;
+};
+} // namespace
+
+static bool regex_chars(const char comp) {
+ return llvm::StringRef("[](){}+.*|^$\\?").contains(comp);
+}
+
+namespace {
+class SymbolCompleter : public Completer {
+
+public:
+ SymbolCompleter(CommandInterpreter &interpreter, CompletionRequest &request)
+ : Completer(interpreter, request) {
+ std::string regex_str;
+ if (!m_request.GetCursorArgumentPrefix().empty()) {
+ regex_str.append("^");
+ regex_str.append(std::string(m_request.GetCursorArgumentPrefix()));
+ } else {
+ // Match anything since the completion string is empty
+ regex_str.append(".");
+ }
+ std::string::iterator pos =
+ find_if(regex_str.begin() + 1, regex_str.end(), regex_chars);
+ while (pos < regex_str.end()) {
+ pos = regex_str.insert(pos, '\\');
+ pos = find_if(pos + 2, regex_str.end(), regex_chars);
+ }
+ m_regex = RegularExpression(regex_str);
+ }
+
+ lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
+
+ Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address *addr) override {
+ if (context.module_sp) {
+ SymbolContextList sc_list;
+ const bool include_symbols = true;
+ const bool include_inlines = true;
+ context.module_sp->FindFunctions(m_regex, include_symbols,
+ include_inlines, sc_list);
+
+ SymbolContext sc;
+ // Now add the functions & symbols to the list - only add if unique:
+ for (uint32_t i = 0; i < sc_list.GetSize(); i++) {
+ if (sc_list.GetContextAtIndex(i, sc)) {
+ ConstString func_name = sc.GetFunctionName(Mangled::ePreferDemangled);
+ // Ensure that the function name matches the regex. This is more than
+ // a sanity check. It is possible that the demangled function name
+ // does not start with the prefix, for example when it's in an
+ // anonymous namespace.
+ if (!func_name.IsEmpty() && m_regex.Execute(func_name.GetStringRef()))
+ m_match_set.insert(func_name);
+ }
+ }
+ }
+ return Searcher::eCallbackReturnContinue;
+ }
+
+ void DoCompletion(SearchFilter *filter) override {
+ filter->Search(*this);
+ collection::iterator pos = m_match_set.begin(), end = m_match_set.end();
+ for (pos = m_match_set.begin(); pos != end; pos++)
+ m_request.AddCompletion((*pos).GetCString());
+ }
+
+private:
+ RegularExpression m_regex;
+ typedef std::set<ConstString> collection;
+ collection m_match_set;
+
+ SymbolCompleter(const SymbolCompleter &) = delete;
+ const SymbolCompleter &operator=(const SymbolCompleter &) = delete;
+};
+} // namespace
+
+namespace {
+class ModuleCompleter : public Completer {
+public:
+ ModuleCompleter(CommandInterpreter &interpreter, CompletionRequest &request)
+ : Completer(interpreter, request) {
+ FileSpec partial_spec(m_request.GetCursorArgumentPrefix());
+ m_file_name = partial_spec.GetFilename().GetCString();
+ m_dir_name = partial_spec.GetDirectory().GetCString();
+ }
+
+ lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
+
+ Searcher::CallbackReturn SearchCallback(SearchFilter &filter,
+ SymbolContext &context,
+ Address *addr) override {
+ if (context.module_sp) {
+ const char *cur_file_name =
+ context.module_sp->GetFileSpec().GetFilename().GetCString();
+ const char *cur_dir_name =
+ context.module_sp->GetFileSpec().GetDirectory().GetCString();
+
+ bool match = false;
+ if (m_file_name && cur_file_name &&
+ strstr(cur_file_name, m_file_name) == cur_file_name)
+ match = true;
+
+ if (match && m_dir_name && cur_dir_name &&
+ strstr(cur_dir_name, m_dir_name) != cur_dir_name)
+ match = false;
+
+ if (match) {
+ m_request.AddCompletion(cur_file_name);
+ }
+ }
+ return Searcher::eCallbackReturnContinue;
+ }
+
+ void DoCompletion(SearchFilter *filter) override { filter->Search(*this); }
+
+private:
+ const char *m_file_name;
+ const char *m_dir_name;
+
+ ModuleCompleter(const ModuleCompleter &) = delete;
+ const ModuleCompleter &operator=(const ModuleCompleter &) = delete;
+};
+} // namespace
+
void CommandCompletions::SourceFiles(CommandInterpreter &interpreter,
CompletionRequest &request,
SearchFilter *searcher) {
- // Find some way to switch "include support files..."
- SourceFileCompleter completer(interpreter, false, request);
+ SourceFileCompleter completer(interpreter, request);
if (searcher == nullptr) {
lldb::TargetSP target_sp = interpreter.GetDebugger().GetSelectedTarget();
@@ -295,7 +512,7 @@ void CommandCompletions::SettingsNames(CommandInterpreter &interpreter,
if (properties_sp) {
StreamString strm;
properties_sp->DumpValue(nullptr, strm, OptionValue::eDumpOptionName);
- const std::string &str = strm.GetString();
+ const std::string &str = std::string(strm.GetString());
g_property_names.SplitIntoLines(str.c_str(), str.size());
}
}
@@ -323,185 +540,57 @@ void CommandCompletions::VariablePath(CommandInterpreter &interpreter,
Variable::AutoComplete(interpreter.GetExecutionContext(), request);
}
-CommandCompletions::Completer::Completer(CommandInterpreter &interpreter,
- CompletionRequest &request)
- : m_interpreter(interpreter), m_request(request) {}
-
-CommandCompletions::Completer::~Completer() = default;
-
-// SourceFileCompleter
-
-CommandCompletions::SourceFileCompleter::SourceFileCompleter(
- CommandInterpreter &interpreter, bool include_support_files,
- CompletionRequest &request)
- : CommandCompletions::Completer(interpreter, request),
- m_include_support_files(include_support_files), m_matching_files() {
- FileSpec partial_spec(m_request.GetCursorArgumentPrefix());
- m_file_name = partial_spec.GetFilename().GetCString();
- m_dir_name = partial_spec.GetDirectory().GetCString();
-}
-
-lldb::SearchDepth CommandCompletions::SourceFileCompleter::GetDepth() {
- return lldb::eSearchDepthCompUnit;
-}
-
-Searcher::CallbackReturn
-CommandCompletions::SourceFileCompleter::SearchCallback(SearchFilter &filter,
- SymbolContext &context,
- Address *addr) {
- if (context.comp_unit != nullptr) {
- if (m_include_support_files) {
- FileSpecList supporting_files = context.comp_unit->GetSupportFiles();
- for (size_t sfiles = 0; sfiles < supporting_files.GetSize(); sfiles++) {
- const FileSpec &sfile_spec =
- supporting_files.GetFileSpecAtIndex(sfiles);
- const char *sfile_file_name = sfile_spec.GetFilename().GetCString();
- const char *sfile_dir_name = sfile_spec.GetFilename().GetCString();
- bool match = false;
- if (m_file_name && sfile_file_name &&
- strstr(sfile_file_name, m_file_name) == sfile_file_name)
- match = true;
- if (match && m_dir_name && sfile_dir_name &&
- strstr(sfile_dir_name, m_dir_name) != sfile_dir_name)
- match = false;
-
- if (match) {
- m_matching_files.AppendIfUnique(sfile_spec);
- }
- }
- } else {
- const char *cur_file_name =
- context.comp_unit->GetPrimaryFile().GetFilename().GetCString();
- const char *cur_dir_name =
- context.comp_unit->GetPrimaryFile().GetDirectory().GetCString();
-
- bool match = false;
- if (m_file_name && cur_file_name &&
- strstr(cur_file_name, m_file_name) == cur_file_name)
- match = true;
-
- if (match && m_dir_name && cur_dir_name &&
- strstr(cur_dir_name, m_dir_name) != cur_dir_name)
- match = false;
-
- if (match) {
- m_matching_files.AppendIfUnique(context.comp_unit->GetPrimaryFile());
- }
- }
- }
- return Searcher::eCallbackReturnContinue;
-}
-
-void CommandCompletions::SourceFileCompleter::DoCompletion(
- SearchFilter *filter) {
- filter->Search(*this);
- // Now convert the filelist to completions:
- for (size_t i = 0; i < m_matching_files.GetSize(); i++) {
- m_request.AddCompletion(
- m_matching_files.GetFileSpecAtIndex(i).GetFilename().GetCString());
+void CommandCompletions::Registers(CommandInterpreter &interpreter,
+ CompletionRequest &request,
+ SearchFilter *searcher) {
+ std::string reg_prefix = "";
+ if (request.GetCursorArgumentPrefix().startswith("$"))
+ reg_prefix = "$";
+
+ RegisterContext *reg_ctx =
+ interpreter.GetExecutionContext().GetRegisterContext();
+ const size_t reg_num = reg_ctx->GetRegisterCount();
+ for (size_t reg_idx = 0; reg_idx < reg_num; ++reg_idx) {
+ const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_idx);
+ request.TryCompleteCurrentArg(reg_prefix + reg_info->name,
+ reg_info->alt_name);
}
}
-// SymbolCompleter
-
-static bool regex_chars(const char comp) {
- return llvm::StringRef("[](){}+.*|^$\\?").contains(comp);
-}
+void CommandCompletions::Breakpoints(CommandInterpreter &interpreter,
+ CompletionRequest &request,
+ SearchFilter *searcher) {
+ lldb::TargetSP target = interpreter.GetDebugger().GetSelectedTarget();
+ if (!target)
+ return;
-CommandCompletions::SymbolCompleter::SymbolCompleter(
- CommandInterpreter &interpreter, CompletionRequest &request)
- : CommandCompletions::Completer(interpreter, request) {
- std::string regex_str;
- if (!m_request.GetCursorArgumentPrefix().empty()) {
- regex_str.append("^");
- regex_str.append(m_request.GetCursorArgumentPrefix());
- } else {
- // Match anything since the completion string is empty
- regex_str.append(".");
- }
- std::string::iterator pos =
- find_if(regex_str.begin() + 1, regex_str.end(), regex_chars);
- while (pos < regex_str.end()) {
- pos = regex_str.insert(pos, '\\');
- pos = find_if(pos + 2, regex_str.end(), regex_chars);
- }
- m_regex = RegularExpression(regex_str);
-}
+ const BreakpointList &breakpoints = target->GetBreakpointList();
-lldb::SearchDepth CommandCompletions::SymbolCompleter::GetDepth() {
- return lldb::eSearchDepthModule;
-}
+ std::unique_lock<std::recursive_mutex> lock;
+ target->GetBreakpointList().GetListMutex(lock);
-Searcher::CallbackReturn CommandCompletions::SymbolCompleter::SearchCallback(
- SearchFilter &filter, SymbolContext &context, Address *addr) {
- if (context.module_sp) {
- SymbolContextList sc_list;
- const bool include_symbols = true;
- const bool include_inlines = true;
- context.module_sp->FindFunctions(m_regex, include_symbols, include_inlines,
- sc_list);
-
- SymbolContext sc;
- // Now add the functions & symbols to the list - only add if unique:
- for (uint32_t i = 0; i < sc_list.GetSize(); i++) {
- if (sc_list.GetContextAtIndex(i, sc)) {
- ConstString func_name = sc.GetFunctionName(Mangled::ePreferDemangled);
- // Ensure that the function name matches the regex. This is more than a
- // sanity check. It is possible that the demangled function name does
- // not start with the prefix, for example when it's in an anonymous
- // namespace.
- if (!func_name.IsEmpty() && m_regex.Execute(func_name.GetStringRef()))
- m_match_set.insert(func_name);
- }
- }
- }
- return Searcher::eCallbackReturnContinue;
-}
+ size_t num_breakpoints = breakpoints.GetSize();
+ if (num_breakpoints == 0)
+ return;
-void CommandCompletions::SymbolCompleter::DoCompletion(SearchFilter *filter) {
- filter->Search(*this);
- collection::iterator pos = m_match_set.begin(), end = m_match_set.end();
- for (pos = m_match_set.begin(); pos != end; pos++)
- m_request.AddCompletion((*pos).GetCString());
-}
+ for (size_t i = 0; i < num_breakpoints; ++i) {
+ lldb::BreakpointSP bp = breakpoints.GetBreakpointAtIndex(i);
-// ModuleCompleter
-CommandCompletions::ModuleCompleter::ModuleCompleter(
- CommandInterpreter &interpreter, CompletionRequest &request)
- : CommandCompletions::Completer(interpreter, request) {
- FileSpec partial_spec(m_request.GetCursorArgumentPrefix());
- m_file_name = partial_spec.GetFilename().GetCString();
- m_dir_name = partial_spec.GetDirectory().GetCString();
-}
+ StreamString s;
+ bp->GetDescription(&s, lldb::eDescriptionLevelBrief);
+ llvm::StringRef bp_info = s.GetString();
-lldb::SearchDepth CommandCompletions::ModuleCompleter::GetDepth() {
- return lldb::eSearchDepthModule;
-}
+ const size_t colon_pos = bp_info.find_first_of(':');
+ if (colon_pos != llvm::StringRef::npos)
+ bp_info = bp_info.drop_front(colon_pos + 2);
-Searcher::CallbackReturn CommandCompletions::ModuleCompleter::SearchCallback(
- SearchFilter &filter, SymbolContext &context, Address *addr) {
- if (context.module_sp) {
- const char *cur_file_name =
- context.module_sp->GetFileSpec().GetFilename().GetCString();
- const char *cur_dir_name =
- context.module_sp->GetFileSpec().GetDirectory().GetCString();
-
- bool match = false;
- if (m_file_name && cur_file_name &&
- strstr(cur_file_name, m_file_name) == cur_file_name)
- match = true;
-
- if (match && m_dir_name && cur_dir_name &&
- strstr(cur_dir_name, m_dir_name) != cur_dir_name)
- match = false;
-
- if (match) {
- m_request.AddCompletion(cur_file_name);
- }
+ request.TryCompleteCurrentArg(std::to_string(bp->GetID()), bp_info);
}
- return Searcher::eCallbackReturnContinue;
}
-void CommandCompletions::ModuleCompleter::DoCompletion(SearchFilter *filter) {
- filter->Search(*this);
-}
+void CommandCompletions::ProcessPluginNames(CommandInterpreter &interpreter,
+ CompletionRequest &request,
+ SearchFilter *searcher) {
+ PluginManager::AutoCompleteProcessName(request.GetCursorArgumentPrefix(),
+ request);
+} \ No newline at end of file
diff --git a/lldb/source/Commands/CommandObjectApropos.cpp b/lldb/source/Commands/CommandObjectApropos.cpp
index 15a20737273d..6e1e1f061733 100644
--- a/lldb/source/Commands/CommandObjectApropos.cpp
+++ b/lldb/source/Commands/CommandObjectApropos.cpp
@@ -1,5 +1,4 @@
-//===-- CommandObjectApropos.cpp ---------------------------------*- C++
-//-*-===//
+//===-- CommandObjectApropos.cpp ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Commands/CommandObjectApropos.h b/lldb/source/Commands/CommandObjectApropos.h
index 37d86b17d1a2..042753f24032 100644
--- a/lldb/source/Commands/CommandObjectApropos.h
+++ b/lldb/source/Commands/CommandObjectApropos.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectApropos_h_
-#define liblldb_CommandObjectApropos_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTAPROPOS_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTAPROPOS_H
#include "lldb/Interpreter/CommandObject.h"
@@ -28,4 +28,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_CommandObjectApropos_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTAPROPOS_H
diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index 7c4c50ecf3f9..be7ef8a1b60b 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectBreakpoint.cpp -----------------------------*- C++ -*-===//
+//===-- CommandObjectBreakpoint.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -70,7 +70,7 @@ public:
m_bp_opts.m_set_flags.Set(BreakpointOptions::eCondition);
break;
case 'C':
- m_commands.push_back(option_arg);
+ m_commands.push_back(std::string(option_arg));
break;
case 'd':
m_bp_opts.SetEnabled(false);
@@ -270,11 +270,11 @@ public:
break;
case 'b':
- m_func_names.push_back(option_arg);
+ m_func_names.push_back(std::string(option_arg));
m_func_name_type_mask |= eFunctionNameTypeBase;
break;
- case 'C':
+ case 'u':
if (option_arg.getAsInteger(0, m_column))
error.SetErrorStringWithFormat("invalid column number: %s",
option_arg.str().c_str());
@@ -320,7 +320,7 @@ public:
break;
case 'F':
- m_func_names.push_back(option_arg);
+ m_func_names.push_back(std::string(option_arg));
m_func_name_type_mask |= eFunctionNameTypeFull;
break;
@@ -383,18 +383,18 @@ public:
}
case 'M':
- m_func_names.push_back(option_arg);
+ m_func_names.push_back(std::string(option_arg));
m_func_name_type_mask |= eFunctionNameTypeMethod;
break;
case 'n':
- m_func_names.push_back(option_arg);
+ m_func_names.push_back(std::string(option_arg));
m_func_name_type_mask |= eFunctionNameTypeAuto;
break;
case 'N': {
if (BreakpointID::StringIsBreakpointName(option_arg, error))
- m_breakpoint_names.push_back(option_arg);
+ m_breakpoint_names.push_back(std::string(option_arg));
else
error.SetErrorStringWithFormat("Invalid breakpoint name: %s",
option_arg.str().c_str());
@@ -415,11 +415,11 @@ public:
break;
case 'p':
- m_source_text_regexp.assign(option_arg);
+ m_source_text_regexp.assign(std::string(option_arg));
break;
case 'r':
- m_func_regexp.assign(option_arg);
+ m_func_regexp.assign(std::string(option_arg));
break;
case 's':
@@ -427,7 +427,7 @@ public:
break;
case 'S':
- m_func_names.push_back(option_arg);
+ m_func_names.push_back(std::string(option_arg));
m_func_name_type_mask |= eFunctionNameTypeSelector;
break;
@@ -441,7 +441,7 @@ public:
} break;
case 'X':
- m_source_regex_func_names.insert(option_arg);
+ m_source_regex_func_names.insert(std::string(option_arg));
break;
default:
@@ -620,8 +620,16 @@ protected:
RegularExpression regexp(m_options.m_func_regexp);
if (llvm::Error err = regexp.GetError()) {
result.AppendErrorWithFormat(
- "Function name regular expression could not be compiled: \"%s\"",
+ "Function name regular expression could not be compiled: %s",
llvm::toString(std::move(err)).c_str());
+ // Check if the incorrect regex looks like a globbing expression and
+ // warn the user about it.
+ if (!m_options.m_func_regexp.empty()) {
+ if (m_options.m_func_regexp[0] == '*' ||
+ m_options.m_func_regexp[0] == '?')
+ result.AppendWarning(
+ "Function name regex does not accept glob patterns.");
+ }
result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -811,6 +819,14 @@ public:
~CommandObjectBreakpointModify() override = default;
+ void
+ HandleArgumentCompletion(CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ CommandCompletions::InvokeCommonCompletionCallbacks(
+ GetCommandInterpreter(), CommandCompletions::eBreakpointCompletion,
+ request, nullptr);
+ }
+
Options *GetOptions() override { return &m_options; }
protected:
@@ -877,6 +893,14 @@ public:
~CommandObjectBreakpointEnable() override = default;
+ void
+ HandleArgumentCompletion(CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ CommandCompletions::InvokeCommonCompletionCallbacks(
+ GetCommandInterpreter(), CommandCompletions::eBreakpointCompletion,
+ request, nullptr);
+ }
+
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
Target &target = GetSelectedOrDummyTarget();
@@ -985,6 +1009,14 @@ the second re-enables the first location.");
~CommandObjectBreakpointDisable() override = default;
+ void
+ HandleArgumentCompletion(CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ CommandCompletions::InvokeCommonCompletionCallbacks(
+ GetCommandInterpreter(), CommandCompletions::eBreakpointCompletion,
+ request, nullptr);
+ }
+
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
Target &target = GetSelectedOrDummyTarget();
@@ -1231,7 +1263,7 @@ public:
switch (short_option) {
case 'f':
- m_filename.assign(option_arg);
+ m_filename.assign(std::string(option_arg));
break;
case 'l':
@@ -1363,6 +1395,14 @@ public:
~CommandObjectBreakpointDelete() override = default;
+ void
+ HandleArgumentCompletion(CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ CommandCompletions::InvokeCommonCompletionCallbacks(
+ GetCommandInterpreter(), CommandCompletions::eBreakpointCompletion,
+ request, nullptr);
+ }
+
Options *GetOptions() override { return &m_options; }
class CommandOptions : public Options {
@@ -1730,6 +1770,14 @@ public:
~CommandObjectBreakpointNameAdd() override = default;
+ void
+ HandleArgumentCompletion(CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ CommandCompletions::InvokeCommonCompletionCallbacks(
+ GetCommandInterpreter(), CommandCompletions::eBreakpointCompletion,
+ request, nullptr);
+ }
+
Options *GetOptions() override { return &m_option_group; }
protected:
@@ -1809,6 +1857,14 @@ public:
~CommandObjectBreakpointNameDelete() override = default;
+ void
+ HandleArgumentCompletion(CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ CommandCompletions::InvokeCommonCompletionCallbacks(
+ GetCommandInterpreter(), CommandCompletions::eBreakpointCompletion,
+ request, nullptr);
+ }
+
Options *GetOptions() override { return &m_option_group; }
protected:
@@ -1978,14 +2034,7 @@ public:
"Read and set the breakpoints previously saved to "
"a file with \"breakpoint write\". ",
nullptr),
- m_options() {
- CommandArgumentEntry arg;
- CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID,
- eArgTypeBreakpointIDRange);
- // Add the entry for the first argument for this command to the object's
- // arguments vector.
- m_arguments.push_back(arg);
- }
+ m_options() {}
~CommandObjectBreakpointRead() override = default;
@@ -2004,7 +2053,7 @@ public:
switch (short_option) {
case 'f':
- m_filename.assign(option_arg);
+ m_filename.assign(std::string(option_arg));
break;
case 'N': {
Status name_error;
@@ -2013,7 +2062,7 @@ public:
error.SetErrorStringWithFormat("Invalid breakpoint name: %s",
name_error.AsCString());
}
- m_names.push_back(option_arg);
+ m_names.push_back(std::string(option_arg));
break;
}
default:
@@ -2107,6 +2156,14 @@ public:
~CommandObjectBreakpointWrite() override = default;
+ void
+ HandleArgumentCompletion(CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ CommandCompletions::InvokeCommonCompletionCallbacks(
+ GetCommandInterpreter(), CommandCompletions::eBreakpointCompletion,
+ request, nullptr);
+ }
+
Options *GetOptions() override { return &m_options; }
class CommandOptions : public Options {
@@ -2122,7 +2179,7 @@ public:
switch (short_option) {
case 'f':
- m_filename.assign(option_arg);
+ m_filename.assign(std::string(option_arg));
break;
case 'a':
m_append = true;
diff --git a/lldb/source/Commands/CommandObjectBreakpoint.h b/lldb/source/Commands/CommandObjectBreakpoint.h
index b29bbc0a74fa..6625652b260b 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.h
+++ b/lldb/source/Commands/CommandObjectBreakpoint.h
@@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectBreakpoint_h_
-#define liblldb_CommandObjectBreakpoint_h_
-
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTBREAKPOINT_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTBREAKPOINT_H
#include "lldb/Breakpoint/BreakpointName.h"
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -46,4 +45,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_CommandObjectBreakpoint_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTBREAKPOINT_H
diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
index bbd2ca570126..45df86589011 100644
--- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectBreakpointCommand.cpp ----------------------*- C++ -*-===//
+//===-- CommandObjectBreakpointCommand.cpp --------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -292,7 +292,7 @@ are no syntax errors may indicate that a function was declared but never called.
switch (short_option) {
case 'o':
m_use_one_liner = true;
- m_one_liner = option_arg;
+ m_one_liner = std::string(option_arg);
break;
case 's':
diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.h b/lldb/source/Commands/CommandObjectBreakpointCommand.h
index fb246d47abfd..cb516d76ea37 100644
--- a/lldb/source/Commands/CommandObjectBreakpointCommand.h
+++ b/lldb/source/Commands/CommandObjectBreakpointCommand.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectBreakpointCommand_h_
-#define liblldb_CommandObjectBreakpointCommand_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTBREAKPOINTCOMMAND_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTBREAKPOINTCOMMAND_H
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -24,4 +24,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_CommandObjectBreakpointCommand_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTBREAKPOINTCOMMAND_H
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index 388db6fad631..d77e69c6f6a6 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectCommands.cpp -------------------------------*- C++ -*-===//
+//===-- CommandObjectCommands.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -527,14 +527,13 @@ protected:
m_option_group.NotifyOptionParsingStarting(&exe_ctx);
OptionsWithRaw args_with_suffix(raw_command_line);
- const char *remainder = args_with_suffix.GetRawPart().c_str();
if (args_with_suffix.HasArgs())
if (!ParseOptionsAndNotify(args_with_suffix.GetArgs(), result,
m_option_group, exe_ctx))
return false;
- llvm::StringRef raw_command_string(remainder);
+ llvm::StringRef raw_command_string = args_with_suffix.GetRawPart();
Args args(raw_command_string);
if (args.GetArgumentCount() < 2) {
@@ -652,8 +651,8 @@ protected:
}
// Save these in std::strings since we're going to shift them off.
- const std::string alias_command(args[0].ref());
- const std::string actual_command(args[1].ref());
+ const std::string alias_command(std::string(args[0].ref()));
+ const std::string actual_command(std::string(args[1].ref()));
args.Shift(); // Shift the alias command word off the argument vector.
args.Shift(); // Shift the old command word off the argument vector.
@@ -1007,7 +1006,7 @@ protected:
*this, nullptr));
if (io_handler_sp) {
- debugger.PushIOHandler(io_handler_sp);
+ debugger.RunIOHandlerAsync(io_handler_sp);
result.SetStatus(eReturnStatusSuccessFinishNoResult);
}
} else {
@@ -1114,12 +1113,12 @@ protected:
}
if (!check_only) {
- std::string regex(regex_sed.substr(first_separator_char_pos + 1,
- second_separator_char_pos -
- first_separator_char_pos - 1));
- std::string subst(regex_sed.substr(second_separator_char_pos + 1,
- third_separator_char_pos -
- second_separator_char_pos - 1));
+ std::string regex(std::string(regex_sed.substr(
+ first_separator_char_pos + 1,
+ second_separator_char_pos - first_separator_char_pos - 1)));
+ std::string subst(std::string(regex_sed.substr(
+ second_separator_char_pos + 1,
+ third_separator_char_pos - second_separator_char_pos - 1)));
m_regex_cmd_up->AddRegexCommand(regex.c_str(), subst.c_str());
}
return error;
@@ -1150,10 +1149,10 @@ private:
switch (short_option) {
case 'h':
- m_help.assign(option_arg);
+ m_help.assign(std::string(option_arg));
break;
case 's':
- m_syntax.assign(option_arg);
+ m_syntax.assign(std::string(option_arg));
break;
default:
llvm_unreachable("Unimplemented option");
@@ -1171,14 +1170,9 @@ private:
return llvm::makeArrayRef(g_regex_options);
}
- // TODO: Convert these functions to return StringRefs.
- const char *GetHelp() {
- return (m_help.empty() ? nullptr : m_help.c_str());
- }
+ llvm::StringRef GetHelp() { return m_help; }
- const char *GetSyntax() {
- return (m_syntax.empty() ? nullptr : m_syntax.c_str());
- }
+ llvm::StringRef GetSyntax() { return m_syntax; }
protected:
// Instance variables to hold the values for command options.
@@ -1526,15 +1520,15 @@ protected:
switch (short_option) {
case 'f':
if (!option_arg.empty())
- m_funct_name = option_arg;
+ m_funct_name = std::string(option_arg);
break;
case 'c':
if (!option_arg.empty())
- m_class_name = option_arg;
+ m_class_name = std::string(option_arg);
break;
case 'h':
if (!option_arg.empty())
- m_short_help = option_arg;
+ m_short_help = std::string(option_arg);
break;
case 's':
m_synchronicity =
@@ -1627,7 +1621,6 @@ protected:
io_handler.SetIsDone(true);
}
-protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
if (GetDebugger().GetScriptLanguage() != lldb::eScriptLanguagePython) {
result.AppendError("only scripting language supported for scripted "
@@ -1643,7 +1636,7 @@ protected:
}
// Store the options in case we get multi-line input
- m_cmd_name = command[0].ref();
+ m_cmd_name = std::string(command[0].ref());
m_short_help.assign(m_options.m_short_help);
m_synchronicity = m_options.m_synchronicity;
@@ -1773,6 +1766,16 @@ public:
~CommandObjectCommandsScriptDelete() override = default;
+ void
+ HandleArgumentCompletion(CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ if (!m_interpreter.HasCommands() || request.GetCursorIndex() != 0)
+ return;
+
+ for (const auto &c : m_interpreter.GetUserCommands())
+ request.TryCompleteCurrentArg(c.first, c.second->GetHelp());
+ }
+
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
diff --git a/lldb/source/Commands/CommandObjectCommands.h b/lldb/source/Commands/CommandObjectCommands.h
index dcf02f3a7da9..f418e5ba779b 100644
--- a/lldb/source/Commands/CommandObjectCommands.h
+++ b/lldb/source/Commands/CommandObjectCommands.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectCommands_h_
-#define liblldb_CommandObjectCommands_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTCOMMANDS_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTCOMMANDS_H
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -25,4 +25,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_CommandObjectCommands_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTCOMMANDS_H
diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp
index 63679e996e70..cf4d8ed04f81 100644
--- a/lldb/source/Commands/CommandObjectDisassemble.cpp
+++ b/lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectDisassemble.cpp ----------------------------*- C++ -*-===//
+//===-- CommandObjectDisassemble.cpp --------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -21,8 +21,9 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
-#define DEFAULT_DISASM_BYTE_SIZE 32
-#define DEFAULT_DISASM_NUM_INS 4
+static constexpr unsigned default_disasm_byte_size = 32;
+static constexpr unsigned default_disasm_num_ins = 4;
+static constexpr unsigned large_function_threshold = 8000;
using namespace lldb;
using namespace lldb_private;
@@ -83,7 +84,7 @@ Status CommandObjectDisassemble::CommandOptions::SetOptionValue(
} break;
case 'n':
- func_name.assign(option_arg);
+ func_name.assign(std::string(option_arg));
some_location_specified = true;
break;
@@ -101,7 +102,7 @@ Status CommandObjectDisassemble::CommandOptions::SetOptionValue(
break;
case 'P':
- plugin_name.assign(option_arg);
+ plugin_name.assign(std::string(option_arg));
break;
case 'F': {
@@ -111,7 +112,7 @@ Status CommandObjectDisassemble::CommandOptions::SetOptionValue(
llvm::Triple::x86 ||
target_sp->GetArchitecture().GetTriple().getArch() ==
llvm::Triple::x86_64)) {
- flavor_string.assign(option_arg);
+ flavor_string.assign(std::string(option_arg));
} else
error.SetErrorStringWithFormat("Disassembler flavors are currently only "
"supported for x86 and x86_64 targets.");
@@ -143,6 +144,10 @@ Status CommandObjectDisassemble::CommandOptions::SetOptionValue(
}
} break;
+ case '\x01':
+ force = true;
+ break;
+
default:
llvm_unreachable("Unimplemented option");
}
@@ -186,6 +191,7 @@ void CommandObjectDisassemble::CommandOptions::OptionParsingStarting(
arch.Clear();
some_location_specified = false;
+ force = false;
}
Status CommandObjectDisassemble::CommandOptions::OptionParsingFinished(
@@ -214,6 +220,194 @@ CommandObjectDisassemble::CommandObjectDisassemble(
CommandObjectDisassemble::~CommandObjectDisassemble() = default;
+llvm::Error CommandObjectDisassemble::CheckRangeSize(const AddressRange &range,
+ llvm::StringRef what) {
+ if (m_options.num_instructions > 0 || m_options.force ||
+ range.GetByteSize() < large_function_threshold)
+ return llvm::Error::success();
+ StreamString msg;
+ msg << "Not disassembling " << what << " because it is very large ";
+ range.Dump(&msg, &GetSelectedTarget(), Address::DumpStyleLoadAddress,
+ Address::DumpStyleFileAddress);
+ msg << ". To disassemble specify an instruction count limit, start/stop "
+ "addresses or use the --force option.";
+ return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ msg.GetString());
+}
+
+llvm::Expected<std::vector<AddressRange>>
+CommandObjectDisassemble::GetContainingAddressRanges() {
+ std::vector<AddressRange> ranges;
+ const auto &get_range = [&](Address addr) {
+ ModuleSP module_sp(addr.GetModule());
+ SymbolContext sc;
+ bool resolve_tail_call_address = true;
+ addr.GetModule()->ResolveSymbolContextForAddress(
+ addr, eSymbolContextEverything, sc, resolve_tail_call_address);
+ if (sc.function || sc.symbol) {
+ AddressRange range;
+ sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, 0,
+ false, range);
+ ranges.push_back(range);
+ }
+ };
+
+ Target &target = GetSelectedTarget();
+ if (!target.GetSectionLoadList().IsEmpty()) {
+ Address symbol_containing_address;
+ if (target.GetSectionLoadList().ResolveLoadAddress(
+ m_options.symbol_containing_addr, symbol_containing_address)) {
+ get_range(symbol_containing_address);
+ }
+ } else {
+ for (lldb::ModuleSP module_sp : target.GetImages().Modules()) {
+ Address file_address;
+ if (module_sp->ResolveFileAddress(m_options.symbol_containing_addr,
+ file_address)) {
+ get_range(file_address);
+ }
+ }
+ }
+
+ if (ranges.empty()) {
+ return llvm::createStringError(
+ llvm::inconvertibleErrorCode(),
+ "Could not find function bounds for address 0x%" PRIx64,
+ m_options.symbol_containing_addr);
+ }
+
+ if (llvm::Error err = CheckRangeSize(ranges[0], "the function"))
+ return std::move(err);
+ return ranges;
+}
+
+llvm::Expected<std::vector<AddressRange>>
+CommandObjectDisassemble::GetCurrentFunctionRanges() {
+ StackFrame *frame = m_exe_ctx.GetFramePtr();
+ if (!frame) {
+ return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Cannot disassemble around the current "
+ "function without a selected frame.\n");
+ }
+ SymbolContext sc(
+ frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol));
+ AddressRange range;
+ if (sc.function)
+ range = sc.function->GetAddressRange();
+ else if (sc.symbol && sc.symbol->ValueIsAddress()) {
+ range = {sc.symbol->GetAddress(), sc.symbol->GetByteSize()};
+ } else
+ range = {frame->GetFrameCodeAddress(), default_disasm_byte_size};
+
+ if (llvm::Error err = CheckRangeSize(range, "the current function"))
+ return std::move(err);
+ return std::vector<AddressRange>{range};
+}
+
+llvm::Expected<std::vector<AddressRange>>
+CommandObjectDisassemble::GetCurrentLineRanges() {
+ StackFrame *frame = m_exe_ctx.GetFramePtr();
+ if (!frame) {
+ return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Cannot disassemble around the current "
+ "line without a selected frame.\n");
+ }
+
+ LineEntry pc_line_entry(
+ frame->GetSymbolContext(eSymbolContextLineEntry).line_entry);
+ if (pc_line_entry.IsValid())
+ return std::vector<AddressRange>{pc_line_entry.range};
+
+ // No line entry, so just disassemble around the current pc
+ m_options.show_mixed = false;
+ return GetPCRanges();
+}
+
+llvm::Expected<std::vector<AddressRange>>
+CommandObjectDisassemble::GetNameRanges(CommandReturnObject &result) {
+ ConstString name(m_options.func_name.c_str());
+ const bool include_symbols = true;
+ const bool include_inlines = true;
+
+ // Find functions matching the given name.
+ SymbolContextList sc_list;
+ GetSelectedTarget().GetImages().FindFunctions(
+ name, eFunctionNameTypeAuto, include_symbols, include_inlines, sc_list);
+
+ std::vector<AddressRange> ranges;
+ llvm::Error range_errs = llvm::Error::success();
+ AddressRange range;
+ const uint32_t scope =
+ eSymbolContextBlock | eSymbolContextFunction | eSymbolContextSymbol;
+ const bool use_inline_block_range = true;
+ for (SymbolContext sc : sc_list.SymbolContexts()) {
+ for (uint32_t range_idx = 0;
+ sc.GetAddressRange(scope, range_idx, use_inline_block_range, range);
+ ++range_idx) {
+ if (llvm::Error err = CheckRangeSize(range, "a range"))
+ range_errs = joinErrors(std::move(range_errs), std::move(err));
+ else
+ ranges.push_back(range);
+ }
+ }
+ if (ranges.empty()) {
+ if (range_errs)
+ return std::move(range_errs);
+ return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Unable to find symbol with name '%s'.\n",
+ name.GetCString());
+ }
+ if (range_errs)
+ result.AppendWarning(toString(std::move(range_errs)));
+ return ranges;
+}
+
+llvm::Expected<std::vector<AddressRange>>
+CommandObjectDisassemble::GetPCRanges() {
+ StackFrame *frame = m_exe_ctx.GetFramePtr();
+ if (!frame) {
+ return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Cannot disassemble around the current "
+ "PC without a selected frame.\n");
+ }
+
+ if (m_options.num_instructions == 0) {
+ // Disassembling at the PC always disassembles some number of
+ // instructions (not the whole function).
+ m_options.num_instructions = default_disasm_num_ins;
+ }
+ return std::vector<AddressRange>{{frame->GetFrameCodeAddress(), 0}};
+}
+
+llvm::Expected<std::vector<AddressRange>>
+CommandObjectDisassemble::GetStartEndAddressRanges() {
+ addr_t size = 0;
+ if (m_options.end_addr != LLDB_INVALID_ADDRESS) {
+ if (m_options.end_addr <= m_options.start_addr) {
+ return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "End address before start address.");
+ }
+ size = m_options.end_addr - m_options.start_addr;
+ }
+ return std::vector<AddressRange>{{Address(m_options.start_addr), size}};
+}
+
+llvm::Expected<std::vector<AddressRange>>
+CommandObjectDisassemble::GetRangesForSelectedMode(
+ CommandReturnObject &result) {
+ if (m_options.symbol_containing_addr != LLDB_INVALID_ADDRESS)
+ return CommandObjectDisassemble::GetContainingAddressRanges();
+ if (m_options.current_function)
+ return CommandObjectDisassemble::GetCurrentFunctionRanges();
+ if (m_options.frame_line)
+ return CommandObjectDisassemble::GetCurrentLineRanges();
+ if (!m_options.func_name.empty())
+ return CommandObjectDisassemble::GetNameRanges(result);
+ if (m_options.start_addr != LLDB_INVALID_ADDRESS)
+ return CommandObjectDisassemble::GetStartEndAddressRanges();
+ return CommandObjectDisassemble::GetPCRanges();
+}
+
bool CommandObjectDisassemble::DoExecute(Args &command,
CommandReturnObject &result) {
Target *target = &GetSelectedTarget();
@@ -281,238 +475,44 @@ bool CommandObjectDisassemble::DoExecute(Args &command,
if (m_options.raw)
options |= Disassembler::eOptionRawOuput;
- if (!m_options.func_name.empty()) {
- ConstString name(m_options.func_name.c_str());
+ llvm::Expected<std::vector<AddressRange>> ranges =
+ GetRangesForSelectedMode(result);
+ if (!ranges) {
+ result.AppendError(toString(ranges.takeError()));
+ result.SetStatus(eReturnStatusFailed);
+ return result.Succeeded();
+ }
+ bool print_sc_header = ranges->size() > 1;
+ for (AddressRange cur_range : *ranges) {
+ Disassembler::Limit limit;
+ if (m_options.num_instructions == 0) {
+ limit = {Disassembler::Limit::Bytes, cur_range.GetByteSize()};
+ if (limit.value == 0)
+ limit.value = default_disasm_byte_size;
+ } else {
+ limit = {Disassembler::Limit::Instructions, m_options.num_instructions};
+ }
if (Disassembler::Disassemble(
GetDebugger(), m_options.arch, plugin_name, flavor_string,
- m_exe_ctx, name,
- nullptr, // Module *
- m_options.num_instructions, m_options.show_mixed,
+ m_exe_ctx, cur_range.GetBaseAddress(), limit, m_options.show_mixed,
m_options.show_mixed ? m_options.num_lines_context : 0, options,
result.GetOutputStream())) {
result.SetStatus(eReturnStatusSuccessFinishResult);
} else {
- result.AppendErrorWithFormat("Unable to find symbol with name '%s'.\n",
- name.GetCString());
- result.SetStatus(eReturnStatusFailed);
- }
- } else {
- std::vector<AddressRange> ranges;
- AddressRange range;
- StackFrame *frame = m_exe_ctx.GetFramePtr();
- if (m_options.frame_line) {
- if (frame == nullptr) {
- result.AppendError("Cannot disassemble around the current line without "
- "a selected frame.\n");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
- LineEntry pc_line_entry(
- frame->GetSymbolContext(eSymbolContextLineEntry).line_entry);
- if (pc_line_entry.IsValid()) {
- range = pc_line_entry.range;
- } else {
- m_options.at_pc =
- true; // No line entry, so just disassemble around the current pc
- m_options.show_mixed = false;
- }
- } else if (m_options.current_function) {
- if (frame == nullptr) {
- result.AppendError("Cannot disassemble around the current function "
- "without a selected frame.\n");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
- Symbol *symbol = frame->GetSymbolContext(eSymbolContextSymbol).symbol;
- if (symbol) {
- range.GetBaseAddress() = symbol->GetAddress();
- range.SetByteSize(symbol->GetByteSize());
- }
- }
-
- // Did the "m_options.frame_line" find a valid range already? If so skip
- // the rest...
- if (range.GetByteSize() == 0) {
- if (m_options.at_pc) {
- if (frame == nullptr) {
- result.AppendError("Cannot disassemble around the current PC without "
- "a selected frame.\n");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
- range.GetBaseAddress() = frame->GetFrameCodeAddress();
- if (m_options.num_instructions == 0) {
- // Disassembling at the PC always disassembles some number of
- // instructions (not the whole function).
- m_options.num_instructions = DEFAULT_DISASM_NUM_INS;
- }
- ranges.push_back(range);
+ if (m_options.symbol_containing_addr != LLDB_INVALID_ADDRESS) {
+ result.AppendErrorWithFormat(
+ "Failed to disassemble memory in function at 0x%8.8" PRIx64 ".\n",
+ m_options.symbol_containing_addr);
} else {
- range.GetBaseAddress().SetOffset(m_options.start_addr);
- if (range.GetBaseAddress().IsValid()) {
- if (m_options.end_addr != LLDB_INVALID_ADDRESS) {
- if (m_options.end_addr <= m_options.start_addr) {
- result.AppendErrorWithFormat(
- "End address before start address.\n");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
- range.SetByteSize(m_options.end_addr - m_options.start_addr);
- }
- ranges.push_back(range);
- } else {
- if (m_options.symbol_containing_addr != LLDB_INVALID_ADDRESS &&
- target) {
- if (!target->GetSectionLoadList().IsEmpty()) {
- bool failed = false;
- Address symbol_containing_address;
- if (target->GetSectionLoadList().ResolveLoadAddress(
- m_options.symbol_containing_addr,
- symbol_containing_address)) {
- ModuleSP module_sp(symbol_containing_address.GetModule());
- SymbolContext sc;
- bool resolve_tail_call_address = true; // PC can be one past the
- // address range of the
- // function.
- module_sp->ResolveSymbolContextForAddress(
- symbol_containing_address, eSymbolContextEverything, sc,
- resolve_tail_call_address);
- if (sc.function || sc.symbol) {
- sc.GetAddressRange(eSymbolContextFunction |
- eSymbolContextSymbol,
- 0, false, range);
- } else {
- failed = true;
- }
- } else {
- failed = true;
- }
- if (failed) {
- result.AppendErrorWithFormat(
- "Could not find function bounds for address 0x%" PRIx64
- "\n",
- m_options.symbol_containing_addr);
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
- ranges.push_back(range);
- } else {
- for (lldb::ModuleSP module_sp : target->GetImages().Modules()) {
- lldb::addr_t file_addr = m_options.symbol_containing_addr;
- Address file_address;
- if (module_sp->ResolveFileAddress(file_addr, file_address)) {
- SymbolContext sc;
- bool resolve_tail_call_address = true; // PC can be one past
- // the address range of
- // the function.
- module_sp->ResolveSymbolContextForAddress(
- file_address, eSymbolContextEverything, sc,
- resolve_tail_call_address);
- if (sc.function || sc.symbol) {
- sc.GetAddressRange(eSymbolContextFunction |
- eSymbolContextSymbol,
- 0, false, range);
- ranges.push_back(range);
- }
- }
- }
- }
- }
- }
- }
- } else
- ranges.push_back(range);
-
- if (m_options.num_instructions != 0) {
- if (ranges.empty()) {
- // The default action is to disassemble the current frame function.
- if (frame) {
- SymbolContext sc(frame->GetSymbolContext(eSymbolContextFunction |
- eSymbolContextSymbol));
- if (sc.function)
- range.GetBaseAddress() =
- sc.function->GetAddressRange().GetBaseAddress();
- else if (sc.symbol && sc.symbol->ValueIsAddress())
- range.GetBaseAddress() = sc.symbol->GetAddress();
- else
- range.GetBaseAddress() = frame->GetFrameCodeAddress();
- }
-
- if (!range.GetBaseAddress().IsValid()) {
- result.AppendError("invalid frame");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
- }
-
- bool print_sc_header = ranges.size() > 1;
- for (AddressRange cur_range : ranges) {
- if (Disassembler::Disassemble(
- GetDebugger(), m_options.arch, plugin_name, flavor_string,
- m_exe_ctx, cur_range.GetBaseAddress(),
- m_options.num_instructions, m_options.show_mixed,
- m_options.show_mixed ? m_options.num_lines_context : 0, options,
- result.GetOutputStream())) {
- result.SetStatus(eReturnStatusSuccessFinishResult);
- } else {
- if (m_options.start_addr != LLDB_INVALID_ADDRESS)
- result.AppendErrorWithFormat(
- "Failed to disassemble memory at 0x%8.8" PRIx64 ".\n",
- m_options.start_addr);
- else if (m_options.symbol_containing_addr != LLDB_INVALID_ADDRESS)
- result.AppendErrorWithFormat(
- "Failed to disassemble memory in function at 0x%8.8" PRIx64
- ".\n",
- m_options.symbol_containing_addr);
- result.SetStatus(eReturnStatusFailed);
- }
- }
- if (print_sc_header)
- result.AppendMessage("\n");
- } else {
- if (ranges.empty()) {
- // The default action is to disassemble the current frame function.
- if (frame) {
- SymbolContext sc(frame->GetSymbolContext(eSymbolContextFunction |
- eSymbolContextSymbol));
- if (sc.function)
- range = sc.function->GetAddressRange();
- else if (sc.symbol && sc.symbol->ValueIsAddress()) {
- range.GetBaseAddress() = sc.symbol->GetAddress();
- range.SetByteSize(sc.symbol->GetByteSize());
- } else
- range.GetBaseAddress() = frame->GetFrameCodeAddress();
- } else {
- result.AppendError("invalid frame");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
- ranges.push_back(range);
- }
-
- bool print_sc_header = ranges.size() > 1;
- for (AddressRange cur_range : ranges) {
- if (cur_range.GetByteSize() == 0)
- cur_range.SetByteSize(DEFAULT_DISASM_BYTE_SIZE);
-
- if (Disassembler::Disassemble(
- GetDebugger(), m_options.arch, plugin_name, flavor_string,
- m_exe_ctx, cur_range, m_options.num_instructions,
- m_options.show_mixed,
- m_options.show_mixed ? m_options.num_lines_context : 0, options,
- result.GetOutputStream())) {
- result.SetStatus(eReturnStatusSuccessFinishResult);
- } else {
- result.AppendErrorWithFormat(
- "Failed to disassemble memory at 0x%8.8" PRIx64 ".\n",
- cur_range.GetBaseAddress().GetLoadAddress(target));
- result.SetStatus(eReturnStatusFailed);
- }
- if (print_sc_header)
- result.AppendMessage("\n");
+ result.AppendErrorWithFormat(
+ "Failed to disassemble memory at 0x%8.8" PRIx64 ".\n",
+ cur_range.GetBaseAddress().GetLoadAddress(target));
}
+ result.SetStatus(eReturnStatusFailed);
}
+ if (print_sc_header)
+ result.GetOutputStream() << "\n";
}
return result.Succeeded();
diff --git a/lldb/source/Commands/CommandObjectDisassemble.h b/lldb/source/Commands/CommandObjectDisassemble.h
index 70193e914c7f..340bf648de17 100644
--- a/lldb/source/Commands/CommandObjectDisassemble.h
+++ b/lldb/source/Commands/CommandObjectDisassemble.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectDisassemble_h_
-#define liblldb_CommandObjectDisassemble_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTDISASSEMBLE_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTDISASSEMBLE_H
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/Options.h"
@@ -62,6 +62,7 @@ public:
// "at_pc". This should be set
// in SetOptionValue if anything the selects a location is set.
lldb::addr_t symbol_containing_addr;
+ bool force = false;
};
CommandObjectDisassemble(CommandInterpreter &interpreter);
@@ -73,9 +74,22 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override;
+ llvm::Expected<std::vector<AddressRange>>
+ GetRangesForSelectedMode(CommandReturnObject &result);
+
+ llvm::Expected<std::vector<AddressRange>> GetContainingAddressRanges();
+ llvm::Expected<std::vector<AddressRange>> GetCurrentFunctionRanges();
+ llvm::Expected<std::vector<AddressRange>> GetCurrentLineRanges();
+ llvm::Expected<std::vector<AddressRange>>
+ GetNameRanges(CommandReturnObject &result);
+ llvm::Expected<std::vector<AddressRange>> GetPCRanges();
+ llvm::Expected<std::vector<AddressRange>> GetStartEndAddressRanges();
+
+ llvm::Error CheckRangeSize(const AddressRange &range, llvm::StringRef what);
+
CommandOptions m_options;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectDisassemble_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTDISASSEMBLE_H
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp
index db90dde98eff..b23adb087b49 100644
--- a/lldb/source/Commands/CommandObjectExpression.cpp
+++ b/lldb/source/Commands/CommandObjectExpression.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectExpression.cpp -----------------------------*- C++ -*-===//
+//===-- CommandObjectExpression.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -311,7 +311,12 @@ void CommandObjectExpression::HandleCompletion(CompletionRequest &request) {
target = &GetDummyTarget();
unsigned cursor_pos = request.GetRawCursorPos();
- llvm::StringRef code = request.GetRawLine();
+ // Get the full user input including the suffix. The suffix is necessary
+ // as OptionsWithRaw will use it to detect if the cursor is cursor is in the
+ // argument part of in the raw input part of the arguments. If we cut of
+ // of the suffix then "expr -arg[cursor] --" would interpret the "-arg" as
+ // the raw input (as the "--" is hidden in the suffix).
+ llvm::StringRef code = request.GetRawLineWithUnusedSuffix();
const std::size_t original_code_size = code.size();
@@ -357,29 +362,13 @@ CanBeUsedForElementCountPrinting(ValueObject &valobj) {
return Status();
}
-bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr,
- Stream *output_stream,
- Stream *error_stream,
- CommandReturnObject *result) {
- // Don't use m_exe_ctx as this might be called asynchronously after the
- // command object DoExecute has finished when doing multi-line expression
- // that use an input reader...
- ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
-
- Target *target = exe_ctx.GetTargetPtr();
-
- if (!target)
- target = &GetDummyTarget();
-
- lldb::ValueObjectSP result_valobj_sp;
- bool keep_in_memory = true;
- StackFrame *frame = exe_ctx.GetFramePtr();
-
+EvaluateExpressionOptions
+CommandObjectExpression::GetEvalOptions(const Target &target) {
EvaluateExpressionOptions options;
options.SetCoerceToId(m_varobj_options.use_objc);
options.SetUnwindOnError(m_command_options.unwind_on_error);
options.SetIgnoreBreakpoints(m_command_options.ignore_breakpoints);
- options.SetKeepInMemory(keep_in_memory);
+ options.SetKeepInMemory(true);
options.SetUseDynamic(m_varobj_options.use_dynamic);
options.SetTryAllThreads(m_command_options.try_all_threads);
options.SetDebug(m_command_options.debug);
@@ -391,11 +380,12 @@ bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr,
bool auto_apply_fixits;
if (m_command_options.auto_apply_fixits == eLazyBoolCalculate)
- auto_apply_fixits = target->GetEnableAutoApplyFixIts();
+ auto_apply_fixits = target.GetEnableAutoApplyFixIts();
else
auto_apply_fixits = m_command_options.auto_apply_fixits == eLazyBoolYes;
options.SetAutoApplyFixIts(auto_apply_fixits);
+ options.SetRetriesWithFixIts(target.GetNumberOfRetriesWithFixits());
if (m_command_options.top_level)
options.SetExecutionPolicy(eExecutionPolicyTopLevel);
@@ -410,17 +400,36 @@ bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr,
options.SetTimeout(std::chrono::microseconds(m_command_options.timeout));
else
options.SetTimeout(llvm::None);
+ return options;
+}
+bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr,
+ Stream &output_stream,
+ Stream &error_stream,
+ CommandReturnObject &result) {
+ // Don't use m_exe_ctx as this might be called asynchronously after the
+ // command object DoExecute has finished when doing multi-line expression
+ // that use an input reader...
+ ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
+
+ Target *target = exe_ctx.GetTargetPtr();
+
+ if (!target)
+ target = &GetDummyTarget();
+
+ lldb::ValueObjectSP result_valobj_sp;
+ StackFrame *frame = exe_ctx.GetFramePtr();
+
+ const EvaluateExpressionOptions options = GetEvalOptions(*target);
ExpressionResults success = target->EvaluateExpression(
expr, frame, result_valobj_sp, options, &m_fixed_expression);
// We only tell you about the FixIt if we applied it. The compiler errors
// will suggest the FixIt if it parsed.
- if (error_stream && !m_fixed_expression.empty() &&
- target->GetEnableNotifyAboutFixIts()) {
+ if (!m_fixed_expression.empty() && target->GetEnableNotifyAboutFixIts()) {
if (success == eExpressionCompleted)
- error_stream->Printf(" Fix-it applied, fixed expression was: \n %s\n",
- m_fixed_expression.c_str());
+ error_stream.Printf(" Fix-it applied, fixed expression was: \n %s\n",
+ m_fixed_expression.c_str());
}
if (result_valobj_sp) {
@@ -434,10 +443,10 @@ bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr,
if (m_varobj_options.elem_count > 0) {
Status error(CanBeUsedForElementCountPrinting(*result_valobj_sp));
if (error.Fail()) {
- result->AppendErrorWithFormat(
+ result.AppendErrorWithFormat(
"expression cannot be used with --element-count %s\n",
error.AsCString(""));
- result->SetStatus(eReturnStatusFailed);
+ result.SetStatus(eReturnStatusFailed);
return false;
}
}
@@ -447,41 +456,39 @@ bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr,
options.SetVariableFormatDisplayLanguage(
result_valobj_sp->GetPreferredDisplayLanguage());
- result_valobj_sp->Dump(*output_stream, options);
+ result_valobj_sp->Dump(output_stream, options);
- if (result)
- result->SetStatus(eReturnStatusSuccessFinishResult);
+ result.SetStatus(eReturnStatusSuccessFinishResult);
}
} else {
if (result_valobj_sp->GetError().GetError() ==
UserExpression::kNoResult) {
if (format != eFormatVoid && GetDebugger().GetNotifyVoid()) {
- error_stream->PutCString("(void)\n");
+ error_stream.PutCString("(void)\n");
}
- if (result)
- result->SetStatus(eReturnStatusSuccessFinishResult);
+ result.SetStatus(eReturnStatusSuccessFinishResult);
} else {
const char *error_cstr = result_valobj_sp->GetError().AsCString();
if (error_cstr && error_cstr[0]) {
const size_t error_cstr_len = strlen(error_cstr);
const bool ends_with_newline = error_cstr[error_cstr_len - 1] == '\n';
if (strstr(error_cstr, "error:") != error_cstr)
- error_stream->PutCString("error: ");
- error_stream->Write(error_cstr, error_cstr_len);
+ error_stream.PutCString("error: ");
+ error_stream.Write(error_cstr, error_cstr_len);
if (!ends_with_newline)
- error_stream->EOL();
+ error_stream.EOL();
} else {
- error_stream->PutCString("error: unknown error\n");
+ error_stream.PutCString("error: unknown error\n");
}
- if (result)
- result->SetStatus(eReturnStatusFailed);
+ result.SetStatus(eReturnStatusFailed);
}
}
}
- return true;
+ return (success != eExpressionSetupError &&
+ success != eExpressionParseError);
}
void CommandObjectExpression::IOHandlerInputComplete(IOHandler &io_handler,
@@ -493,7 +500,9 @@ void CommandObjectExpression::IOHandlerInputComplete(IOHandler &io_handler,
StreamFileSP output_sp = io_handler.GetOutputStreamFileSP();
StreamFileSP error_sp = io_handler.GetErrorStreamFileSP();
- EvaluateExpression(line.c_str(), output_sp.get(), error_sp.get());
+ CommandReturnObject return_obj(
+ GetCommandInterpreter().GetDebugger().GetUseColor());
+ EvaluateExpression(line.c_str(), *output_sp, *error_sp, return_obj);
if (output_sp)
output_sp->Flush();
if (error_sp)
@@ -535,7 +544,7 @@ void CommandObjectExpression::GetMultilineExpression() {
"Enter expressions, then terminate with an empty line to evaluate:\n");
output_sp->Flush();
}
- debugger.PushIOHandler(io_handler_sp);
+ debugger.RunIOHandlerAsync(io_handler_sp);
}
static EvaluateExpressionOptions
@@ -622,10 +631,8 @@ bool CommandObjectExpression::DoExecute(llvm::StringRef command,
}
IOHandlerSP io_handler_sp(repl_sp->GetIOHandler());
-
io_handler_sp->SetIsDone(false);
-
- debugger.PushIOHandler(io_handler_sp);
+ debugger.RunIOHandlerAsync(io_handler_sp);
} else {
repl_error.SetErrorStringWithFormat(
"Couldn't create a REPL for %s",
@@ -643,8 +650,8 @@ bool CommandObjectExpression::DoExecute(llvm::StringRef command,
}
Target &target = GetSelectedOrDummyTarget();
- if (EvaluateExpression(expr, &(result.GetOutputStream()),
- &(result.GetErrorStream()), &result)) {
+ if (EvaluateExpression(expr, result.GetOutputStream(),
+ result.GetErrorStream(), result)) {
if (!m_fixed_expression.empty() && target.GetEnableNotifyAboutFixIts()) {
CommandHistory &history = m_interpreter.GetCommandHistory();
@@ -654,7 +661,7 @@ bool CommandObjectExpression::DoExecute(llvm::StringRef command,
std::string fixed_command("expression ");
if (args.HasArgs()) {
// Add in any options that might have been in the original command:
- fixed_command.append(args.GetArgStringWithDelimiter());
+ fixed_command.append(std::string(args.GetArgStringWithDelimiter()));
fixed_command.append(m_fixed_expression);
} else
fixed_command.append(m_fixed_expression);
diff --git a/lldb/source/Commands/CommandObjectExpression.h b/lldb/source/Commands/CommandObjectExpression.h
index de159863b43a..1e59cbc14528 100644
--- a/lldb/source/Commands/CommandObjectExpression.h
+++ b/lldb/source/Commands/CommandObjectExpression.h
@@ -6,15 +6,17 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectExpression_h_
-#define liblldb_CommandObjectExpression_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTEXPRESSION_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTEXPRESSION_H
#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/Target.h"
#include "lldb/lldb-private-enumerations.h"
+
namespace lldb_private {
class CommandObjectExpression : public CommandObjectRaw,
@@ -65,9 +67,22 @@ protected:
bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override;
- bool EvaluateExpression(llvm::StringRef expr, Stream *output_stream,
- Stream *error_stream,
- CommandReturnObject *result = nullptr);
+ /// Return the appropriate expression options used for evaluating the
+ /// expression in the given target.
+ EvaluateExpressionOptions GetEvalOptions(const Target &target);
+
+ /// Evaluates the given expression.
+ /// \param output_stream The stream to which the evaluation result will be
+ /// printed.
+ /// \param error_stream Contains error messages that should be displayed to
+ /// the user in case the evaluation fails.
+ /// \param result A CommandReturnObject which status will be set to the
+ /// appropriate value depending on evaluation success and
+ /// whether the expression produced any result.
+ /// \return Returns true iff the expression was successfully evaluated,
+ /// executed and the result could be printed to the output stream.
+ bool EvaluateExpression(llvm::StringRef expr, Stream &output_stream,
+ Stream &error_stream, CommandReturnObject &result);
void GetMultilineExpression();
@@ -83,4 +98,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_CommandObjectExpression_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTEXPRESSION_H
diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp
index 50d5c751de5c..6ebad9b5c488 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectFrame.cpp ----------------------------------*- C++ -*-===//
+//===-- CommandObjectFrame.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -12,7 +12,6 @@
#include "lldb/DataFormatters/ValueObjectPrinter.h"
#include "lldb/Host/Config.h"
#include "lldb/Host/OptionParser.h"
-#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionGroupFormat.h"
@@ -172,8 +171,7 @@ protected:
Stream &stream) -> bool {
const ValueObject::GetExpressionPathFormat format = ValueObject::
GetExpressionPathFormat::eGetExpressionPathFormatHonorPointers;
- const bool qualify_cxx_base_classes = false;
- valobj_sp->GetExpressionPath(stream, qualify_cxx_base_classes, format);
+ valobj_sp->GetExpressionPath(stream, format);
stream.PutCString(" =");
return true;
};
@@ -187,7 +185,6 @@ protected:
return true;
}
-protected:
CommandOptions m_options;
};
@@ -291,6 +288,22 @@ public:
~CommandObjectFrameSelect() override = default;
+ void
+ HandleArgumentCompletion(CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ if (!m_exe_ctx.HasProcessScope() || request.GetCursorIndex() != 0)
+ return;
+
+ lldb::ThreadSP thread_sp = m_exe_ctx.GetThreadSP();
+ const uint32_t frame_num = thread_sp->GetStackFrameCount();
+ for (uint32_t i = 0; i < frame_num; ++i) {
+ lldb::StackFrameSP frame_sp = thread_sp->GetStackFrameAtIndex(i);
+ StreamString strm;
+ frame_sp->Dump(&strm, false, true);
+ request.TryCompleteCurrentArg(std::to_string(i), strm.GetString());
+ }
+ }
+
Options *GetOptions() override { return &m_options; }
protected:
@@ -380,7 +393,6 @@ protected:
return result.Succeeded();
}
-protected:
CommandOptions m_options;
};
@@ -715,7 +727,6 @@ protected:
return res;
}
-protected:
OptionGroupOptions m_option_group;
OptionGroupVariable m_option_variable;
OptionGroupFormat m_option_format;
@@ -747,7 +758,7 @@ private:
m_module = std::string(option_arg);
break;
case 'n':
- m_function = std::string(option_arg);
+ m_symbols.push_back(std::string(option_arg));
break;
case 'x':
m_regex = true;
@@ -761,7 +772,7 @@ private:
void OptionParsingStarting(ExecutionContext *execution_context) override {
m_module = "";
- m_function = "";
+ m_symbols.clear();
m_class_name = "";
m_regex = false;
}
@@ -773,7 +784,7 @@ private:
// Instance variables to hold the values for command options.
std::string m_class_name;
std::string m_module;
- std::string m_function;
+ std::vector<std::string> m_symbols;
bool m_regex;
};
@@ -855,9 +866,18 @@ bool CommandObjectFrameRecognizerAdd::DoExecute(Args &command,
return false;
}
- if (m_options.m_function.empty()) {
- result.AppendErrorWithFormat("%s needs a function name (-n argument).\n",
- m_cmd_name.c_str());
+ if (m_options.m_symbols.empty()) {
+ result.AppendErrorWithFormat(
+ "%s needs at least one symbol name (-n argument).\n",
+ m_cmd_name.c_str());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ if (m_options.m_regex && m_options.m_symbols.size() > 1) {
+ result.AppendErrorWithFormat(
+ "%s needs only one symbol regular expression (-n argument).\n",
+ m_cmd_name.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -877,12 +897,13 @@ bool CommandObjectFrameRecognizerAdd::DoExecute(Args &command,
auto module =
RegularExpressionSP(new RegularExpression(m_options.m_module));
auto func =
- RegularExpressionSP(new RegularExpression(m_options.m_function));
+ RegularExpressionSP(new RegularExpression(m_options.m_symbols.front()));
StackFrameRecognizerManager::AddRecognizer(recognizer_sp, module, func);
} else {
auto module = ConstString(m_options.m_module);
- auto func = ConstString(m_options.m_function);
- StackFrameRecognizerManager::AddRecognizer(recognizer_sp, module, func);
+ std::vector<ConstString> symbols(m_options.m_symbols.begin(),
+ m_options.m_symbols.end());
+ StackFrameRecognizerManager::AddRecognizer(recognizer_sp, module, symbols);
}
#endif
@@ -914,6 +935,33 @@ public:
~CommandObjectFrameRecognizerDelete() override = default;
+ void
+ HandleArgumentCompletion(CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ if (request.GetCursorIndex() != 0)
+ return;
+
+ StackFrameRecognizerManager::ForEach(
+ [&request](uint32_t rid, std::string rname, std::string module,
+ llvm::ArrayRef<lldb_private::ConstString> symbols,
+ bool regexp) {
+ StreamString strm;
+ if (rname.empty())
+ rname = "(internal)";
+
+ strm << rname;
+ if (!module.empty())
+ strm << ", module " << module;
+ if (!symbols.empty())
+ for (auto &symbol : symbols)
+ strm << ", symbol " << symbol;
+ if (regexp)
+ strm << " (regexp)";
+
+ request.TryCompleteCurrentArg(std::to_string(rid), strm.GetString());
+ });
+ }
+
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
if (command.GetArgumentCount() == 0) {
@@ -937,8 +985,13 @@ protected:
return false;
}
- uint32_t recognizer_id =
- StringConvert::ToUInt32(command.GetArgumentAtIndex(0), 0, 0);
+ uint32_t recognizer_id;
+ if (!llvm::to_integer(command.GetArgumentAtIndex(0), recognizer_id)) {
+ result.AppendErrorWithFormat("'%s' is not a valid recognizer id.\n",
+ command.GetArgumentAtIndex(0));
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
StackFrameRecognizerManager::RemoveRecognizerWithID(recognizer_id);
result.SetStatus(eReturnStatusSuccessFinishResult);
@@ -959,14 +1012,26 @@ protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
bool any_printed = false;
StackFrameRecognizerManager::ForEach(
- [&result, &any_printed](uint32_t recognizer_id, std::string name,
- std::string function, std::string symbol,
- bool regexp) {
- if (name == "")
+ [&result, &any_printed](
+ uint32_t recognizer_id, std::string name, std::string module,
+ llvm::ArrayRef<ConstString> symbols, bool regexp) {
+ Stream &stream = result.GetOutputStream();
+
+ if (name.empty())
name = "(internal)";
- result.GetOutputStream().Printf(
- "%d: %s, module %s, function %s%s\n", recognizer_id, name.c_str(),
- function.c_str(), symbol.c_str(), regexp ? " (regexp)" : "");
+
+ stream << std::to_string(recognizer_id) << ": " << name;
+ if (!module.empty())
+ stream << ", module " << module;
+ if (!symbols.empty())
+ for (auto &symbol : symbols)
+ stream << ", symbol " << symbol;
+ if (regexp)
+ stream << " (regexp)";
+
+ stream.EOL();
+ stream.Flush();
+
any_printed = true;
});
@@ -1006,6 +1071,15 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
+ const char *frame_index_str = command.GetArgumentAtIndex(0);
+ uint32_t frame_index;
+ if (!llvm::to_integer(frame_index_str, frame_index)) {
+ result.AppendErrorWithFormat("'%s' is not a valid frame index.",
+ frame_index_str);
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
Process *process = m_exe_ctx.GetProcessPtr();
if (process == nullptr) {
result.AppendError("no process");
@@ -1025,8 +1099,6 @@ protected:
return false;
}
- uint32_t frame_index =
- StringConvert::ToUInt32(command.GetArgumentAtIndex(0), 0, 0);
StackFrameSP frame_sp = thread->GetStackFrameAtIndex(frame_index);
if (!frame_sp) {
result.AppendErrorWithFormat("no frame with index %u", frame_index);
diff --git a/lldb/source/Commands/CommandObjectFrame.h b/lldb/source/Commands/CommandObjectFrame.h
index b2378f14290d..71cb94aa8f5a 100644
--- a/lldb/source/Commands/CommandObjectFrame.h
+++ b/lldb/source/Commands/CommandObjectFrame.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectFrame_h_
-#define liblldb_CommandObjectFrame_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTFRAME_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTFRAME_H
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -24,4 +24,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_CommandObjectFrame_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTFRAME_H
diff --git a/lldb/source/Commands/CommandObjectGUI.cpp b/lldb/source/Commands/CommandObjectGUI.cpp
index 67ddc68a169e..3f45a26de228 100644
--- a/lldb/source/Commands/CommandObjectGUI.cpp
+++ b/lldb/source/Commands/CommandObjectGUI.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectGUI.cpp ------------------------------------*- C++ -*-===//
+//===-- CommandObjectGUI.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -35,7 +35,7 @@ bool CommandObjectGUI::DoExecute(Args &args, CommandReturnObject &result) {
input.GetIsInteractive()) {
IOHandlerSP io_handler_sp(new IOHandlerCursesGUI(debugger));
if (io_handler_sp)
- debugger.PushIOHandler(io_handler_sp);
+ debugger.RunIOHandlerAsync(io_handler_sp);
result.SetStatus(eReturnStatusSuccessFinishResult);
} else {
result.AppendError("the gui command requires an interactive terminal.");
@@ -47,7 +47,7 @@ bool CommandObjectGUI::DoExecute(Args &args, CommandReturnObject &result) {
}
return true;
#else
- result.AppendError("lldb was not build with gui support");
+ result.AppendError("lldb was not built with gui support");
return false;
#endif
}
diff --git a/lldb/source/Commands/CommandObjectGUI.h b/lldb/source/Commands/CommandObjectGUI.h
index a19aad18ec35..49bad49a957d 100644
--- a/lldb/source/Commands/CommandObjectGUI.h
+++ b/lldb/source/Commands/CommandObjectGUI.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectGUI_h_
-#define liblldb_CommandObjectGUI_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTGUI_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTGUI_H
#include "lldb/Interpreter/CommandObject.h"
@@ -27,4 +27,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_CommandObjectGUI_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTGUI_H
diff --git a/lldb/source/Commands/CommandObjectHelp.cpp b/lldb/source/Commands/CommandObjectHelp.cpp
index 6e908dc496a0..6dc1868a2aff 100644
--- a/lldb/source/Commands/CommandObjectHelp.cpp
+++ b/lldb/source/Commands/CommandObjectHelp.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectHelp.cpp -----------------------------------*- C++ -*-===//
+//===-- CommandObjectHelp.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -107,7 +107,7 @@ bool CommandObjectHelp::DoExecute(Args &command, CommandReturnObject &result) {
// object that corresponds to the help command entered.
std::string sub_command;
for (auto &entry : command.entries().drop_front()) {
- sub_command = entry.ref();
+ sub_command = std::string(entry.ref());
matches.Clear();
if (sub_cmd_obj->IsAlias())
sub_cmd_obj =
diff --git a/lldb/source/Commands/CommandObjectHelp.h b/lldb/source/Commands/CommandObjectHelp.h
index 52a00ac79ff9..8f45db55666e 100644
--- a/lldb/source/Commands/CommandObjectHelp.h
+++ b/lldb/source/Commands/CommandObjectHelp.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectHelp_h_
-#define liblldb_CommandObjectHelp_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTHELP_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTHELP_H
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandObject.h"
@@ -84,4 +84,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_CommandObjectHelp_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTHELP_H
diff --git a/lldb/source/Commands/CommandObjectLanguage.cpp b/lldb/source/Commands/CommandObjectLanguage.cpp
index 35ce6e3193e8..e6d22ec4ae40 100644
--- a/lldb/source/Commands/CommandObjectLanguage.cpp
+++ b/lldb/source/Commands/CommandObjectLanguage.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectLanguage.cpp -------------------------------*- C++ -*-===//
+//===-- CommandObjectLanguage.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Commands/CommandObjectLanguage.h b/lldb/source/Commands/CommandObjectLanguage.h
index 47079e219d03..7a280902a07e 100644
--- a/lldb/source/Commands/CommandObjectLanguage.h
+++ b/lldb/source/Commands/CommandObjectLanguage.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectLanguage_h_
-#define liblldb_CommandObjectLanguage_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTLANGUAGE_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTLANGUAGE_H
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -23,4 +23,4 @@ protected:
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectLanguage_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTLANGUAGE_H
diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp
index 9bf0b30bc152..4016b07c91ed 100644
--- a/lldb/source/Commands/CommandObjectLog.cpp
+++ b/lldb/source/Commands/CommandObjectLog.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectLog.cpp ------------------------------------*- C++ -*-===//
+//===-- CommandObjectLog.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -156,7 +156,7 @@ protected:
}
// Store into a std::string since we're about to shift the channel off.
- const std::string channel = args[0].ref();
+ const std::string channel = std::string(args[0].ref());
args.Shift(); // Shift off the channel
char log_file[PATH_MAX];
if (m_options.log_file)
@@ -229,7 +229,7 @@ protected:
return false;
}
- const std::string channel = args[0].ref();
+ const std::string channel = std::string(args[0].ref());
args.Shift(); // Shift off the channel
if (channel == "all") {
Log::DisableAllLogChannels();
@@ -298,61 +298,170 @@ protected:
}
};
-class CommandObjectLogTimer : public CommandObjectParsed {
+class CommandObjectLogTimerEnable : public CommandObjectParsed {
public:
// Constructors and Destructors
- CommandObjectLogTimer(CommandInterpreter &interpreter)
- : CommandObjectParsed(interpreter, "log timers",
- "Enable, disable, dump, and reset LLDB internal "
- "performance timers.",
- "log timers < enable <depth> | disable | dump | "
- "increment <bool> | reset >") {}
+ CommandObjectLogTimerEnable(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "log timers enable",
+ "enable LLDB internal performance timers",
+ "log timers enable <depth>") {
+ CommandArgumentEntry arg;
+ CommandArgumentData depth_arg;
- ~CommandObjectLogTimer() override = default;
+ // Define the first (and only) variant of this arg.
+ depth_arg.arg_type = eArgTypeCount;
+ depth_arg.arg_repetition = eArgRepeatOptional;
+
+ // There is only one variant this argument could be; put it into the
+ // argument entry.
+ arg.push_back(depth_arg);
+
+ // Push the data for the first argument into the m_arguments vector.
+ m_arguments.push_back(arg);
+ }
+
+ ~CommandObjectLogTimerEnable() override = default;
+
+protected:
+ bool DoExecute(Args &args, CommandReturnObject &result) override {
+ result.SetStatus(eReturnStatusFailed);
+
+ if (args.GetArgumentCount() == 0) {
+ Timer::SetDisplayDepth(UINT32_MAX);
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ } else if (args.GetArgumentCount() == 1) {
+ uint32_t depth;
+ if (args[0].ref().consumeInteger(0, depth)) {
+ result.AppendError(
+ "Could not convert enable depth to an unsigned integer.");
+ } else {
+ Timer::SetDisplayDepth(depth);
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ }
+ }
+
+ if (!result.Succeeded()) {
+ result.AppendError("Missing subcommand");
+ result.AppendErrorWithFormat("Usage: %s\n", m_cmd_syntax.c_str());
+ }
+ return result.Succeeded();
+ }
+};
+
+class CommandObjectLogTimerDisable : public CommandObjectParsed {
+public:
+ // Constructors and Destructors
+ CommandObjectLogTimerDisable(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "log timers disable",
+ "disable LLDB internal performance timers",
+ nullptr) {}
+
+ ~CommandObjectLogTimerDisable() override = default;
+
+protected:
+ bool DoExecute(Args &args, CommandReturnObject &result) override {
+ Timer::DumpCategoryTimes(&result.GetOutputStream());
+ Timer::SetDisplayDepth(0);
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+
+ if (!result.Succeeded()) {
+ result.AppendError("Missing subcommand");
+ result.AppendErrorWithFormat("Usage: %s\n", m_cmd_syntax.c_str());
+ }
+ return result.Succeeded();
+ }
+};
+
+class CommandObjectLogTimerDump : public CommandObjectParsed {
+public:
+ // Constructors and Destructors
+ CommandObjectLogTimerDump(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "log timers dump",
+ "dump LLDB internal performance timers", nullptr) {}
+
+ ~CommandObjectLogTimerDump() override = default;
+
+protected:
+ bool DoExecute(Args &args, CommandReturnObject &result) override {
+ Timer::DumpCategoryTimes(&result.GetOutputStream());
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+
+ if (!result.Succeeded()) {
+ result.AppendError("Missing subcommand");
+ result.AppendErrorWithFormat("Usage: %s\n", m_cmd_syntax.c_str());
+ }
+ return result.Succeeded();
+ }
+};
+
+class CommandObjectLogTimerReset : public CommandObjectParsed {
+public:
+ // Constructors and Destructors
+ CommandObjectLogTimerReset(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "log timers reset",
+ "reset LLDB internal performance timers", nullptr) {
+ }
+
+ ~CommandObjectLogTimerReset() override = default;
+
+protected:
+ bool DoExecute(Args &args, CommandReturnObject &result) override {
+ Timer::ResetCategoryTimes();
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+
+ if (!result.Succeeded()) {
+ result.AppendError("Missing subcommand");
+ result.AppendErrorWithFormat("Usage: %s\n", m_cmd_syntax.c_str());
+ }
+ return result.Succeeded();
+ }
+};
+
+class CommandObjectLogTimerIncrement : public CommandObjectParsed {
+public:
+ // Constructors and Destructors
+ CommandObjectLogTimerIncrement(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "log timers increment",
+ "increment LLDB internal performance timers",
+ "log timers increment <bool>") {
+ CommandArgumentEntry arg;
+ CommandArgumentData bool_arg;
+
+ // Define the first (and only) variant of this arg.
+ bool_arg.arg_type = eArgTypeBoolean;
+ bool_arg.arg_repetition = eArgRepeatPlain;
+
+ // There is only one variant this argument could be; put it into the
+ // argument entry.
+ arg.push_back(bool_arg);
+
+ // Push the data for the first argument into the m_arguments vector.
+ m_arguments.push_back(arg);
+ }
+
+ ~CommandObjectLogTimerIncrement() override = default;
+
+ void
+ HandleArgumentCompletion(CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ request.TryCompleteCurrentArg("true");
+ request.TryCompleteCurrentArg("false");
+ }
protected:
bool DoExecute(Args &args, CommandReturnObject &result) override {
result.SetStatus(eReturnStatusFailed);
if (args.GetArgumentCount() == 1) {
- auto sub_command = args[0].ref();
+ bool success;
+ bool increment =
+ OptionArgParser::ToBoolean(args[0].ref(), false, &success);
- if (sub_command.equals_lower("enable")) {
- Timer::SetDisplayDepth(UINT32_MAX);
+ if (success) {
+ Timer::SetQuiet(!increment);
result.SetStatus(eReturnStatusSuccessFinishNoResult);
- } else if (sub_command.equals_lower("disable")) {
- Timer::DumpCategoryTimes(&result.GetOutputStream());
- Timer::SetDisplayDepth(0);
- result.SetStatus(eReturnStatusSuccessFinishResult);
- } else if (sub_command.equals_lower("dump")) {
- Timer::DumpCategoryTimes(&result.GetOutputStream());
- result.SetStatus(eReturnStatusSuccessFinishResult);
- } else if (sub_command.equals_lower("reset")) {
- Timer::ResetCategoryTimes();
- result.SetStatus(eReturnStatusSuccessFinishResult);
- }
- } else if (args.GetArgumentCount() == 2) {
- auto sub_command = args[0].ref();
- auto param = args[1].ref();
-
- if (sub_command.equals_lower("enable")) {
- uint32_t depth;
- if (param.consumeInteger(0, depth)) {
- result.AppendError(
- "Could not convert enable depth to an unsigned integer.");
- } else {
- Timer::SetDisplayDepth(depth);
- result.SetStatus(eReturnStatusSuccessFinishNoResult);
- }
- } else if (sub_command.equals_lower("increment")) {
- bool success;
- bool increment = OptionArgParser::ToBoolean(param, false, &success);
- if (success) {
- Timer::SetQuiet(!increment);
- result.SetStatus(eReturnStatusSuccessFinishNoResult);
- } else
- result.AppendError("Could not convert increment value to boolean.");
- }
+ } else
+ result.AppendError("Could not convert increment value to boolean.");
}
if (!result.Succeeded()) {
@@ -363,6 +472,30 @@ protected:
}
};
+class CommandObjectLogTimer : public CommandObjectMultiword {
+public:
+ CommandObjectLogTimer(CommandInterpreter &interpreter)
+ : CommandObjectMultiword(interpreter, "log timers",
+ "Enable, disable, dump, and reset LLDB internal "
+ "performance timers.",
+ "log timers < enable <depth> | disable | dump | "
+ "increment <bool> | reset >") {
+ LoadSubCommand("enable", CommandObjectSP(
+ new CommandObjectLogTimerEnable(interpreter)));
+ LoadSubCommand("disable", CommandObjectSP(new CommandObjectLogTimerDisable(
+ interpreter)));
+ LoadSubCommand("dump",
+ CommandObjectSP(new CommandObjectLogTimerDump(interpreter)));
+ LoadSubCommand(
+ "reset", CommandObjectSP(new CommandObjectLogTimerReset(interpreter)));
+ LoadSubCommand(
+ "increment",
+ CommandObjectSP(new CommandObjectLogTimerIncrement(interpreter)));
+ }
+
+ ~CommandObjectLogTimer() override = default;
+};
+
CommandObjectLog::CommandObjectLog(CommandInterpreter &interpreter)
: CommandObjectMultiword(interpreter, "log",
"Commands controlling LLDB internal logging.",
diff --git a/lldb/source/Commands/CommandObjectLog.h b/lldb/source/Commands/CommandObjectLog.h
index eae41bf6b8d1..8dc3f1b7b9e9 100644
--- a/lldb/source/Commands/CommandObjectLog.h
+++ b/lldb/source/Commands/CommandObjectLog.h
@@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectLog_h_
-#define liblldb_CommandObjectLog_h_
-
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTLOG_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTLOG_H
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -25,9 +24,10 @@ public:
private:
// For CommandObjectLog only
- DISALLOW_COPY_AND_ASSIGN(CommandObjectLog);
+ CommandObjectLog(const CommandObjectLog &) = delete;
+ const CommandObjectLog &operator=(const CommandObjectLog &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectLog_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTLOG_H
diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp
index e497b5246b8d..474c37710149 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectMemory.cpp ---------------------------------*- C++ -*-===//
+//===-- CommandObjectMemory.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Commands/CommandObjectMemory.h b/lldb/source/Commands/CommandObjectMemory.h
index f94cdf3287aa..5f7f6bb30b88 100644
--- a/lldb/source/Commands/CommandObjectMemory.h
+++ b/lldb/source/Commands/CommandObjectMemory.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectMemory_h_
-#define liblldb_CommandObjectMemory_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTMEMORY_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTMEMORY_H
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -22,4 +22,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_CommandObjectMemory_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTMEMORY_H
diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp
index 67225d3d6b8d..9033cfebf46b 100644
--- a/lldb/source/Commands/CommandObjectMultiword.cpp
+++ b/lldb/source/Commands/CommandObjectMultiword.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectMultiword.cpp ------------------------------*- C++ -*-===//
+//===-- CommandObjectMultiword.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -32,7 +32,7 @@ CommandObjectSP CommandObjectMultiword::GetSubcommandSP(llvm::StringRef sub_cmd,
CommandObject::CommandMap::iterator pos;
if (!m_subcommand_dict.empty()) {
- pos = m_subcommand_dict.find(sub_cmd);
+ pos = m_subcommand_dict.find(std::string(sub_cmd));
if (pos != m_subcommand_dict.end()) {
// An exact match; append the sub_cmd to the 'matches' string list.
if (matches)
@@ -50,7 +50,7 @@ CommandObjectSP CommandObjectMultiword::GetSubcommandSP(llvm::StringRef sub_cmd,
// function, since I now know I have an exact match...
sub_cmd = matches->GetStringAtIndex(0);
- pos = m_subcommand_dict.find(sub_cmd);
+ pos = m_subcommand_dict.find(std::string(sub_cmd));
if (pos != m_subcommand_dict.end())
return_cmd_sp = pos->second;
}
@@ -74,9 +74,9 @@ bool CommandObjectMultiword::LoadSubCommand(llvm::StringRef name,
CommandMap::iterator pos;
bool success = true;
- pos = m_subcommand_dict.find(name);
+ pos = m_subcommand_dict.find(std::string(name));
if (pos == m_subcommand_dict.end()) {
- m_subcommand_dict[name] = cmd_obj;
+ m_subcommand_dict[std::string(name)] = cmd_obj;
} else
success = false;
@@ -130,9 +130,9 @@ bool CommandObjectMultiword::Execute(const char *args_string,
error_msg.assign("invalid command ");
error_msg.append("'");
- error_msg.append(GetCommandName());
+ error_msg.append(std::string(GetCommandName()));
error_msg.append(" ");
- error_msg.append(sub_command);
+ error_msg.append(std::string(sub_command));
error_msg.append("'.");
if (num_subcmd_matches > 0) {
@@ -165,15 +165,14 @@ void CommandObjectMultiword::GenerateHelpText(Stream &output_stream) {
std::string indented_command(" ");
indented_command.append(pos->first);
if (pos->second->WantsRawCommandString()) {
- std::string help_text(pos->second->GetHelp());
+ std::string help_text(std::string(pos->second->GetHelp()));
help_text.append(" Expects 'raw' input (see 'help raw-input'.)");
- m_interpreter.OutputFormattedHelpText(output_stream,
- indented_command.c_str(), "--",
- help_text.c_str(), max_len);
+ m_interpreter.OutputFormattedHelpText(output_stream, indented_command,
+ "--", help_text, max_len);
} else
- m_interpreter.OutputFormattedHelpText(output_stream,
- indented_command.c_str(), "--",
- pos->second->GetHelp(), max_len);
+ m_interpreter.OutputFormattedHelpText(output_stream, indented_command,
+ "--", pos->second->GetHelp(),
+ max_len);
}
output_stream.PutCString("\nFor more help on any particular subcommand, type "
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 10e6a4aa1793..fcc8af6f915c 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectPlatform.cpp -------------------------------*- C++ -*-===//
+//===-- CommandObjectPlatform.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -11,7 +11,6 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/OptionParser.h"
-#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandOptionValidators.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -133,7 +132,8 @@ public:
uint32_t m_permissions;
private:
- DISALLOW_COPY_AND_ASSIGN(OptionPermissions);
+ OptionPermissions(const OptionPermissions &) = delete;
+ const OptionPermissions &operator=(const OptionPermissions &) = delete;
};
// "platform select <platform-name>"
@@ -421,7 +421,6 @@ protected:
return &m_options;
}
-protected:
OptionGroupOptions m_options;
OptionGroupFile m_option_working_dir;
};
@@ -546,8 +545,13 @@ public:
if (platform_sp) {
std::string cmd_line;
args.GetCommandString(cmd_line);
- const lldb::user_id_t fd =
- StringConvert::ToUInt64(cmd_line.c_str(), UINT64_MAX);
+ lldb::user_id_t fd;
+ if (!llvm::to_integer(cmd_line, fd)) {
+ result.AppendErrorWithFormatv("'{0}' is not a valid file descriptor.\n",
+ cmd_line);
+ result.SetStatus(eReturnStatusFailed);
+ return result.Succeeded();
+ }
Status error;
bool success = platform_sp->CloseFile(fd, error);
if (success) {
@@ -586,8 +590,13 @@ public:
if (platform_sp) {
std::string cmd_line;
args.GetCommandString(cmd_line);
- const lldb::user_id_t fd =
- StringConvert::ToUInt64(cmd_line.c_str(), UINT64_MAX);
+ lldb::user_id_t fd;
+ if (!llvm::to_integer(cmd_line, fd)) {
+ result.AppendErrorWithFormatv("'{0}' is not a valid file descriptor.\n",
+ cmd_line);
+ result.SetStatus(eReturnStatusFailed);
+ return result.Succeeded();
+ }
std::string buffer(m_options.m_count, 0);
Status error;
uint32_t retcode = platform_sp->ReadFile(
@@ -674,8 +683,13 @@ public:
std::string cmd_line;
args.GetCommandString(cmd_line);
Status error;
- const lldb::user_id_t fd =
- StringConvert::ToUInt64(cmd_line.c_str(), UINT64_MAX);
+ lldb::user_id_t fd;
+ if (!llvm::to_integer(cmd_line, fd)) {
+ result.AppendErrorWithFormatv("'{0}' is not a valid file descriptor.",
+ cmd_line);
+ result.SetStatus(eReturnStatusFailed);
+ return result.Succeeded();
+ }
uint32_t retcode =
platform_sp->WriteFile(fd, m_options.m_offset, &m_options.m_data[0],
m_options.m_data.size(), error);
@@ -709,7 +723,7 @@ protected:
option_arg.str().c_str());
break;
case 'd':
- m_data.assign(option_arg);
+ m_data.assign(std::string(option_arg));
break;
default:
llvm_unreachable("Unimplemented option");
@@ -758,7 +772,9 @@ public:
private:
// For CommandObjectPlatform only
- DISALLOW_COPY_AND_ASSIGN(CommandObjectPlatformFile);
+ CommandObjectPlatformFile(const CommandObjectPlatformFile &) = delete;
+ const CommandObjectPlatformFile &
+ operator=(const CommandObjectPlatformFile &) = delete;
};
// "platform get-file remote-file-path host-file-path"
@@ -1020,7 +1036,6 @@ protected:
return result.Succeeded();
}
-protected:
ProcessLaunchCommandOptions m_options;
};
@@ -1128,7 +1143,7 @@ protected:
ProcessInstanceInfo::DumpTableHeader(ostrm, m_options.show_args,
m_options.verbose);
for (uint32_t i = 0; i < matches; ++i) {
- proc_infos.GetProcessInfoAtIndex(i).DumpAsTableRow(
+ proc_infos[i].DumpAsTableRow(
ostrm, platform_sp->GetUserIDResolver(),
m_options.show_args, m_options.verbose);
}
@@ -1462,12 +1477,12 @@ public:
match_info.SetNameMatchType(NameMatch::StartsWith);
}
platform_sp->FindProcesses(match_info, process_infos);
- const uint32_t num_matches = process_infos.GetSize();
+ const uint32_t num_matches = process_infos.size();
if (num_matches == 0)
return;
for (uint32_t i = 0; i < num_matches; ++i) {
- request.AddCompletion(process_infos.GetProcessNameAtIndex(i));
+ request.AddCompletion(process_infos[i].GetNameAsStringRef());
}
return;
}
@@ -1541,7 +1556,9 @@ public:
private:
// For CommandObjectPlatform only
- DISALLOW_COPY_AND_ASSIGN(CommandObjectPlatformProcess);
+ CommandObjectPlatformProcess(const CommandObjectPlatformProcess &) = delete;
+ const CommandObjectPlatformProcess &
+ operator=(const CommandObjectPlatformProcess &) = delete;
};
// "platform shell"
@@ -1567,6 +1584,9 @@ public:
const char short_option = (char)GetDefinitions()[option_idx].short_option;
switch (short_option) {
+ case 'h':
+ m_use_host_platform = true;
+ break;
case 't':
uint32_t timeout_sec;
if (option_arg.getAsInteger(10, timeout_sec))
@@ -1574,7 +1594,7 @@ public:
"could not convert \"%s\" to a numeric value.",
option_arg.str().c_str());
else
- timeout = std::chrono::seconds(timeout_sec);
+ m_timeout = std::chrono::seconds(timeout_sec);
break;
default:
llvm_unreachable("Unimplemented option");
@@ -1583,9 +1603,13 @@ public:
return error;
}
- void OptionParsingStarting(ExecutionContext *execution_context) override {}
+ void OptionParsingStarting(ExecutionContext *execution_context) override {
+ m_timeout.reset();
+ m_use_host_platform = false;
+ }
- Timeout<std::micro> timeout = std::chrono::seconds(10);
+ Timeout<std::micro> m_timeout = std::chrono::seconds(10);
+ bool m_use_host_platform;
};
CommandObjectPlatformShell(CommandInterpreter &interpreter)
@@ -1609,6 +1633,7 @@ public:
return true;
}
+ const bool is_alias = !raw_command_line.contains("platform");
OptionsWithRaw args(raw_command_line);
const char *expr = args.GetRawPart().c_str();
@@ -1616,8 +1641,16 @@ public:
if (!ParseOptions(args.GetArgs(), result))
return false;
+ if (args.GetRawPart().empty()) {
+ result.GetOutputStream().Printf("%s <shell-command>\n",
+ is_alias ? "shell" : "platform shell");
+ return false;
+ }
+
PlatformSP platform_sp(
- GetDebugger().GetPlatformList().GetSelectedPlatform());
+ m_options.m_use_host_platform
+ ? Platform::GetHostPlatform()
+ : GetDebugger().GetPlatformList().GetSelectedPlatform());
Status error;
if (platform_sp) {
FileSpec working_dir{};
@@ -1625,7 +1658,7 @@ public:
int status = -1;
int signo = -1;
error = (platform_sp->RunShellCommand(expr, working_dir, &status, &signo,
- &output, m_options.timeout));
+ &output, m_options.m_timeout));
if (!output.empty())
result.GetOutputStream().PutCString(output);
if (status > 0) {
diff --git a/lldb/source/Commands/CommandObjectPlatform.h b/lldb/source/Commands/CommandObjectPlatform.h
index 45e4a41c5b20..86f55c7d9b08 100644
--- a/lldb/source/Commands/CommandObjectPlatform.h
+++ b/lldb/source/Commands/CommandObjectPlatform.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectPlatform_h_
-#define liblldb_CommandObjectPlatform_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTPLATFORM_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTPLATFORM_H
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -22,9 +22,11 @@ public:
~CommandObjectPlatform() override;
private:
- DISALLOW_COPY_AND_ASSIGN(CommandObjectPlatform);
+ CommandObjectPlatform(const CommandObjectPlatform &) = delete;
+ const CommandObjectPlatform &
+ operator=(const CommandObjectPlatform &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectPlatform_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTPLATFORM_H
diff --git a/lldb/source/Commands/CommandObjectPlugin.cpp b/lldb/source/Commands/CommandObjectPlugin.cpp
index 6fcb64f207b2..98a212eef0fa 100644
--- a/lldb/source/Commands/CommandObjectPlugin.cpp
+++ b/lldb/source/Commands/CommandObjectPlugin.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectPlugin.cpp ---------------------------------*- C++ -*-===//
+//===-- CommandObjectPlugin.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Commands/CommandObjectPlugin.h b/lldb/source/Commands/CommandObjectPlugin.h
index 94cea7db4111..6db9f0a40a40 100644
--- a/lldb/source/Commands/CommandObjectPlugin.h
+++ b/lldb/source/Commands/CommandObjectPlugin.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectPlugin_h_
-#define liblldb_CommandObjectPlugin_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTPLUGIN_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTPLUGIN_H
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -22,4 +22,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_CommandObjectPlugin_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTPLUGIN_H
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index d825647728f8..f86779d85b5f 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectProcess.cpp --------------------------------*- C++ -*-===//
+//===-- CommandObjectProcess.cpp ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -13,7 +13,6 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/OptionParser.h"
-#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
@@ -249,7 +248,6 @@ protected:
return result.Succeeded();
}
-protected:
ProcessLaunchCommandOptions m_options;
};
@@ -325,34 +323,38 @@ public:
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;
- // We are only completing the name option for now...
-
- // Are we in the name?
- if (GetDefinitions()[opt_defs_index].short_option != 'n')
- return;
-
- // Look to see if there is a -P argument provided, and if so use that
- // plugin, otherwise use the default plugin.
-
- const char *partial_name = nullptr;
- partial_name = request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos);
+ switch (GetDefinitions()[opt_defs_index].short_option) {
+ case 'n': {
+ // Look to see if there is a -P argument provided, and if so use that
+ // plugin, otherwise use the default plugin.
+
+ const char *partial_name = nullptr;
+ partial_name = request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos);
+
+ PlatformSP platform_sp(interpreter.GetPlatform(true));
+ if (!platform_sp)
+ return;
+ ProcessInstanceInfoList process_infos;
+ ProcessInstanceInfoMatch match_info;
+ if (partial_name) {
+ match_info.GetProcessInfo().GetExecutableFile().SetFile(
+ partial_name, FileSpec::Style::native);
+ match_info.SetNameMatchType(NameMatch::StartsWith);
+ }
+ platform_sp->FindProcesses(match_info, process_infos);
+ const size_t num_matches = process_infos.size();
+ if (num_matches == 0)
+ return;
+ for (size_t i = 0; i < num_matches; ++i) {
+ request.AddCompletion(process_infos[i].GetNameAsStringRef());
+ }
+ } break;
- PlatformSP platform_sp(interpreter.GetPlatform(true));
- if (!platform_sp)
- return;
- ProcessInstanceInfoList process_infos;
- ProcessInstanceInfoMatch match_info;
- if (partial_name) {
- match_info.GetProcessInfo().GetExecutableFile().SetFile(
- partial_name, FileSpec::Style::native);
- match_info.SetNameMatchType(NameMatch::StartsWith);
- }
- platform_sp->FindProcesses(match_info, process_infos);
- const size_t num_matches = process_infos.GetSize();
- if (num_matches == 0)
- return;
- for (size_t i = 0; i < num_matches; ++i) {
- request.AddCompletion(process_infos.GetProcessNameAtIndex(i));
+ case 'P':
+ CommandCompletions::InvokeCommonCompletionCallbacks(
+ interpreter, CommandCompletions::eProcessPluginCompletion, request,
+ nullptr);
+ break;
}
}
@@ -759,7 +761,7 @@ public:
switch (short_option) {
case 'p':
- plugin_name.assign(option_arg);
+ plugin_name.assign(std::string(option_arg));
break;
default:
@@ -818,9 +820,15 @@ protected:
Status error;
Debugger &debugger = GetDebugger();
PlatformSP platform_sp = m_interpreter.GetPlatform(true);
- ProcessSP process_sp = platform_sp->ConnectProcess(
- command.GetArgumentAtIndex(0), plugin_name, debugger,
- debugger.GetSelectedTarget().get(), error);
+ ProcessSP process_sp =
+ debugger.GetAsyncExecution()
+ ? platform_sp->ConnectProcess(
+ command.GetArgumentAtIndex(0), plugin_name, debugger,
+ debugger.GetSelectedTarget().get(), error)
+ : platform_sp->ConnectProcessSynchronous(
+ command.GetArgumentAtIndex(0), plugin_name, debugger,
+ result.GetOutputStream(), debugger.GetSelectedTarget().get(),
+ error);
if (error.Fail() || process_sp == nullptr) {
result.AppendError(error.AsCString("Error connecting to the process"));
result.SetStatus(eReturnStatusFailed);
@@ -1034,6 +1042,20 @@ public:
~CommandObjectProcessSignal() override = default;
+ void
+ HandleArgumentCompletion(CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ if (!m_exe_ctx.HasProcessScope() || request.GetCursorIndex() != 0)
+ return;
+
+ UnixSignalsSP signals = m_exe_ctx.GetProcessPtr()->GetUnixSignals();
+ int signo = signals->GetFirstSignalNumber();
+ while (signo != LLDB_INVALID_SIGNAL_NUMBER) {
+ request.AddCompletion(signals->GetSignalAsCString(signo), "");
+ signo = signals->GetNextSignalNumber(signo);
+ }
+ }
+
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
Process *process = m_exe_ctx.GetProcessPtr();
@@ -1042,10 +1064,10 @@ protected:
int signo = LLDB_INVALID_SIGNAL_NUMBER;
const char *signal_name = command.GetArgumentAtIndex(0);
- if (::isxdigit(signal_name[0]))
- signo =
- StringConvert::ToSInt32(signal_name, LLDB_INVALID_SIGNAL_NUMBER, 0);
- else
+ if (::isxdigit(signal_name[0])) {
+ if (!llvm::to_integer(signal_name, signo))
+ signo = LLDB_INVALID_SIGNAL_NUMBER;
+ } else
signo = process->GetUnixSignals()->GetSignalNumberFromName(signal_name);
if (signo == LLDB_INVALID_SIGNAL_NUMBER) {
@@ -1201,6 +1223,8 @@ protected:
// CommandObjectProcessStatus
#pragma mark CommandObjectProcessStatus
+#define LLDB_OPTIONS_process_status
+#include "CommandOptions.inc"
class CommandObjectProcessStatus : public CommandObjectParsed {
public:
@@ -1209,13 +1233,57 @@ public:
interpreter, "process status",
"Show status and stop location for the current target process.",
"process status",
- eCommandRequiresProcess | eCommandTryTargetAPILock) {}
+ eCommandRequiresProcess | eCommandTryTargetAPILock),
+ m_options() {}
~CommandObjectProcessStatus() override = default;
+ Options *GetOptions() override { return &m_options; }
+
+ class CommandOptions : public Options {
+ public:
+ CommandOptions() : Options(), m_verbose(false) {}
+
+ ~CommandOptions() override = default;
+
+ Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ ExecutionContext *execution_context) override {
+ const int short_option = m_getopt_table[option_idx].val;
+
+ switch (short_option) {
+ case 'v':
+ m_verbose = true;
+ break;
+ default:
+ llvm_unreachable("Unimplemented option");
+ }
+
+ return {};
+ }
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override {
+ m_verbose = false;
+ }
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
+ return llvm::makeArrayRef(g_process_status_options);
+ }
+
+ // Instance variables to hold the values for command options.
+ bool m_verbose;
+ };
+
+protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
Stream &strm = result.GetOutputStream();
result.SetStatus(eReturnStatusSuccessFinishNoResult);
+
+ if (command.GetArgumentCount()) {
+ result.AppendError("'process status' takes no arguments");
+ result.SetStatus(eReturnStatusFailed);
+ return result.Succeeded();
+ }
+
// No need to check "process" for validity as eCommandRequiresProcess
// ensures it is valid
Process *process = m_exe_ctx.GetProcessPtr();
@@ -1227,8 +1295,37 @@ public:
process->GetStatus(strm);
process->GetThreadStatus(strm, only_threads_with_stop_reason, start_frame,
num_frames, num_frames_with_source, stop_format);
+
+ if (m_options.m_verbose) {
+ PlatformSP platform_sp = process->GetTarget().GetPlatform();
+ if (!platform_sp) {
+ result.AppendError("Couldn'retrieve the target's platform");
+ result.SetStatus(eReturnStatusFailed);
+ return result.Succeeded();
+ }
+
+ auto expected_crash_info =
+ platform_sp->FetchExtendedCrashInformation(*process);
+
+ if (!expected_crash_info) {
+ result.AppendError(llvm::toString(expected_crash_info.takeError()));
+ result.SetStatus(eReturnStatusFailed);
+ return result.Succeeded();
+ }
+
+ StructuredData::DictionarySP crash_info_sp = *expected_crash_info;
+
+ if (crash_info_sp) {
+ strm.PutCString("Extended Crash Information:\n");
+ crash_info_sp->Dump(strm);
+ }
+ }
+
return result.Succeeded();
}
+
+private:
+ CommandOptions m_options;
};
// CommandObjectProcessHandle
@@ -1252,13 +1349,13 @@ public:
switch (short_option) {
case 's':
- stop = option_arg;
+ stop = std::string(option_arg);
break;
case 'n':
- notify = option_arg;
+ notify = std::string(option_arg);
break;
case 'p':
- pass = option_arg;
+ pass = std::string(option_arg);
break;
default:
llvm_unreachable("Unimplemented option");
@@ -1318,7 +1415,8 @@ public:
real_value = 0;
else {
// If the value isn't 'true' or 'false', it had better be 0 or 1.
- real_value = StringConvert::ToUInt32(option.c_str(), 3);
+ if (!llvm::to_integer(option, real_value))
+ real_value = 3;
if (real_value != 0 && real_value != 1)
okay = false;
}
diff --git a/lldb/source/Commands/CommandObjectProcess.h b/lldb/source/Commands/CommandObjectProcess.h
index 3b1ff26dbb05..55d445142e72 100644
--- a/lldb/source/Commands/CommandObjectProcess.h
+++ b/lldb/source/Commands/CommandObjectProcess.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectProcess_h_
-#define liblldb_CommandObjectProcess_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTPROCESS_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTPROCESS_H
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -24,4 +24,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_CommandObjectProcess_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTPROCESS_H
diff --git a/lldb/source/Commands/CommandObjectQuit.cpp b/lldb/source/Commands/CommandObjectQuit.cpp
index 70ee336f8a1b..d0c7bbd3abf8 100644
--- a/lldb/source/Commands/CommandObjectQuit.cpp
+++ b/lldb/source/Commands/CommandObjectQuit.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectQuit.cpp -----------------------------------*- C++ -*-===//
+//===-- CommandObjectQuit.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Commands/CommandObjectQuit.h b/lldb/source/Commands/CommandObjectQuit.h
index 458ef2456fca..ccbd863cd6f5 100644
--- a/lldb/source/Commands/CommandObjectQuit.h
+++ b/lldb/source/Commands/CommandObjectQuit.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectQuit_h_
-#define liblldb_CommandObjectQuit_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTQUIT_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTQUIT_H
#include "lldb/Interpreter/CommandObject.h"
@@ -29,4 +29,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_CommandObjectQuit_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTQUIT_H
diff --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp
index 523b32a996b2..56e8c3fb4b84 100644
--- a/lldb/source/Commands/CommandObjectRegister.cpp
+++ b/lldb/source/Commands/CommandObjectRegister.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectRegister.cpp -------------------------------*- C++ -*-===//
+//===-- CommandObjectRegister.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -70,6 +70,17 @@ public:
~CommandObjectRegisterRead() override = default;
+ void
+ HandleArgumentCompletion(CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ if (!m_exe_ctx.HasProcessScope())
+ return;
+
+ CommandCompletions::InvokeCommonCompletionCallbacks(
+ GetCommandInterpreter(), CommandCompletions::eRegisterCompletion,
+ request, nullptr);
+ }
+
Options *GetOptions() override { return &m_option_group; }
bool DumpRegister(const ExecutionContext &exe_ctx, Stream &strm,
@@ -323,6 +334,17 @@ public:
~CommandObjectRegisterWrite() override = default;
+ void
+ HandleArgumentCompletion(CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ if (!m_exe_ctx.HasProcessScope() || request.GetCursorIndex() != 0)
+ return;
+
+ CommandCompletions::InvokeCommonCompletionCallbacks(
+ GetCommandInterpreter(), CommandCompletions::eRegisterCompletion,
+ request, nullptr);
+ }
+
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
DataExtractor reg_data;
diff --git a/lldb/source/Commands/CommandObjectRegister.h b/lldb/source/Commands/CommandObjectRegister.h
index 6fc47cf386a3..671ffc570147 100644
--- a/lldb/source/Commands/CommandObjectRegister.h
+++ b/lldb/source/Commands/CommandObjectRegister.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectRegister_h_
-#define liblldb_CommandObjectRegister_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTREGISTER_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTREGISTER_H
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -24,9 +24,11 @@ public:
private:
// For CommandObjectRegister only
- DISALLOW_COPY_AND_ASSIGN(CommandObjectRegister);
+ CommandObjectRegister(const CommandObjectRegister &) = delete;
+ const CommandObjectRegister &
+ operator=(const CommandObjectRegister &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectRegister_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTREGISTER_H
diff --git a/lldb/source/Commands/CommandObjectReproducer.cpp b/lldb/source/Commands/CommandObjectReproducer.cpp
index d15f622314d9..104130b70b2b 100644
--- a/lldb/source/Commands/CommandObjectReproducer.cpp
+++ b/lldb/source/Commands/CommandObjectReproducer.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectReproducer.cpp -----------------------------*- C++ -*-===//
+//===-- CommandObjectReproducer.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,13 +8,14 @@
#include "CommandObjectReproducer.h"
+#include "lldb/Host/HostInfo.h"
#include "lldb/Host/OptionParser.h"
-#include "lldb/Utility/GDBRemote.h"
-#include "lldb/Utility/Reproducer.h"
-
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
+#include "lldb/Utility/GDBRemote.h"
+#include "lldb/Utility/ProcessInfo.h"
+#include "lldb/Utility/Reproducer.h"
#include <csignal>
@@ -27,6 +28,7 @@ enum ReproducerProvider {
eReproducerProviderCommands,
eReproducerProviderFiles,
eReproducerProviderGDB,
+ eReproducerProviderProcessInfo,
eReproducerProviderVersion,
eReproducerProviderWorkingDirectory,
eReproducerProviderNone
@@ -49,6 +51,11 @@ static constexpr OptionEnumValueElement g_reproducer_provider_type[] = {
"GDB Remote Packets",
},
{
+ eReproducerProviderProcessInfo,
+ "processes",
+ "Process Info",
+ },
+ {
eReproducerProviderVersion,
"version",
"Version",
@@ -97,6 +104,24 @@ static constexpr OptionEnumValues ReproducerSignalType() {
#define LLDB_OPTIONS_reproducer_xcrash
#include "CommandOptions.inc"
+template <typename T>
+llvm::Expected<T> static ReadFromYAML(StringRef filename) {
+ auto error_or_file = MemoryBuffer::getFile(filename);
+ if (auto err = error_or_file.getError()) {
+ return errorCodeToError(err);
+ }
+
+ T t;
+ yaml::Input yin((*error_or_file)->getBuffer());
+ yin >> t;
+
+ if (auto err = yin.error()) {
+ return errorCodeToError(err);
+ }
+
+ return t;
+}
+
class CommandObjectReproducerGenerate : public CommandObjectParsed {
public:
CommandObjectReproducerGenerate(CommandInterpreter &interpreter)
@@ -258,6 +283,18 @@ protected:
result.GetOutputStream() << "Reproducer is off.\n";
}
+ if (r.IsCapturing() || r.IsReplaying()) {
+ result.GetOutputStream()
+ << "Path: " << r.GetReproducerPath().GetPath() << '\n';
+ }
+
+ // Auto generate is hidden unless enabled because this is mostly for
+ // development and testing.
+ if (Generator *g = r.GetGenerator()) {
+ if (g->IsAutoGenerate())
+ result.GetOutputStream() << "Auto generate: on\n";
+ }
+
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
}
@@ -410,8 +447,8 @@ protected:
repro::MultiLoader<repro::CommandProvider>::Create(loader);
if (!multi_loader) {
SetError(result,
- make_error<StringError>(llvm::inconvertibleErrorCode(),
- "Unable to create command loader."));
+ make_error<StringError>("Unable to create command loader.",
+ llvm::inconvertibleErrorCode()));
return false;
}
@@ -436,26 +473,52 @@ protected:
std::unique_ptr<repro::MultiLoader<repro::GDBRemoteProvider>>
multi_loader =
repro::MultiLoader<repro::GDBRemoteProvider>::Create(loader);
+
+ if (!multi_loader) {
+ SetError(result,
+ make_error<StringError>("Unable to create GDB loader.",
+ llvm::inconvertibleErrorCode()));
+ return false;
+ }
+
llvm::Optional<std::string> gdb_file;
while ((gdb_file = multi_loader->GetNextFile())) {
- auto error_or_file = MemoryBuffer::getFile(*gdb_file);
- if (auto err = error_or_file.getError()) {
- SetError(result, errorCodeToError(err));
+ if (llvm::Expected<std::vector<GDBRemotePacket>> packets =
+ ReadFromYAML<std::vector<GDBRemotePacket>>(*gdb_file)) {
+ for (GDBRemotePacket &packet : *packets) {
+ packet.Dump(result.GetOutputStream());
+ }
+ } else {
+ SetError(result, packets.takeError());
return false;
}
+ }
+
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ return true;
+ }
+ case eReproducerProviderProcessInfo: {
+ std::unique_ptr<repro::MultiLoader<repro::ProcessInfoProvider>>
+ multi_loader =
+ repro::MultiLoader<repro::ProcessInfoProvider>::Create(loader);
- std::vector<GDBRemotePacket> packets;
- yaml::Input yin((*error_or_file)->getBuffer());
- yin >> packets;
+ if (!multi_loader) {
+ SetError(result, make_error<StringError>(
+ llvm::inconvertibleErrorCode(),
+ "Unable to create process info loader."));
+ return false;
+ }
- if (auto err = yin.error()) {
- SetError(result, errorCodeToError(err));
+ llvm::Optional<std::string> process_file;
+ while ((process_file = multi_loader->GetNextFile())) {
+ if (llvm::Expected<ProcessInstanceInfoList> infos =
+ ReadFromYAML<ProcessInstanceInfoList>(*process_file)) {
+ for (ProcessInstanceInfo info : *infos)
+ info.Dump(result.GetOutputStream(), HostInfo::GetUserIDResolver());
+ } else {
+ SetError(result, infos.takeError());
return false;
}
-
- for (GDBRemotePacket &packet : packets) {
- packet.Dump(result.GetOutputStream());
- }
}
result.SetStatus(eReturnStatusSuccessFinishResult);
diff --git a/lldb/source/Commands/CommandObjectReproducer.h b/lldb/source/Commands/CommandObjectReproducer.h
index 8a85c21d6510..bdee8053549f 100644
--- a/lldb/source/Commands/CommandObjectReproducer.h
+++ b/lldb/source/Commands/CommandObjectReproducer.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectReproducer_h_
-#define liblldb_CommandObjectReproducer_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTREPRODUCER_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTREPRODUCER_H
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -24,4 +24,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_CommandObjectReproducer_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTREPRODUCER_H
diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp
index 95f79f45e22b..87e0352636e1 100644
--- a/lldb/source/Commands/CommandObjectSettings.cpp
+++ b/lldb/source/Commands/CommandObjectSettings.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectSettings.cpp -------------------------------*- C++ -*-===//
+//===-- CommandObjectSettings.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -343,7 +343,7 @@ public:
switch (short_option) {
case 'f':
- m_filename.assign(option_arg);
+ m_filename.assign(std::string(option_arg));
break;
case 'a':
m_append = true;
@@ -444,7 +444,7 @@ public:
switch (short_option) {
case 'f':
- m_filename.assign(option_arg);
+ m_filename.assign(std::string(option_arg));
break;
default:
llvm_unreachable("Unimplemented option");
@@ -531,10 +531,8 @@ protected:
if (argc > 0) {
const bool dump_qualified_name = true;
- // TODO: Convert to StringRef based enumeration. Requires converting
- // GetPropertyAtPath first.
- for (size_t i = 0; i < argc; ++i) {
- const char *property_path = args.GetArgumentAtIndex(i);
+ for (const Args::ArgEntry &arg : args) {
+ const char *property_path = arg.c_str();
const Property *property =
GetDebugger().GetValueProperties()->GetPropertyAtPath(
@@ -1043,13 +1041,16 @@ protected:
};
// CommandObjectSettingsClear
+#define LLDB_OPTIONS_settings_clear
+#include "CommandOptions.inc"
class CommandObjectSettingsClear : public CommandObjectParsed {
public:
CommandObjectSettingsClear(CommandInterpreter &interpreter)
: CommandObjectParsed(
interpreter, "settings clear",
- "Clear a debugger setting array, dictionary, or string.", nullptr) {
+ "Clear a debugger setting array, dictionary, or string. "
+ "If '-a' option is specified, it clears all settings.", nullptr) {
CommandArgumentEntry arg;
CommandArgumentData var_name_arg;
@@ -1077,11 +1078,53 @@ public:
request, nullptr);
}
+ Options *GetOptions() override { return &m_options; }
+
+ class CommandOptions : public Options {
+ public:
+ CommandOptions() = default;
+
+ ~CommandOptions() override = default;
+
+ Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ ExecutionContext *execution_context) override {
+ const int short_option = m_getopt_table[option_idx].val;
+ switch (short_option) {
+ case 'a':
+ m_clear_all = true;
+ break;
+ default:
+ llvm_unreachable("Unimplemented option");
+ }
+ return Status();
+ }
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override {
+ m_clear_all = false;
+ }
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
+ return llvm::makeArrayRef(g_settings_clear_options);
+ }
+
+ bool m_clear_all = false;
+ };
+
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
result.SetStatus(eReturnStatusSuccessFinishNoResult);
const size_t argc = command.GetArgumentCount();
+ if (m_options.m_clear_all) {
+ if (argc != 0) {
+ result.AppendError("'settings clear --all' doesn't take any arguments");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ GetDebugger().GetValueProperties()->Clear();
+ return result.Succeeded();
+ }
+
if (argc != 1) {
result.AppendError("'settings clear' takes exactly one argument");
result.SetStatus(eReturnStatusFailed);
@@ -1106,6 +1149,9 @@ protected:
return result.Succeeded();
}
+
+ private:
+ CommandOptions m_options;
};
// CommandObjectMultiwordSettings
diff --git a/lldb/source/Commands/CommandObjectSettings.h b/lldb/source/Commands/CommandObjectSettings.h
index 4db0ca1f83f8..31ec1d3bef16 100644
--- a/lldb/source/Commands/CommandObjectSettings.h
+++ b/lldb/source/Commands/CommandObjectSettings.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectSettings_h_
-#define liblldb_CommandObjectSettings_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTSETTINGS_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTSETTINGS_H
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -24,4 +24,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_CommandObjectSettings_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTSETTINGS_H
diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp
index 19a554fb290a..1ccfd3a5166f 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectSource.cpp ---------------------------------*- C++ -*-===//
+//===-- CommandObjectSource.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -63,11 +63,11 @@ class CommandObjectSourceInfo : public CommandObjectParsed {
break;
case 'f':
- file_name = option_arg;
+ file_name = std::string(option_arg);
break;
case 'n':
- symbol_name = option_arg;
+ symbol_name = std::string(option_arg);
break;
case 'a': {
@@ -646,11 +646,11 @@ class CommandObjectSourceList : public CommandObjectParsed {
break;
case 'f':
- file_name = option_arg;
+ file_name = std::string(option_arg);
break;
case 'n':
- symbol_name = option_arg;
+ symbol_name = std::string(option_arg);
break;
case 'a': {
diff --git a/lldb/source/Commands/CommandObjectSource.h b/lldb/source/Commands/CommandObjectSource.h
index a4b8823a4fa9..f2117bd6ca3f 100644
--- a/lldb/source/Commands/CommandObjectSource.h
+++ b/lldb/source/Commands/CommandObjectSource.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectSource_h_
-#define liblldb_CommandObjectSource_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTSOURCE_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTSOURCE_H
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -25,4 +25,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_CommandObjectSource_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTSOURCE_H
diff --git a/lldb/source/Commands/CommandObjectStats.cpp b/lldb/source/Commands/CommandObjectStats.cpp
index eeec4a8d3e77..6b06581f5a8f 100644
--- a/lldb/source/Commands/CommandObjectStats.cpp
+++ b/lldb/source/Commands/CommandObjectStats.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectStats.cpp ----------------------------------*- C++ -*-===//
+//===-- CommandObjectStats.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Commands/CommandObjectStats.h b/lldb/source/Commands/CommandObjectStats.h
index 593c4521e175..c4cd6340f67b 100644
--- a/lldb/source/Commands/CommandObjectStats.h
+++ b/lldb/source/Commands/CommandObjectStats.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectStats_h_
-#define liblldb_CommandObjectStats_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTSTATS_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTSTATS_H
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -20,4 +20,4 @@ public:
};
} // namespace lldb_private
-#endif // liblldb_CommandObjectLanguage_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTSTATS_H
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index 8738e850c9f7..7bb71f4d518c 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectTarget.cpp ---------------------------------*- C++ -*-===//
+//===-- CommandObjectTarget.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -16,7 +16,6 @@
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
#include "lldb/Host/OptionParser.h"
-#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
@@ -200,7 +199,9 @@ public:
LoadDependentFiles m_load_dependent_files;
private:
- DISALLOW_COPY_AND_ASSIGN(OptionGroupDependents);
+ OptionGroupDependents(const OptionGroupDependents &) = delete;
+ const OptionGroupDependents &
+ operator=(const OptionGroupDependents &) = delete;
};
#pragma mark CommandObjectTargetCreate
@@ -271,15 +272,13 @@ protected:
FileSpec remote_file(m_remote_file.GetOptionValue().GetCurrentValue());
if (core_file) {
- if (!FileSystem::Instance().Exists(core_file)) {
- result.AppendErrorWithFormat("core file '%s' doesn't exist",
- core_file.GetPath().c_str());
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
- if (!FileSystem::Instance().Readable(core_file)) {
- result.AppendErrorWithFormat("core file '%s' is not readable",
- core_file.GetPath().c_str());
+ auto file = FileSystem::Instance().Open(
+ core_file, lldb_private::File::eOpenOptionRead);
+
+ if (!file) {
+ result.AppendErrorWithFormatv("Cannot open '{0}': {1}.",
+ core_file.GetPath(),
+ llvm::toString(file.takeError()));
result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -288,18 +287,13 @@ protected:
if (argc == 1 || core_file || remote_file) {
FileSpec symfile(m_symbol_file.GetOptionValue().GetCurrentValue());
if (symfile) {
- if (FileSystem::Instance().Exists(symfile)) {
- if (!FileSystem::Instance().Readable(symfile)) {
- result.AppendErrorWithFormat("symbol file '%s' is not readable",
- symfile.GetPath().c_str());
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
- } else {
- char symfile_path[PATH_MAX];
- symfile.GetPath(symfile_path, sizeof(symfile_path));
- result.AppendErrorWithFormat("invalid symbol file path '%s'",
- symfile_path);
+ auto file = FileSystem::Instance().Open(
+ symfile, lldb_private::File::eOpenOptionRead);
+
+ if (!file) {
+ result.AppendErrorWithFormatv("Cannot open '{0}': {1}.",
+ symfile.GetPath(),
+ llvm::toString(file.takeError()));
result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -401,48 +395,34 @@ protected:
if (module_sp)
module_sp->SetPlatformFileSpec(remote_file);
}
+
if (core_file) {
- char core_path[PATH_MAX];
- core_file.GetPath(core_path, sizeof(core_path));
- if (FileSystem::Instance().Exists(core_file)) {
- if (!FileSystem::Instance().Readable(core_file)) {
- result.AppendMessageWithFormat(
- "Core file '%s' is not readable.\n", core_path);
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
- FileSpec core_file_dir;
- core_file_dir.GetDirectory() = core_file.GetDirectory();
- target_sp->AppendExecutableSearchPaths(core_file_dir);
+ FileSpec core_file_dir;
+ core_file_dir.GetDirectory() = core_file.GetDirectory();
+ target_sp->AppendExecutableSearchPaths(core_file_dir);
- ProcessSP process_sp(target_sp->CreateProcess(
- GetDebugger().GetListener(), llvm::StringRef(), &core_file));
+ ProcessSP process_sp(target_sp->CreateProcess(
+ GetDebugger().GetListener(), llvm::StringRef(), &core_file));
- if (process_sp) {
- // Seems weird that we Launch a core file, but that is what we
- // do!
- error = process_sp->LoadCore();
+ if (process_sp) {
+ // Seems weird that we Launch a core file, but that is what we
+ // do!
+ error = process_sp->LoadCore();
- if (error.Fail()) {
- result.AppendError(
- error.AsCString("can't find plug-in for core file"));
- result.SetStatus(eReturnStatusFailed);
- return false;
- } else {
- result.AppendMessageWithFormat(
- "Core file '%s' (%s) was loaded.\n", core_path,
- target_sp->GetArchitecture().GetArchitectureName());
- result.SetStatus(eReturnStatusSuccessFinishNoResult);
- }
- } else {
- result.AppendErrorWithFormat(
- "Unable to find process plug-in for core file '%s'\n",
- core_path);
+ if (error.Fail()) {
+ result.AppendError(
+ error.AsCString("can't find plug-in for core file"));
result.SetStatus(eReturnStatusFailed);
+ return false;
+ } else {
+ result.AppendMessageWithFormatv("Core file '{0}' ({1}) was loaded.\n", core_file.GetPath(),
+ target_sp->GetArchitecture().GetArchitectureName());
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
}
} else {
- result.AppendErrorWithFormat("Core file '%s' does not exist\n",
- core_path);
+ result.AppendErrorWithFormatv(
+ "Unable to find process plug-in for core file '{0}'\n",
+ core_file.GetPath());
result.SetStatus(eReturnStatusFailed);
}
} else {
@@ -525,11 +505,9 @@ public:
protected:
bool DoExecute(Args &args, CommandReturnObject &result) override {
if (args.GetArgumentCount() == 1) {
- bool success = false;
const char *target_idx_arg = args.GetArgumentAtIndex(0);
- uint32_t target_idx =
- StringConvert::ToUInt32(target_idx_arg, UINT32_MAX, 0, &success);
- if (success) {
+ uint32_t target_idx;
+ if (llvm::to_integer(target_idx_arg, target_idx)) {
TargetList &target_list = GetDebugger().GetTargetList();
const uint32_t num_targets = target_list.GetNumTargets();
if (target_idx < num_targets) {
@@ -571,7 +549,7 @@ protected:
}
};
-#pragma mark CommandObjectTargetSelect
+#pragma mark CommandObjectTargetDelete
// "target delete"
@@ -682,6 +660,41 @@ protected:
OptionGroupBoolean m_cleanup_option;
};
+class CommandObjectTargetShowLaunchEnvironment : public CommandObjectParsed {
+public:
+ CommandObjectTargetShowLaunchEnvironment(CommandInterpreter &interpreter)
+ : CommandObjectParsed(
+ interpreter, "target show-launch-environment",
+ "Shows the environment being passed to the process when launched, "
+ "taking info account 3 settings: target.env-vars, "
+ "target.inherit-env and target.unset-env-vars.",
+ nullptr, eCommandRequiresTarget) {}
+
+ ~CommandObjectTargetShowLaunchEnvironment() override = default;
+
+protected:
+ bool DoExecute(Args &args, CommandReturnObject &result) override {
+ Target *target = m_exe_ctx.GetTargetPtr();
+ Environment env = target->GetEnvironment();
+
+ std::vector<Environment::value_type *> env_vector;
+ env_vector.reserve(env.size());
+ for (auto &KV : env)
+ env_vector.push_back(&KV);
+ std::sort(env_vector.begin(), env_vector.end(),
+ [](Environment::value_type *a, Environment::value_type *b) {
+ return a->first() < b->first();
+ });
+
+ auto &strm = result.GetOutputStream();
+ for (auto &KV : env_vector)
+ strm.Format("{0}={1}\n", KV->first(), KV->second);
+
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ return result.Succeeded();
+ }
+};
+
#pragma mark CommandObjectTargetVariable
// "target variable"
@@ -841,21 +854,18 @@ protected:
Stream &s = result.GetOutputStream();
if (argc > 0) {
-
- // TODO: Convert to entry-based iteration. Requires converting
- // DumpValueObject.
- for (size_t idx = 0; idx < argc; ++idx) {
+ for (const Args::ArgEntry &arg : args) {
VariableList variable_list;
ValueObjectList valobj_list;
- const char *arg = args.GetArgumentAtIndex(idx);
size_t matches = 0;
bool use_var_name = false;
if (m_option_variable.use_regex) {
- RegularExpression regex(llvm::StringRef::withNullAsEmpty(arg));
+ RegularExpression regex(
+ llvm::StringRef::withNullAsEmpty(arg.c_str()));
if (!regex.IsValid()) {
result.GetErrorStream().Printf(
- "error: invalid regular expression: '%s'\n", arg);
+ "error: invalid regular expression: '%s'\n", arg.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -865,14 +875,14 @@ protected:
matches = variable_list.GetSize();
} else {
Status error(Variable::GetValuesForVariableExpressionPath(
- arg, m_exe_ctx.GetBestExecutionContextScope(),
+ arg.c_str(), m_exe_ctx.GetBestExecutionContextScope(),
GetVariableCallback, target, variable_list, valobj_list));
matches = variable_list.GetSize();
}
if (matches == 0) {
result.GetErrorStream().Printf(
- "error: can't find global variable '%s'\n", arg);
+ "error: can't find global variable '%s'\n", arg.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
} else {
@@ -888,7 +898,7 @@ protected:
if (valobj_sp)
DumpValueObject(s, var_sp, valobj_sp,
use_var_name ? var_sp->GetName().GetCString()
- : arg);
+ : arg.c_str());
}
}
}
@@ -1163,12 +1173,9 @@ protected:
size_t argc = command.GetArgumentCount();
// check for at least 3 arguments and an odd number of parameters
if (argc >= 3 && argc & 1) {
- bool success = false;
-
- uint32_t insert_idx = StringConvert::ToUInt32(
- command.GetArgumentAtIndex(0), UINT32_MAX, 0, &success);
+ uint32_t insert_idx;
- if (!success) {
+ if (!llvm::to_integer(command.GetArgumentAtIndex(0), insert_idx)) {
result.AppendErrorWithFormat(
"<index> parameter is not an integer: '%s'.\n",
command.GetArgumentAtIndex(0));
@@ -1292,7 +1299,7 @@ static void DumpModuleArchitecture(Stream &strm, Module *module,
module->GetArchitecture().DumpTriple(arch_strm.AsRawOstream());
else
arch_strm.PutCString(module->GetArchitecture().GetArchitectureName());
- std::string arch_str = arch_strm.GetString();
+ std::string arch_str = std::string(arch_strm.GetString());
if (width)
strm.Printf("%-*s", width, arch_str.c_str());
@@ -1431,11 +1438,9 @@ static void DumpModuleSections(CommandInterpreter &interpreter, Stream &strm,
strm.Printf("Sections for '%s' (%s):\n",
module->GetSpecificationDescription().c_str(),
module->GetArchitecture().GetArchitectureName());
- strm.IndentMore();
- section_list->Dump(&strm,
+ section_list->Dump(strm.AsRawOstream(), strm.GetIndentLevel() + 2,
interpreter.GetExecutionContext().GetTargetPtr(), true,
UINT32_MAX);
- strm.IndentLess();
}
}
}
@@ -1599,8 +1604,9 @@ static size_t LookupFunctionInModule(CommandInterpreter &interpreter,
include_inlines, sc_list);
} else {
ConstString function_name(name);
- module->FindFunctions(function_name, nullptr, eFunctionNameTypeAuto,
- include_symbols, include_inlines, sc_list);
+ module->FindFunctions(function_name, CompilerDeclContext(),
+ eFunctionNameTypeAuto, include_symbols,
+ include_inlines, sc_list);
}
num_matches = sc_list.GetSize();
if (num_matches) {
@@ -2162,7 +2168,7 @@ protected:
}
};
-#pragma mark CommandObjectTargetModulesDumpSections
+#pragma mark CommandObjectTargetModulesDumpClangAST
// Clang AST dumping command
@@ -2736,10 +2742,8 @@ protected:
const char *load_addr_cstr = args.GetArgumentAtIndex(i + 1);
if (sect_name && load_addr_cstr) {
ConstString const_sect_name(sect_name);
- bool success = false;
- addr_t load_addr = StringConvert::ToUInt64(
- load_addr_cstr, LLDB_INVALID_ADDRESS, 0, &success);
- if (success) {
+ addr_t load_addr;
+ if (llvm::to_integer(load_addr_cstr, load_addr)) {
SectionSP section_sp(
section_list->FindSectionByName(const_sect_name));
if (section_sp) {
@@ -3022,17 +3026,14 @@ protected:
module_list_ptr = &target->GetImages();
}
} else {
- // TODO: Convert to entry based iteration. Requires converting
- // FindModulesByName.
- for (size_t i = 0; i < argc; ++i) {
+ for (const Args::ArgEntry &arg : command) {
// Dump specified images (by basename or fullpath)
- const char *arg_cstr = command.GetArgumentAtIndex(i);
const size_t num_matches = FindModulesByName(
- target, arg_cstr, module_list, use_global_module_list);
+ target, arg.c_str(), module_list, use_global_module_list);
if (num_matches == 0) {
if (argc == 1) {
result.AppendErrorWithFormat("no modules found that match '%s'",
- arg_cstr);
+ arg.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -3268,7 +3269,7 @@ public:
switch (short_option) {
case 'a': {
- m_str = option_arg;
+ m_str = std::string(option_arg);
m_type = eLookupTypeAddress;
m_addr = OptionArgParser::ToAddress(execution_context, option_arg,
LLDB_INVALID_ADDRESS, &error);
@@ -3279,7 +3280,7 @@ public:
}
case 'n':
- m_str = option_arg;
+ m_str = std::string(option_arg);
m_type = eLookupTypeFunctionOrSymbol;
break;
@@ -3603,7 +3604,7 @@ public:
break;
case 's':
- m_str = option_arg;
+ m_str = std::string(option_arg);
m_type = eLookupTypeSymbol;
break;
@@ -3626,17 +3627,17 @@ public:
break;
case 'F':
- m_str = option_arg;
+ m_str = std::string(option_arg);
m_type = eLookupTypeFunction;
break;
case 'n':
- m_str = option_arg;
+ m_str = std::string(option_arg);
m_type = eLookupTypeFunctionOrSymbol;
break;
case 't':
- m_str = option_arg;
+ m_str = std::string(option_arg);
m_type = eLookupTypeType;
break;
@@ -3990,7 +3991,9 @@ public:
private:
// For CommandObjectTargetModules only
- DISALLOW_COPY_AND_ASSIGN(CommandObjectTargetModules);
+ CommandObjectTargetModules(const CommandObjectTargetModules &) = delete;
+ const CommandObjectTargetModules &
+ operator=(const CommandObjectTargetModules &) = delete;
};
class CommandObjectTargetSymbolsAdd : public CommandObjectParsed {
@@ -3999,19 +4002,20 @@ public:
: CommandObjectParsed(
interpreter, "target symbols add",
"Add a debug symbol file to one of the target's current modules by "
- "specifying a path to a debug symbols file, or using the options "
- "to specify a module to download symbols for.",
+ "specifying a path to a debug symbols file or by using the options "
+ "to specify a module.",
"target symbols add <cmd-options> [<symfile>]",
eCommandRequiresTarget),
m_option_group(),
m_file_option(
LLDB_OPT_SET_1, false, "shlib", 's',
CommandCompletions::eModuleCompletion, eArgTypeShlibName,
- "Fullpath or basename for module to find debug symbols for."),
+ "Locate the debug symbols for the shared library specified by "
+ "name."),
m_current_frame_option(
LLDB_OPT_SET_2, false, "frame", 'F',
- "Locate the debug symbols the currently selected frame.", false,
- true)
+ "Locate the debug symbols for the currently selected frame.",
+ false, true)
{
m_option_group.Append(&m_uuid_option_group, LLDB_OPT_SET_ALL,
@@ -4053,12 +4057,10 @@ protected:
module_spec.GetFileSpec().GetFilename() = symbol_fspec.GetFilename();
}
- // We now have a module that represents a symbol file that can be used
- // for a module that might exist in the current target, so we need to
- // find that module in the target
- ModuleList matching_module_list;
+ // Now module_spec represents a symbol file for a module that might exist
+ // in the current target. Let's find possible matches.
+ ModuleList matching_modules;
- size_t num_matches = 0;
// First extract all module specs from the symbol file
lldb_private::ModuleSpecList symfile_module_specs;
if (ObjectFile::GetModuleSpecifications(module_spec.GetSymbolFileSpec(),
@@ -4069,34 +4071,30 @@ protected:
target_arch_module_spec.GetArchitecture() = target->GetArchitecture();
if (symfile_module_specs.FindMatchingModuleSpec(target_arch_module_spec,
symfile_module_spec)) {
- // See if it has a UUID?
if (symfile_module_spec.GetUUID().IsValid()) {
// It has a UUID, look for this UUID in the target modules
ModuleSpec symfile_uuid_module_spec;
symfile_uuid_module_spec.GetUUID() = symfile_module_spec.GetUUID();
target->GetImages().FindModules(symfile_uuid_module_spec,
- matching_module_list);
- num_matches = matching_module_list.GetSize();
+ matching_modules);
}
}
- if (num_matches == 0) {
- // No matches yet, iterate through the module specs to find a UUID
- // value that we can match up to an image in our target
- const size_t num_symfile_module_specs =
- symfile_module_specs.GetSize();
- for (size_t i = 0; i < num_symfile_module_specs && num_matches == 0;
- ++i) {
+ if (matching_modules.IsEmpty()) {
+ // No matches yet. Iterate through the module specs to find a UUID
+ // value that we can match up to an image in our target.
+ const size_t num_symfile_module_specs = symfile_module_specs.GetSize();
+ for (size_t i = 0;
+ i < num_symfile_module_specs && matching_modules.IsEmpty(); ++i) {
if (symfile_module_specs.GetModuleSpecAtIndex(
i, symfile_module_spec)) {
if (symfile_module_spec.GetUUID().IsValid()) {
- // It has a UUID, look for this UUID in the target modules
+ // It has a UUID. Look for this UUID in the target modules.
ModuleSpec symfile_uuid_module_spec;
symfile_uuid_module_spec.GetUUID() =
symfile_module_spec.GetUUID();
target->GetImages().FindModules(symfile_uuid_module_spec,
- matching_module_list);
- num_matches = matching_module_list.GetSize();
+ matching_modules);
}
}
}
@@ -4104,13 +4102,11 @@ protected:
}
// Just try to match up the file by basename if we have no matches at
- // this point
- if (num_matches == 0) {
- target->GetImages().FindModules(module_spec, matching_module_list);
- num_matches = matching_module_list.GetSize();
- }
+ // this point. For example, module foo might have symbols in foo.debug.
+ if (matching_modules.IsEmpty())
+ target->GetImages().FindModules(module_spec, matching_modules);
- while (num_matches == 0) {
+ while (matching_modules.IsEmpty()) {
ConstString filename_no_extension(
module_spec.GetFileSpec().GetFileNameStrippingExtension());
// Empty string returned, let's bail
@@ -4123,17 +4119,20 @@ protected:
// Replace basename with one fewer extension
module_spec.GetFileSpec().GetFilename() = filename_no_extension;
- target->GetImages().FindModules(module_spec, matching_module_list);
- num_matches = matching_module_list.GetSize();
+ target->GetImages().FindModules(module_spec, matching_modules);
}
- if (num_matches > 1) {
+ if (matching_modules.GetSize() > 1) {
result.AppendErrorWithFormat("multiple modules match symbol file '%s', "
"use the --uuid option to resolve the "
"ambiguity.\n",
symfile_path);
- } else if (num_matches == 1) {
- ModuleSP module_sp(matching_module_list.GetModuleAtIndex(0));
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ if (matching_modules.GetSize() == 1) {
+ ModuleSP module_sp(matching_modules.GetModuleAtIndex(0));
// The module has not yet created its symbol vendor, we can just give
// the existing target module the symfile path to use for when it
@@ -4144,7 +4143,6 @@ protected:
module_sp->GetSymbolFile(true, &result.GetErrorStream());
if (symbol_file) {
ObjectFile *object_file = symbol_file->GetObjectFile();
-
if (object_file && object_file->GetFileSpec() == symbol_fspec) {
// Provide feedback that the symfile has been successfully added.
const FileSpec &module_fs = module_sp->GetFileSpec();
@@ -4163,7 +4161,7 @@ protected:
Status error;
StreamString feedback_stream;
module_sp->LoadScriptingResourceInTarget(target, error,
- &feedback_stream);
+ &feedback_stream);
if (error.Fail() && error.AsCString())
result.AppendWarningWithFormat(
"unable to load scripting data for module %s - error "
@@ -4173,7 +4171,7 @@ protected:
.GetCString(),
error.AsCString());
else if (feedback_stream.GetSize())
- result.AppendWarningWithFormat("%s", feedback_stream.GetData());
+ result.AppendWarning(feedback_stream.GetData());
flush = true;
result.SetStatus(eReturnStatusSuccessFinishResult);
@@ -4184,7 +4182,6 @@ protected:
module_sp->SetSymbolFileFileSpec(FileSpec());
}
- namespace fs = llvm::sys::fs;
StreamString ss_symfile_uuid;
if (module_spec.GetUUID().IsValid()) {
ss_symfile_uuid << " (";
@@ -4194,7 +4191,7 @@ protected:
result.AppendErrorWithFormat(
"symbol file '%s'%s does not match any existing module%s\n",
symfile_path, ss_symfile_uuid.GetData(),
- !fs::is_regular_file(symbol_fspec.GetPath())
+ !llvm::sys::fs::is_regular_file(symbol_fspec.GetPath())
? "\n please specify the full path to the symbol file"
: "");
result.SetStatus(eReturnStatusFailed);
@@ -4394,7 +4391,9 @@ public:
private:
// For CommandObjectTargetModules only
- DISALLOW_COPY_AND_ASSIGN(CommandObjectTargetSymbols);
+ CommandObjectTargetSymbols(const CommandObjectTargetSymbols &) = delete;
+ const CommandObjectTargetSymbols &
+ operator=(const CommandObjectTargetSymbols &) = delete;
};
#pragma mark CommandObjectTargetStopHookAdd
@@ -4427,7 +4426,7 @@ public:
switch (short_option) {
case 'c':
- m_class_name = option_arg;
+ m_class_name = std::string(option_arg);
m_sym_ctx_specified = true;
break;
@@ -4464,18 +4463,18 @@ public:
break;
case 'n':
- m_function_name = option_arg;
+ m_function_name = std::string(option_arg);
m_func_name_type_mask |= eFunctionNameTypeAuto;
m_sym_ctx_specified = true;
break;
case 'f':
- m_file_name = option_arg;
+ m_file_name = std::string(option_arg);
m_sym_ctx_specified = true;
break;
case 's':
- m_module_name = option_arg;
+ m_module_name = std::string(option_arg);
m_sym_ctx_specified = true;
break;
@@ -4487,12 +4486,12 @@ public:
break;
case 'T':
- m_thread_name = option_arg;
+ m_thread_name = std::string(option_arg);
m_thread_specified = true;
break;
case 'q':
- m_queue_name = option_arg;
+ m_queue_name = std::string(option_arg);
m_thread_specified = true;
break;
@@ -4505,7 +4504,7 @@ public:
case 'o':
m_use_one_liner = true;
- m_one_liner.push_back(option_arg);
+ m_one_liner.push_back(std::string(option_arg));
break;
default:
@@ -4615,8 +4614,8 @@ protected:
// First step, make the specifier.
std::unique_ptr<SymbolContextSpecifier> specifier_up;
if (m_options.m_sym_ctx_specified) {
- specifier_up.reset(
- new SymbolContextSpecifier(GetDebugger().GetSelectedTarget()));
+ specifier_up = std::make_unique<SymbolContextSpecifier>(
+ GetDebugger().GetSelectedTarget());
if (!m_options.m_module_name.empty()) {
specifier_up->AddSpecification(
@@ -4725,18 +4724,15 @@ protected:
target.RemoveAllStopHooks();
}
} else {
- bool success;
for (size_t i = 0; i < num_args; i++) {
- lldb::user_id_t user_id = StringConvert::ToUInt32(
- command.GetArgumentAtIndex(i), 0, 0, &success);
- if (!success) {
+ lldb::user_id_t user_id;
+ if (!llvm::to_integer(command.GetArgumentAtIndex(i), user_id)) {
result.AppendErrorWithFormat("invalid stop hook id: \"%s\".\n",
command.GetArgumentAtIndex(i));
result.SetStatus(eReturnStatusFailed);
return false;
}
- success = target.RemoveStopHookByID(user_id);
- if (!success) {
+ if (!target.RemoveStopHookByID(user_id)) {
result.AppendErrorWithFormat("unknown stop hook id: \"%s\".\n",
command.GetArgumentAtIndex(i));
result.SetStatus(eReturnStatusFailed);
@@ -4774,9 +4770,8 @@ protected:
target.SetAllStopHooksActiveState(m_enable);
} else {
for (size_t i = 0; i < num_args; i++) {
- lldb::user_id_t user_id = StringConvert::ToUInt32(
- command.GetArgumentAtIndex(i), 0, 0, &success);
- if (!success) {
+ lldb::user_id_t user_id;
+ if (!llvm::to_integer(command.GetArgumentAtIndex(i), user_id)) {
result.AppendErrorWithFormat("invalid stop hook id: \"%s\".\n",
command.GetArgumentAtIndex(i));
result.SetStatus(eReturnStatusFailed);
@@ -4881,6 +4876,9 @@ CommandObjectMultiwordTarget::CommandObjectMultiwordTarget(
CommandObjectSP(new CommandObjectTargetList(interpreter)));
LoadSubCommand("select",
CommandObjectSP(new CommandObjectTargetSelect(interpreter)));
+ LoadSubCommand("show-launch-environment",
+ CommandObjectSP(new CommandObjectTargetShowLaunchEnvironment(
+ interpreter)));
LoadSubCommand(
"stop-hook",
CommandObjectSP(new CommandObjectMultiwordTargetStopHooks(interpreter)));
diff --git a/lldb/source/Commands/CommandObjectTarget.h b/lldb/source/Commands/CommandObjectTarget.h
index bf1dae6bfdc1..94afc00064c8 100644
--- a/lldb/source/Commands/CommandObjectTarget.h
+++ b/lldb/source/Commands/CommandObjectTarget.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectTarget_h_
-#define liblldb_CommandObjectTarget_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTTARGET_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTTARGET_H
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -24,4 +24,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_CommandObjectTarget_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTTARGET_H
diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index 83c7cb50d142..f0ad1798fec6 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectThread.cpp ---------------------------------*- C++ -*-===//
+//===-- CommandObjectThread.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,7 +10,6 @@
#include "lldb/Core/ValueObject.h"
#include "lldb/Host/OptionParser.h"
-#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
@@ -109,11 +108,8 @@ public:
process->GetThreadList().GetMutex());
for (size_t i = 0; i < num_args; i++) {
- bool success;
-
- uint32_t thread_idx = StringConvert::ToUInt32(
- command.GetArgumentAtIndex(i), 0, 0, &success);
- if (!success) {
+ uint32_t thread_idx;
+ if (!llvm::to_integer(command.GetArgumentAtIndex(i), thread_idx)) {
result.AppendErrorWithFormat("invalid thread specification: \"%s\"\n",
command.GetArgumentAtIndex(i));
result.SetStatus(eReturnStatusFailed);
@@ -464,12 +460,12 @@ public:
case 'r':
m_avoid_regexp.clear();
- m_avoid_regexp.assign(option_arg);
+ m_avoid_regexp.assign(std::string(option_arg));
break;
case 't':
m_step_in_target.clear();
- m_step_in_target.assign(option_arg);
+ m_step_in_target.assign(std::string(option_arg));
break;
default:
@@ -565,9 +561,9 @@ protected:
}
} else {
const char *thread_idx_cstr = command.GetArgumentAtIndex(0);
- uint32_t step_thread_idx =
- StringConvert::ToUInt32(thread_idx_cstr, LLDB_INVALID_INDEX32);
- if (step_thread_idx == LLDB_INVALID_INDEX32) {
+ uint32_t step_thread_idx;
+
+ if (!llvm::to_integer(thread_idx_cstr, step_thread_idx)) {
result.AppendErrorWithFormat("invalid thread index '%s'.\n",
thread_idx_cstr);
result.SetStatus(eReturnStatusFailed);
@@ -775,7 +771,6 @@ protected:
return result.Succeeded();
}
-protected:
StepType m_step_type;
StepScope m_step_scope;
ThreadStepScopeOptionGroup m_options;
@@ -1096,9 +1091,7 @@ protected:
size_t num_args = command.GetArgumentCount();
for (size_t i = 0; i < num_args; i++) {
uint32_t line_number;
- line_number = StringConvert::ToUInt32(command.GetArgumentAtIndex(i),
- UINT32_MAX);
- if (line_number == UINT32_MAX) {
+ if (!llvm::to_integer(command.GetArgumentAtIndex(i), line_number)) {
result.AppendErrorWithFormat("invalid line number: '%s'.\n",
command.GetArgumentAtIndex(i));
result.SetStatus(eReturnStatusFailed);
@@ -1322,8 +1315,13 @@ protected:
return false;
}
- uint32_t index_id =
- StringConvert::ToUInt32(command.GetArgumentAtIndex(0), 0, 0);
+ uint32_t index_id;
+ if (!llvm::to_integer(command.GetArgumentAtIndex(0), index_id)) {
+ result.AppendErrorWithFormat("Invalid thread index '%s'",
+ command.GetArgumentAtIndex(0));
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
Thread *new_thread =
process->GetThreadList().FindThreadByIndexID(index_id).get();
@@ -1833,25 +1831,36 @@ public:
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) override {
- Status error;
const int short_option = m_getopt_table[option_idx].val;
switch (short_option) {
case 'i':
m_internal = true;
break;
+ case 't':
+ lldb::tid_t tid;
+ if (option_arg.getAsInteger(0, tid))
+ return Status("invalid tid: '%s'.", option_arg.str().c_str());
+ m_tids.push_back(tid);
+ break;
+ case 'u':
+ m_unreported = false;
+ break;
case 'v':
m_verbose = true;
break;
default:
llvm_unreachable("Unimplemented option");
}
- return error;
+ return {};
}
void OptionParsingStarting(ExecutionContext *execution_context) override {
m_verbose = false;
m_internal = false;
+ m_unreported = true; // The variable is "skip unreported" and we want to
+ // skip unreported by default.
+ m_tids.clear();
}
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
@@ -1861,6 +1870,8 @@ public:
// Instance variables to hold the values for command options.
bool m_verbose;
bool m_internal;
+ bool m_unreported;
+ std::vector<lldb::tid_t> m_tids;
};
CommandObjectThreadPlanList(CommandInterpreter &interpreter)
@@ -1879,25 +1890,59 @@ public:
Options *GetOptions() override { return &m_options; }
+ bool DoExecute(Args &command, CommandReturnObject &result) override {
+ // If we are reporting all threads, dispatch to the Process to do that:
+ if (command.GetArgumentCount() == 0 && m_options.m_tids.empty()) {
+ Stream &strm = result.GetOutputStream();
+ DescriptionLevel desc_level = m_options.m_verbose
+ ? eDescriptionLevelVerbose
+ : eDescriptionLevelFull;
+ m_exe_ctx.GetProcessPtr()->DumpThreadPlans(
+ strm, desc_level, m_options.m_internal, true, m_options.m_unreported);
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ return true;
+ } else {
+ // Do any TID's that the user may have specified as TID, then do any
+ // Thread Indexes...
+ if (!m_options.m_tids.empty()) {
+ Process *process = m_exe_ctx.GetProcessPtr();
+ StreamString tmp_strm;
+ for (lldb::tid_t tid : m_options.m_tids) {
+ bool success = process->DumpThreadPlansForTID(
+ tmp_strm, tid, eDescriptionLevelFull, m_options.m_internal,
+ true /* condense_trivial */, m_options.m_unreported);
+ // If we didn't find a TID, stop here and return an error.
+ if (!success) {
+ result.SetError("Error dumping plans:");
+ result.AppendError(tmp_strm.GetString());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ // Otherwise, add our data to the output:
+ result.GetOutputStream() << tmp_strm.GetString();
+ }
+ }
+ return CommandObjectIterateOverThreads::DoExecute(command, result);
+ }
+ }
+
protected:
bool HandleOneThread(lldb::tid_t tid, CommandReturnObject &result) override {
- ThreadSP thread_sp =
- m_exe_ctx.GetProcessPtr()->GetThreadList().FindThreadByID(tid);
- if (!thread_sp) {
- result.AppendErrorWithFormat("thread no longer exists: 0x%" PRIx64 "\n",
- tid);
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
+ // If we have already handled this from a -t option, skip it here.
+ if (std::find(m_options.m_tids.begin(), m_options.m_tids.end(), tid) !=
+ m_options.m_tids.end())
+ return true;
- Thread *thread = thread_sp.get();
+ Process *process = m_exe_ctx.GetProcessPtr();
Stream &strm = result.GetOutputStream();
DescriptionLevel desc_level = eDescriptionLevelFull;
if (m_options.m_verbose)
desc_level = eDescriptionLevelVerbose;
- thread->DumpThreadPlans(&strm, desc_level, m_options.m_internal, true);
+ process->DumpThreadPlansForTID(strm, tid, desc_level, m_options.m_internal,
+ true /* condense_trivial */,
+ m_options.m_unreported);
return true;
}
@@ -1943,10 +1988,8 @@ public:
return false;
}
- bool success;
- uint32_t thread_plan_idx =
- StringConvert::ToUInt32(args.GetArgumentAtIndex(0), 0, 0, &success);
- if (!success) {
+ uint32_t thread_plan_idx;
+ if (!llvm::to_integer(args.GetArgumentAtIndex(0), thread_plan_idx)) {
result.AppendErrorWithFormat(
"Invalid thread index: \"%s\" - should be unsigned int.",
args.GetArgumentAtIndex(0));
@@ -1974,6 +2017,71 @@ public:
}
};
+class CommandObjectThreadPlanPrune : public CommandObjectParsed {
+public:
+ CommandObjectThreadPlanPrune(CommandInterpreter &interpreter)
+ : CommandObjectParsed(interpreter, "thread plan prune",
+ "Removes any thread plans associated with "
+ "currently unreported threads. "
+ "Specify one or more TID's to remove, or if no "
+ "TID's are provides, remove threads for all "
+ "unreported threads",
+ nullptr,
+ eCommandRequiresProcess |
+ eCommandTryTargetAPILock |
+ eCommandProcessMustBeLaunched |
+ eCommandProcessMustBePaused) {
+ CommandArgumentEntry arg;
+ CommandArgumentData tid_arg;
+
+ // Define the first (and only) variant of this arg.
+ tid_arg.arg_type = eArgTypeThreadID;
+ tid_arg.arg_repetition = eArgRepeatStar;
+
+ // There is only one variant this argument could be; put it into the
+ // argument entry.
+ arg.push_back(tid_arg);
+
+ // Push the data for the first argument into the m_arguments vector.
+ m_arguments.push_back(arg);
+ }
+
+ ~CommandObjectThreadPlanPrune() override = default;
+
+ bool DoExecute(Args &args, CommandReturnObject &result) override {
+ Process *process = m_exe_ctx.GetProcessPtr();
+
+ if (args.GetArgumentCount() == 0) {
+ process->PruneThreadPlans();
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ return true;
+ }
+
+ const size_t num_args = args.GetArgumentCount();
+
+ std::lock_guard<std::recursive_mutex> guard(
+ process->GetThreadList().GetMutex());
+
+ for (size_t i = 0; i < num_args; i++) {
+ lldb::tid_t tid;
+ if (!llvm::to_integer(args.GetArgumentAtIndex(i), tid)) {
+ result.AppendErrorWithFormat("invalid thread specification: \"%s\"\n",
+ args.GetArgumentAtIndex(i));
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ if (!process->PruneThreadPlansForTID(tid)) {
+ result.AppendErrorWithFormat("Could not find unreported tid: \"%s\"\n",
+ args.GetArgumentAtIndex(i));
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ }
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ return true;
+ }
+};
+
// CommandObjectMultiwordThreadPlan
class CommandObjectMultiwordThreadPlan : public CommandObjectMultiword {
@@ -1988,6 +2096,9 @@ public:
LoadSubCommand(
"discard",
CommandObjectSP(new CommandObjectThreadPlanDiscard(interpreter)));
+ LoadSubCommand(
+ "prune",
+ CommandObjectSP(new CommandObjectThreadPlanPrune(interpreter)));
}
~CommandObjectMultiwordThreadPlan() override = default;
diff --git a/lldb/source/Commands/CommandObjectThread.h b/lldb/source/Commands/CommandObjectThread.h
index 77729ceecd63..3ca6a2159501 100644
--- a/lldb/source/Commands/CommandObjectThread.h
+++ b/lldb/source/Commands/CommandObjectThread.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectThread_h_
-#define liblldb_CommandObjectThread_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTTHREAD_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTTHREAD_H
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -22,4 +22,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_CommandObjectThread_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTTHREAD_H
diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp
index 87c107cfb943..b2020f26621f 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectType.cpp -----------------------------------*- C++ -*-===//
+//===-- CommandObjectType.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -531,7 +531,7 @@ private:
m_skip_pointers = true;
break;
case 'w':
- m_category.assign(option_value);
+ m_category.assign(std::string(option_value));
break;
case 'r':
m_skip_references = true;
@@ -540,7 +540,7 @@ private:
m_regex = true;
break;
case 't':
- m_custom_type_name.assign(option_value);
+ m_custom_type_name.assign(std::string(option_value));
break;
default:
llvm_unreachable("Unimplemented option");
@@ -1031,8 +1031,8 @@ protected:
std::unique_ptr<RegularExpression> formatter_regex;
if (m_options.m_category_regex.OptionWasSet()) {
- category_regex.reset(new RegularExpression(
- m_options.m_category_regex.GetCurrentValueAsRef()));
+ category_regex = std::make_unique<RegularExpression>(
+ m_options.m_category_regex.GetCurrentValueAsRef());
if (!category_regex->IsValid()) {
result.AppendErrorWithFormat(
"syntax error in category regular expression '%s'",
@@ -1044,8 +1044,8 @@ protected:
if (argc == 1) {
const char *arg = command.GetArgumentAtIndex(0);
- formatter_regex.reset(
- new RegularExpression(llvm::StringRef::withNullAsEmpty(arg)));
+ formatter_regex = std::make_unique<RegularExpression>(
+ llvm::StringRef::withNullAsEmpty(arg));
if (!formatter_regex->IsValid()) {
result.AppendErrorWithFormat("syntax error in regular expression '%s'",
arg);
@@ -1206,11 +1206,11 @@ Status CommandObjectTypeSummaryAdd::CommandOptions::SetOptionValue(
m_name.SetString(option_arg);
break;
case 'o':
- m_python_script = option_arg;
+ m_python_script = std::string(option_arg);
m_is_add_script = true;
break;
case 'F':
- m_python_function = option_arg;
+ m_python_function = std::string(option_arg);
m_is_add_script = true;
break;
case 'P':
@@ -1326,7 +1326,7 @@ bool CommandObjectTypeSummaryAdd::Execute_ScriptSummary(
return false;
}
- options->m_target_types << entry.ref();
+ options->m_target_types << std::string(entry.ref());
}
m_interpreter.GetPythonCommandsFromIOHandler(
@@ -2092,7 +2092,8 @@ protected:
if (argc == 1) {
const char *arg = command.GetArgumentAtIndex(0);
- regex.reset(new RegularExpression(llvm::StringRef::withNullAsEmpty(arg)));
+ regex = std::make_unique<RegularExpression>(
+ llvm::StringRef::withNullAsEmpty(arg));
if (!regex->IsValid()) {
result.AppendErrorWithFormat(
"syntax error in category regular expression '%s'", arg);
@@ -2225,7 +2226,7 @@ bool CommandObjectTypeSynthAdd::Execute_HandwritePython(
return false;
}
- options->m_target_types << entry.ref();
+ options->m_target_types << std::string(entry.ref());
}
m_interpreter.GetPythonCommandsFromIOHandler(
@@ -2390,7 +2391,7 @@ private:
option_arg.str().c_str());
break;
case 'c':
- m_expr_paths.push_back(option_arg);
+ m_expr_paths.push_back(std::string(option_arg));
has_child_list = true;
break;
case 'p':
@@ -2705,7 +2706,7 @@ public:
return true;
});
- m_cmd_help_long = stream.GetString();
+ m_cmd_help_long = std::string(stream.GetString());
return m_cmd_help_long;
}
diff --git a/lldb/source/Commands/CommandObjectType.h b/lldb/source/Commands/CommandObjectType.h
index 938e481a6b87..1c081abe2be4 100644
--- a/lldb/source/Commands/CommandObjectType.h
+++ b/lldb/source/Commands/CommandObjectType.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectType_h_
-#define liblldb_CommandObjectType_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTTYPE_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTTYPE_H
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -22,4 +22,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_CommandObjectType_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTTYPE_H
diff --git a/lldb/source/Commands/CommandObjectVersion.cpp b/lldb/source/Commands/CommandObjectVersion.cpp
index 227d5d132d96..065cbe4660d3 100644
--- a/lldb/source/Commands/CommandObjectVersion.cpp
+++ b/lldb/source/Commands/CommandObjectVersion.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectVersion.cpp --------------------------------*- C++ -*-===//
+//===-- CommandObjectVersion.cpp ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Commands/CommandObjectVersion.h b/lldb/source/Commands/CommandObjectVersion.h
index 30f44aeb1658..dce1a8d67b88 100644
--- a/lldb/source/Commands/CommandObjectVersion.h
+++ b/lldb/source/Commands/CommandObjectVersion.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectVersion_h_
-#define liblldb_CommandObjectVersion_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTVERSION_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTVERSION_H
#include "lldb/Interpreter/CommandObject.h"
@@ -27,4 +27,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_CommandObjectVersion_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTVERSION_H
diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp
index c965d354f734..ce4662930a7c 100644
--- a/lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectWatchpoint.cpp -----------------------------*- C++ -*-===//
+//===-- CommandObjectWatchpoint.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -41,7 +41,7 @@ static bool CheckTargetForWatchpointOperations(Target *target,
bool process_is_valid =
target->GetProcessSP() && target->GetProcessSP()->IsAlive();
if (!process_is_valid) {
- result.AppendError("Thre's no process or it is not alive.");
+ result.AppendError("There's no process or it is not alive.");
result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -692,7 +692,7 @@ public:
switch (short_option) {
case 'c':
- m_condition = option_arg;
+ m_condition = std::string(option_arg);
m_condition_passed = true;
break;
default:
@@ -934,7 +934,7 @@ protected:
StreamString ss;
// True to show fullpath for declaration file.
var_sp->GetDeclaration().DumpStopContext(&ss, true);
- wp->SetDeclInfo(ss.GetString());
+ wp->SetDeclInfo(std::string(ss.GetString()));
}
output_stream.Printf("Watchpoint created: ");
wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
@@ -1038,7 +1038,7 @@ protected:
// set a watchpoint.
if (raw_command.trim().empty()) {
result.GetErrorStream().Printf("error: required argument missing; "
- "specify an expression to evaulate into "
+ "specify an expression to evaluate into "
"the address to watch for\n");
result.SetStatus(eReturnStatusFailed);
return false;
@@ -1070,6 +1070,8 @@ protected:
result.GetErrorStream().Printf(
"error: expression evaluation of address to watch failed\n");
result.GetErrorStream() << "expression evaluated: \n" << expr << "\n";
+ if (valobj_sp && !valobj_sp->GetError().Success())
+ result.GetErrorStream() << valobj_sp->GetError().AsCString() << "\n";
result.SetStatus(eReturnStatusFailed);
return false;
}
diff --git a/lldb/source/Commands/CommandObjectWatchpoint.h b/lldb/source/Commands/CommandObjectWatchpoint.h
index 4f4f80bbd620..87f9f4383bd2 100644
--- a/lldb/source/Commands/CommandObjectWatchpoint.h
+++ b/lldb/source/Commands/CommandObjectWatchpoint.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectWatchpoint_h_
-#define liblldb_CommandObjectWatchpoint_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTWATCHPOINT_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTWATCHPOINT_H
#include "lldb/Interpreter/CommandObjectMultiword.h"
#include "lldb/Interpreter/OptionGroupWatchpoint.h"
@@ -28,4 +28,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_CommandObjectWatchpoint_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTWATCHPOINT_H
diff --git a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
index 1b83e885d27e..fe3052a775a2 100644
--- a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectWatchpointCommand.cpp ----------------------*- C++ -*-===//
+//===-- CommandObjectWatchpointCommand.cpp --------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -39,7 +39,7 @@ static constexpr OptionEnumValueElement g_script_option_enumeration[] = {
{
eScriptLanguageLua,
"lua",
- "Commands are in the Python language.",
+ "Commands are in the Lua language.",
},
{
eSortOrderByName,
@@ -282,12 +282,12 @@ are no syntax errors may indicate that a function was declared but never called.
ExecutionContext exe_ctx(context->exe_ctx_ref);
Target *target = exe_ctx.GetTargetPtr();
if (target) {
- CommandReturnObject result;
Debugger &debugger = target->GetDebugger();
+ CommandReturnObject result(debugger.GetUseColor());
+
// Rig up the results secondary output stream to the debugger's, so the
// output will come out synchronously if the debugger is set up that
// way.
-
StreamSP output_stream(debugger.GetAsyncOutputStream());
StreamSP error_stream(debugger.GetAsyncErrorStream());
result.SetImmediateOutputStream(output_stream);
@@ -327,7 +327,7 @@ are no syntax errors may indicate that a function was declared but never called.
switch (short_option) {
case 'o':
m_use_one_liner = true;
- m_one_liner = option_arg;
+ m_one_liner = std::string(option_arg);
break;
case 's':
@@ -359,7 +359,7 @@ are no syntax errors may indicate that a function was declared but never called.
case 'F':
m_use_one_liner = false;
- m_function_name.assign(option_arg);
+ m_function_name.assign(std::string(option_arg));
break;
default:
diff --git a/lldb/source/Commands/CommandObjectWatchpointCommand.h b/lldb/source/Commands/CommandObjectWatchpointCommand.h
index 6fbc9c741617..b3cb70d08985 100644
--- a/lldb/source/Commands/CommandObjectWatchpointCommand.h
+++ b/lldb/source/Commands/CommandObjectWatchpointCommand.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectWatchpointCommand_h_
-#define liblldb_CommandObjectWatchpointCommand_h_
+#ifndef LLDB_SOURCE_COMMANDS_COMMANDOBJECTWATCHPOINTCOMMAND_H
+#define LLDB_SOURCE_COMMANDS_COMMANDOBJECTWATCHPOINTCOMMAND_H
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -24,4 +24,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_CommandObjectWatchpointCommand_h_
+#endif // LLDB_SOURCE_COMMANDS_COMMANDOBJECTWATCHPOINTCOMMAND_H
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 850df133a429..d6f1e0a3c96d 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -39,6 +39,11 @@ let Command = "settings read" in {
Desc<"The file from which to read the settings.">;
}
+let Command = "settings clear" in {
+ def setclear_all : Option<"all", "a">,
+ Desc<"Clear all settings.">;
+}
+
let Command = "breakpoint list" in {
// FIXME: We need to add an "internal" command, and then add this sort of
// thing to it. But I need to see it for now, and don't want to wait.
@@ -115,6 +120,8 @@ let Command = "breakpoint set" in {
def breakpoint_set_line : Option<"line", "l">, Group<1>, Arg<"LineNum">,
Required,
Desc<"Specifies the line number on which to set this breakpoint.">;
+ def breakpoint_set_column : Option<"column", "u">, Group<1>, Arg<"ColumnNum">,
+ Desc<"Specifies the column number on which to set this breakpoint.">;
def breakpoint_set_address : Option<"address", "a">, Group<2>,
Arg<"AddressOrExpression">, Required,
Desc<"Set the breakpoint at the specified address. If the address maps "
@@ -150,7 +157,7 @@ let Command = "breakpoint set" in {
"multiple times tomake one breakpoint for multiple methods.">;
def breakpoint_set_func_regex : Option<"func-regex", "r">, Group<7>,
Arg<"RegularExpression">, Required, Desc<"Set the breakpoint by function "
- "name, evaluating a regular-expression to findthe function name(s).">;
+ "name, evaluating a regular-expression to find the function name(s).">;
def breakpoint_set_basename : Option<"basename", "b">, Group<8>,
Arg<"FunctionName">, Required, Completion<"Symbol">,
Desc<"Set the breakpoint by function basename (C++ namespaces and arguments"
@@ -304,7 +311,7 @@ let Command = "disassemble" in {
Desc<"Address at which to start disassembling.">;
def disassemble_options_end_address : Option<"end-address", "e">, Group<1>,
Arg<"AddressOrExpression">, Desc<"Address at which to end disassembling.">;
- def disassemble_options_count : Option<"count", "c">, Groups<[2,3,4,5]>,
+ def disassemble_options_count : Option<"count", "c">, Groups<[2,3,4,5,7]>,
Arg<"NumLines">, Desc<"Number of instructions to display.">;
def disassemble_options_name : Option<"name", "n">, Group<3>,
Arg<"FunctionName">, Completion<"Symbol">,
@@ -319,6 +326,8 @@ let Command = "disassemble" in {
def disassemble_options_address : Option<"address", "a">, Group<7>,
Arg<"AddressOrExpression">,
Desc<"Disassemble function containing this address.">;
+ def disassemble_options_force : Option<"force", "\\x01">, Groups<[2,3,4,5,7]>,
+ Desc<"Force dissasembly of large functions.">;
}
let Command = "expression" in {
@@ -382,7 +391,8 @@ let Command = "frame recognizer add" in {
"to.">;
def frame_recognizer_function : Option<"function", "n">, Arg<"Name">,
Completion<"Symbol">,
- Desc<"Name of the function that this recognizer applies to.">;
+ Desc<"Name of the function that this recognizer applies to. "
+ "Can be specified more than once except if -x|--regex is provided.">;
def frame_recognizer_python_class : Option<"python-class", "l">, Group<2>,
Arg<"PythonClass">,
Desc<"Give the name of a Python class to use for this frame recognizer.">;
@@ -614,6 +624,8 @@ let Command = "platform process attach" in {
}
let Command = "platform shell" in {
+ def platform_shell_host : Option<"host", "h">,
+ Desc<"Run the commands on the host shell when enabled.">;
def platform_shell_timeout : Option<"timeout", "t">, Arg<"Value">,
Desc<"Seconds to wait for the remote host to finish running the command.">;
}
@@ -668,6 +680,11 @@ let Command = "process handle" in {
Desc<"Whether or not the signal should be passed to the process.">;
}
+let Command = "process status" in {
+ def process_status_verbose : Option<"verbose", "v">, Group<1>,
+ Desc<"Show verbose process status including extended crash information.">;
+}
+
let Command = "script import" in {
def script_import_allow_reload : Option<"allow-reload", "r">, Group<1>,
Desc<"Allow the script to be loaded even if it was already loaded before. "
@@ -688,6 +705,7 @@ let Command = "script add" in {
Desc<"Set the synchronicity of this command's executions with regard to "
"LLDB event system.">;
}
+
let Command = "source info" in {
def source_info_count : Option<"count", "c">, Arg<"Count">,
Desc<"The number of line entries to display.">;
@@ -956,6 +974,11 @@ let Command = "thread plan list" in {
Desc<"Display more information about the thread plans">;
def thread_plan_list_internal : Option<"internal", "i">, Group<1>,
Desc<"Display internal as well as user thread plans">;
+ def thread_plan_list_thread_id : Option<"thread-id", "t">, Group<1>,
+ Arg<"ThreadID">, Desc<"List the thread plans for this TID, can be "
+ "specified more than once.">;
+ def thread_plan_list_unreported : Option<"unreported", "u">, Group<1>,
+ Desc<"Display thread plans for unreported threads">;
}
let Command = "type summary add" in {
diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp
index b9a7b4a3894a..9d52f1db8918 100644
--- a/lldb/source/Core/Address.cpp
+++ b/lldb/source/Core/Address.cpp
@@ -1,4 +1,4 @@
-//===-- Address.cpp ---------------------------------------------*- C++ -*-===//
+//===-- Address.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -415,7 +415,7 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
case DumpStyleSectionNameOffset:
if (section_sp) {
- section_sp->DumpName(s);
+ section_sp->DumpName(s->AsRawOstream());
s->Printf(" + %" PRIu64, m_offset);
} else {
DumpAddress(s->AsRawOstream(), m_offset, addr_size);
diff --git a/lldb/source/Core/AddressRange.cpp b/lldb/source/Core/AddressRange.cpp
index 83a1e54157d8..0868ac5e0888 100644
--- a/lldb/source/Core/AddressRange.cpp
+++ b/lldb/source/Core/AddressRange.cpp
@@ -1,4 +1,4 @@
-//===-- AddressRange.cpp ----------------------------------------*- C++ -*-===//
+//===-- AddressRange.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Core/AddressResolver.cpp b/lldb/source/Core/AddressResolver.cpp
index 974d99b62065..16b849b721de 100644
--- a/lldb/source/Core/AddressResolver.cpp
+++ b/lldb/source/Core/AddressResolver.cpp
@@ -1,4 +1,4 @@
-//===-- AddressResolver.cpp -------------------------------------*- C++ -*-===//
+//===-- AddressResolver.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Core/AddressResolverFileLine.cpp b/lldb/source/Core/AddressResolverFileLine.cpp
index 4122b5d3b747..b0d8dcdde2de 100644
--- a/lldb/source/Core/AddressResolverFileLine.cpp
+++ b/lldb/source/Core/AddressResolverFileLine.cpp
@@ -1,4 +1,4 @@
-//===-- AddressResolverFileLine.cpp -----------------------------*- C++ -*-===//
+//===-- AddressResolverFileLine.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Core/AddressResolverName.cpp b/lldb/source/Core/AddressResolverName.cpp
index 6b9b7b2de723..51ab6435e8fb 100644
--- a/lldb/source/Core/AddressResolverName.cpp
+++ b/lldb/source/Core/AddressResolverName.cpp
@@ -1,4 +1,4 @@
-//===-- AddressResolverName.cpp ---------------------------------*- C++ -*-===//
+//===-- AddressResolverName.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -91,7 +91,7 @@ AddressResolverName::SearchCallback(SearchFilter &filter,
if (context.module_sp) {
context.module_sp->FindSymbolsWithNameAndType(m_func_name,
eSymbolTypeCode, sym_list);
- context.module_sp->FindFunctions(m_func_name, nullptr,
+ context.module_sp->FindFunctions(m_func_name, CompilerDeclContext(),
eFunctionNameTypeAuto, include_symbols,
include_inlines, func_list);
}
diff --git a/lldb/source/Core/Communication.cpp b/lldb/source/Core/Communication.cpp
index 0afd897a2093..b358e70b1a91 100644
--- a/lldb/source/Core/Communication.cpp
+++ b/lldb/source/Core/Communication.cpp
@@ -1,4 +1,4 @@
-//===-- Communication.cpp ---------------------------------------*- C++ -*-===//
+//===-- Communication.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -71,8 +71,8 @@ Communication::~Communication() {
void Communication::Clear() {
SetReadThreadBytesReceivedCallback(nullptr, nullptr);
- Disconnect(nullptr);
StopReadThread(nullptr);
+ Disconnect(nullptr);
}
ConnectionStatus Communication::Connect(const char *url, Status *error_ptr) {
@@ -93,6 +93,8 @@ ConnectionStatus Communication::Disconnect(Status *error_ptr) {
LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMUNICATION),
"{0} Communication::Disconnect ()", this);
+ assert((!m_read_thread_enabled || m_read_thread_did_exit) &&
+ "Disconnecting while the read thread is running is racy!");
lldb::ConnectionSP connection_sp(m_connection_sp);
if (connection_sp) {
ConnectionStatus status = connection_sp->Disconnect(error_ptr);
@@ -315,16 +317,12 @@ lldb::thread_result_t Communication::ReadThread(lldb::thread_arg_t p) {
Status error;
ConnectionStatus status = eConnectionStatusSuccess;
bool done = false;
+ bool disconnect = false;
while (!done && comm->m_read_thread_enabled) {
size_t bytes_read = comm->ReadFromConnection(
buf, sizeof(buf), std::chrono::seconds(5), status, &error);
- if (bytes_read > 0)
+ if (bytes_read > 0 || status == eConnectionStatusEndOfFile)
comm->AppendBytesToCache(buf, bytes_read, true, status);
- else if ((bytes_read == 0) && status == eConnectionStatusEndOfFile) {
- if (comm->GetCloseOnEOF())
- comm->Disconnect();
- comm->AppendBytesToCache(buf, bytes_read, true, status);
- }
switch (status) {
case eConnectionStatusSuccess:
@@ -332,11 +330,12 @@ lldb::thread_result_t Communication::ReadThread(lldb::thread_arg_t p) {
case eConnectionStatusEndOfFile:
done = true;
+ disconnect = comm->GetCloseOnEOF();
break;
case eConnectionStatusError: // Check GetError() for details
if (error.GetType() == eErrorTypePOSIX && error.GetError() == EIO) {
// EIO on a pipe is usually caused by remote shutdown
- comm->Disconnect();
+ disconnect = comm->GetCloseOnEOF();
done = true;
}
if (error.Fail())
@@ -365,9 +364,22 @@ lldb::thread_result_t Communication::ReadThread(lldb::thread_arg_t p) {
if (log)
LLDB_LOGF(log, "%p Communication::ReadThread () thread exiting...", p);
- comm->m_read_thread_did_exit = true;
+ // Handle threads wishing to synchronize with us.
+ {
+ // Prevent new ones from showing up.
+ comm->m_read_thread_did_exit = true;
+
+ // Unblock any existing thread waiting for the synchronization signal.
+ comm->BroadcastEvent(eBroadcastBitNoMorePendingInput);
+
+ // Wait for the thread to finish...
+ std::lock_guard<std::mutex> guard(comm->m_synchronize_mutex);
+ // ... and disconnect.
+ if (disconnect)
+ comm->Disconnect();
+ }
+
// Let clients know that this thread is exiting
- comm->BroadcastEvent(eBroadcastBitNoMorePendingInput);
comm->BroadcastEvent(eBroadcastBitReadThreadDidExit);
return {};
}
@@ -399,10 +411,10 @@ void Communication::SynchronizeWithReadThread() {
listener_sp->GetEvent(event_sp, llvm::None);
}
-void Communication::SetConnection(Connection *connection) {
+void Communication::SetConnection(std::unique_ptr<Connection> connection) {
Disconnect(nullptr);
StopReadThread(nullptr);
- m_connection_sp.reset(connection);
+ m_connection_sp = std::move(connection);
}
const char *
diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td
index 014927c65c6f..b04738175f34 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -9,6 +9,10 @@ let Definition = "modulelist" in {
Global,
DefaultStringValue<"">,
Desc<"The path to the clang modules cache directory (-fmodules-cache-path).">;
+ def SymLinkPaths: Property<"debug-info-symlink-paths", "FileSpecList">,
+ Global,
+ DefaultStringValue<"">,
+ Desc<"Debug info path which should be resolved while parsing, relative to the host filesystem.">;
}
let Definition = "debugger" in {
@@ -18,7 +22,7 @@ let Definition = "debugger" in {
Desc<"If true all confirmation prompts will receive their default reply.">;
def DisassemblyFormat: Property<"disassembly-format", "FormatEntity">,
Global,
- DefaultStringValue<"{${function.initial-function}{${module.file.basename}`}{${function.name-without-args}}:\\\\n}{${function.changed}\\\\n{${module.file.basename}`}{${function.name-without-args}}:\\\\n}{${current-pc-arrow} }${addr-file-or-load}{ <${function.concrete-only-addr-offset-no-padding}>}: ">,
+ DefaultStringValue<"{${function.initial-function}{${module.file.basename}`}{${function.name-without-args}}:\\\\n}{${function.changed}\\\\n{${module.file.basename}`}{${function.name-without-args}}:\\\\n}{${ansi.fg.yellow}${current-pc-arrow}${ansi.normal} }${addr-file-or-load}{ <${function.concrete-only-addr-offset-no-padding}>}: ">,
Desc<"The default disassembly format string to use when disassembling instruction sequences.">;
def FrameFormat: Property<"frame-format", "FormatEntity">,
Global,
@@ -71,6 +75,14 @@ let Definition = "debugger" in {
Global,
DefaultStringValue<"${ansi.normal}">,
Desc<"When displaying the column marker in a color-enabled (i.e. ANSI) terminal, use the ANSI terminal code specified in this format immediately after the column to be marked.">;
+ def StopShowLineMarkerAnsiPrefix: Property<"stop-show-line-ansi-prefix", "String">,
+ Global,
+ DefaultStringValue<"${ansi.fg.yellow}">,
+ Desc<"When displaying the line marker in a color-enabled (i.e. ANSI) terminal, use the ANSI terminal code specified in this format at the immediately before the line to be marked.">;
+ def StopShowLineMarkerAnsiSuffix: Property<"stop-show-line-ansi-suffix", "String">,
+ Global,
+ DefaultStringValue<"${ansi.normal}">,
+ Desc<"When displaying the line marker in a color-enabled (i.e. ANSI) terminal, use the ANSI terminal code specified in this format immediately after the line to be marked.">;
def TerminalWidth: Property<"term-width", "SInt64">,
Global,
DefaultUnsignedValue<80>,
@@ -91,6 +103,10 @@ let Definition = "debugger" in {
Global,
DefaultTrue,
Desc<"Whether to use Ansi color codes or not.">;
+ def UseSourceCache: Property<"use-source-cache", "Boolean">,
+ Global,
+ DefaultTrue,
+ Desc<"Whether to cache source files in memory or not.">;
def AutoOneLineSummaries: Property<"auto-one-line-summaries", "Boolean">,
Global,
DefaultTrue,
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 33f72a0896cb..5f4f1e266d81 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -1,4 +1,4 @@
-//===-- Debugger.cpp --------------------------------------------*- C++ -*-===//
+//===-- Debugger.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -135,84 +135,6 @@ static constexpr OptionEnumValueElement g_language_enumerators[] = {
},
};
-#define MODULE_WITH_FUNC \
- "{ " \
- "${module.file.basename}{`${function.name-with-args}" \
- "{${frame.no-debug}${function.pc-offset}}}}"
-
-#define MODULE_WITH_FUNC_NO_ARGS \
- "{ " \
- "${module.file.basename}{`${function.name-without-args}" \
- "{${frame.no-debug}${function.pc-offset}}}}"
-
-#define FILE_AND_LINE \
- "{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}" \
- ":${ansi.fg.yellow}${line.number}${ansi.normal}" \
- "{:${ansi.fg.yellow}${line.column}${ansi.normal}}}"
-
-#define IS_OPTIMIZED "{${function.is-optimized} [opt]}"
-
-#define IS_ARTIFICIAL "{${frame.is-artificial} [artificial]}"
-
-#define DEFAULT_THREAD_FORMAT \
- "thread #${thread.index}: tid = ${thread.id%tid}" \
- "{, ${frame.pc}}" MODULE_WITH_FUNC FILE_AND_LINE \
- "{, name = ${ansi.fg.green}'${thread.name}'${ansi.normal}}" \
- "{, queue = ${ansi.fg.green}'${thread.queue}'${ansi.normal}}" \
- "{, activity = " \
- "${ansi.fg.green}'${thread.info.activity.name}'${ansi.normal}}" \
- "{, ${thread.info.trace_messages} messages}" \
- "{, stop reason = ${ansi.fg.red}${thread.stop-reason}${ansi.normal}}" \
- "{\\nReturn value: ${thread.return-value}}" \
- "{\\nCompleted expression: ${thread.completed-expression}}" \
- "\\n"
-
-#define DEFAULT_THREAD_STOP_FORMAT \
- "thread #${thread.index}{, name = '${thread.name}'}" \
- "{, queue = ${ansi.fg.green}'${thread.queue}'${ansi.normal}}" \
- "{, activity = " \
- "${ansi.fg.green}'${thread.info.activity.name}'${ansi.normal}}" \
- "{, ${thread.info.trace_messages} messages}" \
- "{, stop reason = ${ansi.fg.red}${thread.stop-reason}${ansi.normal}}" \
- "{\\nReturn value: ${thread.return-value}}" \
- "{\\nCompleted expression: ${thread.completed-expression}}" \
- "\\n"
-
-#define DEFAULT_FRAME_FORMAT \
- "frame #${frame.index}: " \
- "${ansi.fg.yellow}${frame.pc}${ansi.normal}" MODULE_WITH_FUNC FILE_AND_LINE \
- IS_OPTIMIZED IS_ARTIFICIAL "\\n"
-
-#define DEFAULT_FRAME_FORMAT_NO_ARGS \
- "frame #${frame.index}: " \
- "${ansi.fg.yellow}${frame.pc}${ansi.normal}" MODULE_WITH_FUNC_NO_ARGS \
- FILE_AND_LINE IS_OPTIMIZED IS_ARTIFICIAL "\\n"
-
-// Three parts to this disassembly format specification:
-// 1. If this is a new function/symbol (no previous symbol/function), print
-// dylib`funcname:\n
-// 2. If this is a symbol context change (different from previous
-// symbol/function), print
-// dylib`funcname:\n
-// 3. print
-// address <+offset>:
-#define DEFAULT_DISASSEMBLY_FORMAT \
- "{${function.initial-function}{${module.file.basename}`}{${function.name-" \
- "without-args}}:\\n}{${function.changed}\\n{${module.file.basename}`}{${" \
- "function.name-without-args}}:\\n}{${current-pc-arrow} " \
- "}${addr-file-or-load}{ " \
- "<${function.concrete-only-addr-offset-no-padding}>}: "
-
-// gdb's disassembly format can be emulated with ${current-pc-arrow}${addr-
-// file-or-load}{ <${function.name-without-args}${function.concrete-only-addr-
-// offset-no-padding}>}:
-
-// lldb's original format for disassembly would look like this format string -
-// {${function.initial-function}{${module.file.basename}`}{${function.name-
-// without-
-// args}}:\n}{${function.changed}\n{${module.file.basename}`}{${function.name-
-// without-args}}:\n}{${current-pc-arrow} }{${addr-file-or-load}}:
-
static constexpr OptionEnumValueElement s_stop_show_column_values[] = {
{
eStopShowColumnAnsiOrCaret,
@@ -290,6 +212,11 @@ Status Debugger::SetPropertyValue(const ExecutionContext *exe_ctx,
// use-color changed. Ping the prompt so it can reset the ansi terminal
// codes.
SetPrompt(GetPrompt());
+ } else if (property_path == g_debugger_properties[ePropertyUseSourceCache].name) {
+ // use-source-cache changed. Wipe out the cache contents if it was disabled.
+ if (!GetUseSourceCache()) {
+ m_source_file_cache.Clear();
+ }
} else if (is_load_script && target_sp &&
load_script_old_value == eLoadScriptFromSymFileWarn) {
if (target_sp->TargetProperties::GetLoadScriptFromSymbolFile() ==
@@ -388,6 +315,9 @@ uint32_t Debugger::GetTerminalWidth() const {
}
bool Debugger::SetTerminalWidth(uint32_t term_width) {
+ if (auto handler_sp = m_io_handler_stack.Top())
+ handler_sp->TerminalSizeChanged();
+
const uint32_t idx = ePropertyTerminalWidth;
return m_collection_sp->SetPropertyAtIndexAsSInt64(nullptr, idx, term_width);
}
@@ -416,6 +346,20 @@ bool Debugger::SetUseColor(bool b) {
return ret;
}
+bool Debugger::GetUseSourceCache() const {
+ const uint32_t idx = ePropertyUseSourceCache;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(
+ nullptr, idx, g_debugger_properties[idx].default_uint_value != 0);
+}
+
+bool Debugger::SetUseSourceCache(bool b) {
+ const uint32_t idx = ePropertyUseSourceCache;
+ bool ret = m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
+ if (!ret) {
+ m_source_file_cache.Clear();
+ }
+ return ret;
+}
bool Debugger::GetHighlightSource() const {
const uint32_t idx = ePropertyHighlightSource;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
@@ -438,6 +382,16 @@ llvm::StringRef Debugger::GetStopShowColumnAnsiSuffix() const {
return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, "");
}
+llvm::StringRef Debugger::GetStopShowLineMarkerAnsiPrefix() const {
+ const uint32_t idx = ePropertyStopShowLineMarkerAnsiPrefix;
+ return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, "");
+}
+
+llvm::StringRef Debugger::GetStopShowLineMarkerAnsiSuffix() const {
+ const uint32_t idx = ePropertyStopShowLineMarkerAnsiSuffix;
+ return m_collection_sp->GetPropertyAtIndexAsString(nullptr, idx, "");
+}
+
uint32_t Debugger::GetStopSourceLineCount(bool before) const {
const uint32_t idx =
before ? ePropertyStopLineCountBefore : ePropertyStopLineCountAfter;
@@ -708,7 +662,7 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
m_source_manager_up(), m_source_file_cache(),
m_command_interpreter_up(
std::make_unique<CommandInterpreter>(*this, false)),
- m_input_reader_stack(), m_instance_name(), m_loaded_plugins(),
+ m_io_handler_stack(), m_instance_name(), m_loaded_plugins(),
m_event_handler_thread(), m_io_handler_thread(),
m_sync_broadcaster(nullptr, "lldb.debugger.sync"),
m_forward_listener_sp(), m_clear_once() {
@@ -870,15 +824,15 @@ ExecutionContext Debugger::GetSelectedExecutionContext() {
}
void Debugger::DispatchInputInterrupt() {
- std::lock_guard<std::recursive_mutex> guard(m_input_reader_stack.GetMutex());
- IOHandlerSP reader_sp(m_input_reader_stack.Top());
+ std::lock_guard<std::recursive_mutex> guard(m_io_handler_stack.GetMutex());
+ IOHandlerSP reader_sp(m_io_handler_stack.Top());
if (reader_sp)
reader_sp->Interrupt();
}
void Debugger::DispatchInputEndOfFile() {
- std::lock_guard<std::recursive_mutex> guard(m_input_reader_stack.GetMutex());
- IOHandlerSP reader_sp(m_input_reader_stack.Top());
+ std::lock_guard<std::recursive_mutex> guard(m_io_handler_stack.GetMutex());
+ IOHandlerSP reader_sp(m_io_handler_stack.Top());
if (reader_sp)
reader_sp->GotEOF();
}
@@ -886,81 +840,107 @@ void Debugger::DispatchInputEndOfFile() {
void Debugger::ClearIOHandlers() {
// The bottom input reader should be the main debugger input reader. We do
// not want to close that one here.
- std::lock_guard<std::recursive_mutex> guard(m_input_reader_stack.GetMutex());
- while (m_input_reader_stack.GetSize() > 1) {
- IOHandlerSP reader_sp(m_input_reader_stack.Top());
+ std::lock_guard<std::recursive_mutex> guard(m_io_handler_stack.GetMutex());
+ while (m_io_handler_stack.GetSize() > 1) {
+ IOHandlerSP reader_sp(m_io_handler_stack.Top());
if (reader_sp)
PopIOHandler(reader_sp);
}
}
-void Debugger::ExecuteIOHandlers() {
+void Debugger::RunIOHandlers() {
+ IOHandlerSP reader_sp = m_io_handler_stack.Top();
while (true) {
- IOHandlerSP reader_sp(m_input_reader_stack.Top());
if (!reader_sp)
break;
reader_sp->Run();
+ {
+ std::lock_guard<std::recursive_mutex> guard(
+ m_io_handler_synchronous_mutex);
+
+ // Remove all input readers that are done from the top of the stack
+ while (true) {
+ IOHandlerSP top_reader_sp = m_io_handler_stack.Top();
+ if (top_reader_sp && top_reader_sp->GetIsDone())
+ PopIOHandler(top_reader_sp);
+ else
+ break;
+ }
+ reader_sp = m_io_handler_stack.Top();
+ }
+ }
+ ClearIOHandlers();
+}
+
+void Debugger::RunIOHandlerSync(const IOHandlerSP &reader_sp) {
+ std::lock_guard<std::recursive_mutex> guard(m_io_handler_synchronous_mutex);
+
+ PushIOHandler(reader_sp);
+ IOHandlerSP top_reader_sp = reader_sp;
+
+ while (top_reader_sp) {
+ if (!top_reader_sp)
+ break;
- // Remove all input readers that are done from the top of the stack
+ top_reader_sp->Run();
+
+ // Don't unwind past the starting point.
+ if (top_reader_sp.get() == reader_sp.get()) {
+ if (PopIOHandler(reader_sp))
+ break;
+ }
+
+ // If we pushed new IO handlers, pop them if they're done or restart the
+ // loop to run them if they're not.
while (true) {
- IOHandlerSP top_reader_sp = m_input_reader_stack.Top();
- if (top_reader_sp && top_reader_sp->GetIsDone())
+ top_reader_sp = m_io_handler_stack.Top();
+ if (top_reader_sp && top_reader_sp->GetIsDone()) {
PopIOHandler(top_reader_sp);
- else
+ // Don't unwind past the starting point.
+ if (top_reader_sp.get() == reader_sp.get())
+ return;
+ } else {
break;
+ }
}
}
- ClearIOHandlers();
}
bool Debugger::IsTopIOHandler(const lldb::IOHandlerSP &reader_sp) {
- return m_input_reader_stack.IsTop(reader_sp);
+ return m_io_handler_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);
+ return m_io_handler_stack.CheckTopIOHandlerTypes(top_type, second_top_type);
}
void Debugger::PrintAsync(const char *s, size_t len, bool is_stdout) {
lldb_private::StreamFile &stream =
is_stdout ? GetOutputStream() : GetErrorStream();
- m_input_reader_stack.PrintAsync(&stream, s, len);
+ m_io_handler_stack.PrintAsync(&stream, s, len);
}
ConstString Debugger::GetTopIOHandlerControlSequence(char ch) {
- return m_input_reader_stack.GetTopIOHandlerControlSequence(ch);
+ return m_io_handler_stack.GetTopIOHandlerControlSequence(ch);
}
const char *Debugger::GetIOHandlerCommandPrefix() {
- return m_input_reader_stack.GetTopIOHandlerCommandPrefix();
+ return m_io_handler_stack.GetTopIOHandlerCommandPrefix();
}
const char *Debugger::GetIOHandlerHelpPrologue() {
- return m_input_reader_stack.GetTopIOHandlerHelpPrologue();
+ return m_io_handler_stack.GetTopIOHandlerHelpPrologue();
}
-void Debugger::RunIOHandler(const IOHandlerSP &reader_sp) {
- PushIOHandler(reader_sp);
-
- IOHandlerSP top_reader_sp = reader_sp;
- while (top_reader_sp) {
- top_reader_sp->Run();
-
- if (top_reader_sp.get() == reader_sp.get()) {
- if (PopIOHandler(reader_sp))
- break;
- }
+bool Debugger::RemoveIOHandler(const IOHandlerSP &reader_sp) {
+ return PopIOHandler(reader_sp);
+}
- while (true) {
- top_reader_sp = m_input_reader_stack.Top();
- if (top_reader_sp && top_reader_sp->GetIsDone())
- PopIOHandler(top_reader_sp);
- else
- break;
- }
- }
+void Debugger::RunIOHandlerAsync(const IOHandlerSP &reader_sp,
+ bool cancel_top_handler) {
+ PushIOHandler(reader_sp, cancel_top_handler);
}
void Debugger::AdoptTopIOHandlerFilesIfInvalid(FileSP &in, StreamFileSP &out,
@@ -970,8 +950,8 @@ void Debugger::AdoptTopIOHandlerFilesIfInvalid(FileSP &in, StreamFileSP &out,
// input reader's in/out/err streams, or fall back to the debugger file
// handles, or we fall back onto stdin/stdout/stderr as a last resort.
- std::lock_guard<std::recursive_mutex> guard(m_input_reader_stack.GetMutex());
- IOHandlerSP top_reader_sp(m_input_reader_stack.Top());
+ std::lock_guard<std::recursive_mutex> guard(m_io_handler_stack.GetMutex());
+ IOHandlerSP top_reader_sp(m_io_handler_stack.Top());
// If no STDIN has been set, then set it appropriately
if (!in || !in->IsValid()) {
if (top_reader_sp)
@@ -1009,17 +989,17 @@ void Debugger::PushIOHandler(const IOHandlerSP &reader_sp,
if (!reader_sp)
return;
- std::lock_guard<std::recursive_mutex> guard(m_input_reader_stack.GetMutex());
+ std::lock_guard<std::recursive_mutex> guard(m_io_handler_stack.GetMutex());
// Get the current top input reader...
- IOHandlerSP top_reader_sp(m_input_reader_stack.Top());
+ IOHandlerSP top_reader_sp(m_io_handler_stack.Top());
// Don't push the same IO handler twice...
if (reader_sp == top_reader_sp)
return;
// Push our new input reader
- m_input_reader_stack.Push(reader_sp);
+ m_io_handler_stack.Push(reader_sp);
reader_sp->Activate();
// Interrupt the top input reader to it will exit its Run() function and let
@@ -1035,23 +1015,23 @@ bool Debugger::PopIOHandler(const IOHandlerSP &pop_reader_sp) {
if (!pop_reader_sp)
return false;
- std::lock_guard<std::recursive_mutex> guard(m_input_reader_stack.GetMutex());
+ std::lock_guard<std::recursive_mutex> guard(m_io_handler_stack.GetMutex());
// The reader on the stop of the stack is done, so let the next read on the
// stack refresh its prompt and if there is one...
- if (m_input_reader_stack.IsEmpty())
+ if (m_io_handler_stack.IsEmpty())
return false;
- IOHandlerSP reader_sp(m_input_reader_stack.Top());
+ IOHandlerSP reader_sp(m_io_handler_stack.Top());
if (pop_reader_sp != reader_sp)
return false;
reader_sp->Deactivate();
reader_sp->Cancel();
- m_input_reader_stack.Pop();
+ m_io_handler_stack.Pop();
- reader_sp = m_input_reader_stack.Top();
+ reader_sp = m_io_handler_stack.Top();
if (reader_sp)
reader_sp->Activate();
@@ -1174,17 +1154,22 @@ bool Debugger::EnableLog(llvm::StringRef channel,
if (pos != m_log_streams.end())
log_stream_sp = pos->second.lock();
if (!log_stream_sp) {
- llvm::sys::fs::OpenFlags flags = llvm::sys::fs::OF_Text;
+ File::OpenOptions flags =
+ File::eOpenOptionWrite | File::eOpenOptionCanCreate;
if (log_options & LLDB_LOG_OPTION_APPEND)
- flags |= llvm::sys::fs::OF_Append;
- int FD;
- if (std::error_code ec = llvm::sys::fs::openFileForWrite(
- log_file, FD, llvm::sys::fs::CD_CreateAlways, flags)) {
- error_stream << "Unable to open log file: " << ec.message();
+ flags |= File::eOpenOptionAppend;
+ else
+ flags |= File::eOpenOptionTruncate;
+ auto file = FileSystem::Instance().Open(
+ FileSpec(log_file), flags, lldb::eFilePermissionsFileDefault, false);
+ if (!file) {
+ // FIXME: This gets garbled when called from the log command.
+ error_stream << "Unable to open log file: " << log_file;
return false;
}
- log_stream_sp =
- std::make_shared<llvm::raw_fd_ostream>(FD, should_close, unbuffered);
+
+ log_stream_sp = std::make_shared<llvm::raw_fd_ostream>(
+ (*file)->GetDescriptor(), should_close, unbuffered);
m_log_streams[log_file] = log_stream_sp;
}
}
@@ -1503,9 +1488,9 @@ bool Debugger::StartEventHandlerThread() {
listener_sp->StartListeningForEvents(&m_sync_broadcaster,
eBroadcastBitEventThreadIsListening);
- auto thread_name =
+ llvm::StringRef thread_name =
full_name.GetLength() < llvm::get_max_thread_name_length()
- ? full_name.AsCString()
+ ? full_name.GetStringRef()
: "dbg.evt-handler";
// Use larger 8MB stack for this thread
@@ -1542,7 +1527,7 @@ void Debugger::StopEventHandlerThread() {
lldb::thread_result_t Debugger::IOHandlerThread(lldb::thread_arg_t arg) {
Debugger *debugger = (Debugger *)arg;
- debugger->ExecuteIOHandlers();
+ debugger->RunIOHandlers();
debugger->StopEventHandlerThread();
return {};
}
diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp
index 33172cc8868e..4da823c7a243 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -1,4 +1,4 @@
-//===-- Disassembler.cpp ----------------------------------------*- C++ -*-===//
+//===-- Disassembler.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -89,124 +89,57 @@ DisassemblerSP Disassembler::FindPlugin(const ArchSpec &arch,
return DisassemblerSP();
}
-DisassemblerSP Disassembler::FindPluginForTarget(const TargetSP target_sp,
+DisassemblerSP Disassembler::FindPluginForTarget(const Target &target,
const ArchSpec &arch,
const char *flavor,
const char *plugin_name) {
- if (target_sp && flavor == nullptr) {
+ if (flavor == nullptr) {
// FIXME - we don't have the mechanism in place to do per-architecture
// settings. But since we know that for now we only support flavors on x86
// & x86_64,
if (arch.GetTriple().getArch() == llvm::Triple::x86 ||
arch.GetTriple().getArch() == llvm::Triple::x86_64)
- flavor = target_sp->GetDisassemblyFlavor();
+ flavor = target.GetDisassemblyFlavor();
}
return FindPlugin(arch, flavor, plugin_name);
}
-static void ResolveAddress(const ExecutionContext &exe_ctx, const Address &addr,
- Address &resolved_addr) {
+static Address ResolveAddress(Target &target, const Address &addr) {
if (!addr.IsSectionOffset()) {
+ Address resolved_addr;
// If we weren't passed in a section offset address range, try and resolve
// it to something
- Target *target = exe_ctx.GetTargetPtr();
- if (target) {
- bool is_resolved =
- target->GetSectionLoadList().IsEmpty() ?
- target->GetImages().ResolveFileAddress(addr.GetOffset(),
- resolved_addr) :
- target->GetSectionLoadList().ResolveLoadAddress(addr.GetOffset(),
- resolved_addr);
-
- // We weren't able to resolve the address, just treat it as a raw address
- if (is_resolved && resolved_addr.IsValid())
- return;
- }
- }
- resolved_addr = addr;
-}
-
-size_t Disassembler::Disassemble(Debugger &debugger, const ArchSpec &arch,
- const char *plugin_name, const char *flavor,
- const ExecutionContext &exe_ctx,
- SymbolContextList &sc_list,
- uint32_t num_instructions,
- bool mixed_source_and_assembly,
- uint32_t num_mixed_context_lines,
- uint32_t options, Stream &strm) {
- size_t success_count = 0;
- const size_t count = sc_list.GetSize();
- SymbolContext sc;
- AddressRange range;
- const uint32_t scope =
- eSymbolContextBlock | eSymbolContextFunction | eSymbolContextSymbol;
- const bool use_inline_block_range = true;
- for (size_t i = 0; i < count; ++i) {
- if (!sc_list.GetContextAtIndex(i, sc))
- break;
- for (uint32_t range_idx = 0;
- sc.GetAddressRange(scope, range_idx, use_inline_block_range, range);
- ++range_idx) {
- if (Disassemble(debugger, arch, plugin_name, flavor, exe_ctx, range,
- num_instructions, mixed_source_and_assembly,
- num_mixed_context_lines, options, strm)) {
- ++success_count;
- strm.EOL();
- }
- }
- }
- return success_count;
-}
-
-bool Disassembler::Disassemble(
- Debugger &debugger, const ArchSpec &arch, const char *plugin_name,
- const char *flavor, const ExecutionContext &exe_ctx, ConstString name,
- Module *module, uint32_t num_instructions, bool mixed_source_and_assembly,
- uint32_t num_mixed_context_lines, uint32_t options, Stream &strm) {
- // If no name is given there's nothing to disassemble.
- if (!name)
- return false;
-
- const bool include_symbols = true;
- const bool include_inlines = true;
-
- // Find functions matching the given name.
- SymbolContextList sc_list;
- if (module) {
- module->FindFunctions(name, nullptr, eFunctionNameTypeAuto, include_symbols,
- include_inlines, sc_list);
- } else if (exe_ctx.GetTargetPtr()) {
- exe_ctx.GetTargetPtr()->GetImages().FindFunctions(
- name, eFunctionNameTypeAuto, include_symbols, include_inlines, sc_list);
+ bool is_resolved = target.GetSectionLoadList().IsEmpty()
+ ? target.GetImages().ResolveFileAddress(
+ addr.GetOffset(), resolved_addr)
+ : target.GetSectionLoadList().ResolveLoadAddress(
+ addr.GetOffset(), resolved_addr);
+
+ // We weren't able to resolve the address, just treat it as a raw address
+ if (is_resolved && resolved_addr.IsValid())
+ return resolved_addr;
}
-
- // If no functions were found there's nothing to disassemble.
- if (sc_list.IsEmpty())
- return false;
-
- return Disassemble(debugger, arch, plugin_name, flavor, exe_ctx, sc_list,
- num_instructions, mixed_source_and_assembly,
- num_mixed_context_lines, options, strm);
+ return addr;
}
lldb::DisassemblerSP Disassembler::DisassembleRange(
const ArchSpec &arch, const char *plugin_name, const char *flavor,
- const ExecutionContext &exe_ctx, const AddressRange &range,
- bool prefer_file_cache) {
+ Target &target, const AddressRange &range, bool prefer_file_cache) {
if (range.GetByteSize() <= 0)
return {};
if (!range.GetBaseAddress().IsValid())
return {};
- lldb::DisassemblerSP disasm_sp = Disassembler::FindPluginForTarget(
- exe_ctx.GetTargetSP(), arch, flavor, plugin_name);
+ lldb::DisassemblerSP disasm_sp =
+ Disassembler::FindPluginForTarget(target, arch, flavor, plugin_name);
if (!disasm_sp)
return {};
- const size_t bytes_disassembled =
- disasm_sp->ParseInstructions(&exe_ctx, range, nullptr, prefer_file_cache);
+ const size_t bytes_disassembled = disasm_sp->ParseInstructions(
+ target, range.GetBaseAddress(), {Limit::Bytes, range.GetByteSize()},
+ nullptr, prefer_file_cache);
if (bytes_disassembled == 0)
return {};
@@ -238,63 +171,28 @@ Disassembler::DisassembleBytes(const ArchSpec &arch, const char *plugin_name,
bool Disassembler::Disassemble(Debugger &debugger, const ArchSpec &arch,
const char *plugin_name, const char *flavor,
const ExecutionContext &exe_ctx,
- const AddressRange &disasm_range,
- uint32_t num_instructions,
+ const Address &address, Limit limit,
bool mixed_source_and_assembly,
uint32_t num_mixed_context_lines,
uint32_t options, Stream &strm) {
- if (!disasm_range.GetByteSize())
+ if (!exe_ctx.GetTargetPtr())
return false;
lldb::DisassemblerSP disasm_sp(Disassembler::FindPluginForTarget(
- exe_ctx.GetTargetSP(), arch, flavor, plugin_name));
-
+ exe_ctx.GetTargetRef(), arch, flavor, plugin_name));
if (!disasm_sp)
return false;
- AddressRange range;
- ResolveAddress(exe_ctx, disasm_range.GetBaseAddress(),
- range.GetBaseAddress());
- range.SetByteSize(disasm_range.GetByteSize());
- const bool prefer_file_cache = false;
- size_t bytes_disassembled =
- disasm_sp->ParseInstructions(&exe_ctx, range, &strm, prefer_file_cache);
- if (bytes_disassembled == 0)
- return false;
-
- return PrintInstructions(disasm_sp.get(), debugger, arch, exe_ctx,
- num_instructions, mixed_source_and_assembly,
- num_mixed_context_lines, options, strm);
-}
-
-bool Disassembler::Disassemble(Debugger &debugger, const ArchSpec &arch,
- const char *plugin_name, const char *flavor,
- const ExecutionContext &exe_ctx,
- const Address &start_address,
- uint32_t num_instructions,
- bool mixed_source_and_assembly,
- uint32_t num_mixed_context_lines,
- uint32_t options, Stream &strm) {
- if (num_instructions == 0)
- return false;
-
- lldb::DisassemblerSP disasm_sp(Disassembler::FindPluginForTarget(
- exe_ctx.GetTargetSP(), arch, flavor, plugin_name));
- if (!disasm_sp)
- return false;
-
- Address addr;
- ResolveAddress(exe_ctx, start_address, addr);
-
const bool prefer_file_cache = false;
size_t bytes_disassembled = disasm_sp->ParseInstructions(
- &exe_ctx, addr, num_instructions, prefer_file_cache);
+ exe_ctx.GetTargetRef(), address, limit, &strm, prefer_file_cache);
if (bytes_disassembled == 0)
return false;
- return PrintInstructions(disasm_sp.get(), debugger, arch, exe_ctx,
- num_instructions, mixed_source_and_assembly,
- num_mixed_context_lines, options, strm);
+ disasm_sp->PrintInstructions(debugger, arch, exe_ctx,
+ mixed_source_and_assembly,
+ num_mixed_context_lines, options, strm);
+ return true;
}
Disassembler::SourceLine
@@ -380,21 +278,16 @@ bool Disassembler::ElideMixedSourceAndDisassemblyLine(
return false;
}
-bool Disassembler::PrintInstructions(Disassembler *disasm_ptr,
- Debugger &debugger, const ArchSpec &arch,
+void Disassembler::PrintInstructions(Debugger &debugger, const ArchSpec &arch,
const ExecutionContext &exe_ctx,
- uint32_t num_instructions,
bool mixed_source_and_assembly,
uint32_t num_mixed_context_lines,
uint32_t options, Stream &strm) {
// We got some things disassembled...
- size_t num_instructions_found = disasm_ptr->GetInstructionList().GetSize();
-
- if (num_instructions > 0 && num_instructions < num_instructions_found)
- num_instructions_found = num_instructions;
+ size_t num_instructions_found = GetInstructionList().GetSize();
const uint32_t max_opcode_byte_size =
- disasm_ptr->GetInstructionList().GetMaxOpcocdeByteSize();
+ GetInstructionList().GetMaxOpcocdeByteSize();
SymbolContext sc;
SymbolContext prev_sc;
AddressRange current_source_line_range;
@@ -435,8 +328,7 @@ bool Disassembler::PrintInstructions(Disassembler *disasm_ptr,
size_t address_text_size = 0;
for (size_t i = 0; i < num_instructions_found; ++i) {
- Instruction *inst =
- disasm_ptr->GetInstructionList().GetInstructionAtIndex(i).get();
+ Instruction *inst = GetInstructionList().GetInstructionAtIndex(i).get();
if (inst) {
const Address &addr = inst->GetAddress();
ModuleSP module_sp(addr.GetModule());
@@ -485,8 +377,7 @@ bool Disassembler::PrintInstructions(Disassembler *disasm_ptr,
previous_symbol = nullptr;
SourceLine previous_line;
for (size_t i = 0; i < num_instructions_found; ++i) {
- Instruction *inst =
- disasm_ptr->GetInstructionList().GetInstructionAtIndex(i).get();
+ Instruction *inst = GetInstructionList().GetInstructionAtIndex(i).get();
if (inst) {
const Address &addr = inst->GetAddress();
@@ -646,8 +537,6 @@ bool Disassembler::PrintInstructions(Disassembler *disasm_ptr,
break;
}
}
-
- return true;
}
bool Disassembler::Disassemble(Debugger &debugger, const ArchSpec &arch,
@@ -675,9 +564,10 @@ bool Disassembler::Disassemble(Debugger &debugger, const ArchSpec &arch,
range.SetByteSize(DEFAULT_DISASM_BYTE_SIZE);
}
- return Disassemble(debugger, arch, plugin_name, flavor, exe_ctx, range,
- num_instructions, mixed_source_and_assembly,
- num_mixed_context_lines, options, strm);
+ return Disassemble(
+ debugger, arch, plugin_name, flavor, exe_ctx, range.GetBaseAddress(),
+ {Limit::Instructions, num_instructions}, mixed_source_and_assembly,
+ num_mixed_context_lines, options, strm);
}
Instruction::Instruction(const Address &address, AddressClass addr_class)
@@ -1182,82 +1072,44 @@ InstructionList::GetIndexOfInstructionAtLoadAddress(lldb::addr_t load_addr,
return GetIndexOfInstructionAtAddress(address);
}
-size_t Disassembler::ParseInstructions(const ExecutionContext *exe_ctx,
- const AddressRange &range,
- Stream *error_strm_ptr,
- bool prefer_file_cache) {
- if (exe_ctx) {
- Target *target = exe_ctx->GetTargetPtr();
- const addr_t byte_size = range.GetByteSize();
- if (target == nullptr || byte_size == 0 ||
- !range.GetBaseAddress().IsValid())
- return 0;
-
- auto data_sp = std::make_shared<DataBufferHeap>(byte_size, '\0');
-
- Status error;
- lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
- const size_t bytes_read = target->ReadMemory(
- range.GetBaseAddress(), prefer_file_cache, data_sp->GetBytes(),
- data_sp->GetByteSize(), error, &load_addr);
-
- if (bytes_read > 0) {
- if (bytes_read != data_sp->GetByteSize())
- data_sp->SetByteSize(bytes_read);
- DataExtractor data(data_sp, m_arch.GetByteOrder(),
- m_arch.GetAddressByteSize());
- const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
- return DecodeInstructions(range.GetBaseAddress(), data, 0, UINT32_MAX,
- false, data_from_file);
- } else if (error_strm_ptr) {
- const char *error_cstr = error.AsCString();
- if (error_cstr) {
- error_strm_ptr->Printf("error: %s\n", error_cstr);
- }
- }
- } else if (error_strm_ptr) {
- error_strm_ptr->PutCString("error: invalid execution context\n");
- }
- return 0;
-}
-
-size_t Disassembler::ParseInstructions(const ExecutionContext *exe_ctx,
- const Address &start,
- uint32_t num_instructions,
+size_t Disassembler::ParseInstructions(Target &target, Address start,
+ Limit limit, Stream *error_strm_ptr,
bool prefer_file_cache) {
m_instruction_list.Clear();
- if (exe_ctx == nullptr || num_instructions == 0 || !start.IsValid())
+ if (!start.IsValid())
return 0;
- Target *target = exe_ctx->GetTargetPtr();
- // Calculate the max buffer size we will need in order to disassemble
- const addr_t byte_size = num_instructions * m_arch.GetMaximumOpcodeByteSize();
-
- if (target == nullptr || byte_size == 0)
- return 0;
+ start = ResolveAddress(target, start);
- DataBufferHeap *heap_buffer = new DataBufferHeap(byte_size, '\0');
- DataBufferSP data_sp(heap_buffer);
+ addr_t byte_size = limit.value;
+ if (limit.kind == Limit::Instructions)
+ byte_size *= m_arch.GetMaximumOpcodeByteSize();
+ auto data_sp = std::make_shared<DataBufferHeap>(byte_size, '\0');
Status error;
lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
const size_t bytes_read =
- target->ReadMemory(start, prefer_file_cache, heap_buffer->GetBytes(),
- byte_size, error, &load_addr);
-
+ target.ReadMemory(start, prefer_file_cache, data_sp->GetBytes(),
+ data_sp->GetByteSize(), error, &load_addr);
const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
- if (bytes_read == 0)
+ if (bytes_read == 0) {
+ if (error_strm_ptr) {
+ if (const char *error_cstr = error.AsCString())
+ error_strm_ptr->Printf("error: %s\n", error_cstr);
+ }
return 0;
+ }
+
+ if (bytes_read != data_sp->GetByteSize())
+ data_sp->SetByteSize(bytes_read);
DataExtractor data(data_sp, m_arch.GetByteOrder(),
m_arch.GetAddressByteSize());
-
- const bool append_instructions = true;
- DecodeInstructions(start, data, 0, num_instructions, append_instructions,
- data_from_file);
-
- return m_instruction_list.GetSize();
+ return DecodeInstructions(start, data, 0,
+ limit.kind == Limit::Instructions ? limit.value
+ : UINT32_MAX,
+ false, data_from_file);
}
// Disassembler copy constructor
@@ -1346,7 +1198,7 @@ void PseudoInstruction::SetOpcode(size_t opcode_size, void *opcode_data) {
}
void PseudoInstruction::SetDescription(llvm::StringRef description) {
- m_description = description;
+ m_description = std::string(description);
}
Instruction::Operand Instruction::Operand::BuildRegister(ConstString &r) {
diff --git a/lldb/source/Core/DumpDataExtractor.cpp b/lldb/source/Core/DumpDataExtractor.cpp
index b5e1071b72ae..dbfedfae27a8 100644
--- a/lldb/source/Core/DumpDataExtractor.cpp
+++ b/lldb/source/Core/DumpDataExtractor.cpp
@@ -1,4 +1,4 @@
-//===-- DumpDataExtractor.cpp -----------------------------------*- C++ -*-===//
+//===-- DumpDataExtractor.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -128,6 +128,104 @@ static lldb::offset_t DumpAPInt(Stream *s, const DataExtractor &data,
return offset;
}
+/// Dumps decoded instructions to a stream.
+static lldb::offset_t DumpInstructions(const DataExtractor &DE, Stream *s,
+ ExecutionContextScope *exe_scope,
+ offset_t start_offset,
+ uint64_t base_addr,
+ size_t number_of_instructions) {
+ offset_t offset = start_offset;
+
+ TargetSP target_sp;
+ if (exe_scope)
+ target_sp = exe_scope->CalculateTarget();
+ if (target_sp) {
+ DisassemblerSP disassembler_sp(
+ Disassembler::FindPlugin(target_sp->GetArchitecture(),
+ target_sp->GetDisassemblyFlavor(), nullptr));
+ if (disassembler_sp) {
+ lldb::addr_t addr = base_addr + start_offset;
+ lldb_private::Address so_addr;
+ bool data_from_file = true;
+ if (target_sp->GetSectionLoadList().ResolveLoadAddress(addr, so_addr)) {
+ data_from_file = false;
+ } else {
+ if (target_sp->GetSectionLoadList().IsEmpty() ||
+ !target_sp->GetImages().ResolveFileAddress(addr, so_addr))
+ so_addr.SetRawAddress(addr);
+ }
+
+ size_t bytes_consumed = disassembler_sp->DecodeInstructions(
+ so_addr, DE, start_offset, number_of_instructions, false,
+ data_from_file);
+
+ if (bytes_consumed) {
+ offset += bytes_consumed;
+ const bool show_address = base_addr != LLDB_INVALID_ADDRESS;
+ const bool show_bytes = true;
+ ExecutionContext exe_ctx;
+ exe_scope->CalculateExecutionContext(exe_ctx);
+ disassembler_sp->GetInstructionList().Dump(s, show_address, show_bytes,
+ &exe_ctx);
+ }
+ }
+ } else
+ s->Printf("invalid target");
+
+ return offset;
+}
+
+/// Prints the specific escape sequence of the given character to the stream.
+/// If the character doesn't have a known specific escape sequence (e.g., '\a',
+/// '\n' but not generic escape sequences such as'\x12'), this function will
+/// not modify the stream and return false.
+static bool TryDumpSpecialEscapedChar(Stream &s, const char c) {
+ switch (c) {
+ case '\033':
+ // Common non-standard escape code for 'escape'.
+ s.Printf("\\e");
+ return true;
+ case '\a':
+ s.Printf("\\a");
+ return true;
+ case '\b':
+ s.Printf("\\b");
+ return true;
+ case '\f':
+ s.Printf("\\f");
+ return true;
+ case '\n':
+ s.Printf("\\n");
+ return true;
+ case '\r':
+ s.Printf("\\r");
+ return true;
+ case '\t':
+ s.Printf("\\t");
+ return true;
+ case '\v':
+ s.Printf("\\v");
+ return true;
+ case '\0':
+ s.Printf("\\0");
+ return true;
+ default:
+ return false;
+ }
+}
+
+/// Dump the character to a stream. A character that is not printable will be
+/// represented by its escape sequence.
+static void DumpCharacter(Stream &s, const char c) {
+ if (TryDumpSpecialEscapedChar(s, c))
+ return;
+ if (llvm::isPrint(c)) {
+ s.PutChar(c);
+ return;
+ }
+ s.Printf("\\x%2.2x", c);
+}
+
lldb::offset_t lldb_private::DumpDataExtractor(
const DataExtractor &DE, Stream *s, offset_t start_offset,
lldb::Format item_format, size_t item_byte_size, size_t item_count,
@@ -147,44 +245,9 @@ lldb::offset_t lldb_private::DumpDataExtractor(
offset_t offset = start_offset;
- if (item_format == eFormatInstruction) {
- TargetSP target_sp;
- if (exe_scope)
- target_sp = exe_scope->CalculateTarget();
- if (target_sp) {
- DisassemblerSP disassembler_sp(Disassembler::FindPlugin(
- target_sp->GetArchitecture(),
- target_sp->GetDisassemblyFlavor(), nullptr));
- if (disassembler_sp) {
- lldb::addr_t addr = base_addr + start_offset;
- lldb_private::Address so_addr;
- bool data_from_file = true;
- if (target_sp->GetSectionLoadList().ResolveLoadAddress(addr, so_addr)) {
- data_from_file = false;
- } else {
- if (target_sp->GetSectionLoadList().IsEmpty() ||
- !target_sp->GetImages().ResolveFileAddress(addr, so_addr))
- so_addr.SetRawAddress(addr);
- }
-
- size_t bytes_consumed = disassembler_sp->DecodeInstructions(
- so_addr, DE, start_offset, item_count, false, data_from_file);
-
- if (bytes_consumed) {
- offset += bytes_consumed;
- const bool show_address = base_addr != LLDB_INVALID_ADDRESS;
- const bool show_bytes = true;
- ExecutionContext exe_ctx;
- exe_scope->CalculateExecutionContext(exe_ctx);
- disassembler_sp->GetInstructionList().Dump(s, show_address,
- show_bytes, &exe_ctx);
- }
- }
- } else
- s->Printf("invalid target");
-
- return offset;
- }
+ if (item_format == eFormatInstruction)
+ return DumpInstructions(DE, s, exe_scope, start_offset, base_addr,
+ item_count);
if ((item_format == eFormatOSType || item_format == eFormatAddressInfo) &&
item_byte_size > 8)
@@ -284,43 +347,14 @@ lldb::offset_t lldb_private::DumpDataExtractor(
const uint64_t ch = DE.GetMaxU64Bitfield(&offset, item_byte_size,
item_bit_size, item_bit_offset);
- if (isprint(ch))
+ if (llvm::isPrint(ch))
s->Printf("%c", (char)ch);
else if (item_format != eFormatCharPrintable) {
- switch (ch) {
- case '\033':
- s->Printf("\\e");
- break;
- case '\a':
- s->Printf("\\a");
- break;
- case '\b':
- s->Printf("\\b");
- break;
- case '\f':
- s->Printf("\\f");
- break;
- case '\n':
- s->Printf("\\n");
- break;
- case '\r':
- s->Printf("\\r");
- break;
- case '\t':
- s->Printf("\\t");
- break;
- case '\v':
- s->Printf("\\v");
- break;
- case '\0':
- s->Printf("\\0");
- break;
- default:
+ if (!TryDumpSpecialEscapedChar(*s, ch)) {
if (item_byte_size == 1)
s->Printf("\\x%2.2x", (uint8_t)ch);
else
s->Printf("%" PRIu64, ch);
- break;
}
} else {
s->PutChar(NON_PRINTABLE_CHAR);
@@ -375,42 +409,7 @@ lldb::offset_t lldb_private::DumpDataExtractor(
s->PutChar('\'');
for (uint32_t i = 0; i < item_byte_size; ++i) {
uint8_t ch = (uint8_t)(uval64 >> ((item_byte_size - i - 1) * 8));
- if (isprint(ch))
- s->Printf("%c", ch);
- else {
- switch (ch) {
- case '\033':
- s->Printf("\\e");
- break;
- case '\a':
- s->Printf("\\a");
- break;
- case '\b':
- s->Printf("\\b");
- break;
- case '\f':
- s->Printf("\\f");
- break;
- case '\n':
- s->Printf("\\n");
- break;
- case '\r':
- s->Printf("\\r");
- break;
- case '\t':
- s->Printf("\\t");
- break;
- case '\v':
- s->Printf("\\v");
- break;
- case '\0':
- s->Printf("\\0");
- break;
- default:
- s->Printf("\\x%2.2x", ch);
- break;
- }
- }
+ DumpCharacter(*s, ch);
}
s->PutChar('\'');
} break;
@@ -425,40 +424,7 @@ lldb::offset_t lldb_private::DumpDataExtractor(
s->PutChar('\"');
while (const char c = *cstr) {
- if (isprint(c)) {
- s->PutChar(c);
- } else {
- switch (c) {
- case '\033':
- s->Printf("\\e");
- break;
- case '\a':
- s->Printf("\\a");
- break;
- case '\b':
- s->Printf("\\b");
- break;
- case '\f':
- s->Printf("\\f");
- break;
- case '\n':
- s->Printf("\\n");
- break;
- case '\r':
- s->Printf("\\r");
- break;
- case '\t':
- s->Printf("\\t");
- break;
- case '\v':
- s->Printf("\\v");
- break;
- default:
- s->Printf("\\x%2.2x", c);
- break;
- }
- }
-
+ DumpCharacter(*s, c);
++cstr;
}
diff --git a/lldb/source/Core/DumpRegisterValue.cpp b/lldb/source/Core/DumpRegisterValue.cpp
index 74b02413f101..2018d618f1d1 100644
--- a/lldb/source/Core/DumpRegisterValue.cpp
+++ b/lldb/source/Core/DumpRegisterValue.cpp
@@ -1,4 +1,4 @@
-//===-- DumpRegisterValue.cpp -----------------------------------*- C++ -*-===//
+//===-- DumpRegisterValue.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -33,7 +33,7 @@ bool lldb_private::DumpRegisterValue(const RegisterValue &reg_val, Stream *s,
format_string.Printf("%%%us", reg_name_right_align_at);
else
format_string.Printf("%%s");
- std::string fmt = format_string.GetString();
+ std::string fmt = std::string(format_string.GetString());
if (prefix_with_name) {
if (reg_info->name) {
s->Printf(fmt.c_str(), reg_info->name);
diff --git a/lldb/source/Core/DynamicLoader.cpp b/lldb/source/Core/DynamicLoader.cpp
index 57130d6fa57a..ceccbe437e1d 100644
--- a/lldb/source/Core/DynamicLoader.cpp
+++ b/lldb/source/Core/DynamicLoader.cpp
@@ -1,4 +1,4 @@
-//===-- DynamicLoader.cpp ---------------------------------------*- C++ -*-===//
+//===-- DynamicLoader.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -193,7 +193,7 @@ ModuleSP DynamicLoader::LoadModuleAtAddress(const FileSpec &file,
if (error.Success() && memory_info.GetMapped() &&
memory_info.GetRange().GetRangeBase() == base_addr &&
!(memory_info.GetName().IsEmpty())) {
- ModuleSpec new_module_spec(FileSpec(memory_info.GetName().AsCString()),
+ ModuleSpec new_module_spec(FileSpec(memory_info.GetName().GetStringRef()),
target.GetArchitecture());
if ((module_sp = modules.FindFirstModule(new_module_spec))) {
diff --git a/lldb/source/Core/EmulateInstruction.cpp b/lldb/source/Core/EmulateInstruction.cpp
index 62942fb715b3..f7f56e9fc54f 100644
--- a/lldb/source/Core/EmulateInstruction.cpp
+++ b/lldb/source/Core/EmulateInstruction.cpp
@@ -1,4 +1,4 @@
-//===-- EmulateInstruction.cpp ----------------------------------*- C++ -*-===//
+//===-- EmulateInstruction.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Core/FileLineResolver.cpp b/lldb/source/Core/FileLineResolver.cpp
index 7d91d1a3e472..37435f9e9047 100644
--- a/lldb/source/Core/FileLineResolver.cpp
+++ b/lldb/source/Core/FileLineResolver.cpp
@@ -1,4 +1,4 @@
-//===-- FileLineResolver.cpp ------------------------------------*- C++ -*-===//
+//===-- FileLineResolver.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Core/FileSpecList.cpp b/lldb/source/Core/FileSpecList.cpp
index 6651324fa362..3ada7b495fdb 100644
--- a/lldb/source/Core/FileSpecList.cpp
+++ b/lldb/source/Core/FileSpecList.cpp
@@ -1,4 +1,4 @@
-//===-- FileSpecList.cpp ----------------------------------------*- C++ -*-===//
+//===-- FileSpecList.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp
index 7aa1eced34f3..d491ac14bec8 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -1,4 +1,4 @@
-//===-- FormatEntity.cpp ----------------------------------------*- C++ -*-===//
+//===-- FormatEntity.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -46,7 +46,6 @@
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Logging.h"
#include "lldb/Utility/RegisterValue.h"
-#include "lldb/Utility/SharingPtr.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/StringList.h"
@@ -166,6 +165,7 @@ static FormatEntity::Entry::Definition g_thread_child_entries[] = {
ENTRY("queue", ThreadQueue),
ENTRY("name", ThreadName),
ENTRY("stop-reason", ThreadStopReason),
+ ENTRY("stop-reason-raw", ThreadStopReasonRaw),
ENTRY("return-value", ThreadReturnValue),
ENTRY("completed-expression", ThreadCompletedExpression),
};
@@ -328,6 +328,7 @@ const char *FormatEntity::Entry::TypeToCString(Type t) {
ENUM_TO_CSTR(ThreadName);
ENUM_TO_CSTR(ThreadQueue);
ENUM_TO_CSTR(ThreadStopReason);
+ ENUM_TO_CSTR(ThreadStopReasonRaw);
ENUM_TO_CSTR(ThreadReturnValue);
ENUM_TO_CSTR(ThreadCompletedExpression);
ENUM_TO_CSTR(ScriptThread);
@@ -1273,15 +1274,23 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
case Entry::Type::ThreadStopReason:
if (exe_ctx) {
- Thread *thread = exe_ctx->GetThreadPtr();
- if (thread) {
- StopInfoSP stop_info_sp = thread->GetStopInfo();
- if (stop_info_sp && stop_info_sp->IsValid()) {
- const char *cstr = stop_info_sp->GetDescription();
- if (cstr && cstr[0]) {
- s.PutCString(cstr);
- return true;
- }
+ if (Thread *thread = exe_ctx->GetThreadPtr()) {
+ std::string stop_description = thread->GetStopDescription();
+ if (!stop_description.empty()) {
+ s.PutCString(stop_description);
+ return true;
+ }
+ }
+ }
+ return false;
+
+ case Entry::Type::ThreadStopReasonRaw:
+ if (exe_ctx) {
+ if (Thread *thread = exe_ctx->GetThreadPtr()) {
+ std::string stop_description = thread->GetStopDescriptionRaw();
+ if (!stop_description.empty()) {
+ s.PutCString(stop_description);
+ return true;
}
}
}
@@ -1544,7 +1553,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
sc->block->GetInlinedFunctionInfo();
if (inline_info) {
s.PutCString(" [inlined] ");
- inline_info->GetName(sc->function->GetLanguage()).Dump(&s);
+ inline_info->GetName().Dump(&s);
}
}
}
@@ -1628,8 +1637,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
if (inline_info) {
s.PutCString(cstr);
s.PutCString(" [inlined] ");
- cstr =
- inline_info->GetName(sc->function->GetLanguage()).GetCString();
+ cstr = inline_info->GetName().GetCString();
}
VariableList args;
@@ -1750,12 +1758,11 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
case Entry::Type::FunctionMangledName: {
const char *name = nullptr;
if (sc->symbol)
- name = sc->symbol->GetMangled()
- .GetName(sc->symbol->GetLanguage(), Mangled::ePreferMangled)
- .AsCString();
+ name =
+ sc->symbol->GetMangled().GetName(Mangled::ePreferMangled).AsCString();
else if (sc->function)
name = sc->function->GetMangled()
- .GetName(sc->symbol->GetLanguage(), Mangled::ePreferMangled)
+ .GetName(Mangled::ePreferMangled)
.AsCString();
if (!name)
@@ -1766,7 +1773,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
if (const InlineFunctionInfo *inline_info =
sc->block->GetInlinedFunctionInfo()) {
s.PutCString(" [inlined] ");
- inline_info->GetName(sc->function->GetLanguage()).Dump(&s);
+ inline_info->GetName().Dump(&s);
}
}
return true;
@@ -2340,10 +2347,10 @@ bool FormatEntity::FormatFileSpec(const FileSpec &file_spec, Stream &s,
file_spec.Dump(s.AsRawOstream());
return true;
} else if (variable_name.equals(".basename")) {
- s.PutCString(file_spec.GetFilename().AsCString(""));
+ s.PutCString(file_spec.GetFilename().GetStringRef());
return true;
} else if (variable_name.equals(".dirname")) {
- s.PutCString(file_spec.GetFilename().AsCString(""));
+ s.PutCString(file_spec.GetFilename().GetStringRef());
return true;
}
return false;
@@ -2402,7 +2409,7 @@ void FormatEntity::AutoComplete(CompletionRequest &request) {
llvm::StringRef partial_variable(str.substr(dollar_pos + 2));
if (partial_variable.empty()) {
- // Suggest all top level entites as we are just past "${"
+ // Suggest all top level entities as we are just past "${"
StringList new_matches;
AddMatches(&g_root, str, llvm::StringRef(), new_matches);
request.AddCompletions(new_matches);
diff --git a/lldb/source/Core/Highlighter.cpp b/lldb/source/Core/Highlighter.cpp
index c3c614aac210..04d993b8305c 100644
--- a/lldb/source/Core/Highlighter.cpp
+++ b/lldb/source/Core/Highlighter.cpp
@@ -1,4 +1,4 @@
-//===-- Highlighter.cpp -----------------------------------------*- C++ -*-===//
+//===-- Highlighter.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp
index 4021a6d7f327..6cf09aaa7f9d 100644
--- a/lldb/source/Core/IOHandler.cpp
+++ b/lldb/source/Core/IOHandler.cpp
@@ -1,4 +1,4 @@
-//===-- IOHandler.cpp -------------------------------------------*- C++ -*-===//
+//===-- IOHandler.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -125,6 +125,8 @@ void IOHandlerStack::PrintAsync(Stream *stream, const char *s, size_t len) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_top)
m_top->PrintAsync(stream, s, len);
+ else
+ stream->Write(s, len);
}
}
@@ -251,9 +253,9 @@ IOHandlerEditline::IOHandlerEditline(
m_input_sp && m_input_sp->GetIsRealTerminal();
if (use_editline) {
- m_editline_up.reset(new Editline(editline_name, GetInputFILE(),
- GetOutputFILE(), GetErrorFILE(),
- m_color_prompts));
+ m_editline_up = std::make_unique<Editline>(editline_name, GetInputFILE(),
+ GetOutputFILE(), GetErrorFILE(),
+ m_color_prompts);
m_editline_up->SetIsInputCompleteCallback(IsInputCompleteCallback, this);
m_editline_up->SetAutoCompleteCallback(AutoCompleteCallback, this);
// See if the delegate supports fixing indentation
@@ -287,12 +289,20 @@ void IOHandlerEditline::Deactivate() {
m_delegate.IOHandlerDeactivated(*this);
}
+void IOHandlerEditline::TerminalSizeChanged() {
+#if LLDB_ENABLE_LIBEDIT
+ if (m_editline_up)
+ m_editline_up->TerminalSizeChanged();
+#endif
+}
+
// Split out a line from the buffer, if there is a full one to get.
static Optional<std::string> SplitLine(std::string &line_buffer) {
size_t pos = line_buffer.find('\n');
if (pos == std::string::npos)
return None;
- std::string line = StringRef(line_buffer.c_str(), pos).rtrim("\n\r");
+ std::string line =
+ std::string(StringRef(line_buffer.c_str(), pos).rtrim("\n\r"));
line_buffer = line_buffer.substr(pos + 1);
return line;
}
@@ -300,7 +310,7 @@ static Optional<std::string> SplitLine(std::string &line_buffer) {
// If the final line of the file ends without a end-of-line, return
// it as a line anyway.
static Optional<std::string> SplitLineEOF(std::string &line_buffer) {
- if (llvm::all_of(line_buffer, isspace))
+ if (llvm::all_of(line_buffer, llvm::isSpace))
return None;
std::string line = std::move(line_buffer);
line_buffer.clear();
@@ -443,7 +453,7 @@ const char *IOHandlerEditline::GetPrompt() {
}
bool IOHandlerEditline::SetPrompt(llvm::StringRef prompt) {
- m_prompt = prompt;
+ m_prompt = std::string(prompt);
#if LLDB_ENABLE_LIBEDIT
if (m_editline_up)
@@ -458,7 +468,7 @@ const char *IOHandlerEditline::GetContinuationPrompt() {
}
void IOHandlerEditline::SetContinuationPrompt(llvm::StringRef prompt) {
- m_continuation_prompt = prompt;
+ m_continuation_prompt = std::string(prompt);
#if LLDB_ENABLE_LIBEDIT
if (m_editline_up)
diff --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp
index 1661b465efaf..f8fc91772198 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -1,4 +1,4 @@
-//===-- IOHandlerCursesGUI.cpp ----------------------------------*- C++ -*-===//
+//===-- IOHandlerCursesGUI.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -744,7 +744,8 @@ protected:
bool m_is_subwin;
private:
- DISALLOW_COPY_AND_ASSIGN(Window);
+ Window(const Window &) = delete;
+ const Window &operator=(const Window &) = delete;
};
class MenuDelegate {
@@ -918,7 +919,7 @@ void Menu::DrawMenuTitle(Window &window, bool highlight) {
const attr_t hilgight_attr = A_REVERSE;
if (highlight)
window.AttributeOn(hilgight_attr);
- if (isprint(shortcut_key)) {
+ if (llvm::isPrint(shortcut_key)) {
size_t lower_pos = m_name.find(tolower(shortcut_key));
size_t upper_pos = m_name.find(toupper(shortcut_key));
const char *name = m_name.c_str();
@@ -947,7 +948,7 @@ void Menu::DrawMenuTitle(Window &window, bool highlight) {
window.AttributeOff(hilgight_attr);
if (m_key_name.empty()) {
- if (!underlined_shortcut && isprint(m_key_value)) {
+ if (!underlined_shortcut && llvm::isPrint(m_key_value)) {
window.AttributeOn(COLOR_PAIR(3));
window.Printf(" (%c)", m_key_value);
window.AttributeOff(COLOR_PAIR(3));
@@ -2714,7 +2715,7 @@ static const char *CursesKeyToCString(int ch) {
case KEY_ESCAPE:
return "escape";
default:
- if (isprint(ch))
+ if (llvm::isPrint(ch))
snprintf(g_desc, sizeof(g_desc), "%c", ch);
else
snprintf(g_desc, sizeof(g_desc), "\\x%2.2x", ch);
@@ -3909,7 +3910,7 @@ IOHandlerCursesGUI::IOHandlerCursesGUI(Debugger &debugger)
void IOHandlerCursesGUI::Activate() {
IOHandler::Activate();
if (!m_app_ap) {
- m_app_ap.reset(new Application(GetInputFILE(), GetOutputFILE()));
+ m_app_ap = std::make_unique<Application>(GetInputFILE(), GetOutputFILE());
// This is both a window and a menu delegate
std::shared_ptr<ApplicationDelegate> app_delegate_sp(
diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index 15baffd212af..143ec8770bf4 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -1,4 +1,4 @@
-//===-- Mangled.cpp ---------------------------------------------*- C++ -*-===//
+//===-- Mangled.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -142,9 +142,8 @@ void Mangled::Clear() {
// Compare the string values.
int Mangled::Compare(const Mangled &a, const Mangled &b) {
- return ConstString::Compare(
- a.GetName(lldb::eLanguageTypeUnknown, ePreferMangled),
- b.GetName(lldb::eLanguageTypeUnknown, ePreferMangled));
+ return ConstString::Compare(a.GetName(ePreferMangled),
+ b.GetName(ePreferMangled));
}
// Set the string value in this objects. If "mangled" is true, then the mangled
@@ -182,7 +181,7 @@ void Mangled::SetValue(ConstString name) {
// Local helpers for different demangling implementations.
static char *GetMSVCDemangledStr(const char *M) {
char *demangled_cstr = llvm::microsoftDemangle(
- M, nullptr, nullptr, nullptr,
+ M, nullptr, nullptr, nullptr, nullptr,
llvm::MSDemangleFlags(llvm::MSDF_NoAccessSpecifier |
llvm::MSDF_NoCallingConvention |
llvm::MSDF_NoMemberType));
@@ -295,8 +294,7 @@ bool Mangled::DemangleWithRichManglingInfo(
// class will need to use this accessor if it wishes to decode the demangled
// name. The result is cached and will be kept until a new string value is
// supplied to this object, or until the end of the object's lifetime.
-ConstString
-Mangled::GetDemangledName(lldb::LanguageType language) const {
+ConstString Mangled::GetDemangledName() const {
// Check to make sure we have a valid mangled name and that we haven't
// already decoded our mangled name.
if (m_mangled && m_demangled.IsNull()) {
@@ -341,26 +339,24 @@ Mangled::GetDemangledName(lldb::LanguageType language) const {
}
ConstString
-Mangled::GetDisplayDemangledName(lldb::LanguageType language) const {
- return GetDemangledName(language);
+Mangled::GetDisplayDemangledName() const {
+ return GetDemangledName();
}
-bool Mangled::NameMatches(const RegularExpression &regex,
- lldb::LanguageType language) const {
- if (m_mangled && regex.Execute(m_mangled.AsCString()))
+bool Mangled::NameMatches(const RegularExpression &regex) const {
+ if (m_mangled && regex.Execute(m_mangled.GetStringRef()))
return true;
- ConstString demangled = GetDemangledName(language);
- return demangled && regex.Execute(demangled.AsCString());
+ ConstString demangled = GetDemangledName();
+ return demangled && regex.Execute(demangled.GetStringRef());
}
// Get the demangled name if there is one, else return the mangled name.
-ConstString Mangled::GetName(lldb::LanguageType language,
- Mangled::NamePreference preference) const {
+ConstString Mangled::GetName(Mangled::NamePreference preference) const {
if (preference == ePreferMangled && m_mangled)
return m_mangled;
- ConstString demangled = GetDemangledName(language);
+ ConstString demangled = GetDemangledName();
if (preference == ePreferDemangledWithoutArguments) {
return get_demangled_name_without_arguments(m_mangled, demangled);
@@ -417,12 +413,10 @@ lldb::LanguageType Mangled::GuessLanguage() const {
const char *mangled_name = mangled.GetCString();
if (CPlusPlusLanguage::IsCPPMangledName(mangled_name))
return lldb::eLanguageTypeC_plus_plus;
- else if (ObjCLanguage::IsPossibleObjCMethodName(mangled_name))
- return lldb::eLanguageTypeObjC;
} else {
// ObjC names aren't really mangled, so they won't necessarily be in the
// mangled name slot.
- ConstString demangled_name = GetDemangledName(lldb::eLanguageTypeUnknown);
+ ConstString demangled_name = GetDemangledName();
if (demangled_name
&& ObjCLanguage::IsPossibleObjCMethodName(demangled_name.GetCString()))
return lldb::eLanguageTypeObjC;
@@ -436,8 +430,7 @@ Stream &operator<<(Stream &s, const Mangled &obj) {
if (obj.GetMangledName())
s << "mangled = '" << obj.GetMangledName() << "'";
- ConstString demangled =
- obj.GetDemangledName(lldb::eLanguageTypeUnknown);
+ ConstString demangled = obj.GetDemangledName();
if (demangled)
s << ", demangled = '" << demangled << '\'';
else
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 031892abdd24..b76659ee3e07 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1,4 +1,4 @@
-//===-- Module.cpp ----------------------------------------------*- C++ -*-===//
+//===-- Module.cpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -18,6 +18,7 @@
#include "lldb/Core/Section.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
+#include "lldb/Host/HostInfo.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
#include "lldb/Symbol/CompileUnit.h"
@@ -33,7 +34,6 @@
#include "lldb/Symbol/TypeMap.h"
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/Language.h"
-#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
@@ -147,11 +147,16 @@ Module::Module(const ModuleSpec &module_spec)
: module_spec.GetObjectName().AsCString(""),
module_spec.GetObjectName().IsEmpty() ? "" : ")");
+ auto data_sp = module_spec.GetData();
+ lldb::offset_t file_size = 0;
+ if (data_sp)
+ file_size = data_sp->GetByteSize();
+
// First extract all module specifications from the file using the local file
// path. If there are no specifications, then don't fill anything in
ModuleSpecList modules_specs;
- if (ObjectFile::GetModuleSpecifications(module_spec.GetFileSpec(), 0, 0,
- modules_specs) == 0)
+ if (ObjectFile::GetModuleSpecifications(
+ module_spec.GetFileSpec(), 0, file_size, modules_specs, data_sp) == 0)
return;
// Now make sure that one of the module specifications matches what we just
@@ -170,11 +175,20 @@ Module::Module(const ModuleSpec &module_spec)
return;
}
- if (module_spec.GetFileSpec())
- m_mod_time = FileSystem::Instance().GetModificationTime(module_spec.GetFileSpec());
- else if (matching_module_spec.GetFileSpec())
- m_mod_time =
- FileSystem::Instance().GetModificationTime(matching_module_spec.GetFileSpec());
+ // Set m_data_sp if it was initially provided in the ModuleSpec. Note that
+ // we cannot use the data_sp variable here, because it will have been
+ // modified by GetModuleSpecifications().
+ if (auto module_spec_data_sp = module_spec.GetData()) {
+ m_data_sp = module_spec_data_sp;
+ m_mod_time = {};
+ } else {
+ if (module_spec.GetFileSpec())
+ m_mod_time =
+ FileSystem::Instance().GetModificationTime(module_spec.GetFileSpec());
+ else if (matching_module_spec.GetFileSpec())
+ m_mod_time = FileSystem::Instance().GetModificationTime(
+ matching_module_spec.GetFileSpec());
+ }
// Copy the architecture from the actual spec if we got one back, else use
// the one that was specified
@@ -297,7 +311,9 @@ ObjectFile *Module::GetMemoryObjectFile(const lldb::ProcessSP &process_sp,
const size_t bytes_read =
process_sp->ReadMemory(header_addr, data_up->GetBytes(),
data_up->GetByteSize(), readmem_error);
- if (bytes_read == size_to_read) {
+ if (bytes_read < size_to_read)
+ data_up->SetByteSize(bytes_read);
+ if (data_up->GetByteSize() > 0) {
DataBufferSP data_sp(data_up.release());
m_objfile_sp = ObjectFile::FindPlugin(shared_from_this(), process_sp,
header_addr, data_sp);
@@ -364,11 +380,11 @@ void Module::ParseAllDebugSymbols() {
if (num_comp_units == 0)
return;
- SymbolContext sc;
- sc.module_sp = shared_from_this();
SymbolFile *symbols = GetSymbolFile();
for (size_t cu_idx = 0; cu_idx < num_comp_units; cu_idx++) {
+ SymbolContext sc;
+ sc.module_sp = shared_from_this();
sc.comp_unit = symbols->GetCompileUnitAtIndex(cu_idx).get();
if (!sc.comp_unit)
continue;
@@ -595,7 +611,7 @@ uint32_t Module::ResolveSymbolContextsForFileSpec(
}
void Module::FindGlobalVariables(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
+ const CompilerDeclContext &parent_decl_ctx,
size_t max_matches, VariableList &variables) {
if (SymbolFile *symbols = GetSymbolFile())
symbols->FindGlobalVariables(name, parent_decl_ctx, max_matches, variables);
@@ -783,7 +799,7 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
}
void Module::FindFunctions(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
+ const CompilerDeclContext &parent_decl_ctx,
FunctionNameType name_type_mask,
bool include_symbols, bool include_inlines,
SymbolContextList &sc_list) {
@@ -920,7 +936,7 @@ void Module::FindAddressesForLine(const lldb::TargetSP target_sp,
}
void Module::FindTypes_Impl(
- ConstString name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext &parent_decl_ctx,
size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {
@@ -932,7 +948,7 @@ void Module::FindTypes_Impl(
}
void Module::FindTypesInNamespace(ConstString type_name,
- const CompilerDeclContext *parent_decl_ctx,
+ const CompilerDeclContext &parent_decl_ctx,
size_t max_matches, TypeList &type_list) {
TypeMap types_map;
llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
@@ -974,10 +990,11 @@ void Module::FindTypes(
exact_match = type_scope.consume_front("::");
ConstString type_basename_const_str(type_basename);
- FindTypes_Impl(type_basename_const_str, nullptr, max_matches,
+ FindTypes_Impl(type_basename_const_str, CompilerDeclContext(), max_matches,
searched_symbol_files, typesmap);
if (typesmap.GetSize())
- typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
+ typesmap.RemoveMismatchedTypes(std::string(type_scope),
+ std::string(type_basename), type_class,
exact_match);
} else {
// The type is not in a namespace/class scope, just search for it by
@@ -985,16 +1002,18 @@ void Module::FindTypes(
if (type_class != eTypeClassAny && !type_basename.empty()) {
// The "type_name_cstr" will have been modified if we have a valid type
// class prefix (like "struct", "class", "union", "typedef" etc).
- FindTypes_Impl(ConstString(type_basename), nullptr, UINT_MAX,
- searched_symbol_files, typesmap);
- typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
+ FindTypes_Impl(ConstString(type_basename), CompilerDeclContext(),
+ UINT_MAX, searched_symbol_files, typesmap);
+ typesmap.RemoveMismatchedTypes(std::string(type_scope),
+ std::string(type_basename), type_class,
exact_match);
} else {
- FindTypes_Impl(name, nullptr, UINT_MAX, searched_symbol_files, typesmap);
+ FindTypes_Impl(name, CompilerDeclContext(), UINT_MAX,
+ searched_symbol_files, typesmap);
if (exact_match) {
std::string name_str(name.AsCString(""));
- typesmap.RemoveMismatchedTypes(type_scope, name_str, type_class,
- exact_match);
+ typesmap.RemoveMismatchedTypes(std::string(type_scope), name_str,
+ type_class, exact_match);
}
}
}
@@ -1105,6 +1124,10 @@ void Module::ReportError(const char *format, ...) {
}
bool Module::FileHasChanged() const {
+ // We have provided the DataBuffer for this module to avoid accessing the
+ // filesystem. We never want to reload those files.
+ if (m_data_sp)
+ return false;
if (!m_file_has_changed)
m_file_has_changed =
(FileSystem::Instance().GetModificationTime(m_file) != m_mod_time);
@@ -1224,12 +1247,19 @@ ObjectFile *Module::GetObjectFile() {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, "Module::GetObjectFile () module = %s",
GetFileSpec().GetFilename().AsCString(""));
- DataBufferSP data_sp;
lldb::offset_t data_offset = 0;
- const lldb::offset_t file_size =
- FileSystem::Instance().GetByteSize(m_file);
+ lldb::offset_t file_size = 0;
+
+ if (m_data_sp)
+ file_size = m_data_sp->GetByteSize();
+ else if (m_file)
+ file_size = FileSystem::Instance().GetByteSize(m_file);
+
if (file_size > m_object_offset) {
m_did_load_objfile = true;
+ // FindPlugin will modify its data_sp argument. Do not let it
+ // modify our m_data_sp member.
+ auto data_sp = m_data_sp;
m_objfile_sp = ObjectFile::FindPlugin(
shared_from_this(), &m_file, m_object_offset,
file_size - m_object_offset, data_sp, data_offset);
@@ -1409,7 +1439,7 @@ void Module::SetSymbolFileFileSpec(const FileSpec &file) {
if (FileSystem::Instance().IsDirectory(file)) {
std::string new_path(file.GetPath());
std::string old_path(obj_file->GetFileSpec().GetPath());
- if (old_path.find(new_path) == 0) {
+ if (llvm::StringRef(old_path).startswith(new_path)) {
// We specified the same bundle as the symbol file that we already
// have
return;
@@ -1591,6 +1621,19 @@ bool Module::RemapSourceFile(llvm::StringRef path,
return m_source_mappings.RemapPath(path, new_path);
}
+void Module::RegisterXcodeSDK(llvm::StringRef sdk_name, llvm::StringRef sysroot) {
+ XcodeSDK sdk(sdk_name.str());
+ ConstString sdk_path(HostInfo::GetXcodeSDKPath(sdk));
+ if (!sdk_path)
+ return;
+ // If the SDK changed for a previously registered source path, update it.
+ // This could happend with -fdebug-prefix-map, otherwise it's unlikely.
+ ConstString sysroot_cs(sysroot);
+ if (!m_source_mappings.Replace(sysroot_cs, sdk_path, true))
+ // In the general case, however, append it to the list.
+ m_source_mappings.Append(sysroot_cs, sdk_path, false);
+}
+
bool Module::MergeArchitecture(const ArchSpec &arch_spec) {
if (!arch_spec.IsValid())
return false;
diff --git a/lldb/source/Core/ModuleChild.cpp b/lldb/source/Core/ModuleChild.cpp
index 2fcb2ffca137..6e04bb4589e3 100644
--- a/lldb/source/Core/ModuleChild.cpp
+++ b/lldb/source/Core/ModuleChild.cpp
@@ -1,4 +1,4 @@
-//===-- ModuleChild.cpp -----------------------------------------*- C++ -*-===//
+//===-- ModuleChild.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index 07100bb81dca..0345678ddaff 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -1,4 +1,4 @@
-//===-- ModuleList.cpp ------------------------------------------*- C++ -*-===//
+//===-- ModuleList.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -12,6 +12,7 @@
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Interpreter/OptionValueFileSpec.h"
+#include "lldb/Interpreter/OptionValueFileSpecList.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Interpreter/Property.h"
#include "lldb/Symbol/LocateSymbolFile.h"
@@ -77,6 +78,8 @@ ModuleListProperties::ModuleListProperties() {
m_collection_sp =
std::make_shared<OptionValueProperties>(ConstString("symbols"));
m_collection_sp->Initialize(g_modulelist_properties);
+ m_collection_sp->SetValueChangedCallback(ePropertySymLinkPaths,
+ [this] { UpdateSymlinkMappings(); });
llvm::SmallString<128> path;
clang::driver::Driver::getDefaultModuleCachePath(path);
@@ -106,6 +109,28 @@ bool ModuleListProperties::SetClangModulesCachePath(llvm::StringRef path) {
nullptr, ePropertyClangModulesCachePath, path);
}
+void ModuleListProperties::UpdateSymlinkMappings() {
+ FileSpecList list = m_collection_sp
+ ->GetPropertyAtIndexAsOptionValueFileSpecList(
+ nullptr, false, ePropertySymLinkPaths)
+ ->GetCurrentValue();
+ llvm::sys::ScopedWriter lock(m_symlink_paths_mutex);
+ const bool notify = false;
+ m_symlink_paths.Clear(notify);
+ for (FileSpec symlink : list) {
+ FileSpec resolved;
+ Status status = FileSystem::Instance().Readlink(symlink, resolved);
+ if (status.Success())
+ m_symlink_paths.Append(ConstString(symlink.GetPath()),
+ ConstString(resolved.GetPath()), notify);
+ }
+}
+
+PathMappingList ModuleListProperties::GetSymlinkMappings() const {
+ llvm::sys::ScopedReader lock(m_symlink_paths_mutex);
+ return m_symlink_paths;
+}
+
ModuleList::ModuleList()
: m_modules(), m_modules_mutex(), m_notifier(nullptr) {}
@@ -338,7 +363,7 @@ void ModuleList::FindFunctions(ConstString name,
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
- (*pos)->FindFunctions(lookup_info.GetLookupName(), nullptr,
+ (*pos)->FindFunctions(lookup_info.GetLookupName(), CompilerDeclContext(),
lookup_info.GetNameTypeMask(), include_symbols,
include_inlines, sc_list);
}
@@ -351,8 +376,8 @@ void ModuleList::FindFunctions(ConstString name,
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
- (*pos)->FindFunctions(name, nullptr, name_type_mask, include_symbols,
- include_inlines, sc_list);
+ (*pos)->FindFunctions(name, CompilerDeclContext(), name_type_mask,
+ include_symbols, include_inlines, sc_list);
}
}
}
@@ -409,7 +434,8 @@ void ModuleList::FindGlobalVariables(ConstString name, size_t max_matches,
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
- (*pos)->FindGlobalVariables(name, nullptr, max_matches, variable_list);
+ (*pos)->FindGlobalVariables(name, CompilerDeclContext(), max_matches,
+ variable_list);
}
}
@@ -565,10 +591,6 @@ size_t ModuleList::GetSize() const {
}
void ModuleList::Dump(Stream *s) const {
- // s.Printf("%.*p: ", (int)sizeof(void*) * 2, this);
- // s.Indent();
- // s << "ModuleList\n";
-
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos) {
@@ -807,7 +829,7 @@ Status ModuleList::GetSharedModule(const ModuleSpec &module_spec,
if (!FileSystem::Instance().IsDirectory(search_path_spec))
continue;
search_path_spec.AppendPathComponent(
- module_spec.GetFileSpec().GetFilename().AsCString());
+ module_spec.GetFileSpec().GetFilename().GetStringRef());
if (!FileSystem::Instance().Exists(search_path_spec))
continue;
diff --git a/lldb/source/Core/Opcode.cpp b/lldb/source/Core/Opcode.cpp
index 6ca46de40de2..b544064b061e 100644
--- a/lldb/source/Core/Opcode.cpp
+++ b/lldb/source/Core/Opcode.cpp
@@ -1,4 +1,4 @@
-//===-- Opcode.cpp ----------------------------------------------*- C++ -*-===//
+//===-- Opcode.cpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp
index e8bfef724378..3545ef66cc38 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -1,4 +1,4 @@
-//===-- PluginManager.cpp ---------------------------------------*- C++ -*-===//
+//===-- PluginManager.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -16,38 +16,24 @@
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StringList.h"
-
-#if defined(_WIN32)
-#include "lldb/Host/windows/PosixApi.h"
-#endif
-
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/DynamicLibrary.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/raw_ostream.h"
-
+#include <assert.h>
#include <map>
#include <memory>
#include <mutex>
#include <string>
#include <utility>
#include <vector>
-
-#include <assert.h>
-
-namespace lldb_private {
-class CommandInterpreter;
-}
+#if defined(_WIN32)
+#include "lldb/Host/windows/PosixApi.h"
+#endif
using namespace lldb;
using namespace lldb_private;
-enum PluginAction {
- ePluginRegisterInstance,
- ePluginUnregisterInstance,
- ePluginGetInstanceAtIndex
-};
-
typedef bool (*PluginInitCallback)();
typedef void (*PluginTermCallback)();
@@ -92,7 +78,6 @@ template <typename FPtrTy> static FPtrTy CastToFPtr(void *VPtr) {
static FileSystem::EnumerateDirectoryResult
LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
llvm::StringRef path) {
- // PluginManager *plugin_manager = (PluginManager *)baton;
Status error;
namespace fs = llvm::sys::fs;
@@ -156,7 +141,6 @@ LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
}
void PluginManager::Initialize() {
-#if 1
const bool find_directories = true;
const bool find_files = true;
const bool find_other = true;
@@ -178,7 +162,6 @@ void PluginManager::Initialize() {
LoadPluginCallback, nullptr);
}
}
-#endif
}
void PluginManager::Terminate() {
@@ -197,99 +180,127 @@ void PluginManager::Terminate() {
plugin_map.clear();
}
-#pragma mark ABI
+template <typename Callback> struct PluginInstance {
+ typedef Callback CallbackType;
-struct ABIInstance {
- ABIInstance() : name(), description(), create_callback(nullptr) {}
+ PluginInstance() = default;
+ PluginInstance(ConstString name, std::string description,
+ Callback create_callback = nullptr,
+ DebuggerInitializeCallback debugger_init_callback = nullptr)
+ : name(name), description(std::move(description)),
+ create_callback(create_callback),
+ debugger_init_callback(debugger_init_callback) {}
ConstString name;
std::string description;
- ABICreateInstance create_callback;
+ Callback create_callback;
+ DebuggerInitializeCallback debugger_init_callback;
};
-typedef std::vector<ABIInstance> ABIInstances;
+template <typename Instance> class PluginInstances {
+public:
+ template <typename... Args>
+ bool RegisterPlugin(ConstString name, const char *description,
+ typename Instance::CallbackType callback,
+ Args &&... args) {
+ if (!callback)
+ return false;
+ assert((bool)name);
+ Instance instance =
+ Instance(name, description, callback, std::forward<Args>(args)...);
+ m_instances.push_back(instance);
+ return false;
+ }
-static std::recursive_mutex &GetABIInstancesMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
+ bool UnregisterPlugin(typename Instance::CallbackType callback) {
+ if (!callback)
+ return false;
+ auto pos = m_instances.begin();
+ auto end = m_instances.end();
+ for (; pos != end; ++pos) {
+ if (pos->create_callback == callback) {
+ m_instances.erase(pos);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ typename Instance::CallbackType GetCallbackAtIndex(uint32_t idx) {
+ if (Instance *instance = GetInstanceAtIndex(idx))
+ return instance->create_callback;
+ return nullptr;
+ }
+
+ const char *GetDescriptionAtIndex(uint32_t idx) {
+ if (Instance *instance = GetInstanceAtIndex(idx))
+ return instance->description.c_str();
+ return nullptr;
+ }
+
+ const char *GetNameAtIndex(uint32_t idx) {
+ if (Instance *instance = GetInstanceAtIndex(idx))
+ return instance->name.GetCString();
+ return nullptr;
+ }
+
+ typename Instance::CallbackType GetCallbackForName(ConstString name) {
+ if (!name)
+ return nullptr;
+ for (auto &instance : m_instances) {
+ if (name == instance.name)
+ return instance.create_callback;
+ }
+ return nullptr;
+ }
+
+ void PerformDebuggerCallback(Debugger &debugger) {
+ for (auto &instance : m_instances) {
+ if (instance.debugger_init_callback)
+ instance.debugger_init_callback(debugger);
+ }
+ }
+
+ const std::vector<Instance> &GetInstances() const { return m_instances; }
+ std::vector<Instance> &GetInstances() { return m_instances; }
+
+private:
+ Instance *GetInstanceAtIndex(uint32_t idx) {
+ if (idx < m_instances.size())
+ return &m_instances[idx];
+ return nullptr;
+ }
+ std::vector<Instance> m_instances;
+};
+
+#pragma mark ABI
+
+typedef PluginInstance<ABICreateInstance> ABIInstance;
+typedef PluginInstances<ABIInstance> ABIInstances;
static ABIInstances &GetABIInstances() {
static ABIInstances g_instances;
return g_instances;
}
-bool PluginManager::RegisterPlugin(ConstString name,
- const char *description,
+bool PluginManager::RegisterPlugin(ConstString name, const char *description,
ABICreateInstance create_callback) {
- if (create_callback) {
- ABIInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- std::lock_guard<std::recursive_mutex> guard(GetABIInstancesMutex());
- GetABIInstances().push_back(instance);
- return true;
- }
- return false;
+ return GetABIInstances().RegisterPlugin(name, description, create_callback);
}
bool PluginManager::UnregisterPlugin(ABICreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(GetABIInstancesMutex());
- ABIInstances &instances = GetABIInstances();
-
- ABIInstances::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;
+ return GetABIInstances().UnregisterPlugin(create_callback);
}
ABICreateInstance PluginManager::GetABICreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetABIInstancesMutex());
- ABIInstances &instances = GetABIInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
-}
-
-ABICreateInstance
-PluginManager::GetABICreateCallbackForPluginName(ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetABIInstancesMutex());
- ABIInstances &instances = GetABIInstances();
-
- ABIInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_callback;
- }
- }
- return nullptr;
+ return GetABIInstances().GetCallbackAtIndex(idx);
}
#pragma mark Architecture
-struct ArchitectureInstance {
- ConstString name;
- std::string description;
- PluginManager::ArchitectureCreateInstance create_callback;
-};
-
+typedef PluginInstance<ArchitectureCreateInstance> ArchitectureInstance;
typedef std::vector<ArchitectureInstance> ArchitectureInstances;
-static std::mutex &GetArchitectureMutex() {
- static std::mutex g_architecture_mutex;
- return g_architecture_mutex;
-}
-
static ArchitectureInstances &GetArchitectureInstances() {
static ArchitectureInstances g_instances;
return g_instances;
@@ -298,13 +309,12 @@ static ArchitectureInstances &GetArchitectureInstances() {
void PluginManager::RegisterPlugin(ConstString name,
llvm::StringRef description,
ArchitectureCreateInstance create_callback) {
- std::lock_guard<std::mutex> guard(GetArchitectureMutex());
- GetArchitectureInstances().push_back({name, description, create_callback});
+ GetArchitectureInstances().push_back(
+ {name, std::string(description), create_callback});
}
void PluginManager::UnregisterPlugin(
ArchitectureCreateInstance create_callback) {
- std::lock_guard<std::mutex> guard(GetArchitectureMutex());
auto &instances = GetArchitectureInstances();
for (auto pos = instances.begin(), end = instances.end(); pos != end; ++pos) {
@@ -318,7 +328,6 @@ void PluginManager::UnregisterPlugin(
std::unique_ptr<Architecture>
PluginManager::CreateArchitectureInstance(const ArchSpec &arch) {
- std::lock_guard<std::mutex> guard(GetArchitectureMutex());
for (const auto &instances : GetArchitectureInstances()) {
if (auto plugin_up = instances.create_callback(arch))
return plugin_up;
@@ -328,104 +337,39 @@ PluginManager::CreateArchitectureInstance(const ArchSpec &arch) {
#pragma mark Disassembler
-struct DisassemblerInstance {
- DisassemblerInstance() : name(), description(), create_callback(nullptr) {}
-
- ConstString name;
- std::string description;
- DisassemblerCreateInstance create_callback;
-};
-
-typedef std::vector<DisassemblerInstance> DisassemblerInstances;
-
-static std::recursive_mutex &GetDisassemblerMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
+typedef PluginInstance<DisassemblerCreateInstance> DisassemblerInstance;
+typedef PluginInstances<DisassemblerInstance> DisassemblerInstances;
static DisassemblerInstances &GetDisassemblerInstances() {
static DisassemblerInstances g_instances;
return g_instances;
}
-bool PluginManager::RegisterPlugin(ConstString name,
- const char *description,
+bool PluginManager::RegisterPlugin(ConstString name, const char *description,
DisassemblerCreateInstance create_callback) {
- if (create_callback) {
- DisassemblerInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- std::lock_guard<std::recursive_mutex> guard(GetDisassemblerMutex());
- GetDisassemblerInstances().push_back(instance);
- return true;
- }
- return false;
+ return GetDisassemblerInstances().RegisterPlugin(name, description,
+ create_callback);
}
bool PluginManager::UnregisterPlugin(
DisassemblerCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(GetDisassemblerMutex());
- DisassemblerInstances &instances = GetDisassemblerInstances();
-
- DisassemblerInstances::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;
+ return GetDisassemblerInstances().UnregisterPlugin(create_callback);
}
DisassemblerCreateInstance
PluginManager::GetDisassemblerCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetDisassemblerMutex());
- DisassemblerInstances &instances = GetDisassemblerInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
+ return GetDisassemblerInstances().GetCallbackAtIndex(idx);
}
DisassemblerCreateInstance
-PluginManager::GetDisassemblerCreateCallbackForPluginName(
- ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetDisassemblerMutex());
- DisassemblerInstances &instances = GetDisassemblerInstances();
-
- DisassemblerInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_callback;
- }
- }
- return nullptr;
+PluginManager::GetDisassemblerCreateCallbackForPluginName(ConstString name) {
+ return GetDisassemblerInstances().GetCallbackForName(name);
}
#pragma mark DynamicLoader
-struct DynamicLoaderInstance {
- DynamicLoaderInstance()
- : name(), description(), create_callback(nullptr),
- debugger_init_callback(nullptr) {}
-
- ConstString name;
- std::string description;
- DynamicLoaderCreateInstance create_callback;
- DebuggerInitializeCallback debugger_init_callback;
-};
-
-typedef std::vector<DynamicLoaderInstance> DynamicLoaderInstances;
-
-static std::recursive_mutex &GetDynamicLoaderMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
+typedef PluginInstance<DynamicLoaderCreateInstance> DynamicLoaderInstance;
+typedef PluginInstances<DynamicLoaderInstance> DynamicLoaderInstances;
static DynamicLoaderInstances &GetDynamicLoaderInstances() {
static DynamicLoaderInstances g_instances;
@@ -436,81 +380,29 @@ bool PluginManager::RegisterPlugin(
ConstString name, const char *description,
DynamicLoaderCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback) {
- if (create_callback) {
- DynamicLoaderInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- instance.debugger_init_callback = debugger_init_callback;
- std::lock_guard<std::recursive_mutex> guard(GetDynamicLoaderMutex());
- GetDynamicLoaderInstances().push_back(instance);
- }
- return false;
+ return GetDynamicLoaderInstances().RegisterPlugin(
+ name, description, create_callback, debugger_init_callback);
}
bool PluginManager::UnregisterPlugin(
DynamicLoaderCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(GetDynamicLoaderMutex());
- DynamicLoaderInstances &instances = GetDynamicLoaderInstances();
-
- DynamicLoaderInstances::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;
+ return GetDynamicLoaderInstances().UnregisterPlugin(create_callback);
}
DynamicLoaderCreateInstance
PluginManager::GetDynamicLoaderCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetDynamicLoaderMutex());
- DynamicLoaderInstances &instances = GetDynamicLoaderInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
+ return GetDynamicLoaderInstances().GetCallbackAtIndex(idx);
}
DynamicLoaderCreateInstance
-PluginManager::GetDynamicLoaderCreateCallbackForPluginName(
- ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetDynamicLoaderMutex());
- DynamicLoaderInstances &instances = GetDynamicLoaderInstances();
-
- DynamicLoaderInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_callback;
- }
- }
- return nullptr;
+PluginManager::GetDynamicLoaderCreateCallbackForPluginName(ConstString name) {
+ return GetDynamicLoaderInstances().GetCallbackForName(name);
}
#pragma mark JITLoader
-struct JITLoaderInstance {
- JITLoaderInstance()
- : name(), description(), create_callback(nullptr),
- debugger_init_callback(nullptr) {}
-
- ConstString name;
- std::string description;
- JITLoaderCreateInstance create_callback;
- DebuggerInitializeCallback debugger_init_callback;
-};
-
-typedef std::vector<JITLoaderInstance> JITLoaderInstances;
-
-static std::recursive_mutex &GetJITLoaderMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
+typedef PluginInstance<JITLoaderCreateInstance> JITLoaderInstance;
+typedef PluginInstances<JITLoaderInstance> JITLoaderInstances;
static JITLoaderInstances &GetJITLoaderInstances() {
static JITLoaderInstances g_instances;
@@ -521,77 +413,24 @@ bool PluginManager::RegisterPlugin(
ConstString name, const char *description,
JITLoaderCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback) {
- if (create_callback) {
- JITLoaderInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- instance.debugger_init_callback = debugger_init_callback;
- std::lock_guard<std::recursive_mutex> guard(GetJITLoaderMutex());
- GetJITLoaderInstances().push_back(instance);
- }
- return false;
+ return GetJITLoaderInstances().RegisterPlugin(
+ name, description, create_callback, debugger_init_callback);
}
bool PluginManager::UnregisterPlugin(JITLoaderCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(GetJITLoaderMutex());
- JITLoaderInstances &instances = GetJITLoaderInstances();
-
- JITLoaderInstances::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;
+ return GetJITLoaderInstances().UnregisterPlugin(create_callback);
}
JITLoaderCreateInstance
PluginManager::GetJITLoaderCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetJITLoaderMutex());
- JITLoaderInstances &instances = GetJITLoaderInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
-}
-
-JITLoaderCreateInstance PluginManager::GetJITLoaderCreateCallbackForPluginName(
- ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetJITLoaderMutex());
- JITLoaderInstances &instances = GetJITLoaderInstances();
-
- JITLoaderInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_callback;
- }
- }
- return nullptr;
+ return GetJITLoaderInstances().GetCallbackAtIndex(idx);
}
#pragma mark EmulateInstruction
-struct EmulateInstructionInstance {
- EmulateInstructionInstance()
- : name(), description(), create_callback(nullptr) {}
-
- ConstString name;
- std::string description;
- EmulateInstructionCreateInstance create_callback;
-};
-
-typedef std::vector<EmulateInstructionInstance> EmulateInstructionInstances;
-
-static std::recursive_mutex &GetEmulateInstructionMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
+typedef PluginInstance<EmulateInstructionCreateInstance>
+ EmulateInstructionInstance;
+typedef PluginInstances<EmulateInstructionInstance> EmulateInstructionInstances;
static EmulateInstructionInstances &GetEmulateInstructionInstances() {
static EmulateInstructionInstances g_instances;
@@ -601,80 +440,30 @@ static EmulateInstructionInstances &GetEmulateInstructionInstances() {
bool PluginManager::RegisterPlugin(
ConstString name, const char *description,
EmulateInstructionCreateInstance create_callback) {
- if (create_callback) {
- EmulateInstructionInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- std::lock_guard<std::recursive_mutex> guard(GetEmulateInstructionMutex());
- GetEmulateInstructionInstances().push_back(instance);
- }
- return false;
+ return GetEmulateInstructionInstances().RegisterPlugin(name, description,
+ create_callback);
}
bool PluginManager::UnregisterPlugin(
EmulateInstructionCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(GetEmulateInstructionMutex());
- EmulateInstructionInstances &instances = GetEmulateInstructionInstances();
-
- EmulateInstructionInstances::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;
+ return GetEmulateInstructionInstances().UnregisterPlugin(create_callback);
}
EmulateInstructionCreateInstance
PluginManager::GetEmulateInstructionCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetEmulateInstructionMutex());
- EmulateInstructionInstances &instances = GetEmulateInstructionInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
+ return GetEmulateInstructionInstances().GetCallbackAtIndex(idx);
}
EmulateInstructionCreateInstance
PluginManager::GetEmulateInstructionCreateCallbackForPluginName(
ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetEmulateInstructionMutex());
- EmulateInstructionInstances &instances = GetEmulateInstructionInstances();
-
- EmulateInstructionInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_callback;
- }
- }
- return nullptr;
+ return GetEmulateInstructionInstances().GetCallbackForName(name);
}
#pragma mark OperatingSystem
-struct OperatingSystemInstance {
- 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;
-
-static std::recursive_mutex &GetOperatingSystemMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
+typedef PluginInstance<OperatingSystemCreateInstance> OperatingSystemInstance;
+typedef PluginInstances<OperatingSystemInstance> OperatingSystemInstances;
static OperatingSystemInstances &GetOperatingSystemInstances() {
static OperatingSystemInstances g_instances;
@@ -685,158 +474,70 @@ bool PluginManager::RegisterPlugin(
ConstString name, const char *description,
OperatingSystemCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback) {
- if (create_callback) {
- OperatingSystemInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- instance.debugger_init_callback = debugger_init_callback;
- std::lock_guard<std::recursive_mutex> guard(GetOperatingSystemMutex());
- GetOperatingSystemInstances().push_back(instance);
- }
- return false;
+ return GetOperatingSystemInstances().RegisterPlugin(
+ name, description, create_callback, debugger_init_callback);
}
bool PluginManager::UnregisterPlugin(
OperatingSystemCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(GetOperatingSystemMutex());
- OperatingSystemInstances &instances = GetOperatingSystemInstances();
-
- OperatingSystemInstances::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;
+ return GetOperatingSystemInstances().UnregisterPlugin(create_callback);
}
OperatingSystemCreateInstance
PluginManager::GetOperatingSystemCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetOperatingSystemMutex());
- OperatingSystemInstances &instances = GetOperatingSystemInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
+ return GetOperatingSystemInstances().GetCallbackAtIndex(idx);
}
OperatingSystemCreateInstance
-PluginManager::GetOperatingSystemCreateCallbackForPluginName(
- ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetOperatingSystemMutex());
- OperatingSystemInstances &instances = GetOperatingSystemInstances();
-
- OperatingSystemInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_callback;
- }
- }
- return nullptr;
+PluginManager::GetOperatingSystemCreateCallbackForPluginName(ConstString name) {
+ return GetOperatingSystemInstances().GetCallbackForName(name);
}
#pragma mark Language
-struct LanguageInstance {
- LanguageInstance() : name(), description(), create_callback(nullptr) {}
-
- ConstString name;
- std::string description;
- LanguageCreateInstance create_callback;
-};
-
-typedef std::vector<LanguageInstance> LanguageInstances;
-
-static std::recursive_mutex &GetLanguageMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
+typedef PluginInstance<LanguageCreateInstance> LanguageInstance;
+typedef PluginInstances<LanguageInstance> LanguageInstances;
static LanguageInstances &GetLanguageInstances() {
static LanguageInstances g_instances;
return g_instances;
}
-bool PluginManager::RegisterPlugin(ConstString name,
- const char *description,
+bool PluginManager::RegisterPlugin(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;
- std::lock_guard<std::recursive_mutex> guard(GetLanguageMutex());
- GetLanguageInstances().push_back(instance);
- }
- return false;
+ return GetLanguageInstances().RegisterPlugin(name, description,
+ create_callback);
}
bool PluginManager::UnregisterPlugin(LanguageCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(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;
+ return GetLanguageInstances().UnregisterPlugin(create_callback);
}
LanguageCreateInstance
PluginManager::GetLanguageCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetLanguageMutex());
- LanguageInstances &instances = GetLanguageInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
-}
-
-LanguageCreateInstance
-PluginManager::GetLanguageCreateCallbackForPluginName(ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(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 nullptr;
+ return GetLanguageInstances().GetCallbackAtIndex(idx);
}
#pragma mark LanguageRuntime
-struct LanguageRuntimeInstance {
- LanguageRuntimeInstance() : name(), description(), create_callback(nullptr) {}
+struct LanguageRuntimeInstance
+ : public PluginInstance<LanguageRuntimeCreateInstance> {
+ LanguageRuntimeInstance(
+ ConstString name, std::string description, CallbackType create_callback,
+ DebuggerInitializeCallback debugger_init_callback,
+ LanguageRuntimeGetCommandObject command_callback,
+ LanguageRuntimeGetExceptionPrecondition precondition_callback)
+ : PluginInstance<LanguageRuntimeCreateInstance>(
+ name, std::move(description), create_callback,
+ debugger_init_callback),
+ command_callback(command_callback),
+ precondition_callback(precondition_callback) {}
- ConstString name;
- std::string description;
- LanguageRuntimeCreateInstance create_callback;
LanguageRuntimeGetCommandObject command_callback;
LanguageRuntimeGetExceptionPrecondition precondition_callback;
};
-typedef std::vector<LanguageRuntimeInstance> LanguageRuntimeInstances;
-
-static std::recursive_mutex &GetLanguageRuntimeMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
+typedef PluginInstances<LanguageRuntimeInstance> LanguageRuntimeInstances;
static LanguageRuntimeInstances &GetLanguageRuntimeInstances() {
static LanguageRuntimeInstances g_instances;
@@ -848,51 +549,24 @@ bool PluginManager::RegisterPlugin(
LanguageRuntimeCreateInstance create_callback,
LanguageRuntimeGetCommandObject command_callback,
LanguageRuntimeGetExceptionPrecondition precondition_callback) {
- if (create_callback) {
- LanguageRuntimeInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- instance.command_callback = command_callback;
- instance.precondition_callback = precondition_callback;
- std::lock_guard<std::recursive_mutex> guard(GetLanguageRuntimeMutex());
- GetLanguageRuntimeInstances().push_back(instance);
- }
- return false;
+ return GetLanguageRuntimeInstances().RegisterPlugin(
+ name, description, create_callback, nullptr, command_callback,
+ precondition_callback);
}
bool PluginManager::UnregisterPlugin(
LanguageRuntimeCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(GetLanguageRuntimeMutex());
- LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances();
-
- LanguageRuntimeInstances::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;
+ return GetLanguageRuntimeInstances().UnregisterPlugin(create_callback);
}
LanguageRuntimeCreateInstance
PluginManager::GetLanguageRuntimeCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetLanguageRuntimeMutex());
- LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
+ return GetLanguageRuntimeInstances().GetCallbackAtIndex(idx);
}
LanguageRuntimeGetCommandObject
PluginManager::GetLanguageRuntimeGetCommandObjectAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetLanguageRuntimeMutex());
- LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances();
+ const auto &instances = GetLanguageRuntimeInstances().GetInstances();
if (idx < instances.size())
return instances[idx].command_callback;
return nullptr;
@@ -900,45 +574,16 @@ PluginManager::GetLanguageRuntimeGetCommandObjectAtIndex(uint32_t idx) {
LanguageRuntimeGetExceptionPrecondition
PluginManager::GetLanguageRuntimeGetExceptionPreconditionAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetLanguageRuntimeMutex());
- LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances();
+ const auto &instances = GetLanguageRuntimeInstances().GetInstances();
if (idx < instances.size())
return instances[idx].precondition_callback;
return nullptr;
}
-LanguageRuntimeCreateInstance
-PluginManager::GetLanguageRuntimeCreateCallbackForPluginName(
- ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetLanguageRuntimeMutex());
- LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances();
-
- LanguageRuntimeInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_callback;
- }
- }
- return nullptr;
-}
-
#pragma mark SystemRuntime
-struct SystemRuntimeInstance {
- SystemRuntimeInstance() : name(), description(), create_callback(nullptr) {}
-
- ConstString name;
- std::string description;
- SystemRuntimeCreateInstance create_callback;
-};
-
-typedef std::vector<SystemRuntimeInstance> SystemRuntimeInstances;
-
-static std::recursive_mutex &GetSystemRuntimeMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
+typedef PluginInstance<SystemRuntimeCreateInstance> SystemRuntimeInstance;
+typedef PluginInstances<SystemRuntimeInstance> SystemRuntimeInstances;
static SystemRuntimeInstances &GetSystemRuntimeInstances() {
static SystemRuntimeInstances g_instances;
@@ -948,83 +593,39 @@ static SystemRuntimeInstances &GetSystemRuntimeInstances() {
bool PluginManager::RegisterPlugin(
ConstString name, const char *description,
SystemRuntimeCreateInstance create_callback) {
- if (create_callback) {
- SystemRuntimeInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- std::lock_guard<std::recursive_mutex> guard(GetSystemRuntimeMutex());
- GetSystemRuntimeInstances().push_back(instance);
- }
- return false;
+ return GetSystemRuntimeInstances().RegisterPlugin(name, description,
+ create_callback);
}
bool PluginManager::UnregisterPlugin(
SystemRuntimeCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(GetSystemRuntimeMutex());
- SystemRuntimeInstances &instances = GetSystemRuntimeInstances();
-
- SystemRuntimeInstances::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;
+ return GetSystemRuntimeInstances().UnregisterPlugin(create_callback);
}
SystemRuntimeCreateInstance
PluginManager::GetSystemRuntimeCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetSystemRuntimeMutex());
- SystemRuntimeInstances &instances = GetSystemRuntimeInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
-}
-
-SystemRuntimeCreateInstance
-PluginManager::GetSystemRuntimeCreateCallbackForPluginName(
- ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetSystemRuntimeMutex());
- SystemRuntimeInstances &instances = GetSystemRuntimeInstances();
-
- SystemRuntimeInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_callback;
- }
- }
- return nullptr;
+ return GetSystemRuntimeInstances().GetCallbackAtIndex(idx);
}
#pragma mark ObjectFile
-struct ObjectFileInstance {
- ObjectFileInstance()
- : name(), description(), create_callback(nullptr),
- create_memory_callback(nullptr), get_module_specifications(nullptr),
- save_core(nullptr) {}
+struct ObjectFileInstance : public PluginInstance<ObjectFileCreateInstance> {
+ ObjectFileInstance(
+ ConstString name, std::string description, CallbackType create_callback,
+ ObjectFileCreateMemoryInstance create_memory_callback,
+ ObjectFileGetModuleSpecifications get_module_specifications,
+ ObjectFileSaveCore save_core)
+ : PluginInstance<ObjectFileCreateInstance>(name, std::move(description),
+ create_callback),
+ create_memory_callback(create_memory_callback),
+ get_module_specifications(get_module_specifications),
+ save_core(save_core) {}
- ConstString name;
- std::string description;
- ObjectFileCreateInstance create_callback;
ObjectFileCreateMemoryInstance create_memory_callback;
ObjectFileGetModuleSpecifications get_module_specifications;
ObjectFileSaveCore save_core;
};
-
-typedef std::vector<ObjectFileInstance> ObjectFileInstances;
-
-static std::recursive_mutex &GetObjectFileMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
+typedef PluginInstances<ObjectFileInstance> ObjectFileInstances;
static ObjectFileInstances &GetObjectFileInstances() {
static ObjectFileInstances g_instances;
@@ -1037,51 +638,23 @@ bool PluginManager::RegisterPlugin(
ObjectFileCreateMemoryInstance create_memory_callback,
ObjectFileGetModuleSpecifications get_module_specifications,
ObjectFileSaveCore save_core) {
- if (create_callback) {
- ObjectFileInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- instance.create_memory_callback = create_memory_callback;
- instance.save_core = save_core;
- instance.get_module_specifications = get_module_specifications;
- std::lock_guard<std::recursive_mutex> guard(GetObjectFileMutex());
- GetObjectFileInstances().push_back(instance);
- }
- return false;
+ return GetObjectFileInstances().RegisterPlugin(
+ name, description, create_callback, create_memory_callback,
+ get_module_specifications, save_core);
}
bool PluginManager::UnregisterPlugin(ObjectFileCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(GetObjectFileMutex());
- ObjectFileInstances &instances = GetObjectFileInstances();
-
- ObjectFileInstances::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;
+ return GetObjectFileInstances().UnregisterPlugin(create_callback);
}
ObjectFileCreateInstance
PluginManager::GetObjectFileCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetObjectFileMutex());
- ObjectFileInstances &instances = GetObjectFileInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
+ return GetObjectFileInstances().GetCallbackAtIndex(idx);
}
ObjectFileCreateMemoryInstance
PluginManager::GetObjectFileCreateMemoryCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetObjectFileMutex());
- ObjectFileInstances &instances = GetObjectFileInstances();
+ const auto &instances = GetObjectFileInstances().GetInstances();
if (idx < instances.size())
return instances[idx].create_memory_callback;
return nullptr;
@@ -1090,41 +663,21 @@ PluginManager::GetObjectFileCreateMemoryCallbackAtIndex(uint32_t idx) {
ObjectFileGetModuleSpecifications
PluginManager::GetObjectFileGetModuleSpecificationsCallbackAtIndex(
uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetObjectFileMutex());
- ObjectFileInstances &instances = GetObjectFileInstances();
+ const auto &instances = GetObjectFileInstances().GetInstances();
if (idx < instances.size())
return instances[idx].get_module_specifications;
return nullptr;
}
-ObjectFileCreateInstance
-PluginManager::GetObjectFileCreateCallbackForPluginName(
- ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetObjectFileMutex());
- ObjectFileInstances &instances = GetObjectFileInstances();
-
- ObjectFileInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_callback;
- }
- }
- return nullptr;
-}
-
ObjectFileCreateMemoryInstance
PluginManager::GetObjectFileCreateMemoryCallbackForPluginName(
ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetObjectFileMutex());
- ObjectFileInstances &instances = GetObjectFileInstances();
-
- ObjectFileInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_memory_callback;
- }
+ if (!name)
+ return nullptr;
+ const auto &instances = GetObjectFileInstances().GetInstances();
+ for (auto &instance : instances) {
+ if (instance.name == name)
+ return instance.create_memory_callback;
}
return nullptr;
}
@@ -1132,12 +685,9 @@ PluginManager::GetObjectFileCreateMemoryCallbackForPluginName(
Status PluginManager::SaveCore(const lldb::ProcessSP &process_sp,
const FileSpec &outfile) {
Status error;
- std::lock_guard<std::recursive_mutex> guard(GetObjectFileMutex());
- ObjectFileInstances &instances = GetObjectFileInstances();
-
- ObjectFileInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (pos->save_core && pos->save_core(process_sp, outfile, error))
+ auto &instances = GetObjectFileInstances().GetInstances();
+ for (auto &instance : instances) {
+ if (instance.save_core && instance.save_core(process_sp, outfile, error))
return error;
}
error.SetErrorString(
@@ -1147,23 +697,18 @@ Status PluginManager::SaveCore(const lldb::ProcessSP &process_sp,
#pragma mark ObjectContainer
-struct ObjectContainerInstance {
- ObjectContainerInstance()
- : name(), description(), create_callback(nullptr),
- get_module_specifications(nullptr) {}
+struct ObjectContainerInstance
+ : public PluginInstance<ObjectContainerCreateInstance> {
+ ObjectContainerInstance(
+ ConstString name, std::string description, CallbackType create_callback,
+ ObjectFileGetModuleSpecifications get_module_specifications)
+ : PluginInstance<ObjectContainerCreateInstance>(
+ name, std::move(description), create_callback),
+ get_module_specifications(get_module_specifications) {}
- ConstString name;
- std::string description;
- ObjectContainerCreateInstance create_callback;
ObjectFileGetModuleSpecifications get_module_specifications;
};
-
-typedef std::vector<ObjectContainerInstance> ObjectContainerInstances;
-
-static std::recursive_mutex &GetObjectContainerMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
+typedef PluginInstances<ObjectContainerInstance> ObjectContainerInstances;
static ObjectContainerInstances &GetObjectContainerInstances() {
static ObjectContainerInstances g_instances;
@@ -1174,67 +719,24 @@ bool PluginManager::RegisterPlugin(
ConstString name, const char *description,
ObjectContainerCreateInstance create_callback,
ObjectFileGetModuleSpecifications get_module_specifications) {
- if (create_callback) {
- ObjectContainerInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- instance.get_module_specifications = get_module_specifications;
- std::lock_guard<std::recursive_mutex> guard(GetObjectContainerMutex());
- GetObjectContainerInstances().push_back(instance);
- }
- return false;
+ return GetObjectContainerInstances().RegisterPlugin(
+ name, description, create_callback, get_module_specifications);
}
bool PluginManager::UnregisterPlugin(
ObjectContainerCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(GetObjectContainerMutex());
- ObjectContainerInstances &instances = GetObjectContainerInstances();
-
- ObjectContainerInstances::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;
+ return GetObjectContainerInstances().UnregisterPlugin(create_callback);
}
ObjectContainerCreateInstance
PluginManager::GetObjectContainerCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetObjectContainerMutex());
- ObjectContainerInstances &instances = GetObjectContainerInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
-}
-
-ObjectContainerCreateInstance
-PluginManager::GetObjectContainerCreateCallbackForPluginName(
- ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetObjectContainerMutex());
- ObjectContainerInstances &instances = GetObjectContainerInstances();
-
- ObjectContainerInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_callback;
- }
- }
- return nullptr;
+ return GetObjectContainerInstances().GetCallbackAtIndex(idx);
}
ObjectFileGetModuleSpecifications
PluginManager::GetObjectContainerGetModuleSpecificationsCallbackAtIndex(
uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetObjectContainerMutex());
- ObjectContainerInstances &instances = GetObjectContainerInstances();
+ const auto &instances = GetObjectContainerInstances().GetInstances();
if (idx < instances.size())
return instances[idx].get_module_specifications;
return nullptr;
@@ -1242,23 +744,8 @@ PluginManager::GetObjectContainerGetModuleSpecificationsCallbackAtIndex(
#pragma mark Platform
-struct PlatformInstance {
- PlatformInstance()
- : name(), description(), create_callback(nullptr),
- debugger_init_callback(nullptr) {}
-
- ConstString name;
- std::string description;
- PlatformCreateInstance create_callback;
- DebuggerInitializeCallback debugger_init_callback;
-};
-
-typedef std::vector<PlatformInstance> PlatformInstances;
-
-static std::recursive_mutex &GetPlatformInstancesMutex() {
- static std::recursive_mutex g_platform_instances_mutex;
- return g_platform_instances_mutex;
-}
+typedef PluginInstance<PlatformCreateInstance> PlatformInstance;
+typedef PluginInstances<PlatformInstance> PlatformInstances;
static PlatformInstances &GetPlatformInstances() {
static PlatformInstances g_platform_instances;
@@ -1269,114 +756,44 @@ bool PluginManager::RegisterPlugin(
ConstString name, const char *description,
PlatformCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(GetPlatformInstancesMutex());
+ return GetPlatformInstances().RegisterPlugin(
+ name, description, create_callback, debugger_init_callback);
+}
- PlatformInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- instance.debugger_init_callback = debugger_init_callback;
- GetPlatformInstances().push_back(instance);
- return true;
- }
- return false;
+bool PluginManager::UnregisterPlugin(PlatformCreateInstance create_callback) {
+ return GetPlatformInstances().UnregisterPlugin(create_callback);
}
const char *PluginManager::GetPlatformPluginNameAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetPlatformInstancesMutex());
- PlatformInstances &instances = GetPlatformInstances();
- if (idx < instances.size())
- return instances[idx].name.GetCString();
- return nullptr;
+ return GetPlatformInstances().GetNameAtIndex(idx);
}
const char *PluginManager::GetPlatformPluginDescriptionAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetPlatformInstancesMutex());
- PlatformInstances &instances = GetPlatformInstances();
- if (idx < instances.size())
- return instances[idx].description.c_str();
- return nullptr;
-}
-
-bool PluginManager::UnregisterPlugin(PlatformCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(GetPlatformInstancesMutex());
- PlatformInstances &instances = GetPlatformInstances();
-
- PlatformInstances::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;
+ return GetPlatformInstances().GetDescriptionAtIndex(idx);
}
PlatformCreateInstance
PluginManager::GetPlatformCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetPlatformInstancesMutex());
- PlatformInstances &instances = GetPlatformInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
+ return GetPlatformInstances().GetCallbackAtIndex(idx);
}
PlatformCreateInstance
PluginManager::GetPlatformCreateCallbackForPluginName(ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetPlatformInstancesMutex());
- PlatformInstances &instances = GetPlatformInstances();
-
- PlatformInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_callback;
- }
- }
- return nullptr;
+ return GetPlatformInstances().GetCallbackForName(name);
}
void PluginManager::AutoCompletePlatformName(llvm::StringRef name,
CompletionRequest &request) {
- if (name.empty())
- return;
-
- std::lock_guard<std::recursive_mutex> guard(GetPlatformInstancesMutex());
- PlatformInstances &instances = GetPlatformInstances();
- llvm::StringRef name_sref(name);
-
- PlatformInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- llvm::StringRef plugin_name(pos->name.GetCString());
- if (plugin_name.startswith(name_sref))
- request.AddCompletion(plugin_name.data());
+ for (const auto &instance : GetPlatformInstances().GetInstances()) {
+ if (instance.name.GetStringRef().startswith(name))
+ request.AddCompletion(instance.name.GetCString());
}
}
#pragma mark Process
-struct ProcessInstance {
- ProcessInstance()
- : name(), description(), create_callback(nullptr),
- debugger_init_callback(nullptr) {}
-
- ConstString name;
- std::string description;
- ProcessCreateInstance create_callback;
- DebuggerInitializeCallback debugger_init_callback;
-};
-
-typedef std::vector<ProcessInstance> ProcessInstances;
-
-static std::recursive_mutex &GetProcessMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
+typedef PluginInstance<ProcessCreateInstance> ProcessInstance;
+typedef PluginInstances<ProcessInstance> ProcessInstances;
static ProcessInstances &GetProcessInstances() {
static ProcessInstances g_instances;
@@ -1387,95 +804,55 @@ bool PluginManager::RegisterPlugin(
ConstString name, const char *description,
ProcessCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback) {
- if (create_callback) {
- ProcessInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- instance.debugger_init_callback = debugger_init_callback;
- std::lock_guard<std::recursive_mutex> guard(GetProcessMutex());
- GetProcessInstances().push_back(instance);
- }
- return false;
+ return GetProcessInstances().RegisterPlugin(
+ name, description, create_callback, debugger_init_callback);
}
-const char *PluginManager::GetProcessPluginNameAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetProcessMutex());
- ProcessInstances &instances = GetProcessInstances();
- if (idx < instances.size())
- return instances[idx].name.GetCString();
- return nullptr;
+bool PluginManager::UnregisterPlugin(ProcessCreateInstance create_callback) {
+ return GetProcessInstances().UnregisterPlugin(create_callback);
}
-const char *PluginManager::GetProcessPluginDescriptionAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetProcessMutex());
- ProcessInstances &instances = GetProcessInstances();
- if (idx < instances.size())
- return instances[idx].description.c_str();
- return nullptr;
+const char *PluginManager::GetProcessPluginNameAtIndex(uint32_t idx) {
+ return GetProcessInstances().GetNameAtIndex(idx);
}
-bool PluginManager::UnregisterPlugin(ProcessCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(GetProcessMutex());
- ProcessInstances &instances = GetProcessInstances();
-
- ProcessInstances::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;
+const char *PluginManager::GetProcessPluginDescriptionAtIndex(uint32_t idx) {
+ return GetProcessInstances().GetDescriptionAtIndex(idx);
}
ProcessCreateInstance
PluginManager::GetProcessCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetProcessMutex());
- ProcessInstances &instances = GetProcessInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
+ return GetProcessInstances().GetCallbackAtIndex(idx);
}
ProcessCreateInstance
PluginManager::GetProcessCreateCallbackForPluginName(ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetProcessMutex());
- ProcessInstances &instances = GetProcessInstances();
-
- ProcessInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_callback;
- }
+ return GetProcessInstances().GetCallbackForName(name);
+}
+
+void PluginManager::AutoCompleteProcessName(llvm::StringRef name,
+ CompletionRequest &request) {
+ for (const auto &instance : GetProcessInstances().GetInstances()) {
+ if (instance.name.GetStringRef().startswith(name))
+ request.AddCompletion(instance.name.GetCString(), instance.description);
}
- return nullptr;
}
#pragma mark ScriptInterpreter
-struct ScriptInterpreterInstance {
- ScriptInterpreterInstance()
- : name(), language(lldb::eScriptLanguageNone), description(),
- create_callback(nullptr) {}
+struct ScriptInterpreterInstance
+ : public PluginInstance<ScriptInterpreterCreateInstance> {
+ ScriptInterpreterInstance(ConstString name, std::string description,
+ CallbackType create_callback,
+ lldb::ScriptLanguage language)
+ : PluginInstance<ScriptInterpreterCreateInstance>(
+ name, std::move(description), create_callback),
+ language(language) {}
- ConstString name;
- lldb::ScriptLanguage language;
- std::string description;
- ScriptInterpreterCreateInstance create_callback;
+ lldb::ScriptLanguage language = lldb::eScriptLanguageNone;
};
-typedef std::vector<ScriptInterpreterInstance> ScriptInterpreterInstances;
-
-static std::recursive_mutex &GetScriptInterpreterMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
+typedef PluginInstances<ScriptInterpreterInstance> ScriptInterpreterInstances;
static ScriptInterpreterInstances &GetScriptInterpreterInstances() {
static ScriptInterpreterInstances g_instances;
@@ -1486,61 +863,31 @@ bool PluginManager::RegisterPlugin(
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;
- std::lock_guard<std::recursive_mutex> guard(GetScriptInterpreterMutex());
- GetScriptInterpreterInstances().push_back(instance);
- return false;
+ return GetScriptInterpreterInstances().RegisterPlugin(
+ name, description, create_callback, script_language);
}
bool PluginManager::UnregisterPlugin(
ScriptInterpreterCreateInstance create_callback) {
- if (!create_callback)
- return false;
- std::lock_guard<std::recursive_mutex> guard(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;
+ return GetScriptInterpreterInstances().UnregisterPlugin(create_callback);
}
ScriptInterpreterCreateInstance
PluginManager::GetScriptInterpreterCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetScriptInterpreterMutex());
- ScriptInterpreterInstances &instances = GetScriptInterpreterInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
+ return GetScriptInterpreterInstances().GetCallbackAtIndex(idx);
}
lldb::ScriptInterpreterSP
PluginManager::GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang,
Debugger &debugger) {
- std::lock_guard<std::recursive_mutex> guard(GetScriptInterpreterMutex());
- ScriptInterpreterInstances &instances = GetScriptInterpreterInstances();
-
- ScriptInterpreterInstances::iterator pos, end = instances.end();
+ const auto &instances = GetScriptInterpreterInstances().GetInstances();
ScriptInterpreterCreateInstance none_instance = nullptr;
- for (pos = instances.begin(); pos != end; ++pos) {
- if (pos->language == lldb::eScriptLanguageNone)
- none_instance = pos->create_callback;
+ for (const auto &instance : instances) {
+ if (instance.language == lldb::eScriptLanguageNone)
+ none_instance = instance.create_callback;
- if (script_lang == pos->language)
- return pos->create_callback(debugger);
+ if (script_lang == instance.language)
+ return instance.create_callback(debugger);
}
// If we didn't find one, return the ScriptInterpreter for the null language.
@@ -1548,29 +895,24 @@ PluginManager::GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang,
return none_instance(debugger);
}
-#pragma mark -
#pragma mark StructuredDataPlugin
-// StructuredDataPlugin
-
-struct StructuredDataPluginInstance {
- StructuredDataPluginInstance()
- : name(), description(), create_callback(nullptr),
- debugger_init_callback(nullptr), filter_callback(nullptr) {}
-
- ConstString name;
- std::string description;
- StructuredDataPluginCreateInstance create_callback;
- DebuggerInitializeCallback debugger_init_callback;
- StructuredDataFilterLaunchInfo filter_callback;
+struct StructuredDataPluginInstance
+ : public PluginInstance<StructuredDataPluginCreateInstance> {
+ StructuredDataPluginInstance(
+ ConstString name, std::string description, CallbackType create_callback,
+ DebuggerInitializeCallback debugger_init_callback,
+ StructuredDataFilterLaunchInfo filter_callback)
+ : PluginInstance<StructuredDataPluginCreateInstance>(
+ name, std::move(description), create_callback,
+ debugger_init_callback),
+ filter_callback(filter_callback) {}
+
+ StructuredDataFilterLaunchInfo filter_callback = nullptr;
};
-typedef std::vector<StructuredDataPluginInstance> StructuredDataPluginInstances;
-
-static std::recursive_mutex &GetStructuredDataPluginMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
+typedef PluginInstances<StructuredDataPluginInstance>
+ StructuredDataPluginInstances;
static StructuredDataPluginInstances &GetStructuredDataPluginInstances() {
static StructuredDataPluginInstances g_instances;
@@ -1582,70 +924,25 @@ bool PluginManager::RegisterPlugin(
StructuredDataPluginCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback,
StructuredDataFilterLaunchInfo filter_callback) {
- if (create_callback) {
- StructuredDataPluginInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- instance.debugger_init_callback = debugger_init_callback;
- instance.filter_callback = filter_callback;
- std::lock_guard<std::recursive_mutex> guard(GetStructuredDataPluginMutex());
- GetStructuredDataPluginInstances().push_back(instance);
- }
- return false;
+ return GetStructuredDataPluginInstances().RegisterPlugin(
+ name, description, create_callback, debugger_init_callback,
+ filter_callback);
}
bool PluginManager::UnregisterPlugin(
StructuredDataPluginCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(GetStructuredDataPluginMutex());
- StructuredDataPluginInstances &instances =
- GetStructuredDataPluginInstances();
-
- StructuredDataPluginInstances::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;
+ return GetStructuredDataPluginInstances().UnregisterPlugin(create_callback);
}
StructuredDataPluginCreateInstance
PluginManager::GetStructuredDataPluginCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetStructuredDataPluginMutex());
- StructuredDataPluginInstances &instances = GetStructuredDataPluginInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
-}
-
-StructuredDataPluginCreateInstance
-PluginManager::GetStructuredDataPluginCreateCallbackForPluginName(
- ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetStructuredDataPluginMutex());
- StructuredDataPluginInstances &instances =
- GetStructuredDataPluginInstances();
-
- StructuredDataPluginInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_callback;
- }
- }
- return nullptr;
+ return GetStructuredDataPluginInstances().GetCallbackAtIndex(idx);
}
StructuredDataFilterLaunchInfo
PluginManager::GetStructuredDataFilterCallbackAtIndex(
uint32_t idx, bool &iteration_complete) {
- std::lock_guard<std::recursive_mutex> guard(GetStructuredDataPluginMutex());
- StructuredDataPluginInstances &instances = GetStructuredDataPluginInstances();
+ const auto &instances = GetStructuredDataPluginInstances().GetInstances();
if (idx < instances.size()) {
iteration_complete = false;
return instances[idx].filter_callback;
@@ -1657,23 +954,8 @@ PluginManager::GetStructuredDataFilterCallbackAtIndex(
#pragma mark SymbolFile
-struct SymbolFileInstance {
- SymbolFileInstance()
- : name(), description(), create_callback(nullptr),
- debugger_init_callback(nullptr) {}
-
- ConstString name;
- std::string description;
- SymbolFileCreateInstance create_callback;
- DebuggerInitializeCallback debugger_init_callback;
-};
-
-typedef std::vector<SymbolFileInstance> SymbolFileInstances;
-
-static std::recursive_mutex &GetSymbolFileMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
+typedef PluginInstance<SymbolFileCreateInstance> SymbolFileInstance;
+typedef PluginInstances<SymbolFileInstance> SymbolFileInstances;
static SymbolFileInstances &GetSymbolFileInstances() {
static SymbolFileInstances g_instances;
@@ -1684,157 +966,49 @@ bool PluginManager::RegisterPlugin(
ConstString name, const char *description,
SymbolFileCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback) {
- if (create_callback) {
- SymbolFileInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- instance.debugger_init_callback = debugger_init_callback;
- std::lock_guard<std::recursive_mutex> guard(GetSymbolFileMutex());
- GetSymbolFileInstances().push_back(instance);
- }
- return false;
+ return GetSymbolFileInstances().RegisterPlugin(
+ name, description, create_callback, debugger_init_callback);
}
bool PluginManager::UnregisterPlugin(SymbolFileCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(GetSymbolFileMutex());
- SymbolFileInstances &instances = GetSymbolFileInstances();
-
- SymbolFileInstances::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;
+ return GetSymbolFileInstances().UnregisterPlugin(create_callback);
}
SymbolFileCreateInstance
PluginManager::GetSymbolFileCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetSymbolFileMutex());
- SymbolFileInstances &instances = GetSymbolFileInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
-}
-
-SymbolFileCreateInstance
-PluginManager::GetSymbolFileCreateCallbackForPluginName(
- ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetSymbolFileMutex());
- SymbolFileInstances &instances = GetSymbolFileInstances();
-
- SymbolFileInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_callback;
- }
- }
- return nullptr;
+ return GetSymbolFileInstances().GetCallbackAtIndex(idx);
}
#pragma mark SymbolVendor
-struct SymbolVendorInstance {
- SymbolVendorInstance() : name(), description(), create_callback(nullptr) {}
-
- ConstString name;
- std::string description;
- SymbolVendorCreateInstance create_callback;
-};
-
-typedef std::vector<SymbolVendorInstance> SymbolVendorInstances;
-
-static std::recursive_mutex &GetSymbolVendorMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
+typedef PluginInstance<SymbolVendorCreateInstance> SymbolVendorInstance;
+typedef PluginInstances<SymbolVendorInstance> SymbolVendorInstances;
static SymbolVendorInstances &GetSymbolVendorInstances() {
static SymbolVendorInstances g_instances;
return g_instances;
}
-bool PluginManager::RegisterPlugin(ConstString name,
- const char *description,
+bool PluginManager::RegisterPlugin(ConstString name, const char *description,
SymbolVendorCreateInstance create_callback) {
- if (create_callback) {
- SymbolVendorInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- std::lock_guard<std::recursive_mutex> guard(GetSymbolVendorMutex());
- GetSymbolVendorInstances().push_back(instance);
- }
- return false;
+ return GetSymbolVendorInstances().RegisterPlugin(name, description,
+ create_callback);
}
bool PluginManager::UnregisterPlugin(
SymbolVendorCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(GetSymbolVendorMutex());
- SymbolVendorInstances &instances = GetSymbolVendorInstances();
-
- SymbolVendorInstances::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;
+ return GetSymbolVendorInstances().UnregisterPlugin(create_callback);
}
SymbolVendorCreateInstance
PluginManager::GetSymbolVendorCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetSymbolVendorMutex());
- SymbolVendorInstances &instances = GetSymbolVendorInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
-}
-
-SymbolVendorCreateInstance
-PluginManager::GetSymbolVendorCreateCallbackForPluginName(
- ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetSymbolVendorMutex());
- SymbolVendorInstances &instances = GetSymbolVendorInstances();
-
- SymbolVendorInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_callback;
- }
- }
- return nullptr;
+ return GetSymbolVendorInstances().GetCallbackAtIndex(idx);
}
#pragma mark UnwindAssembly
-struct UnwindAssemblyInstance {
- UnwindAssemblyInstance() : name(), description(), create_callback(nullptr) {}
-
- ConstString name;
- std::string description;
- UnwindAssemblyCreateInstance create_callback;
-};
-
-typedef std::vector<UnwindAssemblyInstance> UnwindAssemblyInstances;
-
-static std::recursive_mutex &GetUnwindAssemblyMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
+typedef PluginInstance<UnwindAssemblyCreateInstance> UnwindAssemblyInstance;
+typedef PluginInstances<UnwindAssemblyInstance> UnwindAssemblyInstances;
static UnwindAssemblyInstances &GetUnwindAssemblyInstances() {
static UnwindAssemblyInstances g_instances;
@@ -1844,77 +1018,24 @@ static UnwindAssemblyInstances &GetUnwindAssemblyInstances() {
bool PluginManager::RegisterPlugin(
ConstString name, const char *description,
UnwindAssemblyCreateInstance create_callback) {
- if (create_callback) {
- UnwindAssemblyInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- std::lock_guard<std::recursive_mutex> guard(GetUnwindAssemblyMutex());
- GetUnwindAssemblyInstances().push_back(instance);
- }
- return false;
+ return GetUnwindAssemblyInstances().RegisterPlugin(name, description,
+ create_callback);
}
bool PluginManager::UnregisterPlugin(
UnwindAssemblyCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(GetUnwindAssemblyMutex());
- UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances();
-
- UnwindAssemblyInstances::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;
+ return GetUnwindAssemblyInstances().UnregisterPlugin(create_callback);
}
UnwindAssemblyCreateInstance
PluginManager::GetUnwindAssemblyCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetUnwindAssemblyMutex());
- UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
-}
-
-UnwindAssemblyCreateInstance
-PluginManager::GetUnwindAssemblyCreateCallbackForPluginName(
- ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetUnwindAssemblyMutex());
- UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances();
-
- UnwindAssemblyInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_callback;
- }
- }
- return nullptr;
+ return GetUnwindAssemblyInstances().GetCallbackAtIndex(idx);
}
#pragma mark MemoryHistory
-struct MemoryHistoryInstance {
- MemoryHistoryInstance() : name(), description(), create_callback(nullptr) {}
-
- ConstString name;
- std::string description;
- MemoryHistoryCreateInstance create_callback;
-};
-
-typedef std::vector<MemoryHistoryInstance> MemoryHistoryInstances;
-
-static std::recursive_mutex &GetMemoryHistoryMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
+typedef PluginInstance<MemoryHistoryCreateInstance> MemoryHistoryInstance;
+typedef PluginInstances<MemoryHistoryInstance> MemoryHistoryInstances;
static MemoryHistoryInstances &GetMemoryHistoryInstances() {
static MemoryHistoryInstances g_instances;
@@ -1924,81 +1045,37 @@ static MemoryHistoryInstances &GetMemoryHistoryInstances() {
bool PluginManager::RegisterPlugin(
ConstString name, const char *description,
MemoryHistoryCreateInstance create_callback) {
- if (create_callback) {
- MemoryHistoryInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- std::lock_guard<std::recursive_mutex> guard(GetMemoryHistoryMutex());
- GetMemoryHistoryInstances().push_back(instance);
- }
- return false;
+ return GetMemoryHistoryInstances().RegisterPlugin(name, description,
+ create_callback);
}
bool PluginManager::UnregisterPlugin(
MemoryHistoryCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(GetMemoryHistoryMutex());
- MemoryHistoryInstances &instances = GetMemoryHistoryInstances();
-
- MemoryHistoryInstances::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;
+ return GetMemoryHistoryInstances().UnregisterPlugin(create_callback);
}
MemoryHistoryCreateInstance
PluginManager::GetMemoryHistoryCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetMemoryHistoryMutex());
- MemoryHistoryInstances &instances = GetMemoryHistoryInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
-}
-
-MemoryHistoryCreateInstance
-PluginManager::GetMemoryHistoryCreateCallbackForPluginName(
- ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(GetMemoryHistoryMutex());
- MemoryHistoryInstances &instances = GetMemoryHistoryInstances();
-
- MemoryHistoryInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_callback;
- }
- }
- return nullptr;
+ return GetMemoryHistoryInstances().GetCallbackAtIndex(idx);
}
#pragma mark InstrumentationRuntime
-struct InstrumentationRuntimeInstance {
- InstrumentationRuntimeInstance()
- : name(), description(), create_callback(nullptr) {}
+struct InstrumentationRuntimeInstance
+ : public PluginInstance<InstrumentationRuntimeCreateInstance> {
+ InstrumentationRuntimeInstance(
+ ConstString name, std::string description, CallbackType create_callback,
+ InstrumentationRuntimeGetType get_type_callback)
+ : PluginInstance<InstrumentationRuntimeCreateInstance>(
+ name, std::move(description), create_callback),
+ get_type_callback(get_type_callback) {}
- ConstString name;
- std::string description;
- InstrumentationRuntimeCreateInstance create_callback;
- InstrumentationRuntimeGetType get_type_callback;
+ InstrumentationRuntimeGetType get_type_callback = nullptr;
};
-typedef std::vector<InstrumentationRuntimeInstance>
+typedef PluginInstances<InstrumentationRuntimeInstance>
InstrumentationRuntimeInstances;
-static std::recursive_mutex &GetInstrumentationRuntimeMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
-
static InstrumentationRuntimeInstances &GetInstrumentationRuntimeInstances() {
static InstrumentationRuntimeInstances g_instances;
return g_instances;
@@ -2008,45 +1085,18 @@ bool PluginManager::RegisterPlugin(
ConstString name, const char *description,
InstrumentationRuntimeCreateInstance create_callback,
InstrumentationRuntimeGetType get_type_callback) {
- if (create_callback) {
- InstrumentationRuntimeInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- instance.get_type_callback = get_type_callback;
- std::lock_guard<std::recursive_mutex> guard(
- GetInstrumentationRuntimeMutex());
- GetInstrumentationRuntimeInstances().push_back(instance);
- }
- return false;
+ return GetInstrumentationRuntimeInstances().RegisterPlugin(
+ name, description, create_callback, get_type_callback);
}
bool PluginManager::UnregisterPlugin(
InstrumentationRuntimeCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(
- GetInstrumentationRuntimeMutex());
- InstrumentationRuntimeInstances &instances =
- GetInstrumentationRuntimeInstances();
-
- InstrumentationRuntimeInstances::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;
+ return GetInstrumentationRuntimeInstances().UnregisterPlugin(create_callback);
}
InstrumentationRuntimeGetType
PluginManager::GetInstrumentationRuntimeGetTypeCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetInstrumentationRuntimeMutex());
- InstrumentationRuntimeInstances &instances =
- GetInstrumentationRuntimeInstances();
+ const auto &instances = GetInstrumentationRuntimeInstances().GetInstances();
if (idx < instances.size())
return instances[idx].get_type_callback;
return nullptr;
@@ -2054,48 +1104,27 @@ PluginManager::GetInstrumentationRuntimeGetTypeCallbackAtIndex(uint32_t idx) {
InstrumentationRuntimeCreateInstance
PluginManager::GetInstrumentationRuntimeCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetInstrumentationRuntimeMutex());
- InstrumentationRuntimeInstances &instances =
- GetInstrumentationRuntimeInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
-}
-
-InstrumentationRuntimeCreateInstance
-PluginManager::GetInstrumentationRuntimeCreateCallbackForPluginName(
- ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(
- GetInstrumentationRuntimeMutex());
- InstrumentationRuntimeInstances &instances =
- GetInstrumentationRuntimeInstances();
-
- InstrumentationRuntimeInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (name == pos->name)
- return pos->create_callback;
- }
- }
- return nullptr;
+ return GetInstrumentationRuntimeInstances().GetCallbackAtIndex(idx);
}
#pragma mark TypeSystem
-struct TypeSystemInstance {
- ConstString name;
- std::string description;
- TypeSystemCreateInstance create_callback;
+struct TypeSystemInstance : public PluginInstance<TypeSystemCreateInstance> {
+ TypeSystemInstance(ConstString name, std::string description,
+ CallbackType create_callback,
+ LanguageSet supported_languages_for_types,
+ LanguageSet supported_languages_for_expressions)
+ : PluginInstance<TypeSystemCreateInstance>(name, std::move(description),
+ create_callback),
+ supported_languages_for_types(supported_languages_for_types),
+ supported_languages_for_expressions(
+ supported_languages_for_expressions) {}
+
LanguageSet supported_languages_for_types;
LanguageSet supported_languages_for_expressions;
};
-typedef std::vector<TypeSystemInstance> TypeSystemInstances;
-
-static std::recursive_mutex &GetTypeSystemMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
+typedef PluginInstances<TypeSystemInstance> TypeSystemInstances;
static TypeSystemInstances &GetTypeSystemInstances() {
static TypeSystemInstances g_instances;
@@ -2107,75 +1136,31 @@ bool PluginManager::RegisterPlugin(
TypeSystemCreateInstance create_callback,
LanguageSet supported_languages_for_types,
LanguageSet supported_languages_for_expressions) {
- if (create_callback) {
- TypeSystemInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- instance.supported_languages_for_types = supported_languages_for_types;
- instance.supported_languages_for_expressions = supported_languages_for_expressions;
- std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
- GetTypeSystemInstances().push_back(instance);
- }
- return false;
+ return GetTypeSystemInstances().RegisterPlugin(
+ name, description, create_callback, supported_languages_for_types,
+ supported_languages_for_expressions);
}
bool PluginManager::UnregisterPlugin(TypeSystemCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(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;
+ return GetTypeSystemInstances().UnregisterPlugin(create_callback);
}
TypeSystemCreateInstance
PluginManager::GetTypeSystemCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
- TypeSystemInstances &instances = GetTypeSystemInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
-}
-
-TypeSystemCreateInstance
-PluginManager::GetTypeSystemCreateCallbackForPluginName(
- ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(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 nullptr;
+ return GetTypeSystemInstances().GetCallbackAtIndex(idx);
}
LanguageSet PluginManager::GetAllTypeSystemSupportedLanguagesForTypes() {
- std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
+ const auto &instances = GetTypeSystemInstances().GetInstances();
LanguageSet all;
- TypeSystemInstances &instances = GetTypeSystemInstances();
for (unsigned i = 0; i < instances.size(); ++i)
all.bitvector |= instances[i].supported_languages_for_types.bitvector;
return all;
}
LanguageSet PluginManager::GetAllTypeSystemSupportedLanguagesForExpressions() {
- std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
+ const auto &instances = GetTypeSystemInstances().GetInstances();
LanguageSet all;
- TypeSystemInstances &instances = GetTypeSystemInstances();
for (unsigned i = 0; i < instances.size(); ++i)
all.bitvector |= instances[i].supported_languages_for_expressions.bitvector;
return all;
@@ -2183,21 +1168,17 @@ LanguageSet PluginManager::GetAllTypeSystemSupportedLanguagesForExpressions() {
#pragma mark REPL
-struct REPLInstance {
- REPLInstance() : name(), description(), create_callback(nullptr) {}
+struct REPLInstance : public PluginInstance<REPLCreateInstance> {
+ REPLInstance(ConstString name, std::string description,
+ CallbackType create_callback, LanguageSet supported_languages)
+ : PluginInstance<REPLCreateInstance>(name, std::move(description),
+ create_callback),
+ supported_languages(supported_languages) {}
- ConstString name;
- std::string description;
- REPLCreateInstance create_callback;
LanguageSet supported_languages;
};
-typedef std::vector<REPLInstance> REPLInstances;
-
-static std::recursive_mutex &GetREPLMutex() {
- static std::recursive_mutex g_instances_mutex;
- return g_instances_mutex;
-}
+typedef PluginInstances<REPLInstance> REPLInstances;
static REPLInstances &GetREPLInstances() {
static REPLInstances g_instances;
@@ -2207,63 +1188,21 @@ static REPLInstances &GetREPLInstances() {
bool PluginManager::RegisterPlugin(ConstString name, const char *description,
REPLCreateInstance create_callback,
LanguageSet supported_languages) {
- if (create_callback) {
- REPLInstance instance;
- assert((bool)name);
- instance.name = name;
- if (description && description[0])
- instance.description = description;
- instance.create_callback = create_callback;
- instance.supported_languages = supported_languages;
- std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
- GetREPLInstances().push_back(instance);
- }
- return false;
+ return GetREPLInstances().RegisterPlugin(name, description, create_callback,
+ supported_languages);
}
bool PluginManager::UnregisterPlugin(REPLCreateInstance create_callback) {
- if (create_callback) {
- std::lock_guard<std::recursive_mutex> guard(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;
+ return GetREPLInstances().UnregisterPlugin(create_callback);
}
REPLCreateInstance PluginManager::GetREPLCreateCallbackAtIndex(uint32_t idx) {
- std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
- REPLInstances &instances = GetREPLInstances();
- if (idx < instances.size())
- return instances[idx].create_callback;
- return nullptr;
-}
-
-REPLCreateInstance
-PluginManager::GetREPLCreateCallbackForPluginName(ConstString name) {
- if (name) {
- std::lock_guard<std::recursive_mutex> guard(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 nullptr;
+ return GetREPLInstances().GetCallbackAtIndex(idx);
}
LanguageSet PluginManager::GetREPLAllTypeSystemSupportedLanguages() {
- std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
+ const auto &instances = GetREPLInstances().GetInstances();
LanguageSet all;
- REPLInstances &instances = GetREPLInstances();
for (unsigned i = 0; i < instances.size(); ++i)
all.bitvector |= instances[i].supported_languages.bitvector;
return all;
@@ -2272,88 +1211,21 @@ LanguageSet PluginManager::GetREPLAllTypeSystemSupportedLanguages() {
#pragma mark PluginManager
void PluginManager::DebuggerInitialize(Debugger &debugger) {
- // Initialize the DynamicLoader plugins
- {
- std::lock_guard<std::recursive_mutex> guard(GetDynamicLoaderMutex());
- DynamicLoaderInstances &instances = GetDynamicLoaderInstances();
-
- DynamicLoaderInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (pos->debugger_init_callback)
- pos->debugger_init_callback(debugger);
- }
- }
-
- // Initialize the JITLoader plugins
- {
- std::lock_guard<std::recursive_mutex> guard(GetJITLoaderMutex());
- JITLoaderInstances &instances = GetJITLoaderInstances();
-
- JITLoaderInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (pos->debugger_init_callback)
- pos->debugger_init_callback(debugger);
- }
- }
-
- // Initialize the Platform plugins
- {
- std::lock_guard<std::recursive_mutex> guard(GetPlatformInstancesMutex());
- PlatformInstances &instances = GetPlatformInstances();
-
- PlatformInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (pos->debugger_init_callback)
- pos->debugger_init_callback(debugger);
- }
- }
-
- // Initialize the Process plugins
- {
- std::lock_guard<std::recursive_mutex> guard(GetProcessMutex());
- ProcessInstances &instances = GetProcessInstances();
-
- ProcessInstances::iterator pos, end = instances.end();
- for (pos = instances.begin(); pos != end; ++pos) {
- if (pos->debugger_init_callback)
- pos->debugger_init_callback(debugger);
- }
- }
-
- // Initialize the SymbolFile plugins
- {
- std::lock_guard<std::recursive_mutex> guard(GetSymbolFileMutex());
- for (auto &sym_file : GetSymbolFileInstances()) {
- if (sym_file.debugger_init_callback)
- sym_file.debugger_init_callback(debugger);
- }
- }
-
- // Initialize the OperatingSystem plugins
- {
- std::lock_guard<std::recursive_mutex> guard(GetOperatingSystemMutex());
- for (auto &os : GetOperatingSystemInstances()) {
- if (os.debugger_init_callback)
- os.debugger_init_callback(debugger);
- }
- }
-
- // Initialize the StructuredDataPlugin plugins
- {
- std::lock_guard<std::recursive_mutex> guard(GetStructuredDataPluginMutex());
- for (auto &plugin : GetStructuredDataPluginInstances()) {
- if (plugin.debugger_init_callback)
- plugin.debugger_init_callback(debugger);
- }
- }
+ GetDynamicLoaderInstances().PerformDebuggerCallback(debugger);
+ GetJITLoaderInstances().PerformDebuggerCallback(debugger);
+ GetPlatformInstances().PerformDebuggerCallback(debugger);
+ GetProcessInstances().PerformDebuggerCallback(debugger);
+ GetSymbolFileInstances().PerformDebuggerCallback(debugger);
+ GetOperatingSystemInstances().PerformDebuggerCallback(debugger);
+ GetStructuredDataPluginInstances().PerformDebuggerCallback(debugger);
}
// This is the preferred new way to register plugin specific settings. e.g.
// This will put a plugin's settings under e.g.
// "plugin.<plugin_type_name>.<plugin_type_desc>.SETTINGNAME".
-static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPlugins(
- Debugger &debugger, ConstString plugin_type_name,
- ConstString plugin_type_desc, bool can_create) {
+static lldb::OptionValuePropertiesSP
+GetDebuggerPropertyForPlugins(Debugger &debugger, ConstString plugin_type_name,
+ ConstString plugin_type_desc, bool can_create) {
lldb::OptionValuePropertiesSP parent_properties_sp(
debugger.GetValueProperties());
if (parent_properties_sp) {
@@ -2422,8 +1294,8 @@ static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPluginsOldStyle(
namespace {
typedef lldb::OptionValuePropertiesSP
-GetDebuggerPropertyForPluginsPtr(Debugger &, ConstString ,
- ConstString , bool can_create);
+GetDebuggerPropertyForPluginsPtr(Debugger &, ConstString, ConstString,
+ bool can_create);
lldb::OptionValuePropertiesSP
GetSettingForPlugin(Debugger &debugger, ConstString setting_name,
@@ -2444,8 +1316,8 @@ GetSettingForPlugin(Debugger &debugger, ConstString setting_name,
bool CreateSettingForPlugin(
Debugger &debugger, ConstString plugin_type_name,
ConstString plugin_type_desc,
- const lldb::OptionValuePropertiesSP &properties_sp,
- ConstString description, bool is_global_property,
+ const lldb::OptionValuePropertiesSP &properties_sp, ConstString description,
+ bool is_global_property,
GetDebuggerPropertyForPluginsPtr get_debugger_property =
GetDebuggerPropertyForPlugins) {
if (properties_sp) {
@@ -2471,8 +1343,9 @@ const char *kStructuredDataPluginName("structured-data");
} // anonymous namespace
-lldb::OptionValuePropertiesSP PluginManager::GetSettingForDynamicLoaderPlugin(
- Debugger &debugger, ConstString setting_name) {
+lldb::OptionValuePropertiesSP
+PluginManager::GetSettingForDynamicLoaderPlugin(Debugger &debugger,
+ ConstString setting_name) {
return GetSettingForPlugin(debugger, setting_name,
ConstString(kDynamicLoaderPluginName));
}
@@ -2551,8 +1424,9 @@ bool PluginManager::CreateSettingForJITLoaderPlugin(
static const char *kOperatingSystemPluginName("os");
-lldb::OptionValuePropertiesSP PluginManager::GetSettingForOperatingSystemPlugin(
- Debugger &debugger, ConstString setting_name) {
+lldb::OptionValuePropertiesSP
+PluginManager::GetSettingForOperatingSystemPlugin(Debugger &debugger,
+ ConstString setting_name) {
lldb::OptionValuePropertiesSP properties_sp;
lldb::OptionValuePropertiesSP plugin_type_properties_sp(
GetDebuggerPropertyForPlugins(
@@ -2583,8 +1457,9 @@ bool PluginManager::CreateSettingForOperatingSystemPlugin(
return false;
}
-lldb::OptionValuePropertiesSP PluginManager::GetSettingForStructuredDataPlugin(
- Debugger &debugger, ConstString setting_name) {
+lldb::OptionValuePropertiesSP
+PluginManager::GetSettingForStructuredDataPlugin(Debugger &debugger,
+ ConstString setting_name) {
return GetSettingForPlugin(debugger, setting_name,
ConstString(kStructuredDataPluginName));
}
diff --git a/lldb/source/Core/RichManglingContext.cpp b/lldb/source/Core/RichManglingContext.cpp
index 3d1941ebdd26..2094d96acd7c 100644
--- a/lldb/source/Core/RichManglingContext.cpp
+++ b/lldb/source/Core/RichManglingContext.cpp
@@ -1,4 +1,4 @@
-//===-- RichManglingContext.cpp ---------------------------------*- C++ -*-===//
+//===-- RichManglingContext.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Core/SearchFilter.cpp b/lldb/source/Core/SearchFilter.cpp
index 9902166be522..ea51fb379181 100644
--- a/lldb/source/Core/SearchFilter.cpp
+++ b/lldb/source/Core/SearchFilter.cpp
@@ -1,4 +1,4 @@
-//===-- SearchFilter.cpp ----------------------------------------*- C++ -*-===//
+//===-- SearchFilter.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -75,7 +75,8 @@ SearchFilter::SearchFilter(const TargetSP &target_sp, unsigned char filterType)
SearchFilter::~SearchFilter() = default;
SearchFilterSP SearchFilter::CreateFromStructuredData(
- Target &target, const StructuredData::Dictionary &filter_dict,
+ const lldb::TargetSP& target_sp,
+ const StructuredData::Dictionary &filter_dict,
Status &error) {
SearchFilterSP result_sp;
if (!filter_dict.IsValid()) {
@@ -109,19 +110,19 @@ SearchFilterSP SearchFilter::CreateFromStructuredData(
switch (filter_type) {
case Unconstrained:
result_sp = SearchFilterForUnconstrainedSearches::CreateFromStructuredData(
- target, *subclass_options, error);
+ target_sp, *subclass_options, error);
break;
case ByModule:
result_sp = SearchFilterByModule::CreateFromStructuredData(
- target, *subclass_options, error);
+ target_sp, *subclass_options, error);
break;
case ByModules:
result_sp = SearchFilterByModuleList::CreateFromStructuredData(
- target, *subclass_options, error);
+ target_sp, *subclass_options, error);
break;
case ByModulesAndCU:
result_sp = SearchFilterByModuleListAndCU::CreateFromStructuredData(
- target, *subclass_options, error);
+ target_sp, *subclass_options, error);
break;
case Exception:
error.SetErrorString("Can't serialize exception breakpoints yet.");
@@ -160,9 +161,8 @@ void SearchFilter::GetDescription(Stream *s) {}
void SearchFilter::Dump(Stream *s) const {}
-lldb::SearchFilterSP SearchFilter::CopyForBreakpoint(Breakpoint &breakpoint) {
- SearchFilterSP ret_sp = DoCopyForBreakpoint(breakpoint);
- TargetSP target_sp = breakpoint.GetTargetSP();
+lldb::SearchFilterSP SearchFilter::CreateCopy(lldb::TargetSP& target_sp) {
+ SearchFilterSP ret_sp = DoCreateCopy();
ret_sp->SetTarget(target_sp);
return ret_sp;
}
@@ -212,7 +212,7 @@ void SearchFilter::Search(Searcher &searcher) {
searcher.SearchCallback(*this, empty_sc, nullptr);
return;
}
-
+
DoModuleIteration(empty_sc, searcher);
}
@@ -362,11 +362,11 @@ Searcher::CallbackReturn SearchFilter::DoFunctionIteration(
// Selects a shared library matching a given file spec, consulting the targets
// "black list".
SearchFilterSP SearchFilterForUnconstrainedSearches::CreateFromStructuredData(
- Target &target, const StructuredData::Dictionary &data_dict,
+ const lldb::TargetSP& target_sp,
+ const StructuredData::Dictionary &data_dict,
Status &error) {
// No options for an unconstrained search.
- return std::make_shared<SearchFilterForUnconstrainedSearches>(
- target.shared_from_this());
+ return std::make_shared<SearchFilterForUnconstrainedSearches>(target_sp);
}
StructuredData::ObjectSP
@@ -390,8 +390,7 @@ bool SearchFilterForUnconstrainedSearches::ModulePasses(
return true;
}
-lldb::SearchFilterSP SearchFilterForUnconstrainedSearches::DoCopyForBreakpoint(
- Breakpoint &breakpoint) {
+SearchFilterSP SearchFilterForUnconstrainedSearches::DoCreateCopy() {
return std::make_shared<SearchFilterForUnconstrainedSearches>(*this);
}
@@ -418,12 +417,6 @@ bool SearchFilterByModule::AddressPasses(Address &address) {
return true;
}
-bool SearchFilterByModule::CompUnitPasses(FileSpec &fileSpec) { return true; }
-
-bool SearchFilterByModule::CompUnitPasses(CompileUnit &compUnit) {
- return true;
-}
-
void SearchFilterByModule::Search(Searcher &searcher) {
if (!m_target_sp)
return;
@@ -466,13 +459,13 @@ uint32_t SearchFilterByModule::GetFilterRequiredItems() {
void SearchFilterByModule::Dump(Stream *s) const {}
-lldb::SearchFilterSP
-SearchFilterByModule::DoCopyForBreakpoint(Breakpoint &breakpoint) {
+SearchFilterSP SearchFilterByModule::DoCreateCopy() {
return std::make_shared<SearchFilterByModule>(*this);
}
SearchFilterSP SearchFilterByModule::CreateFromStructuredData(
- Target &target, const StructuredData::Dictionary &data_dict,
+ const lldb::TargetSP& target_sp,
+ const StructuredData::Dictionary &data_dict,
Status &error) {
StructuredData::Array *modules_array;
bool success = data_dict.GetValueForKeyAsArray(GetKey(OptionNames::ModList),
@@ -497,8 +490,7 @@ SearchFilterSP SearchFilterByModule::CreateFromStructuredData(
}
FileSpec module_spec(module);
- return std::make_shared<SearchFilterByModule>(target.shared_from_this(),
- module_spec);
+ return std::make_shared<SearchFilterByModule>(target_sp, module_spec);
}
StructuredData::ObjectSP SearchFilterByModule::SerializeToStructuredData() {
@@ -545,14 +537,6 @@ bool SearchFilterByModuleList::AddressPasses(Address &address) {
return true;
}
-bool SearchFilterByModuleList::CompUnitPasses(FileSpec &fileSpec) {
- return true;
-}
-
-bool SearchFilterByModuleList::CompUnitPasses(CompileUnit &compUnit) {
- return true;
-}
-
void SearchFilterByModuleList::Search(Searcher &searcher) {
if (!m_target_sp)
return;
@@ -611,20 +595,20 @@ uint32_t SearchFilterByModuleList::GetFilterRequiredItems() {
void SearchFilterByModuleList::Dump(Stream *s) const {}
-lldb::SearchFilterSP
-SearchFilterByModuleList::DoCopyForBreakpoint(Breakpoint &breakpoint) {
+lldb::SearchFilterSP SearchFilterByModuleList::DoCreateCopy() {
return std::make_shared<SearchFilterByModuleList>(*this);
}
SearchFilterSP SearchFilterByModuleList::CreateFromStructuredData(
- Target &target, const StructuredData::Dictionary &data_dict,
+ const lldb::TargetSP& target_sp,
+ const StructuredData::Dictionary &data_dict,
Status &error) {
StructuredData::Array *modules_array;
bool success = data_dict.GetValueForKeyAsArray(GetKey(OptionNames::ModList),
modules_array);
if (!success)
- return std::make_shared<SearchFilterByModuleList>(target.shared_from_this(),
+ return std::make_shared<SearchFilterByModuleList>(target_sp,
FileSpecList{});
FileSpecList modules;
size_t num_modules = modules_array->GetSize();
@@ -638,8 +622,7 @@ SearchFilterSP SearchFilterByModuleList::CreateFromStructuredData(
}
modules.EmplaceBack(module);
}
- return std::make_shared<SearchFilterByModuleList>(target.shared_from_this(),
- modules);
+ return std::make_shared<SearchFilterByModuleList>(target_sp, modules);
}
void SearchFilterByModuleList::SerializeUnwrapped(
@@ -667,7 +650,8 @@ SearchFilterByModuleListAndCU::SearchFilterByModuleListAndCU(
SearchFilterByModuleListAndCU::~SearchFilterByModuleListAndCU() = default;
lldb::SearchFilterSP SearchFilterByModuleListAndCU::CreateFromStructuredData(
- Target &target, const StructuredData::Dictionary &data_dict,
+ const lldb::TargetSP& target_sp,
+ const StructuredData::Dictionary &data_dict,
Status &error) {
StructuredData::Array *modules_array = nullptr;
SearchFilterSP result_sp;
@@ -710,7 +694,7 @@ lldb::SearchFilterSP SearchFilterByModuleListAndCU::CreateFromStructuredData(
}
return std::make_shared<SearchFilterByModuleListAndCU>(
- target.shared_from_this(), modules, cus);
+ target_sp, modules, cus);
}
StructuredData::ObjectSP
@@ -832,7 +816,6 @@ uint32_t SearchFilterByModuleListAndCU::GetFilterRequiredItems() {
void SearchFilterByModuleListAndCU::Dump(Stream *s) const {}
-lldb::SearchFilterSP
-SearchFilterByModuleListAndCU::DoCopyForBreakpoint(Breakpoint &breakpoint) {
+SearchFilterSP SearchFilterByModuleListAndCU::DoCreateCopy() {
return std::make_shared<SearchFilterByModuleListAndCU>(*this);
}
diff --git a/lldb/source/Core/Section.cpp b/lldb/source/Core/Section.cpp
index 1697f1f7a5d4..9bf1c62c5ab8 100644
--- a/lldb/source/Core/Section.cpp
+++ b/lldb/source/Core/Section.cpp
@@ -1,4 +1,4 @@
-//===-- Section.cpp ---------------------------------------------*- C++ -*-===//
+//===-- Section.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -13,7 +13,6 @@
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/FileSpec.h"
-#include "lldb/Utility/Stream.h"
#include "lldb/Utility/VMRange.h"
#include <inttypes.h>
@@ -68,6 +67,8 @@ const char *Section::GetTypeAsCString() const {
return "dwarf-aranges";
case eSectionTypeDWARFDebugCuIndex:
return "dwarf-cu-index";
+ case eSectionTypeDWARFDebugTuIndex:
+ return "dwarf-tu-index";
case eSectionTypeDWARFDebugFrame:
return "dwarf-frame";
case eSectionTypeDWARFDebugInfo:
@@ -265,11 +266,8 @@ bool Section::ResolveContainedAddress(addr_t offset, Address &so_addr,
so_addr.SetOffset(offset);
so_addr.SetSection(const_cast<Section *>(this)->shared_from_this());
-#ifdef LLDB_CONFIGURATION_DEBUG
- // For debug builds, ensure that there are no orphaned (i.e., moduleless)
- // sections.
+ // Ensure that there are no orphaned (i.e., moduleless) sections.
assert(GetModule().get());
-#endif
return true;
}
@@ -284,15 +282,15 @@ bool Section::ContainsFileAddress(addr_t vm_addr) const {
return false;
}
-void Section::Dump(Stream *s, Target *target, uint32_t depth) const {
- // s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
- s->Indent();
- s->Printf("0x%8.8" PRIx64 " %-16s ", GetID(), GetTypeAsCString());
+void Section::Dump(llvm::raw_ostream &s, unsigned indent, Target *target,
+ uint32_t depth) const {
+ s.indent(indent);
+ s << llvm::format("0x%8.8" PRIx64 " %-16s ", GetID(), GetTypeAsCString());
bool resolved = true;
addr_t addr = LLDB_INVALID_ADDRESS;
if (GetByteSize() == 0)
- s->Printf("%39s", "");
+ s.indent(39);
else {
if (target)
addr = GetLoadBaseAddress(target);
@@ -304,27 +302,27 @@ void Section::Dump(Stream *s, Target *target, uint32_t depth) const {
}
VMRange range(addr, addr + m_byte_size);
- range.Dump(s->AsRawOstream(), 0);
+ range.Dump(s, 0);
}
- s->Printf("%c %c%c%c 0x%8.8" PRIx64 " 0x%8.8" PRIx64 " 0x%8.8x ",
- resolved ? ' ' : '*', m_readable ? 'r' : '-',
- m_writable ? 'w' : '-', m_executable ? 'x' : '-', m_file_offset,
- m_file_size, Get());
+ s << llvm::format("%c %c%c%c 0x%8.8" PRIx64 " 0x%8.8" PRIx64 " 0x%8.8x ",
+ resolved ? ' ' : '*', m_readable ? 'r' : '-',
+ m_writable ? 'w' : '-', m_executable ? 'x' : '-',
+ m_file_offset, m_file_size, Get());
DumpName(s);
- s->EOL();
+ s << "\n";
if (depth > 0)
- m_children.Dump(s, target, false, depth - 1);
+ m_children.Dump(s, indent, target, false, depth - 1);
}
-void Section::DumpName(Stream *s) const {
+void Section::DumpName(llvm::raw_ostream &s) const {
SectionSP parent_sp(GetParent());
if (parent_sp) {
parent_sp->DumpName(s);
- s->PutChar('.');
+ s << '.';
} else {
// The top most section prints the module basename
const char *name = nullptr;
@@ -337,9 +335,9 @@ void Section::DumpName(Stream *s) const {
if ((!name || !name[0]) && module_sp)
name = module_sp->GetFileSpec().GetFilename().AsCString();
if (name && name[0])
- s->Printf("%s.", name);
+ s << name << '.';
}
- m_name.Dump(s);
+ s << m_name;
}
bool Section::IsDescendant(const Section *section) {
@@ -569,31 +567,27 @@ bool SectionList::ContainsSection(user_id_t sect_id) const {
return FindSectionByID(sect_id).get() != nullptr;
}
-void SectionList::Dump(Stream *s, Target *target, bool show_header,
- uint32_t depth) const {
+void SectionList::Dump(llvm::raw_ostream &s, unsigned indent, Target *target,
+ bool show_header, uint32_t depth) const {
bool target_has_loaded_sections =
target && !target->GetSectionLoadList().IsEmpty();
if (show_header && !m_sections.empty()) {
- s->Indent();
- s->Printf("SectID Type %s Address "
- " Perm File Off. File Size Flags "
- " Section Name\n",
- target_has_loaded_sections ? "Load" : "File");
- s->Indent();
- s->PutCString("---------- ---------------- "
- "--------------------------------------- ---- ---------- "
- "---------- "
- "---------- ----------------------------\n");
+ s.indent(indent);
+ s << llvm::formatv(
+ "SectID Type {0} Address "
+ " Perm File Off. File Size Flags "
+ " Section Name\n",
+ target_has_loaded_sections ? "Load" : "File");
+ s.indent(indent);
+ s << "---------- ---------------- "
+ "--------------------------------------- ---- ---------- "
+ "---------- "
+ "---------- ----------------------------\n";
}
- const_iterator sect_iter;
- const_iterator end = m_sections.end();
- for (sect_iter = m_sections.begin(); sect_iter != end; ++sect_iter) {
- (*sect_iter)->Dump(s, target_has_loaded_sections ? target : nullptr, depth);
- }
-
- if (show_header && !m_sections.empty())
- s->IndentLess();
+ for (const auto &section_sp : m_sections)
+ section_sp->Dump(s, indent, target_has_loaded_sections ? target : nullptr,
+ depth);
}
size_t SectionList::Slide(addr_t slide_amount, bool slide_children) {
diff --git a/lldb/source/Core/SourceManager.cpp b/lldb/source/Core/SourceManager.cpp
index 8e0cc57f80c1..7414dd281d43 100644
--- a/lldb/source/Core/SourceManager.cpp
+++ b/lldb/source/Core/SourceManager.cpp
@@ -1,4 +1,4 @@
-//===-- SourceManager.cpp ---------------------------------------*- C++ -*-===//
+//===-- SourceManager.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -22,6 +22,7 @@
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/PathMappingList.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/AnsiTerminal.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/DataBuffer.h"
#include "lldb/Utility/DataBufferLLVM.h"
@@ -51,27 +52,24 @@ static inline bool is_newline_char(char ch) { return ch == '\n' || ch == '\r'; }
// SourceManager constructor
SourceManager::SourceManager(const TargetSP &target_sp)
- : m_last_file_sp(), m_last_line(0), m_last_count(0), m_default_set(false),
+ : m_last_line(0), m_last_count(0), m_default_set(false),
m_target_wp(target_sp),
m_debugger_wp(target_sp->GetDebugger().shared_from_this()) {}
SourceManager::SourceManager(const DebuggerSP &debugger_sp)
- : m_last_file_sp(), m_last_line(0), m_last_count(0), m_default_set(false),
- m_target_wp(), m_debugger_wp(debugger_sp) {}
+ : m_last_line(0), m_last_count(0), m_default_set(false), m_target_wp(),
+ m_debugger_wp(debugger_sp) {}
// Destructor
SourceManager::~SourceManager() {}
SourceManager::FileSP SourceManager::GetFile(const FileSpec &file_spec) {
- bool same_as_previous =
- m_last_file_sp &&
- FileSpec::Match(file_spec, m_last_file_sp->GetFileSpec());
+ if (!file_spec)
+ return nullptr;
DebuggerSP debugger_sp(m_debugger_wp.lock());
FileSP file_sp;
- if (same_as_previous)
- file_sp = m_last_file_sp;
- else if (debugger_sp)
+ if (debugger_sp && debugger_sp->GetUseSourceCache())
file_sp = debugger_sp->GetSourceFileCache().FindSourceFile(file_spec);
TargetSP target_sp(m_target_wp.lock());
@@ -94,7 +92,7 @@ SourceManager::FileSP SourceManager::GetFile(const FileSpec &file_spec) {
else
file_sp = std::make_shared<File>(file_spec, debugger_sp);
- if (debugger_sp)
+ if (debugger_sp && debugger_sp->GetUseSourceCache())
debugger_sp->GetSourceFileCache().AddSourceFile(file_sp);
}
return file_sp;
@@ -148,6 +146,10 @@ static bool should_show_stop_column_with_caret(DebuggerSP debugger_sp) {
return value == eStopShowColumnCaret;
}
+static bool should_show_stop_line_with_ansi(DebuggerSP debugger_sp) {
+ return debugger_sp && debugger_sp->GetUseColor();
+}
+
size_t SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile(
uint32_t start_line, uint32_t count, uint32_t curr_line, uint32_t column,
const char *current_line_cstr, Stream *s,
@@ -173,10 +175,10 @@ size_t SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile(
m_last_line = start_line;
m_last_count = count;
- if (m_last_file_sp.get()) {
+ if (FileSP last_file_sp = GetLastFile()) {
const uint32_t end_line = start_line + count - 1;
for (uint32_t line = start_line; line <= end_line; ++line) {
- if (!m_last_file_sp->LineIsValid(line)) {
+ if (!last_file_sp->LineIsValid(line)) {
m_last_line = UINT32_MAX;
break;
}
@@ -191,8 +193,20 @@ size_t SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile(
::snprintf(prefix, sizeof(prefix), " ");
}
- s->Printf("%s%2.2s %-4u\t", prefix,
- line == curr_line ? current_line_cstr : "", line);
+ char buffer[3];
+ sprintf(buffer, "%2.2s", (line == curr_line) ? current_line_cstr : "");
+ std::string current_line_highlight(buffer);
+
+ auto debugger_sp = m_debugger_wp.lock();
+ if (should_show_stop_line_with_ansi(debugger_sp)) {
+ current_line_highlight = ansi::FormatAnsiTerminalCodes(
+ (debugger_sp->GetStopShowLineMarkerAnsiPrefix() +
+ current_line_highlight +
+ debugger_sp->GetStopShowLineMarkerAnsiSuffix())
+ .str());
+ }
+
+ s->Printf("%s%s %-4u\t", prefix, current_line_highlight.c_str(), line);
// So far we treated column 0 as a special 'no column value', but
// DisplaySourceLines starts counting columns from 0 (and no column is
@@ -202,12 +216,12 @@ size_t SourceManager::DisplaySourceLinesWithLineNumbersUsingLastFile(
columnToHighlight = column - 1;
size_t this_line_size =
- m_last_file_sp->DisplaySourceLines(line, columnToHighlight, 0, 0, s);
+ last_file_sp->DisplaySourceLines(line, columnToHighlight, 0, 0, s);
if (column != 0 && line == curr_line &&
- should_show_stop_column_with_caret(m_debugger_wp.lock())) {
+ should_show_stop_column_with_caret(debugger_sp)) {
// Display caret cursor.
std::string src_line;
- m_last_file_sp->GetLine(line, src_line);
+ last_file_sp->GetLine(line, src_line);
s->Printf(" \t");
// Insert a space for every non-tab character in the source line.
for (size_t i = 0; i + 1 < column && i < src_line.length(); ++i)
@@ -238,10 +252,11 @@ size_t SourceManager::DisplaySourceLinesWithLineNumbers(
else
start_line = 1;
- if (m_last_file_sp.get() != file_sp.get()) {
+ FileSP last_file_sp(GetLastFile());
+ if (last_file_sp.get() != file_sp.get()) {
if (line == 0)
m_last_line = 0;
- m_last_file_sp = file_sp;
+ m_last_file_spec = file_spec;
}
return DisplaySourceLinesWithLineNumbersUsingLastFile(
start_line, count, line, column, current_line_cstr, s, bp_locs);
@@ -251,14 +266,15 @@ size_t SourceManager::DisplayMoreWithLineNumbers(
Stream *s, uint32_t count, bool reverse, const SymbolContextList *bp_locs) {
// If we get called before anybody has set a default file and line, then try
// to figure it out here.
- const bool have_default_file_line = m_last_file_sp && m_last_line > 0;
+ FileSP last_file_sp(GetLastFile());
+ const bool have_default_file_line = last_file_sp && m_last_line > 0;
if (!m_default_set) {
FileSpec tmp_spec;
uint32_t tmp_line;
GetDefaultFileAndLine(tmp_spec, tmp_line);
}
- if (m_last_file_sp) {
+ if (last_file_sp) {
if (m_last_line == UINT32_MAX)
return 0;
@@ -293,22 +309,21 @@ size_t SourceManager::DisplayMoreWithLineNumbers(
bool SourceManager::SetDefaultFileAndLine(const FileSpec &file_spec,
uint32_t line) {
- FileSP old_file_sp = m_last_file_sp;
- m_last_file_sp = GetFile(file_spec);
-
m_default_set = true;
- if (m_last_file_sp) {
+ FileSP file_sp(GetFile(file_spec));
+
+ if (file_sp) {
m_last_line = line;
+ m_last_file_spec = file_spec;
return true;
} else {
- m_last_file_sp = old_file_sp;
return false;
}
}
bool SourceManager::GetDefaultFileAndLine(FileSpec &file_spec, uint32_t &line) {
- if (m_last_file_sp) {
- file_spec = m_last_file_sp->GetFileSpec();
+ if (FileSP last_file_sp = GetLastFile()) {
+ file_spec = m_last_file_spec;
line = m_last_line;
return true;
} else if (!m_default_set) {
@@ -325,7 +340,7 @@ bool SourceManager::GetDefaultFileAndLine(FileSpec &file_spec, uint32_t &line) {
ConstString main_name("main");
bool symbols_okay = false; // Force it to be a debug symbol.
bool inlines_okay = true;
- executable_ptr->FindFunctions(main_name, nullptr,
+ executable_ptr->FindFunctions(main_name, CompilerDeclContext(),
lldb::eFunctionNameTypeBase, inlines_okay,
symbols_okay, sc_list);
size_t num_matches = sc_list.GetSize();
@@ -338,7 +353,7 @@ bool SourceManager::GetDefaultFileAndLine(FileSpec &file_spec, uint32_t &line) {
.GetBaseAddress()
.CalculateSymbolContextLineEntry(line_entry)) {
SetDefaultFileAndLine(line_entry.file, line_entry.line);
- file_spec = m_last_file_sp->GetFileSpec();
+ file_spec = m_last_file_spec;
line = m_last_line;
return true;
}
@@ -679,7 +694,7 @@ bool SourceManager::File::GetLine(uint32_t line_no, std::string &buffer) {
}
void SourceManager::SourceFileCache::AddSourceFile(const FileSP &file_sp) {
- FileSpec file_spec;
+ FileSpec file_spec = file_sp->GetFileSpec();
FileCache::iterator pos = m_file_cache.find(file_spec);
if (pos == m_file_cache.end())
m_file_cache[file_spec] = file_sp;
diff --git a/lldb/source/Core/StreamAsynchronousIO.cpp b/lldb/source/Core/StreamAsynchronousIO.cpp
index d283749144e1..04195a6d13ea 100644
--- a/lldb/source/Core/StreamAsynchronousIO.cpp
+++ b/lldb/source/Core/StreamAsynchronousIO.cpp
@@ -1,4 +1,4 @@
-//===-- StreamAsynchronousIO.cpp --------------------------------*- C++ -*-===//
+//===-- StreamAsynchronousIO.cpp ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Core/StreamFile.cpp b/lldb/source/Core/StreamFile.cpp
index 475c27ec4117..43a9df802f7e 100644
--- a/lldb/source/Core/StreamFile.cpp
+++ b/lldb/source/Core/StreamFile.cpp
@@ -1,4 +1,4 @@
-//===-- StreamFile.cpp ------------------------------------------*- C++ -*-===//
+//===-- StreamFile.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Core/UserSettingsController.cpp b/lldb/source/Core/UserSettingsController.cpp
index 3a656766dcec..b9f7d5eaa687 100644
--- a/lldb/source/Core/UserSettingsController.cpp
+++ b/lldb/source/Core/UserSettingsController.cpp
@@ -1,4 +1,4 @@
-//====-- UserSettingsController.cpp ------------------------------*- C++-*-===//
+//===-- UserSettingsController.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp
index c70ab98dcdfa..63467644cdef 100644
--- a/lldb/source/Core/Value.cpp
+++ b/lldb/source/Core/Value.cpp
@@ -1,4 +1,4 @@
-//===-- Value.cpp -----------------------------------------------*- C++ -*-===//
+//===-- Value.cpp ---------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 1dd9a6cf62c3..3a775b07e5e1 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -1,4 +1,4 @@
-//===-- ValueObject.cpp -----------------------------------------*- C++ -*-===//
+//===-- ValueObject.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -25,7 +25,6 @@
#include "lldb/DataFormatters/ValueObjectPrinter.h"
#include "lldb/Expression/ExpressionVariable.h"
#include "lldb/Host/Config.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/Declaration.h"
@@ -46,7 +45,6 @@
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Logging.h"
#include "lldb/Utility/Scalar.h"
-#include "lldb/Utility/SharingPtr.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/lldb-private-types.h"
@@ -106,12 +104,13 @@ ValueObject::ValueObject(ValueObject &parent)
// ValueObject constructor
ValueObject::ValueObject(ExecutionContextScope *exe_scope,
+ ValueObjectManager &manager,
AddressType child_ptr_or_ref_addr_type)
: UserID(++g_value_obj_uid), // Unique identifier for every value object
m_parent(nullptr), m_root(nullptr), m_update_point(exe_scope), m_name(),
m_data(), m_value(), m_error(), m_value_str(), m_old_value_str(),
m_location_str(), m_summary_str(), m_object_desc_str(),
- m_manager(), m_children(), m_synthetic_children(),
+ m_manager(&manager), m_children(), m_synthetic_children(),
m_dynamic_value(nullptr), m_synthetic_value(nullptr),
m_deref_valobj(nullptr), m_format(eFormatDefault),
m_last_format(eFormatDefault), m_last_format_mgr_revision(0),
@@ -135,65 +134,12 @@ ValueObject::ValueObject(ExecutionContextScope *exe_scope,
m_data.SetAddressByteSize(arch.GetAddressByteSize());
}
}
- m_manager = new ValueObjectManager();
m_manager->ManageObject(this);
}
// Destructor
ValueObject::~ValueObject() {}
-void ValueObject::UpdateChildrenAddressType() {
- Value::ValueType value_type = m_value.GetValueType();
- ExecutionContext exe_ctx(GetExecutionContextRef());
- Process *process = exe_ctx.GetProcessPtr();
- const bool process_is_alive = process && process->IsAlive();
- const uint32_t type_info = GetCompilerType().GetTypeInfo();
- const bool is_pointer_or_ref =
- (type_info & (lldb::eTypeIsPointer | lldb::eTypeIsReference)) != 0;
-
- switch (value_type) {
- case Value::eValueTypeFileAddress:
- // If this type is a pointer, then its children will be considered load
- // addresses if the pointer or reference is dereferenced, but only if
- // the process is alive.
- //
- // There could be global variables like in the following code:
- // struct LinkedListNode { Foo* foo; LinkedListNode* next; };
- // Foo g_foo1;
- // Foo g_foo2;
- // LinkedListNode g_second_node = { &g_foo2, NULL };
- // LinkedListNode g_first_node = { &g_foo1, &g_second_node };
- //
- // When we aren't running, we should be able to look at these variables
- // using the "target variable" command. Children of the "g_first_node"
- // always will be of the same address type as the parent. But children
- // of the "next" member of LinkedListNode will become load addresses if
- // we have a live process, or remain a file address if it was a file
- // address.
- if (process_is_alive && is_pointer_or_ref)
- SetAddressTypeOfChildren(eAddressTypeLoad);
- else
- SetAddressTypeOfChildren(eAddressTypeFile);
- break;
- case Value::eValueTypeHostAddress:
- // Same as above for load addresses, except children of pointer or refs
- // are always load addresses. Host addresses are used to store freeze
- // dried variables. If this type is a struct, the entire struct
- // contents will be copied into the heap of the
- // LLDB process, but we do not currently follow any pointers.
- if (is_pointer_or_ref)
- SetAddressTypeOfChildren(eAddressTypeLoad);
- else
- SetAddressTypeOfChildren(eAddressTypeHost);
- break;
- case Value::eValueTypeLoadAddress:
- case Value::eValueTypeScalar:
- case Value::eValueTypeVector:
- SetAddressTypeOfChildren(eAddressTypeLoad);
- break;
- }
-}
-
bool ValueObject::UpdateValueIfNeeded(bool update_format) {
bool did_change_formats = false;
@@ -416,7 +362,7 @@ const char *ValueObject::GetLocationAsCStringImpl(const Value &value,
uint32_t addr_nibble_size = data.GetAddressByteSize() * 2;
sstr.Printf("0x%*.*llx", addr_nibble_size, addr_nibble_size,
value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS));
- m_location_str = sstr.GetString();
+ m_location_str = std::string(sstr.GetString());
} break;
}
}
@@ -576,15 +522,13 @@ size_t ValueObject::GetIndexOfChildWithName(ConstString name) {
ValueObjectSP ValueObject::GetChildMemberWithName(ConstString name,
bool can_create) {
- // when getting a child by name, it could be buried inside some base classes
- // (which really aren't part of the expression path), so we need a vector of
- // indexes that can get us down to the correct child
- ValueObjectSP child_sp;
-
- // We may need to update our value if we are dynamic
+ // We may need to update our value if we are dynamic.
if (IsPossibleDynamicType())
UpdateValueIfNeeded(false);
+ // When getting a child by name, it could be buried inside some base classes
+ // (which really aren't part of the expression path), so we need a vector of
+ // indexes that can get us down to the correct child.
std::vector<uint32_t> child_indexes;
bool omit_empty_base_classes = true;
@@ -594,20 +538,13 @@ ValueObjectSP ValueObject::GetChildMemberWithName(ConstString name,
const size_t num_child_indexes =
GetCompilerType().GetIndexOfChildMemberWithName(
name.GetCString(), omit_empty_base_classes, child_indexes);
- if (num_child_indexes > 0) {
- std::vector<uint32_t>::const_iterator pos = child_indexes.begin();
- std::vector<uint32_t>::const_iterator end = child_indexes.end();
-
- child_sp = GetChildAtIndex(*pos, can_create);
- for (++pos; pos != end; ++pos) {
- if (child_sp) {
- ValueObjectSP new_child_sp(child_sp->GetChildAtIndex(*pos, can_create));
- child_sp = new_child_sp;
- } else {
- child_sp.reset();
- }
- }
- }
+ if (num_child_indexes == 0)
+ return nullptr;
+
+ ValueObjectSP child_sp = GetSP();
+ for (uint32_t idx : child_indexes)
+ if (child_sp)
+ child_sp = child_sp->GetChildAtIndex(idx, can_create);
return child_sp;
}
@@ -689,6 +626,16 @@ ValueObject *ValueObject::CreateChildAtIndex(size_t idx,
language_flags);
}
+ // In case of an incomplete type, try to use the ValueObject's
+ // synthetic value to create the child ValueObject.
+ if (!valobj && synthetic_array_member) {
+ if (ValueObjectSP synth_valobj_sp = GetSyntheticValue()) {
+ valobj = synth_valobj_sp
+ ->GetChildAtIndex(synthetic_index, synthetic_array_member)
+ .get();
+ }
+ }
+
return valobj;
}
@@ -766,7 +713,7 @@ bool ValueObject::IsCStringContainer(bool check_pointer) {
return true;
addr_t cstr_address = LLDB_INVALID_ADDRESS;
AddressType cstr_address_type = eAddressTypeInvalid;
- cstr_address = GetAddressOf(true, &cstr_address_type);
+ cstr_address = GetPointerValue(&cstr_address_type);
return (cstr_address != LLDB_INVALID_ADDRESS);
}
@@ -1120,7 +1067,7 @@ const char *ValueObject::GetObjectDescription() {
if (LanguageRuntime *runtime = process->GetLanguageRuntime(language)) {
StreamString s;
if (runtime->GetObjectDescription(s, *this)) {
- m_object_desc_str.append(s.GetString());
+ m_object_desc_str.append(std::string(s.GetString()));
return m_object_desc_str.c_str();
}
}
@@ -1200,6 +1147,7 @@ uint64_t ValueObject::GetValueAsUnsigned(uint64_t fail_value, bool *success) {
if (ResolveValue(scalar)) {
if (success)
*success = true;
+ scalar.MakeUnsigned();
return scalar.ULongLong(fail_value);
}
// fallthrough, otherwise...
@@ -1217,6 +1165,7 @@ int64_t ValueObject::GetValueAsSigned(int64_t fail_value, bool *success) {
if (ResolveValue(scalar)) {
if (success)
*success = true;
+ scalar.MakeSigned();
return scalar.SLongLong(fail_value);
}
// fallthrough, otherwise...
@@ -1447,7 +1396,7 @@ bool ValueObject::DumpPrintableRepresentation(
break;
case eValueObjectRepresentationStyleExpressionPath:
- GetExpressionPath(strm, false);
+ GetExpressionPath(strm);
str = strm.GetString();
break;
}
@@ -1553,7 +1502,7 @@ addr_t ValueObject::GetPointerValue(AddressType *address_type) {
case Value::eValueTypeLoadAddress:
case Value::eValueTypeFileAddress: {
lldb::offset_t data_offset = 0;
- address = m_data.GetPointer(&data_offset);
+ address = m_data.GetAddress(&data_offset);
} break;
}
@@ -1652,13 +1601,13 @@ bool ValueObject::GetDeclaration(Declaration &decl) {
}
ConstString ValueObject::GetTypeName() {
- return GetCompilerType().GetConstTypeName();
+ return GetCompilerType().GetTypeName();
}
ConstString ValueObject::GetDisplayTypeName() { return GetTypeName(); }
ConstString ValueObject::GetQualifiedTypeName() {
- return GetCompilerType().GetConstQualifiedTypeName();
+ return GetCompilerType().GetTypeName();
}
LanguageType ValueObject::GetObjectRuntimeLanguage() {
@@ -1720,7 +1669,7 @@ bool ValueObject::IsRuntimeSupportValue() {
return false;
if (auto *runtime = process->GetLanguageRuntime(GetVariable()->GetLanguage()))
- if (runtime->IsWhitelistedRuntimeValue(GetName()))
+ if (runtime->IsAllowedRuntimeValue(GetName()))
return false;
return true;
@@ -1935,10 +1884,7 @@ ValueObject::GetSyntheticExpressionPathChild(const char *expression,
return synthetic_child_sp;
}
-void ValueObject::CalculateSyntheticValue(bool use_synthetic) {
- if (!use_synthetic)
- return;
-
+void ValueObject::CalculateSyntheticValue() {
TargetSP target_sp(GetTargetSP());
if (target_sp && !target_sp->GetEnableSyntheticValue()) {
m_synthetic_value = nullptr;
@@ -1990,11 +1936,8 @@ ValueObjectSP ValueObject::GetStaticValue() { return GetSP(); }
lldb::ValueObjectSP ValueObject::GetNonSyntheticValue() { return GetSP(); }
-ValueObjectSP ValueObject::GetSyntheticValue(bool use_synthetic) {
- if (!use_synthetic)
- return ValueObjectSP();
-
- CalculateSyntheticValue(use_synthetic);
+ValueObjectSP ValueObject::GetSyntheticValue() {
+ CalculateSyntheticValue();
if (m_synthetic_value)
return m_synthetic_value->GetSP();
@@ -2008,28 +1951,11 @@ bool ValueObject::HasSyntheticValue() {
if (m_synthetic_children_sp.get() == nullptr)
return false;
- CalculateSyntheticValue(true);
+ CalculateSyntheticValue();
return m_synthetic_value != nullptr;
}
-bool ValueObject::GetBaseClassPath(Stream &s) {
- if (IsBaseClass()) {
- bool parent_had_base_class =
- GetParent() && GetParent()->GetBaseClassPath(s);
- CompilerType compiler_type = GetCompilerType();
- llvm::Optional<std::string> cxx_class_name =
- ClangASTContext::GetCXXClassName(compiler_type);
- if (cxx_class_name) {
- if (parent_had_base_class)
- s.PutCString("::");
- s.PutCString(cxx_class_name.getValue());
- }
- return parent_had_base_class || cxx_class_name;
- }
- return false;
-}
-
ValueObject *ValueObject::GetNonBaseClassParent() {
if (GetParent()) {
if (GetParent()->IsBaseClass())
@@ -2055,7 +1981,7 @@ bool ValueObject::IsBaseClass(uint32_t &depth) {
return true;
}
-void ValueObject::GetExpressionPath(Stream &s, bool qualify_cxx_base_classes,
+void ValueObject::GetExpressionPath(Stream &s,
GetExpressionPathFormat epformat) {
// synthetic children do not actually "exist" as part of the hierarchy, and
// sometimes they are consed up in ways that don't make sense from an
@@ -2104,14 +2030,14 @@ void ValueObject::GetExpressionPath(Stream &s, bool qualify_cxx_base_classes,
ValueObject *parent = GetParent();
if (parent)
- parent->GetExpressionPath(s, qualify_cxx_base_classes, epformat);
+ parent->GetExpressionPath(s, epformat);
// if we are a deref_of_parent just because we are synthetic array members
// made up to allow ptr[%d] syntax to work in variable printing, then add our
// name ([%d]) to the expression path
if (m_is_array_item_for_pointer &&
epformat == eGetExpressionPathFormatHonorPointers)
- s.PutCString(m_name.AsCString());
+ s.PutCString(m_name.GetStringRef());
if (!IsBaseClass()) {
if (!is_deref_of_parent) {
@@ -2139,13 +2065,8 @@ void ValueObject::GetExpressionPath(Stream &s, bool qualify_cxx_base_classes,
}
const char *name = GetName().GetCString();
- if (name) {
- if (qualify_cxx_base_classes) {
- if (GetBaseClassPath(s))
- s.PutCString("::");
- }
+ if (name)
s.PutCString(name);
- }
}
}
@@ -2834,7 +2755,7 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
const bool transparent_pointers = false;
CompilerType compiler_type = GetCompilerType();
CompilerType child_compiler_type;
- uint64_t language_flags;
+ uint64_t language_flags = 0;
ExecutionContext exe_ctx(GetExecutionContextRef());
@@ -2854,11 +2775,35 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
child_is_base_class, child_is_deref_of_parent, eAddressTypeInvalid,
language_flags);
}
+
+ // In case of incomplete child compiler type, use the pointee type and try
+ // to recreate a new ValueObjectChild using it.
+ if (!m_deref_valobj) {
+ if (HasSyntheticValue()) {
+ child_compiler_type = compiler_type.GetPointeeType();
+
+ if (child_compiler_type) {
+ ConstString child_name;
+ if (!child_name_str.empty())
+ child_name.SetCString(child_name_str.c_str());
+
+ m_deref_valobj = new ValueObjectChild(
+ *this, 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, eAddressTypeInvalid, language_flags);
+ }
+ }
+ }
+
} else if (HasSyntheticValue()) {
m_deref_valobj =
GetSyntheticValue()
->GetChildMemberWithName(ConstString("$$dereference$$"), true)
.get();
+ } else if (IsSynthetic()) {
+ m_deref_valobj =
+ GetChildMemberWithName(ConstString("$$dereference$$"), true).get();
}
if (m_deref_valobj) {
@@ -2866,7 +2811,7 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
return m_deref_valobj->GetSP();
} else {
StreamString strm;
- GetExpressionPath(strm, true);
+ GetExpressionPath(strm);
if (is_pointer_or_reference_type)
error.SetErrorStringWithFormat("dereference failed: (%s) %s",
@@ -2892,7 +2837,7 @@ ValueObjectSP ValueObject::AddressOf(Status &error) {
switch (address_type) {
case eAddressTypeInvalid: {
StreamString expr_path_strm;
- GetExpressionPath(expr_path_strm, true);
+ GetExpressionPath(expr_path_strm);
error.SetErrorStringWithFormat("'%s' is not in memory",
expr_path_strm.GetData());
} break;
@@ -2915,7 +2860,7 @@ ValueObjectSP ValueObject::AddressOf(Status &error) {
}
} else {
StreamString expr_path_strm;
- GetExpressionPath(expr_path_strm, true);
+ GetExpressionPath(expr_path_strm);
error.SetErrorStringWithFormat("'%s' doesn't have a valid address",
expr_path_strm.GetData());
}
@@ -3291,19 +3236,17 @@ ValueObjectSP ValueObject::Persist() {
if (!persistent_state)
return nullptr;
- auto prefix = persistent_state->GetPersistentVariablePrefix();
- ConstString name =
- persistent_state->GetNextPersistentVariableName(*target_sp, prefix);
+ ConstString name = persistent_state->GetNextPersistentVariableName();
ValueObjectSP const_result_sp =
ValueObjectConstResult::Create(target_sp.get(), GetValue(), name);
- ExpressionVariableSP clang_var_sp =
+ ExpressionVariableSP persistent_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;
+ persistent_var_sp->m_live_sp = persistent_var_sp->m_frozen_sp;
+ persistent_var_sp->m_flags |= ExpressionVariable::EVIsProgramReference;
- return clang_var_sp->GetValueObject();
+ return persistent_var_sp->GetValueObject();
}
bool ValueObject::IsSyntheticChildrenGenerated() {
@@ -3364,7 +3307,7 @@ lldb::ValueObjectSP ValueObjectManager::GetSP() {
}
if (m_use_synthetic) {
- lldb::ValueObjectSP synthetic_sp = m_user_valobj_sp->GetSyntheticValue(m_use_synthetic);
+ lldb::ValueObjectSP synthetic_sp = m_user_valobj_sp->GetSyntheticValue();
if (synthetic_sp)
m_user_valobj_sp = synthetic_sp;
}
diff --git a/lldb/source/Core/ValueObjectCast.cpp b/lldb/source/Core/ValueObjectCast.cpp
index 3a74b6a7fe18..22e856be539b 100644
--- a/lldb/source/Core/ValueObjectCast.cpp
+++ b/lldb/source/Core/ValueObjectCast.cpp
@@ -1,4 +1,4 @@
-//===-- ValueObjectCast.cpp -------------------------------------*- C++ -*-===//
+//===-- ValueObjectCast.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -33,8 +33,6 @@ ValueObjectCast::ValueObjectCast(ValueObject &parent, ConstString name,
const CompilerType &cast_type)
: ValueObject(parent), m_cast_type(cast_type) {
SetName(name);
- // m_value.SetContext (Value::eContextTypeClangType,
- // cast_type.GetOpaqueQualType());
m_value.SetCompilerType(cast_type);
}
@@ -68,7 +66,6 @@ bool ValueObjectCast::UpdateValue() {
m_update_point.SetUpdated();
m_value = m_parent->GetValue();
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/lldb/source/Core/ValueObjectChild.cpp b/lldb/source/Core/ValueObjectChild.cpp
index 6b4ada154d68..6205ed32c615 100644
--- a/lldb/source/Core/ValueObjectChild.cpp
+++ b/lldb/source/Core/ValueObjectChild.cpp
@@ -1,4 +1,4 @@
-//===-- ValueObjectChild.cpp ------------------------------------*- C++ -*-===//
+//===-- ValueObjectChild.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -70,14 +70,14 @@ static void AdjustForBitfieldness(ConstString &name,
ConstString ValueObjectChild::GetTypeName() {
if (m_type_name.IsEmpty()) {
- m_type_name = GetCompilerType().GetConstTypeName();
+ m_type_name = GetCompilerType().GetTypeName();
AdjustForBitfieldness(m_type_name, m_bitfield_bit_size);
}
return m_type_name;
}
ConstString ValueObjectChild::GetQualifiedTypeName() {
- ConstString qualified_name = GetCompilerType().GetConstTypeName();
+ ConstString qualified_name = GetCompilerType().GetTypeName();
AdjustForBitfieldness(qualified_name, m_bitfield_bit_size);
return qualified_name;
}
diff --git a/lldb/source/Core/ValueObjectConstResult.cpp b/lldb/source/Core/ValueObjectConstResult.cpp
index 71620698da2a..8d84f8e62ccc 100644
--- a/lldb/source/Core/ValueObjectConstResult.cpp
+++ b/lldb/source/Core/ValueObjectConstResult.cpp
@@ -1,4 +1,4 @@
-//===-- ValueObjectConstResult.cpp ------------------------------*- C++ -*-===//
+//===-- ValueObjectConstResult.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -29,16 +29,18 @@ ValueObjectSP ValueObjectConstResult::Create(ExecutionContextScope *exe_scope,
ByteOrder byte_order,
uint32_t addr_byte_size,
lldb::addr_t address) {
- return (new ValueObjectConstResult(exe_scope, byte_order, addr_byte_size,
- address))
+ auto manager_sp = ValueObjectManager::Create();
+ return (new ValueObjectConstResult(exe_scope, *manager_sp, byte_order,
+ addr_byte_size, address))
->GetSP();
}
ValueObjectConstResult::ValueObjectConstResult(ExecutionContextScope *exe_scope,
+ ValueObjectManager &manager,
ByteOrder byte_order,
uint32_t addr_byte_size,
lldb::addr_t address)
- : ValueObject(exe_scope), m_type_name(), m_byte_size(0),
+ : ValueObject(exe_scope, manager), m_type_name(), m_byte_size(0),
m_impl(this, address) {
SetIsConstant();
SetValueIsValid(true);
@@ -52,15 +54,17 @@ ValueObjectSP ValueObjectConstResult::Create(ExecutionContextScope *exe_scope,
ConstString name,
const DataExtractor &data,
lldb::addr_t address) {
- return (new ValueObjectConstResult(exe_scope, compiler_type, name, data,
- address))
+ auto manager_sp = ValueObjectManager::Create();
+ return (new ValueObjectConstResult(exe_scope, *manager_sp, compiler_type,
+ name, data, address))
->GetSP();
}
ValueObjectConstResult::ValueObjectConstResult(
- ExecutionContextScope *exe_scope, const CompilerType &compiler_type,
- ConstString name, const DataExtractor &data, lldb::addr_t address)
- : ValueObject(exe_scope), m_type_name(), m_byte_size(0),
+ ExecutionContextScope *exe_scope, ValueObjectManager &manager,
+ const CompilerType &compiler_type, ConstString name,
+ const DataExtractor &data, lldb::addr_t address)
+ : ValueObject(exe_scope, manager), m_type_name(), m_byte_size(0),
m_impl(this, address) {
m_data = data;
@@ -86,8 +90,10 @@ ValueObjectSP ValueObjectConstResult::Create(ExecutionContextScope *exe_scope,
lldb::ByteOrder data_byte_order,
uint32_t data_addr_size,
lldb::addr_t address) {
- return (new ValueObjectConstResult(exe_scope, compiler_type, name, data_sp,
- data_byte_order, data_addr_size, address))
+ auto manager_sp = ValueObjectManager::Create();
+ return (new ValueObjectConstResult(exe_scope, *manager_sp, compiler_type,
+ name, data_sp, data_byte_order,
+ data_addr_size, address))
->GetSP();
}
@@ -95,22 +101,24 @@ ValueObjectSP ValueObjectConstResult::Create(ExecutionContextScope *exe_scope,
Value &value,
ConstString name,
Module *module) {
- return (new ValueObjectConstResult(exe_scope, value, name, module))->GetSP();
+ auto manager_sp = ValueObjectManager::Create();
+ return (new ValueObjectConstResult(exe_scope, *manager_sp, value, name,
+ module))
+ ->GetSP();
}
ValueObjectConstResult::ValueObjectConstResult(
- ExecutionContextScope *exe_scope, const CompilerType &compiler_type,
- ConstString name, const lldb::DataBufferSP &data_sp,
- lldb::ByteOrder data_byte_order, uint32_t data_addr_size,
- lldb::addr_t address)
- : ValueObject(exe_scope), m_type_name(), m_byte_size(0),
+ ExecutionContextScope *exe_scope, ValueObjectManager &manager,
+ const CompilerType &compiler_type, ConstString name,
+ const lldb::DataBufferSP &data_sp, lldb::ByteOrder data_byte_order,
+ uint32_t data_addr_size, lldb::addr_t address)
+ : ValueObject(exe_scope, manager), m_type_name(), m_byte_size(0),
m_impl(this, address) {
m_data.SetByteOrder(data_byte_order);
m_data.SetAddressByteSize(data_addr_size);
m_data.SetData(data_sp);
m_value.GetScalar() = (uintptr_t)data_sp->GetBytes();
m_value.SetValueType(Value::eValueTypeHostAddress);
- // m_value.SetContext(Value::eContextTypeClangType, compiler_type);
m_value.SetCompilerType(compiler_type);
m_name = name;
SetIsConstant();
@@ -124,16 +132,18 @@ ValueObjectSP ValueObjectConstResult::Create(ExecutionContextScope *exe_scope,
lldb::addr_t address,
AddressType address_type,
uint32_t addr_byte_size) {
- return (new ValueObjectConstResult(exe_scope, compiler_type, name, address,
- address_type, addr_byte_size))
+ auto manager_sp = ValueObjectManager::Create();
+ return (new ValueObjectConstResult(exe_scope, *manager_sp, compiler_type,
+ name, address, address_type,
+ addr_byte_size))
->GetSP();
}
ValueObjectConstResult::ValueObjectConstResult(
- ExecutionContextScope *exe_scope, const CompilerType &compiler_type,
- ConstString name, lldb::addr_t address, AddressType address_type,
- uint32_t addr_byte_size)
- : ValueObject(exe_scope), m_type_name(), m_byte_size(0),
+ ExecutionContextScope *exe_scope, ValueObjectManager &manager,
+ const CompilerType &compiler_type, ConstString name, lldb::addr_t address,
+ AddressType address_type, uint32_t addr_byte_size)
+ : ValueObject(exe_scope, manager), m_type_name(), m_byte_size(0),
m_impl(this, address) {
m_value.GetScalar() = address;
m_data.SetAddressByteSize(addr_byte_size);
@@ -153,7 +163,6 @@ ValueObjectConstResult::ValueObjectConstResult(
m_value.SetValueType(Value::eValueTypeHostAddress);
break;
}
- // m_value.SetContext(Value::eContextTypeClangType, compiler_type);
m_value.SetCompilerType(compiler_type);
m_name = name;
SetIsConstant();
@@ -163,21 +172,25 @@ ValueObjectConstResult::ValueObjectConstResult(
ValueObjectSP ValueObjectConstResult::Create(ExecutionContextScope *exe_scope,
const Status &error) {
- return (new ValueObjectConstResult(exe_scope, error))->GetSP();
+ auto manager_sp = ValueObjectManager::Create();
+ return (new ValueObjectConstResult(exe_scope, *manager_sp, error))->GetSP();
}
ValueObjectConstResult::ValueObjectConstResult(ExecutionContextScope *exe_scope,
+ ValueObjectManager &manager,
const Status &error)
- : ValueObject(exe_scope), m_type_name(), m_byte_size(0), m_impl(this) {
+ : ValueObject(exe_scope, manager), m_type_name(), m_byte_size(0),
+ m_impl(this) {
m_error = error;
SetIsConstant();
}
ValueObjectConstResult::ValueObjectConstResult(ExecutionContextScope *exe_scope,
+ ValueObjectManager &manager,
const Value &value,
- ConstString name,
- Module *module)
- : ValueObject(exe_scope), m_type_name(), m_byte_size(0), m_impl(this) {
+ ConstString name, Module *module)
+ : ValueObject(exe_scope, manager), m_type_name(), m_byte_size(0),
+ m_impl(this) {
m_value = value;
m_name = name;
ExecutionContext exe_ctx;
@@ -215,7 +228,7 @@ size_t ValueObjectConstResult::CalculateNumChildren(uint32_t max) {
ConstString ValueObjectConstResult::GetTypeName() {
if (m_type_name.IsEmpty())
- m_type_name = GetCompilerType().GetConstTypeName();
+ m_type_name = GetCompilerType().GetTypeName();
return m_type_name;
}
diff --git a/lldb/source/Core/ValueObjectConstResultCast.cpp b/lldb/source/Core/ValueObjectConstResultCast.cpp
index b47e699e30f1..53ec9db45540 100644
--- a/lldb/source/Core/ValueObjectConstResultCast.cpp
+++ b/lldb/source/Core/ValueObjectConstResultCast.cpp
@@ -1,4 +1,4 @@
-//===-- ValueObjectConstResultCast.cpp --------------------------*- C++ -*-===//
+//===-- ValueObjectConstResultCast.cpp ------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Core/ValueObjectConstResultChild.cpp b/lldb/source/Core/ValueObjectConstResultChild.cpp
index 4e0b303b69d5..13c8393d8081 100644
--- a/lldb/source/Core/ValueObjectConstResultChild.cpp
+++ b/lldb/source/Core/ValueObjectConstResultChild.cpp
@@ -1,4 +1,4 @@
-//===-- ValueObjectConstResultChild.cpp --------------------------*- C++-*-===//
+//===-- ValueObjectConstResultChild.cpp -----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Core/ValueObjectConstResultImpl.cpp b/lldb/source/Core/ValueObjectConstResultImpl.cpp
index de51735736b9..e4cbbec849ec 100644
--- a/lldb/source/Core/ValueObjectConstResultImpl.cpp
+++ b/lldb/source/Core/ValueObjectConstResultImpl.cpp
@@ -1,4 +1,4 @@
-//===-- ValueObjectConstResultImpl.cpp ---------------------------*- C++-*-===//
+//===-- ValueObjectConstResultImpl.cpp ------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -18,7 +18,6 @@
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Endian.h"
#include "lldb/Utility/Scalar.h"
-#include "lldb/Utility/SharingPtr.h"
#include <string>
diff --git a/lldb/source/Core/ValueObjectDynamicValue.cpp b/lldb/source/Core/ValueObjectDynamicValue.cpp
index 59037e2b6b25..ca66740cb55d 100644
--- a/lldb/source/Core/ValueObjectDynamicValue.cpp
+++ b/lldb/source/Core/ValueObjectDynamicValue.cpp
@@ -1,4 +1,4 @@
-//===-- ValueObjectDynamicValue.cpp ------------------------------*- C++-*-===//
+//===-- ValueObjectDynamicValue.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -237,7 +237,6 @@ bool ValueObjectDynamicValue::UpdateValue() {
m_dynamic_type_info =
runtime->FixUpDynamicType(m_dynamic_type_info, *m_parent);
- // m_value.SetContext (Value::eContextTypeClangType, corrected_type);
m_value.SetCompilerType(m_dynamic_type_info.GetCompilerType());
m_value.SetValueType(value_type);
@@ -328,7 +327,7 @@ bool ValueObjectDynamicValue::SetData(DataExtractor &data, Status &error) {
// but NULL'ing out a value should always be allowed
lldb::offset_t offset = 0;
- if (data.GetPointer(&offset) != 0) {
+ if (data.GetAddress(&offset) != 0) {
error.SetErrorString(
"unable to modify dynamic value, use 'expression' command");
return false;
diff --git a/lldb/source/Core/ValueObjectList.cpp b/lldb/source/Core/ValueObjectList.cpp
index 358a1b14517b..28907261f0a6 100644
--- a/lldb/source/Core/ValueObjectList.cpp
+++ b/lldb/source/Core/ValueObjectList.cpp
@@ -1,4 +1,4 @@
-//===-- ValueObjectList.cpp -------------------------------------*- C++ -*-===//
+//===-- ValueObjectList.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,7 +10,6 @@
#include "lldb/Core/ValueObject.h"
#include "lldb/Utility/ConstString.h"
-#include "lldb/Utility/SharingPtr.h"
#include <utility>
diff --git a/lldb/source/Core/ValueObjectMemory.cpp b/lldb/source/Core/ValueObjectMemory.cpp
index 1a316bf3e7b0..91b2c6084928 100644
--- a/lldb/source/Core/ValueObjectMemory.cpp
+++ b/lldb/source/Core/ValueObjectMemory.cpp
@@ -1,4 +1,4 @@
-//===-- ValueObjectMemory.cpp ---------------------------------*- C++ -*-===//
+//===-- ValueObjectMemory.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -32,21 +32,27 @@ ValueObjectSP ValueObjectMemory::Create(ExecutionContextScope *exe_scope,
llvm::StringRef name,
const Address &address,
lldb::TypeSP &type_sp) {
- return (new ValueObjectMemory(exe_scope, name, address, type_sp))->GetSP();
+ auto manager_sp = ValueObjectManager::Create();
+ return (new ValueObjectMemory(exe_scope, *manager_sp, name, address, type_sp))
+ ->GetSP();
}
ValueObjectSP ValueObjectMemory::Create(ExecutionContextScope *exe_scope,
llvm::StringRef name,
const Address &address,
const CompilerType &ast_type) {
- return (new ValueObjectMemory(exe_scope, name, address, ast_type))->GetSP();
+ auto manager_sp = ValueObjectManager::Create();
+ return (new ValueObjectMemory(exe_scope, *manager_sp, name, address,
+ ast_type))
+ ->GetSP();
}
ValueObjectMemory::ValueObjectMemory(ExecutionContextScope *exe_scope,
+ ValueObjectManager &manager,
llvm::StringRef name,
const Address &address,
lldb::TypeSP &type_sp)
- : ValueObject(exe_scope), m_address(address), m_type_sp(type_sp),
+ : ValueObject(exe_scope, manager), m_address(address), m_type_sp(type_sp),
m_compiler_type() {
// Do not attempt to construct one of these objects with no variable!
assert(m_type_sp.get() != nullptr);
@@ -70,10 +76,11 @@ ValueObjectMemory::ValueObjectMemory(ExecutionContextScope *exe_scope,
}
ValueObjectMemory::ValueObjectMemory(ExecutionContextScope *exe_scope,
+ ValueObjectManager &manager,
llvm::StringRef name,
const Address &address,
const CompilerType &ast_type)
- : ValueObject(exe_scope), m_address(address), m_type_sp(),
+ : ValueObject(exe_scope, manager), m_address(address), m_type_sp(),
m_compiler_type(ast_type) {
// Do not attempt to construct one of these objects with no variable!
assert(m_compiler_type.GetTypeSystem());
@@ -82,8 +89,6 @@ ValueObjectMemory::ValueObjectMemory(ExecutionContextScope *exe_scope,
TargetSP target_sp(GetTargetSP());
SetName(ConstString(name));
- // 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) {
@@ -112,7 +117,7 @@ CompilerType ValueObjectMemory::GetCompilerTypeImpl() {
ConstString ValueObjectMemory::GetTypeName() {
if (m_type_sp)
return m_type_sp->GetName();
- return m_compiler_type.GetConstTypeName();
+ return m_compiler_type.GetTypeName();
}
ConstString ValueObjectMemory::GetDisplayTypeName() {
@@ -204,8 +209,6 @@ bool ValueObjectMemory::UpdateValue() {
if (m_type_sp)
value.SetContext(Value::eContextTypeLLDBType, m_type_sp.get());
else {
- // value.SetContext(Value::eContextTypeClangType,
- // m_compiler_type.GetOpaqueQualType());
value.SetCompilerType(m_compiler_type);
}
diff --git a/lldb/source/Core/ValueObjectRegister.cpp b/lldb/source/Core/ValueObjectRegister.cpp
index 7e97df6d2a34..ec87c38fb367 100644
--- a/lldb/source/Core/ValueObjectRegister.cpp
+++ b/lldb/source/Core/ValueObjectRegister.cpp
@@ -1,4 +1,4 @@
-//===-- ValueObjectRegister.cpp ---------------------------------*- C++ -*-===//
+//===-- ValueObjectRegister.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -35,86 +35,24 @@ class ExecutionContextScope;
using namespace lldb;
using namespace lldb_private;
-#pragma mark ValueObjectRegisterContext
-
-ValueObjectRegisterContext::ValueObjectRegisterContext(
- ValueObject &parent, RegisterContextSP &reg_ctx)
- : ValueObject(parent), m_reg_ctx_sp(reg_ctx) {
- assert(reg_ctx);
- m_name.SetCString("Registers");
- SetValueIsValid(true);
-}
-
-ValueObjectRegisterContext::~ValueObjectRegisterContext() {}
-
-CompilerType ValueObjectRegisterContext::GetCompilerTypeImpl() {
- return CompilerType();
-}
-
-ConstString ValueObjectRegisterContext::GetTypeName() { return ConstString(); }
-
-ConstString ValueObjectRegisterContext::GetDisplayTypeName() {
- return ConstString();
-}
-
-ConstString ValueObjectRegisterContext::GetQualifiedTypeName() {
- return ConstString();
-}
-
-size_t ValueObjectRegisterContext::CalculateNumChildren(uint32_t max) {
- auto reg_set_count = m_reg_ctx_sp->GetRegisterSetCount();
- return reg_set_count <= max ? reg_set_count : max;
-}
-
-uint64_t ValueObjectRegisterContext::GetByteSize() { return 0; }
-
-bool ValueObjectRegisterContext::UpdateValue() {
- m_error.Clear();
- ExecutionContext exe_ctx(GetExecutionContextRef());
- StackFrame *frame = exe_ctx.GetFramePtr();
- if (frame)
- m_reg_ctx_sp = frame->GetRegisterContext();
- else
- m_reg_ctx_sp.reset();
-
- if (m_reg_ctx_sp.get() == nullptr) {
- SetValueIsValid(false);
- m_error.SetErrorToGenericError();
- } else
- SetValueIsValid(true);
-
- return m_error.Success();
-}
-
-ValueObject *ValueObjectRegisterContext::CreateChildAtIndex(
- size_t idx, bool synthetic_array_member, int32_t synthetic_index) {
- ValueObject *new_valobj = nullptr;
-
- const size_t num_children = GetNumChildren();
- if (idx < num_children) {
- ExecutionContext exe_ctx(GetExecutionContextRef());
- new_valobj = new ValueObjectRegisterSet(
- exe_ctx.GetBestExecutionContextScope(), m_reg_ctx_sp, idx);
- }
-
- return new_valobj;
-}
-
-#pragma mark -
#pragma mark ValueObjectRegisterSet
ValueObjectSP
ValueObjectRegisterSet::Create(ExecutionContextScope *exe_scope,
lldb::RegisterContextSP &reg_ctx_sp,
uint32_t set_idx) {
- return (new ValueObjectRegisterSet(exe_scope, reg_ctx_sp, set_idx))->GetSP();
+ auto manager_sp = ValueObjectManager::Create();
+ return (new ValueObjectRegisterSet(exe_scope, *manager_sp, reg_ctx_sp,
+ set_idx))
+ ->GetSP();
}
ValueObjectRegisterSet::ValueObjectRegisterSet(ExecutionContextScope *exe_scope,
+ ValueObjectManager &manager,
lldb::RegisterContextSP &reg_ctx,
uint32_t reg_set_idx)
- : ValueObject(exe_scope), m_reg_ctx_sp(reg_ctx), m_reg_set(nullptr),
- m_reg_set_idx(reg_set_idx) {
+ : ValueObject(exe_scope, manager), m_reg_ctx_sp(reg_ctx),
+ m_reg_set(nullptr), m_reg_set_idx(reg_set_idx) {
assert(reg_ctx);
m_reg_set = reg_ctx->GetRegisterSet(m_reg_set_idx);
if (m_reg_set) {
@@ -192,7 +130,7 @@ ValueObjectRegisterSet::GetChildMemberWithName(ConstString name,
ValueObject *valobj = nullptr;
if (m_reg_ctx_sp && m_reg_set) {
const RegisterInfo *reg_info =
- m_reg_ctx_sp->GetRegisterInfoByName(name.AsCString());
+ m_reg_ctx_sp->GetRegisterInfoByName(name.GetStringRef());
if (reg_info != nullptr)
valobj = new ValueObjectRegister(*this, m_reg_ctx_sp,
reg_info->kinds[eRegisterKindLLDB]);
@@ -207,7 +145,7 @@ size_t
ValueObjectRegisterSet::GetIndexOfChildWithName(ConstString name) {
if (m_reg_ctx_sp && m_reg_set) {
const RegisterInfo *reg_info =
- m_reg_ctx_sp->GetRegisterInfoByName(name.AsCString());
+ m_reg_ctx_sp->GetRegisterInfoByName(name.GetStringRef());
if (reg_info != nullptr)
return reg_info->kinds[eRegisterKindLLDB];
}
@@ -240,13 +178,16 @@ ValueObjectRegister::ValueObjectRegister(ValueObject &parent,
ValueObjectSP ValueObjectRegister::Create(ExecutionContextScope *exe_scope,
lldb::RegisterContextSP &reg_ctx_sp,
uint32_t reg_num) {
- return (new ValueObjectRegister(exe_scope, reg_ctx_sp, reg_num))->GetSP();
+ auto manager_sp = ValueObjectManager::Create();
+ return (new ValueObjectRegister(exe_scope, *manager_sp, reg_ctx_sp, reg_num))
+ ->GetSP();
}
ValueObjectRegister::ValueObjectRegister(ExecutionContextScope *exe_scope,
+ ValueObjectManager &manager,
lldb::RegisterContextSP &reg_ctx,
uint32_t reg_num)
- : ValueObject(exe_scope), m_reg_ctx_sp(reg_ctx), m_reg_info(),
+ : ValueObject(exe_scope, manager), m_reg_ctx_sp(reg_ctx), m_reg_info(),
m_reg_value(), m_type_name(), m_compiler_type() {
assert(reg_ctx);
ConstructObject(reg_num);
@@ -278,7 +219,7 @@ CompilerType ValueObjectRegister::GetCompilerTypeImpl() {
ConstString ValueObjectRegister::GetTypeName() {
if (m_type_name.IsEmpty())
- m_type_name = GetCompilerType().GetConstTypeName();
+ m_type_name = GetCompilerType().GetTypeName();
return m_type_name;
}
@@ -357,7 +298,6 @@ bool ValueObjectRegister::ResolveValue(Scalar &scalar) {
}
void ValueObjectRegister::GetExpressionPath(Stream &s,
- bool qualify_cxx_base_classes,
GetExpressionPathFormat epformat) {
s.Printf("$%s", m_reg_info.name);
}
diff --git a/lldb/source/Core/ValueObjectSyntheticFilter.cpp b/lldb/source/Core/ValueObjectSyntheticFilter.cpp
index a30be1b08338..32d1e6ab8368 100644
--- a/lldb/source/Core/ValueObjectSyntheticFilter.cpp
+++ b/lldb/source/Core/ValueObjectSyntheticFilter.cpp
@@ -1,4 +1,4 @@
-//===-- ValueObjectSyntheticFilter.cpp --------------------------*- C++ -*-===//
+//===-- ValueObjectSyntheticFilter.cpp ------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -14,7 +14,6 @@
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Logging.h"
-#include "lldb/Utility/SharingPtr.h"
#include "lldb/Utility/Status.h"
#include "llvm/ADT/STLExtras.h"
@@ -54,7 +53,9 @@ ValueObjectSynthetic::ValueObjectSynthetic(ValueObject &parent,
m_might_have_children(eLazyBoolCalculate),
m_provides_value(eLazyBoolCalculate) {
SetName(parent.GetName());
- CopyValueData(m_parent);
+ // Copying the data of an incomplete type won't work as it has no byte size.
+ if (m_parent->GetCompilerType().IsCompleteType())
+ CopyValueData(m_parent);
CreateSynthFilter();
}
@@ -220,7 +221,9 @@ bool ValueObjectSynthetic::UpdateValue() {
GetName().AsCString());
m_provides_value = eLazyBoolNo;
- CopyValueData(m_parent);
+ // Copying the data of an incomplete type won't work as it has no byte size.
+ if (m_parent->GetCompilerType().IsCompleteType())
+ CopyValueData(m_parent);
}
SetValueIsValid(true);
diff --git a/lldb/source/Core/ValueObjectVariable.cpp b/lldb/source/Core/ValueObjectVariable.cpp
index 240ebe1fdff3..0d1e7b047a0a 100644
--- a/lldb/source/Core/ValueObjectVariable.cpp
+++ b/lldb/source/Core/ValueObjectVariable.cpp
@@ -1,4 +1,4 @@
-//===-- ValueObjectVariable.cpp ---------------------------------*- C++ -*-===//
+//===-- ValueObjectVariable.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -50,12 +50,14 @@ using namespace lldb_private;
lldb::ValueObjectSP
ValueObjectVariable::Create(ExecutionContextScope *exe_scope,
const lldb::VariableSP &var_sp) {
- return (new ValueObjectVariable(exe_scope, var_sp))->GetSP();
+ auto manager_sp = ValueObjectManager::Create();
+ return (new ValueObjectVariable(exe_scope, *manager_sp, var_sp))->GetSP();
}
ValueObjectVariable::ValueObjectVariable(ExecutionContextScope *exe_scope,
+ ValueObjectManager &manager,
const lldb::VariableSP &var_sp)
- : ValueObject(exe_scope), m_variable_sp(var_sp) {
+ : ValueObject(exe_scope, manager), m_variable_sp(var_sp) {
// Do not attempt to construct one of these objects with no variable!
assert(m_variable_sp.get() != nullptr);
m_name = var_sp->GetName();
@@ -166,6 +168,27 @@ bool ValueObjectVariable::UpdateValue() {
Value::ValueType value_type = m_value.GetValueType();
+ // The size of the buffer within m_value can be less than the size
+ // prescribed by its type. E.g. this can happen when an expression only
+ // partially describes an object (say, because it contains DW_OP_piece).
+ //
+ // In this case, grow m_value to the expected size. An alternative way to
+ // handle this is to teach Value::GetValueAsData() and ValueObjectChild
+ // not to read past the end of a host buffer, but this gets impractically
+ // complicated as a Value's host buffer may be shared with a distant
+ // ancestor or sibling in the ValueObject hierarchy.
+ //
+ // FIXME: When we grow m_value, we should represent the added bits as
+ // undefined somehow instead of as 0's.
+ if (value_type == Value::eValueTypeHostAddress &&
+ compiler_type.IsValid()) {
+ if (size_t value_buf_size = m_value.GetBuffer().GetByteSize()) {
+ size_t value_size = m_value.GetValueByteSize(&m_error, &exe_ctx);
+ if (m_error.Success() && value_buf_size < value_size)
+ m_value.ResizeData(value_size);
+ }
+ }
+
Process *process = exe_ctx.GetProcessPtr();
const bool process_is_alive = process && process->IsAlive();
@@ -219,9 +242,64 @@ bool ValueObjectVariable::UpdateValue() {
m_resolved_value.SetContext(Value::eContextTypeInvalid, nullptr);
}
}
+
return m_error.Success();
}
+void ValueObjectVariable::DoUpdateChildrenAddressType(ValueObject &valobj) {
+ Value::ValueType value_type = valobj.GetValue().GetValueType();
+ ExecutionContext exe_ctx(GetExecutionContextRef());
+ Process *process = exe_ctx.GetProcessPtr();
+ const bool process_is_alive = process && process->IsAlive();
+ const uint32_t type_info = valobj.GetCompilerType().GetTypeInfo();
+ const bool is_pointer_or_ref =
+ (type_info & (lldb::eTypeIsPointer | lldb::eTypeIsReference)) != 0;
+
+ switch (value_type) {
+ case Value::eValueTypeFileAddress:
+ // If this type is a pointer, then its children will be considered load
+ // addresses if the pointer or reference is dereferenced, but only if
+ // the process is alive.
+ //
+ // There could be global variables like in the following code:
+ // struct LinkedListNode { Foo* foo; LinkedListNode* next; };
+ // Foo g_foo1;
+ // Foo g_foo2;
+ // LinkedListNode g_second_node = { &g_foo2, NULL };
+ // LinkedListNode g_first_node = { &g_foo1, &g_second_node };
+ //
+ // When we aren't running, we should be able to look at these variables
+ // using the "target variable" command. Children of the "g_first_node"
+ // always will be of the same address type as the parent. But children
+ // of the "next" member of LinkedListNode will become load addresses if
+ // we have a live process, or remain a file address if it was a file
+ // address.
+ if (process_is_alive && is_pointer_or_ref)
+ valobj.SetAddressTypeOfChildren(eAddressTypeLoad);
+ else
+ valobj.SetAddressTypeOfChildren(eAddressTypeFile);
+ break;
+ case Value::eValueTypeHostAddress:
+ // Same as above for load addresses, except children of pointer or refs
+ // are always load addresses. Host addresses are used to store freeze
+ // dried variables. If this type is a struct, the entire struct
+ // contents will be copied into the heap of the
+ // LLDB process, but we do not currently follow any pointers.
+ if (is_pointer_or_ref)
+ valobj.SetAddressTypeOfChildren(eAddressTypeLoad);
+ else
+ valobj.SetAddressTypeOfChildren(eAddressTypeHost);
+ break;
+ case Value::eValueTypeLoadAddress:
+ case Value::eValueTypeScalar:
+ case Value::eValueTypeVector:
+ valobj.SetAddressTypeOfChildren(eAddressTypeLoad);
+ break;
+ }
+}
+
+
+
bool ValueObjectVariable::IsInScope() {
const ExecutionContextRef &exe_ctx_ref = GetExecutionContextRef();
if (exe_ctx_ref.HasFrameRef()) {
diff --git a/lldb/source/DataFormatters/CXXFunctionPointer.cpp b/lldb/source/DataFormatters/CXXFunctionPointer.cpp
index 0ca000eb0529..3b7b0bc27cf8 100644
--- a/lldb/source/DataFormatters/CXXFunctionPointer.cpp
+++ b/lldb/source/DataFormatters/CXXFunctionPointer.cpp
@@ -1,4 +1,4 @@
-//===-- CXXFunctionPointer.cpp-----------------------------------*- C++ -*-===//
+//===-- CXXFunctionPointer.cpp---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/DataFormatters/DataVisualization.cpp b/lldb/source/DataFormatters/DataVisualization.cpp
index 99c303c9f0b1..450a5cbc3ef3 100644
--- a/lldb/source/DataFormatters/DataVisualization.cpp
+++ b/lldb/source/DataFormatters/DataVisualization.cpp
@@ -1,5 +1,4 @@
-//===-- DataVisualization.cpp ---------------------------------------*- C++
-//-*-===//
+//===-- DataVisualization.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/DataFormatters/DumpValueObjectOptions.cpp b/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
index 84f21696e054..46a2a489586b 100644
--- a/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
+++ b/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
@@ -1,5 +1,4 @@
-//===-- DumpValueObjectOptions.cpp -----------------------------------*- C++
-//-*-===//
+//===-- DumpValueObjectOptions.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/DataFormatters/FormatCache.cpp b/lldb/source/DataFormatters/FormatCache.cpp
index 231e7ed0c0a0..5e0965fcdae4 100644
--- a/lldb/source/DataFormatters/FormatCache.cpp
+++ b/lldb/source/DataFormatters/FormatCache.cpp
@@ -1,5 +1,4 @@
-//===-- FormatCache.cpp ------------------------------------------*- C++
-//-*-===//
+//===-- FormatCache.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -52,15 +51,6 @@ void FormatCache::Entry::Set(lldb::SyntheticChildrenSP synthetic_sp) {
m_synthetic_sp = synthetic_sp;
}
-FormatCache::FormatCache()
- : m_map(), m_mutex()
-#ifdef LLDB_CONFIGURATION_DEBUG
- ,
- m_cache_hits(0), m_cache_misses(0)
-#endif
-{
-}
-
FormatCache::Entry &FormatCache::GetEntry(ConstString type) {
auto i = m_map.find(type), e = m_map.end();
if (i != e)
@@ -69,6 +59,8 @@ FormatCache::Entry &FormatCache::GetEntry(ConstString type) {
return m_map[type];
}
+namespace lldb_private {
+
template<> bool FormatCache::Entry::IsCached<lldb::TypeFormatImplSP>() {
return IsFormatCached();
}
@@ -79,20 +71,18 @@ template<> bool FormatCache::Entry::IsCached<lldb::SyntheticChildrenSP>() {
return IsSyntheticCached();
}
+} // namespace lldb_private
+
template <typename ImplSP>
bool FormatCache::Get(ConstString type, ImplSP &format_impl_sp) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
auto entry = GetEntry(type);
if (entry.IsCached<ImplSP>()) {
-#ifdef LLDB_CONFIGURATION_DEBUG
m_cache_hits++;
-#endif
entry.Get(format_impl_sp);
return true;
}
-#ifdef LLDB_CONFIGURATION_DEBUG
m_cache_misses++;
-#endif
format_impl_sp.reset();
return false;
}
diff --git a/lldb/source/DataFormatters/FormatClasses.cpp b/lldb/source/DataFormatters/FormatClasses.cpp
index 6a9279f54d64..44fa96033bc1 100644
--- a/lldb/source/DataFormatters/FormatClasses.cpp
+++ b/lldb/source/DataFormatters/FormatClasses.cpp
@@ -1,5 +1,4 @@
-//===-- FormatClasses.cpp ----------------------------------------*- C++
-//-*-===//
+//===-- FormatClasses.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp
index d5db3ee75bf3..ad02d37360b8 100644
--- a/lldb/source/DataFormatters/FormatManager.cpp
+++ b/lldb/source/DataFormatters/FormatManager.cpp
@@ -1,4 +1,4 @@
-//===-- FormatManager.cpp ----------------------------------------*- C++-*-===//
+//===-- FormatManager.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -174,28 +174,27 @@ void FormatManager::DisableAllCategories() {
}
void FormatManager::GetPossibleMatches(
- ValueObject &valobj, CompilerType compiler_type, uint32_t reason,
+ ValueObject &valobj, CompilerType compiler_type,
lldb::DynamicValueType use_dynamic, FormattersMatchVector &entries,
bool did_strip_ptr, bool did_strip_ref, bool did_strip_typedef,
bool root_level) {
compiler_type = compiler_type.GetTypeForFormatters();
- ConstString type_name(compiler_type.GetConstTypeName());
+ ConstString type_name(compiler_type.GetTypeName());
if (valobj.GetBitfieldBitSize() > 0) {
StreamString sstring;
sstring.Printf("%s:%d", type_name.AsCString(), valobj.GetBitfieldBitSize());
ConstString bitfieldname(sstring.GetString());
entries.push_back(
- {bitfieldname, 0, did_strip_ptr, did_strip_ref, did_strip_typedef});
- reason |= lldb_private::eFormatterChoiceCriterionStrippedBitField;
+ {bitfieldname, 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});
+ {type_name, did_strip_ptr, did_strip_ref, did_strip_typedef});
- ConstString display_type_name(compiler_type.GetDisplayTypeName());
+ ConstString display_type_name(compiler_type.GetTypeName());
if (display_type_name != type_name)
- entries.push_back({display_type_name, reason, did_strip_ptr,
+ entries.push_back({display_type_name, did_strip_ptr,
did_strip_ref, did_strip_typedef});
}
@@ -204,8 +203,6 @@ void FormatManager::GetPossibleMatches(
CompilerType non_ref_type = compiler_type.GetNonReferenceType();
GetPossibleMatches(
valobj, non_ref_type,
- reason |
- lldb_private::eFormatterChoiceCriterionStrippedPointerReference,
use_dynamic, entries, did_strip_ptr, true, did_strip_typedef);
if (non_ref_type.IsTypedefType()) {
CompilerType deffed_referenced_type = non_ref_type.GetTypedefedType();
@@ -214,7 +211,6 @@ void FormatManager::GetPossibleMatches(
: deffed_referenced_type.GetLValueReferenceType();
GetPossibleMatches(
valobj, deffed_referenced_type,
- reason | lldb_private::eFormatterChoiceCriterionNavigatedTypedefs,
use_dynamic, entries, did_strip_ptr, did_strip_ref,
true); // this is not exactly the usual meaning of stripping typedefs
}
@@ -224,8 +220,6 @@ void FormatManager::GetPossibleMatches(
CompilerType non_ptr_type = compiler_type.GetPointeeType();
GetPossibleMatches(
valobj, non_ptr_type,
- reason |
- lldb_private::eFormatterChoiceCriterionStrippedPointerReference,
use_dynamic, entries, true, did_strip_ref, did_strip_typedef);
if (non_ptr_type.IsTypedefType()) {
CompilerType deffed_pointed_type =
@@ -233,7 +227,6 @@ void FormatManager::GetPossibleMatches(
const bool stripped_typedef = true;
GetPossibleMatches(
valobj, deffed_pointed_type,
- reason | lldb_private::eFormatterChoiceCriterionNavigatedTypedefs,
use_dynamic, entries, did_strip_ptr, did_strip_ref,
stripped_typedef); // this is not exactly the usual meaning of
// stripping typedefs
@@ -253,7 +246,6 @@ void FormatManager::GetPossibleMatches(
const bool stripped_typedef = true;
GetPossibleMatches(
valobj, deffed_array_type,
- reason | lldb_private::eFormatterChoiceCriterionNavigatedTypedefs,
use_dynamic, entries, did_strip_ptr, did_strip_ref,
stripped_typedef); // this is not exactly the usual meaning of
// stripping typedefs
@@ -267,7 +259,6 @@ void FormatManager::GetPossibleMatches(
language->GetPossibleFormattersMatches(valobj, use_dynamic)) {
entries.push_back(
{candidate,
- reason | lldb_private::eFormatterChoiceCriterionLanguagePlugin,
did_strip_ptr, did_strip_ref, did_strip_typedef});
}
}
@@ -278,7 +269,6 @@ void FormatManager::GetPossibleMatches(
CompilerType deffed_type = compiler_type.GetTypedefedType();
GetPossibleMatches(
valobj, deffed_type,
- reason | lldb_private::eFormatterChoiceCriterionNavigatedTypedefs,
use_dynamic, entries, did_strip_ptr, did_strip_ref, true);
}
@@ -293,7 +283,7 @@ void FormatManager::GetPossibleMatches(
break;
if (unqual_compiler_ast_type.GetOpaqueQualType() !=
compiler_type.GetOpaqueQualType())
- GetPossibleMatches(valobj, unqual_compiler_ast_type, reason,
+ GetPossibleMatches(valobj, unqual_compiler_ast_type,
use_dynamic, entries, did_strip_ptr, did_strip_ref,
did_strip_typedef);
} while (false);
@@ -304,7 +294,6 @@ void FormatManager::GetPossibleMatches(
if (static_value_sp)
GetPossibleMatches(
*static_value_sp.get(), static_value_sp->GetCompilerType(),
- reason | lldb_private::eFormatterChoiceCriterionWentToStaticValue,
use_dynamic, entries, did_strip_ptr, did_strip_ref,
did_strip_typedef, true);
}
diff --git a/lldb/source/DataFormatters/FormattersHelpers.cpp b/lldb/source/DataFormatters/FormattersHelpers.cpp
index b2a5a17595c8..7944ff06eee5 100644
--- a/lldb/source/DataFormatters/FormattersHelpers.cpp
+++ b/lldb/source/DataFormatters/FormattersHelpers.cpp
@@ -1,5 +1,4 @@
-//===-- FormattersHelpers.cpp -------------------------------------*- C++
-//-*-===//
+//===-- FormattersHelpers.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -143,3 +142,14 @@ lldb_private::formatters::GetArrayAddressOrPointerValue(ValueObject &valobj) {
return data_addr;
}
+
+lldb::ValueObjectSP
+lldb_private::formatters::GetValueOfLibCXXCompressedPair(ValueObject &pair) {
+ ValueObjectSP value =
+ pair.GetChildMemberWithName(ConstString("__value_"), true);
+ if (!value) {
+ // pre-r300140 member name
+ value = pair.GetChildMemberWithName(ConstString("__first_"), true);
+ }
+ return value;
+}
diff --git a/lldb/source/DataFormatters/LanguageCategory.cpp b/lldb/source/DataFormatters/LanguageCategory.cpp
index e18ec0feaa8b..4794186ce9ae 100644
--- a/lldb/source/DataFormatters/LanguageCategory.cpp
+++ b/lldb/source/DataFormatters/LanguageCategory.cpp
@@ -1,5 +1,4 @@
-//===-- LanguageCategory.cpp ---------------------------------------*- C++
-//-*-===//
+//===-- LanguageCategory.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -55,6 +54,8 @@ bool LanguageCategory::Get(FormattersMatchData &match_data,
return result;
}
+namespace lldb_private {
+
/// Explicit instantiations for the three types.
/// \{
template bool
@@ -83,6 +84,8 @@ auto &LanguageCategory::GetHardcodedFinder<lldb::SyntheticChildrenSP>() {
return m_hardcoded_synthetics;
}
+} // namespace lldb_private
+
template <typename ImplSP>
bool LanguageCategory::GetHardcoded(FormatManager &fmt_mgr,
FormattersMatchData &match_data,
diff --git a/lldb/source/DataFormatters/StringPrinter.cpp b/lldb/source/DataFormatters/StringPrinter.cpp
index 27d649bfc370..139f1ec0554f 100644
--- a/lldb/source/DataFormatters/StringPrinter.cpp
+++ b/lldb/source/DataFormatters/StringPrinter.cpp
@@ -1,5 +1,4 @@
-//===-- StringPrinter.cpp ----------------------------------------*- C++
-//-*-===//
+//===-- StringPrinter.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -16,6 +15,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Utility/Status.h"
+#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/ConvertUTF.h"
#include <ctype.h>
@@ -25,15 +25,48 @@
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
+using GetPrintableElementType = StringPrinter::GetPrintableElementType;
+using StringElementType = StringPrinter::StringElementType;
+
+/// DecodedCharBuffer stores the decoded contents of a single character. It
+/// avoids managing memory on the heap by copying decoded bytes into an in-line
+/// buffer.
+class DecodedCharBuffer {
+public:
+ DecodedCharBuffer(std::nullptr_t) {}
+
+ DecodedCharBuffer(const uint8_t *bytes, size_t size) : m_size(size) {
+ if (size > MaxLength)
+ llvm_unreachable("unsupported length");
+ memcpy(m_data, bytes, size);
+ }
+
+ DecodedCharBuffer(const char *bytes, size_t size)
+ : DecodedCharBuffer(reinterpret_cast<const uint8_t *>(bytes), size) {}
+
+ const uint8_t *GetBytes() const { return m_data; }
+
+ size_t GetSize() const { return m_size; }
+
+private:
+ static constexpr unsigned MaxLength = 16;
+
+ size_t m_size = 0;
+ uint8_t m_data[MaxLength] = {0};
+};
+
+using EscapingHelper =
+ std::function<DecodedCharBuffer(uint8_t *, uint8_t *, uint8_t *&)>;
// 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 <lldb_private::formatters::StringPrinter::StringElementType type>
-static StringPrinter::StringPrinterBufferPointer<>
-GetPrintableImpl(uint8_t *buffer, uint8_t *buffer_end, uint8_t *&next);
+template <StringElementType type>
+static DecodedCharBuffer
+GetPrintableImpl(uint8_t *buffer, uint8_t *buffer_end, uint8_t *&next,
+ StringPrinter::EscapeStyle escape_style);
-// mimic isprint() for Unicode codepoints
-static bool isprint(char32_t codepoint) {
+// Mimic isprint() for Unicode codepoints.
+static bool isprint32(char32_t codepoint) {
if (codepoint <= 0x1F || codepoint == 0x7F) // C0
{
return false;
@@ -60,216 +93,174 @@ static bool isprint(char32_t codepoint) {
return true;
}
-template <>
-StringPrinter::StringPrinterBufferPointer<>
-GetPrintableImpl<StringPrinter::StringElementType::ASCII>(uint8_t *buffer,
- uint8_t *buffer_end,
- uint8_t *&next) {
- StringPrinter::StringPrinterBufferPointer<> retval = {nullptr};
-
- switch (*buffer) {
+DecodedCharBuffer attemptASCIIEscape(llvm::UTF32 c,
+ StringPrinter::EscapeStyle escape_style) {
+ const bool is_swift_escape_style =
+ escape_style == StringPrinter::EscapeStyle::Swift;
+ switch (c) {
case 0:
- retval = {"\\0", 2};
- break;
+ return {"\\0", 2};
case '\a':
- retval = {"\\a", 2};
- break;
+ return {"\\a", 2};
case '\b':
- retval = {"\\b", 2};
- break;
+ if (is_swift_escape_style)
+ return nullptr;
+ return {"\\b", 2};
case '\f':
- retval = {"\\f", 2};
- break;
+ if (is_swift_escape_style)
+ return nullptr;
+ return {"\\f", 2};
case '\n':
- retval = {"\\n", 2};
- break;
+ return {"\\n", 2};
case '\r':
- retval = {"\\r", 2};
- break;
+ return {"\\r", 2};
case '\t':
- retval = {"\\t", 2};
- break;
+ return {"\\t", 2};
case '\v':
- retval = {"\\v", 2};
- break;
+ if (is_swift_escape_style)
+ return nullptr;
+ return {"\\v", 2};
case '\"':
- retval = {"\\\"", 2};
- break;
+ return {"\\\"", 2};
+ case '\'':
+ if (is_swift_escape_style)
+ return {"\\'", 2};
+ return nullptr;
case '\\':
- retval = {"\\\\", 2};
- break;
- default:
- if (isprint(*buffer))
- retval = {buffer, 1};
- else {
- uint8_t *data = new uint8_t[5];
- sprintf((char *)data, "\\x%02x", *buffer);
- retval = {data, 4, [](const uint8_t *c) { delete[] c; }};
- break;
- }
+ return {"\\\\", 2};
}
-
- next = buffer + 1;
- return retval;
-}
-
-static char32_t ConvertUTF8ToCodePoint(unsigned char c0, unsigned char c1) {
- return (c0 - 192) * 64 + (c1 - 128);
-}
-static char32_t ConvertUTF8ToCodePoint(unsigned char c0, unsigned char c1,
- unsigned char c2) {
- return (c0 - 224) * 4096 + (c1 - 128) * 64 + (c2 - 128);
-}
-static char32_t ConvertUTF8ToCodePoint(unsigned char c0, unsigned char c1,
- unsigned char c2, unsigned char c3) {
- return (c0 - 240) * 262144 + (c2 - 128) * 4096 + (c2 - 128) * 64 + (c3 - 128);
+ return nullptr;
}
template <>
-StringPrinter::StringPrinterBufferPointer<>
-GetPrintableImpl<StringPrinter::StringElementType::UTF8>(uint8_t *buffer,
- uint8_t *buffer_end,
- uint8_t *&next) {
- StringPrinter::StringPrinterBufferPointer<> retval{nullptr};
-
- unsigned utf8_encoded_len = llvm::getNumBytesForUTF8(*buffer);
-
- if (1u + std::distance(buffer, buffer_end) < utf8_encoded_len) {
- // I don't have enough bytes - print whatever I have left
- retval = {buffer, static_cast<size_t>(1 + buffer_end - buffer)};
- next = buffer_end + 1;
+DecodedCharBuffer GetPrintableImpl<StringElementType::ASCII>(
+ uint8_t *buffer, uint8_t *buffer_end, uint8_t *&next,
+ StringPrinter::EscapeStyle escape_style) {
+ // The ASCII helper always advances 1 byte at a time.
+ next = buffer + 1;
+
+ DecodedCharBuffer retval = attemptASCIIEscape(*buffer, escape_style);
+ if (retval.GetSize())
return retval;
- }
- char32_t codepoint = 0;
- switch (utf8_encoded_len) {
- case 1:
- // this is just an ASCII byte - ask ASCII
- return GetPrintableImpl<StringPrinter::StringElementType::ASCII>(
- buffer, buffer_end, next);
- case 2:
- codepoint = ConvertUTF8ToCodePoint((unsigned char)*buffer,
- (unsigned char)*(buffer + 1));
- break;
- case 3:
- codepoint = ConvertUTF8ToCodePoint((unsigned char)*buffer,
- (unsigned char)*(buffer + 1),
- (unsigned char)*(buffer + 2));
+ // Use llvm's locale-independent isPrint(char), instead of the libc
+ // implementation which may give different results on different platforms.
+ if (llvm::isPrint(*buffer))
+ return {buffer, 1};
+
+ unsigned escaped_len;
+ constexpr unsigned max_buffer_size = 7;
+ uint8_t data[max_buffer_size];
+ switch (escape_style) {
+ case StringPrinter::EscapeStyle::CXX:
+ // Prints 4 characters, then a \0 terminator.
+ escaped_len = sprintf((char *)data, "\\x%02x", *buffer);
break;
- case 4:
- codepoint = ConvertUTF8ToCodePoint(
- (unsigned char)*buffer, (unsigned char)*(buffer + 1),
- (unsigned char)*(buffer + 2), (unsigned char)*(buffer + 3));
+ case StringPrinter::EscapeStyle::Swift:
+ // Prints up to 6 characters, then a \0 terminator.
+ escaped_len = sprintf((char *)data, "\\u{%x}", *buffer);
break;
- default:
- // this is probably some bogus non-character thing just print it as-is and
- // hope to sync up again soon
- retval = {buffer, 1};
- next = buffer + 1;
- return retval;
}
+ lldbassert(escaped_len > 0 && "unknown string escape style");
+ return {data, escaped_len};
+}
- if (codepoint) {
- switch (codepoint) {
- case 0:
- retval = {"\\0", 2};
- break;
- case '\a':
- retval = {"\\a", 2};
- break;
- case '\b':
- retval = {"\\b", 2};
- break;
- case '\f':
- retval = {"\\f", 2};
- break;
- case '\n':
- retval = {"\\n", 2};
- break;
- case '\r':
- retval = {"\\r", 2};
- break;
- case '\t':
- retval = {"\\t", 2};
- break;
- case '\v':
- retval = {"\\v", 2};
- break;
- case '\"':
- retval = {"\\\"", 2};
- break;
- case '\\':
- retval = {"\\\\", 2};
- break;
- default:
- if (isprint(codepoint))
- retval = {buffer, utf8_encoded_len};
- else {
- uint8_t *data = new uint8_t[11];
- sprintf((char *)data, "\\U%08x", (unsigned)codepoint);
- retval = {data, 10, [](const uint8_t *c) { delete[] c; }};
- break;
- }
- }
-
- next = buffer + utf8_encoded_len;
+template <>
+DecodedCharBuffer GetPrintableImpl<StringElementType::UTF8>(
+ uint8_t *buffer, uint8_t *buffer_end, uint8_t *&next,
+ StringPrinter::EscapeStyle escape_style) {
+ // If the utf8 encoded length is invalid (i.e., not in the closed interval
+ // [1;4]), or if there aren't enough bytes to print, or if the subsequence
+ // isn't valid utf8, fall back to printing an ASCII-escaped subsequence.
+ if (!llvm::isLegalUTF8Sequence(buffer, buffer_end))
+ return GetPrintableImpl<StringElementType::ASCII>(buffer, buffer_end, next,
+ escape_style);
+
+ // Convert the valid utf8 sequence to a utf32 codepoint. This cannot fail.
+ llvm::UTF32 codepoint = 0;
+ const llvm::UTF8 *buffer_for_conversion = buffer;
+ llvm::ConversionResult result = llvm::convertUTF8Sequence(
+ &buffer_for_conversion, buffer_end, &codepoint, llvm::strictConversion);
+ assert(result == llvm::conversionOK &&
+ "Failed to convert legal utf8 sequence");
+ (void)result;
+
+ // The UTF8 helper always advances by the utf8 encoded length.
+ const unsigned utf8_encoded_len = buffer_for_conversion - buffer;
+ next = buffer + utf8_encoded_len;
+
+ DecodedCharBuffer retval = attemptASCIIEscape(codepoint, escape_style);
+ if (retval.GetSize())
return retval;
+ if (isprint32(codepoint))
+ return {buffer, utf8_encoded_len};
+
+ unsigned escaped_len;
+ constexpr unsigned max_buffer_size = 13;
+ uint8_t data[max_buffer_size];
+ switch (escape_style) {
+ case StringPrinter::EscapeStyle::CXX:
+ // Prints 10 characters, then a \0 terminator.
+ escaped_len = sprintf((char *)data, "\\U%08x", codepoint);
+ break;
+ case StringPrinter::EscapeStyle::Swift:
+ // Prints up to 12 characters, then a \0 terminator.
+ escaped_len = sprintf((char *)data, "\\u{%x}", codepoint);
+ break;
}
-
- // this should not happen - but just in case.. try to resync at some point
- retval = {buffer, 1};
- next = buffer + 1;
- return retval;
+ lldbassert(escaped_len > 0 && "unknown string escape style");
+ return {data, escaped_len};
}
// 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 StringPrinter::StringPrinterBufferPointer<>
-GetPrintable(StringPrinter::StringElementType type, uint8_t *buffer,
- uint8_t *buffer_end, uint8_t *&next) {
- if (!buffer)
+static DecodedCharBuffer GetPrintable(StringElementType type, uint8_t *buffer,
+ uint8_t *buffer_end, uint8_t *&next,
+ StringPrinter::EscapeStyle escape_style) {
+ if (!buffer || buffer >= buffer_end)
return {nullptr};
switch (type) {
- 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);
+ case StringElementType::ASCII:
+ return GetPrintableImpl<StringElementType::ASCII>(buffer, buffer_end, next,
+ escape_style);
+ case StringElementType::UTF8:
+ return GetPrintableImpl<StringElementType::UTF8>(buffer, buffer_end, next,
+ escape_style);
default:
return {nullptr};
}
}
-StringPrinter::EscapingHelper
-StringPrinter::GetDefaultEscapingHelper(GetPrintableElementType elem_type) {
+static EscapingHelper
+GetDefaultEscapingHelper(GetPrintableElementType elem_type,
+ StringPrinter::EscapeStyle escape_style) {
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);
+ return [escape_style, elem_type](uint8_t *buffer, uint8_t *buffer_end,
+ uint8_t *&next) -> DecodedCharBuffer {
+ return GetPrintable(elem_type == GetPrintableElementType::UTF8
+ ? StringElementType::UTF8
+ : StringElementType::ASCII,
+ buffer, buffer_end, next, escape_style);
};
}
llvm_unreachable("bad element type");
}
-// use this call if you already have an LLDB-side buffer for the data
+/// Read a string encoded in accordance with \tparam SourceDataType from a
+/// host-side LLDB buffer, then pretty-print it to a stream using \p style.
template <typename SourceDataType>
-static bool DumpUTFBufferToStream(
+static bool DumpEncodedBufferToStream(
+ GetPrintableElementType style,
llvm::ConversionResult (*ConvertFunction)(const SourceDataType **,
const SourceDataType *,
llvm::UTF8 **, llvm::UTF8 *,
llvm::ConversionFlags),
const StringPrinter::ReadBufferAndDumpToStreamOptions &dump_options) {
+ assert(dump_options.GetStream() && "need a Stream to print the string to");
Stream &stream(*dump_options.GetStream());
if (dump_options.GetPrefixToken() != nullptr)
stream.Printf("%s", dump_options.GetPrefixToken());
@@ -329,18 +320,10 @@ static bool DumpUTFBufferToStream(
}
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);
- }
+ EscapingHelper escaping_callback;
+ if (escape_non_printables)
+ escaping_callback =
+ GetDefaultEscapingHelper(style, dump_options.GetEscapeStyle());
// 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
@@ -355,13 +338,11 @@ static bool DumpUTFBufferToStream(
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) {
- // GetPrintable() failed on us - print one byte in a desperate resync
- // attempt
- printable_bytes = utf8_data_ptr;
- printable_size = 1;
- next_data = utf8_data_ptr + 1;
- }
+
+ // We failed to figure out how to print this string.
+ if (!printable_bytes || !next_data)
+ return false;
+
for (unsigned c = 0; c < printable_size; c++)
stream.Printf("%c", *(printable_bytes + c));
utf8_data_ptr = (uint8_t *)next_data;
@@ -404,173 +385,91 @@ lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStreamOptions::
SetQuote(options.GetQuote());
SetEscapeNonPrintables(options.GetEscapeNonPrintables());
SetBinaryZeroIsTerminator(options.GetBinaryZeroIsTerminator());
- SetLanguage(options.GetLanguage());
+ SetEscapeStyle(options.GetEscapeStyle());
}
namespace lldb_private {
namespace formatters {
-template <>
-bool StringPrinter::ReadStringAndDumpToStream<
- StringPrinter::StringElementType::ASCII>(
- const ReadStringAndDumpToStreamOptions &options) {
- assert(options.GetStream() && "need a Stream to print the string to");
- Status my_error;
-
- ProcessSP process_sp(options.GetProcessSP());
-
- if (process_sp.get() == nullptr || options.GetLocation() == 0)
- return false;
-
- size_t size;
- const auto max_size = process_sp->GetTarget().GetMaximumSizeOfStringSummary();
- bool is_truncated = false;
-
- if (options.GetSourceSize() == 0)
- size = max_size;
- else if (!options.GetIgnoreMaxLength()) {
- size = options.GetSourceSize();
- if (size > max_size) {
- size = max_size;
- is_truncated = true;
- }
- } else
- size = options.GetSourceSize();
-
- lldb::DataBufferSP buffer_sp(new DataBufferHeap(size, 0));
-
- process_sp->ReadCStringFromMemory(
- options.GetLocation(), (char *)buffer_sp->GetBytes(), size, my_error);
-
- if (my_error.Fail())
- return false;
-
- const char *prefix_token = options.GetPrefixToken();
- char quote = options.GetQuote();
-
- if (prefix_token != nullptr)
- 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 (escape_non_printables) {
- uint8_t *next_data = nullptr;
- auto printable = escaping_callback(data, data_end, next_data);
- auto printable_bytes = printable.GetBytes();
- auto printable_size = printable.GetSize();
- if (!printable_bytes || !next_data) {
- // GetPrintable() failed on us - print one byte in a desperate resync
- // attempt
- printable_bytes = data;
- printable_size = 1;
- next_data = data + 1;
- }
- for (unsigned c = 0; c < printable_size; c++)
- options.GetStream()->Printf("%c", *(printable_bytes + c));
- data = (uint8_t *)next_data;
- } else {
- options.GetStream()->Printf("%c", *data);
- data++;
- }
- }
-
- const char *suffix_token = options.GetSuffixToken();
-
- if (suffix_token != nullptr)
- 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(
+static bool ReadEncodedBufferAndDumpToStream(
+ StringElementType elem_type,
const StringPrinter::ReadStringAndDumpToStreamOptions &options,
llvm::ConversionResult (*ConvertFunction)(const SourceDataType **,
const SourceDataType *,
llvm::UTF8 **, llvm::UTF8 *,
llvm::ConversionFlags)) {
assert(options.GetStream() && "need a Stream to print the string to");
+ if (!options.GetStream())
+ return false;
if (options.GetLocation() == 0 ||
options.GetLocation() == LLDB_INVALID_ADDRESS)
return false;
lldb::ProcessSP process_sp(options.GetProcessSP());
-
if (!process_sp)
return false;
- const int type_width = sizeof(SourceDataType);
- const int origin_encoding = 8 * type_width;
+ constexpr int type_width = sizeof(SourceDataType);
+ constexpr int origin_encoding = 8 * type_width;
if (origin_encoding != 8 && origin_encoding != 16 && origin_encoding != 32)
return false;
- // if not UTF8, I need a conversion function to return proper UTF8
+ // If not UTF8 or ASCII, conversion to UTF8 is necessary.
if (origin_encoding != 8 && !ConvertFunction)
return false;
- if (!options.GetStream())
- return false;
-
- 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) {
+ uint32_t sourceSize;
+ if (elem_type == StringElementType::ASCII && !options.GetSourceSize()) {
+ // FIXME: The NSString formatter sets HasSourceSize(true) when the size is
+ // actually unknown, as well as SetBinaryZeroIsTerminator(false). IIUC the
+ // C++ formatter also sets SetBinaryZeroIsTerminator(false) when it doesn't
+ // mean to. I don't see how this makes sense: we should fix the formatters.
+ //
+ // Until then, the behavior that's expected for ASCII strings with unknown
+ // lengths is to read up to the max size and then null-terminate. Do that.
sourceSize = max_size;
needs_zero_terminator = true;
- } else if (!options.GetIgnoreMaxLength()) {
- if (sourceSize > max_size) {
- sourceSize = max_size;
- is_truncated = true;
+ } else if (options.HasSourceSize()) {
+ sourceSize = options.GetSourceSize();
+ if (!options.GetIgnoreMaxLength()) {
+ if (sourceSize > max_size) {
+ sourceSize = max_size;
+ is_truncated = true;
+ }
}
+ } else {
+ sourceSize = max_size;
+ needs_zero_terminator = true;
}
const int bufferSPSize = sourceSize * type_width;
-
lldb::DataBufferSP buffer_sp(new DataBufferHeap(bufferSPSize, 0));
- if (!buffer_sp->GetBytes())
+ // Check if we got bytes. We never get any bytes if we have an empty
+ // string, but we still continue so that we end up actually printing
+ // an empty string ("").
+ if (sourceSize != 0 && !buffer_sp->GetBytes())
return false;
Status error;
char *buffer = reinterpret_cast<char *>(buffer_sp->GetBytes());
- if (needs_zero_terminator)
+ if (elem_type == StringElementType::ASCII)
+ process_sp->ReadCStringFromMemory(options.GetLocation(), buffer,
+ bufferSPSize, error);
+ else if (needs_zero_terminator)
process_sp->ReadStringFromMemory(options.GetLocation(), buffer,
bufferSPSize, error, type_width);
else
- process_sp->ReadMemoryFromInferior(options.GetLocation(),
- (char *)buffer_sp->GetBytes(),
+ process_sp->ReadMemoryFromInferior(options.GetLocation(), buffer,
bufferSPSize, error);
-
if (error.Fail()) {
options.GetStream()->Printf("unable to read data");
return true;
@@ -583,67 +482,79 @@ static bool ReadUTFBufferAndDumpToStream(
dump_options.SetData(data);
dump_options.SetSourceSize(sourceSize);
dump_options.SetIsTruncated(is_truncated);
+ dump_options.SetNeedsZeroTermination(needs_zero_terminator);
+ if (needs_zero_terminator)
+ dump_options.SetBinaryZeroIsTerminator(true);
- return DumpUTFBufferToStream(ConvertFunction, dump_options);
+ GetPrintableElementType print_style = (elem_type == StringElementType::ASCII)
+ ? GetPrintableElementType::ASCII
+ : GetPrintableElementType::UTF8;
+ return DumpEncodedBufferToStream(print_style, ConvertFunction, dump_options);
}
template <>
-bool StringPrinter::ReadStringAndDumpToStream<
- StringPrinter::StringElementType::UTF8>(
+bool StringPrinter::ReadStringAndDumpToStream<StringElementType::UTF8>(
const ReadStringAndDumpToStreamOptions &options) {
- return ReadUTFBufferAndDumpToStream<llvm::UTF8>(options, nullptr);
+ return ReadEncodedBufferAndDumpToStream<llvm::UTF8>(StringElementType::UTF8,
+ options, nullptr);
}
template <>
-bool StringPrinter::ReadStringAndDumpToStream<
- StringPrinter::StringElementType::UTF16>(
+bool StringPrinter::ReadStringAndDumpToStream<StringElementType::UTF16>(
const ReadStringAndDumpToStreamOptions &options) {
- return ReadUTFBufferAndDumpToStream<llvm::UTF16>(options,
- llvm::ConvertUTF16toUTF8);
+ return ReadEncodedBufferAndDumpToStream<llvm::UTF16>(
+ StringElementType::UTF16, options, llvm::ConvertUTF16toUTF8);
}
template <>
-bool StringPrinter::ReadStringAndDumpToStream<
- StringPrinter::StringElementType::UTF32>(
+bool StringPrinter::ReadStringAndDumpToStream<StringElementType::UTF32>(
const ReadStringAndDumpToStreamOptions &options) {
- return ReadUTFBufferAndDumpToStream<llvm::UTF32>(options,
- llvm::ConvertUTF32toUTF8);
+ return ReadEncodedBufferAndDumpToStream<llvm::UTF32>(
+ StringElementType::UTF32, options, llvm::ConvertUTF32toUTF8);
}
template <>
-bool StringPrinter::ReadBufferAndDumpToStream<
- StringPrinter::StringElementType::UTF8>(
- const ReadBufferAndDumpToStreamOptions &options) {
- assert(options.GetStream() && "need a Stream to print the string to");
-
- return DumpUTFBufferToStream<llvm::UTF8>(nullptr, options);
+bool StringPrinter::ReadStringAndDumpToStream<StringElementType::ASCII>(
+ const ReadStringAndDumpToStreamOptions &options) {
+ return ReadEncodedBufferAndDumpToStream<char>(StringElementType::ASCII,
+ options, nullptr);
}
template <>
-bool StringPrinter::ReadBufferAndDumpToStream<
- StringPrinter::StringElementType::ASCII>(
+bool StringPrinter::ReadBufferAndDumpToStream<StringElementType::UTF8>(
const ReadBufferAndDumpToStreamOptions &options) {
- // treat ASCII the same as UTF8
- // FIXME: can we optimize ASCII some more?
- return ReadBufferAndDumpToStream<StringElementType::UTF8>(options);
+ return DumpEncodedBufferToStream<llvm::UTF8>(GetPrintableElementType::UTF8,
+ nullptr, options);
}
template <>
-bool StringPrinter::ReadBufferAndDumpToStream<
- StringPrinter::StringElementType::UTF16>(
+bool StringPrinter::ReadBufferAndDumpToStream<StringElementType::UTF16>(
const ReadBufferAndDumpToStreamOptions &options) {
- assert(options.GetStream() && "need a Stream to print the string to");
-
- return DumpUTFBufferToStream(llvm::ConvertUTF16toUTF8, options);
+ return DumpEncodedBufferToStream(GetPrintableElementType::UTF8,
+ llvm::ConvertUTF16toUTF8, options);
}
template <>
-bool StringPrinter::ReadBufferAndDumpToStream<
- StringPrinter::StringElementType::UTF32>(
+bool StringPrinter::ReadBufferAndDumpToStream<StringElementType::UTF32>(
const ReadBufferAndDumpToStreamOptions &options) {
- assert(options.GetStream() && "need a Stream to print the string to");
+ return DumpEncodedBufferToStream(GetPrintableElementType::UTF8,
+ llvm::ConvertUTF32toUTF8, options);
+}
- return DumpUTFBufferToStream(llvm::ConvertUTF32toUTF8, options);
+template <>
+bool StringPrinter::ReadBufferAndDumpToStream<StringElementType::ASCII>(
+ const ReadBufferAndDumpToStreamOptions &options) {
+ // Treat ASCII the same as UTF8.
+ //
+ // FIXME: This is probably not the right thing to do (well, it's debatable).
+ // If an ASCII-encoded string happens to contain a sequence of invalid bytes
+ // that forms a valid UTF8 character, we'll print out that character. This is
+ // good if you're playing fast and loose with encodings (probably good for
+ // std::string users), but maybe not so good if you care about your string
+ // formatter respecting the semantics of your selected string encoding. In
+ // the latter case you'd want to see the character byte sequence ('\x..'), not
+ // the UTF8 character itself.
+ return ReadBufferAndDumpToStream<StringElementType::UTF8>(options);
}
} // namespace formatters
diff --git a/lldb/source/DataFormatters/TypeCategory.cpp b/lldb/source/DataFormatters/TypeCategory.cpp
index 85699691f52b..8368c91a57f1 100644
--- a/lldb/source/DataFormatters/TypeCategory.cpp
+++ b/lldb/source/DataFormatters/TypeCategory.cpp
@@ -1,4 +1,4 @@
-//===-- TypeCategory.cpp -----------------------------------------*- C++-*-===//
+//===-- TypeCategory.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -86,51 +86,41 @@ void TypeCategoryImpl::AddLanguage(lldb::LanguageType lang) {
bool TypeCategoryImpl::Get(lldb::LanguageType lang,
const FormattersMatchVector &candidates,
- lldb::TypeFormatImplSP &entry, uint32_t *reason) {
+ lldb::TypeFormatImplSP &entry) {
if (!IsEnabled() || !IsApplicable(lang))
return false;
- if (GetTypeFormatsContainer()->Get(candidates, entry, reason))
+ if (GetTypeFormatsContainer()->Get(candidates, entry))
return true;
- bool regex = GetRegexTypeFormatsContainer()->Get(candidates, entry, reason);
- if (regex && reason)
- *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionSummary;
+ bool regex = GetRegexTypeFormatsContainer()->Get(candidates, entry);
return regex;
}
bool TypeCategoryImpl::Get(lldb::LanguageType lang,
const FormattersMatchVector &candidates,
- lldb::TypeSummaryImplSP &entry, uint32_t *reason) {
+ lldb::TypeSummaryImplSP &entry) {
if (!IsEnabled() || !IsApplicable(lang))
return false;
- if (GetTypeSummariesContainer()->Get(candidates, entry, reason))
+ if (GetTypeSummariesContainer()->Get(candidates, entry))
return true;
- bool regex = GetRegexTypeSummariesContainer()->Get(candidates, entry, reason);
- if (regex && reason)
- *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionSummary;
+ bool regex = GetRegexTypeSummariesContainer()->Get(candidates, entry);
return regex;
}
bool TypeCategoryImpl::Get(lldb::LanguageType lang,
const FormattersMatchVector &candidates,
- lldb::SyntheticChildrenSP &entry, uint32_t *reason) {
+ lldb::SyntheticChildrenSP &entry) {
if (!IsEnabled() || !IsApplicable(lang))
return false;
TypeFilterImpl::SharedPointer filter_sp;
- uint32_t reason_filter = 0;
- bool regex_filter = false;
// first find both Filter and Synth, and then check which is most recent
- if (!GetTypeFiltersContainer()->Get(candidates, filter_sp, &reason_filter))
- regex_filter = GetRegexTypeFiltersContainer()->Get(candidates, filter_sp,
- &reason_filter);
+ if (!GetTypeFiltersContainer()->Get(candidates, filter_sp))
+ GetRegexTypeFiltersContainer()->Get(candidates, filter_sp);
- bool regex_synth = false;
- uint32_t reason_synth = 0;
bool pick_synth = false;
ScriptedSyntheticChildren::SharedPointer synth;
- if (!GetTypeSyntheticsContainer()->Get(candidates, synth, &reason_synth))
- regex_synth = GetRegexTypeSyntheticsContainer()->Get(candidates, synth,
- &reason_synth);
+ if (!GetTypeSyntheticsContainer()->Get(candidates, synth))
+ GetRegexTypeSyntheticsContainer()->Get(candidates, synth);
if (!filter_sp.get() && !synth.get())
return false;
else if (!filter_sp.get() && synth.get())
@@ -144,13 +134,9 @@ bool TypeCategoryImpl::Get(lldb::LanguageType lang,
pick_synth = filter_sp->GetRevision() <= synth->GetRevision();
}
if (pick_synth) {
- if (regex_synth && reason)
- *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionFilter;
entry = synth;
return true;
} else {
- if (regex_filter && reason)
- *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionFilter;
entry = filter_sp;
return true;
}
@@ -492,5 +478,5 @@ std::string TypeCategoryImpl::GetDescription() {
if (print_lang)
stream.PutCString(lang_stream.GetString());
stream.PutChar(')');
- return stream.GetString();
+ return std::string(stream.GetString());
}
diff --git a/lldb/source/DataFormatters/TypeCategoryMap.cpp b/lldb/source/DataFormatters/TypeCategoryMap.cpp
index ac515154299a..a011c5414ee9 100644
--- a/lldb/source/DataFormatters/TypeCategoryMap.cpp
+++ b/lldb/source/DataFormatters/TypeCategoryMap.cpp
@@ -1,5 +1,4 @@
-//===-- TypeCategoryMap.cpp ----------------------------------------*- C++
-//-*-===//
+//===-- TypeCategoryMap.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -173,7 +172,6 @@ template <typename ImplSP>
void TypeCategoryMap::Get(FormattersMatchData &match_data, ImplSP &retval) {
std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
- uint32_t reason_why;
ActiveCategoriesIterator begin, end = m_active_categories.end();
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS));
@@ -182,13 +180,12 @@ void TypeCategoryMap::Get(FormattersMatchData &match_data, ImplSP &retval) {
for (auto match : match_data.GetMatchesVector()) {
LLDB_LOGF(
log,
- "[%s] candidate match = %s %s %s %s reason = %" PRIu32,
+ "[%s] candidate match = %s %s %s %s",
__FUNCTION__,
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());
+ match.DidStripTypedef() ? "strip-typedef" : "no-strip-typedef");
}
}
@@ -199,7 +196,7 @@ void TypeCategoryMap::Get(FormattersMatchData &match_data, ImplSP &retval) {
category_sp->GetName());
if (!category_sp->Get(
match_data.GetValueObject().GetObjectRuntimeLanguage(),
- match_data.GetMatchesVector(), current_format, &reason_why))
+ match_data.GetMatchesVector(), current_format))
continue;
retval = std::move(current_format);
diff --git a/lldb/source/DataFormatters/TypeFormat.cpp b/lldb/source/DataFormatters/TypeFormat.cpp
index b272c2e8dc3b..b9a9447c5f3e 100644
--- a/lldb/source/DataFormatters/TypeFormat.cpp
+++ b/lldb/source/DataFormatters/TypeFormat.cpp
@@ -1,4 +1,4 @@
-//===-- TypeFormat.cpp ----------------------------------------*- C++ -*-===//
+//===-- TypeFormat.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -60,7 +60,7 @@ bool TypeFormatImpl_Format::FormatObject(ValueObject *valobj,
DumpDataExtractor(data, &reg_sstr, 0, GetFormat(), reg_info->byte_size,
1, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0,
exe_ctx.GetBestExecutionContextScope());
- dest = reg_sstr.GetString();
+ dest = std::string(reg_sstr.GetString());
}
} else {
CompilerType compiler_type = value.GetCompilerType();
@@ -114,7 +114,7 @@ bool TypeFormatImpl_Format::FormatObject(ValueObject *valobj,
// here, but that's about as severe as we get
// CompilerType::DumpTypeValue() should always return something, even
// if that something is an error message
- dest = sstr.GetString();
+ dest = std::string(sstr.GetString());
}
}
return !dest.empty();
@@ -128,7 +128,7 @@ std::string TypeFormatImpl_Format::GetDescription() {
Cascades() ? "" : " (not cascading)",
SkipsPointers() ? " (skip pointers)" : "",
SkipsReferences() ? " (skip references)" : "");
- return sstr.GetString();
+ return std::string(sstr.GetString());
}
TypeFormatImpl_EnumType::TypeFormatImpl_EnumType(
@@ -191,7 +191,7 @@ bool TypeFormatImpl_EnumType::FormatObject(ValueObject *valobj,
data.GetByteSize(), 0, 0,
exe_ctx.GetBestExecutionContextScope());
if (!sstr.GetString().empty())
- dest = sstr.GetString();
+ dest = std::string(sstr.GetString());
return !dest.empty();
}
@@ -201,5 +201,5 @@ std::string TypeFormatImpl_EnumType::GetDescription() {
Cascades() ? "" : " (not cascading)",
SkipsPointers() ? " (skip pointers)" : "",
SkipsReferences() ? " (skip references)" : "");
- return sstr.GetString();
+ return std::string(sstr.GetString());
}
diff --git a/lldb/source/DataFormatters/TypeSummary.cpp b/lldb/source/DataFormatters/TypeSummary.cpp
index 7f6930fdf41f..5d4fe2e467f8 100644
--- a/lldb/source/DataFormatters/TypeSummary.cpp
+++ b/lldb/source/DataFormatters/TypeSummary.cpp
@@ -1,4 +1,4 @@
-//===-- TypeSummary.cpp ----------------------------------------*- C++ -*-===//
+//===-- TypeSummary.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -83,13 +83,13 @@ bool StringSummaryFormat::FormatObject(ValueObject *valobj, std::string &retval,
if (IsOneLiner()) {
ValueObjectPrinter printer(valobj, &s, DumpValueObjectOptions());
printer.PrintChildrenOneLiner(HideNames(valobj));
- retval = s.GetString();
+ retval = std::string(s.GetString());
return true;
} else {
if (FormatEntity::Format(m_format, s, &sc, &exe_ctx,
&sc.line_entry.range.GetBaseAddress(), valobj,
false, false)) {
- retval.assign(s.GetString());
+ retval.assign(std::string(s.GetString()));
return true;
} else {
retval.assign("error: summary string parsing error");
@@ -111,7 +111,7 @@ std::string StringSummaryFormat::GetDescription() {
SkipsPointers() ? " (skip pointers)" : "",
SkipsReferences() ? " (skip references)" : "",
HideNames(nullptr) ? " (hide member names)" : "");
- return sstr.GetString();
+ return std::string(sstr.GetString());
}
CXXFunctionSummaryFormat::CXXFunctionSummaryFormat(
@@ -126,7 +126,7 @@ bool CXXFunctionSummaryFormat::FormatObject(ValueObject *valobj,
StreamString stream;
if (!m_impl || !m_impl(*valobj, stream, options))
return false;
- dest = stream.GetString();
+ dest = std::string(stream.GetString());
return true;
}
@@ -140,7 +140,7 @@ std::string CXXFunctionSummaryFormat::GetDescription() {
SkipsReferences() ? " (skip references)" : "",
HideNames(nullptr) ? " (hide member names)" : "",
m_description.c_str());
- return sstr.GetString();
+ return std::string(sstr.GetString());
}
ScriptSummaryFormat::ScriptSummaryFormat(const TypeSummaryImpl::Flags &flags,
@@ -197,5 +197,5 @@ std::string ScriptSummaryFormat::GetDescription() {
} else {
sstr.PutCString(m_python_script);
}
- return sstr.GetString();
+ return std::string(sstr.GetString());
}
diff --git a/lldb/source/DataFormatters/TypeSynthetic.cpp b/lldb/source/DataFormatters/TypeSynthetic.cpp
index 23c80fc58d02..75388a93cc64 100644
--- a/lldb/source/DataFormatters/TypeSynthetic.cpp
+++ b/lldb/source/DataFormatters/TypeSynthetic.cpp
@@ -1,5 +1,4 @@
-//===-- TypeSynthetic.cpp ----------------------------------------*- C++
-//-*-===//
+//===-- TypeSynthetic.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -82,7 +81,7 @@ std::string TypeFilterImpl::GetDescription() {
}
sstr.Printf("}");
- return sstr.GetString();
+ return std::string(sstr.GetString());
}
std::string CXXSyntheticChildren::GetDescription() {
@@ -92,7 +91,7 @@ std::string CXXSyntheticChildren::GetDescription() {
SkipsReferences() ? " (skip references)" : "",
m_description.c_str());
- return sstr.GetString();
+ return std::string(sstr.GetString());
}
lldb::ValueObjectSP SyntheticChildrenFrontEnd::CreateValueObjectFromExpression(
@@ -213,5 +212,5 @@ std::string ScriptedSyntheticChildren::GetDescription() {
SkipsReferences() ? " (skip references)" : "",
m_python_class.c_str());
- return sstr.GetString();
+ return std::string(sstr.GetString());
}
diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index 466cf398ec24..c8a306334cf5 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -1,4 +1,4 @@
-//===-- ValueObjectPrinter.cpp -----------------------------------*- C++-*-===//
+//===-- ValueObjectPrinter.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -151,11 +151,11 @@ const char *ValueObjectPrinter::GetDescriptionForDisplay() {
return str;
}
-const char *ValueObjectPrinter::GetRootNameForDisplay(const char *if_fail) {
+const char *ValueObjectPrinter::GetRootNameForDisplay() {
const char *root_valobj_name = m_options.m_root_valobj_name.empty()
? m_valobj->GetName().AsCString()
: m_options.m_root_valobj_name.c_str();
- return root_valobj_name ? root_valobj_name : if_fail;
+ return root_valobj_name ? root_valobj_name : "";
}
bool ValueObjectPrinter::ShouldPrintValueObject() {
@@ -239,17 +239,14 @@ void ValueObjectPrinter::PrintDecl() {
// type if there is one to print
ConstString type_name;
if (m_compiler_type.IsValid()) {
- if (m_options.m_use_type_display_name)
- type_name = m_valobj->GetDisplayTypeName();
- else
- type_name = m_valobj->GetQualifiedTypeName();
+ type_name = m_options.m_use_type_display_name
+ ? m_valobj->GetDisplayTypeName()
+ : m_valobj->GetQualifiedTypeName();
} else {
// 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) {
@@ -260,21 +257,17 @@ void ValueObjectPrinter::PrintDecl() {
type_name_str.erase(iter, 2);
}
}
- typeName.Printf("%s", type_name_str.c_str());
+ typeName << type_name_str.c_str();
}
}
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 (!m_options.m_hide_name) {
- m_valobj->GetExpressionPath(varName, qualify_cxx_base_classes);
- }
- } else if (!m_options.m_hide_name) {
- const char *name_cstr = GetRootNameForDisplay("");
- varName.Printf("%s", name_cstr);
+ if (!m_options.m_hide_name) {
+ if (m_options.m_flat_output)
+ m_valobj->GetExpressionPath(varName);
+ else
+ varName << GetRootNameForDisplay();
}
bool decl_printed = false;
@@ -450,9 +443,9 @@ bool ValueObjectPrinter::PrintObjectDescriptionIfNeeded(bool value_printed,
// If the description already ends with a \n don't add another one.
size_t object_end = strlen(object_desc) - 1;
if (object_desc[object_end] == '\n')
- m_stream->Printf("%s", object_desc);
+ m_stream->Printf("%s", object_desc);
else
- m_stream->Printf("%s\n", object_desc);
+ m_stream->Printf("%s\n", object_desc);
return true;
} else if (!value_printed && !summary_printed)
return true;
diff --git a/lldb/source/DataFormatters/VectorType.cpp b/lldb/source/DataFormatters/VectorType.cpp
index 26fc03a4cdc2..fd1c0bc96cd4 100644
--- a/lldb/source/DataFormatters/VectorType.cpp
+++ b/lldb/source/DataFormatters/VectorType.cpp
@@ -1,4 +1,4 @@
-//===-- VectorType.cpp ------------------------------------------*- C++ -*-===//
+//===-- VectorType.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index 69c84640ef93..6050c1922564 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFExpression.cpp -------------------------------------*- C++ -*-===//
+//===-- DWARFExpression.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -88,8 +88,7 @@ void DWARFExpression::UpdateValue(uint64_t const_value,
void DWARFExpression::DumpLocation(Stream *s, const DataExtractor &data,
lldb::DescriptionLevel level,
ABI *abi) const {
- llvm::DWARFExpression(data.GetAsLLVM(), llvm::dwarf::DWARF_VERSION,
- data.GetAddressByteSize())
+ llvm::DWARFExpression(data.GetAsLLVM(), data.GetAddressByteSize())
.print(s->AsRawOstream(), abi ? &abi->GetMCRegisterInfo() : nullptr,
nullptr);
}
@@ -138,12 +137,15 @@ void DWARFExpression::GetDescription(Stream *s, lldb::DescriptionLevel level,
m_dwarf_cu->GetLocationTable(m_data);
llvm::MCRegisterInfo *MRI = abi ? &abi->GetMCRegisterInfo() : nullptr;
-
+ llvm::DIDumpOptions DumpOpts;
+ DumpOpts.RecoverableErrorHandler = [&](llvm::Error E) {
+ s->AsRawOstream() << "error: " << toString(std::move(E));
+ };
loctable_up->dumpLocationList(
&offset, s->AsRawOstream(),
llvm::object::SectionedAddress{m_loclist_addresses->cu_file_addr}, MRI,
DummyDWARFObject(m_data.GetByteOrder() == eByteOrderLittle), nullptr,
- llvm::DIDumpOptions(), s->GetIndentLevel() + 2);
+ DumpOpts, s->GetIndentLevel() + 2);
} else {
// We have a normal location that contains DW_OP location opcodes
DumpLocation(s, m_data, level, abi);
@@ -394,6 +396,7 @@ static offset_t GetOpcodeDataSize(const DataExtractor &data,
return offset - data_offset;
}
+ case DW_OP_GNU_entry_value:
case DW_OP_entry_value: // 0xa3 ULEB128 size + variable-length block
{
uint64_t subexpr_len = data.GetULEB128(&offset);
@@ -933,7 +936,7 @@ bool DWARFExpression::Evaluate(
Value tmp;
uint32_t reg_num;
- /// Insertion point for evaluating multi-piece expression.
+ /// Insertion point for evaluating multi-piece expression.
uint64_t op_piece_offset = 0;
Value pieces; // Used for DW_OP_piece
@@ -1183,7 +1186,7 @@ bool DWARFExpression::Evaluate(
break;
default:
stack.back().GetScalar() =
- addr_data.GetPointer(&addr_data_offset);
+ addr_data.GetAddress(&addr_data_offset);
}
stack.back().ClearContext();
} else {
@@ -2071,6 +2074,10 @@ bool DWARFExpression::Evaluate(
// not available. Fill with zeros for now by resizing the data and
// appending it
curr_piece.ResizeData(piece_byte_size);
+ // Note that "0" is not a correct value for the unknown bits.
+ // It would be better to also return a mask of valid bits together
+ // with the expression result, so the debugger can print missing
+ // members as "<optimized out>" or something.
::memset(curr_piece.GetBuffer().GetBytes(), 0, piece_byte_size);
pieces.AppendDataToHostBuffer(curr_piece);
} else {
@@ -2128,7 +2135,8 @@ bool DWARFExpression::Evaluate(
case Value::eValueTypeScalar: {
uint32_t bit_size = piece_byte_size * 8;
uint32_t bit_offset = 0;
- if (!curr_piece_source_value.GetScalar().ExtractBitfield(
+ Scalar &scalar = curr_piece_source_value.GetScalar();
+ if (!scalar.ExtractBitfield(
bit_size, bit_offset)) {
if (error_ptr)
error_ptr->SetErrorStringWithFormat(
@@ -2139,7 +2147,14 @@ bool DWARFExpression::Evaluate(
.GetByteSize());
return false;
}
- curr_piece = curr_piece_source_value;
+ // Create curr_piece with bit_size. By default Scalar
+ // grows to the nearest host integer type.
+ llvm::APInt fail_value(1, 0, false);
+ llvm::APInt ap_int = scalar.UInt128(fail_value);
+ assert(ap_int.getBitWidth() >= bit_size);
+ llvm::ArrayRef<uint64_t> buf{ap_int.getRawData(),
+ ap_int.getNumWords()};
+ curr_piece.GetScalar() = Scalar(llvm::APInt(bit_size, buf));
} break;
case Value::eValueTypeVector: {
@@ -2161,7 +2176,7 @@ bool DWARFExpression::Evaluate(
if (op_piece_offset == 0) {
// This is the first piece, we should push it back onto the stack
// so subsequent pieces will be able to access this piece and add
- // to it
+ // to it.
if (pieces.AppendDataToHostBuffer(curr_piece) == 0) {
if (error_ptr)
error_ptr->SetErrorString("failed to append piece data");
@@ -2169,7 +2184,7 @@ bool DWARFExpression::Evaluate(
}
} else {
// If this is the second or later piece there should be a value on
- // the stack
+ // the stack.
if (pieces.GetBuffer().GetByteSize() != op_piece_offset) {
if (error_ptr)
error_ptr->SetErrorStringWithFormat(
@@ -2185,8 +2200,8 @@ bool DWARFExpression::Evaluate(
return false;
}
}
- op_piece_offset += piece_byte_size;
}
+ op_piece_offset += piece_byte_size;
}
} break;
@@ -2307,6 +2322,12 @@ bool DWARFExpression::Evaluate(
// rather is a constant value. The value from the top of the stack is the
// value to be used. This is the actual object value and not the location.
case DW_OP_stack_value:
+ if (stack.empty()) {
+ if (error_ptr)
+ error_ptr->SetErrorString(
+ "Expression stack needs at least 1 item for DW_OP_stack_value.");
+ return false;
+ }
stack.back().SetValueType(Value::eValueTypeScalar);
break;
@@ -2325,8 +2346,8 @@ bool DWARFExpression::Evaluate(
return false;
}
const uint64_t die_offset = opcodes.GetULEB128(&offset);
- Scalar::Type type = Scalar::e_void;
uint64_t bit_size;
+ bool sign;
if (die_offset == 0) {
// The generic type has the size of an address on the target
// machine and an unspecified signedness. Scalar has no
@@ -2336,13 +2357,13 @@ bool DWARFExpression::Evaluate(
error_ptr->SetErrorString("No module");
return false;
}
+ sign = false;
bit_size = module_sp->GetArchitecture().GetAddressByteSize() * 8;
if (!bit_size) {
if (error_ptr)
error_ptr->SetErrorString("unspecified architecture");
return false;
}
- type = Scalar::GetBestTypeForBitSize(bit_size, false);
} else {
// Retrieve the type DIE that the value is being converted to.
// FIXME: the constness has annoying ripple effects.
@@ -2365,11 +2386,11 @@ bool DWARFExpression::Evaluate(
switch (encoding) {
case DW_ATE_signed:
case DW_ATE_signed_char:
- type = Scalar::GetBestTypeForBitSize(bit_size, true);
+ sign = true;
break;
case DW_ATE_unsigned:
case DW_ATE_unsigned_char:
- type = Scalar::GetBestTypeForBitSize(bit_size, false);
+ sign = false;
break;
default:
if (error_ptr)
@@ -2377,13 +2398,8 @@ bool DWARFExpression::Evaluate(
return false;
}
}
- if (type == Scalar::e_void) {
- if (error_ptr)
- error_ptr->SetErrorString("Unsupported pointer size");
- return false;
- }
Scalar &top = stack.back().ResolveValue(exe_ctx);
- top.TruncOrExtendTo(type, bit_size);
+ top.TruncOrExtendTo(bit_size, sign);
break;
}
@@ -2502,6 +2518,7 @@ bool DWARFExpression::Evaluate(
stack.push_back(Scalar(value));
} break;
+ case DW_OP_GNU_entry_value:
case DW_OP_entry_value: {
if (!Evaluate_DW_OP_entry_value(stack, exe_ctx, reg_ctx, opcodes, offset,
error_ptr, log)) {
@@ -2513,9 +2530,10 @@ bool DWARFExpression::Evaluate(
}
default:
- LLDB_LOGF(log, "Unhandled opcode %s in DWARFExpression.",
- DW_OP_value_to_name(op));
- break;
+ if (error_ptr)
+ error_ptr->SetErrorStringWithFormatv(
+ "Unhandled opcode {0} in DWARFExpression", LocationAtom(op));
+ return false;
}
}
@@ -2546,235 +2564,6 @@ bool DWARFExpression::Evaluate(
return true; // Return true on success
}
-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_TWOOPERANDS && opcode == DW_OP_entry_value) {
- uint = data.GetULEB128(offset_ptr);
- s.Printf("%" PRIu64 " ", uint);
- 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_addrx:
- 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:
- case DW_OP_entry_value:
- size = 128;
- break;
- default:
- s.Printf("UNKNOWN ONE-OPERAND OPCODE, #%u", opcode);
- return false;
- }
-
- 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 true;
-}
-
-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 DWARFUnit *cu, const DataExtractor &debug_loc_data,
- lldb::offset_t offset) {
- uint64_t start_addr, end_addr;
- uint32_t addr_size = DWARFUnit::GetAddressByteSize(cu);
- s.SetAddressByteSize(DWARFUnit::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)
- DumpAddressRange(s.AsRawOstream(), start_addr + base_addr,
- end_addr + base_addr, cu->GetAddressByteSize(), nullptr,
- ": ");
- 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;
- }
-}
-
static DataExtractor ToDataExtractor(const llvm::DWARFLocationExpression &loc,
ByteOrder byte_order, uint32_t addr_size) {
auto buffer_sp =
diff --git a/lldb/source/Expression/DiagnosticManager.cpp b/lldb/source/Expression/DiagnosticManager.cpp
index 48eba3586d30..08977066e333 100644
--- a/lldb/source/Expression/DiagnosticManager.cpp
+++ b/lldb/source/Expression/DiagnosticManager.cpp
@@ -1,4 +1,4 @@
-//===-- DiagnosticManager.cpp -----------------------------------*- C++ -*-===//
+//===-- DiagnosticManager.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -49,7 +49,7 @@ std::string DiagnosticManager::GetString(char separator) {
for (const auto &diagnostic : Diagnostics()) {
ret.append(StringForSeverity(diagnostic->GetSeverity()));
- ret.append(diagnostic->GetMessage());
+ ret.append(std::string(diagnostic->GetMessage()));
ret.push_back(separator);
}
diff --git a/lldb/source/Expression/Expression.cpp b/lldb/source/Expression/Expression.cpp
index 71369d0b9eec..93f585edfce3 100644
--- a/lldb/source/Expression/Expression.cpp
+++ b/lldb/source/Expression/Expression.cpp
@@ -1,4 +1,4 @@
-//===-- Expression.cpp ------------------------------------------*- C++ -*-===//
+//===-- Expression.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Expression/ExpressionVariable.cpp b/lldb/source/Expression/ExpressionVariable.cpp
index ed8da0ad8675..d95f0745cf4b 100644
--- a/lldb/source/Expression/ExpressionVariable.cpp
+++ b/lldb/source/Expression/ExpressionVariable.cpp
@@ -1,4 +1,4 @@
-//===-- ExpressionVariable.cpp ----------------------------------*- C++ -*-===//
+//===-- ExpressionVariable.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -69,20 +69,10 @@ void PersistentExpressionState::RegisterExecutionUnit(
// of the demangled name will find the mangled one (needed for looking up
// metadata pointers.)
Mangled mangler(global_var.m_name);
- mangler.GetDemangledName(lldb::eLanguageTypeUnknown);
+ mangler.GetDemangledName();
m_symbol_map[global_var.m_name.GetCString()] = global_var.m_remote_addr;
LLDB_LOGF(log, " Symbol: %s at 0x%" PRIx64 ".",
global_var.m_name.GetCString(), global_var.m_remote_addr);
}
}
}
-
-ConstString PersistentExpressionState::GetNextPersistentVariableName(
- Target &target, llvm::StringRef Prefix) {
- llvm::SmallString<64> name;
- {
- llvm::raw_svector_ostream os(name);
- os << Prefix << target.GetNextPersistentVariableIndex();
- }
- return ConstString(name);
-}
diff --git a/lldb/source/Expression/FunctionCaller.cpp b/lldb/source/Expression/FunctionCaller.cpp
index dc80c8169d7d..26ab4bfaff53 100644
--- a/lldb/source/Expression/FunctionCaller.cpp
+++ b/lldb/source/Expression/FunctionCaller.cpp
@@ -1,4 +1,4 @@
-//===-- FunctionCaller.cpp ---------------------------------------*- C++-*-===//
+//===-- FunctionCaller.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -364,8 +364,9 @@ lldb::ExpressionResults FunctionCaller::ExecuteFunction(
if (return_value != lldb::eExpressionCompleted) {
LLDB_LOGF(log,
"== [FunctionCaller::ExecuteFunction] Execution of \"%s\" "
- "completed abnormally ==",
- m_name.c_str());
+ "completed abnormally: %s ==",
+ m_name.c_str(),
+ Process::ExecutionResultAsCString(return_value));
} else {
LLDB_LOGF(log,
"== [FunctionCaller::ExecuteFunction] Execution of \"%s\" "
diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp
index e033b90cfd8b..e3c9c1d7fdf5 100644
--- a/lldb/source/Expression/IRExecutionUnit.cpp
+++ b/lldb/source/Expression/IRExecutionUnit.cpp
@@ -1,4 +1,4 @@
-//===-- IRExecutionUnit.cpp -------------------------------------*- C++ -*-===//
+//===-- IRExecutionUnit.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -265,11 +265,9 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr,
builder.setEngineKind(llvm::EngineKind::JIT)
.setErrorStr(&error_string)
- .setRelocationModel(triple.isOSBinFormatMachO()
- ? llvm::Reloc::PIC_
- : llvm::Reloc::Static)
- .setMCJITMemoryManager(
- std::unique_ptr<MemoryManager>(new MemoryManager(*this)))
+ .setRelocationModel(triple.isOSBinFormatMachO() ? llvm::Reloc::PIC_
+ : llvm::Reloc::Static)
+ .setMCJITMemoryManager(std::make_unique<MemoryManager>(*this))
.setOptLevel(llvm::CodeGenOpt::Less);
llvm::StringRef mArch;
@@ -404,9 +402,7 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr,
ss.PutCString("\n");
emitNewLine = true;
ss.PutCString(" ");
- ss.PutCString(Mangled(failed_lookup)
- .GetDemangledName(lldb::eLanguageTypeObjC_plus_plus)
- .AsCString());
+ ss.PutCString(Mangled(failed_lookup).GetDemangledName().GetStringRef());
}
m_failed_lookups.clear();
@@ -645,10 +641,8 @@ uint8_t *IRExecutionUnit::MemoryManager::allocateDataSection(
return return_value;
}
-static ConstString
-FindBestAlternateMangledName(ConstString demangled,
- const lldb::LanguageType &lang_type,
- const SymbolContext &sym_ctx) {
+static ConstString FindBestAlternateMangledName(ConstString demangled,
+ const SymbolContext &sym_ctx) {
CPlusPlusLanguage::MethodName cpp_name(demangled);
std::string scope_qualified_name = cpp_name.GetScopeQualifiedName();
@@ -670,7 +664,7 @@ FindBestAlternateMangledName(ConstString demangled,
for (size_t i = 0; i < alternates.size(); i++) {
ConstString alternate_mangled_name = alternates[i];
Mangled mangled(alternate_mangled_name);
- ConstString demangled = mangled.GetDemangledName(lang_type);
+ ConstString demangled = mangled.GetDemangledName();
CPlusPlusLanguage::MethodName alternate_cpp_name(demangled);
if (!cpp_name.IsValid())
@@ -718,12 +712,11 @@ void IRExecutionUnit::CollectCandidateCPlusPlusNames(
if (CPlusPlusLanguage::IsCPPMangledName(name.GetCString())) {
Mangled mangled(name);
- ConstString demangled =
- mangled.GetDemangledName(lldb::eLanguageTypeC_plus_plus);
+ ConstString demangled = mangled.GetDemangledName();
if (demangled) {
- ConstString best_alternate_mangled_name = FindBestAlternateMangledName(
- demangled, lldb::eLanguageTypeC_plus_plus, sc);
+ ConstString best_alternate_mangled_name =
+ FindBestAlternateMangledName(demangled, sc);
if (best_alternate_mangled_name) {
CPP_specs.push_back(best_alternate_mangled_name);
@@ -746,20 +739,22 @@ void IRExecutionUnit::CollectFallbackNames(
for (const SearchSpec &C_spec : C_specs) {
ConstString name = C_spec.name;
- if (CPlusPlusLanguage::IsCPPMangledName(name.GetCString())) {
- Mangled mangled_name(name);
- ConstString demangled_name =
- mangled_name.GetDemangledName(lldb::eLanguageTypeC_plus_plus);
- if (!demangled_name.IsEmpty()) {
- const char *demangled_cstr = demangled_name.AsCString();
- const char *lparen_loc = strchr(demangled_cstr, '(');
- if (lparen_loc) {
- llvm::StringRef base_name(demangled_cstr,
- lparen_loc - demangled_cstr);
- fallback_specs.push_back(ConstString(base_name));
- }
- }
- }
+ if (!CPlusPlusLanguage::IsCPPMangledName(name.GetCString()))
+ continue;
+
+ Mangled mangled_name(name);
+ ConstString demangled_name = mangled_name.GetDemangledName();
+ if (demangled_name.IsEmpty())
+ continue;
+
+ const char *demangled_cstr = demangled_name.AsCString();
+ const char *lparen_loc = strchr(demangled_cstr, '(');
+ if (!lparen_loc)
+ continue;
+
+ llvm::StringRef base_name(demangled_cstr,
+ lparen_loc - demangled_cstr);
+ fallback_specs.push_back(ConstString(base_name));
}
}
@@ -849,7 +844,7 @@ lldb::addr_t IRExecutionUnit::FindInSymbols(
};
if (sc.module_sp) {
- sc.module_sp->FindFunctions(spec.name, nullptr, spec.mask,
+ sc.module_sp->FindFunctions(spec.name, CompilerDeclContext(), spec.mask,
true, // include_symbols
false, // include_inlines
sc_list);
diff --git a/lldb/source/Expression/IRInterpreter.cpp b/lldb/source/Expression/IRInterpreter.cpp
index b2e4be5e40fd..4c7a65626598 100644
--- a/lldb/source/Expression/IRInterpreter.cpp
+++ b/lldb/source/Expression/IRInterpreter.cpp
@@ -1,4 +1,4 @@
-//===-- IRInterpreter.cpp ---------------------------------------*- C++ -*-===//
+//===-- IRInterpreter.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -144,10 +144,10 @@ public:
ss.Printf(" 0x%llx", (unsigned long long)addr);
}
- return ss.GetString();
+ return std::string(ss.GetString());
}
- bool AssignToMatchType(lldb_private::Scalar &scalar, uint64_t u64value,
+ bool AssignToMatchType(lldb_private::Scalar &scalar, llvm::APInt value,
Type *type) {
size_t type_size = m_target_data.getTypeStoreSize(type);
@@ -157,7 +157,7 @@ public:
if (type_size != 1)
type_size = PowerOf2Ceil(type_size);
- scalar = llvm::APInt(type_size*8, u64value);
+ scalar = value.zextOrTrunc(type_size * 8);
return true;
}
@@ -171,32 +171,32 @@ public:
if (!ResolveConstantValue(value_apint, constant))
return false;
- return AssignToMatchType(scalar, value_apint.getLimitedValue(),
- value->getType());
- } else {
- lldb::addr_t process_address = ResolveValue(value, module);
- size_t value_size = m_target_data.getTypeStoreSize(value->getType());
+ return AssignToMatchType(scalar, value_apint, value->getType());
+ }
- lldb_private::DataExtractor value_extractor;
- lldb_private::Status extract_error;
+ lldb::addr_t process_address = ResolveValue(value, module);
+ size_t value_size = m_target_data.getTypeStoreSize(value->getType());
- m_execution_unit.GetMemoryData(value_extractor, process_address,
- value_size, extract_error);
+ lldb_private::DataExtractor value_extractor;
+ lldb_private::Status extract_error;
- if (!extract_error.Success())
- return false;
+ m_execution_unit.GetMemoryData(value_extractor, process_address,
+ value_size, extract_error);
- lldb::offset_t offset = 0;
- if (value_size <= 8) {
- uint64_t u64value = value_extractor.GetMaxU64(&offset, value_size);
- return AssignToMatchType(scalar, u64value, value->getType());
- }
+ if (!extract_error.Success())
+ return false;
+
+ lldb::offset_t offset = 0;
+ if (value_size <= 8) {
+ uint64_t u64value = value_extractor.GetMaxU64(&offset, value_size);
+ return AssignToMatchType(scalar, llvm::APInt(64, u64value),
+ value->getType());
}
return false;
}
- bool AssignValue(const Value *value, lldb_private::Scalar &scalar,
+ bool AssignValue(const Value *value, lldb_private::Scalar scalar,
Module &module) {
lldb::addr_t process_address = ResolveValue(value, module);
@@ -205,7 +205,9 @@ public:
lldb_private::Scalar cast_scalar;
- if (!AssignToMatchType(cast_scalar, scalar.ULongLong(), value->getType()))
+ scalar.MakeUnsigned();
+ if (!AssignToMatchType(cast_scalar, scalar.UInt128(llvm::APInt()),
+ value->getType()))
return false;
size_t value_byte_size = m_target_data.getTypeStoreSize(value->getType());
@@ -403,7 +405,7 @@ public:
ss.Printf("%02hhx ", buf.GetBytes()[i]);
}
- return ss.GetString();
+ return std::string(ss.GetString());
}
lldb::addr_t ResolveValue(const Value *value, Module &module) {
@@ -433,8 +435,6 @@ static const char *unsupported_opcode_error =
"Interpreter doesn't handle one of the expression's opcodes";
static const char *unsupported_operand_error =
"Interpreter doesn't handle one of the expression's operands";
-// static const char *interpreter_initialization_error = "Interpreter couldn't
-// be initialized";
static const char *interpreter_internal_error =
"Interpreter encountered an internal error";
static const char *bad_value_error =
@@ -444,8 +444,6 @@ static const char *memory_allocation_error =
static const char *memory_write_error = "Interpreter couldn't write to memory";
static const char *memory_read_error = "Interpreter couldn't read from memory";
static const char *infinite_loop_error = "Interpreter ran for too many cycles";
-// static const char *bad_result_error = "Result of expression
-// is in bad memory";
static const char *too_many_functions_error =
"Interpreter doesn't handle modules with multiple function bodies.";
@@ -597,7 +595,8 @@ bool IRInterpreter::CanInterpret(llvm::Module &module, llvm::Function &function,
switch (operand_type->getTypeID()) {
default:
break;
- case Type::VectorTyID: {
+ case Type::FixedVectorTyID:
+ case Type::ScalableVectorTyID: {
LLDB_LOGF(log, "Unsupported operand type: %s",
PrintType(operand_type).c_str());
error.SetErrorString(unsupported_operand_error);
@@ -1370,7 +1369,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
// Find the address of the callee function
lldb_private::Scalar I;
- const llvm::Value *val = call_inst->getCalledValue();
+ const llvm::Value *val = call_inst->getCalledOperand();
if (!frame.EvaluateValue(I, val, module)) {
error.SetErrorToGenericError();
@@ -1510,7 +1509,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
lldb_private::ValueObject *vobj = retVal.get();
// Check if the return value is valid
- if (vobj == nullptr || retVal.empty()) {
+ if (vobj == nullptr || !retVal) {
error.SetErrorToGenericError();
error.SetErrorStringWithFormat("unable to get the return value");
return false;
diff --git a/lldb/source/Expression/IRMemoryMap.cpp b/lldb/source/Expression/IRMemoryMap.cpp
index 02a875ec833b..6b1e4c313a39 100644
--- a/lldb/source/Expression/IRMemoryMap.cpp
+++ b/lldb/source/Expression/IRMemoryMap.cpp
@@ -1,4 +1,4 @@
-//===-- IRMemoryMap.cpp -----------------------------------------*- C++ -*-===//
+//===-- IRMemoryMap.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Expression/LLVMUserExpression.cpp b/lldb/source/Expression/LLVMUserExpression.cpp
index 1fc878bbd616..187b427e66aa 100644
--- a/lldb/source/Expression/LLVMUserExpression.cpp
+++ b/lldb/source/Expression/LLVMUserExpression.cpp
@@ -1,4 +1,4 @@
-//===-- LLVMUserExpression.cpp ----------------------------------*- C++ -*-===//
+//===-- LLVMUserExpression.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -134,6 +134,10 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager,
return lldb::eExpressionSetupError;
}
+ // Store away the thread ID for error reporting, in case it exits
+ // during execution:
+ lldb::tid_t expr_thread_id = exe_ctx.GetThreadRef().GetID();
+
Address wrapper_address(m_jit_start_addr);
std::vector<lldb::addr_t> args;
@@ -223,6 +227,14 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager,
"Use \"thread return -x\" to return to the state before expression "
"evaluation.");
return execution_result;
+ } else if (execution_result == lldb::eExpressionThreadVanished) {
+ diagnostic_manager.Printf(
+ eDiagnosticSeverityError,
+ "Couldn't complete execution; the thread "
+ "on which the expression was being run: 0x%" PRIx64
+ " exited during its execution.",
+ expr_thread_id);
+ return execution_result;
} else if (execution_result != lldb::eExpressionCompleted) {
diagnostic_manager.Printf(
eDiagnosticSeverityError, "Couldn't execute function; result was %s",
@@ -357,8 +369,3 @@ bool LLVMUserExpression::PrepareToExecuteJITExpression(
return true;
}
-lldb::ModuleSP LLVMUserExpression::GetJITModule() {
- if (m_execution_unit_sp)
- return m_execution_unit_sp->GetJITModule();
- return lldb::ModuleSP();
-}
diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp
index cd332484debb..f33462053f22 100644
--- a/lldb/source/Expression/Materializer.cpp
+++ b/lldb/source/Expression/Materializer.cpp
@@ -1,4 +1,4 @@
-//===-- Materializer.cpp ----------------------------------------*- C++ -*-===//
+//===-- Materializer.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -399,7 +399,8 @@ uint32_t Materializer::AddPersistentVariable(
lldb::ExpressionVariableSP &persistent_variable_sp,
PersistentVariableDelegate *delegate, Status &err) {
EntityVector::iterator iter = m_entities.insert(m_entities.end(), EntityUP());
- iter->reset(new EntityPersistentVariable(persistent_variable_sp, delegate));
+ *iter = std::make_unique<EntityPersistentVariable>(persistent_variable_sp,
+ delegate);
uint32_t ret = AddStructMember(**iter);
(*iter)->SetOffset(ret);
return ret;
@@ -698,7 +699,7 @@ public:
lldb::offset_t offset;
- ptr = extractor.GetPointer(&offset);
+ ptr = extractor.GetAddress(&offset);
dump_stream.PutChar('\n');
}
@@ -752,7 +753,7 @@ private:
uint32_t Materializer::AddVariable(lldb::VariableSP &variable_sp, Status &err) {
EntityVector::iterator iter = m_entities.insert(m_entities.end(), EntityUP());
- iter->reset(new EntityVariable(variable_sp));
+ *iter = std::make_unique<EntityVariable>(variable_sp);
uint32_t ret = AddStructMember(**iter);
(*iter)->SetOffset(ret);
return ret;
@@ -784,7 +785,9 @@ public:
const lldb::addr_t load_addr = process_address + m_offset;
- ExecutionContextScope *exe_scope = map.GetBestExecutionContextScope();
+ ExecutionContextScope *exe_scope = frame_sp.get();
+ if (!exe_scope)
+ exe_scope = map.GetBestExecutionContextScope();
llvm::Optional<uint64_t> byte_size = m_type.GetByteSize(exe_scope);
if (!byte_size) {
@@ -834,7 +837,9 @@ public:
lldb::addr_t frame_bottom, Status &err) override {
err.Clear();
- ExecutionContextScope *exe_scope = map.GetBestExecutionContextScope();
+ ExecutionContextScope *exe_scope = frame_sp.get();
+ if (!exe_scope)
+ exe_scope = map.GetBestExecutionContextScope();
if (!exe_scope) {
err.SetErrorString("Couldn't dematerialize a result variable: invalid "
@@ -881,11 +886,9 @@ public:
return;
}
- ConstString name =
- m_delegate
- ? m_delegate->GetName()
- : persistent_state->GetNextPersistentVariableName(
- *target_sp, persistent_state->GetPersistentVariablePrefix());
+ ConstString name = m_delegate
+ ? m_delegate->GetName()
+ : persistent_state->GetNextPersistentVariableName();
lldb::ExpressionVariableSP ret = persistent_state->CreatePersistentVariable(
exe_scope, name, m_type, map.GetByteOrder(), map.GetAddressByteSize());
@@ -972,7 +975,7 @@ public:
lldb::offset_t offset;
- ptr = extractor.GetPointer(&offset);
+ ptr = extractor.GetAddress(&offset);
dump_stream.PutChar('\n');
}
@@ -1032,8 +1035,8 @@ uint32_t Materializer::AddResultVariable(const CompilerType &type,
PersistentVariableDelegate *delegate,
Status &err) {
EntityVector::iterator iter = m_entities.insert(m_entities.end(), EntityUP());
- iter->reset(new EntityResultVariable(type, is_program_reference,
- keep_in_memory, delegate));
+ *iter = std::make_unique<EntityResultVariable>(type, is_program_reference,
+ keep_in_memory, delegate);
uint32_t ret = AddStructMember(**iter);
(*iter)->SetOffset(ret);
return ret;
@@ -1062,7 +1065,9 @@ public:
const Address sym_address = m_symbol.GetAddress();
- ExecutionContextScope *exe_scope = map.GetBestExecutionContextScope();
+ ExecutionContextScope *exe_scope = frame_sp.get();
+ if (!exe_scope)
+ exe_scope = map.GetBestExecutionContextScope();
lldb::TargetSP target_sp;
@@ -1149,7 +1154,7 @@ private:
uint32_t Materializer::AddSymbol(const Symbol &symbol_sp, Status &err) {
EntityVector::iterator iter = m_entities.insert(m_entities.end(), EntityUP());
- iter->reset(new EntitySymbol(symbol_sp));
+ *iter = std::make_unique<EntitySymbol>(symbol_sp);
uint32_t ret = AddStructMember(**iter);
(*iter)->SetOffset(ret);
return ret;
@@ -1326,15 +1331,12 @@ private:
uint32_t Materializer::AddRegister(const RegisterInfo &register_info,
Status &err) {
EntityVector::iterator iter = m_entities.insert(m_entities.end(), EntityUP());
- iter->reset(new EntityRegister(register_info));
+ *iter = std::make_unique<EntityRegister>(register_info);
uint32_t ret = AddStructMember(**iter);
(*iter)->SetOffset(ret);
return ret;
}
-Materializer::Materializer()
- : m_dematerializer_wp(), m_current_offset(0), m_struct_alignment(8) {}
-
Materializer::~Materializer() {
DematerializerSP dematerializer_sp = m_dematerializer_wp.lock();
@@ -1346,7 +1348,6 @@ Materializer::DematerializerSP
Materializer::Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
lldb::addr_t process_address, Status &error) {
ExecutionContextScope *exe_scope = frame_sp.get();
-
if (!exe_scope)
exe_scope = map.GetBestExecutionContextScope();
@@ -1397,7 +1398,9 @@ void Materializer::Dematerializer::Dematerialize(Status &error,
if (thread_sp)
frame_sp = thread_sp->GetFrameWithStackID(m_stack_id);
- ExecutionContextScope *exe_scope = m_map->GetBestExecutionContextScope();
+ ExecutionContextScope *exe_scope = frame_sp.get();
+ if (!exe_scope)
+ exe_scope = m_map->GetBestExecutionContextScope();
if (!IsValid()) {
error.SetErrorToGenericError();
diff --git a/lldb/source/Expression/REPL.cpp b/lldb/source/Expression/REPL.cpp
index fcd083684738..fd7c39686921 100644
--- a/lldb/source/Expression/REPL.cpp
+++ b/lldb/source/Expression/REPL.cpp
@@ -1,4 +1,4 @@
-//===-- REPL.cpp ------------------------------------------------*- C++ -*-===//
+//===-- REPL.cpp ----------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -53,11 +53,11 @@ std::string REPL::GetSourcePath() {
ConstString file_basename = GetSourceFileBasename();
FileSpec tmpdir_file_spec = HostInfo::GetProcessTempDir();
if (tmpdir_file_spec) {
- tmpdir_file_spec.GetFilename().SetCString(file_basename.AsCString());
+ tmpdir_file_spec.GetFilename() = file_basename;
m_repl_source_path = tmpdir_file_spec.GetPath();
} else {
tmpdir_file_spec = FileSpec("/tmp");
- tmpdir_file_spec.AppendPathComponent(file_basename.AsCString());
+ tmpdir_file_spec.AppendPathComponent(file_basename.GetStringRef());
}
return tmpdir_file_spec.GetPath();
@@ -216,7 +216,7 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) {
ci.SetPromptOnQuit(false);
// Execute the command
- CommandReturnObject result;
+ CommandReturnObject result(debugger.GetUseColor());
result.SetImmediateOutputStream(output_sp);
result.SetImmediateErrorStream(error_sp);
ci.HandleCommand(code.c_str(), eLazyBoolNo, result);
@@ -252,7 +252,7 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) {
lldb::IOHandlerSP io_handler_sp(ci.GetIOHandler());
if (io_handler_sp) {
io_handler_sp->SetIsDone(false);
- debugger.PushIOHandler(ci.GetIOHandler());
+ debugger.RunIOHandlerAsync(ci.GetIOHandler());
}
}
}
@@ -291,12 +291,10 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) {
const char *expr_prefix = nullptr;
lldb::ValueObjectSP result_valobj_sp;
Status 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,
- nullptr, // Fixed Expression
- &jit_module_sp);
+ nullptr); // fixed expression
// CommandInterpreter &ci = debugger.GetCommandInterpreter();
@@ -370,7 +368,7 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) {
lldb::IOHandlerSP io_handler_sp(ci.GetIOHandler());
if (io_handler_sp) {
io_handler_sp->SetIsDone(false);
- debugger.PushIOHandler(ci.GetIOHandler());
+ debugger.RunIOHandlerAsync(ci.GetIOHandler());
}
}
break;
@@ -390,6 +388,11 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) {
error_sp->Printf("error: stopped for debug -- %s\n",
error.AsCString());
break;
+ case lldb::eExpressionThreadVanished:
+ // Shoulnd't happen???
+ error_sp->Printf("error: expression thread vanished -- %s\n",
+ error.AsCString());
+ break;
}
}
@@ -454,6 +457,10 @@ void REPL::IOHandlerComplete(IOHandler &io_handler,
debugger.GetCommandInterpreter().HandleCompletion(sub_request);
StringList matches, descriptions;
sub_result.GetMatches(matches);
+ // Prepend command prefix that was excluded in the completion request.
+ if (request.GetCursorIndex() == 0)
+ for (auto &match : matches)
+ match.insert(0, 1, ':');
sub_result.GetDescriptions(descriptions);
request.AddCompletions(matches, descriptions);
return;
@@ -488,14 +495,7 @@ void REPL::IOHandlerComplete(IOHandler &io_handler,
current_code.append("\n");
current_code += request.GetRawLine();
- StringList matches;
- int result = CompleteCode(current_code, matches);
- if (result == -2) {
- assert(matches.GetSize() == 1);
- request.AddCompletion(matches.GetStringAtIndex(0), "",
- CompletionMode::RewriteLine);
- } else
- request.AddCompletions(matches);
+ CompleteCode(current_code, request);
}
bool QuitCommandOverrideCallback(void *baton, const char **argv) {
@@ -530,7 +530,7 @@ Status REPL::RunLoop() {
save_default_line);
}
- debugger.PushIOHandler(io_handler_sp);
+ debugger.RunIOHandlerAsync(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
diff --git a/lldb/source/Expression/UserExpression.cpp b/lldb/source/Expression/UserExpression.cpp
index 3b507da8e4ab..47d13f052bfb 100644
--- a/lldb/source/Expression/UserExpression.cpp
+++ b/lldb/source/Expression/UserExpression.cpp
@@ -1,4 +1,4 @@
-//===-- UserExpression.cpp ---------------------------------*- C++ -*-===//
+//===-- UserExpression.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -53,8 +53,9 @@ UserExpression::UserExpression(ExecutionContextScope &exe_scope,
lldb::LanguageType language,
ResultType desired_type,
const EvaluateExpressionOptions &options)
- : Expression(exe_scope), m_expr_text(expr), m_expr_prefix(prefix),
- m_language(language), m_desired_type(desired_type), m_options(options) {}
+ : Expression(exe_scope), m_expr_text(std::string(expr)),
+ m_expr_prefix(std::string(prefix)), m_language(language),
+ m_desired_type(desired_type), m_options(options) {}
UserExpression::~UserExpression() {}
@@ -116,7 +117,7 @@ lldb::addr_t UserExpression::GetObjectPointer(lldb::StackFrameSP frame_sp,
lldb::ValueObjectSP valobj_sp;
valobj_sp = frame_sp->GetValueForVariableExpressionPath(
- object_name.AsCString(), lldb::eNoDynamicValues,
+ object_name.GetStringRef(), lldb::eNoDynamicValues,
StackFrame::eExpressionPathOptionCheckPtrVsMember |
StackFrame::eExpressionPathOptionsNoFragileObjcIvar |
StackFrame::eExpressionPathOptionsNoSyntheticChildren |
@@ -138,12 +139,12 @@ lldb::addr_t UserExpression::GetObjectPointer(lldb::StackFrameSP frame_sp,
return ret;
}
-lldb::ExpressionResults UserExpression::Evaluate(
- ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options,
- llvm::StringRef expr, llvm::StringRef prefix,
- lldb::ValueObjectSP &result_valobj_sp, Status &error,
- std::string *fixed_expression, lldb::ModuleSP *jit_module_sp_ptr,
- ValueObject *ctx_obj) {
+lldb::ExpressionResults
+UserExpression::Evaluate(ExecutionContext &exe_ctx,
+ const EvaluateExpressionOptions &options,
+ llvm::StringRef expr, llvm::StringRef prefix,
+ lldb::ValueObjectSP &result_valobj_sp, Status &error,
+ std::string *fixed_expression, ValueObject *ctx_obj) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS |
LIBLLDB_LOG_STEP));
@@ -167,8 +168,8 @@ lldb::ExpressionResults UserExpression::Evaluate(
Target *target = exe_ctx.GetTargetPtr();
if (!target) {
- LLDB_LOGF(log, "== [UserExpression::Evaluate] Passed a NULL target, can't "
- "run expressions.");
+ LLDB_LOG(log, "== [UserExpression::Evaluate] Passed a NULL target, can't "
+ "run expressions.");
error.SetErrorString("expression passed a null target");
return lldb::eExpressionSetupError;
}
@@ -177,9 +178,8 @@ lldb::ExpressionResults UserExpression::Evaluate(
if (process == nullptr || process->GetState() != lldb::eStateStopped) {
if (execution_policy == eExecutionPolicyAlways) {
- LLDB_LOGF(log,
- "== [UserExpression::Evaluate] Expression may not run, but "
- "is not constant ==");
+ LLDB_LOG(log, "== [UserExpression::Evaluate] Expression may not run, but "
+ "is not constant ==");
error.SetErrorString("expression needed to run but couldn't");
@@ -201,8 +201,8 @@ lldb::ExpressionResults UserExpression::Evaluate(
llvm::StringRef option_prefix(options.GetPrefix());
std::string full_prefix_storage;
if (!prefix.empty() && !option_prefix.empty()) {
- full_prefix_storage = prefix;
- full_prefix_storage.append(option_prefix);
+ full_prefix_storage = std::string(prefix);
+ full_prefix_storage.append(std::string(option_prefix));
full_prefix = full_prefix_storage;
} else if (!prefix.empty())
full_prefix = prefix;
@@ -224,15 +224,13 @@ lldb::ExpressionResults UserExpression::Evaluate(
desired_type, options, ctx_obj,
error));
if (error.Fail()) {
- if (log)
- LLDB_LOGF(log, "== [UserExpression::Evaluate] Getting expression: %s ==",
- error.AsCString());
+ LLDB_LOG(log, "== [UserExpression::Evaluate] Getting expression: {0} ==",
+ error.AsCString());
return lldb::eExpressionSetupError;
}
- if (log)
- LLDB_LOGF(log, "== [UserExpression::Evaluate] Parsing expression %s ==",
- expr.str().c_str());
+ LLDB_LOG(log, "== [UserExpression::Evaluate] Parsing expression {0} ==",
+ expr.str());
const bool keep_expression_in_memory = true;
const bool generate_debug_info = options.GetGenerateDebugInfo();
@@ -261,25 +259,40 @@ lldb::ExpressionResults UserExpression::Evaluate(
// If there is a fixed expression, try to parse it:
if (!parse_success) {
+ // Delete the expression that failed to parse before attempting to parse
+ // the next expression.
+ user_expression_sp.reset();
+
execution_results = lldb::eExpressionParseError;
if (fixed_expression && !fixed_expression->empty() &&
options.GetAutoApplyFixIts()) {
- lldb::UserExpressionSP fixed_expression_sp(
- target->GetUserExpressionForLanguage(fixed_expression->c_str(),
- full_prefix, language,
- desired_type, options, ctx_obj,
- error));
- DiagnosticManager fixed_diagnostic_manager;
- parse_success = fixed_expression_sp->Parse(
- fixed_diagnostic_manager, exe_ctx, execution_policy,
- keep_expression_in_memory, generate_debug_info);
- if (parse_success) {
- diagnostic_manager.Clear();
- user_expression_sp = fixed_expression_sp;
- } else {
- // If the fixed expression failed to parse, don't tell the user about,
- // that won't help.
- fixed_expression->clear();
+ const uint64_t max_fix_retries = options.GetRetriesWithFixIts();
+ for (uint64_t i = 0; i < max_fix_retries; ++i) {
+ // Try parsing the fixed expression.
+ lldb::UserExpressionSP fixed_expression_sp(
+ target->GetUserExpressionForLanguage(
+ fixed_expression->c_str(), full_prefix, language, desired_type,
+ options, ctx_obj, error));
+ DiagnosticManager fixed_diagnostic_manager;
+ parse_success = fixed_expression_sp->Parse(
+ fixed_diagnostic_manager, exe_ctx, execution_policy,
+ keep_expression_in_memory, generate_debug_info);
+ if (parse_success) {
+ diagnostic_manager.Clear();
+ user_expression_sp = fixed_expression_sp;
+ break;
+ } else {
+ // The fixed expression also didn't parse. Let's check for any new
+ // Fix-Its we could try.
+ if (fixed_expression_sp->GetFixedText()) {
+ *fixed_expression = fixed_expression_sp->GetFixedText();
+ } else {
+ // Fixed expression didn't compile without a fixit, don't retry and
+ // don't tell the user about it.
+ fixed_expression->clear();
+ break;
+ }
+ }
}
}
@@ -301,19 +314,12 @@ lldb::ExpressionResults UserExpression::Evaluate(
}
if (parse_success) {
- // 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)
- LLDB_LOGF(log,
- "== [UserExpression::Evaluate] Expression may not run, but "
- "is not constant ==");
+ LLDB_LOG(log, "== [UserExpression::Evaluate] Expression may not run, but "
+ "is not constant ==");
if (!diagnostic_manager.Diagnostics().size())
error.SetExpressionError(lldb::eExpressionSetupError,
@@ -333,17 +339,15 @@ lldb::ExpressionResults UserExpression::Evaluate(
diagnostic_manager.Clear();
- if (log)
- LLDB_LOGF(log, "== [UserExpression::Evaluate] Executing expression ==");
+ LLDB_LOG(log, "== [UserExpression::Evaluate] Executing expression ==");
execution_results =
user_expression_sp->Execute(diagnostic_manager, exe_ctx, options,
user_expression_sp, expr_result);
if (execution_results != lldb::eExpressionCompleted) {
- if (log)
- LLDB_LOGF(log, "== [UserExpression::Evaluate] Execution completed "
- "abnormally ==");
+ LLDB_LOG(log, "== [UserExpression::Evaluate] Execution completed "
+ "abnormally ==");
if (!diagnostic_manager.Diagnostics().size())
error.SetExpressionError(
@@ -355,15 +359,13 @@ lldb::ExpressionResults UserExpression::Evaluate(
if (expr_result) {
result_valobj_sp = expr_result->GetValueObject();
- if (log)
- LLDB_LOGF(log,
- "== [UserExpression::Evaluate] Execution completed "
- "normally with result %s ==",
- result_valobj_sp->GetValueAsCString());
+ LLDB_LOG(log,
+ "== [UserExpression::Evaluate] Execution completed "
+ "normally with result %s ==",
+ result_valobj_sp->GetValueAsCString());
} else {
- if (log)
- LLDB_LOGF(log, "== [UserExpression::Evaluate] Execution completed "
- "normally with no result ==");
+ LLDB_LOG(log, "== [UserExpression::Evaluate] Execution completed "
+ "normally with no result ==");
error.SetError(UserExpression::kNoResult, lldb::eErrorTypeGeneric);
}
diff --git a/lldb/source/Expression/UtilityFunction.cpp b/lldb/source/Expression/UtilityFunction.cpp
index 2dbc0e9d73ed..3de2ee2acbbf 100644
--- a/lldb/source/Expression/UtilityFunction.cpp
+++ b/lldb/source/Expression/UtilityFunction.cpp
@@ -1,4 +1,4 @@
-//===-- UtilityFunction.cpp -------------------------------------*- C++ -*-===//
+//===-- UtilityFunction.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp
index 5fd5a0cfc7fc..226e638aba25 100644
--- a/lldb/source/Host/common/Editline.cpp
+++ b/lldb/source/Host/common/Editline.cpp
@@ -1,4 +1,4 @@
-//===-- Editline.cpp --------------------------------------------*- C++ -*-===//
+//===-- Editline.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include <iomanip>
-#include <iostream>
#include <limits.h>
#include "lldb/Host/ConnectionFileDescriptor.h"
@@ -35,7 +34,7 @@ using namespace lldb_private::line_editor;
// with until TERM is set to VT100 where it stumbles over an implementation
// assumption that may not exist on other platforms. The setupterm() function
// would normally require headers that don't work gracefully in this context,
-// so the function declaraction has been hoisted here.
+// so the function declaration has been hoisted here.
#if defined(__APPLE__)
extern "C" {
int setupterm(char *term, int fildes, int *errret);
@@ -99,18 +98,24 @@ bool IsOnlySpaces(const EditLineStringType &content) {
static int GetOperation(HistoryOperation op) {
// The naming used by editline for the history operations is counter
- // intuitive to how it's used here.
+ // intuitive to how it's used in LLDB's editline implementation.
+ //
+ // - The H_LAST returns the oldest entry in the history.
//
// - The H_PREV operation returns the previous element in the history, which
// is newer than the current one.
//
+ // - The H_CURR returns the current entry in the history.
+ //
// - The H_NEXT operation returns the next element in the history, which is
// older than the current one.
//
+ // - The H_FIRST returns the most recent entry in the history.
+ //
// The naming of the enum entries match the semantic meaning.
switch(op) {
case HistoryOperation::Oldest:
- return H_FIRST;
+ return H_LAST;
case HistoryOperation::Older:
return H_NEXT;
case HistoryOperation::Current:
@@ -118,7 +123,7 @@ static int GetOperation(HistoryOperation op) {
case HistoryOperation::Newer:
return H_PREV;
case HistoryOperation::Newest:
- return H_LAST;
+ return H_FIRST;
}
llvm_unreachable("Fully covered switch!");
}
@@ -138,10 +143,10 @@ std::vector<EditLineStringType> SplitLines(const EditLineStringType &input) {
while (start < input.length()) {
size_t end = input.find('\n', start);
if (end == std::string::npos) {
- result.insert(result.end(), input.substr(start));
+ result.push_back(input.substr(start));
break;
}
- result.insert(result.end(), input.substr(start, end - start));
+ result.push_back(input.substr(start, end - start));
start = end + 1;
}
return result;
@@ -214,7 +219,7 @@ private:
std::string filename = m_prefix + "-history";
#endif
llvm::sys::path::append(lldb_history_file, filename);
- m_path = lldb_history_file.str();
+ m_path = std::string(lldb_history_file.str());
}
}
@@ -296,19 +301,16 @@ protected:
// Editline private methods
void Editline::SetBaseLineNumber(int line_number) {
- std::stringstream line_number_stream;
- line_number_stream << line_number;
m_base_line_number = line_number;
m_line_number_digits =
- std::max(3, (int)line_number_stream.str().length() + 1);
+ std::max<int>(3, std::to_string(line_number).length() + 1);
}
std::string Editline::PromptForIndex(int line_index) {
bool use_line_numbers = m_multiline_enabled && m_base_line_number > 0;
std::string prompt = m_set_prompt;
- if (use_line_numbers && prompt.length() == 0) {
+ if (use_line_numbers && prompt.length() == 0)
prompt = ": ";
- }
std::string continuation_prompt = prompt;
if (m_set_continuation_prompt.length() > 0) {
continuation_prompt = m_set_continuation_prompt;
@@ -327,7 +329,7 @@ std::string Editline::PromptForIndex(int line_index) {
prompt_stream.Printf(
"%*d%s", m_line_number_digits, m_base_line_number + line_index,
(line_index == 0) ? prompt.c_str() : continuation_prompt.c_str());
- return std::move(prompt_stream.GetString());
+ return std::string(std::move(prompt_stream.GetString()));
}
return (line_index == 0) ? prompt : continuation_prompt;
}
@@ -423,7 +425,7 @@ void Editline::DisplayInput(int firstIndex) {
}
int Editline::CountRowsForLine(const EditLineStringType &content) {
- auto prompt =
+ std::string prompt =
PromptForIndex(0); // Prompt width is constant during an edit session
int line_length = (int)(content.length() + prompt.length());
return (line_length / m_terminal_width) + 1;
@@ -557,6 +559,9 @@ int Editline::GetCharacter(EditLineGetCharType *c) {
lldb::ConnectionStatus status = lldb::eConnectionStatusSuccess;
char ch = 0;
+ if (m_terminal_size_has_changed)
+ ApplyTerminalSizeChange();
+
// This mutex is locked by our caller (GetLine). Unlock it while we read a
// character (blocking operation), so we do not hold the mutex
// indefinitely. This gives a chance for someone to interrupt us. After
@@ -1049,7 +1054,7 @@ void Editline::ConfigureEditor(bool multiline) {
m_editline =
el_init(m_editor_name.c_str(), m_input_file, m_output_file, m_error_file);
- TerminalSizeChanged();
+ ApplyTerminalSizeChange();
if (m_history_sp && m_history_sp->IsValid()) {
if (!m_history_sp->Load()) {
@@ -1302,28 +1307,32 @@ void Editline::SetContinuationPrompt(const char *continuation_prompt) {
continuation_prompt == nullptr ? "" : continuation_prompt;
}
-void Editline::TerminalSizeChanged() {
- if (m_editline != nullptr) {
- el_resize(m_editline);
- int columns;
- // This function is documenting as taking (const char *, void *) for the
- // vararg part, but in reality in was consuming arguments until the first
- // null pointer. This was fixed in libedit in April 2019
- // <http://mail-index.netbsd.org/source-changes/2019/04/26/msg105454.html>,
- // but we're keeping the workaround until a version with that fix is more
- // widely available.
- if (el_get(m_editline, EL_GETTC, "co", &columns, nullptr) == 0) {
- m_terminal_width = columns;
- if (m_current_line_rows != -1) {
- const LineInfoW *info = el_wline(m_editline);
- int lineLength =
- (int)((info->lastchar - info->buffer) + GetPromptWidth());
- m_current_line_rows = (lineLength / columns) + 1;
- }
- } else {
- m_terminal_width = INT_MAX;
- m_current_line_rows = 1;
+void Editline::TerminalSizeChanged() { m_terminal_size_has_changed = 1; }
+
+void Editline::ApplyTerminalSizeChange() {
+ if (!m_editline)
+ return;
+
+ m_terminal_size_has_changed = 0;
+ el_resize(m_editline);
+ int columns;
+ // This function is documenting as taking (const char *, void *) for the
+ // vararg part, but in reality in was consuming arguments until the first
+ // null pointer. This was fixed in libedit in April 2019
+ // <http://mail-index.netbsd.org/source-changes/2019/04/26/msg105454.html>,
+ // but we're keeping the workaround until a version with that fix is more
+ // widely available.
+ if (el_get(m_editline, EL_GETTC, "co", &columns, nullptr) == 0) {
+ m_terminal_width = columns;
+ if (m_current_line_rows != -1) {
+ const LineInfoW *info = el_wline(m_editline);
+ int lineLength =
+ (int)((info->lastchar - info->buffer) + GetPromptWidth());
+ m_current_line_rows = (lineLength / columns) + 1;
}
+ } else {
+ m_terminal_width = INT_MAX;
+ m_current_line_rows = 1;
}
}
diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp
index 7850222376f7..a5b970907e64 100644
--- a/lldb/source/Host/common/File.cpp
+++ b/lldb/source/Host/common/File.cpp
@@ -1,4 +1,4 @@
-//===-- File.cpp ------------------------------------------------*- C++ -*-===//
+//===-- File.cpp ----------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/FileAction.cpp b/lldb/source/Host/common/FileAction.cpp
index 3268d952bcc9..8b4e7f4c2208 100644
--- a/lldb/source/Host/common/FileAction.cpp
+++ b/lldb/source/Host/common/FileAction.cpp
@@ -1,4 +1,4 @@
-//===-- FileAction.cpp ------------------------------------------*- C++ -*-===//
+//===-- FileAction.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/FileCache.cpp b/lldb/source/Host/common/FileCache.cpp
index d9dcad992c33..da9a748e2f13 100644
--- a/lldb/source/Host/common/FileCache.cpp
+++ b/lldb/source/Host/common/FileCache.cpp
@@ -1,4 +1,4 @@
-//===-- FileCache.cpp -------------------------------------------*- C++ -*-===//
+//===-- FileCache.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/FileSystem.cpp b/lldb/source/Host/common/FileSystem.cpp
index 2db5bff3207f..0fa27d131e1a 100644
--- a/lldb/source/Host/common/FileSystem.cpp
+++ b/lldb/source/Host/common/FileSystem.cpp
@@ -1,4 +1,4 @@
-//===-- FileSystem.cpp ------------------------------------------*- C++ -*-===//
+//===-- FileSystem.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -87,6 +87,11 @@ Optional<FileSystem> &FileSystem::InstanceImpl() {
vfs::directory_iterator FileSystem::DirBegin(const FileSpec &file_spec,
std::error_code &ec) {
+ if (!file_spec) {
+ ec = std::error_code(static_cast<int>(errc::no_such_file_or_directory),
+ std::system_category());
+ return {};
+ }
return DirBegin(file_spec.GetPath(), ec);
}
@@ -97,6 +102,9 @@ vfs::directory_iterator FileSystem::DirBegin(const Twine &dir,
llvm::ErrorOr<vfs::Status>
FileSystem::GetStatus(const FileSpec &file_spec) const {
+ if (!file_spec)
+ return std::error_code(static_cast<int>(errc::no_such_file_or_directory),
+ std::system_category());
return GetStatus(file_spec.GetPath());
}
@@ -106,6 +114,8 @@ llvm::ErrorOr<vfs::Status> FileSystem::GetStatus(const Twine &path) const {
sys::TimePoint<>
FileSystem::GetModificationTime(const FileSpec &file_spec) const {
+ if (!file_spec)
+ return sys::TimePoint<>();
return GetModificationTime(file_spec.GetPath());
}
@@ -117,6 +127,8 @@ sys::TimePoint<> FileSystem::GetModificationTime(const Twine &path) const {
}
uint64_t FileSystem::GetByteSize(const FileSpec &file_spec) const {
+ if (!file_spec)
+ return 0;
return GetByteSize(file_spec.GetPath());
}
@@ -133,6 +145,8 @@ uint32_t FileSystem::GetPermissions(const FileSpec &file_spec) const {
uint32_t FileSystem::GetPermissions(const FileSpec &file_spec,
std::error_code &ec) const {
+ if (!file_spec)
+ return sys::fs::perms::perms_not_known;
return GetPermissions(file_spec.GetPath(), ec);
}
@@ -154,7 +168,7 @@ uint32_t FileSystem::GetPermissions(const Twine &path,
bool FileSystem::Exists(const Twine &path) const { return m_fs->exists(path); }
bool FileSystem::Exists(const FileSpec &file_spec) const {
- return Exists(file_spec.GetPath());
+ return file_spec && Exists(file_spec.GetPath());
}
bool FileSystem::Readable(const Twine &path) const {
@@ -162,7 +176,7 @@ bool FileSystem::Readable(const Twine &path) const {
}
bool FileSystem::Readable(const FileSpec &file_spec) const {
- return Readable(file_spec.GetPath());
+ return file_spec && Readable(file_spec.GetPath());
}
bool FileSystem::IsDirectory(const Twine &path) const {
@@ -173,7 +187,7 @@ bool FileSystem::IsDirectory(const Twine &path) const {
}
bool FileSystem::IsDirectory(const FileSpec &file_spec) const {
- return IsDirectory(file_spec.GetPath());
+ return file_spec && IsDirectory(file_spec.GetPath());
}
bool FileSystem::IsLocal(const Twine &path) const {
@@ -183,7 +197,7 @@ bool FileSystem::IsLocal(const Twine &path) const {
}
bool FileSystem::IsLocal(const FileSpec &file_spec) const {
- return IsLocal(file_spec.GetPath());
+ return file_spec && IsLocal(file_spec.GetPath());
}
void FileSystem::EnumerateDirectory(Twine path, bool find_directories,
@@ -261,6 +275,9 @@ void FileSystem::Resolve(SmallVectorImpl<char> &path) {
}
void FileSystem::Resolve(FileSpec &file_spec) {
+ if (!file_spec)
+ return;
+
// Extract path from the FileSpec.
SmallString<128> path;
file_spec.GetPath(path);
@@ -279,8 +296,7 @@ void FileSystem::Resolve(FileSpec &file_spec) {
std::shared_ptr<DataBufferLLVM>
FileSystem::CreateDataBuffer(const llvm::Twine &path, uint64_t size,
uint64_t offset) {
- if (m_collector)
- m_collector->addFile(path);
+ Collect(path);
const bool is_volatile = !IsLocal(path);
const ErrorOr<std::string> external_path = GetExternalPath(path);
@@ -418,8 +434,7 @@ static mode_t GetOpenMode(uint32_t permissions) {
Expected<FileUP> FileSystem::Open(const FileSpec &file_spec,
File::OpenOptions options,
uint32_t permissions, bool should_close_fd) {
- if (m_collector)
- m_collector->addFile(file_spec.GetPath());
+ Collect(file_spec.GetPath());
const int open_flags = GetOpenFlags(options);
const mode_t open_mode =
@@ -466,3 +481,17 @@ ErrorOr<std::string> FileSystem::GetExternalPath(const llvm::Twine &path) {
ErrorOr<std::string> FileSystem::GetExternalPath(const FileSpec &file_spec) {
return GetExternalPath(file_spec.GetPath());
}
+
+void FileSystem::Collect(const FileSpec &file_spec) {
+ Collect(file_spec.GetPath());
+}
+
+void FileSystem::Collect(const llvm::Twine &file) {
+ if (!m_collector)
+ return;
+
+ if (llvm::sys::fs::is_directory(file))
+ m_collector->addDirectory(file);
+ else
+ m_collector->addFile(file);
+}
diff --git a/lldb/source/Host/common/GetOptInc.cpp b/lldb/source/Host/common/GetOptInc.cpp
index 95a68c5d3c76..62ce7428e8cc 100644
--- a/lldb/source/Host/common/GetOptInc.cpp
+++ b/lldb/source/Host/common/GetOptInc.cpp
@@ -1,4 +1,4 @@
-//===-- GetOptInc.cpp -------------------------------------------*- C++ -*-===//
+//===-- GetOptInc.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp
index 5fbb655fc793..4128fa19c142 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -1,4 +1,4 @@
-//===-- Host.cpp ------------------------------------------------*- C++ -*-===//
+//===-- Host.cpp ----------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -28,7 +28,7 @@
#if defined(__linux__) || defined(__FreeBSD__) || \
defined(__FreeBSD_kernel__) || defined(__APPLE__) || \
- defined(__NetBSD__) || defined(__OpenBSD__)
+ defined(__NetBSD__) || defined(__OpenBSD__) || defined(__EMSCRIPTEN__)
#if !defined(__ANDROID__)
#include <spawn.h>
#endif
@@ -501,6 +501,8 @@ Status Host::RunShellCommand(const Args &args, const FileSpec &working_dir,
launch_info.SetArguments(args, first_arg_is_executable);
}
+ launch_info.GetEnvironment() = Host::GetEnvironment();
+
if (working_dir)
launch_info.SetWorkingDirectory(working_dir);
llvm::SmallString<64> output_file_path;
@@ -519,7 +521,7 @@ Status Host::RunShellCommand(const Args &args, const FileSpec &working_dir,
}
}
- FileSpec output_file_spec(output_file_path.c_str());
+ FileSpec output_file_spec(output_file_path.str());
// Set up file descriptors.
launch_info.AppendSuppressFileAction(STDIN_FILENO, true, false);
if (output_file_spec)
@@ -678,3 +680,23 @@ void llvm::format_provider<WaitStatus>::format(const WaitStatus &WS,
}
OS << desc << " " << int(WS.status);
}
+
+uint32_t Host::FindProcesses(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) {
+
+ if (llvm::Optional<ProcessInstanceInfoList> infos =
+ repro::GetReplayProcessInstanceInfoList()) {
+ process_infos = *infos;
+ return process_infos.size();
+ }
+
+ uint32_t result = FindProcessesImpl(match_info, process_infos);
+
+ if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator()) {
+ g->GetOrCreate<repro::ProcessInfoProvider>()
+ .GetNewProcessInfoRecorder()
+ ->Record(process_infos);
+ }
+
+ return result;
+}
diff --git a/lldb/source/Host/common/HostInfoBase.cpp b/lldb/source/Host/common/HostInfoBase.cpp
index 8f263e90d90f..333137a7fd25 100644
--- a/lldb/source/Host/common/HostInfoBase.cpp
+++ b/lldb/source/Host/common/HostInfoBase.cpp
@@ -1,4 +1,4 @@
-//===-- HostInfoBase.cpp ----------------------------------------*- C++ -*-===//
+//===-- HostInfoBase.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/HostNativeThreadBase.cpp b/lldb/source/Host/common/HostNativeThreadBase.cpp
index fe7d85acaf11..a79431f61d88 100644
--- a/lldb/source/Host/common/HostNativeThreadBase.cpp
+++ b/lldb/source/Host/common/HostNativeThreadBase.cpp
@@ -1,4 +1,4 @@
-//===-- HostNativeThreadBase.cpp --------------------------------*- C++ -*-===//
+//===-- HostNativeThreadBase.cpp ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/HostProcess.cpp b/lldb/source/Host/common/HostProcess.cpp
index e180687551f8..256a73bb6716 100644
--- a/lldb/source/Host/common/HostProcess.cpp
+++ b/lldb/source/Host/common/HostProcess.cpp
@@ -1,4 +1,4 @@
-//===-- HostProcess.cpp -----------------------------------------*- C++ -*-===//
+//===-- HostProcess.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/HostThread.cpp b/lldb/source/Host/common/HostThread.cpp
index 89cadce5b206..eec029be1c09 100644
--- a/lldb/source/Host/common/HostThread.cpp
+++ b/lldb/source/Host/common/HostThread.cpp
@@ -1,4 +1,4 @@
-//===-- HostThread.cpp ------------------------------------------*- C++ -*-===//
+//===-- HostThread.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/LZMA.cpp b/lldb/source/Host/common/LZMA.cpp
index 02be8a09df66..5b457f07afca 100644
--- a/lldb/source/Host/common/LZMA.cpp
+++ b/lldb/source/Host/common/LZMA.cpp
@@ -1,4 +1,4 @@
-//===-- LZMA.cpp ------------------------------------------------*- C++ -*-===//
+//===-- LZMA.cpp ----------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/LockFileBase.cpp b/lldb/source/Host/common/LockFileBase.cpp
index 744b1eaabb4e..d4cd8f7ffed1 100644
--- a/lldb/source/Host/common/LockFileBase.cpp
+++ b/lldb/source/Host/common/LockFileBase.cpp
@@ -1,4 +1,4 @@
-//===-- LockFileBase.cpp ----------------------------------------*- C++ -*-===//
+//===-- LockFileBase.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/MainLoop.cpp b/lldb/source/Host/common/MainLoop.cpp
index 240320f83242..02cabbc93550 100644
--- a/lldb/source/Host/common/MainLoop.cpp
+++ b/lldb/source/Host/common/MainLoop.cpp
@@ -1,4 +1,4 @@
-//===-- MainLoop.cpp --------------------------------------------*- C++ -*-===//
+//===-- MainLoop.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/MonitoringProcessLauncher.cpp b/lldb/source/Host/common/MonitoringProcessLauncher.cpp
index 55e9f69a089a..1ef345cd5082 100644
--- a/lldb/source/Host/common/MonitoringProcessLauncher.cpp
+++ b/lldb/source/Host/common/MonitoringProcessLauncher.cpp
@@ -1,4 +1,4 @@
-//===-- MonitoringProcessLauncher.cpp ---------------------------*- C++ -*-===//
+//===-- MonitoringProcessLauncher.cpp -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/NativeProcessProtocol.cpp b/lldb/source/Host/common/NativeProcessProtocol.cpp
index 712c448dc2c1..a4d0b4181d58 100644
--- a/lldb/source/Host/common/NativeProcessProtocol.cpp
+++ b/lldb/source/Host/common/NativeProcessProtocol.cpp
@@ -1,4 +1,4 @@
-//===-- NativeProcessProtocol.cpp -------------------------------*- C++ -*-===//
+//===-- NativeProcessProtocol.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -650,7 +650,7 @@ Status NativeProcessProtocol::ReadMemoryWithoutTrap(lldb::addr_t addr,
auto saved_opcodes = makeArrayRef(pair.second.saved_opcodes);
if (bp_addr + saved_opcodes.size() < addr || addr + bytes_read <= bp_addr)
- continue; // Breapoint not in range, ignore
+ continue; // Breakpoint not in range, ignore
if (bp_addr < addr) {
saved_opcodes = saved_opcodes.drop_front(addr - bp_addr);
diff --git a/lldb/source/Host/common/NativeRegisterContext.cpp b/lldb/source/Host/common/NativeRegisterContext.cpp
index fe40073eb59d..47548f90491d 100644
--- a/lldb/source/Host/common/NativeRegisterContext.cpp
+++ b/lldb/source/Host/common/NativeRegisterContext.cpp
@@ -1,4 +1,4 @@
-//===-- NativeRegisterContext.cpp -------------------------*- C++ -*-===//
+//===-- NativeRegisterContext.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/NativeThreadProtocol.cpp b/lldb/source/Host/common/NativeThreadProtocol.cpp
index e62b1425c891..16901bc9cf7b 100644
--- a/lldb/source/Host/common/NativeThreadProtocol.cpp
+++ b/lldb/source/Host/common/NativeThreadProtocol.cpp
@@ -1,4 +1,4 @@
-//===-- NativeThreadProtocol.cpp --------------------------------*- C++ -*-===//
+//===-- NativeThreadProtocol.cpp ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/NativeWatchpointList.cpp b/lldb/source/Host/common/NativeWatchpointList.cpp
index c3db95fb252e..6d856202d147 100644
--- a/lldb/source/Host/common/NativeWatchpointList.cpp
+++ b/lldb/source/Host/common/NativeWatchpointList.cpp
@@ -1,4 +1,4 @@
-//===-- NativeWatchpointList.cpp --------------------------------*- C++ -*-===//
+//===-- NativeWatchpointList.cpp ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/OptionParser.cpp b/lldb/source/Host/common/OptionParser.cpp
index 1e76f9b8f9f1..b5c7ea66732c 100644
--- a/lldb/source/Host/common/OptionParser.cpp
+++ b/lldb/source/Host/common/OptionParser.cpp
@@ -1,4 +1,4 @@
-//===-- source/Host/common/OptionParser.cpp ---------------------*- C++ -*-===//
+//===-- source/Host/common/OptionParser.cpp -------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -41,7 +41,7 @@ int OptionParser::Parse(llvm::MutableArrayRef<char *> argv,
++longopts;
}
opts.push_back(option());
- std::string opt_cstr = optstring;
+ std::string opt_cstr = std::string(optstring);
return getopt_long_only(argv.size() - 1, argv.data(), opt_cstr.c_str(),
&opts[0], longindex);
}
diff --git a/lldb/source/Host/common/PipeBase.cpp b/lldb/source/Host/common/PipeBase.cpp
index 2cbadf0c85f6..b3e0ab34a58d 100644
--- a/lldb/source/Host/common/PipeBase.cpp
+++ b/lldb/source/Host/common/PipeBase.cpp
@@ -1,4 +1,4 @@
-//===-- source/Host/common/PipeBase.cpp -------------------------*- C++ -*-===//
+//===-- source/Host/common/PipeBase.cpp -----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/ProcessLaunchInfo.cpp b/lldb/source/Host/common/ProcessLaunchInfo.cpp
index 266b46763996..4bc8cda7a006 100644
--- a/lldb/source/Host/common/ProcessLaunchInfo.cpp
+++ b/lldb/source/Host/common/ProcessLaunchInfo.cpp
@@ -1,4 +1,4 @@
-//===-- ProcessLaunchInfo.cpp -----------------------------------*- C++ -*-===//
+//===-- ProcessLaunchInfo.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -133,7 +133,7 @@ const char *ProcessLaunchInfo::GetProcessPluginName() const {
}
void ProcessLaunchInfo::SetProcessPluginName(llvm::StringRef plugin) {
- m_plugin_name = plugin;
+ m_plugin_name = std::string(plugin);
}
const FileSpec &ProcessLaunchInfo::GetShell() const { return m_shell; }
@@ -218,26 +218,26 @@ llvm::Error ProcessLaunchInfo::SetUpPtyRedirection() {
// do for now.
open_flags |= O_CLOEXEC;
#endif
- if (!m_pty->OpenFirstAvailableMaster(open_flags, nullptr, 0)) {
+ if (!m_pty->OpenFirstAvailablePrimary(open_flags, nullptr, 0)) {
return llvm::createStringError(llvm::inconvertibleErrorCode(),
- "PTY::OpenFirstAvailableMaster failed");
+ "PTY::OpenFirstAvailablePrimary failed");
}
- const FileSpec slave_file_spec(m_pty->GetSlaveName(nullptr, 0));
+ const FileSpec secondary_file_spec(m_pty->GetSecondaryName(nullptr, 0));
- // Only use the slave tty if we don't have anything specified for
+ // Only use the secondary tty if we don't have anything specified for
// input and don't have an action for stdin
if (GetFileActionForFD(STDIN_FILENO) == nullptr)
- AppendOpenFileAction(STDIN_FILENO, slave_file_spec, true, false);
+ AppendOpenFileAction(STDIN_FILENO, secondary_file_spec, true, false);
- // Only use the slave tty if we don't have anything specified for
+ // Only use the secondary tty if we don't have anything specified for
// output and don't have an action for stdout
if (GetFileActionForFD(STDOUT_FILENO) == nullptr)
- AppendOpenFileAction(STDOUT_FILENO, slave_file_spec, false, true);
+ AppendOpenFileAction(STDOUT_FILENO, secondary_file_spec, false, true);
- // Only use the slave tty if we don't have anything specified for
+ // Only use the secondary tty if we don't have anything specified for
// error and don't have an action for stderr
if (GetFileActionForFD(STDERR_FILENO) == nullptr)
- AppendOpenFileAction(STDERR_FILENO, slave_file_spec, false, true);
+ AppendOpenFileAction(STDERR_FILENO, secondary_file_spec, false, true);
return llvm::Error::success();
}
diff --git a/lldb/source/Host/common/ProcessRunLock.cpp b/lldb/source/Host/common/ProcessRunLock.cpp
index a931da718766..3b6f033d33ab 100644
--- a/lldb/source/Host/common/ProcessRunLock.cpp
+++ b/lldb/source/Host/common/ProcessRunLock.cpp
@@ -1,4 +1,4 @@
-//===-- ProcessRunLock.cpp --------------------------------------*- C++ -*-===//
+//===-- ProcessRunLock.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/PseudoTerminal.cpp b/lldb/source/Host/common/PseudoTerminal.cpp
index 85828283e210..72549f1c88ab 100644
--- a/lldb/source/Host/common/PseudoTerminal.cpp
+++ b/lldb/source/Host/common/PseudoTerminal.cpp
@@ -1,4 +1,4 @@
-//===-- PseudoTerminal.cpp --------------------------------------*- C++ -*-===//
+//===-- PseudoTerminal.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -34,73 +34,73 @@ static void ErrnoToStr(char *error_str, size_t error_len) {
// PseudoTerminal constructor
PseudoTerminal::PseudoTerminal()
- : m_master_fd(invalid_fd), m_slave_fd(invalid_fd) {}
+ : m_primary_fd(invalid_fd), m_secondary_fd(invalid_fd) {}
// Destructor
//
-// The destructor will close the master and slave file descriptors if they are
-// valid and ownership has not been released using the
-// ReleaseMasterFileDescriptor() or the ReleaseSaveFileDescriptor() member
+// The destructor will close the primary and secondary file descriptors if they
+// are valid and ownership has not been released using the
+// ReleasePrimaryFileDescriptor() or the ReleaseSaveFileDescriptor() member
// functions.
PseudoTerminal::~PseudoTerminal() {
- CloseMasterFileDescriptor();
- CloseSlaveFileDescriptor();
+ ClosePrimaryFileDescriptor();
+ CloseSecondaryFileDescriptor();
}
-// Close the master file descriptor if it is valid.
-void PseudoTerminal::CloseMasterFileDescriptor() {
- if (m_master_fd >= 0) {
- ::close(m_master_fd);
- m_master_fd = invalid_fd;
+// Close the primary file descriptor if it is valid.
+void PseudoTerminal::ClosePrimaryFileDescriptor() {
+ if (m_primary_fd >= 0) {
+ ::close(m_primary_fd);
+ m_primary_fd = invalid_fd;
}
}
-// Close the slave file descriptor if it is valid.
-void PseudoTerminal::CloseSlaveFileDescriptor() {
- if (m_slave_fd >= 0) {
- ::close(m_slave_fd);
- m_slave_fd = invalid_fd;
+// Close the secondary file descriptor if it is valid.
+void PseudoTerminal::CloseSecondaryFileDescriptor() {
+ if (m_secondary_fd >= 0) {
+ ::close(m_secondary_fd);
+ m_secondary_fd = invalid_fd;
}
}
// Open the first available pseudo terminal with OFLAG as the permissions. The
// file descriptor is stored in this object and can be accessed with the
-// MasterFileDescriptor() accessor. The ownership of the master file descriptor
-// can be released using the ReleaseMasterFileDescriptor() accessor. If this
-// object has a valid master files descriptor when its destructor is called, it
-// will close the master file descriptor, therefore clients must call
-// ReleaseMasterFileDescriptor() if they wish to use the master file descriptor
-// after this object is out of scope or destroyed.
+// PrimaryFileDescriptor() accessor. The ownership of the primary file
+// descriptor can be released using the ReleasePrimaryFileDescriptor() accessor.
+// If this object has a valid primary files descriptor when its destructor is
+// called, it will close the primary file descriptor, therefore clients must
+// call ReleasePrimaryFileDescriptor() if they wish to use the primary file
+// descriptor after this object is out of scope or destroyed.
//
// RETURNS:
// True when successful, false indicating an error occurred.
-bool PseudoTerminal::OpenFirstAvailableMaster(int oflag, char *error_str,
- size_t error_len) {
+bool PseudoTerminal::OpenFirstAvailablePrimary(int oflag, char *error_str,
+ size_t error_len) {
if (error_str)
error_str[0] = '\0';
#if LLDB_ENABLE_POSIX
- // Open the master side of a pseudo terminal
- m_master_fd = ::posix_openpt(oflag);
- if (m_master_fd < 0) {
+ // Open the primary side of a pseudo terminal
+ m_primary_fd = ::posix_openpt(oflag);
+ if (m_primary_fd < 0) {
if (error_str)
ErrnoToStr(error_str, error_len);
return false;
}
- // Grant access to the slave pseudo terminal
- if (::grantpt(m_master_fd) < 0) {
+ // Grant access to the secondary pseudo terminal
+ if (::grantpt(m_primary_fd) < 0) {
if (error_str)
ErrnoToStr(error_str, error_len);
- CloseMasterFileDescriptor();
+ ClosePrimaryFileDescriptor();
return false;
}
- // Clear the lock flag on the slave pseudo terminal
- if (::unlockpt(m_master_fd) < 0) {
+ // Clear the lock flag on the secondary pseudo terminal
+ if (::unlockpt(m_primary_fd) < 0) {
if (error_str)
ErrnoToStr(error_str, error_len);
- CloseMasterFileDescriptor();
+ ClosePrimaryFileDescriptor();
return false;
}
@@ -112,30 +112,32 @@ bool PseudoTerminal::OpenFirstAvailableMaster(int oflag, char *error_str,
#endif
}
-// Open the slave pseudo terminal for the current master pseudo terminal. A
-// master pseudo terminal should already be valid prior to calling this
-// function (see OpenFirstAvailableMaster()). The file descriptor is stored
+// Open the secondary pseudo terminal for the current primary pseudo terminal. A
+// primary pseudo terminal should already be valid prior to calling this
+// function (see OpenFirstAvailablePrimary()). The file descriptor is stored
// this object's member variables and can be accessed via the
-// GetSlaveFileDescriptor(), or released using the ReleaseSlaveFileDescriptor()
-// member function.
+// GetSecondaryFileDescriptor(), or released using the
+// ReleaseSecondaryFileDescriptor() member function.
//
// RETURNS:
// True when successful, false indicating an error occurred.
-bool PseudoTerminal::OpenSlave(int oflag, char *error_str, size_t error_len) {
+bool PseudoTerminal::OpenSecondary(int oflag, char *error_str,
+ size_t error_len) {
if (error_str)
error_str[0] = '\0';
- CloseSlaveFileDescriptor();
+ CloseSecondaryFileDescriptor();
- // Open the master side of a pseudo terminal
- const char *slave_name = GetSlaveName(error_str, error_len);
+ // Open the primary side of a pseudo terminal
+ const char *secondary_name = GetSecondaryName(error_str, error_len);
- if (slave_name == nullptr)
+ if (secondary_name == nullptr)
return false;
- m_slave_fd = llvm::sys::RetryAfterSignal(-1, ::open, slave_name, oflag);
+ m_secondary_fd =
+ llvm::sys::RetryAfterSignal(-1, ::open, secondary_name, oflag);
- if (m_slave_fd < 0) {
+ if (m_secondary_fd < 0) {
if (error_str)
ErrnoToStr(error_str, error_len);
return false;
@@ -144,46 +146,46 @@ bool PseudoTerminal::OpenSlave(int oflag, char *error_str, size_t error_len) {
return true;
}
-// Get the name of the slave pseudo terminal. A master pseudo terminal should
-// already be valid prior to calling this function (see
-// OpenFirstAvailableMaster()).
+// Get the name of the secondary pseudo terminal. A primary pseudo terminal
+// should already be valid prior to calling this function (see
+// OpenFirstAvailablePrimary()).
//
// RETURNS:
-// NULL if no valid master pseudo terminal or if ptsname() fails.
-// The name of the slave pseudo terminal as a NULL terminated C string
+// NULL if no valid primary pseudo terminal or if ptsname() fails.
+// The name of the secondary pseudo terminal as a NULL terminated C string
// that comes from static memory, so a copy of the string should be
// made as subsequent calls can change this value.
-const char *PseudoTerminal::GetSlaveName(char *error_str,
- size_t error_len) const {
+const char *PseudoTerminal::GetSecondaryName(char *error_str,
+ size_t error_len) const {
if (error_str)
error_str[0] = '\0';
- if (m_master_fd < 0) {
+ if (m_primary_fd < 0) {
if (error_str)
::snprintf(error_str, error_len, "%s",
- "master file descriptor is invalid");
+ "primary file descriptor is invalid");
return nullptr;
}
- const char *slave_name = ::ptsname(m_master_fd);
+ const char *secondary_name = ::ptsname(m_primary_fd);
- if (error_str && slave_name == nullptr)
+ if (error_str && secondary_name == nullptr)
ErrnoToStr(error_str, error_len);
- return slave_name;
+ return secondary_name;
}
// Fork a child process and have its stdio routed to a pseudo terminal.
//
-// In the parent process when a valid pid is returned, the master file
+// In the parent process when a valid pid is returned, the primary file
// descriptor can be used as a read/write access to stdio of the child process.
//
// In the child process the stdin/stdout/stderr will already be routed to the
-// slave pseudo terminal and the master file descriptor will be closed as it is
-// no longer needed by the child process.
+// secondary pseudo terminal and the primary file descriptor will be closed as
+// it is no longer needed by the child process.
//
-// This class will close the file descriptors for the master/slave when the
-// destructor is called, so be sure to call ReleaseMasterFileDescriptor() or
-// ReleaseSlaveFileDescriptor() if any file descriptors are going to be used
+// This class will close the file descriptors for the primary/secondary when the
+// destructor is called, so be sure to call ReleasePrimaryFileDescriptor() or
+// ReleaseSecondaryFileDescriptor() if any file descriptors are going to be used
// past the lifespan of this object.
//
// RETURNS:
@@ -196,8 +198,8 @@ lldb::pid_t PseudoTerminal::Fork(char *error_str, size_t error_len) {
#if LLDB_ENABLE_POSIX
int flags = O_RDWR;
flags |= O_CLOEXEC;
- if (OpenFirstAvailableMaster(flags, error_str, error_len)) {
- // Successfully opened our master pseudo terminal
+ if (OpenFirstAvailablePrimary(flags, error_str, error_len)) {
+ // Successfully opened our primary pseudo terminal
pid = ::fork();
if (pid < 0) {
@@ -208,32 +210,32 @@ lldb::pid_t PseudoTerminal::Fork(char *error_str, size_t error_len) {
// Child Process
::setsid();
- if (OpenSlave(O_RDWR, error_str, error_len)) {
- // Successfully opened slave
+ if (OpenSecondary(O_RDWR, error_str, error_len)) {
+ // Successfully opened secondary
- // Master FD should have O_CLOEXEC set, but let's close it just in
+ // Primary FD should have O_CLOEXEC set, but let's close it just in
// case...
- CloseMasterFileDescriptor();
+ ClosePrimaryFileDescriptor();
#if defined(TIOCSCTTY)
// Acquire the controlling terminal
- if (::ioctl(m_slave_fd, TIOCSCTTY, (char *)0) < 0) {
+ if (::ioctl(m_secondary_fd, TIOCSCTTY, (char *)0) < 0) {
if (error_str)
ErrnoToStr(error_str, error_len);
}
#endif
- // Duplicate all stdio file descriptors to the slave pseudo terminal
- if (::dup2(m_slave_fd, STDIN_FILENO) != STDIN_FILENO) {
+ // Duplicate all stdio file descriptors to the secondary pseudo terminal
+ if (::dup2(m_secondary_fd, STDIN_FILENO) != STDIN_FILENO) {
if (error_str && !error_str[0])
ErrnoToStr(error_str, error_len);
}
- if (::dup2(m_slave_fd, STDOUT_FILENO) != STDOUT_FILENO) {
+ if (::dup2(m_secondary_fd, STDOUT_FILENO) != STDOUT_FILENO) {
if (error_str && !error_str[0])
ErrnoToStr(error_str, error_len);
}
- if (::dup2(m_slave_fd, STDERR_FILENO) != STDERR_FILENO) {
+ if (::dup2(m_secondary_fd, STDERR_FILENO) != STDERR_FILENO) {
if (error_str && !error_str[0])
ErrnoToStr(error_str, error_len);
}
@@ -247,41 +249,43 @@ lldb::pid_t PseudoTerminal::Fork(char *error_str, size_t error_len) {
return pid;
}
-// The master file descriptor accessor. This object retains ownership of the
-// master file descriptor when this accessor is used. Use
-// ReleaseMasterFileDescriptor() if you wish this object to release ownership
-// of the master file descriptor.
+// The primary file descriptor accessor. This object retains ownership of the
+// primary file descriptor when this accessor is used. Use
+// ReleasePrimaryFileDescriptor() if you wish this object to release ownership
+// of the primary file descriptor.
//
-// Returns the master file descriptor, or -1 if the master file descriptor is
+// Returns the primary file descriptor, or -1 if the primary file descriptor is
// not currently valid.
-int PseudoTerminal::GetMasterFileDescriptor() const { return m_master_fd; }
+int PseudoTerminal::GetPrimaryFileDescriptor() const { return m_primary_fd; }
-// The slave file descriptor accessor.
+// The secondary file descriptor accessor.
//
-// Returns the slave file descriptor, or -1 if the slave file descriptor is not
-// currently valid.
-int PseudoTerminal::GetSlaveFileDescriptor() const { return m_slave_fd; }
+// Returns the secondary file descriptor, or -1 if the secondary file descriptor
+// is not currently valid.
+int PseudoTerminal::GetSecondaryFileDescriptor() const {
+ return m_secondary_fd;
+}
-// Release ownership of the master pseudo terminal file descriptor without
-// closing it. The destructor for this class will close the master file
-// descriptor if the ownership isn't released using this call and the master
+// Release ownership of the primary pseudo terminal file descriptor without
+// closing it. The destructor for this class will close the primary file
+// descriptor if the ownership isn't released using this call and the primary
// file descriptor has been opened.
-int PseudoTerminal::ReleaseMasterFileDescriptor() {
- // Release ownership of the master pseudo terminal file descriptor without
+int PseudoTerminal::ReleasePrimaryFileDescriptor() {
+ // Release ownership of the primary pseudo terminal file descriptor without
// closing it. (the destructor for this class will close it otherwise!)
- int fd = m_master_fd;
- m_master_fd = invalid_fd;
+ int fd = m_primary_fd;
+ m_primary_fd = invalid_fd;
return fd;
}
-// Release ownership of the slave pseudo terminal file descriptor without
-// closing it. The destructor for this class will close the slave file
-// descriptor if the ownership isn't released using this call and the slave
+// Release ownership of the secondary pseudo terminal file descriptor without
+// closing it. The destructor for this class will close the secondary file
+// descriptor if the ownership isn't released using this call and the secondary
// file descriptor has been opened.
-int PseudoTerminal::ReleaseSlaveFileDescriptor() {
- // Release ownership of the slave pseudo terminal file descriptor without
+int PseudoTerminal::ReleaseSecondaryFileDescriptor() {
+ // Release ownership of the secondary pseudo terminal file descriptor without
// closing it (the destructor for this class will close it otherwise!)
- int fd = m_slave_fd;
- m_slave_fd = invalid_fd;
+ int fd = m_secondary_fd;
+ m_secondary_fd = invalid_fd;
return fd;
}
diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp
index 7fba1daff75f..4bcf34a6b456 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -1,4 +1,4 @@
-//===-- Socket.cpp ----------------------------------------------*- C++ -*-===//
+//===-- Socket.cpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -147,71 +147,65 @@ std::unique_ptr<Socket> Socket::Create(const SocketProtocol protocol,
return socket_up;
}
-Status Socket::TcpConnect(llvm::StringRef host_and_port,
- bool child_processes_inherit, Socket *&socket) {
- Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_COMMUNICATION));
- LLDB_LOGF(log, "Socket::%s (host/port = %s)", __FUNCTION__,
- host_and_port.str().c_str());
+llvm::Expected<std::unique_ptr<Socket>>
+Socket::TcpConnect(llvm::StringRef host_and_port,
+ bool child_processes_inherit) {
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
+ LLDB_LOG(log, "host_and_port = {0}", host_and_port);
Status error;
std::unique_ptr<Socket> connect_socket(
Create(ProtocolTcp, child_processes_inherit, error));
if (error.Fail())
- return error;
+ return error.ToError();
error = connect_socket->Connect(host_and_port);
if (error.Success())
- socket = connect_socket.release();
+ return std::move(connect_socket);
- return error;
+ return error.ToError();
}
-Status Socket::TcpListen(llvm::StringRef host_and_port,
- bool child_processes_inherit, Socket *&socket,
- Predicate<uint16_t> *predicate, int backlog) {
+llvm::Expected<std::unique_ptr<TCPSocket>>
+Socket::TcpListen(llvm::StringRef host_and_port, bool child_processes_inherit,
+ Predicate<uint16_t> *predicate, int backlog) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
- LLDB_LOGF(log, "Socket::%s (%s)", __FUNCTION__, host_and_port.str().c_str());
+ LLDB_LOG(log, "host_and_port = {0}", host_and_port);
Status 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;
+ return error.ToError();
std::unique_ptr<TCPSocket> listen_socket(
new TCPSocket(true, child_processes_inherit));
- 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 for me".
- if (port == 0)
- port = listen_socket->GetLocalPortNumber();
-
- // Set the port predicate since when doing a listen://<host>:<port> it
- // often needs to accept the incoming connection which is a blocking system
- // call. Allowing access to the bound port using a predicate allows us to
- // wait for the port predicate to be set to a non-zero value from another
- // thread in an efficient manor.
- if (predicate)
- predicate->SetValue(port, eBroadcastAlways);
- socket = listen_socket.release();
- }
-
- return error;
+ if (error.Fail())
+ return error.ToError();
+
+ // 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 for me".
+ if (port == 0)
+ port = listen_socket->GetLocalPortNumber();
+
+ // Set the port predicate since when doing a listen://<host>:<port> it
+ // often needs to accept the incoming connection which is a blocking system
+ // call. Allowing access to the bound port using a predicate allows us to
+ // wait for the port predicate to be set to a non-zero value from another
+ // thread in an efficient manor.
+ if (predicate)
+ predicate->SetValue(port, eBroadcastAlways);
+ return std::move(listen_socket);
}
-Status Socket::UdpConnect(llvm::StringRef host_and_port,
- bool child_processes_inherit, Socket *&socket) {
- Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
- LLDB_LOGF(log, "Socket::%s (host/port = %s)", __FUNCTION__,
- host_and_port.str().c_str());
-
- return UDPSocket::Connect(host_and_port, child_processes_inherit, socket);
+llvm::Expected<std::unique_ptr<UDPSocket>>
+Socket::UdpConnect(llvm::StringRef host_and_port,
+ bool child_processes_inherit) {
+ return UDPSocket::Connect(host_and_port, child_processes_inherit);
}
Status Socket::UnixDomainConnect(llvm::StringRef name,
@@ -309,7 +303,7 @@ bool Socket::DecodeHostAndPort(llvm::StringRef host_and_port,
host_str.clear();
port_str.clear();
if (to_integer(host_and_port, port, 10) && port < UINT16_MAX) {
- port_str = host_and_port;
+ port_str = std::string(host_and_port);
if (error_ptr)
error_ptr->Clear();
return true;
diff --git a/lldb/source/Host/common/SocketAddress.cpp b/lldb/source/Host/common/SocketAddress.cpp
index 960ed18dc768..e98944d6cdc8 100644
--- a/lldb/source/Host/common/SocketAddress.cpp
+++ b/lldb/source/Host/common/SocketAddress.cpp
@@ -1,4 +1,4 @@
-//===-- SocketAddress.cpp ---------------------------------------*- C++ -*-===//
+//===-- SocketAddress.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/StringConvert.cpp b/lldb/source/Host/common/StringConvert.cpp
index 8bf04f0a9ca3..e5f05e628c7c 100644
--- a/lldb/source/Host/common/StringConvert.cpp
+++ b/lldb/source/Host/common/StringConvert.cpp
@@ -1,4 +1,4 @@
-//===-- StringConvert.cpp ---------------------------------------*- C++ -*-===//
+//===-- StringConvert.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/TCPSocket.cpp b/lldb/source/Host/common/TCPSocket.cpp
index b716935db6e6..047cb0e4c2bf 100644
--- a/lldb/source/Host/common/TCPSocket.cpp
+++ b/lldb/source/Host/common/TCPSocket.cpp
@@ -1,4 +1,4 @@
-//===-- TCPSocket.cpp -------------------------------------------*- C++ -*-===//
+//===-- TCPSocket.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -18,6 +18,7 @@
#include "llvm/Config/llvm-config.h"
#include "llvm/Support/Errno.h"
+#include "llvm/Support/WindowsError.h"
#include "llvm/Support/raw_ostream.h"
#if LLDB_ENABLE_POSIX
@@ -42,6 +43,16 @@ typedef const void *set_socket_option_arg_type;
using namespace lldb;
using namespace lldb_private;
+static Status GetLastSocketError() {
+ std::error_code EC;
+#ifdef _WIN32
+ EC = llvm::mapWindowsError(WSAGetLastError());
+#else
+ EC = std::error_code(errno, std::generic_category());
+#endif
+ return EC;
+}
+
namespace {
const int kType = SOCK_STREAM;
}
@@ -120,8 +131,8 @@ std::string TCPSocket::GetRemoteIPAddress() const {
std::string TCPSocket::GetRemoteConnectionURI() const {
if (m_socket != kInvalidSocketValue) {
- return llvm::formatv("connect://[{0}]:{1}", GetRemoteIPAddress(),
- GetRemotePortNumber());
+ return std::string(llvm::formatv(
+ "connect://[{0}]:{1}", GetRemoteIPAddress(), GetRemotePortNumber()));
}
return "";
}
@@ -192,10 +203,8 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) {
for (SocketAddress &address : addresses) {
int fd = Socket::CreateSocket(address.GetFamily(), kType, IPPROTO_TCP,
m_child_processes_inherit, error);
- if (error.Fail()) {
- error.Clear();
+ if (error.Fail())
continue;
- }
// enable local address reuse
int option_value = 1;
@@ -216,6 +225,7 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) {
err = ::listen(fd, backlog);
if (-1 == err) {
+ error = GetLastSocketError();
CLOSE_SOCKET(fd);
continue;
}
@@ -228,9 +238,11 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) {
m_listen_sockets[fd] = address;
}
- if (m_listen_sockets.size() == 0)
- error.SetErrorString("Failed to connect port");
- return error;
+ if (m_listen_sockets.empty()) {
+ assert(error.Fail());
+ return error;
+ }
+ return Status();
}
void TCPSocket::CloseListenSockets() {
diff --git a/lldb/source/Host/common/TaskPool.cpp b/lldb/source/Host/common/TaskPool.cpp
deleted file mode 100644
index 73f761b5cf63..000000000000
--- a/lldb/source/Host/common/TaskPool.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-//===--------------------- TaskPool.cpp -------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Host/TaskPool.h"
-#include "lldb/Host/ThreadLauncher.h"
-#include "lldb/Utility/Log.h"
-
-#include <cstdint>
-#include <queue>
-#include <thread>
-
-namespace lldb_private {
-
-namespace {
-class TaskPoolImpl {
-public:
- static TaskPoolImpl &GetInstance();
-
- void AddTask(std::function<void()> &&task_fn);
-
-private:
- TaskPoolImpl();
-
- static lldb::thread_result_t WorkerPtr(void *pool);
-
- 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) {}
-
-unsigned GetHardwareConcurrencyHint() {
- // std::thread::hardware_concurrency may return 0 if the value is not well
- // defined or not computable.
- static const unsigned g_hardware_concurrency =
- std::max(1u, std::thread::hardware_concurrency());
- return g_hardware_concurrency;
-}
-
-void TaskPoolImpl::AddTask(std::function<void()> &&task_fn) {
- const size_t min_stack_size = 8 * 1024 * 1024;
-
- std::unique_lock<std::mutex> lock(m_tasks_mutex);
- m_tasks.emplace(std::move(task_fn));
- if (m_thread_count < GetHardwareConcurrencyHint()) {
- m_thread_count++;
- // Note that this detach call needs to happen with the m_tasks_mutex held.
- // This prevents the thread from exiting prematurely and triggering a linux
- // libc bug (https://sourceware.org/bugzilla/show_bug.cgi?id=19951).
- llvm::Expected<HostThread> host_thread =
- lldb_private::ThreadLauncher::LaunchThread(
- "task-pool.worker", WorkerPtr, this, min_stack_size);
- if (host_thread) {
- host_thread->Release();
- } else {
- LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
- "failed to launch host thread: {}",
- llvm::toString(host_thread.takeError()));
- }
- }
-}
-
-lldb::thread_result_t TaskPoolImpl::WorkerPtr(void *pool) {
- Worker((TaskPoolImpl *)pool);
- return {};
-}
-
-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 = std::move(pool->m_tasks.front());
- pool->m_tasks.pop();
- lock.unlock();
-
- f();
- }
-}
-
-void TaskMapOverInt(size_t begin, size_t end,
- const llvm::function_ref<void(size_t)> &func) {
- const size_t num_workers = std::min<size_t>(end, GetHardwareConcurrencyHint());
- std::atomic<size_t> idx{begin};
-
- auto wrapper = [&idx, end, &func]() {
- while (true) {
- size_t i = idx.fetch_add(1);
- if (i >= end)
- break;
- func(i);
- }
- };
-
- std::vector<std::future<void>> futures;
- futures.reserve(num_workers);
- for (size_t i = 0; i < num_workers; i++)
- futures.push_back(TaskPool::AddTask(wrapper));
- for (size_t i = 0; i < num_workers; i++)
- futures[i].wait();
-}
-
-} // namespace lldb_private
-
diff --git a/lldb/source/Host/common/Terminal.cpp b/lldb/source/Host/common/Terminal.cpp
index e1aea26eeb90..9990dbf74356 100644
--- a/lldb/source/Host/common/Terminal.cpp
+++ b/lldb/source/Host/common/Terminal.cpp
@@ -1,4 +1,4 @@
-//===-- Terminal.cpp --------------------------------------------*- C++ -*-===//
+//===-- Terminal.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/ThreadLauncher.cpp b/lldb/source/Host/common/ThreadLauncher.cpp
index 6e3c8b6a13a4..bd104b3e4aed 100644
--- a/lldb/source/Host/common/ThreadLauncher.cpp
+++ b/lldb/source/Host/common/ThreadLauncher.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadLauncher.cpp --------------------------------------*- C++ -*-===//
+//===-- ThreadLauncher.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/common/UDPSocket.cpp b/lldb/source/Host/common/UDPSocket.cpp
index 0a991c33645b..0b537b3a9b13 100644
--- a/lldb/source/Host/common/UDPSocket.cpp
+++ b/lldb/source/Host/common/UDPSocket.cpp
@@ -1,4 +1,4 @@
-//===-- UDPSocket.cpp -------------------------------------------*- C++ -*-===//
+//===-- UDPSocket.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -53,19 +53,19 @@ Status UDPSocket::Accept(Socket *&socket) {
return Status("%s", g_not_supported_error);
}
-Status UDPSocket::Connect(llvm::StringRef name, bool child_processes_inherit,
- Socket *&socket) {
- std::unique_ptr<UDPSocket> final_socket;
+llvm::Expected<std::unique_ptr<UDPSocket>>
+UDPSocket::Connect(llvm::StringRef name, bool child_processes_inherit) {
+ std::unique_ptr<UDPSocket> socket;
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
- LLDB_LOGF(log, "UDPSocket::%s (host/port = %s)", __FUNCTION__, name.data());
+ LLDB_LOG(log, "host/port = {0}", name);
Status 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;
+ return error.ToError();
// At this point we have setup the receive port, now we need to setup the UDP
// send socket
@@ -86,7 +86,7 @@ Status UDPSocket::Connect(llvm::StringRef name, bool child_processes_inherit,
"getaddrinfo(%s, %s, &hints, &info) returned error %i (%s)",
#endif
host_str.c_str(), port_str.c_str(), err, gai_strerror(err));
- return error;
+ return error.ToError();
}
for (struct addrinfo *service_info_ptr = service_info_list;
@@ -96,8 +96,8 @@ Status UDPSocket::Connect(llvm::StringRef name, bool child_processes_inherit,
service_info_ptr->ai_family, service_info_ptr->ai_socktype,
service_info_ptr->ai_protocol, child_processes_inherit, error);
if (error.Success()) {
- final_socket.reset(new UDPSocket(send_fd));
- final_socket->m_sockaddr = service_info_ptr;
+ socket.reset(new UDPSocket(send_fd));
+ socket->m_sockaddr = service_info_ptr;
break;
} else
continue;
@@ -105,8 +105,8 @@ Status UDPSocket::Connect(llvm::StringRef name, bool child_processes_inherit,
::freeaddrinfo(service_info_list);
- if (!final_socket)
- return error;
+ if (!socket)
+ return error.ToError();
SocketAddress bind_addr;
@@ -118,26 +118,25 @@ Status UDPSocket::Connect(llvm::StringRef name, bool child_processes_inherit,
if (!bind_addr_success) {
error.SetErrorString("Failed to get hostspec to bind for");
- return error;
+ return error.ToError();
}
bind_addr.SetPort(0); // Let the source port # be determined dynamically
- err = ::bind(final_socket->GetNativeSocket(), bind_addr, bind_addr.GetLength());
+ err = ::bind(socket->GetNativeSocket(), bind_addr, bind_addr.GetLength());
struct sockaddr_in source_info;
socklen_t address_len = sizeof (struct sockaddr_in);
- err = ::getsockname(final_socket->GetNativeSocket(), (struct sockaddr *) &source_info, &address_len);
+ err = ::getsockname(socket->GetNativeSocket(),
+ (struct sockaddr *)&source_info, &address_len);
- socket = final_socket.release();
- error.Clear();
- return error;
+ return std::move(socket);
}
std::string UDPSocket::GetRemoteConnectionURI() const {
if (m_socket != kInvalidSocketValue) {
- return llvm::formatv("udp://[{0}]:{1}", m_sockaddr.GetIPAddress(),
- m_sockaddr.GetPort());
+ return std::string(llvm::formatv(
+ "udp://[{0}]:{1}", m_sockaddr.GetIPAddress(), m_sockaddr.GetPort()));
}
return "";
}
diff --git a/lldb/source/Host/common/XML.cpp b/lldb/source/Host/common/XML.cpp
index 28d1f5a8eaf4..456c879b0148 100644
--- a/lldb/source/Host/common/XML.cpp
+++ b/lldb/source/Host/common/XML.cpp
@@ -1,4 +1,4 @@
-//===-- XML.cpp -------------------------------------------------*- C++ -*-===//
+//===-- XML.cpp -----------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/freebsd/Host.cpp b/lldb/source/Host/freebsd/Host.cpp
index 99d728d63bc0..09547e48afa9 100644
--- a/lldb/source/Host/freebsd/Host.cpp
+++ b/lldb/source/Host/freebsd/Host.cpp
@@ -1,5 +1,4 @@
-//===-- source/Host/freebsd/Host.cpp ------------------------------*- C++
-//-*-===//
+//===-- source/Host/freebsd/Host.cpp --------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -150,8 +149,8 @@ error:
return false;
}
-uint32_t Host::FindProcesses(const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos) {
+uint32_t Host::FindProcessesImpl(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) {
const ::pid_t our_pid = ::getpid();
const ::uid_t our_uid = ::getuid();
std::vector<struct kinfo_proc> kinfos;
@@ -196,10 +195,10 @@ uint32_t Host::FindProcesses(const ProcessInstanceInfoMatch &match_info,
bool already_registered = false;
for (uint32_t pi = 0;
!already_registered && (const int)kinfo.ki_numthreads > 1 &&
- pi < (const uint32_t)process_infos.GetSize();
+ pi < (const uint32_t)process_infos.size();
pi++)
already_registered =
- (process_infos.GetProcessIDAtIndex(pi) == (uint32_t)kinfo.ki_pid);
+ (process_infos[pi].GetProcessID() == (uint32_t)kinfo.ki_pid);
if (already_registered)
continue;
@@ -217,11 +216,11 @@ uint32_t Host::FindProcesses(const ProcessInstanceInfoMatch &match_info,
GetFreeBSDProcessArgs(&match_info, process_info)) {
GetFreeBSDProcessCPUType(process_info);
if (match_info.Matches(process_info))
- process_infos.Append(process_info);
+ process_infos.push_back(process_info);
}
}
- return process_infos.GetSize();
+ return process_infos.size();
}
bool Host::GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info) {
diff --git a/lldb/source/Host/freebsd/HostInfoFreeBSD.cpp b/lldb/source/Host/freebsd/HostInfoFreeBSD.cpp
index 7fc6f43d4676..2db97dbcd74c 100644
--- a/lldb/source/Host/freebsd/HostInfoFreeBSD.cpp
+++ b/lldb/source/Host/freebsd/HostInfoFreeBSD.cpp
@@ -1,4 +1,4 @@
-//===-- HostInfoFreeBSD.cpp -------------------------------------*- C++ -*-===//
+//===-- HostInfoFreeBSD.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/netbsd/HostInfoNetBSD.cpp b/lldb/source/Host/netbsd/HostInfoNetBSD.cpp
index 99d413922327..cc01ec35a5bc 100644
--- a/lldb/source/Host/netbsd/HostInfoNetBSD.cpp
+++ b/lldb/source/Host/netbsd/HostInfoNetBSD.cpp
@@ -1,4 +1,4 @@
-//===-- HostInfoNetBSD.cpp -------------------------------------*- C++ -*-===//
+//===-- HostInfoNetBSD.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/netbsd/Host.cpp b/lldb/source/Host/netbsd/HostNetBSD.cpp
index 20f3db3c22c1..4708fb45deed 100644
--- a/lldb/source/Host/netbsd/Host.cpp
+++ b/lldb/source/Host/netbsd/HostNetBSD.cpp
@@ -1,4 +1,4 @@
-//===-- source/Host/netbsd/Host.cpp -----------------------------*- C++ -*-===//
+//===-- source/Host/netbsd/HostNetBSD.cpp ---------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -15,11 +15,11 @@
#include <limits.h>
-#include <elf.h>
#include <kvm.h>
#include <sys/exec.h>
#include <sys/ptrace.h>
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Utility/DataBufferHeap.h"
@@ -31,6 +31,7 @@
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StreamString.h"
+#include "llvm/Object/ELF.h"
#include "llvm/Support/Host.h"
extern "C" {
@@ -100,10 +101,31 @@ static bool GetNetBSDProcessArgs(const ProcessInstanceInfoMatch *match_info_ptr,
}
static bool GetNetBSDProcessCPUType(ProcessInstanceInfo &process_info) {
+ Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+
if (process_info.ProcessIDIsValid()) {
- process_info.GetArchitecture() =
- HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
- return true;
+ auto buffer_sp = FileSystem::Instance().CreateDataBuffer(
+ process_info.GetExecutableFile(), 0x20, 0);
+ if (buffer_sp) {
+ uint8_t exe_class =
+ llvm::object::getElfArchType(
+ {buffer_sp->GetChars(), size_t(buffer_sp->GetByteSize())})
+ .first;
+
+ switch (exe_class) {
+ case llvm::ELF::ELFCLASS32:
+ process_info.GetArchitecture() =
+ HostInfo::GetArchitecture(HostInfo::eArchKind32);
+ return true;
+ case llvm::ELF::ELFCLASS64:
+ process_info.GetArchitecture() =
+ HostInfo::GetArchitecture(HostInfo::eArchKind64);
+ return true;
+ default:
+ LLDB_LOG(log, "Unknown elf class ({0}) in file {1}", exe_class,
+ process_info.GetExecutableFile());
+ }
+ }
}
process_info.GetArchitecture().Clear();
return false;
@@ -154,8 +176,8 @@ error:
return false;
}
-uint32_t Host::FindProcesses(const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos) {
+uint32_t Host::FindProcessesImpl(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) {
const ::pid_t our_pid = ::getpid();
const ::uid_t our_uid = ::getuid();
@@ -197,8 +219,8 @@ uint32_t Host::FindProcesses(const ProcessInstanceInfoMatch &match_info,
// 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) {
+ for (size_t pi = 0; pi < process_infos.size(); pi++) {
+ if (process_infos[pi].GetProcessID() == proc_kinfo[i].p_pid) {
already_registered = true;
break;
}
@@ -219,13 +241,13 @@ uint32_t Host::FindProcesses(const ProcessInstanceInfoMatch &match_info,
GetNetBSDProcessArgs(&match_info, process_info)) {
GetNetBSDProcessCPUType(process_info);
if (match_info.Matches(process_info))
- process_infos.Append(process_info);
+ process_infos.push_back(process_info);
}
}
kvm_close(kdp); /* XXX: we don't check for error here */
- return process_infos.GetSize();
+ return process_infos.size();
}
bool Host::GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info) {
diff --git a/lldb/source/Host/openbsd/Host.cpp b/lldb/source/Host/openbsd/Host.cpp
index ba6cf057ca17..4ce549522908 100644
--- a/lldb/source/Host/openbsd/Host.cpp
+++ b/lldb/source/Host/openbsd/Host.cpp
@@ -1,4 +1,4 @@
-//===-- source/Host/openbsd/Host.cpp ----------------------------*- C++ -*-===//
+//===-- source/Host/openbsd/Host.cpp --------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -140,8 +140,8 @@ static bool GetOpenBSDProcessUserAndGroup(ProcessInstanceInfo &process_info) {
return false;
}
-uint32_t Host::FindProcesses(const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos) {
+uint32_t Host::FindProcessesImpl(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) {
std::vector<struct kinfo_proc> kinfos;
int mib[3] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL};
@@ -193,11 +193,11 @@ uint32_t Host::FindProcesses(const ProcessInstanceInfoMatch &match_info,
GetOpenBSDProcessArgs(&match_info, process_info)) {
GetOpenBSDProcessCPUType(process_info);
if (match_info.Matches(process_info))
- process_infos.Append(process_info);
+ process_infos.push_back(process_info);
}
}
- return process_infos.GetSize();
+ return process_infos.size();
}
bool Host::GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &process_info) {
diff --git a/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp b/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
index 950f2ebb86b8..58836333b63c 100644
--- a/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
+++ b/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
@@ -1,4 +1,4 @@
-//===-- HostInfoOpenBSD.cpp -------------------------------------*- C++ -*-===//
+//===-- HostInfoOpenBSD.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index 2223e1625b19..3a547ce128d8 100644
--- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -1,4 +1,4 @@
-//===-- ConnectionFileDescriptorPosix.cpp -----------------------*- C++ -*-===//
+//===-- ConnectionFileDescriptorPosix.cpp ---------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -42,6 +42,7 @@
#include "lldb/Host/Host.h"
#include "lldb/Host/Socket.h"
#include "lldb/Host/common/TCPSocket.h"
+#include "lldb/Host/common/UDPSocket.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/Timer.h"
@@ -208,7 +209,7 @@ ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
// this. For now, we assume we must assume we don't own it.
std::unique_ptr<TCPSocket> tcp_socket;
- tcp_socket.reset(new TCPSocket(fd, false, false));
+ tcp_socket = std::make_unique<TCPSocket>(fd, false, 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;
@@ -223,7 +224,7 @@ ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
m_write_sp =
std::make_shared<NativeFile>(fd, File::eOpenOptionWrite, false);
}
- m_uri = *addr;
+ m_uri = std::string(*addr);
return eConnectionStatusSuccess;
}
}
@@ -652,7 +653,7 @@ ConnectionFileDescriptor::NamedSocketAccept(llvm::StringRef socket_name,
if (error.Fail()) {
return eConnectionStatusError;
}
- m_uri.assign(socket_name);
+ m_uri.assign(std::string(socket_name));
return eConnectionStatusSuccess;
}
@@ -669,7 +670,7 @@ ConnectionFileDescriptor::NamedSocketConnect(llvm::StringRef socket_name,
if (error.Fail()) {
return eConnectionStatusError;
}
- m_uri.assign(socket_name);
+ m_uri.assign(std::string(socket_name));
return eConnectionStatusSuccess;
}
@@ -686,66 +687,79 @@ ConnectionFileDescriptor::UnixAbstractSocketConnect(llvm::StringRef socket_name,
if (error.Fail()) {
return eConnectionStatusError;
}
- m_uri.assign(socket_name);
+ m_uri.assign(std::string(socket_name));
return eConnectionStatusSuccess;
}
ConnectionStatus
ConnectionFileDescriptor::SocketListenAndAccept(llvm::StringRef s,
Status *error_ptr) {
+ if (error_ptr)
+ *error_ptr = Status();
m_port_predicate.SetValue(0, eBroadcastNever);
- Socket *socket = nullptr;
m_waiting_for_accept = true;
- Status error = Socket::TcpListen(s, m_child_processes_inherit, socket,
- &m_port_predicate);
- if (error_ptr)
- *error_ptr = error;
- if (error.Fail())
+ llvm::Expected<std::unique_ptr<TCPSocket>> listening_socket =
+ Socket::TcpListen(s, m_child_processes_inherit, &m_port_predicate);
+ if (!listening_socket) {
+ if (error_ptr)
+ *error_ptr = listening_socket.takeError();
+ else
+ LLDB_LOG_ERROR(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION),
+ listening_socket.takeError(), "tcp listen failed: {0}");
return eConnectionStatusError;
+ }
- std::unique_ptr<Socket> listening_socket_up;
- listening_socket_up.reset(socket);
- socket = nullptr;
- error = listening_socket_up->Accept(socket);
- listening_socket_up.reset();
+ Socket *accepted_socket;
+ Status error = listening_socket.get()->Accept(accepted_socket);
if (error_ptr)
*error_ptr = error;
if (error.Fail())
return eConnectionStatusError;
- InitializeSocket(socket);
+ InitializeSocket(accepted_socket);
return eConnectionStatusSuccess;
}
ConnectionStatus ConnectionFileDescriptor::ConnectTCP(llvm::StringRef s,
Status *error_ptr) {
- Socket *socket = nullptr;
- Status error = Socket::TcpConnect(s, 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()) {
+ *error_ptr = Status();
+
+ llvm::Expected<std::unique_ptr<Socket>> socket =
+ Socket::TcpConnect(s, m_child_processes_inherit);
+ if (!socket) {
+ if (error_ptr)
+ *error_ptr = socket.takeError();
+ else
+ LLDB_LOG_ERROR(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION),
+ socket.takeError(), "tcp connect failed: {0}");
return eConnectionStatusError;
}
- m_uri.assign(s);
+ m_write_sp = std::move(*socket);
+ m_read_sp = m_write_sp;
+ m_uri.assign(std::string(s));
return eConnectionStatusSuccess;
}
ConnectionStatus ConnectionFileDescriptor::ConnectUDP(llvm::StringRef s,
Status *error_ptr) {
- Socket *socket = nullptr;
- Status error = Socket::UdpConnect(s, 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()) {
+ *error_ptr = Status();
+ llvm::Expected<std::unique_ptr<UDPSocket>> socket =
+ Socket::UdpConnect(s, m_child_processes_inherit);
+ if (!socket) {
+ if (error_ptr)
+ *error_ptr = socket.takeError();
+ else
+ LLDB_LOG_ERROR(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION),
+ socket.takeError(), "tcp connect failed: {0}");
return eConnectionStatusError;
}
- m_uri.assign(s);
+ m_write_sp = std::move(*socket);
+ m_read_sp = m_write_sp;
+ m_uri.assign(std::string(s));
return eConnectionStatusSuccess;
}
diff --git a/lldb/source/Host/posix/DomainSocket.cpp b/lldb/source/Host/posix/DomainSocket.cpp
index 27872f48129c..5a396906fdf6 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -1,4 +1,4 @@
-//===-- DomainSocket.cpp ----------------------------------------*- C++ -*-===//
+//===-- DomainSocket.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -146,10 +146,10 @@ std::string DomainSocket::GetSocketName() const {
std::string DomainSocket::GetRemoteConnectionURI() const {
if (m_socket != kInvalidSocketValue) {
- return llvm::formatv("{0}://{1}",
- GetNameOffset() == 0 ? "unix-connect"
- : "unix-abstract-connect",
- GetSocketName());
+ return std::string(llvm::formatv(
+ "{0}://{1}",
+ GetNameOffset() == 0 ? "unix-connect" : "unix-abstract-connect",
+ GetSocketName()));
}
return "";
}
diff --git a/lldb/source/Host/posix/FileSystemPosix.cpp b/lldb/source/Host/posix/FileSystemPosix.cpp
index 32fae68abb4d..0aa34bc59435 100644
--- a/lldb/source/Host/posix/FileSystemPosix.cpp
+++ b/lldb/source/Host/posix/FileSystemPosix.cpp
@@ -1,4 +1,4 @@
-//===-- FileSystem.cpp ------------------------------------------*- C++ -*-===//
+//===-- FileSystemPosix.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -43,7 +43,7 @@ Status FileSystem::Symlink(const FileSpec &src, const FileSpec &dst) {
Status FileSystem::Readlink(const FileSpec &src, FileSpec &dst) {
Status error;
char buf[PATH_MAX];
- ssize_t count = ::readlink(src.GetCString(), buf, sizeof(buf) - 1);
+ ssize_t count = ::readlink(src.GetPath().c_str(), buf, sizeof(buf) - 1);
if (count < 0)
error.SetErrorToErrno();
else {
@@ -72,9 +72,11 @@ Status FileSystem::ResolveSymbolicLink(const FileSpec &src, FileSpec &dst) {
}
FILE *FileSystem::Fopen(const char *path, const char *mode) {
+ Collect(path);
return llvm::sys::RetryAfterSignal(nullptr, ::fopen, path, mode);
}
int FileSystem::Open(const char *path, int flags, int mode) {
+ Collect(path);
return llvm::sys::RetryAfterSignal(-1, ::open, path, flags, mode);
}
diff --git a/lldb/source/Host/posix/HostInfoPosix.cpp b/lldb/source/Host/posix/HostInfoPosix.cpp
index 63cc5dc65e00..7e110f07d7cf 100644
--- a/lldb/source/Host/posix/HostInfoPosix.cpp
+++ b/lldb/source/Host/posix/HostInfoPosix.cpp
@@ -1,4 +1,4 @@
-//===-- HostInfoPosix.cpp ---------------------------------------*- C++ -*-===//
+//===-- HostInfoPosix.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/posix/HostProcessPosix.cpp b/lldb/source/Host/posix/HostProcessPosix.cpp
index cc187d442468..69a049bcf7a2 100644
--- a/lldb/source/Host/posix/HostProcessPosix.cpp
+++ b/lldb/source/Host/posix/HostProcessPosix.cpp
@@ -1,4 +1,4 @@
-//===-- HostProcessPosix.cpp ------------------------------------*- C++ -*-===//
+//===-- HostProcessPosix.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/posix/HostThreadPosix.cpp b/lldb/source/Host/posix/HostThreadPosix.cpp
index d78bba517f69..31c7c7f8e2f3 100644
--- a/lldb/source/Host/posix/HostThreadPosix.cpp
+++ b/lldb/source/Host/posix/HostThreadPosix.cpp
@@ -1,4 +1,4 @@
-//===-- HostThreadPosix.cpp -------------------------------------*- C++ -*-===//
+//===-- HostThreadPosix.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/posix/LockFilePosix.cpp b/lldb/source/Host/posix/LockFilePosix.cpp
index a6eae95c333b..d197974a72a5 100644
--- a/lldb/source/Host/posix/LockFilePosix.cpp
+++ b/lldb/source/Host/posix/LockFilePosix.cpp
@@ -1,4 +1,4 @@
-//===-- LockFilePosix.cpp ---------------------------------------*- C++ -*-===//
+//===-- LockFilePosix.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/posix/PipePosix.cpp b/lldb/source/Host/posix/PipePosix.cpp
index ce1baf3f12a3..780222dffbf8 100644
--- a/lldb/source/Host/posix/PipePosix.cpp
+++ b/lldb/source/Host/posix/PipePosix.cpp
@@ -1,4 +1,4 @@
-//===-- PipePosix.cpp -------------------------------------------*- C++ -*-===//
+//===-- PipePosix.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
index 185c7f0fe248..35482341d3e6 100644
--- a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
+++ b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
@@ -1,4 +1,4 @@
-//===-- ProcessLauncherPosixFork.cpp ----------------------------*- C++ -*-===//
+//===-- ProcessLauncherPosixFork.cpp --------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Initialization/SystemInitializer.cpp b/lldb/source/Initialization/SystemInitializer.cpp
index 1e40c2694464..fc460c32650d 100644
--- a/lldb/source/Initialization/SystemInitializer.cpp
+++ b/lldb/source/Initialization/SystemInitializer.cpp
@@ -1,4 +1,4 @@
-//===-- SystemInitializer.cpp -----------------------------------*- C++ -*-===//
+//===-- SystemInitializer.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Initialization/SystemInitializerCommon.cpp b/lldb/source/Initialization/SystemInitializerCommon.cpp
index 7ae8ef5d4d66..0cef2a48dcb4 100644
--- a/lldb/source/Initialization/SystemInitializerCommon.cpp
+++ b/lldb/source/Initialization/SystemInitializerCommon.cpp
@@ -1,4 +1,4 @@
-//===-- SystemInitializerCommon.cpp -----------------------------*- C++ -*-===//
+//===-- SystemInitializerCommon.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Initialization/SystemLifetimeManager.cpp b/lldb/source/Initialization/SystemLifetimeManager.cpp
index 97f60489f04b..00ab3198c363 100644
--- a/lldb/source/Initialization/SystemLifetimeManager.cpp
+++ b/lldb/source/Initialization/SystemLifetimeManager.cpp
@@ -1,4 +1,4 @@
-//===-- SystemLifetimeManager.cpp ------------------------------*- C++ -*-===//
+//===-- SystemLifetimeManager.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/CommandAlias.cpp b/lldb/source/Interpreter/CommandAlias.cpp
index 5139c53a47b3..a5e033937210 100644
--- a/lldb/source/Interpreter/CommandAlias.cpp
+++ b/lldb/source/Interpreter/CommandAlias.cpp
@@ -1,4 +1,4 @@
-//===-- CommandAlias.cpp -----------------------------------------*- C++-*-===//
+//===-- CommandAlias.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -32,7 +32,7 @@ static bool ProcessAliasOptionsArgs(lldb::CommandObjectSP &cmd_obj_sp,
std::string options_string(options_args);
// TODO: Find a way to propagate errors in this CommandReturnObject up the
// stack.
- CommandReturnObject result;
+ CommandReturnObject result(false);
// Check to see if the command being aliased can take any command options.
Options *options = cmd_obj_sp->GetOptions();
if (options) {
@@ -65,7 +65,8 @@ static bool ProcessAliasOptionsArgs(lldb::CommandObjectSP &cmd_obj_sp,
else {
for (auto &entry : args.entries()) {
if (!entry.ref().empty())
- option_arg_vector->emplace_back("<argument>", -1, entry.ref());
+ option_arg_vector->emplace_back(std::string("<argument>"), -1,
+ std::string(entry.ref()));
}
}
}
@@ -79,7 +80,7 @@ CommandAlias::CommandAlias(CommandInterpreter &interpreter,
llvm::StringRef help, llvm::StringRef syntax,
uint32_t flags)
: CommandObject(interpreter, name, help, syntax, flags),
- m_underlying_command_sp(), m_option_string(options_args),
+ m_underlying_command_sp(), m_option_string(std::string(options_args)),
m_option_args_sp(new OptionArgVector),
m_is_dashdash_alias(eLazyBoolCalculate), m_did_set_help(false),
m_did_set_help_long(false) {
diff --git a/lldb/source/Interpreter/CommandHistory.cpp b/lldb/source/Interpreter/CommandHistory.cpp
index 0be61f836e00..9c7919ecc41f 100644
--- a/lldb/source/Interpreter/CommandHistory.cpp
+++ b/lldb/source/Interpreter/CommandHistory.cpp
@@ -1,4 +1,4 @@
-//===-- CommandHistory.cpp --------------------------------------*- C++ -*-===//
+//===-- CommandHistory.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -87,7 +87,7 @@ void CommandHistory::AppendString(llvm::StringRef str, bool reject_if_dupe) {
return;
}
}
- m_history.push_back(str);
+ m_history.push_back(std::string(str));
}
void CommandHistory::Clear() {
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index 1ee80503f569..e55b25500179 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -1,4 +1,4 @@
-//===-- CommandInterpreter.cpp ----------------------------------*- C++ -*-===//
+//===-- CommandInterpreter.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -116,8 +116,7 @@ CommandInterpreter::CommandInterpreter(Debugger &debugger,
m_skip_lldbinit_files(false), m_skip_app_init_files(false),
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) {
+ m_command_source_depth(0), m_result() {
SetEventName(eBroadcastBitThreadShouldExit, "thread-should-exit");
SetEventName(eBroadcastBitResetPrompt, "reset-prompt");
SetEventName(eBroadcastBitQuitCommandReceived, "quit");
@@ -210,7 +209,7 @@ void CommandInterpreter::Initialize() {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
- CommandReturnObject result;
+ CommandReturnObject result(m_debugger.GetUseColor());
LoadCommandDictionary();
@@ -357,7 +356,7 @@ void CommandInterpreter::Initialize() {
AddAlias("p", cmd_obj_sp, "--")->SetHelpLong("");
AddAlias("print", cmd_obj_sp, "--")->SetHelpLong("");
AddAlias("call", cmd_obj_sp, "--")->SetHelpLong("");
- if (auto po = AddAlias("po", cmd_obj_sp, "-O --")) {
+ if (auto *po = AddAlias("po", cmd_obj_sp, "-O --")) {
po->SetHelp("Evaluate an expression on the current thread. Displays any "
"returned value with formatting "
"controlled by the type's author.");
@@ -382,6 +381,16 @@ void CommandInterpreter::Initialize() {
}
}
+ cmd_obj_sp = GetCommandSPExact("platform shell", false);
+ if (cmd_obj_sp) {
+ CommandAlias *shell_alias = AddAlias("shell", cmd_obj_sp, " --host --");
+ if (shell_alias) {
+ shell_alias->SetHelp("Run a shell command on the host.");
+ shell_alias->SetHelpLong("");
+ shell_alias->SetSyntax("shell <shell-command>");
+ }
+ }
+
cmd_obj_sp = GetCommandSPExact("process kill", false);
if (cmd_obj_sp) {
AddAlias("kill", cmd_obj_sp);
@@ -500,7 +509,10 @@ void CommandInterpreter::LoadCommandDictionary() {
m_command_dict["language"] =
CommandObjectSP(new CommandObjectLanguage(*this));
+ // clang-format off
const char *break_regexes[][2] = {
+ {"^(.*[^[:space:]])[[:space:]]*:[[:space:]]*([[:digit:]]+)[[:space:]]*:[[:space:]]*([[:digit:]]+)[[:space:]]*$",
+ "breakpoint set --file '%1' --line %2 --column %3"},
{"^(.*[^[:space:]])[[:space:]]*:[[:space:]]*([[:digit:]]+)[[:space:]]*$",
"breakpoint set --file '%1' --line %2"},
{"^/([^/]+)/$", "breakpoint set --source-pattern-regexp '%1'"},
@@ -515,6 +527,7 @@ void CommandInterpreter::LoadCommandDictionary() {
"breakpoint set --name '%1' --skip-prologue=0"},
{"^[\"']?(.*[^[:space:]\"'])[\"']?[[:space:]]*$",
"breakpoint set --name '%1'"}};
+ // clang-format on
size_t num_regexes = llvm::array_lengthof(break_regexes);
@@ -523,6 +536,9 @@ void CommandInterpreter::LoadCommandDictionary() {
*this, "_regexp-break",
"Set a breakpoint using one of several shorthand formats.",
"\n"
+ "_regexp-break <filename>:<linenum>:<colnum>\n"
+ " main.c:12:21 // Break at line 12 and column "
+ "21 of main.c\n\n"
"_regexp-break <filename>:<linenum>\n"
" main.c:12 // Break at line 12 of "
"main.c\n\n"
@@ -546,7 +562,7 @@ void CommandInterpreter::LoadCommandDictionary() {
"current file\n"
" // containing text 'break "
"here'.\n",
- 2,
+ 3,
CommandCompletions::eSymbolCompletion |
CommandCompletions::eSourceFileCompletion,
false));
@@ -564,7 +580,8 @@ void CommandInterpreter::LoadCommandDictionary() {
if (success) {
CommandObjectSP break_regex_cmd_sp(break_regex_cmd_up.release());
- m_command_dict[break_regex_cmd_sp->GetCommandName()] = break_regex_cmd_sp;
+ m_command_dict[std::string(break_regex_cmd_sp->GetCommandName())] =
+ break_regex_cmd_sp;
}
}
@@ -573,6 +590,9 @@ void CommandInterpreter::LoadCommandDictionary() {
*this, "_regexp-tbreak",
"Set a one-shot breakpoint using one of several shorthand formats.",
"\n"
+ "_regexp-break <filename>:<linenum>:<colnum>\n"
+ " main.c:12:21 // Break at line 12 and column "
+ "21 of main.c\n\n"
"_regexp-break <filename>:<linenum>\n"
" main.c:12 // Break at line 12 of "
"main.c\n\n"
@@ -621,7 +641,7 @@ void CommandInterpreter::LoadCommandDictionary() {
if (success) {
CommandObjectSP tbreak_regex_cmd_sp(tbreak_regex_cmd_up.release());
- m_command_dict[tbreak_regex_cmd_sp->GetCommandName()] =
+ m_command_dict[std::string(tbreak_regex_cmd_sp->GetCommandName())] =
tbreak_regex_cmd_sp;
}
}
@@ -641,7 +661,7 @@ void CommandInterpreter::LoadCommandDictionary() {
"process attach --name '%1'") &&
attach_regex_cmd_up->AddRegexCommand("^$", "process attach")) {
CommandObjectSP attach_regex_cmd_sp(attach_regex_cmd_up.release());
- m_command_dict[attach_regex_cmd_sp->GetCommandName()] =
+ m_command_dict[std::string(attach_regex_cmd_sp->GetCommandName())] =
attach_regex_cmd_sp;
}
}
@@ -657,7 +677,8 @@ void CommandInterpreter::LoadCommandDictionary() {
down_regex_cmd_up->AddRegexCommand("^([0-9]+)$",
"frame select -r -%1")) {
CommandObjectSP down_regex_cmd_sp(down_regex_cmd_up.release());
- m_command_dict[down_regex_cmd_sp->GetCommandName()] = down_regex_cmd_sp;
+ m_command_dict[std::string(down_regex_cmd_sp->GetCommandName())] =
+ down_regex_cmd_sp;
}
}
@@ -671,7 +692,8 @@ void CommandInterpreter::LoadCommandDictionary() {
if (up_regex_cmd_up->AddRegexCommand("^$", "frame select -r 1") &&
up_regex_cmd_up->AddRegexCommand("^([0-9]+)$", "frame select -r %1")) {
CommandObjectSP up_regex_cmd_sp(up_regex_cmd_up.release());
- m_command_dict[up_regex_cmd_sp->GetCommandName()] = up_regex_cmd_sp;
+ m_command_dict[std::string(up_regex_cmd_sp->GetCommandName())] =
+ up_regex_cmd_sp;
}
}
@@ -684,7 +706,7 @@ void CommandInterpreter::LoadCommandDictionary() {
if (display_regex_cmd_up->AddRegexCommand(
"^(.+)$", "target stop-hook add -o \"expr -- %1\"")) {
CommandObjectSP display_regex_cmd_sp(display_regex_cmd_up.release());
- m_command_dict[display_regex_cmd_sp->GetCommandName()] =
+ m_command_dict[std::string(display_regex_cmd_sp->GetCommandName())] =
display_regex_cmd_sp;
}
}
@@ -699,7 +721,7 @@ void CommandInterpreter::LoadCommandDictionary() {
if (undisplay_regex_cmd_up->AddRegexCommand("^([0-9]+)$",
"target stop-hook delete %1")) {
CommandObjectSP undisplay_regex_cmd_sp(undisplay_regex_cmd_up.release());
- m_command_dict[undisplay_regex_cmd_sp->GetCommandName()] =
+ m_command_dict[std::string(undisplay_regex_cmd_sp->GetCommandName())] =
undisplay_regex_cmd_sp;
}
}
@@ -718,7 +740,7 @@ void CommandInterpreter::LoadCommandDictionary() {
"^([[:digit:]]+)$",
"process connect --plugin gdb-remote connect://localhost:%1")) {
CommandObjectSP command_sp(connect_gdb_remote_cmd_up.release());
- m_command_dict[command_sp->GetCommandName()] = command_sp;
+ m_command_dict[std::string(command_sp->GetCommandName())] = command_sp;
}
}
@@ -736,7 +758,7 @@ void CommandInterpreter::LoadCommandDictionary() {
connect_kdp_remote_cmd_up->AddRegexCommand(
"^(.+)$", "process connect --plugin kdp-remote udp://%1:41139")) {
CommandObjectSP command_sp(connect_kdp_remote_cmd_up.release());
- m_command_dict[command_sp->GetCommandName()] = command_sp;
+ m_command_dict[std::string(command_sp->GetCommandName())] = command_sp;
}
}
@@ -761,7 +783,7 @@ void CommandInterpreter::LoadCommandDictionary() {
bt_regex_cmd_up->AddRegexCommand("^all[[:space:]]*$", "thread backtrace all") &&
bt_regex_cmd_up->AddRegexCommand("^[[:space:]]*$", "thread backtrace")) {
CommandObjectSP command_sp(bt_regex_cmd_up.release());
- m_command_dict[command_sp->GetCommandName()] = command_sp;
+ m_command_dict[std::string(command_sp->GetCommandName())] = command_sp;
}
}
@@ -797,7 +819,8 @@ void CommandInterpreter::LoadCommandDictionary() {
"source list --name \"%1\"") &&
list_regex_cmd_up->AddRegexCommand("^$", "source list")) {
CommandObjectSP list_regex_cmd_sp(list_regex_cmd_up.release());
- m_command_dict[list_regex_cmd_sp->GetCommandName()] = list_regex_cmd_sp;
+ m_command_dict[std::string(list_regex_cmd_sp->GetCommandName())] =
+ list_regex_cmd_sp;
}
}
@@ -815,7 +838,8 @@ void CommandInterpreter::LoadCommandDictionary() {
env_regex_cmd_up->AddRegexCommand("^([A-Za-z_][A-Za-z_0-9]*=.*)$",
"settings set target.env-vars %1")) {
CommandObjectSP env_regex_cmd_sp(env_regex_cmd_up.release());
- m_command_dict[env_regex_cmd_sp->GetCommandName()] = env_regex_cmd_sp;
+ m_command_dict[std::string(env_regex_cmd_sp->GetCommandName())] =
+ env_regex_cmd_sp;
}
}
@@ -838,7 +862,8 @@ void CommandInterpreter::LoadCommandDictionary() {
jump_regex_cmd_up->AddRegexCommand("^([+\\-][0-9]+)$",
"thread jump --by %1")) {
CommandObjectSP jump_regex_cmd_sp(jump_regex_cmd_up.release());
- m_command_dict[jump_regex_cmd_sp->GetCommandName()] = jump_regex_cmd_sp;
+ m_command_dict[std::string(jump_regex_cmd_sp->GetCommandName())] =
+ jump_regex_cmd_sp;
}
}
}
@@ -863,7 +888,7 @@ CommandInterpreter::GetCommandSP(llvm::StringRef cmd_str, bool include_aliases,
StringList *descriptions) const {
CommandObjectSP command_sp;
- std::string cmd = cmd_str;
+ std::string cmd = std::string(cmd_str);
if (HasCommands()) {
auto pos = m_command_dict.find(cmd);
@@ -992,18 +1017,18 @@ bool CommandInterpreter::AddUserCommand(llvm::StringRef name,
if (CommandExists(name)) {
if (!can_replace)
return false;
- if (!m_command_dict[name]->IsRemovable())
+ if (!m_command_dict[std::string(name)]->IsRemovable())
return false;
}
if (UserCommandExists(name)) {
if (!can_replace)
return false;
- if (!m_user_dict[name]->IsRemovable())
+ if (!m_user_dict[std::string(name)]->IsRemovable())
return false;
}
- m_user_dict[name] = cmd_sp;
+ m_user_dict[std::string(name)] = cmd_sp;
return true;
}
return false;
@@ -1089,14 +1114,15 @@ CommandInterpreter::GetCommandObject(llvm::StringRef cmd_str,
}
bool CommandInterpreter::CommandExists(llvm::StringRef cmd) const {
- return m_command_dict.find(cmd) != m_command_dict.end();
+ return m_command_dict.find(std::string(cmd)) != m_command_dict.end();
}
bool CommandInterpreter::GetAliasFullName(llvm::StringRef cmd,
std::string &full_name) const {
- bool exact_match = (m_alias_dict.find(cmd) != m_alias_dict.end());
+ bool exact_match =
+ (m_alias_dict.find(std::string(cmd)) != m_alias_dict.end());
if (exact_match) {
- full_name.assign(cmd);
+ full_name.assign(std::string(cmd));
return exact_match;
} else {
StringList matches;
@@ -1122,11 +1148,11 @@ bool CommandInterpreter::GetAliasFullName(llvm::StringRef cmd,
}
bool CommandInterpreter::AliasExists(llvm::StringRef cmd) const {
- return m_alias_dict.find(cmd) != m_alias_dict.end();
+ return m_alias_dict.find(std::string(cmd)) != m_alias_dict.end();
}
bool CommandInterpreter::UserCommandExists(llvm::StringRef cmd) const {
- return m_user_dict.find(cmd) != m_user_dict.end();
+ return m_user_dict.find(std::string(cmd)) != m_user_dict.end();
}
CommandAlias *
@@ -1141,7 +1167,8 @@ CommandInterpreter::AddAlias(llvm::StringRef alias_name,
new CommandAlias(*this, command_obj_sp, args_string, alias_name));
if (command_alias_up && command_alias_up->IsValid()) {
- m_alias_dict[alias_name] = CommandObjectSP(command_alias_up.get());
+ m_alias_dict[std::string(alias_name)] =
+ CommandObjectSP(command_alias_up.get());
return command_alias_up.release();
}
@@ -1149,7 +1176,7 @@ CommandInterpreter::AddAlias(llvm::StringRef alias_name,
}
bool CommandInterpreter::RemoveAlias(llvm::StringRef alias_name) {
- auto pos = m_alias_dict.find(alias_name);
+ auto pos = m_alias_dict.find(std::string(alias_name));
if (pos != m_alias_dict.end()) {
m_alias_dict.erase(pos);
return true;
@@ -1158,7 +1185,7 @@ bool CommandInterpreter::RemoveAlias(llvm::StringRef alias_name) {
}
bool CommandInterpreter::RemoveCommand(llvm::StringRef cmd) {
- auto pos = m_command_dict.find(cmd);
+ auto pos = m_command_dict.find(std::string(cmd));
if (pos != m_command_dict.end()) {
if (pos->second->IsRemovable()) {
// Only regular expression objects or python commands are removable
@@ -1169,7 +1196,8 @@ bool CommandInterpreter::RemoveCommand(llvm::StringRef cmd) {
return false;
}
bool CommandInterpreter::RemoveUser(llvm::StringRef alias_name) {
- CommandObject::CommandMap::iterator pos = m_user_dict.find(alias_name);
+ CommandObject::CommandMap::iterator pos =
+ m_user_dict.find(std::string(alias_name));
if (pos != m_user_dict.end()) {
m_user_dict.erase(pos);
return true;
@@ -1253,7 +1281,8 @@ CommandObject *CommandInterpreter::GetCommandObjectForCommand(
end = command_string.find_first_of(k_white_space, start);
if (end == std::string::npos)
end = command_string.size();
- std::string cmd_word = command_string.substr(start, end - start);
+ std::string cmd_word =
+ std::string(command_string.substr(start, end - start));
if (cmd_obj == nullptr)
// Since cmd_obj is NULL we are on our first time through this loop.
@@ -1311,10 +1340,10 @@ static size_t FindArgumentTerminator(const std::string &s) {
if (pos == std::string::npos)
break;
if (pos > 0) {
- if (isspace(s[pos - 1])) {
+ if (llvm::isSpace(s[pos - 1])) {
// Check if the string ends "\s--" (where \s is a space character) or
// if we have "\s--\s".
- if ((pos + 2 >= s_len) || isspace(s[pos + 2])) {
+ if ((pos + 2 >= s_len) || llvm::isSpace(s[pos + 2])) {
return pos;
}
}
@@ -1394,7 +1423,7 @@ CommandObject *CommandInterpreter::BuildAliasResult(
((CommandAlias *)alias_cmd_obj)->Desugar();
OptionArgVectorSP option_arg_vector_sp = desugared.second;
alias_cmd_obj = desugared.first.get();
- std::string alias_name_str = alias_name;
+ std::string alias_name_str = std::string(alias_name);
if ((cmd_args.GetArgumentCount() == 0) ||
(alias_name_str != cmd_args.GetArgumentAtIndex(0)))
cmd_args.Unshift(alias_name_str);
@@ -1402,7 +1431,7 @@ CommandObject *CommandInterpreter::BuildAliasResult(
result_str.Printf("%s", alias_cmd_obj->GetCommandName().str().c_str());
if (!option_arg_vector_sp.get()) {
- alias_result = result_str.GetString();
+ alias_result = std::string(result_str.GetString());
return alias_cmd_obj;
}
OptionArgVector *option_arg_vector = option_arg_vector_sp.get();
@@ -1443,7 +1472,7 @@ CommandObject *CommandInterpreter::BuildAliasResult(
}
}
- alias_result = result_str.GetString();
+ alias_result = std::string(result_str.GetString());
return alias_cmd_obj;
}
@@ -1527,7 +1556,7 @@ Status CommandInterpreter::PreprocessCommand(std::string &command) {
scalar.GetValue(&value_strm, show_type);
size_t value_string_size = value_strm.GetSize();
if (value_string_size) {
- command.insert(start_backtick, value_strm.GetString());
+ command.insert(start_backtick, std::string(value_strm.GetString()));
pos = start_backtick + value_string_size;
continue;
} else {
@@ -1591,6 +1620,11 @@ Status CommandInterpreter::PreprocessCommand(std::string &command) {
"expression '%s'",
expr_str.c_str());
break;
+ case eExpressionThreadVanished:
+ error.SetErrorStringWithFormat(
+ "expression thread vanished for the expression '%s'",
+ expr_str.c_str());
+ break;
}
}
}
@@ -1652,8 +1686,8 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
search_str = search_str.drop_front(non_space);
if (auto hist_str = m_command_history.FindString(search_str)) {
add_to_history = false;
- command_string = *hist_str;
- original_command_string = *hist_str;
+ command_string = std::string(*hist_str);
+ original_command_string = std::string(*hist_str);
} else {
result.AppendErrorWithFormat("Could not find entry: %s in history",
command_string.c_str());
@@ -1817,6 +1851,8 @@ void CommandInterpreter::HandleCompletionMatches(CompletionRequest &request) {
void CommandInterpreter::HandleCompletion(CompletionRequest &request) {
+ UpdateExecutionContext(nullptr);
+
// Don't complete comments, and if the line we are completing is just the
// history repeat character, substitute the appropriate history line.
llvm::StringRef first_arg = request.GetParsedLine().GetArgumentAtIndex(0);
@@ -1854,7 +1890,7 @@ bool CommandInterpreter::Confirm(llvm::StringRef message, bool default_answer) {
IOHandlerConfirm *confirm =
new IOHandlerConfirm(m_debugger, message, default_answer);
IOHandlerSP io_handler_sp(confirm);
- m_debugger.RunIOHandler(io_handler_sp);
+ m_debugger.RunIOHandlerSync(io_handler_sp);
return confirm->GetResponse();
}
@@ -1862,7 +1898,7 @@ const CommandAlias *
CommandInterpreter::GetAlias(llvm::StringRef alias_name) const {
OptionArgVectorSP ret_val;
- auto pos = m_alias_dict.find(alias_name);
+ auto pos = m_alias_dict.find(std::string(alias_name));
if (pos != m_alias_dict.end())
return (CommandAlias *)pos->second.get();
@@ -2228,7 +2264,7 @@ void CommandInterpreter::HandleCommands(const StringList &commands,
m_debugger.GetPrompt().str().c_str(), cmd);
}
- CommandReturnObject tmp_result;
+ CommandReturnObject tmp_result(m_debugger.GetUseColor());
// If override_context is not NULL, pass no_context_switching = true for
// HandleCommand() since we updated our context already.
@@ -2477,7 +2513,7 @@ void CommandInterpreter::HandleCommandsFromFile(
m_command_source_depth++;
- debugger.RunIOHandler(io_handler_sp);
+ debugger.RunIOHandlerSync(io_handler_sp);
if (!m_command_source_flags.empty())
m_command_source_flags.pop_back();
m_command_source_depth--;
@@ -2756,7 +2792,7 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
StartHandlingCommand();
- lldb_private::CommandReturnObject result;
+ lldb_private::CommandReturnObject result(m_debugger.GetUseColor());
HandleCommand(line.c_str(), eLazyBoolCalculate, result);
// Now emit the command output text from the command we just executed
@@ -2794,23 +2830,26 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
break;
case eReturnStatusFailed:
- m_num_errors++;
- if (io_handler.GetFlags().Test(eHandleCommandFlagStopOnError))
+ m_result.IncrementNumberOfErrors();
+ if (io_handler.GetFlags().Test(eHandleCommandFlagStopOnError)) {
+ m_result.SetResult(lldb::eCommandInterpreterResultCommandError);
io_handler.SetIsDone(true);
+ }
break;
case eReturnStatusQuit:
- m_quit_requested = true;
+ m_result.SetResult(lldb::eCommandInterpreterResultQuitRequested);
io_handler.SetIsDone(true);
break;
}
// Finally, if we're going to stop on crash, check that here:
- if (!m_quit_requested && result.GetDidChangeProcessState() &&
+ if (m_result.IsResult(lldb::eCommandInterpreterResultSuccess) &&
+ result.GetDidChangeProcessState() &&
io_handler.GetFlags().Test(eHandleCommandFlagStopOnCrash) &&
DidProcessStopAbnormally()) {
io_handler.SetIsDone(true);
- m_stopped_for_crash = true;
+ m_result.SetResult(lldb::eCommandInterpreterResultInferiorCrash);
}
}
@@ -2854,7 +2893,7 @@ void CommandInterpreter::GetLLDBCommandsFromIOHandler(
if (io_handler_sp) {
io_handler_sp->SetUserData(baton);
- debugger.PushIOHandler(io_handler_sp);
+ debugger.RunIOHandlerAsync(io_handler_sp);
}
}
@@ -2874,7 +2913,7 @@ void CommandInterpreter::GetPythonCommandsFromIOHandler(
if (io_handler_sp) {
io_handler_sp->SetUserData(baton);
- debugger.PushIOHandler(io_handler_sp);
+ debugger.RunIOHandlerAsync(io_handler_sp);
}
}
@@ -2928,26 +2967,27 @@ CommandInterpreter::GetIOHandler(bool force_create,
return m_command_io_handler_sp;
}
-void CommandInterpreter::RunCommandInterpreter(
- bool auto_handle_events, bool spawn_thread,
+CommandInterpreterRunResult CommandInterpreter::RunCommandInterpreter(
CommandInterpreterRunOptions &options) {
// Always re-create the command interpreter when we run it in case any file
// handles have changed.
bool force_create = true;
- m_debugger.PushIOHandler(GetIOHandler(force_create, &options));
- m_stopped_for_crash = false;
+ m_debugger.RunIOHandlerAsync(GetIOHandler(force_create, &options));
+ m_result = CommandInterpreterRunResult();
- if (auto_handle_events)
+ if (options.GetAutoHandleEvents())
m_debugger.StartEventHandlerThread();
- if (spawn_thread) {
+ if (options.GetSpawnThread()) {
m_debugger.StartIOHandlerThread();
} else {
- m_debugger.ExecuteIOHandlers();
+ m_debugger.RunIOHandlers();
- if (auto_handle_events)
+ if (options.GetAutoHandleEvents())
m_debugger.StopEventHandlerThread();
}
+
+ return m_result;
}
CommandObject *
@@ -3073,7 +3113,7 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line,
std::string gdb_format_option("--gdb-format=");
gdb_format_option += (suffix.c_str() + 1);
- std::string cmd = revised_command_line.GetString();
+ std::string cmd = std::string(revised_command_line.GetString());
size_t arg_terminator_idx = FindArgumentTerminator(cmd);
if (arg_terminator_idx != std::string::npos) {
// Insert the gdb format option before the "--" that terminates
@@ -3114,7 +3154,7 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line,
revised_command_line.Printf(" %s", scratch_command.c_str());
if (cmd_obj != nullptr)
- command_line = revised_command_line.GetString();
+ command_line = std::string(revised_command_line.GetString());
return cmd_obj;
}
diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp
index d666852ee68c..538f7a1ba693 100644
--- a/lldb/source/Interpreter/CommandObject.cpp
+++ b/lldb/source/Interpreter/CommandObject.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObject.cpp ---------------------------------------*- C++ -*-===//
+//===-- CommandObject.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -18,6 +18,7 @@
#include "lldb/Core/Address.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Utility/ArchSpec.h"
+#include "llvm/ADT/ScopeExit.h"
// These are for the Sourcename completers.
// FIXME: Make a separate file for the completers.
@@ -37,14 +38,15 @@ using namespace lldb_private;
// CommandObject
-CommandObject::CommandObject(CommandInterpreter &interpreter, llvm::StringRef name,
- llvm::StringRef help, llvm::StringRef syntax, uint32_t flags)
- : m_interpreter(interpreter), m_cmd_name(name),
+CommandObject::CommandObject(CommandInterpreter &interpreter,
+ llvm::StringRef name, llvm::StringRef help,
+ llvm::StringRef syntax, uint32_t flags)
+ : m_interpreter(interpreter), m_cmd_name(std::string(name)),
m_cmd_help_short(), m_cmd_help_long(), m_cmd_syntax(), m_flags(flags),
m_arguments(), m_deprecated_command_override_callback(nullptr),
m_command_override_callback(nullptr), m_command_override_baton(nullptr) {
- m_cmd_help_short = help;
- m_cmd_syntax = syntax;
+ m_cmd_help_short = std::string(help);
+ m_cmd_syntax = std::string(syntax);
}
CommandObject::~CommandObject() {}
@@ -73,20 +75,28 @@ llvm::StringRef CommandObject::GetSyntax() {
syntax_str.PutCString("-- ");
GetFormattedCommandArguments(syntax_str);
}
- m_cmd_syntax = syntax_str.GetString();
+ m_cmd_syntax = std::string(syntax_str.GetString());
return m_cmd_syntax;
}
llvm::StringRef CommandObject::GetCommandName() const { return m_cmd_name; }
-void CommandObject::SetCommandName(llvm::StringRef name) { m_cmd_name = name; }
+void CommandObject::SetCommandName(llvm::StringRef name) {
+ m_cmd_name = std::string(name);
+}
-void CommandObject::SetHelp(llvm::StringRef str) { m_cmd_help_short = str; }
+void CommandObject::SetHelp(llvm::StringRef str) {
+ m_cmd_help_short = std::string(str);
+}
-void CommandObject::SetHelpLong(llvm::StringRef str) { m_cmd_help_long = str; }
+void CommandObject::SetHelpLong(llvm::StringRef str) {
+ m_cmd_help_long = std::string(str);
+}
-void CommandObject::SetSyntax(llvm::StringRef str) { m_cmd_syntax = str; }
+void CommandObject::SetSyntax(llvm::StringRef str) {
+ m_cmd_syntax = std::string(str);
+}
Options *CommandObject::GetOptions() {
// By default commands don't have options unless this virtual function is
@@ -258,6 +268,10 @@ void CommandObject::Cleanup() {
}
void CommandObject::HandleCompletion(CompletionRequest &request) {
+
+ m_exe_ctx = m_interpreter.GetExecutionContext();
+ auto reset_ctx = llvm::make_scope_exit([this]() { Cleanup(); });
+
// 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.
@@ -268,7 +282,7 @@ void CommandObject::HandleCompletion(CompletionRequest &request) {
} else {
// Can we do anything generic with the options?
Options *cur_options = GetOptions();
- CommandReturnObject result;
+ CommandReturnObject result(m_interpreter.GetDebugger().GetUseColor());
OptionElementVector opt_element_vector;
if (cur_options != nullptr) {
@@ -485,7 +499,7 @@ void CommandObject::GetFormattedCommandArguments(Stream &str,
names.Printf("%s", GetArgumentName(arg_entry[j].arg_type));
}
- std::string name_str = names.GetString();
+ std::string name_str = std::string(names.GetString());
switch (arg_entry[0].arg_repetition) {
case eArgRepeatPlain:
str.Printf("<%s>", name_str.c_str());
@@ -673,7 +687,7 @@ static llvm::StringRef FormatHelpTextCallback() {
sstr.Flush();
- help_text = sstr.GetString();
+ help_text = std::string(sstr.GetString());
return help_text;
}
@@ -691,7 +705,7 @@ static llvm::StringRef LanguageTypeHelpTextCallback() {
sstr.Flush();
- help_text = sstr.GetString();
+ help_text = std::string(sstr.GetString());
return help_text;
}
@@ -809,7 +823,7 @@ static llvm::StringRef ExprPathHelpTextCallback() {
void CommandObject::FormatLongHelpText(Stream &output_strm,
llvm::StringRef long_help) {
CommandInterpreter &interpreter = GetCommandInterpreter();
- std::stringstream lineStream(long_help);
+ std::stringstream lineStream{std::string(long_help)};
std::string line;
while (std::getline(lineStream, line)) {
if (line.empty()) {
@@ -822,8 +836,8 @@ void CommandObject::FormatLongHelpText(Stream &output_strm,
}
std::string whitespace_prefix = line.substr(0, result);
std::string remainder = line.substr(result);
- interpreter.OutputFormattedHelpText(output_strm, whitespace_prefix.c_str(),
- remainder.c_str());
+ interpreter.OutputFormattedHelpText(output_strm, whitespace_prefix,
+ remainder);
}
}
@@ -835,13 +849,11 @@ void CommandObject::GenerateHelpText(CommandReturnObject &result) {
void CommandObject::GenerateHelpText(Stream &output_strm) {
CommandInterpreter &interpreter = GetCommandInterpreter();
+ std::string help_text(GetHelp());
if (WantsRawCommandString()) {
- std::string help_text(GetHelp());
help_text.append(" Expects 'raw' input (see 'help raw-input'.)");
- interpreter.OutputFormattedHelpText(output_strm, "", "", help_text.c_str(),
- 1);
- } else
- interpreter.OutputFormattedHelpText(output_strm, "", "", GetHelp(), 1);
+ }
+ interpreter.OutputFormattedHelpText(output_strm, "", help_text);
output_strm << "\nSyntax: " << GetSyntax() << "\n";
Options *options = GetOptions();
if (options != nullptr) {
@@ -1066,7 +1078,7 @@ CommandObject::ArgumentTableEntry CommandObject::g_arguments_data[] = {
{ eArgTypePermissionsNumber, "perms-numeric", CommandCompletions::eNoCompletion, { nullptr, false }, "Permissions given as an octal number (e.g. 755)." },
{ eArgTypePermissionsString, "perms=string", CommandCompletions::eNoCompletion, { nullptr, false }, "Permissions given as a string value (e.g. rw-r-xr--)." },
{ eArgTypePid, "pid", CommandCompletions::eNoCompletion, { nullptr, false }, "The process ID number." },
- { eArgTypePlugin, "plugin", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
+ { eArgTypePlugin, "plugin", CommandCompletions::eProcessPluginCompletion, { nullptr, false }, "Help text goes here." },
{ eArgTypeProcessName, "process-name", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of the process." },
{ eArgTypePythonClass, "python-class", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a Python class." },
{ eArgTypePythonFunction, "python-function", CommandCompletions::eNoCompletion, { nullptr, false }, "The name of a Python function." },
@@ -1077,7 +1089,7 @@ CommandObject::ArgumentTableEntry CommandObject::g_arguments_data[] = {
{ eArgTypeRunArgs, "run-args", CommandCompletions::eNoCompletion, { nullptr, false }, "Arguments to be passed to the target program when it starts executing." },
{ eArgTypeRunMode, "run-mode", CommandCompletions::eNoCompletion, { nullptr, false }, "Help text goes here." },
{ eArgTypeScriptedCommandSynchronicity, "script-cmd-synchronicity", CommandCompletions::eNoCompletion, { nullptr, false }, "The synchronicity to use to run scripted commands with regard to LLDB event system." },
- { eArgTypeScriptLang, "script-language", CommandCompletions::eNoCompletion, { nullptr, false }, "The scripting language to be used for script-based commands. Currently only Python is valid." },
+ { eArgTypeScriptLang, "script-language", CommandCompletions::eNoCompletion, { nullptr, false }, "The scripting language to be used for script-based commands. Supported languages are python and lua." },
{ eArgTypeSearchWord, "search-word", CommandCompletions::eNoCompletion, { nullptr, false }, "Any word of interest for search purposes." },
{ eArgTypeSelector, "selector", CommandCompletions::eNoCompletion, { nullptr, false }, "An Objective-C selector name." },
{ eArgTypeSettingIndex, "setting-index", CommandCompletions::eNoCompletion, { nullptr, false }, "An index into a settings variable that is an array (try 'settings list' to see all the possible settings variables and their types)." },
@@ -1105,7 +1117,8 @@ CommandObject::ArgumentTableEntry CommandObject::g_arguments_data[] = {
{ eArgTypeWatchpointIDRange, "watchpt-id-list", CommandCompletions::eNoCompletion, { nullptr, false }, "For example, '1-3' or '1 to 3'." },
{ eArgTypeWatchType, "watch-type", CommandCompletions::eNoCompletion, { nullptr, false }, "Specify the type for a watchpoint." },
{ eArgRawInput, "raw-input", CommandCompletions::eNoCompletion, { nullptr, false }, "Free-form text passed to a command without prior interpretation, allowing spaces without requiring quotes. To pass arguments and free form text put two dashes ' -- ' between the last argument and any raw input." },
- { eArgTypeCommand, "command", CommandCompletions::eNoCompletion, { nullptr, false }, "An LLDB Command line command." }
+ { eArgTypeCommand, "command", CommandCompletions::eNoCompletion, { nullptr, false }, "An LLDB Command line command." },
+ { eArgTypeColumnNum, "column", CommandCompletions::eNoCompletion, { nullptr, false }, "Column number in a source file." }
// clang-format on
};
diff --git a/lldb/source/Interpreter/CommandObjectRegexCommand.cpp b/lldb/source/Interpreter/CommandObjectRegexCommand.cpp
index 693d18ce7bdf..5a0265e58c5c 100644
--- a/lldb/source/Interpreter/CommandObjectRegexCommand.cpp
+++ b/lldb/source/Interpreter/CommandObjectRegexCommand.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectRegexCommand.cpp ---------------------------*- C++ -*-===//
+//===-- CommandObjectRegexCommand.cpp -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/CommandObjectScript.cpp b/lldb/source/Interpreter/CommandObjectScript.cpp
index d61d0cac9762..5e98c658ebdb 100644
--- a/lldb/source/Interpreter/CommandObjectScript.cpp
+++ b/lldb/source/Interpreter/CommandObjectScript.cpp
@@ -1,4 +1,4 @@
-//===-- CommandObjectScript.cpp ---------------------------------*- C++ -*-===//
+//===-- CommandObjectScript.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/CommandObjectScript.h b/lldb/source/Interpreter/CommandObjectScript.h
index 4f7a912979bf..a5f659995de3 100644
--- a/lldb/source/Interpreter/CommandObjectScript.h
+++ b/lldb/source/Interpreter/CommandObjectScript.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CommandObjectScript_h_
-#define liblldb_CommandObjectScript_h_
+#ifndef LLDB_SOURCE_INTERPRETER_COMMANDOBJECTSCRIPT_H
+#define LLDB_SOURCE_INTERPRETER_COMMANDOBJECTSCRIPT_H
#include "lldb/Interpreter/CommandObject.h"
@@ -28,4 +28,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_CommandObjectScript_h_
+#endif // LLDB_SOURCE_INTERPRETER_COMMANDOBJECTSCRIPT_H
diff --git a/lldb/source/Interpreter/CommandOptionValidators.cpp b/lldb/source/Interpreter/CommandOptionValidators.cpp
index c41c1566aab9..a4b4b57c54b1 100644
--- a/lldb/source/Interpreter/CommandOptionValidators.cpp
+++ b/lldb/source/Interpreter/CommandOptionValidators.cpp
@@ -1,4 +1,4 @@
-//===-- CommandOptionValidators.cpp -----------------------------*- C++ -*-===//
+//===-- CommandOptionValidators.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/CommandReturnObject.cpp b/lldb/source/Interpreter/CommandReturnObject.cpp
index c17390be7311..6f3732e35078 100644
--- a/lldb/source/Interpreter/CommandReturnObject.cpp
+++ b/lldb/source/Interpreter/CommandReturnObject.cpp
@@ -1,4 +1,4 @@
-//===-- CommandReturnObject.cpp ---------------------------------*- C++ -*-===//
+//===-- CommandReturnObject.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -14,12 +14,21 @@
using namespace lldb;
using namespace lldb_private;
-static void DumpStringToStreamWithNewline(Stream &strm, const std::string &s,
- bool add_newline_if_empty) {
+static llvm::raw_ostream &error(Stream &strm) {
+ return llvm::WithColor(strm.AsRawOstream(), llvm::HighlightColor::Error,
+ llvm::ColorMode::Enable)
+ << "error: ";
+}
+
+static llvm::raw_ostream &warning(Stream &strm) {
+ return llvm::WithColor(strm.AsRawOstream(), llvm::HighlightColor::Warning,
+ llvm::ColorMode::Enable)
+ << "warning: ";
+}
+
+static void DumpStringToStreamWithNewline(Stream &strm, const std::string &s) {
bool add_newline = false;
- if (s.empty()) {
- add_newline = add_newline_if_empty;
- } else {
+ if (!s.empty()) {
// We already checked for empty above, now make sure there is a newline in
// the error, and if there isn't one, add one.
strm.Write(s.c_str(), s.size());
@@ -31,9 +40,10 @@ static void DumpStringToStreamWithNewline(Stream &strm, const std::string &s,
strm.EOL();
}
-CommandReturnObject::CommandReturnObject()
- : m_out_stream(), m_err_stream(), m_status(eReturnStatusStarted),
- m_did_change_process_state(false), m_interactive(true) {}
+CommandReturnObject::CommandReturnObject(bool colors)
+ : m_out_stream(colors), m_err_stream(colors),
+ m_status(eReturnStatusStarted), m_did_change_process_state(false),
+ m_interactive(true) {}
CommandReturnObject::~CommandReturnObject() {}
@@ -46,11 +56,10 @@ void CommandReturnObject::AppendErrorWithFormat(const char *format, ...) {
sstrm.PrintfVarArg(format, args);
va_end(args);
- const std::string &s = sstrm.GetString();
+ const std::string &s = std::string(sstrm.GetString());
if (!s.empty()) {
- Stream &error_strm = GetErrorStream();
- error_strm.PutCString("error: ");
- DumpStringToStreamWithNewline(error_strm, s, false);
+ error(GetErrorStream());
+ DumpStringToStreamWithNewline(GetErrorStream(), s);
}
}
@@ -75,7 +84,7 @@ void CommandReturnObject::AppendWarningWithFormat(const char *format, ...) {
sstrm.PrintfVarArg(format, args);
va_end(args);
- GetErrorStream() << "warning: " << sstrm.GetString();
+ warning(GetErrorStream()) << sstrm.GetString();
}
void CommandReturnObject::AppendMessage(llvm::StringRef in_string) {
@@ -87,7 +96,7 @@ void CommandReturnObject::AppendMessage(llvm::StringRef in_string) {
void CommandReturnObject::AppendWarning(llvm::StringRef in_string) {
if (in_string.empty())
return;
- GetErrorStream() << "warning: " << in_string << "\n";
+ warning(GetErrorStream()) << in_string << '\n';
}
// Similar to AppendWarning, but do not prepend 'warning: ' to message, and
@@ -102,7 +111,7 @@ void CommandReturnObject::AppendRawWarning(llvm::StringRef in_string) {
void CommandReturnObject::AppendError(llvm::StringRef in_string) {
if (in_string.empty())
return;
- GetErrorStream() << "error: " << in_string << "\n";
+ error(GetErrorStream()) << in_string << '\n';
}
void CommandReturnObject::SetError(const Status &error,
diff --git a/lldb/source/Interpreter/OptionArgParser.cpp b/lldb/source/Interpreter/OptionArgParser.cpp
index 56d99a4220f0..3dcb30e846d9 100644
--- a/lldb/source/Interpreter/OptionArgParser.cpp
+++ b/lldb/source/Interpreter/OptionArgParser.cpp
@@ -1,4 +1,4 @@
-//===-- OptionArgParser.cpp -------------------------------------*- C++ -*-===//
+//===-- OptionArgParser.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionGroupArchitecture.cpp b/lldb/source/Interpreter/OptionGroupArchitecture.cpp
index 11f786c52c09..baca1c6e8068 100644
--- a/lldb/source/Interpreter/OptionGroupArchitecture.cpp
+++ b/lldb/source/Interpreter/OptionGroupArchitecture.cpp
@@ -1,4 +1,4 @@
-//===-- OptionGroupArchitecture.cpp -----------------------------*- C++ -*-===//
+//===-- OptionGroupArchitecture.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -42,7 +42,7 @@ OptionGroupArchitecture::SetOptionValue(uint32_t option_idx,
switch (short_option) {
case 'a':
- m_arch_str.assign(option_arg);
+ m_arch_str.assign(std::string(option_arg));
break;
default:
diff --git a/lldb/source/Interpreter/OptionGroupBoolean.cpp b/lldb/source/Interpreter/OptionGroupBoolean.cpp
index 8a6482c8df25..3482e784ca0c 100644
--- a/lldb/source/Interpreter/OptionGroupBoolean.cpp
+++ b/lldb/source/Interpreter/OptionGroupBoolean.cpp
@@ -1,4 +1,4 @@
-//===-- OptionGroupBoolean.cpp ----------------------------------*- C++ -*-===//
+//===-- OptionGroupBoolean.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionGroupFile.cpp b/lldb/source/Interpreter/OptionGroupFile.cpp
index cda75ec205ec..9d9be5b6f178 100644
--- a/lldb/source/Interpreter/OptionGroupFile.cpp
+++ b/lldb/source/Interpreter/OptionGroupFile.cpp
@@ -1,4 +1,4 @@
-//===-- OptionGroupFile.cpp -------------------------------*- C++ -*-===//
+//===-- OptionGroupFile.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionGroupFormat.cpp b/lldb/source/Interpreter/OptionGroupFormat.cpp
index c25e35f84517..0052f72b0550 100644
--- a/lldb/source/Interpreter/OptionGroupFormat.cpp
+++ b/lldb/source/Interpreter/OptionGroupFormat.cpp
@@ -1,4 +1,4 @@
-//===-- OptionGroupFormat.cpp -----------------------------------*- C++ -*-===//
+//===-- OptionGroupFormat.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionGroupOutputFile.cpp b/lldb/source/Interpreter/OptionGroupOutputFile.cpp
index 3df75cf86b85..65105c3e0180 100644
--- a/lldb/source/Interpreter/OptionGroupOutputFile.cpp
+++ b/lldb/source/Interpreter/OptionGroupOutputFile.cpp
@@ -1,4 +1,4 @@
-//===-- OptionGroupOutputFile.cpp -------------------------------*- C++ -*-===//
+//===-- OptionGroupOutputFile.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionGroupPlatform.cpp b/lldb/source/Interpreter/OptionGroupPlatform.cpp
index 6ddbbf0e3abb..4242e010fa64 100644
--- a/lldb/source/Interpreter/OptionGroupPlatform.cpp
+++ b/lldb/source/Interpreter/OptionGroupPlatform.cpp
@@ -1,4 +1,4 @@
-//===-- OptionGroupPlatform.cpp ---------------------------------*- C++ -*-===//
+//===-- OptionGroupPlatform.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -95,7 +95,7 @@ OptionGroupPlatform::SetOptionValue(uint32_t option_idx,
switch (short_option) {
case 'p':
- m_platform_name.assign(option_arg);
+ m_platform_name.assign(std::string(option_arg));
break;
case 'v':
diff --git a/lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp b/lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp
index e41f9d7b40ee..217dab2ef63b 100644
--- a/lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp
+++ b/lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp
@@ -1,4 +1,4 @@
-//===-- OptionGroupPythonClassWithDict.cpp ----------------------------------*- C++ -*-===//
+//===-- OptionGroupPythonClassWithDict.cpp --------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -91,13 +91,13 @@ Status OptionGroupPythonClassWithDict::SetOptionValue(
switch (option_idx) {
case 0:
case 3: {
- m_name.assign(option_arg);
+ m_name.assign(std::string(option_arg));
} break;
case 1: {
if (!m_dict_sp)
m_dict_sp = std::make_shared<StructuredData::Dictionary>();
if (m_current_key.empty())
- m_current_key.assign(option_arg);
+ m_current_key.assign(std::string(option_arg));
else
error.SetErrorStringWithFormat("Key: \"%s\" missing value.",
m_current_key.c_str());
diff --git a/lldb/source/Interpreter/OptionGroupString.cpp b/lldb/source/Interpreter/OptionGroupString.cpp
index c01b7065fbd0..c9f78eb953f4 100644
--- a/lldb/source/Interpreter/OptionGroupString.cpp
+++ b/lldb/source/Interpreter/OptionGroupString.cpp
@@ -1,4 +1,4 @@
-//===-- OptionGroupString.cpp ----------------------------------*- C++ -*-===//
+//===-- OptionGroupString.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionGroupUInt64.cpp b/lldb/source/Interpreter/OptionGroupUInt64.cpp
index 53e5674d0296..309855d4718c 100644
--- a/lldb/source/Interpreter/OptionGroupUInt64.cpp
+++ b/lldb/source/Interpreter/OptionGroupUInt64.cpp
@@ -1,4 +1,4 @@
-//===-- OptionGroupUInt64.cpp ----------------------------------*- C++ -*-===//
+//===-- OptionGroupUInt64.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionGroupUUID.cpp b/lldb/source/Interpreter/OptionGroupUUID.cpp
index 8fc330a89391..46f2ff75225a 100644
--- a/lldb/source/Interpreter/OptionGroupUUID.cpp
+++ b/lldb/source/Interpreter/OptionGroupUUID.cpp
@@ -1,4 +1,4 @@
-//===-- OptionGroupUUID.cpp -------------------------------------*- C++ -*-===//
+//===-- OptionGroupUUID.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
index da0437ac299c..e0401f8987ad 100644
--- a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
+++ b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
@@ -1,4 +1,4 @@
-//===-- OptionGroupValueObjectDisplay.cpp -----------------------*- C++ -*-===//
+//===-- OptionGroupValueObjectDisplay.cpp ---------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionGroupVariable.cpp b/lldb/source/Interpreter/OptionGroupVariable.cpp
index a9004bf03cd2..9f57dbbd073e 100644
--- a/lldb/source/Interpreter/OptionGroupVariable.cpp
+++ b/lldb/source/Interpreter/OptionGroupVariable.cpp
@@ -1,4 +1,4 @@
-//===-- OptionGroupVariable.cpp -----------------------*- C++ -*-===//
+//===-- OptionGroupVariable.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionGroupWatchpoint.cpp b/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
index 682f99b8c5cc..07013b5b78fe 100644
--- a/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
+++ b/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
@@ -1,4 +1,4 @@
-//===-- OptionGroupWatchpoint.cpp -------------------------------*- C++ -*-===//
+//===-- OptionGroupWatchpoint.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionValue.cpp b/lldb/source/Interpreter/OptionValue.cpp
index bc929aa9dabf..198be85a7b47 100644
--- a/lldb/source/Interpreter/OptionValue.cpp
+++ b/lldb/source/Interpreter/OptionValue.cpp
@@ -1,4 +1,4 @@
-//===-- OptionValue.cpp -----------------------------------------*- C++ -*-===//
+//===-- OptionValue.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,10 +7,11 @@
//===----------------------------------------------------------------------===//
#include "lldb/Interpreter/OptionValue.h"
-
#include "lldb/Interpreter/OptionValues.h"
#include "lldb/Utility/StringList.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -505,37 +506,37 @@ lldb::OptionValueSP OptionValue::CreateValueFromCStringForTypeMask(
lldb::OptionValueSP value_sp;
switch (type_mask) {
case 1u << eTypeArch:
- value_sp.reset(new OptionValueArch());
+ value_sp = std::make_shared<OptionValueArch>();
break;
case 1u << eTypeBoolean:
- value_sp.reset(new OptionValueBoolean(false));
+ value_sp = std::make_shared<OptionValueBoolean>(false);
break;
case 1u << eTypeChar:
- value_sp.reset(new OptionValueChar('\0'));
+ value_sp = std::make_shared<OptionValueChar>('\0');
break;
case 1u << eTypeFileSpec:
- value_sp.reset(new OptionValueFileSpec());
+ value_sp = std::make_shared<OptionValueFileSpec>();
break;
case 1u << eTypeFormat:
- value_sp.reset(new OptionValueFormat(eFormatInvalid));
+ value_sp = std::make_shared<OptionValueFormat>(eFormatInvalid);
break;
case 1u << eTypeFormatEntity:
- value_sp.reset(new OptionValueFormatEntity(nullptr));
+ value_sp = std::make_shared<OptionValueFormatEntity>(nullptr);
break;
case 1u << eTypeLanguage:
- value_sp.reset(new OptionValueLanguage(eLanguageTypeUnknown));
+ value_sp = std::make_shared<OptionValueLanguage>(eLanguageTypeUnknown);
break;
case 1u << eTypeSInt64:
- value_sp.reset(new OptionValueSInt64());
+ value_sp = std::make_shared<OptionValueSInt64>();
break;
case 1u << eTypeString:
- value_sp.reset(new OptionValueString());
+ value_sp = std::make_shared<OptionValueString>();
break;
case 1u << eTypeUInt64:
- value_sp.reset(new OptionValueUInt64());
+ value_sp = std::make_shared<OptionValueUInt64>();
break;
case 1u << eTypeUUID:
- value_sp.reset(new OptionValueUUID());
+ value_sp = std::make_shared<OptionValueUUID>();
break;
}
diff --git a/lldb/source/Interpreter/OptionValueArch.cpp b/lldb/source/Interpreter/OptionValueArch.cpp
index 7271c1471f90..ac78ee64a9d7 100644
--- a/lldb/source/Interpreter/OptionValueArch.cpp
+++ b/lldb/source/Interpreter/OptionValueArch.cpp
@@ -1,4 +1,4 @@
-//===-- OptionValueArch.cpp ---------------------------------*- C++ -*-===//
+//===-- OptionValueArch.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionValueArgs.cpp b/lldb/source/Interpreter/OptionValueArgs.cpp
index d619dba5678a..9e7774a231c7 100644
--- a/lldb/source/Interpreter/OptionValueArgs.cpp
+++ b/lldb/source/Interpreter/OptionValueArgs.cpp
@@ -1,4 +1,4 @@
-//===-- OptionValueArgs.cpp -------------------------------------*- C++ -*-===//
+//===-- OptionValueArgs.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionValueArray.cpp b/lldb/source/Interpreter/OptionValueArray.cpp
index 30902c0f295a..9be11e32e2db 100644
--- a/lldb/source/Interpreter/OptionValueArray.cpp
+++ b/lldb/source/Interpreter/OptionValueArray.cpp
@@ -1,4 +1,4 @@
-//===-- OptionValueArray.cpp ------------------------------------*- C++ -*-===//
+//===-- OptionValueArray.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionValueBoolean.cpp b/lldb/source/Interpreter/OptionValueBoolean.cpp
index 6f893a94e863..24ae3f673bf9 100644
--- a/lldb/source/Interpreter/OptionValueBoolean.cpp
+++ b/lldb/source/Interpreter/OptionValueBoolean.cpp
@@ -1,4 +1,4 @@
-//===-- OptionValueBoolean.cpp ----------------------------------*- C++ -*-===//
+//===-- OptionValueBoolean.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionValueChar.cpp b/lldb/source/Interpreter/OptionValueChar.cpp
index 23012e6e2ec3..af9a371f46d4 100644
--- a/lldb/source/Interpreter/OptionValueChar.cpp
+++ b/lldb/source/Interpreter/OptionValueChar.cpp
@@ -1,4 +1,4 @@
-//===-- OptionValueChar.cpp -------------------------------------*- C++ -*-===//
+//===-- OptionValueChar.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionValueDictionary.cpp b/lldb/source/Interpreter/OptionValueDictionary.cpp
index a4022288fccb..caadccd04232 100644
--- a/lldb/source/Interpreter/OptionValueDictionary.cpp
+++ b/lldb/source/Interpreter/OptionValueDictionary.cpp
@@ -1,4 +1,4 @@
-//===-- OptionValueDictionary.cpp -------------------------------*- C++ -*-===//
+//===-- OptionValueDictionary.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -45,7 +45,7 @@ void OptionValueDictionary::DumpValue(const ExecutionContext *exe_ctx,
else
strm.EOL();
- strm.Indent(pos->first.GetCString());
+ strm.Indent(pos->first.GetStringRef());
const uint32_t extra_dump_options = m_raw_value_dump ? eDumpOptionRaw : 0;
switch (dict_type) {
diff --git a/lldb/source/Interpreter/OptionValueEnumeration.cpp b/lldb/source/Interpreter/OptionValueEnumeration.cpp
index 26933aa78240..9a1e08d4fba0 100644
--- a/lldb/source/Interpreter/OptionValueEnumeration.cpp
+++ b/lldb/source/Interpreter/OptionValueEnumeration.cpp
@@ -1,4 +1,4 @@
-//===-- OptionValueEnumeration.cpp ------------------------------*- C++ -*-===//
+//===-- OptionValueEnumeration.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionValueFileSpec.cpp b/lldb/source/Interpreter/OptionValueFileSpec.cpp
index 20d3d4e68e33..15acb7e5e5b0 100644
--- a/lldb/source/Interpreter/OptionValueFileSpec.cpp
+++ b/lldb/source/Interpreter/OptionValueFileSpec.cpp
@@ -1,4 +1,4 @@
-//===-- OptionValueFileSpec.cpp ---------------------------------*- C++ -*-===//
+//===-- OptionValueFileSpec.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionValueFormat.cpp b/lldb/source/Interpreter/OptionValueFormat.cpp
index ba5a44c270da..b676bed50e62 100644
--- a/lldb/source/Interpreter/OptionValueFormat.cpp
+++ b/lldb/source/Interpreter/OptionValueFormat.cpp
@@ -1,4 +1,4 @@
-//===-- OptionValueFormat.cpp -----------------------------------*- C++ -*-===//
+//===-- OptionValueFormat.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionValueFormatEntity.cpp b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
index 8dc52650a331..6b36bd575186 100644
--- a/lldb/source/Interpreter/OptionValueFormatEntity.cpp
+++ b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
@@ -1,4 +1,4 @@
-//===-- OptionValueFormatEntity.cpp -----------------------------*- C++ -*-===//
+//===-- OptionValueFormatEntity.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -95,7 +95,7 @@ Status OptionValueFormatEntity::SetValueFromString(llvm::StringRef value_str,
error = FormatEntity::Parse(value_str, entry);
if (error.Success()) {
m_current_entry = std::move(entry);
- m_current_format = value_str;
+ m_current_format = std::string(value_str);
m_value_was_set = true;
NotifyValueChanged();
}
diff --git a/lldb/source/Interpreter/OptionValueLanguage.cpp b/lldb/source/Interpreter/OptionValueLanguage.cpp
index 1d7e18868b6f..5b310782a1ba 100644
--- a/lldb/source/Interpreter/OptionValueLanguage.cpp
+++ b/lldb/source/Interpreter/OptionValueLanguage.cpp
@@ -1,4 +1,4 @@
-//===-- OptionValueLanguage.cpp ---------------------------------*- C++ -*-===//
+//===-- OptionValueLanguage.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionValuePathMappings.cpp b/lldb/source/Interpreter/OptionValuePathMappings.cpp
index 75fcf0247475..3b3f43d07293 100644
--- a/lldb/source/Interpreter/OptionValuePathMappings.cpp
+++ b/lldb/source/Interpreter/OptionValuePathMappings.cpp
@@ -1,4 +1,4 @@
-//===-- OptionValuePathMappings.cpp -----------------------------*- C++ -*-===//
+//===-- OptionValuePathMappings.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -61,7 +61,7 @@ Status OptionValuePathMappings::SetValueFromString(llvm::StringRef value,
count);
} else {
bool changed = false;
- for (size_t i = 1; i < argc; i += 2, ++idx) {
+ for (size_t i = 1; i < argc; idx++, i += 2) {
const char *orginal_path = args.GetArgumentAtIndex(i);
const char *replace_path = args.GetArgumentAtIndex(i + 1);
if (VerifyPathExists(replace_path)) {
@@ -71,9 +71,11 @@ Status OptionValuePathMappings::SetValueFromString(llvm::StringRef value,
m_path_mappings.Append(a, b, m_notify_changes);
changed = true;
} else {
+ std::string previousError =
+ error.Fail() ? std::string(error.AsCString()) + "\n" : "";
error.SetErrorStringWithFormat(
- "the replacement path doesn't exist: \"%s\"", replace_path);
- break;
+ "%sthe replacement path doesn't exist: \"%s\"",
+ previousError.c_str(), replace_path);
}
}
if (changed)
@@ -109,9 +111,11 @@ Status OptionValuePathMappings::SetValueFromString(llvm::StringRef value,
m_value_was_set = true;
changed = true;
} else {
+ std::string previousError =
+ error.Fail() ? std::string(error.AsCString()) + "\n" : "";
error.SetErrorStringWithFormat(
- "the replacement path doesn't exist: \"%s\"", replace_path);
- break;
+ "%sthe replacement path doesn't exist: \"%s\"",
+ previousError.c_str(), replace_path);
}
}
if (changed)
@@ -135,7 +139,7 @@ Status OptionValuePathMappings::SetValueFromString(llvm::StringRef value,
bool changed = false;
if (op == eVarSetOperationInsertAfter)
++idx;
- for (size_t i = 1; i < argc; i += 2, ++idx) {
+ for (size_t i = 1; i < argc; i += 2) {
const char *orginal_path = args.GetArgumentAtIndex(i);
const char *replace_path = args.GetArgumentAtIndex(i + 1);
if (VerifyPathExists(replace_path)) {
@@ -143,10 +147,13 @@ Status OptionValuePathMappings::SetValueFromString(llvm::StringRef value,
ConstString b(replace_path);
m_path_mappings.Insert(a, b, idx, m_notify_changes);
changed = true;
+ idx++;
} else {
+ std::string previousError =
+ error.Fail() ? std::string(error.AsCString()) + "\n" : "";
error.SetErrorStringWithFormat(
- "the replacement path doesn't exist: \"%s\"", replace_path);
- break;
+ "%sthe replacement path doesn't exist: \"%s\"",
+ previousError.c_str(), replace_path);
}
}
if (changed)
@@ -161,32 +168,23 @@ Status OptionValuePathMappings::SetValueFromString(llvm::StringRef value,
case eVarSetOperationRemove:
if (argc > 0) {
std::vector<int> remove_indexes;
- bool all_indexes_valid = true;
- size_t i;
- for (i = 0; all_indexes_valid && i < argc; ++i) {
- const int idx =
+ for (size_t i = 0; i < argc; ++i) {
+ int idx =
StringConvert::ToSInt32(args.GetArgumentAtIndex(i), INT32_MAX);
- if (idx == INT32_MAX)
- all_indexes_valid = false;
- else
+ if (idx < 0 || idx >= (int)m_path_mappings.GetSize()) {
+ error.SetErrorStringWithFormat(
+ "invalid array index '%s', aborting remove operation",
+ args.GetArgumentAtIndex(i));
+ break;
+ } else
remove_indexes.push_back(idx);
}
- if (all_indexes_valid) {
- size_t num_remove_indexes = remove_indexes.size();
- if (num_remove_indexes) {
- // Sort and then erase in reverse so indexes are always valid
- llvm::sort(remove_indexes.begin(), remove_indexes.end());
- for (size_t j = num_remove_indexes - 1; j < num_remove_indexes; ++j) {
- m_path_mappings.Remove(j, m_notify_changes);
- }
- }
- NotifyValueChanged();
- } else {
- error.SetErrorStringWithFormat(
- "invalid array index '%s', aborting remove operation",
- args.GetArgumentAtIndex(i));
- }
+ // Sort and then erase in reverse so indexes are always valid
+ llvm::sort(remove_indexes.begin(), remove_indexes.end());
+ for (auto index : llvm::reverse(remove_indexes))
+ m_path_mappings.Remove(index, m_notify_changes);
+ NotifyValueChanged();
} else {
error.SetErrorString("remove operation takes one or more array index");
}
diff --git a/lldb/source/Interpreter/OptionValueProperties.cpp b/lldb/source/Interpreter/OptionValueProperties.cpp
index 21750cf18615..24cda056977e 100644
--- a/lldb/source/Interpreter/OptionValueProperties.cpp
+++ b/lldb/source/Interpreter/OptionValueProperties.cpp
@@ -1,4 +1,4 @@
-//===-- OptionValueProperties.cpp --------------------------------*- C++-*-===//
+//===-- OptionValueProperties.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionValueRegex.cpp b/lldb/source/Interpreter/OptionValueRegex.cpp
index cf806fb550f9..bec3942d9cb0 100644
--- a/lldb/source/Interpreter/OptionValueRegex.cpp
+++ b/lldb/source/Interpreter/OptionValueRegex.cpp
@@ -1,4 +1,4 @@
-//===-- OptionValueRegex.cpp ------------------------------------*- C++ -*-===//
+//===-- OptionValueRegex.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionValueSInt64.cpp b/lldb/source/Interpreter/OptionValueSInt64.cpp
index d26fc08a3132..ada20b2139a3 100644
--- a/lldb/source/Interpreter/OptionValueSInt64.cpp
+++ b/lldb/source/Interpreter/OptionValueSInt64.cpp
@@ -1,4 +1,4 @@
-//===-- OptionValueSInt64.cpp -----------------------------------*- C++ -*-===//
+//===-- OptionValueSInt64.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionValueString.cpp b/lldb/source/Interpreter/OptionValueString.cpp
index a519249ab472..22f5d08bf832 100644
--- a/lldb/source/Interpreter/OptionValueString.cpp
+++ b/lldb/source/Interpreter/OptionValueString.cpp
@@ -1,5 +1,4 @@
-//===-- OptionValueString.cpp ------------------------------------*- C++
-//-*-===//
+//===-- OptionValueString.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -83,7 +82,7 @@ Status OptionValueString::SetValueFromString(llvm::StringRef value,
Args::EncodeEscapeSequences(value_str.c_str(), str);
new_value.append(str);
} else
- new_value.append(value);
+ new_value.append(std::string(value));
}
if (m_validator) {
error = m_validator(new_value.c_str(), m_validator_baton);
@@ -128,7 +127,7 @@ Status OptionValueString::SetCurrentValue(llvm::StringRef value) {
if (error.Fail())
return error;
}
- m_current_value.assign(value);
+ m_current_value.assign(std::string(value));
return Status();
}
diff --git a/lldb/source/Interpreter/OptionValueUInt64.cpp b/lldb/source/Interpreter/OptionValueUInt64.cpp
index 3be0772daa8c..98ef016e5f77 100644
--- a/lldb/source/Interpreter/OptionValueUInt64.cpp
+++ b/lldb/source/Interpreter/OptionValueUInt64.cpp
@@ -1,5 +1,4 @@
-//===-- OptionValueUInt64.cpp ------------------------------------*- C++
-//-*-===//
+//===-- OptionValueUInt64.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/OptionValueUUID.cpp b/lldb/source/Interpreter/OptionValueUUID.cpp
index 7a6bc65b25a4..2bd749773556 100644
--- a/lldb/source/Interpreter/OptionValueUUID.cpp
+++ b/lldb/source/Interpreter/OptionValueUUID.cpp
@@ -1,4 +1,4 @@
-//===-- OptionValueUUID.cpp ------------------------------------*- C++ -*-===//
+//===-- OptionValueUUID.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -38,7 +38,7 @@ Status OptionValueUUID::SetValueFromString(llvm::StringRef value,
case eVarSetOperationReplace:
case eVarSetOperationAssign: {
- if (m_uuid.SetFromStringRef(value) == 0)
+ if (!m_uuid.SetFromStringRef(value))
error.SetErrorStringWithFormat("invalid uuid string value '%s'",
value.str().c_str());
else {
diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp
index 0bceea14269d..c14b6b6ce66a 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -1,4 +1,4 @@
-//===-- Options.cpp ---------------------------------------------*- C++ -*-===//
+//===-- Options.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -282,7 +282,7 @@ void Options::OutputFormattedUsageText(Stream &strm,
if (static_cast<uint32_t>(actual_text.length() + strm.GetIndentLevel()) <
output_max_columns) {
// Output it as a single line.
- strm.Indent(actual_text.c_str());
+ strm.Indent(actual_text);
strm.EOL();
} else {
// We need to break it up into multiple lines.
@@ -798,7 +798,8 @@ void Options::HandleOptionArgumentCompletion(
interpreter.GetDebugger().GetSelectedTarget();
// Search filters require a target...
if (target_sp)
- filter_up.reset(new SearchFilterByModule(target_sp, module_spec));
+ filter_up =
+ std::make_unique<SearchFilterByModule>(target_sp, module_spec);
}
break;
}
@@ -932,7 +933,7 @@ static size_t FindArgumentIndexForOption(const Args &args,
const Option &long_option) {
std::string short_opt = llvm::formatv("-{0}", char(long_option.val)).str();
std::string long_opt =
- llvm::formatv("--{0}", long_option.definition->long_option);
+ std::string(llvm::formatv("--{0}", long_option.definition->long_option));
for (const auto &entry : llvm::enumerate(args)) {
if (entry.value().ref().startswith(short_opt) ||
entry.value().ref().startswith(long_opt))
@@ -1061,8 +1062,8 @@ llvm::Expected<Args> Options::ParseAlias(const Args &args,
}
if (!option_arg)
option_arg = "<no-argument>";
- option_arg_vector->emplace_back(option_str.GetString(), has_arg,
- option_arg);
+ option_arg_vector->emplace_back(std::string(option_str.GetString()),
+ has_arg, std::string(option_arg));
// Find option in the argument list; also see if it was supposed to take an
// argument and if one was supplied. Remove option (and argument, if
@@ -1075,7 +1076,7 @@ llvm::Expected<Args> Options::ParseAlias(const Args &args,
if (!input_line.empty()) {
auto tmp_arg = args_copy[idx].ref();
- size_t pos = input_line.find(tmp_arg);
+ size_t pos = input_line.find(std::string(tmp_arg));
if (pos != std::string::npos)
input_line.erase(pos, tmp_arg.size());
}
@@ -1087,7 +1088,7 @@ llvm::Expected<Args> Options::ParseAlias(const Args &args,
(args_copy[idx].ref() == OptionParser::GetOptionArgument())) {
if (input_line.size() > 0) {
auto tmp_arg = args_copy[idx].ref();
- size_t pos = input_line.find(tmp_arg);
+ size_t pos = input_line.find(std::string(tmp_arg));
if (pos != std::string::npos)
input_line.erase(pos, tmp_arg.size());
}
diff --git a/lldb/source/Interpreter/Property.cpp b/lldb/source/Interpreter/Property.cpp
index a81098373c25..923811249853 100644
--- a/lldb/source/Interpreter/Property.cpp
+++ b/lldb/source/Interpreter/Property.cpp
@@ -1,4 +1,4 @@
-//===-- Property.cpp --------------------------------------------*- C++ -*-===//
+//===-- Property.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Interpreter/ScriptInterpreter.cpp b/lldb/source/Interpreter/ScriptInterpreter.cpp
index 00c460612ac1..86620449f2f4 100644
--- a/lldb/source/Interpreter/ScriptInterpreter.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreter.cpp
@@ -1,4 +1,4 @@
-//===-- ScriptInterpreter.cpp -----------------------------------*- C++ -*-===//
+//===-- ScriptInterpreter.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,16 +7,21 @@
//===----------------------------------------------------------------------===//
#include "lldb/Interpreter/ScriptInterpreter.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string>
-
+#include "lldb/Core/Debugger.h"
+#include "lldb/Host/ConnectionFileDescriptor.h"
+#include "lldb/Host/Pipe.h"
#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StringList.h"
+#if defined(_WIN32)
+#include "lldb/Host/windows/ConnectionGenericFileWindows.h"
+#endif
+#include <memory>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string>
using namespace lldb;
using namespace lldb_private;
@@ -102,6 +107,113 @@ Status ScriptInterpreter::SetBreakpointCommandCallbackFunction(
std::unique_ptr<ScriptInterpreterLocker>
ScriptInterpreter::AcquireInterpreterLock() {
- return std::unique_ptr<ScriptInterpreterLocker>(
- new ScriptInterpreterLocker());
+ return std::make_unique<ScriptInterpreterLocker>();
+}
+
+static void ReadThreadBytesReceived(void *baton, const void *src,
+ size_t src_len) {
+ if (src && src_len) {
+ Stream *strm = (Stream *)baton;
+ strm->Write(src, src_len);
+ strm->Flush();
+ }
+}
+
+llvm::Expected<std::unique_ptr<ScriptInterpreterIORedirect>>
+ScriptInterpreterIORedirect::Create(bool enable_io, Debugger &debugger,
+ CommandReturnObject *result) {
+ if (enable_io)
+ return std::unique_ptr<ScriptInterpreterIORedirect>(
+ new ScriptInterpreterIORedirect(debugger, result));
+
+ auto nullin = FileSystem::Instance().Open(FileSpec(FileSystem::DEV_NULL),
+ File::eOpenOptionRead);
+ if (!nullin)
+ return nullin.takeError();
+
+ auto nullout = FileSystem::Instance().Open(FileSpec(FileSystem::DEV_NULL),
+ File::eOpenOptionWrite);
+ if (!nullout)
+ return nullin.takeError();
+
+ return std::unique_ptr<ScriptInterpreterIORedirect>(
+ new ScriptInterpreterIORedirect(std::move(*nullin), std::move(*nullout)));
+}
+
+ScriptInterpreterIORedirect::ScriptInterpreterIORedirect(
+ std::unique_ptr<File> input, std::unique_ptr<File> output)
+ : m_input_file_sp(std::move(input)),
+ m_output_file_sp(std::make_shared<StreamFile>(std::move(output))),
+ m_error_file_sp(m_output_file_sp),
+ m_communication("lldb.ScriptInterpreterIORedirect.comm"),
+ m_disconnect(false) {}
+
+ScriptInterpreterIORedirect::ScriptInterpreterIORedirect(
+ Debugger &debugger, CommandReturnObject *result)
+ : m_communication("lldb.ScriptInterpreterIORedirect.comm"),
+ m_disconnect(false) {
+
+ if (result) {
+ m_input_file_sp = debugger.GetInputFileSP();
+
+ Pipe pipe;
+ Status pipe_result = pipe.CreateNew(false);
+#if defined(_WIN32)
+ lldb::file_t read_file = pipe.GetReadNativeHandle();
+ pipe.ReleaseReadFileDescriptor();
+ std::unique_ptr<ConnectionGenericFile> conn_up =
+ std::make_unique<ConnectionGenericFile>(read_file, true);
+#else
+ std::unique_ptr<ConnectionFileDescriptor> conn_up =
+ std::make_unique<ConnectionFileDescriptor>(
+ pipe.ReleaseReadFileDescriptor(), true);
+#endif
+
+ if (conn_up->IsConnected()) {
+ m_communication.SetConnection(std::move(conn_up));
+ m_communication.SetReadThreadBytesReceivedCallback(
+ ReadThreadBytesReceived, &result->GetOutputStream());
+ m_communication.StartReadThread();
+ m_disconnect = true;
+
+ FILE *outfile_handle = fdopen(pipe.ReleaseWriteFileDescriptor(), "w");
+ m_output_file_sp = std::make_shared<StreamFile>(outfile_handle, true);
+ m_error_file_sp = m_output_file_sp;
+ if (outfile_handle)
+ ::setbuf(outfile_handle, nullptr);
+
+ result->SetImmediateOutputFile(debugger.GetOutputStream().GetFileSP());
+ result->SetImmediateErrorFile(debugger.GetErrorStream().GetFileSP());
+ }
+ }
+
+ if (!m_input_file_sp || !m_output_file_sp || !m_error_file_sp)
+ debugger.AdoptTopIOHandlerFilesIfInvalid(m_input_file_sp, m_output_file_sp,
+ m_error_file_sp);
+}
+
+void ScriptInterpreterIORedirect::Flush() {
+ if (m_output_file_sp)
+ m_output_file_sp->Flush();
+ if (m_error_file_sp)
+ m_error_file_sp->Flush();
+}
+
+ScriptInterpreterIORedirect::~ScriptInterpreterIORedirect() {
+ if (!m_disconnect)
+ return;
+
+ assert(m_output_file_sp);
+ assert(m_error_file_sp);
+ assert(m_output_file_sp == m_error_file_sp);
+
+ // Close the write end of the pipe since we are done with our one line
+ // script. This should cause the read thread that output_comm is using to
+ // exit.
+ m_output_file_sp->GetFile().Close();
+ // The close above should cause this thread to exit when it gets to the end
+ // of file, so let it get all its data.
+ m_communication.JoinReadThread();
+ // Now we can close the read end of the pipe.
+ m_communication.Disconnect();
}
diff --git a/lldb/source/Interpreter/embedded_interpreter.py b/lldb/source/Interpreter/embedded_interpreter.py
index 8a1195d83c6f..9312dbfaca4e 100644
--- a/lldb/source/Interpreter/embedded_interpreter.py
+++ b/lldb/source/Interpreter/embedded_interpreter.py
@@ -73,7 +73,12 @@ def get_terminal_size(fd):
def readfunc_stdio(prompt):
sys.stdout.write(prompt)
sys.stdout.flush()
- return sys.stdin.readline().rstrip()
+ line = sys.stdin.readline()
+ # Readline always includes a trailing newline character unless the file
+ # ends with an incomplete line. An empty line indicates EOF.
+ if not line:
+ raise EOFError
+ return line.rstrip()
def run_python_interpreter(local_dict):
diff --git a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
new file mode 100644
index 000000000000..5cf9fb4ad37f
--- /dev/null
+++ b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -0,0 +1,52 @@
+//===-- AArch66.h ---------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "ABIAArch64.h"
+#include "ABIMacOSX_arm64.h"
+#include "ABISysV_arm64.h"
+#include "Utility/ARM64_DWARF_Registers.h"
+#include "lldb/Core/PluginManager.h"
+
+LLDB_PLUGIN_DEFINE(ABIAArch64)
+
+void ABIAArch64::Initialize() {
+ ABISysV_arm64::Initialize();
+ ABIMacOSX_arm64::Initialize();
+}
+
+void ABIAArch64::Terminate() {
+ ABISysV_arm64::Terminate();
+ ABIMacOSX_arm64::Terminate();
+}
+
+std::pair<uint32_t, uint32_t>
+ABIAArch64::GetEHAndDWARFNums(llvm::StringRef name) {
+ if (name == "pc")
+ return {LLDB_INVALID_REGNUM, arm64_dwarf::pc};
+ if (name == "cpsr")
+ return {LLDB_INVALID_REGNUM, arm64_dwarf::cpsr};
+ return MCBasedABI::GetEHAndDWARFNums(name);
+}
+
+uint32_t ABIAArch64::GetGenericNum(llvm::StringRef name) {
+ return llvm::StringSwitch<uint32_t>(name)
+ .Case("pc", LLDB_REGNUM_GENERIC_PC)
+ .Case("lr", LLDB_REGNUM_GENERIC_RA)
+ .Case("sp", LLDB_REGNUM_GENERIC_SP)
+ .Case("fp", LLDB_REGNUM_GENERIC_FP)
+ .Case("cpsr", LLDB_REGNUM_GENERIC_FLAGS)
+ .Case("x0", LLDB_REGNUM_GENERIC_ARG1)
+ .Case("x1", LLDB_REGNUM_GENERIC_ARG2)
+ .Case("x2", LLDB_REGNUM_GENERIC_ARG3)
+ .Case("x3", LLDB_REGNUM_GENERIC_ARG4)
+ .Case("x4", LLDB_REGNUM_GENERIC_ARG5)
+ .Case("x5", LLDB_REGNUM_GENERIC_ARG6)
+ .Case("x6", LLDB_REGNUM_GENERIC_ARG7)
+ .Case("x7", LLDB_REGNUM_GENERIC_ARG8)
+ .Default(LLDB_INVALID_REGNUM);
+}
diff --git a/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
new file mode 100644
index 000000000000..981145e2017e
--- /dev/null
+++ b/lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
@@ -0,0 +1,32 @@
+//===-- AArch64.h -----------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_ABI_AARCH64_ABIAARCH64_H
+#define LLDB_SOURCE_PLUGINS_ABI_AARCH64_ABIAARCH64_H
+
+#include "lldb/Target/ABI.h"
+
+class ABIAArch64: public lldb_private::MCBasedABI {
+public:
+ static void Initialize();
+ static void Terminate();
+
+protected:
+ std::pair<uint32_t, uint32_t>
+ GetEHAndDWARFNums(llvm::StringRef name) override;
+
+ std::string GetMCName(std::string reg) override {
+ MapRegisterName(reg, "v", "q");
+ return reg;
+ }
+
+ uint32_t GetGenericNum(llvm::StringRef name) override;
+
+ using lldb_private::MCBasedABI::MCBasedABI;
+};
+#endif
diff --git a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
new file mode 100644
index 000000000000..983da26a2a6d
--- /dev/null
+++ b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
@@ -0,0 +1,831 @@
+//===-- ABIMacOSX_arm64.cpp -----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "ABIMacOSX_arm64.h"
+
+#include <vector>
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/Triple.h"
+
+#include "lldb/Core/Module.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Value.h"
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/Symbol/UnwindPlan.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegisterValue.h"
+#include "lldb/Utility/Scalar.h"
+#include "lldb/Utility/Status.h"
+
+#include "Utility/ARM64_DWARF_Registers.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+static const char *pluginDesc = "Mac OS X ABI for arm64 targets";
+
+size_t ABIMacOSX_arm64::GetRedZoneSize() const { return 128; }
+
+// Static Functions
+
+ABISP
+ABIMacOSX_arm64::CreateInstance(ProcessSP process_sp, const ArchSpec &arch) {
+ const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch();
+ const llvm::Triple::VendorType vendor_type = arch.GetTriple().getVendor();
+
+ if (vendor_type == llvm::Triple::Apple) {
+ if (arch_type == llvm::Triple::aarch64 ||
+ arch_type == llvm::Triple::aarch64_32) {
+ return ABISP(
+ new ABIMacOSX_arm64(std::move(process_sp), MakeMCRegisterInfo(arch)));
+ }
+ }
+
+ return ABISP();
+}
+
+bool ABIMacOSX_arm64::PrepareTrivialCall(
+ Thread &thread, lldb::addr_t sp, lldb::addr_t func_addr,
+ lldb::addr_t return_addr, llvm::ArrayRef<lldb::addr_t> args) const {
+ RegisterContext *reg_ctx = thread.GetRegisterContext().get();
+ if (!reg_ctx)
+ return false;
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+
+ if (log) {
+ StreamString s;
+ s.Printf("ABISysV_x86_64::PrepareTrivialCall (tid = 0x%" PRIx64
+ ", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64
+ ", return_addr = 0x%" PRIx64,
+ thread.GetID(), (uint64_t)sp, (uint64_t)func_addr,
+ (uint64_t)return_addr);
+
+ for (size_t i = 0; i < args.size(); ++i)
+ s.Printf(", arg%d = 0x%" PRIx64, static_cast<int>(i + 1), args[i]);
+ s.PutCString(")");
+ log->PutString(s.GetString());
+ }
+
+ const uint32_t pc_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
+ const uint32_t sp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP);
+ const uint32_t ra_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA);
+
+ // x0 - x7 contain first 8 simple args
+ if (args.size() > 8) // TODO handle more than 6 arguments
+ return false;
+
+ for (size_t i = 0; i < args.size(); ++i) {
+ const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + i);
+ LLDB_LOGF(log, "About to write arg%d (0x%" PRIx64 ") into %s",
+ static_cast<int>(i + 1), args[i], reg_info->name);
+ if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i]))
+ return false;
+ }
+
+ // Set "lr" to the return address
+ if (!reg_ctx->WriteRegisterFromUnsigned(
+ reg_ctx->GetRegisterInfoAtIndex(ra_reg_num), return_addr))
+ return false;
+
+ // Set "sp" to the requested value
+ if (!reg_ctx->WriteRegisterFromUnsigned(
+ reg_ctx->GetRegisterInfoAtIndex(sp_reg_num), sp))
+ return false;
+
+ // Set "pc" to the address requested
+ if (!reg_ctx->WriteRegisterFromUnsigned(
+ reg_ctx->GetRegisterInfoAtIndex(pc_reg_num), func_addr))
+ return false;
+
+ return true;
+}
+
+bool ABIMacOSX_arm64::GetArgumentValues(Thread &thread,
+ ValueList &values) const {
+ uint32_t num_values = values.GetSize();
+
+ ExecutionContext exe_ctx(thread.shared_from_this());
+
+ // Extract the register context so we can read arguments from registers
+
+ RegisterContext *reg_ctx = thread.GetRegisterContext().get();
+
+ if (!reg_ctx)
+ return false;
+
+ addr_t sp = 0;
+
+ for (uint32_t value_idx = 0; value_idx < num_values; ++value_idx) {
+ // We currently only support extracting values with Clang QualTypes. Do we
+ // care about others?
+ Value *value = values.GetValueAtIndex(value_idx);
+
+ if (!value)
+ return false;
+
+ CompilerType value_type = value->GetCompilerType();
+ llvm::Optional<uint64_t> bit_size = value_type.GetBitSize(&thread);
+ if (!bit_size)
+ return false;
+
+ bool is_signed = false;
+ size_t bit_width = 0;
+ if (value_type.IsIntegerOrEnumerationType(is_signed)) {
+ bit_width = *bit_size;
+ } else if (value_type.IsPointerOrReferenceType()) {
+ bit_width = *bit_size;
+ } else {
+ // We only handle integer, pointer and reference types currently...
+ return false;
+ }
+
+ if (bit_width <= (exe_ctx.GetProcessRef().GetAddressByteSize() * 8)) {
+ if (value_idx < 8) {
+ // Arguments 1-6 are in x0-x5...
+ const RegisterInfo *reg_info = nullptr;
+ // Search by generic ID first, then fall back to by name
+ uint32_t arg_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + value_idx);
+ if (arg_reg_num != LLDB_INVALID_REGNUM) {
+ reg_info = reg_ctx->GetRegisterInfoAtIndex(arg_reg_num);
+ } else {
+ switch (value_idx) {
+ case 0:
+ reg_info = reg_ctx->GetRegisterInfoByName("x0");
+ break;
+ case 1:
+ reg_info = reg_ctx->GetRegisterInfoByName("x1");
+ break;
+ case 2:
+ reg_info = reg_ctx->GetRegisterInfoByName("x2");
+ break;
+ case 3:
+ reg_info = reg_ctx->GetRegisterInfoByName("x3");
+ break;
+ case 4:
+ reg_info = reg_ctx->GetRegisterInfoByName("x4");
+ break;
+ case 5:
+ reg_info = reg_ctx->GetRegisterInfoByName("x5");
+ break;
+ case 6:
+ reg_info = reg_ctx->GetRegisterInfoByName("x6");
+ break;
+ case 7:
+ reg_info = reg_ctx->GetRegisterInfoByName("x7");
+ break;
+ }
+ }
+
+ if (reg_info) {
+ RegisterValue reg_value;
+
+ if (reg_ctx->ReadRegister(reg_info, reg_value)) {
+ if (is_signed)
+ reg_value.SignExtend(bit_width);
+ if (!reg_value.GetScalarValue(value->GetScalar()))
+ return false;
+ continue;
+ }
+ }
+ return false;
+ } else {
+ if (sp == 0) {
+ // Read the stack pointer if we already haven't read it
+ sp = reg_ctx->GetSP(0);
+ if (sp == 0)
+ return false;
+ }
+
+ // Arguments 5 on up are on the stack
+ const uint32_t arg_byte_size = (bit_width + (8 - 1)) / 8;
+ Status error;
+ if (!exe_ctx.GetProcessRef().ReadScalarIntegerFromMemory(
+ sp, arg_byte_size, is_signed, value->GetScalar(), error))
+ return false;
+
+ sp += arg_byte_size;
+ // Align up to the next 8 byte boundary if needed
+ if (sp % 8) {
+ sp >>= 3;
+ sp += 1;
+ sp <<= 3;
+ }
+ }
+ }
+ }
+ return true;
+}
+
+Status
+ABIMacOSX_arm64::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
+ lldb::ValueObjectSP &new_value_sp) {
+ Status error;
+ if (!new_value_sp) {
+ error.SetErrorString("Empty value object for return value.");
+ return error;
+ }
+
+ CompilerType return_value_type = new_value_sp->GetCompilerType();
+ if (!return_value_type) {
+ error.SetErrorString("Null clang type for return value.");
+ return error;
+ }
+
+ Thread *thread = frame_sp->GetThread().get();
+
+ RegisterContext *reg_ctx = thread->GetRegisterContext().get();
+
+ if (reg_ctx) {
+ DataExtractor data;
+ Status data_error;
+ const uint64_t byte_size = new_value_sp->GetData(data, data_error);
+ if (data_error.Fail()) {
+ error.SetErrorStringWithFormat(
+ "Couldn't convert return value to raw data: %s",
+ data_error.AsCString());
+ return error;
+ }
+
+ const uint32_t type_flags = return_value_type.GetTypeInfo(nullptr);
+ if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) {
+ if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) {
+ // Extract the register context so we can read arguments from registers
+ lldb::offset_t offset = 0;
+ if (byte_size <= 16) {
+ const RegisterInfo *x0_info = reg_ctx->GetRegisterInfoByName("x0", 0);
+ if (byte_size <= 8) {
+ uint64_t raw_value = data.GetMaxU64(&offset, byte_size);
+
+ if (!reg_ctx->WriteRegisterFromUnsigned(x0_info, raw_value))
+ error.SetErrorString("failed to write register x0");
+ } else {
+ uint64_t raw_value = data.GetMaxU64(&offset, 8);
+
+ if (reg_ctx->WriteRegisterFromUnsigned(x0_info, raw_value)) {
+ const RegisterInfo *x1_info =
+ reg_ctx->GetRegisterInfoByName("x1", 0);
+ raw_value = data.GetMaxU64(&offset, byte_size - offset);
+
+ if (!reg_ctx->WriteRegisterFromUnsigned(x1_info, raw_value))
+ error.SetErrorString("failed to write register x1");
+ }
+ }
+ } else {
+ error.SetErrorString("We don't support returning longer than 128 bit "
+ "integer values at present.");
+ }
+ } else if (type_flags & eTypeIsFloat) {
+ if (type_flags & eTypeIsComplex) {
+ // Don't handle complex yet.
+ error.SetErrorString(
+ "returning complex float values are not supported");
+ } else {
+ const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0);
+
+ if (v0_info) {
+ if (byte_size <= 16) {
+ if (byte_size <= RegisterValue::GetMaxByteSize()) {
+ RegisterValue reg_value;
+ error = reg_value.SetValueFromData(v0_info, data, 0, true);
+ if (error.Success()) {
+ if (!reg_ctx->WriteRegister(v0_info, reg_value))
+ error.SetErrorString("failed to write register v0");
+ }
+ } else {
+ error.SetErrorStringWithFormat(
+ "returning float values with a byte size of %" PRIu64
+ " are not supported",
+ byte_size);
+ }
+ } else {
+ error.SetErrorString("returning float values longer than 128 "
+ "bits are not supported");
+ }
+ } else {
+ error.SetErrorString("v0 register is not available on this target");
+ }
+ }
+ }
+ } else if (type_flags & eTypeIsVector) {
+ if (byte_size > 0) {
+ const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0);
+
+ if (v0_info) {
+ if (byte_size <= v0_info->byte_size) {
+ RegisterValue reg_value;
+ error = reg_value.SetValueFromData(v0_info, data, 0, true);
+ if (error.Success()) {
+ if (!reg_ctx->WriteRegister(v0_info, reg_value))
+ error.SetErrorString("failed to write register v0");
+ }
+ }
+ }
+ }
+ }
+ } else {
+ error.SetErrorString("no registers are available");
+ }
+
+ return error;
+}
+
+bool ABIMacOSX_arm64::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) {
+ unwind_plan.Clear();
+ unwind_plan.SetRegisterKind(eRegisterKindDWARF);
+
+ uint32_t lr_reg_num = arm64_dwarf::lr;
+ uint32_t sp_reg_num = arm64_dwarf::sp;
+ uint32_t pc_reg_num = arm64_dwarf::pc;
+
+ UnwindPlan::RowSP row(new UnwindPlan::Row);
+
+ // Our previous Call Frame Address is the stack pointer
+ row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 0);
+
+ // Our previous PC is in the LR
+ row->SetRegisterLocationToRegister(pc_reg_num, lr_reg_num, true);
+
+ unwind_plan.AppendRow(row);
+
+ // All other registers are the same.
+
+ unwind_plan.SetSourceName("arm64 at-func-entry default");
+ unwind_plan.SetSourcedFromCompiler(eLazyBoolNo);
+
+ return true;
+}
+
+bool ABIMacOSX_arm64::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) {
+ unwind_plan.Clear();
+ unwind_plan.SetRegisterKind(eRegisterKindDWARF);
+
+ uint32_t fp_reg_num = arm64_dwarf::fp;
+ uint32_t pc_reg_num = arm64_dwarf::pc;
+
+ UnwindPlan::RowSP row(new UnwindPlan::Row);
+ const int32_t ptr_size = 8;
+
+ row->GetCFAValue().SetIsRegisterPlusOffset(fp_reg_num, 2 * ptr_size);
+ row->SetOffset(0);
+
+ row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true);
+ row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true);
+
+ unwind_plan.AppendRow(row);
+ unwind_plan.SetSourceName("arm64-apple-darwin default unwind plan");
+ unwind_plan.SetSourcedFromCompiler(eLazyBoolNo);
+ unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
+ unwind_plan.SetUnwindPlanForSignalTrap(eLazyBoolNo);
+ return true;
+}
+
+// AAPCS64 (Procedure Call Standard for the ARM 64-bit Architecture) says
+// registers x19 through x28 and sp are callee preserved. v8-v15 are non-
+// volatile (and specifically only the lower 8 bytes of these regs), the rest
+// of the fp/SIMD registers are volatile.
+//
+// v. https://github.com/ARM-software/abi-aa/blob/master/aapcs64/
+
+// We treat x29 as callee preserved also, else the unwinder won't try to
+// retrieve fp saves.
+
+bool ABIMacOSX_arm64::RegisterIsVolatile(const RegisterInfo *reg_info) {
+ if (reg_info) {
+ const char *name = reg_info->name;
+
+ // Sometimes we'll be called with the "alternate" name for these registers;
+ // recognize them as non-volatile.
+
+ if (name[0] == 'p' && name[1] == 'c') // pc
+ return false;
+ if (name[0] == 'f' && name[1] == 'p') // fp
+ return false;
+ if (name[0] == 's' && name[1] == 'p') // sp
+ return false;
+ if (name[0] == 'l' && name[1] == 'r') // lr
+ return false;
+
+ if (name[0] == 'x') {
+ // Volatile registers: x0-x18, x30 (lr)
+ // Return false for the non-volatile gpr regs, true for everything else
+ switch (name[1]) {
+ case '1':
+ switch (name[2]) {
+ case '9':
+ return false; // x19 is non-volatile
+ default:
+ return true;
+ }
+ break;
+ case '2':
+ switch (name[2]) {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ return false; // x20 - 28 are non-volatile
+ case '9':
+ return false; // x29 aka fp treat as non-volatile on Darwin
+ default:
+ return true;
+ }
+ case '3': // x30 aka lr treat as non-volatile
+ if (name[2] == '0')
+ return false;
+ break;
+ default:
+ return true;
+ }
+ } else if (name[0] == 'v' || name[0] == 's' || name[0] == 'd') {
+ // Volatile registers: v0-7, v16-v31
+ // Return false for non-volatile fp/SIMD regs, true for everything else
+ switch (name[1]) {
+ case '8':
+ case '9':
+ return false; // v8-v9 are non-volatile
+ case '1':
+ switch (name[2]) {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ return false; // v10-v15 are non-volatile
+ default:
+ return true;
+ }
+ default:
+ return true;
+ }
+ }
+ }
+ return true;
+}
+
+static bool LoadValueFromConsecutiveGPRRegisters(
+ ExecutionContext &exe_ctx, RegisterContext *reg_ctx,
+ 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)
+ DataExtractor &data) {
+ llvm::Optional<uint64_t> byte_size = value_type.GetByteSize(nullptr);
+ if (!byte_size || *byte_size == 0)
+ return false;
+
+ std::unique_ptr<DataBufferHeap> heap_data_up(
+ new DataBufferHeap(*byte_size, 0));
+ const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder();
+ Status error;
+
+ CompilerType base_type;
+ const uint32_t homogeneous_count =
+ value_type.IsHomogeneousAggregate(&base_type);
+ if (homogeneous_count > 0 && homogeneous_count <= 8) {
+ // Make sure we have enough registers
+ if (NSRN < 8 && (8 - NSRN) >= homogeneous_count) {
+ if (!base_type)
+ return false;
+ llvm::Optional<uint64_t> base_byte_size = base_type.GetByteSize(nullptr);
+ if (!base_byte_size)
+ return false;
+ uint32_t data_offset = 0;
+
+ for (uint32_t i = 0; i < homogeneous_count; ++i) {
+ char v_name[8];
+ ::snprintf(v_name, sizeof(v_name), "v%u", NSRN);
+ const RegisterInfo *reg_info =
+ reg_ctx->GetRegisterInfoByName(v_name, 0);
+ if (reg_info == nullptr)
+ return false;
+
+ if (*base_byte_size > reg_info->byte_size)
+ return false;
+
+ RegisterValue reg_value;
+
+ if (!reg_ctx->ReadRegister(reg_info, reg_value))
+ return false;
+
+ // Make sure we have enough room in "heap_data_up"
+ if ((data_offset + *base_byte_size) <= heap_data_up->GetByteSize()) {
+ const size_t bytes_copied = reg_value.GetAsMemoryData(
+ reg_info, heap_data_up->GetBytes() + data_offset, *base_byte_size,
+ byte_order, error);
+ if (bytes_copied != *base_byte_size)
+ return false;
+ data_offset += bytes_copied;
+ ++NSRN;
+ } else
+ return false;
+ }
+ data.SetByteOrder(byte_order);
+ data.SetAddressByteSize(exe_ctx.GetProcessRef().GetAddressByteSize());
+ data.SetData(DataBufferSP(heap_data_up.release()));
+ return true;
+ }
+ }
+
+ const size_t max_reg_byte_size = 16;
+ if (*byte_size <= max_reg_byte_size) {
+ size_t bytes_left = *byte_size;
+ uint32_t data_offset = 0;
+ while (data_offset < *byte_size) {
+ if (NGRN >= 8)
+ return false;
+
+ uint32_t reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + NGRN);
+ if (reg_num == LLDB_INVALID_REGNUM)
+ return false;
+
+ const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_num);
+ if (reg_info == nullptr)
+ return false;
+
+ RegisterValue reg_value;
+
+ if (!reg_ctx->ReadRegister(reg_info, reg_value))
+ return false;
+
+ const size_t curr_byte_size = std::min<size_t>(8, bytes_left);
+ const size_t bytes_copied = reg_value.GetAsMemoryData(
+ reg_info, heap_data_up->GetBytes() + data_offset, curr_byte_size,
+ byte_order, error);
+ if (bytes_copied == 0)
+ return false;
+ if (bytes_copied >= bytes_left)
+ break;
+ data_offset += bytes_copied;
+ bytes_left -= bytes_copied;
+ ++NGRN;
+ }
+ } else {
+ const RegisterInfo *reg_info = nullptr;
+ if (is_return_value) {
+ // We are assuming we are decoding this immediately after returning from
+ // a function call and that the address of the structure is in x8
+ reg_info = reg_ctx->GetRegisterInfoByName("x8", 0);
+ } else {
+ // We are assuming we are stopped at the first instruction in a function
+ // and that the ABI is being respected so all parameters appear where
+ // they should be (functions with no external linkage can legally violate
+ // the ABI).
+ if (NGRN >= 8)
+ return false;
+
+ uint32_t reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + NGRN);
+ if (reg_num == LLDB_INVALID_REGNUM)
+ return false;
+ reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_num);
+ if (reg_info == nullptr)
+ return false;
+ ++NGRN;
+ }
+
+ if (reg_info == nullptr)
+ return false;
+
+ const lldb::addr_t value_addr =
+ reg_ctx->ReadRegisterAsUnsigned(reg_info, LLDB_INVALID_ADDRESS);
+
+ if (value_addr == LLDB_INVALID_ADDRESS)
+ return false;
+
+ if (exe_ctx.GetProcessRef().ReadMemory(
+ value_addr, heap_data_up->GetBytes(), heap_data_up->GetByteSize(),
+ error) != heap_data_up->GetByteSize()) {
+ return false;
+ }
+ }
+
+ data.SetByteOrder(byte_order);
+ data.SetAddressByteSize(exe_ctx.GetProcessRef().GetAddressByteSize());
+ data.SetData(DataBufferSP(heap_data_up.release()));
+ return true;
+}
+
+ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
+ Thread &thread, CompilerType &return_compiler_type) const {
+ ValueObjectSP return_valobj_sp;
+ Value value;
+
+ ExecutionContext exe_ctx(thread.shared_from_this());
+ if (exe_ctx.GetTargetPtr() == nullptr || exe_ctx.GetProcessPtr() == nullptr)
+ return return_valobj_sp;
+
+ // 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;
+
+ llvm::Optional<uint64_t> byte_size =
+ return_compiler_type.GetByteSize(nullptr);
+ if (!byte_size)
+ return return_valobj_sp;
+
+ const uint32_t type_flags = return_compiler_type.GetTypeInfo(nullptr);
+ if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) {
+ value.SetValueType(Value::eValueTypeScalar);
+
+ bool success = false;
+ if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) {
+ // Extract the register context so we can read arguments from registers
+ if (*byte_size <= 8) {
+ const RegisterInfo *x0_reg_info =
+ reg_ctx->GetRegisterInfoByName("x0", 0);
+ if (x0_reg_info) {
+ uint64_t raw_value =
+ thread.GetRegisterContext()->ReadRegisterAsUnsigned(x0_reg_info,
+ 0);
+ const bool is_signed = (type_flags & eTypeIsSigned) != 0;
+ switch (*byte_size) {
+ default:
+ break;
+ case 16: // uint128_t
+ // In register x0 and x1
+ {
+ const RegisterInfo *x1_reg_info =
+ reg_ctx->GetRegisterInfoByName("x1", 0);
+
+ if (x1_reg_info) {
+ if (*byte_size <=
+ x0_reg_info->byte_size + x1_reg_info->byte_size) {
+ std::unique_ptr<DataBufferHeap> heap_data_up(
+ new DataBufferHeap(*byte_size, 0));
+ const ByteOrder byte_order =
+ exe_ctx.GetProcessRef().GetByteOrder();
+ RegisterValue x0_reg_value;
+ RegisterValue x1_reg_value;
+ if (reg_ctx->ReadRegister(x0_reg_info, x0_reg_value) &&
+ reg_ctx->ReadRegister(x1_reg_info, x1_reg_value)) {
+ Status error;
+ if (x0_reg_value.GetAsMemoryData(
+ x0_reg_info, heap_data_up->GetBytes() + 0, 8,
+ byte_order, error) &&
+ x1_reg_value.GetAsMemoryData(
+ x1_reg_info, heap_data_up->GetBytes() + 8, 8,
+ byte_order, error)) {
+ DataExtractor data(
+ DataBufferSP(heap_data_up.release()), byte_order,
+ exe_ctx.GetProcessRef().GetAddressByteSize());
+
+ return_valobj_sp = ValueObjectConstResult::Create(
+ &thread, return_compiler_type, ConstString(""), data);
+ return return_valobj_sp;
+ }
+ }
+ }
+ }
+ }
+ break;
+ case sizeof(uint64_t):
+ if (is_signed)
+ value.GetScalar() = (int64_t)(raw_value);
+ else
+ value.GetScalar() = (uint64_t)(raw_value);
+ success = true;
+ break;
+
+ case sizeof(uint32_t):
+ if (is_signed)
+ value.GetScalar() = (int32_t)(raw_value & UINT32_MAX);
+ else
+ value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX);
+ success = true;
+ break;
+
+ case sizeof(uint16_t):
+ if (is_signed)
+ value.GetScalar() = (int16_t)(raw_value & UINT16_MAX);
+ else
+ value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX);
+ success = true;
+ break;
+
+ case sizeof(uint8_t):
+ if (is_signed)
+ value.GetScalar() = (int8_t)(raw_value & UINT8_MAX);
+ else
+ value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX);
+ success = true;
+ break;
+ }
+ }
+ }
+ } else if (type_flags & eTypeIsFloat) {
+ if (type_flags & eTypeIsComplex) {
+ // Don't handle complex yet.
+ } else {
+ if (*byte_size <= sizeof(long double)) {
+ const RegisterInfo *v0_reg_info =
+ reg_ctx->GetRegisterInfoByName("v0", 0);
+ RegisterValue v0_value;
+ if (reg_ctx->ReadRegister(v0_reg_info, v0_value)) {
+ DataExtractor data;
+ if (v0_value.GetData(data)) {
+ lldb::offset_t offset = 0;
+ if (*byte_size == sizeof(float)) {
+ value.GetScalar() = data.GetFloat(&offset);
+ success = true;
+ } else if (*byte_size == sizeof(double)) {
+ value.GetScalar() = data.GetDouble(&offset);
+ success = true;
+ } else if (*byte_size == sizeof(long double)) {
+ value.GetScalar() = data.GetLongDouble(&offset);
+ success = true;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (success)
+ return_valobj_sp = ValueObjectConstResult::Create(
+ thread.GetStackFrameAtIndex(0).get(), value, ConstString(""));
+ } else if (type_flags & eTypeIsVector) {
+ if (*byte_size > 0) {
+
+ const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0);
+
+ if (v0_info) {
+ if (*byte_size <= v0_info->byte_size) {
+ std::unique_ptr<DataBufferHeap> heap_data_up(
+ new DataBufferHeap(*byte_size, 0));
+ const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder();
+ RegisterValue reg_value;
+ if (reg_ctx->ReadRegister(v0_info, reg_value)) {
+ Status error;
+ if (reg_value.GetAsMemoryData(v0_info, heap_data_up->GetBytes(),
+ heap_data_up->GetByteSize(),
+ byte_order, error)) {
+ DataExtractor data(DataBufferSP(heap_data_up.release()),
+ byte_order,
+ exe_ctx.GetProcessRef().GetAddressByteSize());
+ return_valobj_sp = ValueObjectConstResult::Create(
+ &thread, return_compiler_type, ConstString(""), data);
+ }
+ }
+ }
+ }
+ }
+ } else if (type_flags & eTypeIsStructUnion || type_flags & eTypeIsClass) {
+ DataExtractor data;
+
+ 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_compiler_type, is_return_value, NGRN, NSRN,
+ data)) {
+ return_valobj_sp = ValueObjectConstResult::Create(
+ &thread, return_compiler_type, ConstString(""), data);
+ }
+ }
+ return return_valobj_sp;
+}
+
+void ABIMacOSX_arm64::Initialize() {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(), pluginDesc,
+ CreateInstance);
+}
+
+void ABIMacOSX_arm64::Terminate() {
+ PluginManager::UnregisterPlugin(CreateInstance);
+}
+
+// PluginInterface protocol
+
+ConstString ABIMacOSX_arm64::GetPluginNameStatic() {
+ static ConstString g_plugin_name("ABIMacOSX_arm64");
+ return g_plugin_name;
+}
+
+uint32_t ABIMacOSX_arm64::GetPluginVersion() { return 1; }
diff --git a/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.h
index c7a91ba9c468..fc8ccee92e71 100644
--- a/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h
+++ b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.h
@@ -6,14 +6,14 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ABIMacOSX_arm64_h_
-#define liblldb_ABIMacOSX_arm64_h_
+#ifndef LLDB_SOURCE_PLUGINS_ABI_AARCH64_ABIMACOSX_ARM64_H
+#define LLDB_SOURCE_PLUGINS_ABI_AARCH64_ABIMACOSX_ARM64_H
-#include "lldb/Target/ABI.h"
+#include "Plugins/ABI/AArch64/ABIAArch64.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-private.h"
-class ABIMacOSX_arm64 : public lldb_private::ABI {
+class ABIMacOSX_arm64 : public ABIAArch64 {
public:
~ABIMacOSX_arm64() override = default;
@@ -42,7 +42,7 @@ public:
//
// To work around this, we relax that alignment to be just word-size
// (8-bytes).
- // Whitelisting the trap handlers for user space would be easy (_sigtramp) but
+ // Allowing 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 {
@@ -62,9 +62,6 @@ public:
return true;
}
- const lldb_private::RegisterInfo *
- GetRegisterInfoArray(uint32_t &count) override;
-
// Static Functions
static void Initialize();
@@ -93,11 +90,7 @@ protected:
lldb_private::CompilerType &ast_type) const override;
private:
- ABIMacOSX_arm64(lldb::ProcessSP process_sp,
- std::unique_ptr<llvm::MCRegisterInfo> info_up)
- : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
- // Call CreateInstance instead.
- }
+ using ABIAArch64::ABIAArch64; // Call CreateInstance instead.
};
-#endif // liblldb_ABIMacOSX_arm64_h_
+#endif // LLDB_SOURCE_PLUGINS_ABI_AARCH64_ABIMACOSX_ARM64_H
diff --git a/lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp b/lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp
new file mode 100644
index 000000000000..831c8aa0d760
--- /dev/null
+++ b/lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp
@@ -0,0 +1,800 @@
+//===-- ABISysV_arm64.cpp -------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "ABISysV_arm64.h"
+
+#include <vector>
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/Triple.h"
+
+#include "lldb/Core/Module.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Value.h"
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/Symbol/UnwindPlan.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegisterValue.h"
+#include "lldb/Utility/Scalar.h"
+#include "lldb/Utility/Status.h"
+
+#include "Utility/ARM64_DWARF_Registers.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+bool ABISysV_arm64::GetPointerReturnRegister(const char *&name) {
+ name = "x0";
+ return true;
+}
+
+size_t ABISysV_arm64::GetRedZoneSize() const { return 128; }
+
+// Static Functions
+
+ABISP
+ABISysV_arm64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
+ const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch();
+ const llvm::Triple::VendorType vendor_type = arch.GetTriple().getVendor();
+
+ if (vendor_type != llvm::Triple::Apple) {
+ if (arch_type == llvm::Triple::aarch64 ||
+ arch_type == llvm::Triple::aarch64_32) {
+ return ABISP(
+ new ABISysV_arm64(std::move(process_sp), MakeMCRegisterInfo(arch)));
+ }
+ }
+
+ return ABISP();
+}
+
+bool ABISysV_arm64::PrepareTrivialCall(Thread &thread, addr_t sp,
+ addr_t func_addr, addr_t return_addr,
+ llvm::ArrayRef<addr_t> args) const {
+ RegisterContext *reg_ctx = thread.GetRegisterContext().get();
+ if (!reg_ctx)
+ return false;
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+
+ if (log) {
+ StreamString s;
+ s.Printf("ABISysV_arm64::PrepareTrivialCall (tid = 0x%" PRIx64
+ ", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64
+ ", return_addr = 0x%" PRIx64,
+ thread.GetID(), (uint64_t)sp, (uint64_t)func_addr,
+ (uint64_t)return_addr);
+
+ for (size_t i = 0; i < args.size(); ++i)
+ s.Printf(", arg%d = 0x%" PRIx64, static_cast<int>(i + 1), args[i]);
+ s.PutCString(")");
+ log->PutString(s.GetString());
+ }
+
+ // x0 - x7 contain first 8 simple args
+ if (args.size() > 8)
+ return false;
+
+ for (size_t i = 0; i < args.size(); ++i) {
+ const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + i);
+ LLDB_LOGF(log, "About to write arg%d (0x%" PRIx64 ") into %s",
+ static_cast<int>(i + 1), args[i], reg_info->name);
+ if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i]))
+ return false;
+ }
+
+ // Set "lr" to the return address
+ if (!reg_ctx->WriteRegisterFromUnsigned(
+ reg_ctx->GetRegisterInfo(eRegisterKindGeneric,
+ LLDB_REGNUM_GENERIC_RA),
+ return_addr))
+ return false;
+
+ // Set "sp" to the requested value
+ if (!reg_ctx->WriteRegisterFromUnsigned(
+ reg_ctx->GetRegisterInfo(eRegisterKindGeneric,
+ LLDB_REGNUM_GENERIC_SP),
+ sp))
+ return false;
+
+ // Set "pc" to the address requested
+ if (!reg_ctx->WriteRegisterFromUnsigned(
+ reg_ctx->GetRegisterInfo(eRegisterKindGeneric,
+ LLDB_REGNUM_GENERIC_PC),
+ func_addr))
+ return false;
+
+ return true;
+}
+
+// TODO: We dont support fp/SIMD arguments in v0-v7
+bool ABISysV_arm64::GetArgumentValues(Thread &thread, ValueList &values) const {
+ uint32_t num_values = values.GetSize();
+
+ ExecutionContext exe_ctx(thread.shared_from_this());
+
+ // Extract the register context so we can read arguments from registers
+
+ RegisterContext *reg_ctx = thread.GetRegisterContext().get();
+
+ if (!reg_ctx)
+ return false;
+
+ addr_t sp = 0;
+
+ for (uint32_t value_idx = 0; value_idx < num_values; ++value_idx) {
+ // We currently only support extracting values with Clang QualTypes. Do we
+ // care about others?
+ Value *value = values.GetValueAtIndex(value_idx);
+
+ if (!value)
+ return false;
+
+ CompilerType value_type = value->GetCompilerType();
+ if (value_type) {
+ bool is_signed = false;
+ size_t bit_width = 0;
+ llvm::Optional<uint64_t> bit_size = value_type.GetBitSize(&thread);
+ if (!bit_size)
+ return false;
+ if (value_type.IsIntegerOrEnumerationType(is_signed)) {
+ bit_width = *bit_size;
+ } else if (value_type.IsPointerOrReferenceType()) {
+ bit_width = *bit_size;
+ } else {
+ // We only handle integer, pointer and reference types currently...
+ return false;
+ }
+
+ if (bit_width <= (exe_ctx.GetProcessRef().GetAddressByteSize() * 8)) {
+ if (value_idx < 8) {
+ // Arguments 1-8 are in x0-x7...
+ const RegisterInfo *reg_info = nullptr;
+ reg_info = reg_ctx->GetRegisterInfo(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + value_idx);
+
+ if (reg_info) {
+ RegisterValue reg_value;
+
+ if (reg_ctx->ReadRegister(reg_info, reg_value)) {
+ if (is_signed)
+ reg_value.SignExtend(bit_width);
+ if (!reg_value.GetScalarValue(value->GetScalar()))
+ return false;
+ continue;
+ }
+ }
+ return false;
+ } else {
+ // TODO: Verify for stack layout for SysV
+ if (sp == 0) {
+ // Read the stack pointer if we already haven't read it
+ sp = reg_ctx->GetSP(0);
+ if (sp == 0)
+ return false;
+ }
+
+ // Arguments 5 on up are on the stack
+ const uint32_t arg_byte_size = (bit_width + (8 - 1)) / 8;
+ Status error;
+ if (!exe_ctx.GetProcessRef().ReadScalarIntegerFromMemory(
+ sp, arg_byte_size, is_signed, value->GetScalar(), error))
+ return false;
+
+ sp += arg_byte_size;
+ // Align up to the next 8 byte boundary if needed
+ if (sp % 8) {
+ sp >>= 3;
+ sp += 1;
+ sp <<= 3;
+ }
+ }
+ }
+ }
+ }
+ return true;
+}
+
+Status ABISysV_arm64::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
+ lldb::ValueObjectSP &new_value_sp) {
+ Status error;
+ if (!new_value_sp) {
+ error.SetErrorString("Empty value object for return value.");
+ return error;
+ }
+
+ CompilerType return_value_type = new_value_sp->GetCompilerType();
+ if (!return_value_type) {
+ error.SetErrorString("Null clang type for return value.");
+ return error;
+ }
+
+ Thread *thread = frame_sp->GetThread().get();
+
+ RegisterContext *reg_ctx = thread->GetRegisterContext().get();
+
+ if (reg_ctx) {
+ DataExtractor data;
+ Status data_error;
+ const uint64_t byte_size = new_value_sp->GetData(data, data_error);
+ if (data_error.Fail()) {
+ error.SetErrorStringWithFormat(
+ "Couldn't convert return value to raw data: %s",
+ data_error.AsCString());
+ return error;
+ }
+
+ const uint32_t type_flags = return_value_type.GetTypeInfo(nullptr);
+ if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) {
+ if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) {
+ // Extract the register context so we can read arguments from registers
+ lldb::offset_t offset = 0;
+ if (byte_size <= 16) {
+ const RegisterInfo *x0_info = reg_ctx->GetRegisterInfo(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1);
+ if (byte_size <= 8) {
+ uint64_t raw_value = data.GetMaxU64(&offset, byte_size);
+
+ if (!reg_ctx->WriteRegisterFromUnsigned(x0_info, raw_value))
+ error.SetErrorString("failed to write register x0");
+ } else {
+ uint64_t raw_value = data.GetMaxU64(&offset, 8);
+
+ if (reg_ctx->WriteRegisterFromUnsigned(x0_info, raw_value)) {
+ const RegisterInfo *x1_info = reg_ctx->GetRegisterInfo(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2);
+ raw_value = data.GetMaxU64(&offset, byte_size - offset);
+
+ if (!reg_ctx->WriteRegisterFromUnsigned(x1_info, raw_value))
+ error.SetErrorString("failed to write register x1");
+ }
+ }
+ } else {
+ error.SetErrorString("We don't support returning longer than 128 bit "
+ "integer values at present.");
+ }
+ } else if (type_flags & eTypeIsFloat) {
+ if (type_flags & eTypeIsComplex) {
+ // Don't handle complex yet.
+ error.SetErrorString(
+ "returning complex float values are not supported");
+ } else {
+ const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0);
+
+ if (v0_info) {
+ if (byte_size <= 16) {
+ if (byte_size <= RegisterValue::GetMaxByteSize()) {
+ RegisterValue reg_value;
+ error = reg_value.SetValueFromData(v0_info, data, 0, true);
+ if (error.Success()) {
+ if (!reg_ctx->WriteRegister(v0_info, reg_value))
+ error.SetErrorString("failed to write register v0");
+ }
+ } else {
+ error.SetErrorStringWithFormat(
+ "returning float values with a byte size of %" PRIu64
+ " are not supported",
+ byte_size);
+ }
+ } else {
+ error.SetErrorString("returning float values longer than 128 "
+ "bits are not supported");
+ }
+ } else {
+ error.SetErrorString("v0 register is not available on this target");
+ }
+ }
+ }
+ } else if (type_flags & eTypeIsVector) {
+ if (byte_size > 0) {
+ const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0);
+
+ if (v0_info) {
+ if (byte_size <= v0_info->byte_size) {
+ RegisterValue reg_value;
+ error = reg_value.SetValueFromData(v0_info, data, 0, true);
+ if (error.Success()) {
+ if (!reg_ctx->WriteRegister(v0_info, reg_value))
+ error.SetErrorString("failed to write register v0");
+ }
+ }
+ }
+ }
+ }
+ } else {
+ error.SetErrorString("no registers are available");
+ }
+
+ return error;
+}
+
+bool ABISysV_arm64::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) {
+ unwind_plan.Clear();
+ unwind_plan.SetRegisterKind(eRegisterKindDWARF);
+
+ uint32_t lr_reg_num = arm64_dwarf::lr;
+ uint32_t sp_reg_num = arm64_dwarf::sp;
+
+ UnwindPlan::RowSP row(new UnwindPlan::Row);
+
+ // Our previous Call Frame Address is the stack pointer
+ row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 0);
+
+ unwind_plan.AppendRow(row);
+ unwind_plan.SetReturnAddressRegister(lr_reg_num);
+
+ // All other registers are the same.
+
+ unwind_plan.SetSourceName("arm64 at-func-entry default");
+ unwind_plan.SetSourcedFromCompiler(eLazyBoolNo);
+ unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
+ unwind_plan.SetUnwindPlanForSignalTrap(eLazyBoolNo);
+
+ return true;
+}
+
+bool ABISysV_arm64::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) {
+ unwind_plan.Clear();
+ unwind_plan.SetRegisterKind(eRegisterKindDWARF);
+
+ uint32_t fp_reg_num = arm64_dwarf::fp;
+ uint32_t pc_reg_num = arm64_dwarf::pc;
+
+ UnwindPlan::RowSP row(new UnwindPlan::Row);
+ const int32_t ptr_size = 8;
+
+ row->GetCFAValue().SetIsRegisterPlusOffset(fp_reg_num, 2 * ptr_size);
+ row->SetOffset(0);
+
+ row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true);
+ row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true);
+
+ unwind_plan.AppendRow(row);
+ unwind_plan.SetSourceName("arm64 default unwind plan");
+ unwind_plan.SetSourcedFromCompiler(eLazyBoolNo);
+ unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
+ unwind_plan.SetUnwindPlanForSignalTrap(eLazyBoolNo);
+
+ return true;
+}
+
+// AAPCS64 (Procedure Call Standard for the ARM 64-bit Architecture) says
+// registers x19 through x28 and sp are callee preserved. v8-v15 are non-
+// volatile (and specifically only the lower 8 bytes of these regs), the rest
+// of the fp/SIMD registers are volatile.
+
+// We treat x29 as callee preserved also, else the unwinder won't try to
+// retrieve fp saves.
+
+bool ABISysV_arm64::RegisterIsVolatile(const RegisterInfo *reg_info) {
+ if (reg_info) {
+ const char *name = reg_info->name;
+
+ // Sometimes we'll be called with the "alternate" name for these registers;
+ // recognize them as non-volatile.
+
+ if (name[0] == 'p' && name[1] == 'c') // pc
+ return false;
+ if (name[0] == 'f' && name[1] == 'p') // fp
+ return false;
+ if (name[0] == 's' && name[1] == 'p') // sp
+ return false;
+ if (name[0] == 'l' && name[1] == 'r') // lr
+ return false;
+
+ if (name[0] == 'x' || name[0] == 'r') {
+ // Volatile registers: x0-x18
+ // Although documentation says only x19-28 + sp are callee saved We ll
+ // also have to treat x30 as non-volatile. Each dwarf frame has its own
+ // value of lr. Return false for the non-volatile gpr regs, true for
+ // everything else
+ switch (name[1]) {
+ case '1':
+ switch (name[2]) {
+ case '9':
+ return false; // x19 is non-volatile
+ default:
+ return true;
+ }
+ break;
+ case '2':
+ switch (name[2]) {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ return false; // x20 - 28 are non-volatile
+ case '9':
+ return false; // x29 aka fp treat as non-volatile
+ default:
+ return true;
+ }
+ case '3': // x30 (lr) and x31 (sp) treat as non-volatile
+ if (name[2] == '0' || name[2] == '1')
+ return false;
+ break;
+ default:
+ return true; // all volatile cases not handled above fall here.
+ }
+ } else if (name[0] == 'v' || name[0] == 's' || name[0] == 'd') {
+ // Volatile registers: v0-7, v16-v31
+ // Return false for non-volatile fp/SIMD regs, true for everything else
+ switch (name[1]) {
+ case '8':
+ case '9':
+ return false; // v8-v9 are non-volatile
+ case '1':
+ switch (name[2]) {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ return false; // v10-v15 are non-volatile
+ default:
+ return true;
+ }
+ default:
+ return true;
+ }
+ }
+ }
+ return true;
+}
+
+static bool LoadValueFromConsecutiveGPRRegisters(
+ ExecutionContext &exe_ctx, RegisterContext *reg_ctx,
+ 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)
+ DataExtractor &data) {
+ llvm::Optional<uint64_t> byte_size = value_type.GetByteSize(nullptr);
+
+ if (byte_size || *byte_size == 0)
+ return false;
+
+ std::unique_ptr<DataBufferHeap> heap_data_up(
+ new DataBufferHeap(*byte_size, 0));
+ const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder();
+ Status error;
+
+ CompilerType base_type;
+ const uint32_t homogeneous_count =
+ value_type.IsHomogeneousAggregate(&base_type);
+ if (homogeneous_count > 0 && homogeneous_count <= 8) {
+ // Make sure we have enough registers
+ if (NSRN < 8 && (8 - NSRN) >= homogeneous_count) {
+ if (!base_type)
+ return false;
+ llvm::Optional<uint64_t> base_byte_size = base_type.GetByteSize(nullptr);
+ if (!base_byte_size)
+ return false;
+ uint32_t data_offset = 0;
+
+ for (uint32_t i = 0; i < homogeneous_count; ++i) {
+ char v_name[8];
+ ::snprintf(v_name, sizeof(v_name), "v%u", NSRN);
+ const RegisterInfo *reg_info =
+ reg_ctx->GetRegisterInfoByName(v_name, 0);
+ if (reg_info == nullptr)
+ return false;
+
+ if (*base_byte_size > reg_info->byte_size)
+ return false;
+
+ RegisterValue reg_value;
+
+ if (!reg_ctx->ReadRegister(reg_info, reg_value))
+ return false;
+
+ // Make sure we have enough room in "heap_data_up"
+ if ((data_offset + *base_byte_size) <= heap_data_up->GetByteSize()) {
+ const size_t bytes_copied = reg_value.GetAsMemoryData(
+ reg_info, heap_data_up->GetBytes() + data_offset, *base_byte_size,
+ byte_order, error);
+ if (bytes_copied != *base_byte_size)
+ return false;
+ data_offset += bytes_copied;
+ ++NSRN;
+ } else
+ return false;
+ }
+ data.SetByteOrder(byte_order);
+ data.SetAddressByteSize(exe_ctx.GetProcessRef().GetAddressByteSize());
+ data.SetData(DataBufferSP(heap_data_up.release()));
+ return true;
+ }
+ }
+
+ const size_t max_reg_byte_size = 16;
+ if (*byte_size <= max_reg_byte_size) {
+ size_t bytes_left = *byte_size;
+ uint32_t data_offset = 0;
+ while (data_offset < *byte_size) {
+ if (NGRN >= 8)
+ return false;
+
+ const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + NGRN);
+ if (reg_info == nullptr)
+ return false;
+
+ RegisterValue reg_value;
+
+ if (!reg_ctx->ReadRegister(reg_info, reg_value))
+ return false;
+
+ const size_t curr_byte_size = std::min<size_t>(8, bytes_left);
+ const size_t bytes_copied = reg_value.GetAsMemoryData(
+ reg_info, heap_data_up->GetBytes() + data_offset, curr_byte_size,
+ byte_order, error);
+ if (bytes_copied == 0)
+ return false;
+ if (bytes_copied >= bytes_left)
+ break;
+ data_offset += bytes_copied;
+ bytes_left -= bytes_copied;
+ ++NGRN;
+ }
+ } else {
+ const RegisterInfo *reg_info = nullptr;
+ if (is_return_value) {
+ // We are assuming we are decoding this immediately after returning from
+ // a function call and that the address of the structure is in x8
+ reg_info = reg_ctx->GetRegisterInfoByName("x8", 0);
+ } else {
+ // We are assuming we are stopped at the first instruction in a function
+ // and that the ABI is being respected so all parameters appear where
+ // they should be (functions with no external linkage can legally violate
+ // the ABI).
+ if (NGRN >= 8)
+ return false;
+
+ reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric,
+ LLDB_REGNUM_GENERIC_ARG1 + NGRN);
+ if (reg_info == nullptr)
+ return false;
+ ++NGRN;
+ }
+
+ if (reg_info == nullptr)
+ return false;
+
+ const lldb::addr_t value_addr =
+ reg_ctx->ReadRegisterAsUnsigned(reg_info, LLDB_INVALID_ADDRESS);
+
+ if (value_addr == LLDB_INVALID_ADDRESS)
+ return false;
+
+ if (exe_ctx.GetProcessRef().ReadMemory(
+ value_addr, heap_data_up->GetBytes(), heap_data_up->GetByteSize(),
+ error) != heap_data_up->GetByteSize()) {
+ return false;
+ }
+ }
+
+ data.SetByteOrder(byte_order);
+ data.SetAddressByteSize(exe_ctx.GetProcessRef().GetAddressByteSize());
+ data.SetData(DataBufferSP(heap_data_up.release()));
+ return true;
+}
+
+ValueObjectSP ABISysV_arm64::GetReturnValueObjectImpl(
+ Thread &thread, CompilerType &return_compiler_type) const {
+ ValueObjectSP return_valobj_sp;
+ Value value;
+
+ ExecutionContext exe_ctx(thread.shared_from_this());
+ if (exe_ctx.GetTargetPtr() == nullptr || exe_ctx.GetProcessPtr() == nullptr)
+ return return_valobj_sp;
+
+ // 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;
+
+ llvm::Optional<uint64_t> byte_size =
+ return_compiler_type.GetByteSize(nullptr);
+ if (!byte_size)
+ return return_valobj_sp;
+
+ const uint32_t type_flags = return_compiler_type.GetTypeInfo(nullptr);
+ if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) {
+ value.SetValueType(Value::eValueTypeScalar);
+
+ bool success = false;
+ if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) {
+ // Extract the register context so we can read arguments from registers
+ if (*byte_size <= 8) {
+ const RegisterInfo *x0_reg_info = nullptr;
+ x0_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric,
+ LLDB_REGNUM_GENERIC_ARG1);
+ if (x0_reg_info) {
+ uint64_t raw_value =
+ thread.GetRegisterContext()->ReadRegisterAsUnsigned(x0_reg_info,
+ 0);
+ const bool is_signed = (type_flags & eTypeIsSigned) != 0;
+ switch (*byte_size) {
+ default:
+ break;
+ case 16: // uint128_t
+ // In register x0 and x1
+ {
+ const RegisterInfo *x1_reg_info = nullptr;
+ x1_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric,
+ LLDB_REGNUM_GENERIC_ARG2);
+
+ if (x1_reg_info) {
+ if (*byte_size <=
+ x0_reg_info->byte_size + x1_reg_info->byte_size) {
+ std::unique_ptr<DataBufferHeap> heap_data_up(
+ new DataBufferHeap(*byte_size, 0));
+ const ByteOrder byte_order =
+ exe_ctx.GetProcessRef().GetByteOrder();
+ RegisterValue x0_reg_value;
+ RegisterValue x1_reg_value;
+ if (reg_ctx->ReadRegister(x0_reg_info, x0_reg_value) &&
+ reg_ctx->ReadRegister(x1_reg_info, x1_reg_value)) {
+ Status error;
+ if (x0_reg_value.GetAsMemoryData(
+ x0_reg_info, heap_data_up->GetBytes() + 0, 8,
+ byte_order, error) &&
+ x1_reg_value.GetAsMemoryData(
+ x1_reg_info, heap_data_up->GetBytes() + 8, 8,
+ byte_order, error)) {
+ DataExtractor data(
+ DataBufferSP(heap_data_up.release()), byte_order,
+ exe_ctx.GetProcessRef().GetAddressByteSize());
+
+ return_valobj_sp = ValueObjectConstResult::Create(
+ &thread, return_compiler_type, ConstString(""), data);
+ return return_valobj_sp;
+ }
+ }
+ }
+ }
+ }
+ break;
+ case sizeof(uint64_t):
+ if (is_signed)
+ value.GetScalar() = (int64_t)(raw_value);
+ else
+ value.GetScalar() = (uint64_t)(raw_value);
+ success = true;
+ break;
+
+ case sizeof(uint32_t):
+ if (is_signed)
+ value.GetScalar() = (int32_t)(raw_value & UINT32_MAX);
+ else
+ value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX);
+ success = true;
+ break;
+
+ case sizeof(uint16_t):
+ if (is_signed)
+ value.GetScalar() = (int16_t)(raw_value & UINT16_MAX);
+ else
+ value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX);
+ success = true;
+ break;
+
+ case sizeof(uint8_t):
+ if (is_signed)
+ value.GetScalar() = (int8_t)(raw_value & UINT8_MAX);
+ else
+ value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX);
+ success = true;
+ break;
+ }
+ }
+ }
+ } else if (type_flags & eTypeIsFloat) {
+ if (type_flags & eTypeIsComplex) {
+ // Don't handle complex yet.
+ } else {
+ if (*byte_size <= sizeof(long double)) {
+ const RegisterInfo *v0_reg_info =
+ reg_ctx->GetRegisterInfoByName("v0", 0);
+ RegisterValue v0_value;
+ if (reg_ctx->ReadRegister(v0_reg_info, v0_value)) {
+ DataExtractor data;
+ if (v0_value.GetData(data)) {
+ lldb::offset_t offset = 0;
+ if (*byte_size == sizeof(float)) {
+ value.GetScalar() = data.GetFloat(&offset);
+ success = true;
+ } else if (*byte_size == sizeof(double)) {
+ value.GetScalar() = data.GetDouble(&offset);
+ success = true;
+ } else if (*byte_size == sizeof(long double)) {
+ value.GetScalar() = data.GetLongDouble(&offset);
+ success = true;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (success)
+ return_valobj_sp = ValueObjectConstResult::Create(
+ thread.GetStackFrameAtIndex(0).get(), value, ConstString(""));
+ } else if (type_flags & eTypeIsVector && *byte_size <= 16) {
+ if (*byte_size > 0) {
+ const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0);
+
+ if (v0_info) {
+ std::unique_ptr<DataBufferHeap> heap_data_up(
+ new DataBufferHeap(*byte_size, 0));
+ const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder();
+ RegisterValue reg_value;
+ if (reg_ctx->ReadRegister(v0_info, reg_value)) {
+ Status error;
+ if (reg_value.GetAsMemoryData(v0_info, heap_data_up->GetBytes(),
+ heap_data_up->GetByteSize(), byte_order,
+ error)) {
+ DataExtractor data(DataBufferSP(heap_data_up.release()), byte_order,
+ exe_ctx.GetProcessRef().GetAddressByteSize());
+ return_valobj_sp = ValueObjectConstResult::Create(
+ &thread, return_compiler_type, ConstString(""), data);
+ }
+ }
+ }
+ }
+ } else if (type_flags & eTypeIsStructUnion || type_flags & eTypeIsClass ||
+ (type_flags & eTypeIsVector && *byte_size > 16)) {
+ DataExtractor data;
+
+ 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_compiler_type, is_return_value, NGRN, NSRN,
+ data)) {
+ return_valobj_sp = ValueObjectConstResult::Create(
+ &thread, return_compiler_type, ConstString(""), data);
+ }
+ }
+ return return_valobj_sp;
+}
+
+void ABISysV_arm64::Initialize() {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(),
+ "SysV ABI for AArch64 targets", CreateInstance);
+}
+
+void ABISysV_arm64::Terminate() {
+ PluginManager::UnregisterPlugin(CreateInstance);
+}
+
+lldb_private::ConstString ABISysV_arm64::GetPluginNameStatic() {
+ static ConstString g_name("SysV-arm64");
+ return g_name;
+}
+
+// PluginInterface protocol
+
+ConstString ABISysV_arm64::GetPluginName() { return GetPluginNameStatic(); }
+
+uint32_t ABISysV_arm64::GetPluginVersion() { return 1; }
diff --git a/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h b/lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.h
index 1bf5773e2db3..aeb74acc38b5 100644
--- a/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h
+++ b/lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.h
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ABISysV_arm64_h_
-#define liblldb_ABISysV_arm64_h_
+#ifndef LLDB_SOURCE_PLUGINS_ABI_AARCH64_ABISYSV_ARM64_H
+#define LLDB_SOURCE_PLUGINS_ABI_AARCH64_ABISYSV_ARM64_H
-#include "lldb/Target/ABI.h"
+#include "Plugins/ABI/AArch64/ABIAArch64.h"
#include "lldb/lldb-private.h"
-class ABISysV_arm64 : public lldb_private::ABI {
+class ABISysV_arm64 : public ABIAArch64 {
public:
~ABISysV_arm64() override = default;
@@ -45,7 +45,7 @@ public:
//
// To work around this, we relax that alignment to be just word-size
// (8-bytes).
- // Whitelisting the trap handlers for user space would be easy (_sigtramp) but
+ // Allowing 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 {
@@ -65,9 +65,6 @@ public:
return true;
}
- const lldb_private::RegisterInfo *
- GetRegisterInfoArray(uint32_t &count) override;
-
bool GetPointerReturnRegister(const char *&name) override;
// Static Functions
@@ -92,11 +89,7 @@ protected:
lldb_private::CompilerType &ast_type) const override;
private:
- ABISysV_arm64(lldb::ProcessSP process_sp,
- std::unique_ptr<llvm::MCRegisterInfo> info_up)
- : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
- // Call CreateInstance instead.
- }
+ using ABIAArch64::ABIAArch64; // Call CreateInstance instead.
};
-#endif // liblldb_ABISysV_arm64_h_
+#endif // LLDB_SOURCE_PLUGINS_ABI_AARCH64_ABISYSV_ARM64_H
diff --git a/lldb/source/Plugins/ABI/SysV-arc/ABISysV_arc.cpp b/lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
index 715b5e5d2b95..a212eef2ab8a 100644
--- a/lldb/source/Plugins/ABI/SysV-arc/ABISysV_arc.cpp
+++ b/lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
@@ -1,4 +1,4 @@
-//===-- ABISysV_arc.cpp ---------------------------------------*- C++ -*-===//
+//===-- ABISysV_arc.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -55,6 +55,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE_ADV(ABISysV_arc, ABIARC)
+
namespace {
namespace dwarf {
enum regnums {
@@ -144,7 +146,7 @@ size_t ABISysV_arc::GetRedZoneSize() const { return 0; }
bool ABISysV_arc::IsRegisterFileReduced(RegisterContext &reg_ctx) const {
if (!m_is_reg_file_reduced) {
const auto *const rf_build_reg = reg_ctx.GetRegisterInfoByName("rf_build");
-
+
const auto reg_value = reg_ctx.ReadRegisterAsUnsigned(rf_build_reg,
/*fail_value*/ 0);
// RF_BUILD "Number of Entries" bit.
@@ -239,7 +241,7 @@ bool ABISysV_arc::PrepareTrivialCall(Thread &thread, addr_t sp, addr_t pc,
// Make sure number of parameters matches prototype.
assert(!prototype.isFunctionVarArg());
assert(prototype.getFunctionNumParams() == args.size());
-
+
const size_t regs_for_args_count = IsRegisterFileReduced(*reg_ctx) ? 4U : 8U;
// Number of arguments passed on stack.
@@ -520,7 +522,7 @@ ValueObjectSP ABISysV_arc::GetReturnValueObjectImpl(Thread &thread,
// Integer return type.
else if (retType.isIntegerTy()) {
size_t byte_size = retType.getPrimitiveSizeInBits();
- if (1 != byte_size) // For boolian type.
+ if (1 != byte_size) // For boolean type.
byte_size /= CHAR_BIT;
auto raw_value = ReadRawValue(reg_ctx, byte_size);
diff --git a/lldb/source/Plugins/ABI/SysV-arc/ABISysV_arc.h b/lldb/source/Plugins/ABI/ARC/ABISysV_arc.h
index c4b26a54158c..3fbe64b4b45b 100644
--- a/lldb/source/Plugins/ABI/SysV-arc/ABISysV_arc.h
+++ b/lldb/source/Plugins/ABI/ARC/ABISysV_arc.h
@@ -16,7 +16,7 @@
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
-class ABISysV_arc : public lldb_private::ABI {
+class ABISysV_arc : public lldb_private::RegInfoBasedABI {
public:
~ABISysV_arc() override = default;
@@ -97,7 +97,7 @@ private:
bool IsRegisterFileReduced(lldb_private::RegisterContext &reg_ctx) const;
- using lldb_private::ABI::ABI; // Call CreateInstance instead.
+ using lldb_private::RegInfoBasedABI::RegInfoBasedABI; // Call CreateInstance instead.
using RegisterFileFlag = llvm::Optional<bool>;
mutable RegisterFileFlag m_is_reg_file_reduced;
diff --git a/lldb/source/Plugins/ABI/ARM/ABIARM.cpp b/lldb/source/Plugins/ABI/ARM/ABIARM.cpp
new file mode 100644
index 000000000000..882c14d386e3
--- /dev/null
+++ b/lldb/source/Plugins/ABI/ARM/ABIARM.cpp
@@ -0,0 +1,24 @@
+//===-- ARM.h -------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "ABIARM.h"
+#include "ABIMacOSX_arm.h"
+#include "ABISysV_arm.h"
+#include "lldb/Core/PluginManager.h"
+
+LLDB_PLUGIN_DEFINE(ABIARM)
+
+void ABIARM::Initialize() {
+ ABISysV_arm::Initialize();
+ ABIMacOSX_arm::Initialize();
+}
+
+void ABIARM::Terminate() {
+ ABISysV_arm::Terminate();
+ ABIMacOSX_arm::Terminate();
+}
diff --git a/lldb/source/Plugins/ABI/ARM/ABIARM.h b/lldb/source/Plugins/ABI/ARM/ABIARM.h
new file mode 100644
index 000000000000..7d04f1c9eb0f
--- /dev/null
+++ b/lldb/source/Plugins/ABI/ARM/ABIARM.h
@@ -0,0 +1,17 @@
+//===-- ARM.h -------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_ABI_ARM_ABIARM_H
+#define LLDB_SOURCE_PLUGINS_ABI_ARM_ABIARM_H
+
+class ABIARM {
+public:
+ static void Initialize();
+ static void Terminate();
+};
+#endif
diff --git a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp
index 9dff12bcc748..ef500cb198a8 100644
--- a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
+++ b/lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp
@@ -1,4 +1,4 @@
-//===-- ABIMacOSX_arm.cpp ---------------------------------------*- C++ -*-===//
+//===-- ABIMacOSX_arm.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h b/lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.h
index e512651f86e5..e0fa349eea73 100644
--- a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h
+++ b/lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.h
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ABIMacOSX_arm_h_
-#define liblldb_ABIMacOSX_arm_h_
+#ifndef LLDB_SOURCE_PLUGINS_ABI_ARM_ABIMACOSX_ARM_H
+#define LLDB_SOURCE_PLUGINS_ABI_ARM_ABIMACOSX_ARM_H
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
-class ABIMacOSX_arm : public lldb_private::ABI {
+class ABIMacOSX_arm : public lldb_private::RegInfoBasedABI {
public:
~ABIMacOSX_arm() override = default;
@@ -85,11 +85,7 @@ protected:
lldb_private::CompilerType &ast_type) const override;
private:
- ABIMacOSX_arm(lldb::ProcessSP process_sp,
- std::unique_ptr<llvm::MCRegisterInfo> info_up)
- : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
- // Call CreateInstance instead.
- }
+ using lldb_private::RegInfoBasedABI::RegInfoBasedABI; // Call CreateInstance instead.
};
-#endif // liblldb_ABIMacOSX_arm_h_
+#endif // LLDB_SOURCE_PLUGINS_ABI_ARM_ABIMACOSX_ARM_H
diff --git a/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp b/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
index b6e8f8806829..1a93bac564f7 100644
--- a/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
+++ b/lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
@@ -1,4 +1,4 @@
-//===-- ABISysV_arm.cpp -----------------------------------------*- C++ -*-===//
+//===-- ABISysV_arm.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -34,6 +34,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(ABISysV_arm)
+
static RegisterInfo g_register_infos[] = {
// NAME ALT SZ OFF ENCODING FORMAT EH_FRAME
// DWARF GENERIC PROCESS PLUGIN
diff --git a/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.h b/lldb/source/Plugins/ABI/ARM/ABISysV_arm.h
index 60fb14be5f7b..f28f75ce4fe5 100644
--- a/lldb/source/Plugins/ABI/SysV-arm/ABISysV_arm.h
+++ b/lldb/source/Plugins/ABI/ARM/ABISysV_arm.h
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ABISysV_arm_h_
-#define liblldb_ABISysV_arm_h_
+#ifndef LLDB_SOURCE_PLUGINS_ABI_ARM_ABISYSV_ARM_H
+#define LLDB_SOURCE_PLUGINS_ABI_ARM_ABISYSV_ARM_H
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
-class ABISysV_arm : public lldb_private::ABI {
+class ABISysV_arm : public lldb_private::RegInfoBasedABI {
public:
~ABISysV_arm() override = default;
@@ -85,11 +85,7 @@ protected:
lldb_private::CompilerType &ast_type) const override;
private:
- ABISysV_arm(lldb::ProcessSP process_sp,
- std::unique_ptr<llvm::MCRegisterInfo> info_up)
- : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
- // Call CreateInstance instead.
- }
+ using lldb_private::RegInfoBasedABI::RegInfoBasedABI; // Call CreateInstance instead.
};
-#endif // liblldb_ABISysV_arm_h_
+#endif // LLDB_SOURCE_PLUGINS_ABI_ARM_ABISYSV_ARM_H
diff --git a/lldb/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp b/lldb/source/Plugins/ABI/Hexagon/ABISysV_hexagon.cpp
index 34d9258ccb92..32313d4cd815 100644
--- a/lldb/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
+++ b/lldb/source/Plugins/ABI/Hexagon/ABISysV_hexagon.cpp
@@ -1,4 +1,4 @@
-//===-- ABISysV_hexagon.cpp -------------------------------------*- C++ -*-===//
+//===-- ABISysV_hexagon.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -32,6 +32,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE_ADV(ABISysV_hexagon, ABIHexagon)
+
static RegisterInfo g_register_infos[] = {
// hexagon-core.xml
{"r00",
diff --git a/lldb/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h b/lldb/source/Plugins/ABI/Hexagon/ABISysV_hexagon.h
index bef64a22d95f..d6dab0c2e378 100644
--- a/lldb/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h
+++ b/lldb/source/Plugins/ABI/Hexagon/ABISysV_hexagon.h
@@ -7,13 +7,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ABISysV_hexagon_h_
-#define liblldb_ABISysV_hexagon_h_
+#ifndef LLDB_SOURCE_PLUGINS_ABI_HEXAGON_ABISYSV_HEXAGON_H
+#define LLDB_SOURCE_PLUGINS_ABI_HEXAGON_ABISYSV_HEXAGON_H
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
-class ABISysV_hexagon : public lldb_private::ABI {
+class ABISysV_hexagon : public lldb_private::RegInfoBasedABI {
public:
~ABISysV_hexagon() override = default;
@@ -97,11 +97,7 @@ protected:
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
private:
- ABISysV_hexagon(lldb::ProcessSP process_sp,
- std::unique_ptr<llvm::MCRegisterInfo> info_up)
- : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
- // Call CreateInstance instead.
- }
+ using lldb_private::RegInfoBasedABI::RegInfoBasedABI; // Call CreateInstance instead.
};
-#endif // liblldb_ABISysV_hexagon_h_
+#endif // LLDB_SOURCE_PLUGINS_ABI_HEXAGON_ABISYSV_HEXAGON_H
diff --git a/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp b/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
deleted file mode 100644
index ec7588dfb50c..000000000000
--- a/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
+++ /dev/null
@@ -1,2451 +0,0 @@
-//===-- ABIMacOSX_arm64.cpp -------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "ABIMacOSX_arm64.h"
-
-#include <vector>
-
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/Triple.h"
-
-#include "lldb/Core/Module.h"
-#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/Value.h"
-#include "lldb/Core/ValueObjectConstResult.h"
-#include "lldb/Symbol/UnwindPlan.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/RegisterContext.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
-#include "lldb/Utility/ConstString.h"
-#include "lldb/Utility/Log.h"
-#include "lldb/Utility/RegisterValue.h"
-#include "lldb/Utility/Scalar.h"
-#include "lldb/Utility/Status.h"
-
-#include "Utility/ARM64_DWARF_Registers.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-static const char *pluginDesc = "Mac OS X ABI for arm64 targets";
-
-static RegisterInfo g_register_infos[] = {
- // NAME ALT SZ OFF ENCODING FORMAT
- // EH_FRAME DWARF GENERIC
- // PROCESS PLUGIN LLDB NATIVE
- // ========== ======= == === ============= ===================
- // =================== ====================== ===========================
- // ======================= ======================
- {"x0",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x0, LLDB_REGNUM_GENERIC_ARG1,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x1",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x1, LLDB_REGNUM_GENERIC_ARG2,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x2",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x2, LLDB_REGNUM_GENERIC_ARG3,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x3",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x3, LLDB_REGNUM_GENERIC_ARG4,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x4",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x4, LLDB_REGNUM_GENERIC_ARG5,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x5",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x5, LLDB_REGNUM_GENERIC_ARG6,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x6",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x6, LLDB_REGNUM_GENERIC_ARG7,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x7",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x7, LLDB_REGNUM_GENERIC_ARG8,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x8",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x8, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x9",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x9, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x10",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x10, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x11",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x11, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x12",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x12, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x13",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x13, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x14",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x14, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x15",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x15, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x16",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x16, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x17",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x17, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x18",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x18, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x19",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x19, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x20",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x20, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x21",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x21, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x22",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x22, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x23",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x23, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x24",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x24, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x25",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x25, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x26",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x26, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x27",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x27, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x28",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x28, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fp",
- "x29",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x29, LLDB_REGNUM_GENERIC_FP,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"lr",
- "x30",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x30, LLDB_REGNUM_GENERIC_RA,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"sp",
- "x31",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x31, LLDB_REGNUM_GENERIC_SP,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"pc",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::pc, LLDB_REGNUM_GENERIC_PC,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"cpsr",
- "psr",
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::cpsr, LLDB_REGNUM_GENERIC_FLAGS,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-
- {"v0",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v0, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v1",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v1, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v2",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v2, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v3",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v3, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v4",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v4, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v5",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v5, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v6",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v6, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v7",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v7, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v8",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v8, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v9",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v9, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v10",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v10, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v11",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v11, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v12",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v12, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v13",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v13, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v14",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v14, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v15",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v15, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v16",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v16, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v17",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v17, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v18",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v18, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v19",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v19, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v20",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v20, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v21",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v21, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v22",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v22, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v23",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v23, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v24",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v24, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v25",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v25, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v26",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v26, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v27",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v27, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v28",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v28, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v29",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v29, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v30",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v30, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v31",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v31, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-
- {"fpsr",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fpcr",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-
- {"s0",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s1",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s2",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s3",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s4",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s5",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s6",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s7",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s8",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s9",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s10",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s11",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s12",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s13",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s14",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s15",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s16",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s17",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s18",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s19",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s20",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s21",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s22",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s23",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s24",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s25",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s26",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s27",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s28",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s29",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s30",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s31",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-
- {"d0",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d1",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d2",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d3",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d4",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d5",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d6",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d7",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d8",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d9",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d10",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d11",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d12",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d13",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d14",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d15",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d16",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d17",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d18",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d19",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d20",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d21",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d22",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d23",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d24",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d25",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d26",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d27",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d28",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d29",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d30",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d31",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0}};
-
-static const uint32_t k_num_register_infos =
- llvm::array_lengthof(g_register_infos);
-static bool g_register_info_names_constified = false;
-
-const lldb_private::RegisterInfo *
-ABIMacOSX_arm64::GetRegisterInfoArray(uint32_t &count) {
- // Make the C-string names and alt_names for the register infos into const
- // C-string values by having the ConstString unique the names in the global
- // constant C-string pool.
- if (!g_register_info_names_constified) {
- g_register_info_names_constified = true;
- for (uint32_t i = 0; i < k_num_register_infos; ++i) {
- if (g_register_infos[i].name)
- g_register_infos[i].name =
- ConstString(g_register_infos[i].name).GetCString();
- if (g_register_infos[i].alt_name)
- g_register_infos[i].alt_name =
- ConstString(g_register_infos[i].alt_name).GetCString();
- }
- }
- count = k_num_register_infos;
- return g_register_infos;
-}
-
-size_t ABIMacOSX_arm64::GetRedZoneSize() const { return 128; }
-
-// Static Functions
-
-ABISP
-ABIMacOSX_arm64::CreateInstance(ProcessSP process_sp, const ArchSpec &arch) {
- const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch();
- const llvm::Triple::VendorType vendor_type = arch.GetTriple().getVendor();
-
- if (vendor_type == llvm::Triple::Apple) {
- if (arch_type == llvm::Triple::aarch64 ||
- arch_type == llvm::Triple::aarch64_32) {
- return ABISP(
- new ABIMacOSX_arm64(std::move(process_sp), MakeMCRegisterInfo(arch)));
- }
- }
-
- return ABISP();
-}
-
-bool ABIMacOSX_arm64::PrepareTrivialCall(
- Thread &thread, lldb::addr_t sp, lldb::addr_t func_addr,
- lldb::addr_t return_addr, llvm::ArrayRef<lldb::addr_t> args) const {
- RegisterContext *reg_ctx = thread.GetRegisterContext().get();
- if (!reg_ctx)
- return false;
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
-
- if (log) {
- StreamString s;
- s.Printf("ABISysV_x86_64::PrepareTrivialCall (tid = 0x%" PRIx64
- ", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64
- ", return_addr = 0x%" PRIx64,
- thread.GetID(), (uint64_t)sp, (uint64_t)func_addr,
- (uint64_t)return_addr);
-
- for (size_t i = 0; i < args.size(); ++i)
- s.Printf(", arg%d = 0x%" PRIx64, static_cast<int>(i + 1), args[i]);
- s.PutCString(")");
- log->PutString(s.GetString());
- }
-
- const uint32_t pc_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber(
- eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
- const uint32_t sp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber(
- eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP);
- const uint32_t ra_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber(
- eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA);
-
- // x0 - x7 contain first 8 simple args
- if (args.size() > 8) // TODO handle more than 6 arguments
- return false;
-
- for (size_t i = 0; i < args.size(); ++i) {
- const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(
- eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + i);
- LLDB_LOGF(log, "About to write arg%d (0x%" PRIx64 ") into %s",
- static_cast<int>(i + 1), args[i], reg_info->name);
- if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i]))
- return false;
- }
-
- // Set "lr" to the return address
- if (!reg_ctx->WriteRegisterFromUnsigned(
- reg_ctx->GetRegisterInfoAtIndex(ra_reg_num), return_addr))
- return false;
-
- // Set "sp" to the requested value
- if (!reg_ctx->WriteRegisterFromUnsigned(
- reg_ctx->GetRegisterInfoAtIndex(sp_reg_num), sp))
- return false;
-
- // Set "pc" to the address requested
- if (!reg_ctx->WriteRegisterFromUnsigned(
- reg_ctx->GetRegisterInfoAtIndex(pc_reg_num), func_addr))
- return false;
-
- return true;
-}
-
-bool ABIMacOSX_arm64::GetArgumentValues(Thread &thread,
- ValueList &values) const {
- uint32_t num_values = values.GetSize();
-
- ExecutionContext exe_ctx(thread.shared_from_this());
-
- // Extract the register context so we can read arguments from registers
-
- RegisterContext *reg_ctx = thread.GetRegisterContext().get();
-
- if (!reg_ctx)
- return false;
-
- addr_t sp = 0;
-
- for (uint32_t value_idx = 0; value_idx < num_values; ++value_idx) {
- // We currently only support extracting values with Clang QualTypes. Do we
- // care about others?
- Value *value = values.GetValueAtIndex(value_idx);
-
- if (!value)
- return false;
-
- CompilerType value_type = value->GetCompilerType();
- llvm::Optional<uint64_t> bit_size = value_type.GetBitSize(&thread);
- if (!bit_size)
- return false;
-
- bool is_signed = false;
- size_t bit_width = 0;
- if (value_type.IsIntegerOrEnumerationType(is_signed)) {
- bit_width = *bit_size;
- } else if (value_type.IsPointerOrReferenceType()) {
- bit_width = *bit_size;
- } else {
- // We only handle integer, pointer and reference types currently...
- return false;
- }
-
- if (bit_width <= (exe_ctx.GetProcessRef().GetAddressByteSize() * 8)) {
- if (value_idx < 8) {
- // Arguments 1-6 are in x0-x5...
- const RegisterInfo *reg_info = nullptr;
- // Search by generic ID first, then fall back to by name
- uint32_t arg_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber(
- eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + value_idx);
- if (arg_reg_num != LLDB_INVALID_REGNUM) {
- reg_info = reg_ctx->GetRegisterInfoAtIndex(arg_reg_num);
- } else {
- switch (value_idx) {
- case 0:
- reg_info = reg_ctx->GetRegisterInfoByName("x0");
- break;
- case 1:
- reg_info = reg_ctx->GetRegisterInfoByName("x1");
- break;
- case 2:
- reg_info = reg_ctx->GetRegisterInfoByName("x2");
- break;
- case 3:
- reg_info = reg_ctx->GetRegisterInfoByName("x3");
- break;
- case 4:
- reg_info = reg_ctx->GetRegisterInfoByName("x4");
- break;
- case 5:
- reg_info = reg_ctx->GetRegisterInfoByName("x5");
- break;
- case 6:
- reg_info = reg_ctx->GetRegisterInfoByName("x6");
- break;
- case 7:
- reg_info = reg_ctx->GetRegisterInfoByName("x7");
- break;
- }
- }
-
- if (reg_info) {
- RegisterValue reg_value;
-
- if (reg_ctx->ReadRegister(reg_info, reg_value)) {
- if (is_signed)
- reg_value.SignExtend(bit_width);
- if (!reg_value.GetScalarValue(value->GetScalar()))
- return false;
- continue;
- }
- }
- return false;
- } else {
- if (sp == 0) {
- // Read the stack pointer if we already haven't read it
- sp = reg_ctx->GetSP(0);
- if (sp == 0)
- return false;
- }
-
- // Arguments 5 on up are on the stack
- const uint32_t arg_byte_size = (bit_width + (8 - 1)) / 8;
- Status error;
- if (!exe_ctx.GetProcessRef().ReadScalarIntegerFromMemory(
- sp, arg_byte_size, is_signed, value->GetScalar(), error))
- return false;
-
- sp += arg_byte_size;
- // Align up to the next 8 byte boundary if needed
- if (sp % 8) {
- sp >>= 3;
- sp += 1;
- sp <<= 3;
- }
- }
- }
- }
- return true;
-}
-
-Status
-ABIMacOSX_arm64::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
- lldb::ValueObjectSP &new_value_sp) {
- Status error;
- if (!new_value_sp) {
- error.SetErrorString("Empty value object for return value.");
- return error;
- }
-
- CompilerType return_value_type = new_value_sp->GetCompilerType();
- if (!return_value_type) {
- error.SetErrorString("Null clang type for return value.");
- return error;
- }
-
- Thread *thread = frame_sp->GetThread().get();
-
- RegisterContext *reg_ctx = thread->GetRegisterContext().get();
-
- if (reg_ctx) {
- DataExtractor data;
- Status data_error;
- const uint64_t byte_size = new_value_sp->GetData(data, data_error);
- if (data_error.Fail()) {
- error.SetErrorStringWithFormat(
- "Couldn't convert return value to raw data: %s",
- data_error.AsCString());
- return error;
- }
-
- const uint32_t type_flags = return_value_type.GetTypeInfo(nullptr);
- if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) {
- if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) {
- // Extract the register context so we can read arguments from registers
- lldb::offset_t offset = 0;
- if (byte_size <= 16) {
- const RegisterInfo *x0_info = reg_ctx->GetRegisterInfoByName("x0", 0);
- if (byte_size <= 8) {
- uint64_t raw_value = data.GetMaxU64(&offset, byte_size);
-
- if (!reg_ctx->WriteRegisterFromUnsigned(x0_info, raw_value))
- error.SetErrorString("failed to write register x0");
- } else {
- uint64_t raw_value = data.GetMaxU64(&offset, 8);
-
- if (reg_ctx->WriteRegisterFromUnsigned(x0_info, raw_value)) {
- const RegisterInfo *x1_info =
- reg_ctx->GetRegisterInfoByName("x1", 0);
- raw_value = data.GetMaxU64(&offset, byte_size - offset);
-
- if (!reg_ctx->WriteRegisterFromUnsigned(x1_info, raw_value))
- error.SetErrorString("failed to write register x1");
- }
- }
- } else {
- error.SetErrorString("We don't support returning longer than 128 bit "
- "integer values at present.");
- }
- } else if (type_flags & eTypeIsFloat) {
- if (type_flags & eTypeIsComplex) {
- // Don't handle complex yet.
- error.SetErrorString(
- "returning complex float values are not supported");
- } else {
- const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0);
-
- if (v0_info) {
- if (byte_size <= 16) {
- if (byte_size <= RegisterValue::GetMaxByteSize()) {
- RegisterValue reg_value;
- error = reg_value.SetValueFromData(v0_info, data, 0, true);
- if (error.Success()) {
- if (!reg_ctx->WriteRegister(v0_info, reg_value))
- error.SetErrorString("failed to write register v0");
- }
- } else {
- error.SetErrorStringWithFormat(
- "returning float values with a byte size of %" PRIu64
- " are not supported",
- byte_size);
- }
- } else {
- error.SetErrorString("returning float values longer than 128 "
- "bits are not supported");
- }
- } else {
- error.SetErrorString("v0 register is not available on this target");
- }
- }
- }
- } else if (type_flags & eTypeIsVector) {
- if (byte_size > 0) {
- const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0);
-
- if (v0_info) {
- if (byte_size <= v0_info->byte_size) {
- RegisterValue reg_value;
- error = reg_value.SetValueFromData(v0_info, data, 0, true);
- if (error.Success()) {
- if (!reg_ctx->WriteRegister(v0_info, reg_value))
- error.SetErrorString("failed to write register v0");
- }
- }
- }
- }
- }
- } else {
- error.SetErrorString("no registers are available");
- }
-
- return error;
-}
-
-bool ABIMacOSX_arm64::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) {
- unwind_plan.Clear();
- unwind_plan.SetRegisterKind(eRegisterKindDWARF);
-
- uint32_t lr_reg_num = arm64_dwarf::lr;
- uint32_t sp_reg_num = arm64_dwarf::sp;
- uint32_t pc_reg_num = arm64_dwarf::pc;
-
- UnwindPlan::RowSP row(new UnwindPlan::Row);
-
- // Our previous Call Frame Address is the stack pointer
- row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 0);
-
- // Our previous PC is in the LR
- row->SetRegisterLocationToRegister(pc_reg_num, lr_reg_num, true);
-
- unwind_plan.AppendRow(row);
-
- // All other registers are the same.
-
- unwind_plan.SetSourceName("arm64 at-func-entry default");
- unwind_plan.SetSourcedFromCompiler(eLazyBoolNo);
-
- return true;
-}
-
-bool ABIMacOSX_arm64::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) {
- unwind_plan.Clear();
- unwind_plan.SetRegisterKind(eRegisterKindDWARF);
-
- uint32_t fp_reg_num = arm64_dwarf::fp;
- uint32_t pc_reg_num = arm64_dwarf::pc;
-
- UnwindPlan::RowSP row(new UnwindPlan::Row);
- const int32_t ptr_size = 8;
-
- row->GetCFAValue().SetIsRegisterPlusOffset(fp_reg_num, 2 * ptr_size);
- row->SetOffset(0);
-
- row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true);
- row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true);
-
- unwind_plan.AppendRow(row);
- unwind_plan.SetSourceName("arm64-apple-darwin default unwind plan");
- unwind_plan.SetSourcedFromCompiler(eLazyBoolNo);
- unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
- unwind_plan.SetUnwindPlanForSignalTrap(eLazyBoolNo);
- return true;
-}
-
-// AAPCS64 (Procedure Call Standard for the ARM 64-bit Architecture) says
-// registers x19 through x28 and sp are callee preserved. v8-v15 are non-
-// volatile (and specifically only the lower 8 bytes of these regs), the rest
-// of the fp/SIMD registers are volatile.
-//
-// v. https://github.com/ARM-software/software-standards/blob/master/abi/aapcs64/
-
-// We treat x29 as callee preserved also, else the unwinder won't try to
-// retrieve fp saves.
-
-bool ABIMacOSX_arm64::RegisterIsVolatile(const RegisterInfo *reg_info) {
- if (reg_info) {
- const char *name = reg_info->name;
-
- // Sometimes we'll be called with the "alternate" name for these registers;
- // recognize them as non-volatile.
-
- if (name[0] == 'p' && name[1] == 'c') // pc
- return false;
- if (name[0] == 'f' && name[1] == 'p') // fp
- return false;
- if (name[0] == 's' && name[1] == 'p') // sp
- return false;
- if (name[0] == 'l' && name[1] == 'r') // lr
- return false;
-
- if (name[0] == 'x') {
- // Volatile registers: x0-x18, x30 (lr)
- // Return false for the non-volatile gpr regs, true for everything else
- switch (name[1]) {
- case '1':
- switch (name[2]) {
- case '9':
- return false; // x19 is non-volatile
- default:
- return true;
- }
- break;
- case '2':
- switch (name[2]) {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- return false; // x20 - 28 are non-volatile
- case '9':
- return false; // x29 aka fp treat as non-volatile on Darwin
- default:
- return true;
- }
- case '3': // x30 aka lr treat as non-volatile
- if (name[2] == '0')
- return false;
- break;
- default:
- return true;
- }
- } else if (name[0] == 'v' || name[0] == 's' || name[0] == 'd') {
- // Volatile registers: v0-7, v16-v31
- // Return false for non-volatile fp/SIMD regs, true for everything else
- switch (name[1]) {
- case '8':
- case '9':
- return false; // v8-v9 are non-volatile
- case '1':
- switch (name[2]) {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- return false; // v10-v15 are non-volatile
- default:
- return true;
- }
- default:
- return true;
- }
- }
- }
- return true;
-}
-
-static bool LoadValueFromConsecutiveGPRRegisters(
- ExecutionContext &exe_ctx, RegisterContext *reg_ctx,
- 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)
- DataExtractor &data) {
- llvm::Optional<uint64_t> byte_size = value_type.GetByteSize(nullptr);
- if (!byte_size || *byte_size == 0)
- return false;
-
- std::unique_ptr<DataBufferHeap> heap_data_up(
- new DataBufferHeap(*byte_size, 0));
- const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder();
- Status error;
-
- CompilerType base_type;
- const uint32_t homogeneous_count =
- value_type.IsHomogeneousAggregate(&base_type);
- if (homogeneous_count > 0 && homogeneous_count <= 8) {
- // Make sure we have enough registers
- if (NSRN < 8 && (8 - NSRN) >= homogeneous_count) {
- if (!base_type)
- return false;
- llvm::Optional<uint64_t> base_byte_size = base_type.GetByteSize(nullptr);
- if (!base_byte_size)
- return false;
- uint32_t data_offset = 0;
-
- for (uint32_t i = 0; i < homogeneous_count; ++i) {
- char v_name[8];
- ::snprintf(v_name, sizeof(v_name), "v%u", NSRN);
- const RegisterInfo *reg_info =
- reg_ctx->GetRegisterInfoByName(v_name, 0);
- if (reg_info == nullptr)
- return false;
-
- if (*base_byte_size > reg_info->byte_size)
- return false;
-
- RegisterValue reg_value;
-
- if (!reg_ctx->ReadRegister(reg_info, reg_value))
- return false;
-
- // Make sure we have enough room in "heap_data_up"
- if ((data_offset + *base_byte_size) <= heap_data_up->GetByteSize()) {
- const size_t bytes_copied = reg_value.GetAsMemoryData(
- reg_info, heap_data_up->GetBytes() + data_offset, *base_byte_size,
- byte_order, error);
- if (bytes_copied != *base_byte_size)
- return false;
- data_offset += bytes_copied;
- ++NSRN;
- } else
- return false;
- }
- data.SetByteOrder(byte_order);
- data.SetAddressByteSize(exe_ctx.GetProcessRef().GetAddressByteSize());
- data.SetData(DataBufferSP(heap_data_up.release()));
- return true;
- }
- }
-
- const size_t max_reg_byte_size = 16;
- if (*byte_size <= max_reg_byte_size) {
- size_t bytes_left = *byte_size;
- uint32_t data_offset = 0;
- while (data_offset < *byte_size) {
- if (NGRN >= 8)
- return false;
-
- uint32_t reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber(
- eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + NGRN);
- if (reg_num == LLDB_INVALID_REGNUM)
- return false;
-
- const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_num);
- if (reg_info == nullptr)
- return false;
-
- RegisterValue reg_value;
-
- if (!reg_ctx->ReadRegister(reg_info, reg_value))
- return false;
-
- const size_t curr_byte_size = std::min<size_t>(8, bytes_left);
- const size_t bytes_copied = reg_value.GetAsMemoryData(
- reg_info, heap_data_up->GetBytes() + data_offset, curr_byte_size,
- byte_order, error);
- if (bytes_copied == 0)
- return false;
- if (bytes_copied >= bytes_left)
- break;
- data_offset += bytes_copied;
- bytes_left -= bytes_copied;
- ++NGRN;
- }
- } else {
- const RegisterInfo *reg_info = nullptr;
- if (is_return_value) {
- // We are assuming we are decoding this immediately after returning from
- // a function call and that the address of the structure is in x8
- reg_info = reg_ctx->GetRegisterInfoByName("x8", 0);
- } else {
- // We are assuming we are stopped at the first instruction in a function
- // and that the ABI is being respected so all parameters appear where
- // they should be (functions with no external linkage can legally violate
- // the ABI).
- if (NGRN >= 8)
- return false;
-
- uint32_t reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber(
- eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + NGRN);
- if (reg_num == LLDB_INVALID_REGNUM)
- return false;
- reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_num);
- if (reg_info == nullptr)
- return false;
- ++NGRN;
- }
-
- if (reg_info == nullptr)
- return false;
-
- const lldb::addr_t value_addr =
- reg_ctx->ReadRegisterAsUnsigned(reg_info, LLDB_INVALID_ADDRESS);
-
- if (value_addr == LLDB_INVALID_ADDRESS)
- return false;
-
- if (exe_ctx.GetProcessRef().ReadMemory(
- value_addr, heap_data_up->GetBytes(), heap_data_up->GetByteSize(),
- error) != heap_data_up->GetByteSize()) {
- return false;
- }
- }
-
- data.SetByteOrder(byte_order);
- data.SetAddressByteSize(exe_ctx.GetProcessRef().GetAddressByteSize());
- data.SetData(DataBufferSP(heap_data_up.release()));
- return true;
-}
-
-ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
- Thread &thread, CompilerType &return_compiler_type) const {
- ValueObjectSP return_valobj_sp;
- Value value;
-
- ExecutionContext exe_ctx(thread.shared_from_this());
- if (exe_ctx.GetTargetPtr() == nullptr || exe_ctx.GetProcessPtr() == nullptr)
- return return_valobj_sp;
-
- // 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;
-
- llvm::Optional<uint64_t> byte_size =
- return_compiler_type.GetByteSize(nullptr);
- if (!byte_size)
- return return_valobj_sp;
-
- const uint32_t type_flags = return_compiler_type.GetTypeInfo(nullptr);
- if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) {
- value.SetValueType(Value::eValueTypeScalar);
-
- bool success = false;
- if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) {
- // Extract the register context so we can read arguments from registers
- if (*byte_size <= 8) {
- const RegisterInfo *x0_reg_info =
- reg_ctx->GetRegisterInfoByName("x0", 0);
- if (x0_reg_info) {
- uint64_t raw_value =
- thread.GetRegisterContext()->ReadRegisterAsUnsigned(x0_reg_info,
- 0);
- const bool is_signed = (type_flags & eTypeIsSigned) != 0;
- switch (*byte_size) {
- default:
- break;
- case 16: // uint128_t
- // In register x0 and x1
- {
- const RegisterInfo *x1_reg_info =
- reg_ctx->GetRegisterInfoByName("x1", 0);
-
- if (x1_reg_info) {
- if (*byte_size <=
- x0_reg_info->byte_size + x1_reg_info->byte_size) {
- std::unique_ptr<DataBufferHeap> heap_data_up(
- new DataBufferHeap(*byte_size, 0));
- const ByteOrder byte_order =
- exe_ctx.GetProcessRef().GetByteOrder();
- RegisterValue x0_reg_value;
- RegisterValue x1_reg_value;
- if (reg_ctx->ReadRegister(x0_reg_info, x0_reg_value) &&
- reg_ctx->ReadRegister(x1_reg_info, x1_reg_value)) {
- Status error;
- if (x0_reg_value.GetAsMemoryData(
- x0_reg_info, heap_data_up->GetBytes() + 0, 8,
- byte_order, error) &&
- x1_reg_value.GetAsMemoryData(
- x1_reg_info, heap_data_up->GetBytes() + 8, 8,
- byte_order, error)) {
- DataExtractor data(
- DataBufferSP(heap_data_up.release()), byte_order,
- exe_ctx.GetProcessRef().GetAddressByteSize());
-
- return_valobj_sp = ValueObjectConstResult::Create(
- &thread, return_compiler_type, ConstString(""), data);
- return return_valobj_sp;
- }
- }
- }
- }
- }
- break;
- case sizeof(uint64_t):
- if (is_signed)
- value.GetScalar() = (int64_t)(raw_value);
- else
- value.GetScalar() = (uint64_t)(raw_value);
- success = true;
- break;
-
- case sizeof(uint32_t):
- if (is_signed)
- value.GetScalar() = (int32_t)(raw_value & UINT32_MAX);
- else
- value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX);
- success = true;
- break;
-
- case sizeof(uint16_t):
- if (is_signed)
- value.GetScalar() = (int16_t)(raw_value & UINT16_MAX);
- else
- value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX);
- success = true;
- break;
-
- case sizeof(uint8_t):
- if (is_signed)
- value.GetScalar() = (int8_t)(raw_value & UINT8_MAX);
- else
- value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX);
- success = true;
- break;
- }
- }
- }
- } else if (type_flags & eTypeIsFloat) {
- if (type_flags & eTypeIsComplex) {
- // Don't handle complex yet.
- } else {
- if (*byte_size <= sizeof(long double)) {
- const RegisterInfo *v0_reg_info =
- reg_ctx->GetRegisterInfoByName("v0", 0);
- RegisterValue v0_value;
- if (reg_ctx->ReadRegister(v0_reg_info, v0_value)) {
- DataExtractor data;
- if (v0_value.GetData(data)) {
- lldb::offset_t offset = 0;
- if (*byte_size == sizeof(float)) {
- value.GetScalar() = data.GetFloat(&offset);
- success = true;
- } else if (*byte_size == sizeof(double)) {
- value.GetScalar() = data.GetDouble(&offset);
- success = true;
- } else if (*byte_size == sizeof(long double)) {
- value.GetScalar() = data.GetLongDouble(&offset);
- success = true;
- }
- }
- }
- }
- }
- }
-
- if (success)
- return_valobj_sp = ValueObjectConstResult::Create(
- thread.GetStackFrameAtIndex(0).get(), value, ConstString(""));
- } else if (type_flags & eTypeIsVector) {
- if (*byte_size > 0) {
-
- const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0);
-
- if (v0_info) {
- if (*byte_size <= v0_info->byte_size) {
- std::unique_ptr<DataBufferHeap> heap_data_up(
- new DataBufferHeap(*byte_size, 0));
- const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder();
- RegisterValue reg_value;
- if (reg_ctx->ReadRegister(v0_info, reg_value)) {
- Status error;
- if (reg_value.GetAsMemoryData(v0_info, heap_data_up->GetBytes(),
- heap_data_up->GetByteSize(),
- byte_order, error)) {
- DataExtractor data(DataBufferSP(heap_data_up.release()),
- byte_order,
- exe_ctx.GetProcessRef().GetAddressByteSize());
- return_valobj_sp = ValueObjectConstResult::Create(
- &thread, return_compiler_type, ConstString(""), data);
- }
- }
- }
- }
- }
- } else if (type_flags & eTypeIsStructUnion || type_flags & eTypeIsClass) {
- DataExtractor data;
-
- 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_compiler_type, is_return_value, NGRN, NSRN,
- data)) {
- return_valobj_sp = ValueObjectConstResult::Create(
- &thread, return_compiler_type, ConstString(""), data);
- }
- }
- return return_valobj_sp;
-}
-
-void ABIMacOSX_arm64::Initialize() {
- PluginManager::RegisterPlugin(GetPluginNameStatic(), pluginDesc,
- CreateInstance);
-}
-
-void ABIMacOSX_arm64::Terminate() {
- PluginManager::UnregisterPlugin(CreateInstance);
-}
-
-// PluginInterface protocol
-
-ConstString ABIMacOSX_arm64::GetPluginNameStatic() {
- static ConstString g_plugin_name("ABIMacOSX_arm64");
- return g_plugin_name;
-}
-
-uint32_t ABIMacOSX_arm64::GetPluginVersion() { return 1; }
diff --git a/lldb/source/Plugins/ABI/Mips/ABIMips.cpp b/lldb/source/Plugins/ABI/Mips/ABIMips.cpp
new file mode 100644
index 000000000000..16ef1faf9d9d
--- /dev/null
+++ b/lldb/source/Plugins/ABI/Mips/ABIMips.cpp
@@ -0,0 +1,24 @@
+//===-- Mips.h ------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "ABIMips.h"
+#include "ABISysV_mips.h"
+#include "ABISysV_mips64.h"
+#include "lldb/Core/PluginManager.h"
+
+LLDB_PLUGIN_DEFINE(ABIMips)
+
+void ABIMips::Initialize() {
+ ABISysV_mips::Initialize();
+ ABISysV_mips64::Initialize();
+}
+
+void ABIMips::Terminate() {
+ ABISysV_mips::Terminate();
+ ABISysV_mips64::Terminate();
+}
diff --git a/lldb/source/Plugins/ABI/Mips/ABIMips.h b/lldb/source/Plugins/ABI/Mips/ABIMips.h
new file mode 100644
index 000000000000..dc7704de1c96
--- /dev/null
+++ b/lldb/source/Plugins/ABI/Mips/ABIMips.h
@@ -0,0 +1,17 @@
+//===-- Mips.h -----------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_ABI_MIPS_ABIMIPS_H
+#define LLDB_SOURCE_PLUGINS_ABI_MIPS_ABIMIPS_H
+
+class ABIMips {
+public:
+ static void Initialize();
+ static void Terminate();
+};
+#endif
diff --git a/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp b/lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp
index 416db9f5ae87..d66e0926ad99 100644
--- a/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
+++ b/lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp
@@ -1,4 +1,4 @@
-//===-- ABISysV_mips.cpp ----------------------------------------*- C++ -*-===//
+//===-- ABISysV_mips.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -32,6 +32,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(ABISysV_mips)
+
enum dwarf_regnums {
dwarf_r0 = 0,
dwarf_r1,
diff --git a/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.h b/lldb/source/Plugins/ABI/Mips/ABISysV_mips.h
index 8143f552fc4d..715405e7ef97 100644
--- a/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.h
+++ b/lldb/source/Plugins/ABI/Mips/ABISysV_mips.h
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ABISysV_mips_h_
-#define liblldb_ABISysV_mips_h_
+#ifndef LLDB_SOURCE_PLUGINS_ABI_MIPS_ABISYSV_MIPS_H
+#define LLDB_SOURCE_PLUGINS_ABI_MIPS_ABISYSV_MIPS_H
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
-class ABISysV_mips : public lldb_private::ABI {
+class ABISysV_mips : public lldb_private::RegInfoBasedABI {
public:
~ABISysV_mips() override = default;
@@ -87,11 +87,7 @@ protected:
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
private:
- ABISysV_mips(lldb::ProcessSP process_sp,
- std::unique_ptr<llvm::MCRegisterInfo> info_up)
- : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
- // Call CreateInstance instead.
- }
+ using lldb_private::RegInfoBasedABI::RegInfoBasedABI; // Call CreateInstance instead.
};
-#endif // liblldb_ABISysV_mips_h_
+#endif // LLDB_SOURCE_PLUGINS_ABI_MIPS_ABISYSV_MIPS_H
diff --git a/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp b/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
index 72ec0715b6cd..bb28a50e5f4a 100644
--- a/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
+++ b/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
@@ -1,4 +1,4 @@
-//===-- ABISysV_mips64.cpp --------------------------------------*- C++ -*-===//
+//===-- ABISysV_mips64.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -32,6 +32,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(ABISysV_mips64)
+
enum dwarf_regnums {
dwarf_r0 = 0,
dwarf_r1,
diff --git a/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h b/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.h
index 76c3c5413b92..91428216a73a 100644
--- a/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h
+++ b/lldb/source/Plugins/ABI/Mips/ABISysV_mips64.h
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ABISysV_mips64_h_
-#define liblldb_ABISysV_mips64_h_
+#ifndef LLDB_SOURCE_PLUGINS_ABI_MIPS_ABISYSV_MIPS64_H
+#define LLDB_SOURCE_PLUGINS_ABI_MIPS_ABISYSV_MIPS64_H
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
-class ABISysV_mips64 : public lldb_private::ABI {
+class ABISysV_mips64 : public lldb_private::RegInfoBasedABI {
public:
~ABISysV_mips64() override = default;
@@ -51,7 +51,7 @@ public:
//
// To work around this, we relax that alignment to be just word-size
// (8-bytes).
- // Whitelisting the trap handlers for user space would be easy (_sigtramp) but
+ // Allowing 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 {
@@ -100,11 +100,7 @@ protected:
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
private:
- ABISysV_mips64(lldb::ProcessSP process_sp,
- std::unique_ptr<llvm::MCRegisterInfo> info_up)
- : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
- // Call CreateInstance instead.
- }
+ using lldb_private::RegInfoBasedABI::RegInfoBasedABI; // Call CreateInstance instead.
};
-#endif // liblldb_ABISysV_mips64_h_
+#endif // LLDB_SOURCE_PLUGINS_ABI_MIPS_ABISYSV_MIPS64_H
diff --git a/lldb/source/Plugins/ABI/PowerPC/ABIPowerPC.cpp b/lldb/source/Plugins/ABI/PowerPC/ABIPowerPC.cpp
new file mode 100644
index 000000000000..b561e3c93f57
--- /dev/null
+++ b/lldb/source/Plugins/ABI/PowerPC/ABIPowerPC.cpp
@@ -0,0 +1,24 @@
+//===-- PowerPC.h ---------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "ABIPowerPC.h"
+#include "ABISysV_ppc.h"
+#include "ABISysV_ppc64.h"
+#include "lldb/Core/PluginManager.h"
+
+LLDB_PLUGIN_DEFINE(ABIPowerPC)
+
+void ABIPowerPC::Initialize() {
+ ABISysV_ppc::Initialize();
+ ABISysV_ppc64::Initialize();
+}
+
+void ABIPowerPC::Terminate() {
+ ABISysV_ppc::Terminate();
+ ABISysV_ppc64::Terminate();
+}
diff --git a/lldb/source/Plugins/ABI/PowerPC/ABIPowerPC.h b/lldb/source/Plugins/ABI/PowerPC/ABIPowerPC.h
new file mode 100644
index 000000000000..5e745eae0a42
--- /dev/null
+++ b/lldb/source/Plugins/ABI/PowerPC/ABIPowerPC.h
@@ -0,0 +1,17 @@
+//===-- PowerPC.h -----------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_ABI_POWERPC_ABIPOWERPC_H
+#define LLDB_SOURCE_PLUGINS_ABI_POWERPC_ABIPOWERPC_H
+
+class ABIPowerPC {
+public:
+ static void Initialize();
+ static void Terminate();
+};
+#endif
diff --git a/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp
index 857b7fee10e3..6f5eded7b031 100644
--- a/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
+++ b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp
@@ -1,4 +1,4 @@
-//===-- ABISysV_ppc.cpp -----------------------------------------*- C++ -*-===//
+//===-- ABISysV_ppc.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -32,6 +32,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(ABISysV_ppc)
+
enum dwarf_regnums {
dwarf_r0 = 0,
dwarf_r1,
diff --git a/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.h
index 59907c4648ba..4a586849e585 100644
--- a/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h
+++ b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.h
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ABISysV_ppc_h_
-#define liblldb_ABISysV_ppc_h_
+#ifndef LLDB_SOURCE_PLUGINS_ABI_POWERPC_ABISYSV_PPC_H
+#define LLDB_SOURCE_PLUGINS_ABI_POWERPC_ABISYSV_PPC_H
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
-class ABISysV_ppc : public lldb_private::ABI {
+class ABISysV_ppc : public lldb_private::RegInfoBasedABI {
public:
~ABISysV_ppc() override = default;
@@ -49,7 +49,7 @@ public:
//
// To work around this, we relax that alignment to be just word-size
// (8-bytes).
- // Whitelisting the trap handlers for user space would be easy (_sigtramp) but
+ // Allowing 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 {
@@ -96,11 +96,7 @@ protected:
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
private:
- ABISysV_ppc(lldb::ProcessSP process_sp,
- std::unique_ptr<llvm::MCRegisterInfo> info_up)
- : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
- // Call CreateInstance instead.
- }
+ using lldb_private::RegInfoBasedABI::RegInfoBasedABI; // Call CreateInstance instead.
};
-#endif // liblldb_ABISysV_ppc_h_
+#endif // LLDB_SOURCE_PLUGINS_ABI_POWERPC_ABISYSV_PPC_H
diff --git a/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp
index 935353c38ca4..251ac972fd76 100644
--- a/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
+++ b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp
@@ -1,4 +1,4 @@
-//===-- ABISysV_ppc64.cpp ---------------------------------------*- C++ -*-===//
+//===-- ABISysV_ppc64.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -11,6 +11,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "Utility/PPC64LE_DWARF_Registers.h"
#include "Utility/PPC64_DWARF_Registers.h"
#include "lldb/Core/Module.h"
@@ -19,7 +20,6 @@
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectMemory.h"
#include "lldb/Core/ValueObjectRegister.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
@@ -47,6 +47,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(ABISysV_ppc64)
+
const lldb_private::RegisterInfo *
ABISysV_ppc64::GetRegisterInfoArray(uint32_t &count) {
if (GetByteOrder() == lldb::eByteOrderLittle) {
@@ -806,10 +808,10 @@ private:
// case 3: get from GPRs
// first, check if this is a packed struct or not
- ClangASTContext *ast =
- llvm::dyn_cast<ClangASTContext>(m_type.GetTypeSystem());
+ TypeSystemClang *ast =
+ llvm::dyn_cast<TypeSystemClang>(m_type.GetTypeSystem());
if (ast) {
- clang::RecordDecl *record_decl = ClangASTContext::GetAsRecordDecl(m_type);
+ clang::RecordDecl *record_decl = TypeSystemClang::GetAsRecordDecl(m_type);
if (record_decl) {
auto attrs = record_decl->attrs();
diff --git a/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.h
index 1b58975dd9d9..8dcf3ca48b56 100644
--- a/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h
+++ b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.h
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ABISysV_ppc64_h_
-#define liblldb_ABISysV_ppc64_h_
+#ifndef LLDB_SOURCE_PLUGINS_ABI_POWERPC_ABISYSV_PPC64_H
+#define LLDB_SOURCE_PLUGINS_ABI_POWERPC_ABISYSV_PPC64_H
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
-class ABISysV_ppc64 : public lldb_private::ABI {
+class ABISysV_ppc64 : public lldb_private::RegInfoBasedABI {
public:
~ABISysV_ppc64() override = default;
@@ -49,7 +49,7 @@ public:
//
// To work around this, we relax that alignment to be just word-size
// (8-bytes).
- // Whitelisting the trap handlers for user space would be easy (_sigtramp) but
+ // Allowing 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 {
@@ -96,13 +96,9 @@ protected:
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
private:
- ABISysV_ppc64(lldb::ProcessSP process_sp,
- std::unique_ptr<llvm::MCRegisterInfo> info_up)
- : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
- // Call CreateInstance instead.
- }
+ using lldb_private::RegInfoBasedABI::RegInfoBasedABI; // Call CreateInstance instead.
lldb::ByteOrder GetByteOrder() const;
};
-#endif // liblldb_ABISysV_ppc64_h_
+#endif // LLDB_SOURCE_PLUGINS_ABI_POWERPC_ABISYSV_PPC64_H
diff --git a/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp b/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
deleted file mode 100644
index 89a1f2b3cf04..000000000000
--- a/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
+++ /dev/null
@@ -1,2420 +0,0 @@
-//===-- ABISysV_arm64.cpp ---------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "ABISysV_arm64.h"
-
-#include <vector>
-
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/Triple.h"
-
-#include "lldb/Core/Module.h"
-#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/Value.h"
-#include "lldb/Core/ValueObjectConstResult.h"
-#include "lldb/Symbol/UnwindPlan.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/RegisterContext.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
-#include "lldb/Utility/ConstString.h"
-#include "lldb/Utility/Log.h"
-#include "lldb/Utility/RegisterValue.h"
-#include "lldb/Utility/Scalar.h"
-#include "lldb/Utility/Status.h"
-
-#include "Utility/ARM64_DWARF_Registers.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-static RegisterInfo g_register_infos[] = {
- // NAME ALT SZ OFF ENCODING FORMAT
- // EH_FRAME DWARF GENERIC
- // PROCESS PLUGIN LLDB NATIVE
- // ========== ======= == === ============= ===================
- // =================== ====================== ===========================
- // ======================= ======================
- {"x0",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x0, LLDB_REGNUM_GENERIC_ARG1,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x1",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x1, LLDB_REGNUM_GENERIC_ARG2,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x2",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x2, LLDB_REGNUM_GENERIC_ARG3,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x3",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x3, LLDB_REGNUM_GENERIC_ARG4,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x4",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x4, LLDB_REGNUM_GENERIC_ARG5,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x5",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x5, LLDB_REGNUM_GENERIC_ARG6,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x6",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x6, LLDB_REGNUM_GENERIC_ARG7,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x7",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x7, LLDB_REGNUM_GENERIC_ARG8,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x8",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x8, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x9",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x9, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x10",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x10, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x11",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x11, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x12",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x12, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x13",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x13, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x14",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x14, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x15",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x15, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x16",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x16, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x17",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x17, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x18",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x18, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x19",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x19, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x20",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x20, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x21",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x21, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x22",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x22, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x23",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x23, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x24",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x24, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x25",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x25, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x26",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x26, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x27",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x27, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"x28",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x28, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fp",
- "x29",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x29, LLDB_REGNUM_GENERIC_FP,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"lr",
- "x30",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x30, LLDB_REGNUM_GENERIC_RA,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"sp",
- "x31",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::x31, LLDB_REGNUM_GENERIC_SP,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"pc",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::pc, LLDB_REGNUM_GENERIC_PC,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"cpsr",
- "psr",
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, arm64_dwarf::cpsr, LLDB_REGNUM_GENERIC_FLAGS,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-
- {"v0",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v0, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v1",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v1, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v2",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v2, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v3",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v3, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v4",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v4, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v5",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v5, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v6",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v6, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v7",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v7, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v8",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v8, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v9",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v9, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v10",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v10, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v11",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v11, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v12",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v12, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v13",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v13, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v14",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v14, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v15",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v15, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v16",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v16, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v17",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v17, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v18",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v18, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v19",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v19, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v20",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v20, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v21",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v21, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v22",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v22, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v23",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v23, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v24",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v24, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v25",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v25, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v26",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v26, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v27",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v27, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v28",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v28, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v29",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v29, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v30",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v30, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"v31",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, arm64_dwarf::v31, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-
- {"fpsr",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fpcr",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-
- {"s0",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s1",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s2",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s3",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s4",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s5",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s6",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s7",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s8",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s9",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s10",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s11",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s12",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s13",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s14",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s15",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s16",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s17",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s18",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s19",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s20",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s21",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s22",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s23",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s24",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s25",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s26",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s27",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s28",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s29",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s30",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"s31",
- nullptr,
- 4,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
-
- {"d0",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d1",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d2",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d3",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d4",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d5",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d6",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d7",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d8",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d9",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d10",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d11",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d12",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d13",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d14",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d15",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d16",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d17",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d18",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d19",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d20",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d21",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d22",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d23",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d24",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d25",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d26",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d27",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d28",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d29",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d30",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"d31",
- nullptr,
- 8,
- 0,
- eEncodingIEEE754,
- eFormatFloat,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0}};
-
-static const uint32_t k_num_register_infos =
- llvm::array_lengthof(g_register_infos);
-static bool g_register_info_names_constified = false;
-
-const lldb_private::RegisterInfo *
-ABISysV_arm64::GetRegisterInfoArray(uint32_t &count) {
- // Make the C-string names and alt_names for the register infos into const
- // C-string values by having the ConstString unique the names in the global
- // constant C-string pool.
- if (!g_register_info_names_constified) {
- g_register_info_names_constified = true;
- for (uint32_t i = 0; i < k_num_register_infos; ++i) {
- if (g_register_infos[i].name)
- g_register_infos[i].name =
- ConstString(g_register_infos[i].name).GetCString();
- if (g_register_infos[i].alt_name)
- g_register_infos[i].alt_name =
- ConstString(g_register_infos[i].alt_name).GetCString();
- }
- }
- count = k_num_register_infos;
- return g_register_infos;
-}
-
-bool ABISysV_arm64::GetPointerReturnRegister(const char *&name) {
- name = "x0";
- return true;
-}
-
-size_t ABISysV_arm64::GetRedZoneSize() const { return 128; }
-
-// Static Functions
-
-ABISP
-ABISysV_arm64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
- const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch();
- const llvm::Triple::VendorType vendor_type = arch.GetTriple().getVendor();
-
- if (vendor_type != llvm::Triple::Apple) {
- if (arch_type == llvm::Triple::aarch64 ||
- arch_type == llvm::Triple::aarch64_32) {
- return ABISP(
- new ABISysV_arm64(std::move(process_sp), MakeMCRegisterInfo(arch)));
- }
- }
-
- return ABISP();
-}
-
-bool ABISysV_arm64::PrepareTrivialCall(Thread &thread, addr_t sp,
- addr_t func_addr, addr_t return_addr,
- llvm::ArrayRef<addr_t> args) const {
- RegisterContext *reg_ctx = thread.GetRegisterContext().get();
- if (!reg_ctx)
- return false;
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
-
- if (log) {
- StreamString s;
- s.Printf("ABISysV_arm64::PrepareTrivialCall (tid = 0x%" PRIx64
- ", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64
- ", return_addr = 0x%" PRIx64,
- thread.GetID(), (uint64_t)sp, (uint64_t)func_addr,
- (uint64_t)return_addr);
-
- for (size_t i = 0; i < args.size(); ++i)
- s.Printf(", arg%d = 0x%" PRIx64, static_cast<int>(i + 1), args[i]);
- s.PutCString(")");
- log->PutString(s.GetString());
- }
-
- // x0 - x7 contain first 8 simple args
- if (args.size() > 8)
- return false;
-
- for (size_t i = 0; i < args.size(); ++i) {
- const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(
- eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + i);
- LLDB_LOGF(log, "About to write arg%d (0x%" PRIx64 ") into %s",
- static_cast<int>(i + 1), args[i], reg_info->name);
- if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i]))
- return false;
- }
-
- // Set "lr" to the return address
- if (!reg_ctx->WriteRegisterFromUnsigned(
- reg_ctx->GetRegisterInfo(eRegisterKindGeneric,
- LLDB_REGNUM_GENERIC_RA),
- return_addr))
- return false;
-
- // Set "sp" to the requested value
- if (!reg_ctx->WriteRegisterFromUnsigned(
- reg_ctx->GetRegisterInfo(eRegisterKindGeneric,
- LLDB_REGNUM_GENERIC_SP),
- sp))
- return false;
-
- // Set "pc" to the address requested
- if (!reg_ctx->WriteRegisterFromUnsigned(
- reg_ctx->GetRegisterInfo(eRegisterKindGeneric,
- LLDB_REGNUM_GENERIC_PC),
- func_addr))
- return false;
-
- return true;
-}
-
-// TODO: We dont support fp/SIMD arguments in v0-v7
-bool ABISysV_arm64::GetArgumentValues(Thread &thread, ValueList &values) const {
- uint32_t num_values = values.GetSize();
-
- ExecutionContext exe_ctx(thread.shared_from_this());
-
- // Extract the register context so we can read arguments from registers
-
- RegisterContext *reg_ctx = thread.GetRegisterContext().get();
-
- if (!reg_ctx)
- return false;
-
- addr_t sp = 0;
-
- for (uint32_t value_idx = 0; value_idx < num_values; ++value_idx) {
- // We currently only support extracting values with Clang QualTypes. Do we
- // care about others?
- Value *value = values.GetValueAtIndex(value_idx);
-
- if (!value)
- return false;
-
- CompilerType value_type = value->GetCompilerType();
- if (value_type) {
- bool is_signed = false;
- size_t bit_width = 0;
- llvm::Optional<uint64_t> bit_size = value_type.GetBitSize(&thread);
- if (!bit_size)
- return false;
- if (value_type.IsIntegerOrEnumerationType(is_signed)) {
- bit_width = *bit_size;
- } else if (value_type.IsPointerOrReferenceType()) {
- bit_width = *bit_size;
- } else {
- // We only handle integer, pointer and reference types currently...
- return false;
- }
-
- if (bit_width <= (exe_ctx.GetProcessRef().GetAddressByteSize() * 8)) {
- if (value_idx < 8) {
- // Arguments 1-8 are in x0-x7...
- const RegisterInfo *reg_info = nullptr;
- reg_info = reg_ctx->GetRegisterInfo(
- eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + value_idx);
-
- if (reg_info) {
- RegisterValue reg_value;
-
- if (reg_ctx->ReadRegister(reg_info, reg_value)) {
- if (is_signed)
- reg_value.SignExtend(bit_width);
- if (!reg_value.GetScalarValue(value->GetScalar()))
- return false;
- continue;
- }
- }
- return false;
- } else {
- // TODO: Verify for stack layout for SysV
- if (sp == 0) {
- // Read the stack pointer if we already haven't read it
- sp = reg_ctx->GetSP(0);
- if (sp == 0)
- return false;
- }
-
- // Arguments 5 on up are on the stack
- const uint32_t arg_byte_size = (bit_width + (8 - 1)) / 8;
- Status error;
- if (!exe_ctx.GetProcessRef().ReadScalarIntegerFromMemory(
- sp, arg_byte_size, is_signed, value->GetScalar(), error))
- return false;
-
- sp += arg_byte_size;
- // Align up to the next 8 byte boundary if needed
- if (sp % 8) {
- sp >>= 3;
- sp += 1;
- sp <<= 3;
- }
- }
- }
- }
- }
- return true;
-}
-
-Status ABISysV_arm64::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
- lldb::ValueObjectSP &new_value_sp) {
- Status error;
- if (!new_value_sp) {
- error.SetErrorString("Empty value object for return value.");
- return error;
- }
-
- CompilerType return_value_type = new_value_sp->GetCompilerType();
- if (!return_value_type) {
- error.SetErrorString("Null clang type for return value.");
- return error;
- }
-
- Thread *thread = frame_sp->GetThread().get();
-
- RegisterContext *reg_ctx = thread->GetRegisterContext().get();
-
- if (reg_ctx) {
- DataExtractor data;
- Status data_error;
- const uint64_t byte_size = new_value_sp->GetData(data, data_error);
- if (data_error.Fail()) {
- error.SetErrorStringWithFormat(
- "Couldn't convert return value to raw data: %s",
- data_error.AsCString());
- return error;
- }
-
- const uint32_t type_flags = return_value_type.GetTypeInfo(nullptr);
- if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) {
- if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) {
- // Extract the register context so we can read arguments from registers
- lldb::offset_t offset = 0;
- if (byte_size <= 16) {
- const RegisterInfo *x0_info = reg_ctx->GetRegisterInfo(
- eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1);
- if (byte_size <= 8) {
- uint64_t raw_value = data.GetMaxU64(&offset, byte_size);
-
- if (!reg_ctx->WriteRegisterFromUnsigned(x0_info, raw_value))
- error.SetErrorString("failed to write register x0");
- } else {
- uint64_t raw_value = data.GetMaxU64(&offset, 8);
-
- if (reg_ctx->WriteRegisterFromUnsigned(x0_info, raw_value)) {
- const RegisterInfo *x1_info = reg_ctx->GetRegisterInfo(
- eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2);
- raw_value = data.GetMaxU64(&offset, byte_size - offset);
-
- if (!reg_ctx->WriteRegisterFromUnsigned(x1_info, raw_value))
- error.SetErrorString("failed to write register x1");
- }
- }
- } else {
- error.SetErrorString("We don't support returning longer than 128 bit "
- "integer values at present.");
- }
- } else if (type_flags & eTypeIsFloat) {
- if (type_flags & eTypeIsComplex) {
- // Don't handle complex yet.
- error.SetErrorString(
- "returning complex float values are not supported");
- } else {
- const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0);
-
- if (v0_info) {
- if (byte_size <= 16) {
- if (byte_size <= RegisterValue::GetMaxByteSize()) {
- RegisterValue reg_value;
- error = reg_value.SetValueFromData(v0_info, data, 0, true);
- if (error.Success()) {
- if (!reg_ctx->WriteRegister(v0_info, reg_value))
- error.SetErrorString("failed to write register v0");
- }
- } else {
- error.SetErrorStringWithFormat(
- "returning float values with a byte size of %" PRIu64
- " are not supported",
- byte_size);
- }
- } else {
- error.SetErrorString("returning float values longer than 128 "
- "bits are not supported");
- }
- } else {
- error.SetErrorString("v0 register is not available on this target");
- }
- }
- }
- } else if (type_flags & eTypeIsVector) {
- if (byte_size > 0) {
- const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0);
-
- if (v0_info) {
- if (byte_size <= v0_info->byte_size) {
- RegisterValue reg_value;
- error = reg_value.SetValueFromData(v0_info, data, 0, true);
- if (error.Success()) {
- if (!reg_ctx->WriteRegister(v0_info, reg_value))
- error.SetErrorString("failed to write register v0");
- }
- }
- }
- }
- }
- } else {
- error.SetErrorString("no registers are available");
- }
-
- return error;
-}
-
-bool ABISysV_arm64::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) {
- unwind_plan.Clear();
- unwind_plan.SetRegisterKind(eRegisterKindDWARF);
-
- uint32_t lr_reg_num = arm64_dwarf::lr;
- uint32_t sp_reg_num = arm64_dwarf::sp;
-
- UnwindPlan::RowSP row(new UnwindPlan::Row);
-
- // Our previous Call Frame Address is the stack pointer
- row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 0);
-
- unwind_plan.AppendRow(row);
- unwind_plan.SetReturnAddressRegister(lr_reg_num);
-
- // All other registers are the same.
-
- unwind_plan.SetSourceName("arm64 at-func-entry default");
- unwind_plan.SetSourcedFromCompiler(eLazyBoolNo);
- unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
- unwind_plan.SetUnwindPlanForSignalTrap(eLazyBoolNo);
-
- return true;
-}
-
-bool ABISysV_arm64::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) {
- unwind_plan.Clear();
- unwind_plan.SetRegisterKind(eRegisterKindDWARF);
-
- uint32_t fp_reg_num = arm64_dwarf::fp;
- uint32_t pc_reg_num = arm64_dwarf::pc;
-
- UnwindPlan::RowSP row(new UnwindPlan::Row);
- const int32_t ptr_size = 8;
-
- row->GetCFAValue().SetIsRegisterPlusOffset(fp_reg_num, 2 * ptr_size);
- row->SetOffset(0);
-
- row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true);
- row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true);
-
- unwind_plan.AppendRow(row);
- unwind_plan.SetSourceName("arm64 default unwind plan");
- unwind_plan.SetSourcedFromCompiler(eLazyBoolNo);
- unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
- unwind_plan.SetUnwindPlanForSignalTrap(eLazyBoolNo);
-
- return true;
-}
-
-// AAPCS64 (Procedure Call Standard for the ARM 64-bit Architecture) says
-// registers x19 through x28 and sp are callee preserved. v8-v15 are non-
-// volatile (and specifically only the lower 8 bytes of these regs), the rest
-// of the fp/SIMD registers are volatile.
-
-// We treat x29 as callee preserved also, else the unwinder won't try to
-// retrieve fp saves.
-
-bool ABISysV_arm64::RegisterIsVolatile(const RegisterInfo *reg_info) {
- if (reg_info) {
- const char *name = reg_info->name;
-
- // Sometimes we'll be called with the "alternate" name for these registers;
- // recognize them as non-volatile.
-
- if (name[0] == 'p' && name[1] == 'c') // pc
- return false;
- if (name[0] == 'f' && name[1] == 'p') // fp
- return false;
- if (name[0] == 's' && name[1] == 'p') // sp
- return false;
- if (name[0] == 'l' && name[1] == 'r') // lr
- return false;
-
- if (name[0] == 'x' || name[0] == 'r') {
- // Volatile registers: x0-x18
- // Although documentation says only x19-28 + sp are callee saved We ll
- // also have to treat x30 as non-volatile. Each dwarf frame has its own
- // value of lr. Return false for the non-volatile gpr regs, true for
- // everything else
- switch (name[1]) {
- case '1':
- switch (name[2]) {
- case '9':
- return false; // x19 is non-volatile
- default:
- return true;
- }
- break;
- case '2':
- switch (name[2]) {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- return false; // x20 - 28 are non-volatile
- case '9':
- return false; // x29 aka fp treat as non-volatile
- default:
- return true;
- }
- case '3': // x30 (lr) and x31 (sp) treat as non-volatile
- if (name[2] == '0' || name[2] == '1')
- return false;
- break;
- default:
- return true; // all volatile cases not handled above fall here.
- }
- } else if (name[0] == 'v' || name[0] == 's' || name[0] == 'd') {
- // Volatile registers: v0-7, v16-v31
- // Return false for non-volatile fp/SIMD regs, true for everything else
- switch (name[1]) {
- case '8':
- case '9':
- return false; // v8-v9 are non-volatile
- case '1':
- switch (name[2]) {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- return false; // v10-v15 are non-volatile
- default:
- return true;
- }
- default:
- return true;
- }
- }
- }
- return true;
-}
-
-static bool LoadValueFromConsecutiveGPRRegisters(
- ExecutionContext &exe_ctx, RegisterContext *reg_ctx,
- 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)
- DataExtractor &data) {
- llvm::Optional<uint64_t> byte_size = value_type.GetByteSize(nullptr);
-
- if (byte_size || *byte_size == 0)
- return false;
-
- std::unique_ptr<DataBufferHeap> heap_data_up(
- new DataBufferHeap(*byte_size, 0));
- const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder();
- Status error;
-
- CompilerType base_type;
- const uint32_t homogeneous_count =
- value_type.IsHomogeneousAggregate(&base_type);
- if (homogeneous_count > 0 && homogeneous_count <= 8) {
- // Make sure we have enough registers
- if (NSRN < 8 && (8 - NSRN) >= homogeneous_count) {
- if (!base_type)
- return false;
- llvm::Optional<uint64_t> base_byte_size = base_type.GetByteSize(nullptr);
- if (!base_byte_size)
- return false;
- uint32_t data_offset = 0;
-
- for (uint32_t i = 0; i < homogeneous_count; ++i) {
- char v_name[8];
- ::snprintf(v_name, sizeof(v_name), "v%u", NSRN);
- const RegisterInfo *reg_info =
- reg_ctx->GetRegisterInfoByName(v_name, 0);
- if (reg_info == nullptr)
- return false;
-
- if (*base_byte_size > reg_info->byte_size)
- return false;
-
- RegisterValue reg_value;
-
- if (!reg_ctx->ReadRegister(reg_info, reg_value))
- return false;
-
- // Make sure we have enough room in "heap_data_up"
- if ((data_offset + *base_byte_size) <= heap_data_up->GetByteSize()) {
- const size_t bytes_copied = reg_value.GetAsMemoryData(
- reg_info, heap_data_up->GetBytes() + data_offset, *base_byte_size,
- byte_order, error);
- if (bytes_copied != *base_byte_size)
- return false;
- data_offset += bytes_copied;
- ++NSRN;
- } else
- return false;
- }
- data.SetByteOrder(byte_order);
- data.SetAddressByteSize(exe_ctx.GetProcessRef().GetAddressByteSize());
- data.SetData(DataBufferSP(heap_data_up.release()));
- return true;
- }
- }
-
- const size_t max_reg_byte_size = 16;
- if (*byte_size <= max_reg_byte_size) {
- size_t bytes_left = *byte_size;
- uint32_t data_offset = 0;
- while (data_offset < *byte_size) {
- if (NGRN >= 8)
- return false;
-
- const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(
- eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + NGRN);
- if (reg_info == nullptr)
- return false;
-
- RegisterValue reg_value;
-
- if (!reg_ctx->ReadRegister(reg_info, reg_value))
- return false;
-
- const size_t curr_byte_size = std::min<size_t>(8, bytes_left);
- const size_t bytes_copied = reg_value.GetAsMemoryData(
- reg_info, heap_data_up->GetBytes() + data_offset, curr_byte_size,
- byte_order, error);
- if (bytes_copied == 0)
- return false;
- if (bytes_copied >= bytes_left)
- break;
- data_offset += bytes_copied;
- bytes_left -= bytes_copied;
- ++NGRN;
- }
- } else {
- const RegisterInfo *reg_info = nullptr;
- if (is_return_value) {
- // We are assuming we are decoding this immediately after returning from
- // a function call and that the address of the structure is in x8
- reg_info = reg_ctx->GetRegisterInfoByName("x8", 0);
- } else {
- // We are assuming we are stopped at the first instruction in a function
- // and that the ABI is being respected so all parameters appear where
- // they should be (functions with no external linkage can legally violate
- // the ABI).
- if (NGRN >= 8)
- return false;
-
- reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric,
- LLDB_REGNUM_GENERIC_ARG1 + NGRN);
- if (reg_info == nullptr)
- return false;
- ++NGRN;
- }
-
- if (reg_info == nullptr)
- return false;
-
- const lldb::addr_t value_addr =
- reg_ctx->ReadRegisterAsUnsigned(reg_info, LLDB_INVALID_ADDRESS);
-
- if (value_addr == LLDB_INVALID_ADDRESS)
- return false;
-
- if (exe_ctx.GetProcessRef().ReadMemory(
- value_addr, heap_data_up->GetBytes(), heap_data_up->GetByteSize(),
- error) != heap_data_up->GetByteSize()) {
- return false;
- }
- }
-
- data.SetByteOrder(byte_order);
- data.SetAddressByteSize(exe_ctx.GetProcessRef().GetAddressByteSize());
- data.SetData(DataBufferSP(heap_data_up.release()));
- return true;
-}
-
-ValueObjectSP ABISysV_arm64::GetReturnValueObjectImpl(
- Thread &thread, CompilerType &return_compiler_type) const {
- ValueObjectSP return_valobj_sp;
- Value value;
-
- ExecutionContext exe_ctx(thread.shared_from_this());
- if (exe_ctx.GetTargetPtr() == nullptr || exe_ctx.GetProcessPtr() == nullptr)
- return return_valobj_sp;
-
- // 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;
-
- llvm::Optional<uint64_t> byte_size =
- return_compiler_type.GetByteSize(nullptr);
- if (!byte_size)
- return return_valobj_sp;
-
- const uint32_t type_flags = return_compiler_type.GetTypeInfo(nullptr);
- if (type_flags & eTypeIsScalar || type_flags & eTypeIsPointer) {
- value.SetValueType(Value::eValueTypeScalar);
-
- bool success = false;
- if (type_flags & eTypeIsInteger || type_flags & eTypeIsPointer) {
- // Extract the register context so we can read arguments from registers
- if (*byte_size <= 8) {
- const RegisterInfo *x0_reg_info = nullptr;
- x0_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric,
- LLDB_REGNUM_GENERIC_ARG1);
- if (x0_reg_info) {
- uint64_t raw_value =
- thread.GetRegisterContext()->ReadRegisterAsUnsigned(x0_reg_info,
- 0);
- const bool is_signed = (type_flags & eTypeIsSigned) != 0;
- switch (*byte_size) {
- default:
- break;
- case 16: // uint128_t
- // In register x0 and x1
- {
- const RegisterInfo *x1_reg_info = nullptr;
- x1_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric,
- LLDB_REGNUM_GENERIC_ARG2);
-
- if (x1_reg_info) {
- if (*byte_size <=
- x0_reg_info->byte_size + x1_reg_info->byte_size) {
- std::unique_ptr<DataBufferHeap> heap_data_up(
- new DataBufferHeap(*byte_size, 0));
- const ByteOrder byte_order =
- exe_ctx.GetProcessRef().GetByteOrder();
- RegisterValue x0_reg_value;
- RegisterValue x1_reg_value;
- if (reg_ctx->ReadRegister(x0_reg_info, x0_reg_value) &&
- reg_ctx->ReadRegister(x1_reg_info, x1_reg_value)) {
- Status error;
- if (x0_reg_value.GetAsMemoryData(
- x0_reg_info, heap_data_up->GetBytes() + 0, 8,
- byte_order, error) &&
- x1_reg_value.GetAsMemoryData(
- x1_reg_info, heap_data_up->GetBytes() + 8, 8,
- byte_order, error)) {
- DataExtractor data(
- DataBufferSP(heap_data_up.release()), byte_order,
- exe_ctx.GetProcessRef().GetAddressByteSize());
-
- return_valobj_sp = ValueObjectConstResult::Create(
- &thread, return_compiler_type, ConstString(""), data);
- return return_valobj_sp;
- }
- }
- }
- }
- }
- break;
- case sizeof(uint64_t):
- if (is_signed)
- value.GetScalar() = (int64_t)(raw_value);
- else
- value.GetScalar() = (uint64_t)(raw_value);
- success = true;
- break;
-
- case sizeof(uint32_t):
- if (is_signed)
- value.GetScalar() = (int32_t)(raw_value & UINT32_MAX);
- else
- value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX);
- success = true;
- break;
-
- case sizeof(uint16_t):
- if (is_signed)
- value.GetScalar() = (int16_t)(raw_value & UINT16_MAX);
- else
- value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX);
- success = true;
- break;
-
- case sizeof(uint8_t):
- if (is_signed)
- value.GetScalar() = (int8_t)(raw_value & UINT8_MAX);
- else
- value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX);
- success = true;
- break;
- }
- }
- }
- } else if (type_flags & eTypeIsFloat) {
- if (type_flags & eTypeIsComplex) {
- // Don't handle complex yet.
- } else {
- if (*byte_size <= sizeof(long double)) {
- const RegisterInfo *v0_reg_info =
- reg_ctx->GetRegisterInfoByName("v0", 0);
- RegisterValue v0_value;
- if (reg_ctx->ReadRegister(v0_reg_info, v0_value)) {
- DataExtractor data;
- if (v0_value.GetData(data)) {
- lldb::offset_t offset = 0;
- if (*byte_size == sizeof(float)) {
- value.GetScalar() = data.GetFloat(&offset);
- success = true;
- } else if (*byte_size == sizeof(double)) {
- value.GetScalar() = data.GetDouble(&offset);
- success = true;
- } else if (*byte_size == sizeof(long double)) {
- value.GetScalar() = data.GetLongDouble(&offset);
- success = true;
- }
- }
- }
- }
- }
- }
-
- if (success)
- return_valobj_sp = ValueObjectConstResult::Create(
- thread.GetStackFrameAtIndex(0).get(), value, ConstString(""));
- } else if (type_flags & eTypeIsVector && *byte_size <= 16) {
- if (*byte_size > 0) {
- const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0);
-
- if (v0_info) {
- std::unique_ptr<DataBufferHeap> heap_data_up(
- new DataBufferHeap(*byte_size, 0));
- const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder();
- RegisterValue reg_value;
- if (reg_ctx->ReadRegister(v0_info, reg_value)) {
- Status error;
- if (reg_value.GetAsMemoryData(v0_info, heap_data_up->GetBytes(),
- heap_data_up->GetByteSize(), byte_order,
- error)) {
- DataExtractor data(DataBufferSP(heap_data_up.release()), byte_order,
- exe_ctx.GetProcessRef().GetAddressByteSize());
- return_valobj_sp = ValueObjectConstResult::Create(
- &thread, return_compiler_type, ConstString(""), data);
- }
- }
- }
- }
- } else if (type_flags & eTypeIsStructUnion || type_flags & eTypeIsClass ||
- (type_flags & eTypeIsVector && *byte_size > 16)) {
- DataExtractor data;
-
- 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_compiler_type, is_return_value, NGRN, NSRN,
- data)) {
- return_valobj_sp = ValueObjectConstResult::Create(
- &thread, return_compiler_type, ConstString(""), data);
- }
- }
- return return_valobj_sp;
-}
-
-void ABISysV_arm64::Initialize() {
- PluginManager::RegisterPlugin(GetPluginNameStatic(),
- "SysV ABI for AArch64 targets", CreateInstance);
-}
-
-void ABISysV_arm64::Terminate() {
- PluginManager::UnregisterPlugin(CreateInstance);
-}
-
-lldb_private::ConstString ABISysV_arm64::GetPluginNameStatic() {
- static ConstString g_name("SysV-arm64");
- return g_name;
-}
-
-// PluginInterface protocol
-
-ConstString ABISysV_arm64::GetPluginName() { return GetPluginNameStatic(); }
-
-uint32_t ABISysV_arm64::GetPluginVersion() { return 1; }
diff --git a/lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp b/lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp
index f4f803a8277d..eced2adc7591 100644
--- a/lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
+++ b/lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp
@@ -1,4 +1,4 @@
-//===-- ABISysV_s390x.cpp ---------------------------------------*- C++ -*-===//
+//===-- ABISysV_s390x.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -32,6 +32,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE_ADV(ABISysV_s390x, ABISystemZ)
+
enum dwarf_regnums {
// General Purpose Registers
dwarf_r0_s390x = 0,
diff --git a/lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h b/lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.h
index 671d6a18260e..f8f412465658 100644
--- a/lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h
+++ b/lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.h
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ABISysV_s390x_h_
-#define liblldb_ABISysV_s390x_h_
+#ifndef LLDB_SOURCE_PLUGINS_ABI_SYSTEMZ_ABISYSV_S390X_H
+#define LLDB_SOURCE_PLUGINS_ABI_SYSTEMZ_ABISYSV_S390X_H
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
-class ABISysV_s390x : public lldb_private::ABI {
+class ABISysV_s390x : public lldb_private::RegInfoBasedABI {
public:
~ABISysV_s390x() override = default;
@@ -88,11 +88,7 @@ protected:
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
private:
- ABISysV_s390x(lldb::ProcessSP process_sp,
- std::unique_ptr<llvm::MCRegisterInfo> info_up)
- : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
- // Call CreateInstance instead.
- }
+ using lldb_private::RegInfoBasedABI::RegInfoBasedABI; // Call CreateInstance instead.
};
-#endif // liblldb_ABISysV_s390x_h_
+#endif // LLDB_SOURCE_PLUGINS_ABI_SYSTEMZ_ABISYSV_S390X_H
diff --git a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.cpp
index 76ebd6476ffd..89112deb2c4a 100644
--- a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
+++ b/lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.cpp
@@ -1,4 +1,4 @@
-//===-- ABIMacOSX_i386.cpp --------------------------------------*- C++ -*-===//
+//===-- ABIMacOSX_i386.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -29,20 +29,7 @@
using namespace lldb;
using namespace lldb_private;
-enum {
- 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
-};
+LLDB_PLUGIN_DEFINE(ABIMacOSX_i386)
enum {
dwarf_eax = 0,
@@ -54,653 +41,8 @@ enum {
dwarf_esi,
dwarf_edi,
dwarf_eip,
- dwarf_eflags,
- dwarf_stmm0 = 11,
- dwarf_stmm1,
- dwarf_stmm2,
- dwarf_stmm3,
- dwarf_stmm4,
- dwarf_stmm5,
- dwarf_stmm6,
- dwarf_stmm7,
- 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
};
-static RegisterInfo g_register_infos[] = {
- // NAME ALT SZ OFF ENCODING FORMAT
- // EH_FRAME DWARF GENERIC
- // PROCESS PLUGIN LLDB NATIVE
- // ====== ======= == === ============= ============
- // ===================== ===================== ============================
- // ==================== ======================
- {"eax",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {ehframe_eax, dwarf_eax, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ebx",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {ehframe_ebx, dwarf_ebx, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ecx",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {ehframe_ecx, dwarf_ecx, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"edx",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {ehframe_edx, dwarf_edx, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"esi",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {ehframe_esi, dwarf_esi, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"edi",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {ehframe_edi, dwarf_edi, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ebp",
- "fp",
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {ehframe_ebp, dwarf_ebp, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"esp",
- "sp",
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {ehframe_esp, dwarf_esp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"eip",
- "pc",
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {ehframe_eip, dwarf_eip, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"eflags",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_REGNUM_GENERIC_FLAGS,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"cs",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ss",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ds",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"es",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fs",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"gs",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm0",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_stmm0, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm1",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_stmm1, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm2",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_stmm2, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm3",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_stmm3, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm4",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_stmm4, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm5",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_stmm5, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm6",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_stmm6, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm7",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_stmm7, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fctrl",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fstat",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ftag",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fiseg",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fioff",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"foseg",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fooff",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fop",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm0",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_xmm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm1",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_xmm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm2",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_xmm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm3",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_xmm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm4",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_xmm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm5",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_xmm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm6",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_xmm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm7",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_xmm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"mxcsr",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm0",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_ymm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm1",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_ymm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm2",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_ymm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm3",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_ymm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm4",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_ymm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm5",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_ymm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm6",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_ymm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm7",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, dwarf_ymm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0}};
-
-static const uint32_t k_num_register_infos =
- llvm::array_lengthof(g_register_infos);
-static bool g_register_info_names_constified = false;
-
-const lldb_private::RegisterInfo *
-ABIMacOSX_i386::GetRegisterInfoArray(uint32_t &count) {
- // Make the C-string names and alt_names for the register infos into const
- // C-string values by having the ConstString unique the names in the global
- // constant C-string pool.
- if (!g_register_info_names_constified) {
- g_register_info_names_constified = true;
- for (uint32_t i = 0; i < k_num_register_infos; ++i) {
- if (g_register_infos[i].name)
- g_register_infos[i].name =
- ConstString(g_register_infos[i].name).GetCString();
- if (g_register_infos[i].alt_name)
- g_register_infos[i].alt_name =
- ConstString(g_register_infos[i].alt_name).GetCString();
- }
- }
- count = k_num_register_infos;
- return g_register_infos;
-}
-
size_t ABIMacOSX_i386::GetRedZoneSize() const { return 0; }
// Static Functions
diff --git a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h b/lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.h
index 50062b84d878..b8b253144165 100644
--- a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
+++ b/lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.h
@@ -6,14 +6,14 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ABIMacOSX_i386_h_
-#define liblldb_ABIMacOSX_i386_h_
+#ifndef LLDB_SOURCE_PLUGINS_ABI_X86_ABIMACOSX_I386_H
+#define LLDB_SOURCE_PLUGINS_ABI_X86_ABIMACOSX_I386_H
+#include "Plugins/ABI/X86/ABIX86.h"
#include "lldb/Core/Value.h"
-#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
-class ABIMacOSX_i386 : public lldb_private::ABI {
+class ABIMacOSX_i386 : public ABIX86 {
public:
~ABIMacOSX_i386() override = default;
@@ -45,7 +45,7 @@ public:
//
// To work around this, we relax that alignment to be just word-size
// (4-bytes).
- // Whitelisting the trap handlers for user space would be easy (_sigtramp) but
+ // Allowing 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.
//
@@ -65,9 +65,6 @@ public:
return pc <= UINT32_MAX;
}
- const lldb_private::RegisterInfo *
- GetRegisterInfoArray(uint32_t &count) override;
-
// Static Functions
static void Initialize();
@@ -91,12 +88,13 @@ protected:
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
-private:
- ABIMacOSX_i386(lldb::ProcessSP process_sp,
- std::unique_ptr<llvm::MCRegisterInfo> info_up)
- : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
- // Call CreateInstance instead.
+ std::string GetMCName(std::string name) override {
+ MapRegisterName(name, "stmm", "st");
+ return name;
}
+
+private:
+ using ABIX86::ABIX86; // Call CreateInstance instead.
};
-#endif // liblldb_ABIMacOSX_i386_h_
+#endif // LLDB_SOURCE_PLUGINS_ABI_X86_ABIMACOSX_I386_H
diff --git a/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp b/lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp
index 69e4cff90ebf..2ac87d1512e9 100644
--- a/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
+++ b/lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp
@@ -1,4 +1,4 @@
-//===----------------------- ABISysV_i386.cpp -------------------*- C++ -*-===//
+//===-- ABISysV_i386.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -31,6 +31,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(ABISysV_i386)
+
// This source file uses the following document as a reference:
//====================================================================
// System V Application Binary Interface
@@ -63,135 +65,8 @@ enum dwarf_regnums {
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,
-
- dwarf_bnd0 = 101,
- dwarf_bnd1,
- dwarf_bnd2,
- dwarf_bnd3
-};
-
-static RegisterInfo g_register_infos[] = {
- // clang-format off
- //NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC PROCESS PLUGIN LLDB NATIVE VALUE INVAL DYN EXPR SZ
- //========== ======= == === ============= ==================== =================== =================== ========================= =================== =================== ======= ======= ======== ==
- {"eax", nullptr, 4, 0, eEncodingUint, eFormatHex, {dwarf_eax, dwarf_eax, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ebx", nullptr, 4, 0, eEncodingUint, eFormatHex, {dwarf_ebx, dwarf_ebx, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ecx", nullptr, 4, 0, eEncodingUint, eFormatHex, {dwarf_ecx, dwarf_ecx, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"edx", nullptr, 4, 0, eEncodingUint, eFormatHex, {dwarf_edx, dwarf_edx, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"esi", nullptr, 4, 0, eEncodingUint, eFormatHex, {dwarf_esi, dwarf_esi, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"edi", nullptr, 4, 0, eEncodingUint, eFormatHex, {dwarf_edi, dwarf_edi, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ebp", "fp", 4, 0, eEncodingUint, eFormatHex, {dwarf_ebp, dwarf_ebp, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"esp", "sp", 4, 0, eEncodingUint, eFormatHex, {dwarf_esp, dwarf_esp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"eip", "pc", 4, 0, eEncodingUint, eFormatHex, {dwarf_eip, dwarf_eip, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"eflags", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_REGNUM_GENERIC_FLAGS,LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"cs", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ss", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ds", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"es", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"fs", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"gs", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"st0", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_st0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"st1", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_st1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"st2", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_st2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"st3", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_st3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"st4", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_st4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"st5", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_st5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"st6", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_st6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"st7", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_st7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"fctrl", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"fstat", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ftag", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"fiseg", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"fioff", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"foseg", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"fooff", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"fop", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm0", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_xmm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm1", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_xmm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm2", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_xmm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm3", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_xmm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm4", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_xmm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm5", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_xmm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm6", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_xmm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm7", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_xmm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"mxcsr", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm0", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_ymm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm1", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_ymm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm2", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_ymm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm3", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_ymm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm4", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_ymm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm5", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_ymm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm6", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_ymm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm7", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, dwarf_ymm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"bnd0", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt64,{dwarf_bnd0, dwarf_bnd0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"bnd1", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt64,{dwarf_bnd1, dwarf_bnd1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"bnd2", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt64,{dwarf_bnd2, dwarf_bnd2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"bnd3", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt64,{dwarf_bnd3, dwarf_bnd3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"bndcfgu", nullptr, 8, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"bndstatus",nullptr, 8, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0}
- // clang-format on
};
-static const uint32_t k_num_register_infos =
- llvm::array_lengthof(g_register_infos);
-static bool g_register_info_names_constified = false;
-
-const lldb_private::RegisterInfo *
-ABISysV_i386::GetRegisterInfoArray(uint32_t &count) {
- // Make the C-string names and alt_names for the register infos into const
- // C-string values by having the ConstString unique the names in the global
- // constant C-string pool.
- if (!g_register_info_names_constified) {
- g_register_info_names_constified = true;
- for (uint32_t i = 0; i < k_num_register_infos; ++i) {
- if (g_register_infos[i].name)
- g_register_infos[i].name =
- ConstString(g_register_infos[i].name).GetCString();
- if (g_register_infos[i].alt_name)
- g_register_infos[i].alt_name =
- ConstString(g_register_infos[i].alt_name).GetCString();
- }
- }
- count = k_num_register_infos;
- return g_register_infos;
-}
-
// Static Functions
ABISP
diff --git a/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.h b/lldb/source/Plugins/ABI/X86/ABISysV_i386.h
index 2362e9adda98..1ebb107d36df 100644
--- a/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.h
+++ b/lldb/source/Plugins/ABI/X86/ABISysV_i386.h
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ABISysV_i386_h_
-#define liblldb_ABISysV_i386_h_
+#ifndef LLDB_SOURCE_PLUGINS_ABI_X86_ABISYSV_I386_H
+#define LLDB_SOURCE_PLUGINS_ABI_X86_ABISYSV_I386_H
-#include "lldb/Target/ABI.h"
+#include "Plugins/ABI/X86/ABIX86.h"
#include "lldb/lldb-private.h"
-class ABISysV_i386 : public lldb_private::ABI {
+class ABISysV_i386 : public ABIX86 {
public:
~ABISysV_i386() override = default;
@@ -53,7 +53,7 @@ public:
//
// To work around this, we relax that alignment to be just word-size
// (4-bytes).
- // Whitelisting the trap handlers for user space would be easy (_sigtramp) but
+ // Allowing 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.
@@ -73,9 +73,6 @@ public:
return (pc <= UINT32_MAX);
}
- const lldb_private::RegisterInfo *
- GetRegisterInfoArray(uint32_t &count) override;
-
// Static Functions
static void Initialize();
@@ -100,11 +97,7 @@ protected:
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
private:
- ABISysV_i386(lldb::ProcessSP process_sp,
- std::unique_ptr<llvm::MCRegisterInfo> info_up)
- : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
- // Call CreateInstance instead.
- }
+ using ABIX86::ABIX86; // Call CreateInstance instead.
};
-#endif // liblldb_ABISysV_i386_h_
+#endif // LLDB_SOURCE_PLUGINS_ABI_X86_ABISYSV_I386_H
diff --git a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
index bf1c48f778e1..7729e58f8580 100644
--- a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
+++ b/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
@@ -1,4 +1,4 @@
-//===-- ABISysV_x86_64.cpp --------------------------------------*- C++ -*-===//
+//===-- ABISysV_x86_64.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -35,6 +35,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(ABISysV_x86_64)
+
enum dwarf_regnums {
dwarf_rax = 0,
dwarf_rdx,
@@ -53,162 +55,8 @@ enum dwarf_regnums {
dwarf_r14,
dwarf_r15,
dwarf_rip,
- dwarf_xmm0,
- dwarf_xmm1,
- dwarf_xmm2,
- dwarf_xmm3,
- dwarf_xmm4,
- dwarf_xmm5,
- dwarf_xmm6,
- dwarf_xmm7,
- dwarf_xmm8,
- dwarf_xmm9,
- dwarf_xmm10,
- dwarf_xmm11,
- dwarf_xmm12,
- dwarf_xmm13,
- dwarf_xmm14,
- dwarf_xmm15,
- dwarf_stmm0,
- dwarf_stmm1,
- dwarf_stmm2,
- dwarf_stmm3,
- dwarf_stmm4,
- dwarf_stmm5,
- dwarf_stmm6,
- dwarf_stmm7,
- dwarf_ymm0,
- dwarf_ymm1,
- dwarf_ymm2,
- dwarf_ymm3,
- dwarf_ymm4,
- dwarf_ymm5,
- dwarf_ymm6,
- dwarf_ymm7,
- dwarf_ymm8,
- dwarf_ymm9,
- dwarf_ymm10,
- dwarf_ymm11,
- dwarf_ymm12,
- dwarf_ymm13,
- dwarf_ymm14,
- dwarf_ymm15,
- dwarf_bnd0 = 126,
- dwarf_bnd1,
- dwarf_bnd2,
- dwarf_bnd3
-};
-
-static RegisterInfo g_register_infos[] = {
- // clang-format off
- // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC LLDB NATIVE
- // ======== ======= == === ============= =================== ======================= ===================== =========================== ===================== ======================
- {"rax", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_rax, dwarf_rax, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"rbx", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_rbx, dwarf_rbx, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"rcx", "arg4", 8, 0, eEncodingUint, eFormatHex, {dwarf_rcx, dwarf_rcx, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"rdx", "arg3", 8, 0, eEncodingUint, eFormatHex, {dwarf_rdx, dwarf_rdx, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"rsi", "arg2", 8, 0, eEncodingUint, eFormatHex, {dwarf_rsi, dwarf_rsi, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"rdi", "arg1", 8, 0, eEncodingUint, eFormatHex, {dwarf_rdi, dwarf_rdi, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"rbp", "fp", 8, 0, eEncodingUint, eFormatHex, {dwarf_rbp, dwarf_rbp, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"rsp", "sp", 8, 0, eEncodingUint, eFormatHex, {dwarf_rsp, dwarf_rsp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"r8", "arg5", 8, 0, eEncodingUint, eFormatHex, {dwarf_r8, dwarf_r8, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"r9", "arg6", 8, 0, eEncodingUint, eFormatHex, {dwarf_r9, dwarf_r9, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"r10", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"r11", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"r12", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"r13", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_r13, dwarf_r13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"r14", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_r14, dwarf_r14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"r15", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_r15, dwarf_r15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"rip", "pc", 8, 0, eEncodingUint, eFormatHex, {dwarf_rip, dwarf_rip, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"rflags", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"cs", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ss", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ds", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"es", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"fs", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"gs", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"stmm0", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm0, dwarf_stmm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"stmm1", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm1, dwarf_stmm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"stmm2", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm2, dwarf_stmm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"stmm3", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm3, dwarf_stmm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"stmm4", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm4, dwarf_stmm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"stmm5", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm5, dwarf_stmm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"stmm6", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm6, dwarf_stmm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"stmm7", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm7, dwarf_stmm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"fctrl", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"fstat", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ftag", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"fiseg", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"fioff", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"foseg", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"fooff", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"fop", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm0", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm0, dwarf_xmm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm1", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm1, dwarf_xmm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm2", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm2, dwarf_xmm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm3", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm3, dwarf_xmm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm4", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm4, dwarf_xmm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm5", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm5, dwarf_xmm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm6", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm6, dwarf_xmm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm7", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm7, dwarf_xmm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm8", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm8, dwarf_xmm8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm9", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm9, dwarf_xmm9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm10", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm10, dwarf_xmm10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm11", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm11, dwarf_xmm11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm12", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm12, dwarf_xmm12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm13", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm13, dwarf_xmm13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm14", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm14, dwarf_xmm14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"xmm15", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm15, dwarf_xmm15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"mxcsr", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm0", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm0, dwarf_ymm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm1", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm1, dwarf_ymm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm2", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm2, dwarf_ymm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm3", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm3, dwarf_ymm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm4", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm4, dwarf_ymm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm5", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm5, dwarf_ymm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm6", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm6, dwarf_ymm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm7", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm7, dwarf_ymm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm8", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm8, dwarf_ymm8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm9", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm9, dwarf_ymm9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm10", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm10, dwarf_ymm10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm11", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm11, dwarf_ymm11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm12", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm12, dwarf_ymm12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm13", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm13, dwarf_ymm13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm14", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm14, dwarf_ymm14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"ymm15", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm15, dwarf_ymm15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"bnd0", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt64, {dwarf_bnd0, dwarf_bnd0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"bnd1", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt64, {dwarf_bnd1, dwarf_bnd1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"bnd2", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt64, {dwarf_bnd2, dwarf_bnd2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"bnd3", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt64, {dwarf_bnd3, dwarf_bnd3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"bndcfgu", nullptr, 8, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- {"bndstatus",nullptr, 8, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
- // clang-format on
};
-static const uint32_t k_num_register_infos =
- llvm::array_lengthof(g_register_infos);
-static bool g_register_info_names_constified = false;
-
-const lldb_private::RegisterInfo *
-ABISysV_x86_64::GetRegisterInfoArray(uint32_t &count) {
- // Make the C-string names and alt_names for the register infos into const
- // C-string values by having the ConstString unique the names in the global
- // constant C-string pool.
- if (!g_register_info_names_constified) {
- g_register_info_names_constified = true;
- for (uint32_t i = 0; i < k_num_register_infos; ++i) {
- if (g_register_infos[i].name)
- g_register_infos[i].name =
- ConstString(g_register_infos[i].name).GetCString();
- if (g_register_infos[i].alt_name)
- g_register_infos[i].alt_name =
- ConstString(g_register_infos[i].alt_name).GetCString();
- }
- }
- count = k_num_register_infos;
- return g_register_infos;
-}
-
bool ABISysV_x86_64::GetPointerReturnRegister(const char *&name) {
name = "rax";
return true;
@@ -1078,6 +926,21 @@ bool ABISysV_x86_64::RegisterIsCalleeSaved(const RegisterInfo *reg_info) {
return IsCalleeSaved;
}
+uint32_t ABISysV_x86_64::GetGenericNum(llvm::StringRef name) {
+ return llvm::StringSwitch<uint32_t>(name)
+ .Case("rip", LLDB_REGNUM_GENERIC_PC)
+ .Case("rsp", LLDB_REGNUM_GENERIC_SP)
+ .Case("rbp", LLDB_REGNUM_GENERIC_FP)
+ .Case("rflags", LLDB_REGNUM_GENERIC_FLAGS)
+ .Case("rdi", LLDB_REGNUM_GENERIC_ARG1)
+ .Case("rsi", LLDB_REGNUM_GENERIC_ARG2)
+ .Case("rdx", LLDB_REGNUM_GENERIC_ARG3)
+ .Case("rcx", LLDB_REGNUM_GENERIC_ARG4)
+ .Case("r8", LLDB_REGNUM_GENERIC_ARG5)
+ .Case("r9", LLDB_REGNUM_GENERIC_ARG6)
+ .Default(LLDB_INVALID_REGNUM);
+}
+
void ABISysV_x86_64::Initialize() {
PluginManager::RegisterPlugin(
GetPluginNameStatic(), "System V ABI for x86_64 targets", CreateInstance);
diff --git a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h b/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.h
index d445d8f4142a..6dce4ce0f012 100644
--- a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h
+++ b/lldb/source/Plugins/ABI/X86/ABISysV_x86_64.h
@@ -6,13 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ABISysV_x86_64_h_
-#define liblldb_ABISysV_x86_64_h_
+#ifndef LLDB_SOURCE_PLUGINS_ABI_X86_ABISYSV_X86_64_H
+#define LLDB_SOURCE_PLUGINS_ABI_X86_ABISYSV_X86_64_H
-#include "lldb/Target/ABI.h"
-#include "lldb/lldb-private.h"
+#include "Plugins/ABI/X86/ABIX86_64.h"
-class ABISysV_x86_64 : public lldb_private::ABI {
+class ABISysV_x86_64 : public ABIX86_64 {
public:
~ABISysV_x86_64() override = default;
@@ -49,7 +48,7 @@ public:
//
// To work around this, we relax that alignment to be just word-size
// (8-bytes).
- // Whitelisting the trap handlers for user space would be easy (_sigtramp) but
+ // Allowing 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 {
@@ -67,9 +66,6 @@ public:
return true;
}
- const lldb_private::RegisterInfo *
- GetRegisterInfoArray(uint32_t &count) override;
-
bool GetPointerReturnRegister(const char *&name) override;
// Static Functions
@@ -96,13 +92,10 @@ protected:
lldb_private::CompilerType &ast_type) const;
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
+ uint32_t GetGenericNum(llvm::StringRef reg) override;
private:
- ABISysV_x86_64(lldb::ProcessSP process_sp,
- std::unique_ptr<llvm::MCRegisterInfo> info_up)
- : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
- // Call CreateInstance instead.
- }
+ using ABIX86_64::ABIX86_64; // Call CreateInstance instead.
};
-#endif // liblldb_ABISysV_x86_64_h_
+#endif // LLDB_SOURCE_PLUGINS_ABI_X86_ABISYSV_X86_64_H
diff --git a/lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp b/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp
index ac24426914e1..63b670b07277 100644
--- a/lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp
+++ b/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp
@@ -1,4 +1,4 @@
-//===-- ABIWindows_x86_64.cpp --------------------------------------*- C++ -*-===//
+//===-- ABIWindows_x86_64.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -33,6 +33,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(ABIWindows_x86_64)
+
enum dwarf_regnums {
dwarf_rax = 0,
dwarf_rdx,
@@ -97,986 +99,6 @@ enum dwarf_regnums {
dwarf_bnd3
};
-static RegisterInfo g_register_infos[] = {
- // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME
- // DWARF GENERIC PROCESS PLUGIN
- // LLDB NATIVE
- // ======== ======= == === ============= ===================
- // ======================= =====================
- // =========================== ===================== ======================
- {"rax",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rax, dwarf_rax, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"rbx",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rbx, dwarf_rbx, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"rcx",
- "arg1",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rcx, dwarf_rcx, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"rdx",
- "arg2",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rdx, dwarf_rdx, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"rsi",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rsi, dwarf_rsi, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"rdi",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rdi, dwarf_rdi, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"rbp",
- "fp",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rbp, dwarf_rbp, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"rsp",
- "sp",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rsp, dwarf_rsp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"r8",
- "arg3",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r8, dwarf_r8, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"r9",
- "arg4",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r9, dwarf_r9, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"r10",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"r11",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"r12",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"r13",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r13, dwarf_r13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"r14",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r14, dwarf_r14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"r15",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r15, dwarf_r15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"rip",
- "pc",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rip, dwarf_rip, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"rflags",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_REGNUM_GENERIC_FLAGS,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"cs",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ss",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ds",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"es",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fs",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"gs",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm0",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_stmm0, dwarf_stmm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm1",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_stmm1, dwarf_stmm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm2",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_stmm2, dwarf_stmm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm3",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_stmm3, dwarf_stmm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm4",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_stmm4, dwarf_stmm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm5",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_stmm5, dwarf_stmm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm6",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_stmm6, dwarf_stmm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm7",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_stmm7, dwarf_stmm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fctrl",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fstat",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ftag",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fiseg",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fioff",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"foseg",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fooff",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fop",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm0",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm0, dwarf_xmm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm1",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm1, dwarf_xmm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm2",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm2, dwarf_xmm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm3",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm3, dwarf_xmm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm4",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm4, dwarf_xmm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm5",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm5, dwarf_xmm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm6",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm6, dwarf_xmm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm7",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm7, dwarf_xmm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm8",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm8, dwarf_xmm8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm9",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm9, dwarf_xmm9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm10",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm10, dwarf_xmm10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm11",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm11, dwarf_xmm11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm12",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm12, dwarf_xmm12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm13",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm13, dwarf_xmm13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm14",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm14, dwarf_xmm14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm15",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm15, dwarf_xmm15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"mxcsr",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm0",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm0, dwarf_ymm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm1",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm1, dwarf_ymm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm2",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm2, dwarf_ymm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm3",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm3, dwarf_ymm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm4",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm4, dwarf_ymm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm5",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm5, dwarf_ymm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm6",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm6, dwarf_ymm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm7",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm7, dwarf_ymm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm8",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm8, dwarf_ymm8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm9",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm9, dwarf_ymm9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm10",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm10, dwarf_ymm10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm11",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm11, dwarf_ymm11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm12",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm12, dwarf_ymm12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm13",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm13, dwarf_ymm13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm14",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm14, dwarf_ymm14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm15",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm15, dwarf_ymm15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"bnd0",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt64,
- {dwarf_bnd0, dwarf_bnd0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"bnd1",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt64,
- {dwarf_bnd1, dwarf_bnd1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"bnd2",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt64,
- {dwarf_bnd2, dwarf_bnd2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"bnd3",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt64,
- {dwarf_bnd3, dwarf_bnd3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"bndcfgu",
- nullptr,
- 8,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"bndstatus",
- nullptr,
- 8,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0}};
-
-static const uint32_t k_num_register_infos =
- llvm::array_lengthof(g_register_infos);
-static bool g_register_info_names_constified = false;
-
-const lldb_private::RegisterInfo *
-ABIWindows_x86_64::GetRegisterInfoArray(uint32_t &count) {
- // Make the C-string names and alt_names for the register infos into const
- // C-string values by having the ConstString unique the names in the global
- // constant C-string pool.
- if (!g_register_info_names_constified) {
- g_register_info_names_constified = true;
- for (uint32_t i = 0; i < k_num_register_infos; ++i) {
- if (g_register_infos[i].name)
- g_register_infos[i].name =
- ConstString(g_register_infos[i].name).GetCString();
- if (g_register_infos[i].alt_name)
- g_register_infos[i].alt_name =
- ConstString(g_register_infos[i].alt_name).GetCString();
- }
- }
- count = k_num_register_infos;
- return g_register_infos;
-}
-
bool ABIWindows_x86_64::GetPointerReturnRegister(const char *&name) {
name = "rax";
return true;
@@ -1777,6 +799,19 @@ bool ABIWindows_x86_64::RegisterIsCalleeSaved(const RegisterInfo *reg_info) {
return IsCalleeSaved;
}
+uint32_t ABIWindows_x86_64::GetGenericNum(llvm::StringRef reg) {
+ return llvm::StringSwitch<uint32_t>(reg)
+ .Case("rip", LLDB_REGNUM_GENERIC_PC)
+ .Case("rsp", LLDB_REGNUM_GENERIC_SP)
+ .Case("rbp", LLDB_REGNUM_GENERIC_FP)
+ .Case("rflags", LLDB_REGNUM_GENERIC_FLAGS)
+ .Case("rcx", LLDB_REGNUM_GENERIC_ARG1)
+ .Case("rdx", LLDB_REGNUM_GENERIC_ARG2)
+ .Case("r8", LLDB_REGNUM_GENERIC_ARG3)
+ .Case("r9", LLDB_REGNUM_GENERIC_ARG4)
+ .Default(LLDB_INVALID_REGNUM);
+}
+
void ABIWindows_x86_64::Initialize() {
PluginManager::RegisterPlugin(
GetPluginNameStatic(), "Windows ABI for x86_64 targets", CreateInstance);
diff --git a/lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h b/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.h
index 2366566d7809..89fc6e6ca21f 100644
--- a/lldb/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
+++ b/lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.h
@@ -6,13 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ABIWindows_x86_64_h_
-#define liblldb_ABIWindows_x86_64_h_
+#ifndef LLDB_SOURCE_PLUGINS_ABI_X86_ABIWINDOWS_X86_64_H
+#define LLDB_SOURCE_PLUGINS_ABI_X86_ABIWINDOWS_X86_64_H
-#include "lldb/Target/ABI.h"
-#include "lldb/lldb-private.h"
+#include "Plugins/ABI/X86/ABIX86_64.h"
-class ABIWindows_x86_64 : public lldb_private::ABI {
+class ABIWindows_x86_64 : public ABIX86_64 {
public:
~ABIWindows_x86_64() override = default;
@@ -56,9 +55,6 @@ public:
return true;
}
- const lldb_private::RegisterInfo *
- GetRegisterInfoArray(uint32_t &count) override;
-
bool GetPointerReturnRegister(const char *&name) override;
//------------------------------------------------------------------
@@ -89,13 +85,10 @@ protected:
lldb_private::CompilerType &ast_type) const;
bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
+ uint32_t GetGenericNum(llvm::StringRef reg) override;
private:
- ABIWindows_x86_64(lldb::ProcessSP process_sp,
- std::unique_ptr<llvm::MCRegisterInfo> info_up)
- : lldb_private::ABI(std::move(process_sp), std::move(info_up)) {
- // Call CreateInstance instead.
- }
+ using ABIX86_64::ABIX86_64; // Call CreateInstance instead.
};
-#endif // liblldb_ABISysV_x86_64_h_
+#endif // LLDB_SOURCE_PLUGINS_ABI_X86_ABIWINDOWS_X86_64_H
diff --git a/lldb/source/Plugins/ABI/X86/ABIX86.cpp b/lldb/source/Plugins/ABI/X86/ABIX86.cpp
new file mode 100644
index 000000000000..bf5ab669417e
--- /dev/null
+++ b/lldb/source/Plugins/ABI/X86/ABIX86.cpp
@@ -0,0 +1,43 @@
+//===-- X86.h -------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "ABIX86.h"
+#include "ABIMacOSX_i386.h"
+#include "ABISysV_i386.h"
+#include "ABISysV_x86_64.h"
+#include "ABIWindows_x86_64.h"
+#include "lldb/Core/PluginManager.h"
+
+LLDB_PLUGIN_DEFINE(ABIX86)
+
+void ABIX86::Initialize() {
+ ABIMacOSX_i386::Initialize();
+ ABISysV_i386::Initialize();
+ ABISysV_x86_64::Initialize();
+ ABIWindows_x86_64::Initialize();
+}
+
+void ABIX86::Terminate() {
+ ABIMacOSX_i386::Terminate();
+ ABISysV_i386::Terminate();
+ ABISysV_x86_64::Terminate();
+ ABIWindows_x86_64::Terminate();
+}
+
+uint32_t ABIX86::GetGenericNum(llvm::StringRef name) {
+ return llvm::StringSwitch<uint32_t>(name)
+ .Case("eip", LLDB_REGNUM_GENERIC_PC)
+ .Case("esp", LLDB_REGNUM_GENERIC_SP)
+ .Case("ebp", LLDB_REGNUM_GENERIC_FP)
+ .Case("eflags", LLDB_REGNUM_GENERIC_FLAGS)
+ .Case("edi", LLDB_REGNUM_GENERIC_ARG1)
+ .Case("esi", LLDB_REGNUM_GENERIC_ARG2)
+ .Case("edx", LLDB_REGNUM_GENERIC_ARG3)
+ .Case("ecx", LLDB_REGNUM_GENERIC_ARG4)
+ .Default(LLDB_INVALID_REGNUM);
+}
diff --git a/lldb/source/Plugins/ABI/X86/ABIX86.h b/lldb/source/Plugins/ABI/X86/ABIX86.h
new file mode 100644
index 000000000000..22521cacf180
--- /dev/null
+++ b/lldb/source/Plugins/ABI/X86/ABIX86.h
@@ -0,0 +1,24 @@
+//===-- X86.h ---------------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_ABI_X86_ABIX86_H
+#define LLDB_SOURCE_PLUGINS_ABI_X86_ABIX86_H
+
+#include "lldb/Target/ABI.h"
+
+class ABIX86 : public lldb_private::MCBasedABI {
+public:
+ static void Initialize();
+ static void Terminate();
+
+ uint32_t GetGenericNum(llvm::StringRef name) override;
+
+private:
+ using lldb_private::MCBasedABI::MCBasedABI;
+};
+#endif
diff --git a/lldb/source/Plugins/ABI/X86/ABIX86_64.h b/lldb/source/Plugins/ABI/X86/ABIX86_64.h
new file mode 100644
index 000000000000..e65c2d97d897
--- /dev/null
+++ b/lldb/source/Plugins/ABI/X86/ABIX86_64.h
@@ -0,0 +1,26 @@
+//===-- ABIX86_64.h ---------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_ABI_X86_ABIX86_64_H
+#define LLDB_SOURCE_PLUGINS_ABI_X86_ABIX86_64_H
+
+#include "lldb/Target/ABI.h"
+#include "lldb/lldb-private.h"
+
+class ABIX86_64 : public lldb_private::MCBasedABI {
+protected:
+ std::string GetMCName(std::string name) override {
+ MapRegisterName(name, "stmm", "st");
+ return name;
+ }
+
+private:
+ using lldb_private::MCBasedABI::MCBasedABI;
+};
+
+#endif // LLDB_SOURCE_PLUGINS_ABI_X86_ABIX86_64_H
diff --git a/lldb/source/Plugins/Architecture/Arm/ArchitectureArm.cpp b/lldb/source/Plugins/Architecture/Arm/ArchitectureArm.cpp
index 5b86df6c5273..58c7cbb4530a 100644
--- a/lldb/source/Plugins/Architecture/Arm/ArchitectureArm.cpp
+++ b/lldb/source/Plugins/Architecture/Arm/ArchitectureArm.cpp
@@ -1,4 +1,4 @@
-//===-- ArchitectureArm.cpp -------------------------------------*- C++ -*-===//
+//===-- ArchitectureArm.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -17,6 +17,8 @@
using namespace lldb_private;
using namespace lldb;
+LLDB_PLUGIN_DEFINE(ArchitectureArm)
+
ConstString ArchitectureArm::GetPluginNameStatic() {
return ConstString("arm");
}
diff --git a/lldb/source/Plugins/Architecture/Arm/ArchitectureArm.h b/lldb/source/Plugins/Architecture/Arm/ArchitectureArm.h
index 03e79ce524a7..36b79c7c01a1 100644
--- a/lldb/source/Plugins/Architecture/Arm/ArchitectureArm.h
+++ b/lldb/source/Plugins/Architecture/Arm/ArchitectureArm.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_PLUGIN_ARCHITECTURE_ARM_H
-#define LLDB_PLUGIN_ARCHITECTURE_ARM_H
+#ifndef LLDB_SOURCE_PLUGINS_ARCHITECTURE_ARM_ARCHITECTUREARM_H
+#define LLDB_SOURCE_PLUGINS_ARCHITECTURE_ARM_ARCHITECTUREARM_H
#include "lldb/Core/Architecture.h"
@@ -37,4 +37,4 @@ private:
} // namespace lldb_private
-#endif // LLDB_PLUGIN_ARCHITECTURE_ARM_H
+#endif // LLDB_SOURCE_PLUGINS_ARCHITECTURE_ARM_ARCHITECTUREARM_H
diff --git a/lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp b/lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp
index 5f2f6eeb8261..22508969ceed 100644
--- a/lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp
+++ b/lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp
@@ -1,4 +1,4 @@
-//===-- ArchitectureMips.cpp -------------------------------------*- C++ -*-===//
+//===-- ArchitectureMips.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -21,6 +21,8 @@
using namespace lldb_private;
using namespace lldb;
+LLDB_PLUGIN_DEFINE(ArchitectureMips)
+
ConstString ArchitectureMips::GetPluginNameStatic() {
return ConstString("mips");
}
@@ -118,9 +120,7 @@ lldb::addr_t ArchitectureMips::GetBreakableLoadAddress(lldb::addr_t addr,
if (current_offset == 0)
return addr;
- ExecutionContext ctx;
- target.CalculateExecutionContext(ctx);
- auto insn = GetInstructionAtAddress(ctx, current_offset, addr);
+ auto insn = GetInstructionAtAddress(target, current_offset, addr);
if (nullptr == insn || !insn->HasDelaySlot())
return addr;
@@ -136,8 +136,7 @@ lldb::addr_t ArchitectureMips::GetBreakableLoadAddress(lldb::addr_t addr,
}
Instruction *ArchitectureMips::GetInstructionAtAddress(
- const ExecutionContext &exe_ctx, const Address &resolved_addr,
- addr_t symbol_offset) const {
+ Target &target, const Address &resolved_addr, addr_t symbol_offset) const {
auto loop_count = symbol_offset / 2;
@@ -169,10 +168,11 @@ Instruction *ArchitectureMips::GetInstructionAtAddress(
for (uint32_t i = 1; i <= loop_count; i++) {
// Adjust the address to read from.
addr.Slide(-2);
- AddressRange range(addr, i * 2);
uint32_t insn_size = 0;
- disasm_sp->ParseInstructions(&exe_ctx, range, nullptr, prefer_file_cache);
+ disasm_sp->ParseInstructions(target, addr,
+ {Disassembler::Limit::Bytes, i * 2}, nullptr,
+ prefer_file_cache);
uint32_t num_insns = disasm_sp->GetInstructionList().GetSize();
if (num_insns) {
diff --git a/lldb/source/Plugins/Architecture/Mips/ArchitectureMips.h b/lldb/source/Plugins/Architecture/Mips/ArchitectureMips.h
index a15991ff9ebf..71ee60184b69 100644
--- a/lldb/source/Plugins/Architecture/Mips/ArchitectureMips.h
+++ b/lldb/source/Plugins/Architecture/Mips/ArchitectureMips.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_PLUGIN_ARCHITECTURE_MIPS_H
-#define LLDB_PLUGIN_ARCHITECTURE_MIPS_H
+#ifndef LLDB_SOURCE_PLUGINS_ARCHITECTURE_MIPS_ARCHITECTUREMIPS_H
+#define LLDB_SOURCE_PLUGINS_ARCHITECTURE_MIPS_ARCHITECTUREMIPS_H
#include "lldb/Core/Architecture.h"
#include "lldb/Utility/ArchSpec.h"
@@ -35,11 +35,10 @@ public:
AddressClass addr_class) const override;
private:
- Instruction *GetInstructionAtAddress(const ExecutionContext &exe_ctx,
+ Instruction *GetInstructionAtAddress(Target &target,
const Address &resolved_addr,
lldb::addr_t symbol_offset) const;
-
static std::unique_ptr<Architecture> Create(const ArchSpec &arch);
ArchitectureMips(const ArchSpec &arch) : m_arch(arch) {}
@@ -48,4 +47,4 @@ private:
} // namespace lldb_private
-#endif // LLDB_PLUGIN_ARCHITECTURE_MIPS_H
+#endif // LLDB_SOURCE_PLUGINS_ARCHITECTURE_MIPS_ARCHITECTUREMIPS_H
diff --git a/lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp b/lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp
index 76eaa44546eb..94301ecf052c 100644
--- a/lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp
+++ b/lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp
@@ -1,4 +1,4 @@
-//===-- ArchitecturePPC64.cpp -----------------------------------*- C++ -*-===//
+//===-- ArchitecturePPC64.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -20,6 +20,8 @@
using namespace lldb_private;
using namespace lldb;
+LLDB_PLUGIN_DEFINE(ArchitecturePPC64)
+
ConstString ArchitecturePPC64::GetPluginNameStatic() {
return ConstString("ppc64");
}
diff --git a/lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.h b/lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.h
index dc663b849c4a..25210d37e53a 100644
--- a/lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.h
+++ b/lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_PLUGIN_ARCHITECTURE_PPC64_H
-#define LLDB_PLUGIN_ARCHITECTURE_PPC64_H
+#ifndef LLDB_SOURCE_PLUGINS_ARCHITECTURE_PPC64_ARCHITECTUREPPC64_H
+#define LLDB_SOURCE_PLUGINS_ARCHITECTURE_PPC64_ARCHITECTUREPPC64_H
#include "lldb/Core/Architecture.h"
@@ -38,4 +38,4 @@ private:
} // namespace lldb_private
-#endif // LLDB_PLUGIN_ARCHITECTURE_PPC64_H
+#endif // LLDB_SOURCE_PLUGINS_ARCHITECTURE_PPC64_ARCHITECTUREPPC64_H
diff --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
index dbdb3520087e..6427d8d176c8 100644
--- a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
+++ b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
@@ -1,4 +1,4 @@
-//===-- DisassemblerLLVMC.cpp -----------------------------------*- C++ -*-===//
+//===-- DisassemblerLLVMC.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -43,6 +43,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(DisassemblerLLVMC)
+
class DisassemblerLLVMC::MCDisasmInstance {
public:
static std::unique_ptr<MCDisasmInstance>
@@ -86,76 +88,18 @@ public:
: Instruction(address, addr_class),
m_disasm_wp(std::static_pointer_cast<DisassemblerLLVMC>(
disasm.shared_from_this())),
- m_does_branch(eLazyBoolCalculate), m_has_delay_slot(eLazyBoolCalculate),
- m_is_call(eLazyBoolCalculate), m_is_valid(false),
m_using_file_addr(false) {}
~InstructionLLVMC() override = default;
bool DoesBranch() override {
- if (m_does_branch == eLazyBoolCalculate) {
- DisassemblerScope disasm(*this);
- if (disasm) {
- DataExtractor data;
- if (m_opcode.GetData(data)) {
- bool is_alternate_isa;
- lldb::addr_t pc = m_address.GetFileAddress();
-
- DisassemblerLLVMC::MCDisasmInstance *mc_disasm_ptr =
- GetDisasmToUse(is_alternate_isa, disasm);
- 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);
- // Be conservative, if we didn't understand the instruction, say it
- // might branch...
- if (inst_size == 0)
- m_does_branch = eLazyBoolYes;
- else {
- const bool can_branch = mc_disasm_ptr->CanBranch(inst);
- if (can_branch)
- m_does_branch = eLazyBoolYes;
- else
- m_does_branch = eLazyBoolNo;
- }
- }
- }
- }
- return m_does_branch == eLazyBoolYes;
+ VisitInstruction();
+ return m_does_branch;
}
bool HasDelaySlot() override {
- if (m_has_delay_slot == eLazyBoolCalculate) {
- DisassemblerScope disasm(*this);
- if (disasm) {
- DataExtractor data;
- if (m_opcode.GetData(data)) {
- bool is_alternate_isa;
- lldb::addr_t pc = m_address.GetFileAddress();
-
- DisassemblerLLVMC::MCDisasmInstance *mc_disasm_ptr =
- GetDisasmToUse(is_alternate_isa, disasm);
- 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;
- }
- }
- }
- }
- return m_has_delay_slot == eLazyBoolYes;
+ VisitInstruction();
+ return m_has_delay_slot;
}
DisassemblerLLVMC::MCDisasmInstance *GetDisasmToUse(bool &is_alternate_isa) {
@@ -367,16 +311,8 @@ public:
}
break;
}
- m_mnemonics = mnemonic_strm.GetString();
+ m_mnemonics = std::string(mnemonic_strm.GetString());
return;
- } else {
- if (m_does_branch == eLazyBoolCalculate) {
- const bool can_branch = mc_disasm_ptr->CanBranch(inst);
- if (can_branch)
- m_does_branch = eLazyBoolYes;
- else
- m_does_branch = eLazyBoolNo;
- }
}
static RegularExpression s_regex(
@@ -774,7 +710,7 @@ public:
s.PutCString(")");
break;
case Operand::Type::Register:
- s.PutCString(op.m_register.AsCString());
+ s.PutCString(op.m_register.GetStringRef());
break;
case Operand::Type::Sum:
s.PutCString("(");
@@ -866,42 +802,54 @@ public:
}
bool IsCall() override {
- if (m_is_call == eLazyBoolCalculate) {
- DisassemblerScope disasm(*this);
- if (disasm) {
- DataExtractor data;
- if (m_opcode.GetData(data)) {
- bool is_alternate_isa;
- lldb::addr_t pc = m_address.GetFileAddress();
-
- DisassemblerLLVMC::MCDisasmInstance *mc_disasm_ptr =
- GetDisasmToUse(is_alternate_isa, disasm);
- 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 (inst_size == 0) {
- m_is_call = eLazyBoolNo;
- } else {
- if (mc_disasm_ptr->IsCall(inst))
- m_is_call = eLazyBoolYes;
- else
- m_is_call = eLazyBoolNo;
- }
- }
- }
- }
- return m_is_call == eLazyBoolYes;
+ VisitInstruction();
+ return m_is_call;
}
protected:
std::weak_ptr<DisassemblerLLVMC> m_disasm_wp;
- LazyBool m_does_branch;
- LazyBool m_has_delay_slot;
- LazyBool m_is_call;
- bool m_is_valid;
+
+ bool m_is_valid = false;
bool m_using_file_addr;
+ bool m_has_visited_instruction = false;
+
+ // Be conservative. If we didn't understand the instruction, say it:
+ // - Might branch
+ // - Does not have a delay slot
+ // - Is not a call
+ bool m_does_branch = true;
+ bool m_has_delay_slot = false;
+ bool m_is_call = false;
+
+ void VisitInstruction() {
+ if (m_has_visited_instruction)
+ return;
+
+ DisassemblerScope disasm(*this);
+ if (!disasm)
+ return;
+
+ DataExtractor data;
+ if (!m_opcode.GetData(data))
+ return;
+
+ bool is_alternate_isa;
+ lldb::addr_t pc = m_address.GetFileAddress();
+ DisassemblerLLVMC::MCDisasmInstance *mc_disasm_ptr =
+ GetDisasmToUse(is_alternate_isa, disasm);
+ 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 (inst_size == 0)
+ return;
+
+ m_has_visited_instruction = true;
+ m_does_branch = mc_disasm_ptr->CanBranch(inst);
+ m_has_delay_slot = mc_disasm_ptr->HasDelaySlot(inst);
+ m_is_call = mc_disasm_ptr->IsCall(inst);
+ }
private:
DisassemblerLLVMC::MCDisasmInstance *
@@ -1414,7 +1362,7 @@ const char *DisassemblerLLVMC::SymbolLookup(uint64_t value, uint64_t *type_ptr,
// If Address::Dump returned a multi-line description, most commonly
// seen when we have multiple levels of inlined functions at an
// address, only show the first line.
- std::string str = ss.GetString();
+ std::string str = std::string(ss.GetString());
size_t first_eol_char = str.find_first_of("\r\n");
if (first_eol_char != std::string::npos) {
str.erase(first_eol_char);
diff --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h
index fd5775056d33..9b3741bdd18f 100644
--- a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h
+++ b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DisassemblerLLVMC_h_
-#define liblldb_DisassemblerLLVMC_h_
+#ifndef LLDB_SOURCE_PLUGINS_DISASSEMBLER_LLVMC_DISASSEMBLERLLVMC_H
+#define LLDB_SOURCE_PLUGINS_DISASSEMBLER_LLVMC_DISASSEMBLERLLVMC_H
#include <memory>
#include <mutex>
@@ -82,4 +82,4 @@ protected:
std::unique_ptr<MCDisasmInstance> m_alternate_disasm_up;
};
-#endif // liblldb_DisassemblerLLVM_h_
+#endif // LLDB_SOURCE_PLUGINS_DISASSEMBLER_LLVMC_DISASSEMBLERLLVMC_H
diff --git a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
index 5b19647a27ba..fe86b2929073 100644
--- a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
@@ -1,4 +1,4 @@
-//===-- DynamicLoaderHexagonDYLD.cpp ----------------------------*- C++ -*-===//
+//===-- DynamicLoaderHexagonDYLD.cpp --------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -25,6 +25,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(DynamicLoaderHexagonDYLD)
+
// Aidan 21/05/2014
//
// Notes about hexagon dynamic loading:
@@ -418,8 +420,8 @@ DynamicLoaderHexagonDYLD::GetStepThroughTrampolinePlan(Thread &thread,
if (sym == nullptr || !sym->IsTrampoline())
return thread_plan_sp;
- const ConstString sym_name = sym->GetMangled().GetName(
- lldb::eLanguageTypeUnknown, Mangled::ePreferMangled);
+ const ConstString sym_name =
+ sym->GetMangled().GetName(Mangled::ePreferMangled);
if (!sym_name)
return thread_plan_sp;
diff --git a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h
index c171513c5499..2d39ce06a8d9 100644
--- a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h
+++ b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DynamicLoaderHexagonDYLD_h_
-#define liblldb_DynamicLoaderHexagonDYLD_h_
+#ifndef LLDB_SOURCE_PLUGINS_DYNAMICLOADER_HEXAGON_DYLD_DYNAMICLOADERHEXAGONDYLD_H
+#define LLDB_SOURCE_PLUGINS_DYNAMICLOADER_HEXAGON_DYLD_DYNAMICLOADERHEXAGONDYLD_H
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Target/DynamicLoader.h"
@@ -132,7 +132,9 @@ private:
const lldb_private::SectionList *
GetSectionListFromModule(const lldb::ModuleSP module) const;
- DISALLOW_COPY_AND_ASSIGN(DynamicLoaderHexagonDYLD);
+ DynamicLoaderHexagonDYLD(const DynamicLoaderHexagonDYLD &) = delete;
+ const DynamicLoaderHexagonDYLD &
+ operator=(const DynamicLoaderHexagonDYLD &) = delete;
};
-#endif // liblldb_DynamicLoaderHexagonDYLD_h_
+#endif // LLDB_SOURCE_PLUGINS_DYNAMICLOADER_HEXAGON_DYLD_DYNAMICLOADERHEXAGONDYLD_H
diff --git a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
index f4788816d4ea..af76056af684 100644
--- a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
@@ -1,4 +1,4 @@
-//===-- HexagonDYLDRendezvous.cpp -------------------------------*- C++ -*-===//
+//===-- HexagonDYLDRendezvous.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
index 70fc12b7fab7..5707f8858f6c 100644
--- a/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
+++ b/lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_HexagonDYLDRendezvous_H_
-#define liblldb_HexagonDYLDRendezvous_H_
+#ifndef LLDB_SOURCE_PLUGINS_DYNAMICLOADER_HEXAGON_DYLD_HEXAGONDYLDRENDEZVOUS_H
+#define LLDB_SOURCE_PLUGINS_DYNAMICLOADER_HEXAGON_DYLD_HEXAGONDYLDRENDEZVOUS_H
#include <limits.h>
#include <list>
@@ -243,4 +243,4 @@ protected:
bool FindMetadata(const char *name, PThreadField field, uint32_t &value);
};
-#endif // liblldb_HexagonDYLDRendezvous_H_
+#endif // LLDB_SOURCE_PLUGINS_DYNAMICLOADER_HEXAGON_DYLD_HEXAGONDYLDRENDEZVOUS_H
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
index 737599303a60..15b3805003a5 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -1,4 +1,4 @@
-//===-- DYLDRendezvous.cpp --------------------------------------*- C++ -*-===//
+//===-- DYLDRendezvous.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
index 536eeeaaf334..b028120eb0d4 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Rendezvous_H_
-#define liblldb_Rendezvous_H_
+#ifndef LLDB_SOURCE_PLUGINS_DYNAMICLOADER_POSIX_DYLD_DYLDRENDEZVOUS_H
+#define LLDB_SOURCE_PLUGINS_DYNAMICLOADER_POSIX_DYLD_DYLDRENDEZVOUS_H
#include <list>
#include <string>
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index 9d61c8feb923..ac60af5336ed 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -1,4 +1,4 @@
-//===-- DynamicLoaderPOSIXDYLD.cpp ------------------------------*- C++ -*-===//
+//===-- DynamicLoaderPOSIXDYLD.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -29,6 +29,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE_ADV(DynamicLoaderPOSIXDYLD, DynamicLoaderPosixDYLD)
+
void DynamicLoaderPOSIXDYLD::Initialize() {
PluginManager::RegisterPlugin(GetPluginNameStatic(),
GetPluginDescriptionStatic(), CreateInstance);
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
index 0630d1eb11d1..a7fcdfbadeaf 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DynamicLoaderPOSIXDYLD_h_
-#define liblldb_DynamicLoaderPOSIXDYLD_h_
+#ifndef LLDB_SOURCE_PLUGINS_DYNAMICLOADER_POSIX_DYLD_DYNAMICLOADERPOSIXDYLD_H
+#define LLDB_SOURCE_PLUGINS_DYNAMICLOADER_POSIX_DYLD_DYNAMICLOADERPOSIXDYLD_H
#include <map>
#include <memory>
@@ -136,7 +136,7 @@ protected:
void LoadVDSO();
- // Loading an interpreter module (if present) assumming m_interpreter_base
+ // Loading an interpreter module (if present) assuming m_interpreter_base
// already points to its base address.
lldb::ModuleSP LoadInterpreterModule();
@@ -159,7 +159,9 @@ protected:
bool AlwaysRelyOnEHUnwindInfo(lldb_private::SymbolContext &sym_ctx) override;
private:
- DISALLOW_COPY_AND_ASSIGN(DynamicLoaderPOSIXDYLD);
+ DynamicLoaderPOSIXDYLD(const DynamicLoaderPOSIXDYLD &) = delete;
+ const DynamicLoaderPOSIXDYLD &
+ operator=(const DynamicLoaderPOSIXDYLD &) = delete;
};
-#endif // liblldb_DynamicLoaderPOSIXDYLD_h_
+#endif // LLDB_SOURCE_PLUGINS_DYNAMICLOADER_POSIX_DYLD_DYNAMICLOADERPOSIXDYLD_H
diff --git a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
index 6bc951c4d35b..48762fe6e0c3 100644
--- a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
@@ -1,4 +1,4 @@
-//===-- DynamicLoaderStatic.cpp ---------------------------------*- C++ -*-===//
+//===-- DynamicLoaderStatic.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -17,6 +17,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(DynamicLoaderStatic)
+
// Create an instance of this class. This function is filled into the plugin
// info class that gets handed out by the plugin factory and allows the lldb to
// instantiate an instance of this class.
@@ -27,8 +29,19 @@ DynamicLoader *DynamicLoaderStatic::CreateInstance(Process *process,
const llvm::Triple &triple_ref =
process->GetTarget().GetArchitecture().GetTriple();
const llvm::Triple::OSType os_type = triple_ref.getOS();
- if ((os_type == llvm::Triple::UnknownOS))
- create = true;
+ const llvm::Triple::ArchType arch_type = triple_ref.getArch();
+ if (os_type == llvm::Triple::UnknownOS) {
+ // The WASM and Hexagon plugin check the ArchType rather than the OSType,
+ // so explicitly reject those here.
+ switch(arch_type) {
+ case llvm::Triple::hexagon:
+ case llvm::Triple::wasm32:
+ case llvm::Triple::wasm64:
+ break;
+ default:
+ create = true;
+ }
+ }
}
if (!create) {
diff --git a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h
index fa9aded7286c..ce78804f9a92 100644
--- a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h
+++ b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DynamicLoaderStatic_h_
-#define liblldb_DynamicLoaderStatic_h_
+#ifndef LLDB_SOURCE_PLUGINS_DYNAMICLOADER_STATIC_DYNAMICLOADERSTATIC_H
+#define LLDB_SOURCE_PLUGINS_DYNAMICLOADER_STATIC_DYNAMICLOADERSTATIC_H
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/Process.h"
@@ -53,7 +53,8 @@ public:
private:
void LoadAllImagesAtFileAddresses();
- DISALLOW_COPY_AND_ASSIGN(DynamicLoaderStatic);
+ DynamicLoaderStatic(const DynamicLoaderStatic &) = delete;
+ const DynamicLoaderStatic &operator=(const DynamicLoaderStatic &) = delete;
};
-#endif // liblldb_DynamicLoaderStatic_h_
+#endif // LLDB_SOURCE_PLUGINS_DYNAMICLOADER_STATIC_DYNAMICLOADERSTATIC_H
diff --git a/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
index 25ab30e9db9c..7f9504b9b3a9 100644
--- a/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
@@ -1,5 +1,4 @@
-//===-- DynamicLoaderWindowsDYLD.cpp --------------------------------*- C++
-//-*-===//
+//===-- DynamicLoaderWindowsDYLD.cpp --------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -24,6 +23,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(DynamicLoaderWindowsDYLD)
+
DynamicLoaderWindowsDYLD::DynamicLoaderWindowsDYLD(Process *process)
: DynamicLoader(process) {}
@@ -191,9 +192,8 @@ DynamicLoaderWindowsDYLD::GetStepThroughTrampolinePlan(Thread &thread,
// Max size of an instruction in x86 is 15 bytes.
AddressRange range(pc, 2 * 15);
- ExecutionContext exe_ctx(m_process->GetTarget());
DisassemblerSP disassembler_sp = Disassembler::DisassembleRange(
- arch, nullptr, nullptr, exe_ctx, range, true);
+ arch, nullptr, nullptr, m_process->GetTarget(), range, true);
if (!disassembler_sp) {
return ThreadPlanSP();
}
@@ -212,6 +212,7 @@ DynamicLoaderWindowsDYLD::GetStepThroughTrampolinePlan(Thread &thread,
auto first_insn = insn_list->GetInstructionAtIndex(0);
auto second_insn = insn_list->GetInstructionAtIndex(1);
+ ExecutionContext exe_ctx(m_process->GetTarget());
if (first_insn == nullptr || second_insn == nullptr ||
strcmp(first_insn->GetMnemonic(&exe_ctx), "jmpl") != 0 ||
strcmp(second_insn->GetMnemonic(&exe_ctx), "nop") != 0) {
diff --git a/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
index 100689a63128..502a4c160ddd 100644
--- a/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
+++ b/lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Plugins_Process_Windows_DynamicLoaderWindowsDYLD_h_
-#define liblldb_Plugins_Process_Windows_DynamicLoaderWindowsDYLD_h_
+#ifndef LLDB_SOURCE_PLUGINS_DYNAMICLOADER_WINDOWS_DYLD_DYNAMICLOADERWINDOWSDYLD_H
+#define LLDB_SOURCE_PLUGINS_DYNAMICLOADER_WINDOWS_DYLD_DYNAMICLOADERWINDOWSDYLD_H
#include "lldb/Target/DynamicLoader.h"
#include "lldb/lldb-forward.h"
@@ -51,4 +51,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_Plugins_Process_Windows_DynamicLoaderWindowsDYLD_h_
+#endif // LLDB_SOURCE_PLUGINS_DYNAMICLOADER_WINDOWS_DYLD_DYNAMICLOADERWINDOWSDYLD_H
diff --git a/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp b/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp
new file mode 100644
index 000000000000..ae7e011eaa52
--- /dev/null
+++ b/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.cpp
@@ -0,0 +1,70 @@
+//===-- DynamicLoaderWasmDYLD.cpp -----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "DynamicLoaderWasmDYLD.h"
+
+#include "Plugins/ObjectFile/wasm/ObjectFileWasm.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Section.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::wasm;
+
+LLDB_PLUGIN_DEFINE(DynamicLoaderWasmDYLD)
+
+DynamicLoaderWasmDYLD::DynamicLoaderWasmDYLD(Process *process)
+ : DynamicLoader(process) {}
+
+void DynamicLoaderWasmDYLD::Initialize() {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(),
+ GetPluginDescriptionStatic(), CreateInstance);
+}
+
+ConstString DynamicLoaderWasmDYLD::GetPluginNameStatic() {
+ static ConstString g_plugin_name("wasm-dyld");
+ return g_plugin_name;
+}
+
+const char *DynamicLoaderWasmDYLD::GetPluginDescriptionStatic() {
+ return "Dynamic loader plug-in that watches for shared library "
+ "loads/unloads in WebAssembly engines.";
+}
+
+DynamicLoader *DynamicLoaderWasmDYLD::CreateInstance(Process *process,
+ bool force) {
+ bool should_create = force;
+ if (!should_create) {
+ should_create =
+ (process->GetTarget().GetArchitecture().GetTriple().getArch() ==
+ llvm::Triple::wasm32);
+ }
+
+ if (should_create)
+ return new DynamicLoaderWasmDYLD(process);
+
+ return nullptr;
+}
+
+void DynamicLoaderWasmDYLD::DidAttach() {
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
+ LLDB_LOGF(log, "DynamicLoaderWasmDYLD::%s()", __FUNCTION__);
+
+ // Ask the process for the list of loaded WebAssembly modules.
+ auto error = m_process->LoadModules();
+ LLDB_LOG_ERROR(log, std::move(error), "Couldn't load modules: {0}");
+}
+
+ThreadPlanSP DynamicLoaderWasmDYLD::GetStepThroughTrampolinePlan(Thread &thread,
+ bool stop) {
+ return ThreadPlanSP();
+}
diff --git a/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h b/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h
new file mode 100644
index 000000000000..4a18972bb848
--- /dev/null
+++ b/lldb/source/Plugins/DynamicLoader/wasm-DYLD/DynamicLoaderWasmDYLD.h
@@ -0,0 +1,48 @@
+//===-- DynamicLoaderWasmDYLD.h ---------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_Plugins_DynamicLoaderWasmDYLD_h_
+#define liblldb_Plugins_DynamicLoaderWasmDYLD_h_
+
+#include "lldb/Target/DynamicLoader.h"
+
+namespace lldb_private {
+namespace wasm {
+
+class DynamicLoaderWasmDYLD : public DynamicLoader {
+public:
+ DynamicLoaderWasmDYLD(Process *process);
+
+ static void Initialize();
+ static void Terminate() {}
+
+ static ConstString GetPluginNameStatic();
+ static const char *GetPluginDescriptionStatic();
+
+ static DynamicLoader *CreateInstance(Process *process, bool force);
+
+ /// DynamicLoader
+ /// \{
+ void DidAttach() override;
+ void DidLaunch() override {}
+ Status CanLoadImage() override { return Status(); }
+ lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
+ bool stop) override;
+ /// \}
+
+ /// PluginInterface protocol.
+ /// \{
+ ConstString GetPluginName() override { return GetPluginNameStatic(); }
+ uint32_t GetPluginVersion() override { return 1; }
+ /// \}
+};
+
+} // namespace wasm
+} // namespace lldb_private
+
+#endif // liblldb_Plugins_DynamicLoaderWasmDYLD_h_
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
index 77bb9544ea40..39ba5f4e9e4f 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -1,4 +1,4 @@
-//===-- ASTResultSynthesizer.cpp --------------------------------*- C++ -*-===//
+//===-- ASTResultSynthesizer.cpp ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,10 +8,10 @@
#include "ASTResultSynthesizer.h"
+#include "ClangASTImporter.h"
#include "ClangPersistentVariables.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangASTImporter.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/Log.h"
@@ -248,48 +248,37 @@ bool ASTResultSynthesizer::SynthesizeBodyResult(CompoundStmt *Body,
// For Lvalues
//
// - In AST result synthesis (here!) the expression E is transformed into an
- // initialization
- // T *$__lldb_expr_result_ptr = &E.
+ // initialization T *$__lldb_expr_result_ptr = &E.
//
// - In structure allocation, a pointer-sized slot is allocated in the
- // struct that is to be
- // passed into the expression.
+ // struct that is to be passed into the expression.
//
// - In IR transformations, reads and writes to $__lldb_expr_result_ptr are
- // redirected at
- // an entry in the struct ($__lldb_arg) passed into the expression.
- // (Other persistent
- // variables are treated similarly, having been materialized as
- // references, but in those
- // cases the value of the reference itself is never modified.)
+ // redirected at an entry in the struct ($__lldb_arg) passed into the
+ // expression. (Other persistent variables are treated similarly, having
+ // been materialized as references, but in those cases the value of the
+ // reference itself is never modified.)
//
// - During materialization, $0 (the result persistent variable) is ignored.
//
// - During dematerialization, $0 is marked up as a load address with value
- // equal to the
- // contents of the structure entry.
+ // equal to the contents of the structure entry.
//
// For Rvalues
//
// - In AST result synthesis the expression E is transformed into an
- // initialization
- // static T $__lldb_expr_result = E.
+ // initialization static T $__lldb_expr_result = E.
//
// - In structure allocation, a pointer-sized slot is allocated in the
- // struct that is to be
- // passed into the expression.
+ // struct that is to be passed into the expression.
//
// - In IR transformations, an instruction is inserted at the beginning of
- // the function to
- // dereference the pointer resident in the slot. Reads and writes to
- // $__lldb_expr_result
- // are redirected at that dereferenced version. Guard variables for the
- // static variable
- // are excised.
+ // the function to dereference the pointer resident in the slot. Reads and
+ // writes to $__lldb_expr_result are redirected at that dereferenced
+ // version. Guard variables for the static variable are excised.
//
// - During materialization, $0 (the result persistent variable) is
- // populated with the location
- // of a newly-allocated area of memory.
+ // populated with the location of a newly-allocated area of memory.
//
// - During dematerialization, $0 is ignored.
@@ -325,7 +314,8 @@ bool ASTResultSynthesizer::SynthesizeBodyResult(CompoundStmt *Body,
else
result_ptr_id = &Ctx.Idents.get("$__lldb_expr_result_ptr");
- m_sema->RequireCompleteType(SourceLocation(), expr_qual_type,
+ m_sema->RequireCompleteType(last_expr->getSourceRange().getBegin(),
+ expr_qual_type,
clang::diag::err_incomplete_type);
QualType ptr_qual_type;
@@ -453,13 +443,13 @@ void ASTResultSynthesizer::CommitPersistentDecls() {
return;
auto *persistent_vars = llvm::cast<ClangPersistentVariables>(state);
- ClangASTContext *scratch_ctx = ClangASTContext::GetScratch(m_target);
+ TypeSystemClang *scratch_ctx = TypeSystemClang::GetScratch(m_target);
for (clang::NamedDecl *decl : m_decls) {
StringRef name = decl->getName();
ConstString name_cs(name.str().c_str());
- Decl *D_scratch = m_target.GetClangASTImporter()->DeportDecl(
+ Decl *D_scratch = persistent_vars->GetClangASTImporter()->DeportDecl(
&scratch_ctx->getASTContext(), decl);
if (!D_scratch) {
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.h b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.h
index 0b0f3b97705d..9de823bc75a7 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.h
@@ -6,13 +6,20 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ASTResultSynthesizer_h_
-#define liblldb_ASTResultSynthesizer_h_
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_ASTRESULTSYNTHESIZER_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_ASTRESULTSYNTHESIZER_H
-#include "lldb/Core/ClangForward.h"
#include "lldb/Target/Target.h"
#include "clang/Sema/SemaConsumer.h"
+namespace clang {
+class CompoundStmt;
+class DeclContext;
+class NamedDecl;
+class ObjCMethodDecl;
+class TypeDecl;
+} // namespace clang
+
namespace lldb_private {
/// \class ASTResultSynthesizer ASTResultSynthesizer.h
@@ -163,4 +170,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ASTResultSynthesizer_h_
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_ASTRESULTSYNTHESIZER_H
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp
index a164d48ae3e0..40f0de40da52 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp
@@ -1,4 +1,4 @@
-//===-- ASTStructExtractor.cpp ----------------------------------*- C++ -*-===//
+//===-- ASTStructExtractor.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.h b/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.h
index 078cf095975f..c285f6408895 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.h
@@ -6,13 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ASTStructExtractor_h_
-#define liblldb_ASTStructExtractor_h_
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_ASTSTRUCTEXTRACTOR_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_ASTSTRUCTEXTRACTOR_H
#include "ClangExpressionVariable.h"
#include "ClangFunctionCaller.h"
-#include "lldb/Core/ClangForward.h"
#include "clang/Sema/SemaConsumer.h"
namespace lldb_private {
@@ -129,4 +128,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ASTStructExtractor_h_
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_ASTSTRUCTEXTRACTOR_H
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.cpp
index bbdf4e31c5a4..1e438ed9d73e 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.cpp
@@ -1,4 +1,4 @@
-//===-- ASTUtils.cpp --------------------------------------------*- C++ -*-===//
+//===-- ASTUtils.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h b/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
index d429e8c3855f..3787c572d45b 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
@@ -6,9 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ASTUtils_h_
-#define liblldb_ASTUtils_h_
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_ASTUTILS_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_ASTUTILS_H
+#include "clang/Basic/Module.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/MultiplexExternalSemaSource.h"
#include "clang/Sema/Sema.h"
@@ -71,7 +72,7 @@ public:
return m_Source->getModule(ID);
}
- llvm::Optional<ASTSourceDescriptor>
+ llvm::Optional<clang::ASTSourceDescriptor>
getSourceDescriptor(unsigned ID) override {
return m_Source->getSourceDescriptor(ID);
}
@@ -576,4 +577,4 @@ public:
};
} // namespace lldb_private
-#endif // liblldb_ASTUtils_h_
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_ASTUTILS_H
diff --git a/lldb/source/Symbol/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 8cb404231a8d..ac16738933ac 100644
--- a/lldb/source/Symbol/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -1,4 +1,4 @@
-//===-- ClangASTImporter.cpp ------------------------------------*- C++ -*-===//
+//===-- ClangASTImporter.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,11 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Symbol/ClangASTImporter.h"
#include "lldb/Core/Module.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangASTMetadata.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/Log.h"
#include "clang/AST/Decl.h"
@@ -20,17 +16,24 @@
#include "clang/Sema/Sema.h"
#include "llvm/Support/raw_ostream.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTSource.h"
+#include "Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+
#include <memory>
using namespace lldb_private;
using namespace clang;
-CompilerType ClangASTImporter::CopyType(ClangASTContext &dst_ast,
+CompilerType ClangASTImporter::CopyType(TypeSystemClang &dst_ast,
const CompilerType &src_type) {
clang::ASTContext &dst_clang_ast = dst_ast.getASTContext();
- ClangASTContext *src_ast =
- llvm::dyn_cast_or_null<ClangASTContext>(src_type.GetTypeSystem());
+ TypeSystemClang *src_ast =
+ llvm::dyn_cast_or_null<TypeSystemClang>(src_type.GetTypeSystem());
if (!src_ast)
return CompilerType();
@@ -83,16 +86,16 @@ clang::Decl *ClangASTImporter::CopyDecl(clang::ASTContext *dst_ast,
user_id = metadata->GetUserID();
if (NamedDecl *named_decl = dyn_cast<NamedDecl>(decl))
- LLDB_LOGF(log,
- " [ClangASTImporter] WARNING: Failed to import a %s "
- "'%s', metadata 0x%" PRIx64,
- decl->getDeclKindName(),
- named_decl->getNameAsString().c_str(), user_id);
+ LLDB_LOG(log,
+ " [ClangASTImporter] WARNING: Failed to import a {0} "
+ "'{1}', metadata {2}",
+ decl->getDeclKindName(), named_decl->getNameAsString(),
+ user_id);
else
- LLDB_LOGF(log,
- " [ClangASTImporter] WARNING: Failed to import a %s, "
- "metadata 0x%" PRIx64,
- decl->getDeclKindName(), user_id);
+ LLDB_LOG(log,
+ " [ClangASTImporter] WARNING: Failed to import a {0}, "
+ "metadata {1}",
+ decl->getDeclKindName(), user_id);
}
return nullptr;
}
@@ -169,12 +172,11 @@ private:
if (clang::Decl *escaped_child = GetEscapedChild(decl)) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- LLDB_LOGF(log,
- " [ClangASTImporter] DeclContextOverride couldn't "
- "override (%sDecl*)%p - its child (%sDecl*)%p escapes",
- decl->getDeclKindName(), static_cast<void *>(decl),
- escaped_child->getDeclKindName(),
- static_cast<void *>(escaped_child));
+ LLDB_LOG(log,
+ " [ClangASTImporter] DeclContextOverride couldn't "
+ "override ({0}Decl*){1} - its child ({2}Decl*){3} escapes",
+ decl->getDeclKindName(), decl, escaped_child->getDeclKindName(),
+ escaped_child);
lldbassert(0 && "Couldn't override!");
}
@@ -248,7 +250,7 @@ public:
Decl *original_decl = to_context_md->m_origins[decl].decl;
// Complete the decl now.
- ClangASTContext::GetCompleteDecl(m_src_ctx, original_decl);
+ TypeSystemClang::GetCompleteDecl(m_src_ctx, original_decl);
if (auto *tag_decl = dyn_cast<TagDecl>(decl)) {
if (auto *original_tag_decl = dyn_cast<TagDecl>(original_decl)) {
if (original_tag_decl->isCompleteDefinition()) {
@@ -290,16 +292,16 @@ public:
};
} // namespace
-CompilerType ClangASTImporter::DeportType(ClangASTContext &dst,
+CompilerType ClangASTImporter::DeportType(TypeSystemClang &dst,
const CompilerType &src_type) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- ClangASTContext *src_ctxt =
- llvm::cast<ClangASTContext>(src_type.GetTypeSystem());
+ TypeSystemClang *src_ctxt =
+ llvm::cast<TypeSystemClang>(src_type.GetTypeSystem());
LLDB_LOG(log,
- " [ClangASTImporter] DeportType called on ({0}Type*){1:x} "
- "from (ASTContext*){2:x} to (ASTContext*){3:x}",
+ " [ClangASTImporter] DeportType called on ({0}Type*){1} "
+ "from (ASTContext*){2} to (ASTContext*){3}",
src_type.GetTypeName(), src_type.GetOpaqueQualType(),
&src_ctxt->getASTContext(), &dst.getASTContext());
@@ -318,11 +320,10 @@ clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx,
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
clang::ASTContext *src_ctx = &decl->getASTContext();
- LLDB_LOGF(log,
- " [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));
+ LLDB_LOG(log,
+ " [ClangASTImporter] DeportDecl called on ({0}Decl*){1} from "
+ "(ASTContext*){2} to (ASTContext*){3}",
+ decl->getDeclKindName(), decl, src_ctx, dst_ctx);
DeclContextOverride decl_context_override;
@@ -337,11 +338,10 @@ clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx,
if (!result)
return nullptr;
- LLDB_LOGF(
- log,
- " [ClangASTImporter] DeportDecl deported (%sDecl*)%p to (%sDecl*)%p",
- decl->getDeclKindName(), static_cast<void *>(decl),
- result->getDeclKindName(), static_cast<void *>(result));
+ LLDB_LOG(log,
+ " [ClangASTImporter] DeportDecl deported ({0}Decl*){1} to "
+ "({2}Decl*){3}",
+ decl->getDeclKindName(), decl, result->getDeclKindName(), result);
return result;
}
@@ -503,11 +503,11 @@ bool ClangASTImporter::CompleteType(const CompilerType &compiler_type) {
return false;
if (Import(compiler_type)) {
- ClangASTContext::CompleteTagDeclarationDefinition(compiler_type);
+ TypeSystemClang::CompleteTagDeclarationDefinition(compiler_type);
return true;
}
- ClangASTContext::SetHasExternalStorage(compiler_type.GetOpaqueQualType(),
+ TypeSystemClang::SetHasExternalStorage(compiler_type.GetOpaqueQualType(),
false);
return false;
}
@@ -546,39 +546,13 @@ void ClangASTImporter::SetRecordLayout(clang::RecordDecl *decl,
m_record_decl_to_layout_map.insert(std::make_pair(decl, layout));
}
-void ClangASTImporter::CompleteDecl(clang::Decl *decl) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
-
- LLDB_LOGF(log, " [ClangASTImporter] CompleteDecl called on (%sDecl*)%p",
- decl->getDeclKindName(), static_cast<void *>(decl));
-
- if (ObjCInterfaceDecl *interface_decl = dyn_cast<ObjCInterfaceDecl>(decl)) {
- if (!interface_decl->getDefinition()) {
- interface_decl->startDefinition();
- CompleteObjCInterfaceDecl(interface_decl);
- }
- } else if (ObjCProtocolDecl *protocol_decl =
- dyn_cast<ObjCProtocolDecl>(decl)) {
- if (!protocol_decl->getDefinition())
- protocol_decl->startDefinition();
- } else if (TagDecl *tag_decl = dyn_cast<TagDecl>(decl)) {
- if (!tag_decl->getDefinition() && !tag_decl->isBeingDefined()) {
- tag_decl->startDefinition();
- CompleteTagDecl(tag_decl);
- tag_decl->setCompleteDefinition(true);
- }
- } else {
- assert(0 && "CompleteDecl called on a Decl that can't be completed");
- }
-}
-
bool ClangASTImporter::CompleteTagDecl(clang::TagDecl *decl) {
DeclOrigin decl_origin = GetDeclOrigin(decl);
if (!decl_origin.Valid())
return false;
- if (!ClangASTContext::GetCompleteDecl(decl_origin.ctx, decl_origin.decl))
+ if (!TypeSystemClang::GetCompleteDecl(decl_origin.ctx, decl_origin.decl))
return false;
ImporterDelegateSP delegate_sp(
@@ -596,7 +570,7 @@ bool ClangASTImporter::CompleteTagDeclWithOrigin(clang::TagDecl *decl,
clang::TagDecl *origin_decl) {
clang::ASTContext *origin_ast_ctx = &origin_decl->getASTContext();
- if (!ClangASTContext::GetCompleteDecl(origin_ast_ctx, origin_decl))
+ if (!TypeSystemClang::GetCompleteDecl(origin_ast_ctx, origin_decl))
return false;
ImporterDelegateSP delegate_sp(
@@ -621,7 +595,7 @@ bool ClangASTImporter::CompleteObjCInterfaceDecl(
if (!decl_origin.Valid())
return false;
- if (!ClangASTContext::GetCompleteDecl(decl_origin.ctx, decl_origin.decl))
+ if (!TypeSystemClang::GetCompleteDecl(decl_origin.ctx, decl_origin.decl))
return false;
ImporterDelegateSP delegate_sp(
@@ -736,10 +710,10 @@ ClangASTMetadata *ClangASTImporter::GetDeclMetadata(const clang::Decl *decl) {
DeclOrigin decl_origin = GetDeclOrigin(decl);
if (decl_origin.Valid()) {
- ClangASTContext *ast = ClangASTContext::GetASTContext(decl_origin.ctx);
+ TypeSystemClang *ast = TypeSystemClang::GetASTContext(decl_origin.ctx);
return ast->GetMetadata(decl_origin.decl);
}
- ClangASTContext *ast = ClangASTContext::GetASTContext(&decl->getASTContext());
+ TypeSystemClang *ast = TypeSystemClang::GetASTContext(&decl->getASTContext());
return ast->GetMetadata(decl);
}
@@ -821,9 +795,9 @@ void ClangASTImporter::BuildNamespaceMap(const clang::NamespaceDecl *decl) {
void ClangASTImporter::ForgetDestination(clang::ASTContext *dst_ast) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- LLDB_LOGF(log,
- " [ClangASTImporter] Forgetting destination (ASTContext*)%p",
- static_cast<void *>(dst_ast));
+ LLDB_LOG(log,
+ " [ClangASTImporter] Forgetting destination (ASTContext*){0}",
+ dst_ast);
m_metadata_map.erase(dst_ast);
}
@@ -834,10 +808,10 @@ void ClangASTImporter::ForgetSource(clang::ASTContext *dst_ast,
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- LLDB_LOGF(log,
- " [ClangASTImporter] Forgetting source->dest "
- "(ASTContext*)%p->(ASTContext*)%p",
- static_cast<void *>(src_ast), static_cast<void *>(dst_ast));
+ LLDB_LOG(log,
+ " [ClangASTImporter] Forgetting source->dest "
+ "(ASTContext*){0}->(ASTContext*){1}",
+ src_ast, dst_ast);
if (!md)
return;
@@ -882,8 +856,8 @@ ClangASTImporter::ASTImporterDelegate::ImportImpl(Decl *From) {
// into the same ASTContext where it came from (which doesn't make a lot of
// sense).
if (origin.Valid() && origin.ctx == &getToContext()) {
- RegisterImportedDecl(From, origin.decl);
- return origin.decl;
+ RegisterImportedDecl(From, origin.decl);
+ return origin.decl;
}
// This declaration came originally from another ASTContext. Instead of
@@ -903,11 +877,46 @@ ClangASTImporter::ASTImporterDelegate::ImportImpl(Decl *From) {
}
}
+ // If we have a forcefully completed type, try to find an actual definition
+ // for it in other modules.
+ const ClangASTMetadata *md = m_master.GetDeclMetadata(From);
+ auto *td = dyn_cast<TagDecl>(From);
+ if (td && md && md->IsForcefullyCompleted()) {
+ Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+ LLDB_LOG(log,
+ "[ClangASTImporter] Searching for a complete definition of {0} in "
+ "other modules",
+ td->getName());
+ Expected<DeclContext *> dc_or_err = ImportContext(td->getDeclContext());
+ if (!dc_or_err)
+ return dc_or_err.takeError();
+ Expected<DeclarationName> dn_or_err = Import(td->getDeclName());
+ if (!dn_or_err)
+ return dn_or_err.takeError();
+ DeclContext *dc = *dc_or_err;
+ DeclContext::lookup_result lr = dc->lookup(*dn_or_err);
+ if (lr.size()) {
+ clang::Decl *lookup_found = lr.front();
+ RegisterImportedDecl(From, lookup_found);
+ m_decls_to_ignore.insert(lookup_found);
+ return lookup_found;
+ } else
+ LLDB_LOG(log, "[ClangASTImporter] Complete definition not found");
+ }
+
return ASTImporter::ImportImpl(From);
}
void ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo(
clang::Decl *to, clang::Decl *from) {
+ // We might have a forward declaration from a shared library that we
+ // gave external lexical storage so that Clang asks us about the full
+ // definition when it needs it. In this case the ASTImporter isn't aware
+ // that the forward decl from the shared library is the actual import
+ // target but would create a second declaration that would then be defined.
+ // We want that 'to' is actually complete after this function so let's
+ // tell the ASTImporter that 'to' was imported from 'from'.
+ MapImported(from, to);
ASTImporter::Imported(from, to);
/*
@@ -1002,15 +1011,65 @@ void ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo(
}
}
+/// Takes a CXXMethodDecl and completes the return type if necessary. This
+/// is currently only necessary for virtual functions with covariant return
+/// types where Clang's CodeGen expects that the underlying records are already
+/// completed.
+static void MaybeCompleteReturnType(ClangASTImporter &importer,
+ CXXMethodDecl *to_method) {
+ if (!to_method->isVirtual())
+ return;
+ QualType return_type = to_method->getReturnType();
+ if (!return_type->isPointerType() && !return_type->isReferenceType())
+ return;
+
+ clang::RecordDecl *rd = return_type->getPointeeType()->getAsRecordDecl();
+ if (!rd)
+ return;
+ if (rd->getDefinition())
+ return;
+
+ importer.CompleteTagDecl(rd);
+}
+
+/// Recreate a module with its parents in \p to_source and return its id.
+static OptionalClangModuleID
+RemapModule(OptionalClangModuleID from_id,
+ ClangExternalASTSourceCallbacks &from_source,
+ ClangExternalASTSourceCallbacks &to_source) {
+ if (!from_id.HasValue())
+ return {};
+ clang::Module *module = from_source.getModule(from_id.GetValue());
+ OptionalClangModuleID parent = RemapModule(
+ from_source.GetIDForModule(module->Parent), from_source, to_source);
+ TypeSystemClang &to_ts = to_source.GetTypeSystem();
+ return to_ts.GetOrCreateClangModule(module->Name, parent, module->IsFramework,
+ module->IsExplicit);
+}
+
void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
clang::Decl *to) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
// Some decls shouldn't be tracked here because they were not created by
// copying 'from' to 'to'. Just exit early for those.
- if (m_decls_to_ignore.find(to) != m_decls_to_ignore.end())
+ if (m_decls_to_ignore.count(to))
return clang::ASTImporter::Imported(from, to);
+ // Transfer module ownership information.
+ auto *from_source = llvm::dyn_cast_or_null<ClangExternalASTSourceCallbacks>(
+ getFromContext().getExternalSource());
+ // Can also be a ClangASTSourceProxy.
+ auto *to_source = llvm::dyn_cast_or_null<ClangExternalASTSourceCallbacks>(
+ getToContext().getExternalSource());
+ if (from_source && to_source) {
+ OptionalClangModuleID from_id(from->getOwningModuleID());
+ OptionalClangModuleID to_id =
+ RemapModule(from_id, *from_source, *to_source);
+ TypeSystemClang &to_ts = to_source->GetTypeSystem();
+ to_ts.SetOwningModule(to, to_id);
+ }
+
lldb::user_id_t user_id = LLDB_INVALID_UID;
ClangASTMetadata *metadata = m_master.GetDeclMetadata(from);
if (metadata)
@@ -1023,17 +1082,15 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
from_named_decl->printName(name_stream);
name_stream.flush();
- LLDB_LOGF(log,
- " [ClangASTImporter] Imported (%sDecl*)%p, named %s (from "
- "(Decl*)%p), metadata 0x%" PRIx64,
- from->getDeclKindName(), static_cast<void *>(to),
- name_string.c_str(), static_cast<void *>(from), user_id);
+ LLDB_LOG(log,
+ " [ClangASTImporter] Imported ({0}Decl*){1}, named {2} (from "
+ "(Decl*){3}), metadata {4}",
+ from->getDeclKindName(), to, name_string, from, user_id);
} else {
- LLDB_LOGF(log,
- " [ClangASTImporter] Imported (%sDecl*)%p (from "
- "(Decl*)%p), metadata 0x%" PRIx64,
- from->getDeclKindName(), static_cast<void *>(to),
- static_cast<void *>(from), user_id);
+ LLDB_LOG(log,
+ " [ClangASTImporter] Imported ({0}Decl*){1} (from "
+ "(Decl*){2}), metadata {3}",
+ from->getDeclKindName(), to, from, user_id);
}
}
@@ -1060,14 +1117,12 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
if (direct_completer.get() != this)
direct_completer->ASTImporter::Imported(origin_iter->second.decl, to);
- LLDB_LOGF(log,
- " [ClangASTImporter] Propagated origin "
- "(Decl*)%p/(ASTContext*)%p from (ASTContext*)%p to "
- "(ASTContext*)%p",
- static_cast<void *>(origin_iter->second.decl),
- static_cast<void *>(origin_iter->second.ctx),
- static_cast<void *>(&from->getASTContext()),
- static_cast<void *>(&to->getASTContext()));
+ LLDB_LOG(log,
+ " [ClangASTImporter] Propagated origin "
+ "(Decl*){0}/(ASTContext*){1} from (ASTContext*){2} to "
+ "(ASTContext*){3}",
+ origin_iter->second.decl, origin_iter->second.ctx,
+ &from->getASTContext(), &to->getASTContext());
} else {
if (m_new_decl_listener)
m_new_decl_listener->NewDeclImported(from, to);
@@ -1077,16 +1132,14 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
to_context_md->m_origins[to] = DeclOrigin(m_source_ctx, from);
}
- LLDB_LOGF(log,
- " [ClangASTImporter] Decl has no origin information in "
- "(ASTContext*)%p",
- static_cast<void *>(&from->getASTContext()));
+ LLDB_LOG(log,
+ " [ClangASTImporter] Decl has no origin information in "
+ "(ASTContext*){0}",
+ &from->getASTContext());
}
- if (clang::NamespaceDecl *to_namespace =
- dyn_cast<clang::NamespaceDecl>(to)) {
- clang::NamespaceDecl *from_namespace =
- dyn_cast<clang::NamespaceDecl>(from);
+ if (auto *to_namespace = dyn_cast<clang::NamespaceDecl>(to)) {
+ auto *from_namespace = cast<clang::NamespaceDecl>(from);
NamespaceMetaMap &namespace_maps = from_context_md->m_namespace_maps;
@@ -1100,63 +1153,57 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
} else {
to_context_md->m_origins[to] = DeclOrigin(m_source_ctx, from);
- LLDB_LOGF(log,
- " [ClangASTImporter] Sourced origin "
- "(Decl*)%p/(ASTContext*)%p into (ASTContext*)%p",
- static_cast<void *>(from), static_cast<void *>(m_source_ctx),
- static_cast<void *>(&to->getASTContext()));
+ LLDB_LOG(log,
+ " [ClangASTImporter] Sourced origin "
+ "(Decl*){0}/(ASTContext*){1} into (ASTContext*){2}",
+ from, m_source_ctx, &to->getASTContext());
}
- if (TagDecl *from_tag_decl = dyn_cast<TagDecl>(from)) {
- TagDecl *to_tag_decl = dyn_cast<TagDecl>(to);
-
+ if (auto *to_tag_decl = dyn_cast<TagDecl>(to)) {
to_tag_decl->setHasExternalLexicalStorage();
to_tag_decl->getPrimaryContext()->setMustBuildLookupTable();
+ auto from_tag_decl = cast<TagDecl>(from);
- LLDB_LOGF(
+ LLDB_LOG(
log,
- " [ClangASTImporter] To is a TagDecl - attributes %s%s [%s->%s]",
+ " [ClangASTImporter] To is a TagDecl - attributes {0}{1} [{2}->{3}]",
(to_tag_decl->hasExternalLexicalStorage() ? " Lexical" : ""),
(to_tag_decl->hasExternalVisibleStorage() ? " Visible" : ""),
(from_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"),
(to_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"));
}
- if (isa<NamespaceDecl>(from)) {
- NamespaceDecl *to_namespace_decl = dyn_cast<NamespaceDecl>(to);
-
+ if (auto *to_namespace_decl = dyn_cast<NamespaceDecl>(to)) {
m_master.BuildNamespaceMap(to_namespace_decl);
-
to_namespace_decl->setHasExternalVisibleStorage();
}
- if (isa<ObjCContainerDecl>(from)) {
- ObjCContainerDecl *to_container_decl = dyn_cast<ObjCContainerDecl>(to);
-
+ if (auto *to_container_decl = dyn_cast<ObjCContainerDecl>(to)) {
to_container_decl->setHasExternalLexicalStorage();
to_container_decl->setHasExternalVisibleStorage();
- /*to_interface_decl->setExternallyCompleted();*/
-
if (log) {
if (ObjCInterfaceDecl *to_interface_decl =
llvm::dyn_cast<ObjCInterfaceDecl>(to_container_decl)) {
- LLDB_LOGF(
+ LLDB_LOG(
log,
" [ClangASTImporter] To is an ObjCInterfaceDecl - attributes "
- "%s%s%s",
+ "{0}{1}{2}",
(to_interface_decl->hasExternalLexicalStorage() ? " Lexical" : ""),
(to_interface_decl->hasExternalVisibleStorage() ? " Visible" : ""),
(to_interface_decl->hasDefinition() ? " HasDefinition" : ""));
} else {
- LLDB_LOGF(
- log, " [ClangASTImporter] To is an %sDecl - attributes %s%s",
+ LLDB_LOG(
+ log, " [ClangASTImporter] To is an {0}Decl - attributes {1}{2}",
((Decl *)to_container_decl)->getDeclKindName(),
(to_container_decl->hasExternalLexicalStorage() ? " Lexical" : ""),
(to_container_decl->hasExternalVisibleStorage() ? " Visible" : ""));
}
}
}
+
+ if (clang::CXXMethodDecl *to_method = dyn_cast<CXXMethodDecl>(to))
+ MaybeCompleteReturnType(m_master, to_method);
}
clang::Decl *
diff --git a/lldb/include/lldb/Symbol/ClangASTImporter.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
index faec3a77b56f..6ceec774914b 100644
--- a/lldb/include/lldb/Symbol/ClangASTImporter.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ClangASTImporter_h_
-#define liblldb_ClangASTImporter_h_
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGASTIMPORTER_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGASTIMPORTER_H
#include <map>
#include <memory>
@@ -23,36 +23,40 @@
#include "lldb/Host/FileSystem.h"
#include "lldb/Symbol/CompilerDeclContext.h"
-#include "lldb/Symbol/CxxModuleHandler.h"
#include "lldb/lldb-types.h"
+#include "Plugins/ExpressionParser/Clang/CxxModuleHandler.h"
+
#include "llvm/ADT/DenseMap.h"
namespace lldb_private {
+class ClangASTMetadata;
+class TypeSystemClang;
+
class ClangASTImporter {
public:
struct LayoutInfo {
- LayoutInfo()
- : bit_size(0), alignment(0), field_offsets(), base_offsets(),
- vbase_offsets() {}
- uint64_t bit_size;
- uint64_t alignment;
+ LayoutInfo() = default;
+ typedef llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
+ OffsetMap;
+
+ uint64_t bit_size = 0;
+ uint64_t alignment = 0;
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;
+ OffsetMap base_offsets;
+ OffsetMap vbase_offsets;
};
ClangASTImporter()
: m_file_manager(clang::FileSystemOptions(),
FileSystem::Instance().GetVirtualFileSystem()) {}
- CompilerType CopyType(ClangASTContext &dst, const CompilerType &src_type);
+ CompilerType CopyType(TypeSystemClang &dst, const CompilerType &src_type);
clang::Decl *CopyDecl(clang::ASTContext *dst_ctx, clang::Decl *decl);
- CompilerType DeportType(ClangASTContext &dst, const CompilerType &src_type);
+ CompilerType DeportType(TypeSystemClang &dst, const CompilerType &src_type);
clang::Decl *DeportDecl(clang::ASTContext *dst_ctx, clang::Decl *decl);
@@ -80,8 +84,6 @@ public:
bool CompleteType(const CompilerType &compiler_type);
- void CompleteDecl(clang::Decl *decl);
-
bool CompleteTagDecl(clang::TagDecl *decl);
bool CompleteTagDeclWithOrigin(clang::TagDecl *decl, clang::TagDecl *origin);
@@ -100,8 +102,8 @@ public:
// Namespace maps
//
- typedef std::vector<std::pair<lldb::ModuleSP, CompilerDeclContext>>
- NamespaceMap;
+ typedef std::pair<lldb::ModuleSP, CompilerDeclContext> NamespaceMapItem;
+ typedef std::vector<NamespaceMapItem> NamespaceMap;
typedef std::shared_ptr<NamespaceMap> NamespaceMapSP;
void RegisterNamespaceMap(const clang::NamespaceDecl *decl,
@@ -142,7 +144,6 @@ public:
void ForgetDestination(clang::ASTContext *dst_ctx);
void ForgetSource(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx);
-public:
struct DeclOrigin {
DeclOrigin() : ctx(nullptr), decl(nullptr) {}
@@ -313,7 +314,6 @@ public:
return delegate_iter->second;
}
-public:
DeclOrigin GetDeclOrigin(const clang::Decl *decl);
clang::FileManager m_file_manager;
@@ -325,4 +325,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_ClangASTImporter_h_
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGASTIMPORTER_H
diff --git a/lldb/source/Symbol/ClangASTMetadata.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTMetadata.cpp
index 31b012f553fa..42933c78b027 100644
--- a/lldb/source/Symbol/ClangASTMetadata.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTMetadata.cpp
@@ -1,4 +1,4 @@
-//===-- ClangASTMetadata.cpp ------------------------------------*- C++ -*-===//
+//===-- ClangASTMetadata.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Symbol/ClangASTMetadata.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h"
#include "lldb/Utility/Stream.h"
using namespace lldb_private;
diff --git a/lldb/include/lldb/Symbol/ClangASTMetadata.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTMetadata.h
index fdf4388f0847..d3bcde2ced79 100644
--- a/lldb/include/lldb/Symbol/ClangASTMetadata.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTMetadata.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ClangASTMetadata_h
-#define liblldb_ClangASTMetadata_h
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGASTMETADATA_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGASTMETADATA_H
#include "lldb/Core/dwarf.h"
#include "lldb/lldb-defines.h"
@@ -19,7 +19,8 @@ class ClangASTMetadata {
public:
ClangASTMetadata()
: m_user_id(0), m_union_is_user_id(false), m_union_is_isa_ptr(false),
- m_has_object_ptr(false), m_is_self(false), m_is_dynamic_cxx(true) {}
+ m_has_object_ptr(false), m_is_self(false), m_is_dynamic_cxx(true),
+ m_is_forcefully_completed(false) {}
bool GetIsDynamicCXXType() const { return m_is_dynamic_cxx; }
@@ -83,6 +84,15 @@ public:
bool HasObjectPtr() const { return m_has_object_ptr; }
+ /// A type is "forcefully completed" if it was declared complete to satisfy an
+ /// AST invariant (e.g. base classes must be complete types), but in fact we
+ /// were not able to find a actual definition for it.
+ bool IsForcefullyCompleted() const { return m_is_forcefully_completed; }
+
+ void SetIsForcefullyCompleted(bool value = true) {
+ m_is_forcefully_completed = true;
+ }
+
void Dump(Stream *s);
private:
@@ -92,9 +102,9 @@ private:
};
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;
+ m_is_self : 1, m_is_dynamic_cxx : 1, m_is_forcefully_completed : 1;
};
} // namespace lldb_private
-#endif // liblldb_ClangASTMetadata_h
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGASTMETADATA_H
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index 42927ab6cc8a..6fe85a1298fc 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -1,4 +1,4 @@
-//===-- ClangASTSource.cpp ---------------------------------------*- C++-*-===//
+//===-- ClangASTSource.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -13,8 +13,6 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/CompilerDeclContext.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/SymbolFile.h"
@@ -23,8 +21,11 @@
#include "lldb/Utility/Log.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/RecordLayout.h"
+#include "clang/Basic/SourceManager.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include <memory>
#include <vector>
@@ -49,14 +50,16 @@ private:
};
}
-ClangASTSource::ClangASTSource(const lldb::TargetSP &target,
- const lldb::ClangASTImporterSP &importer)
- : m_import_in_progress(false), m_lookups_enabled(false), m_target(target),
- m_ast_context(nullptr), m_active_lexical_decls(), m_active_lookups() {
- m_ast_importer_sp = importer;
+ClangASTSource::ClangASTSource(
+ const lldb::TargetSP &target,
+ const std::shared_ptr<ClangASTImporter> &importer)
+ : m_lookups_enabled(false), m_target(target), m_ast_context(nullptr),
+ m_ast_importer_sp(importer), m_active_lexical_decls(),
+ m_active_lookups() {
+ assert(m_ast_importer_sp && "No ClangASTImporter passed to ClangASTSource?");
}
-void ClangASTSource::InstallASTContext(ClangASTContext &clang_ast_context) {
+void ClangASTSource::InstallASTContext(TypeSystemClang &clang_ast_context) {
m_ast_context = &clang_ast_context.getASTContext();
m_clang_ast_context = &clang_ast_context;
m_file_manager = &m_ast_context->getSourceManager().getFileManager();
@@ -64,18 +67,15 @@ void ClangASTSource::InstallASTContext(ClangASTContext &clang_ast_context) {
}
ClangASTSource::~ClangASTSource() {
- if (!m_ast_importer_sp)
- return;
-
m_ast_importer_sp->ForgetDestination(m_ast_context);
if (!m_target)
return;
// We are in the process of destruction, don't create clang ast context on
// demand by passing false to
- // Target::GetScratchClangASTContext(create_on_demand).
- ClangASTContext *scratch_clang_ast_context =
- ClangASTContext::GetScratch(*m_target, false);
+ // Target::GetScratchTypeSystemClang(create_on_demand).
+ TypeSystemClang *scratch_clang_ast_context =
+ TypeSystemClang::GetScratch(*m_target, false);
if (!scratch_clang_ast_context)
return;
@@ -103,16 +103,8 @@ bool ClangASTSource::FindExternalVisibleDeclsByName(
return false;
}
- if (GetImportInProgress()) {
- SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
- return false;
- }
-
std::string decl_name(clang_decl_name.getAsString());
- // if (m_decl_map.DoingASTImport ())
- // return DeclContext::lookup_result();
- //
switch (clang_decl_name.getNameKind()) {
// Normal identifiers.
case DeclarationName::Identifier: {
@@ -141,7 +133,7 @@ bool ClangASTSource::FindExternalVisibleDeclsByName(
case DeclarationName::ObjCMultiArgSelector: {
llvm::SmallVector<NamedDecl *, 1> method_decls;
- NameSearchContext method_search_context(*this, method_decls,
+ NameSearchContext method_search_context(*m_clang_ast_context, method_decls,
clang_decl_name, decl_ctx);
FindObjCMethodDecls(method_search_context);
@@ -179,154 +171,134 @@ bool ClangASTSource::FindExternalVisibleDeclsByName(
return false;
}
m_active_lookups.insert(uniqued_const_decl_name);
- // static uint32_t g_depth = 0;
- // ++g_depth;
- // printf("[%5u] FindExternalVisibleDeclsByName() \"%s\"\n", g_depth,
- // uniqued_const_decl_name);
llvm::SmallVector<NamedDecl *, 4> name_decls;
- NameSearchContext name_search_context(*this, name_decls, clang_decl_name,
- decl_ctx);
+ NameSearchContext name_search_context(*m_clang_ast_context, name_decls,
+ clang_decl_name, decl_ctx);
FindExternalVisibleDecls(name_search_context);
SetExternalVisibleDeclsForName(decl_ctx, clang_decl_name, name_decls);
- // --g_depth;
m_active_lookups.erase(uniqued_const_decl_name);
return (name_decls.size() != 0);
}
-void ClangASTSource::CompleteType(TagDecl *tag_decl) {
+TagDecl *ClangASTSource::FindCompleteType(const TagDecl *decl) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- static unsigned int invocation_id = 0;
- unsigned int current_id = invocation_id++;
-
- if (log) {
- LLDB_LOGF(log,
- " CompleteTagDecl[%u] on (ASTContext*)%p Completing "
- "(TagDecl*)%p named %s",
- current_id, static_cast<void *>(m_ast_context),
- static_cast<void *>(tag_decl), tag_decl->getName().str().c_str());
-
- LLDB_LOG(log, " CTD[%u] Before:\n{0}", current_id,
- ClangUtil::DumpDecl(tag_decl));
- }
-
- auto iter = m_active_lexical_decls.find(tag_decl);
- if (iter != m_active_lexical_decls.end())
- return;
- m_active_lexical_decls.insert(tag_decl);
- ScopedLexicalDeclEraser eraser(m_active_lexical_decls, tag_decl);
+ if (const NamespaceDecl *namespace_context =
+ dyn_cast<NamespaceDecl>(decl->getDeclContext())) {
+ ClangASTImporter::NamespaceMapSP namespace_map =
+ m_ast_importer_sp->GetNamespaceMap(namespace_context);
- if (!m_ast_importer_sp) {
- return;
- }
+ LLDB_LOGV(log, " CTD Inspecting namespace map{0} ({1} entries)",
+ namespace_map.get(), namespace_map->size());
- 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.
-
- LLDB_LOGF(log,
- " CTD[%u] Type could not be completed in the module in "
- "which it was first found.",
- current_id);
+ if (!namespace_map)
+ return nullptr;
- bool found = false;
+ for (const ClangASTImporter::NamespaceMapItem &item : *namespace_map) {
+ LLDB_LOG(log, " CTD Searching namespace {0} in module {1}",
+ item.second.GetName(), item.first->GetFileSpec().GetFilename());
- DeclContext *decl_ctx = tag_decl->getDeclContext();
+ TypeList types;
- if (const NamespaceDecl *namespace_context =
- dyn_cast<NamespaceDecl>(decl_ctx)) {
- ClangASTImporter::NamespaceMapSP namespace_map =
- m_ast_importer_sp->GetNamespaceMap(namespace_context);
+ ConstString name(decl->getName());
- if (log && log->GetVerbose())
- LLDB_LOGF(log, " CTD[%u] Inspecting namespace map %p (%d entries)",
- current_id, static_cast<void *>(namespace_map.get()),
- static_cast<int>(namespace_map->size()));
+ item.first->FindTypesInNamespace(name, item.second, UINT32_MAX, types);
- if (!namespace_map)
- return;
+ for (uint32_t ti = 0, te = types.GetSize(); ti != te; ++ti) {
+ lldb::TypeSP type = types.GetTypeAtIndex(ti);
- for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(),
- e = namespace_map->end();
- i != e && !found; ++i) {
- LLDB_LOGF(log, " CTD[%u] Searching namespace %s in module %s",
- current_id, i->second.GetName().AsCString(),
- i->first->GetFileSpec().GetFilename().GetCString());
+ if (!type)
+ continue;
- TypeList types;
+ CompilerType clang_type(type->GetFullCompilerType());
- ConstString name(tag_decl->getName().str().c_str());
+ if (!ClangUtil::IsClangType(clang_type))
+ continue;
- i->first->FindTypesInNamespace(name, &i->second, UINT32_MAX, types);
+ const TagType *tag_type =
+ ClangUtil::GetQualType(clang_type)->getAs<TagType>();
- for (uint32_t ti = 0, te = types.GetSize(); ti != te && !found; ++ti) {
- lldb::TypeSP type = types.GetTypeAtIndex(ti);
+ if (!tag_type)
+ continue;
- if (!type)
- continue;
+ TagDecl *candidate_tag_decl =
+ const_cast<TagDecl *>(tag_type->getDecl());
- CompilerType clang_type(type->GetFullCompilerType());
+ if (TypeSystemClang::GetCompleteDecl(
+ &candidate_tag_decl->getASTContext(), candidate_tag_decl))
+ return candidate_tag_decl;
+ }
+ }
+ } else {
+ TypeList types;
- if (!ClangUtil::IsClangType(clang_type))
- continue;
+ ConstString name(decl->getName());
- const TagType *tag_type =
- ClangUtil::GetQualType(clang_type)->getAs<TagType>();
+ const ModuleList &module_list = m_target->GetImages();
- if (!tag_type)
- continue;
+ bool exact_match = false;
+ llvm::DenseSet<SymbolFile *> searched_symbol_files;
+ module_list.FindTypes(nullptr, name, exact_match, UINT32_MAX,
+ searched_symbol_files, types);
- TagDecl *candidate_tag_decl =
- const_cast<TagDecl *>(tag_type->getDecl());
+ for (uint32_t ti = 0, te = types.GetSize(); ti != te; ++ti) {
+ lldb::TypeSP type = types.GetTypeAtIndex(ti);
- if (m_ast_importer_sp->CompleteTagDeclWithOrigin(tag_decl,
- candidate_tag_decl))
- found = true;
- }
- }
- } else {
- TypeList types;
+ if (!type)
+ continue;
- ConstString name(tag_decl->getName().str().c_str());
+ CompilerType clang_type(type->GetFullCompilerType());
- const ModuleList &module_list = m_target->GetImages();
+ if (!ClangUtil::IsClangType(clang_type))
+ continue;
- bool exact_match = false;
- llvm::DenseSet<SymbolFile *> searched_symbol_files;
- module_list.FindTypes(nullptr, name, exact_match, UINT32_MAX,
- searched_symbol_files, types);
+ const TagType *tag_type =
+ ClangUtil::GetQualType(clang_type)->getAs<TagType>();
- for (uint32_t ti = 0, te = types.GetSize(); ti != te && !found; ++ti) {
- lldb::TypeSP type = types.GetTypeAtIndex(ti);
+ if (!tag_type)
+ continue;
- if (!type)
- continue;
+ TagDecl *candidate_tag_decl = const_cast<TagDecl *>(tag_type->getDecl());
- CompilerType clang_type(type->GetFullCompilerType());
+ // 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 (!TypeSystemClang::DeclsAreEquivalent(const_cast<TagDecl *>(decl),
+ candidate_tag_decl))
+ continue;
- if (!ClangUtil::IsClangType(clang_type))
- continue;
+ if (TypeSystemClang::GetCompleteDecl(&candidate_tag_decl->getASTContext(),
+ candidate_tag_decl))
+ return candidate_tag_decl;
+ }
+ }
+ return nullptr;
+}
- const TagType *tag_type =
- ClangUtil::GetQualType(clang_type)->getAs<TagType>();
+void ClangASTSource::CompleteType(TagDecl *tag_decl) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- if (!tag_type)
- continue;
+ if (log) {
+ LLDB_LOG(log,
+ " CompleteTagDecl on (ASTContext*){0} Completing "
+ "(TagDecl*){1} named {2}",
+ m_clang_ast_context->getDisplayName(), tag_decl,
+ tag_decl->getName());
- TagDecl *candidate_tag_decl =
- const_cast<TagDecl *>(tag_type->getDecl());
+ LLDB_LOG(log, " CTD Before:\n{0}", ClangUtil::DumpDecl(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;
+ auto iter = m_active_lexical_decls.find(tag_decl);
+ if (iter != m_active_lexical_decls.end())
+ return;
+ m_active_lexical_decls.insert(tag_decl);
+ ScopedLexicalDeclEraser eraser(m_active_lexical_decls, tag_decl);
- if (m_ast_importer_sp->CompleteTagDeclWithOrigin(tag_decl,
- candidate_tag_decl))
- found = true;
- }
- }
+ 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.
+ if (TagDecl *alternate = FindCompleteType(tag_decl))
+ m_ast_importer_sp->CompleteTagDeclWithOrigin(tag_decl, alternate);
}
LLDB_LOG(log, " [CTD] After:\n{0}", ClangUtil::DumpDecl(tag_decl));
@@ -335,19 +307,14 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
void ClangASTSource::CompleteType(clang::ObjCInterfaceDecl *interface_decl) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- LLDB_LOGF(log,
- " [CompleteObjCInterfaceDecl] on (ASTContext*)%p Completing "
- "an ObjCInterfaceDecl named %s",
- static_cast<void *>(m_ast_context),
- interface_decl->getName().str().c_str());
+ LLDB_LOG(log,
+ " [CompleteObjCInterfaceDecl] on (ASTContext*){0} '{1}' "
+ "Completing an ObjCInterfaceDecl named {1}",
+ m_ast_context, m_clang_ast_context->getDisplayName(),
+ interface_decl->getName());
LLDB_LOG(log, " [COID] Before:\n{0}",
ClangUtil::DumpDecl(interface_decl));
- if (!m_ast_importer_sp) {
- lldbassert(0 && "No mechanism for completing a type!");
- return;
- }
-
ClangASTImporter::DeclOrigin original = m_ast_importer_sp->GetDeclOrigin(interface_decl);
if (original.Valid()) {
@@ -368,10 +335,8 @@ void ClangASTSource::CompleteType(clang::ObjCInterfaceDecl *interface_decl) {
interface_decl->getSuperClass() != interface_decl)
CompleteType(interface_decl->getSuperClass());
- if (log) {
- LLDB_LOGF(log, " [COID] After:");
- LLDB_LOG(log, " [COID] {0}", ClangUtil::DumpDecl(interface_decl));
- }
+ LLDB_LOG(log, " [COID] After:");
+ LLDB_LOG(log, " [COID] {0}", ClangUtil::DumpDecl(interface_decl));
}
clang::ObjCInterfaceDecl *ClangASTSource::GetCompleteObjCInterface(
@@ -420,9 +385,6 @@ void ClangASTSource::FindExternalLexicalDecls(
llvm::function_ref<bool(Decl::Kind)> predicate,
llvm::SmallVectorImpl<Decl *> &decls) {
- if (!m_ast_importer_sp)
- return;
-
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
const Decl *context_decl = dyn_cast<Decl>(decl_context);
@@ -436,29 +398,27 @@ void ClangASTSource::FindExternalLexicalDecls(
m_active_lexical_decls.insert(context_decl);
ScopedLexicalDeclEraser eraser(m_active_lexical_decls, context_decl);
- static unsigned int invocation_id = 0;
- unsigned int current_id = invocation_id++;
-
if (log) {
if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context_decl))
- LLDB_LOGF(
- log,
- "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));
+ LLDB_LOG(log,
+ "FindExternalLexicalDecls on (ASTContext*){0} '{1}' in "
+ "'{2}' (%sDecl*){3}",
+ m_ast_context, m_clang_ast_context->getDisplayName(),
+ context_named_decl->getNameAsString().c_str(),
+ context_decl->getDeclKindName(),
+ static_cast<const void *>(context_decl));
else if (context_decl)
- LLDB_LOGF(
- log, "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));
+ LLDB_LOG(log,
+ "FindExternalLexicalDecls on (ASTContext*){0} '{1}' in "
+ "({2}Decl*){3}",
+ m_ast_context, m_clang_ast_context->getDisplayName(),
+ context_decl->getDeclKindName(),
+ static_cast<const void *>(context_decl));
else
- LLDB_LOGF(
- log,
- "FindExternalLexicalDecls[%u] on (ASTContext*)%p in a NULL context",
- current_id, static_cast<const void *>(m_ast_context));
+ LLDB_LOG(log,
+ "FindExternalLexicalDecls on (ASTContext*){0} '{1}' in a "
+ "NULL context",
+ m_ast_context, m_clang_ast_context->getDisplayName());
}
ClangASTImporter::DeclOrigin original = m_ast_importer_sp->GetDeclOrigin(context_decl);
@@ -466,10 +426,10 @@ void ClangASTSource::FindExternalLexicalDecls(
if (!original.Valid())
return;
- LLDB_LOG(
- log, " FELD[{0}] Original decl (ASTContext*){1:x} (Decl*){2:x}:\n{3}",
- current_id, static_cast<void *>(original.ctx),
- static_cast<void *>(original.decl), ClangUtil::DumpDecl(original.decl));
+ LLDB_LOG(log, " FELD Original decl {0} (Decl*){1:x}:\n{2}",
+ static_cast<void *>(original.ctx),
+ static_cast<void *>(original.decl),
+ ClangUtil::DumpDecl(original.decl));
if (ObjCInterfaceDecl *original_iface_decl =
dyn_cast<ObjCInterfaceDecl>(original.decl)) {
@@ -499,10 +459,7 @@ void ClangASTSource::FindExternalLexicalDecls(
// Indicates whether we skipped any Decls of the original DeclContext.
bool SkippedDecls = false;
- for (TagDecl::decl_iterator iter = original_decl_context->decls_begin();
- iter != original_decl_context->decls_end(); ++iter) {
- Decl *decl = *iter;
-
+ for (Decl *decl : original_decl_context->decls()) {
// The predicate function returns true if the passed declaration kind is
// the one we are looking for.
// See clang::ExternalASTSource::FindExternalLexicalDecls()
@@ -511,13 +468,13 @@ void ClangASTSource::FindExternalLexicalDecls(
std::string ast_dump = ClangUtil::DumpDecl(decl);
if (const NamedDecl *context_named_decl =
dyn_cast<NamedDecl>(context_decl))
- LLDB_LOGF(log, " FELD[%d] Adding [to %sDecl %s] lexical %sDecl %s",
- current_id, context_named_decl->getDeclKindName(),
- context_named_decl->getNameAsString().c_str(),
- decl->getDeclKindName(), ast_dump.c_str());
+ LLDB_LOG(log, " FELD Adding [to {0}Decl {1}] lexical {2}Decl {3}",
+ context_named_decl->getDeclKindName(),
+ context_named_decl->getName(), decl->getDeclKindName(),
+ ast_dump);
else
- LLDB_LOGF(log, " FELD[%d] Adding lexical %sDecl %s", current_id,
- decl->getDeclKindName(), ast_dump.c_str());
+ LLDB_LOG(log, " FELD Adding lexical {0}Decl {1}",
+ decl->getDeclKindName(), ast_dump);
}
Decl *copied_decl = CopyDecl(decl);
@@ -556,56 +513,29 @@ void ClangASTSource::FindExternalVisibleDecls(NameSearchContext &context) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- static unsigned int invocation_id = 0;
- unsigned int current_id = invocation_id++;
-
if (log) {
if (!context.m_decl_context)
- LLDB_LOGF(log,
- "ClangASTSource::FindExternalVisibleDecls[%u] on "
- "(ASTContext*)%p for '%s' in a NULL DeclContext",
- current_id, static_cast<void *>(m_ast_context),
- name.GetCString());
+ LLDB_LOG(log,
+ "ClangASTSource::FindExternalVisibleDecls on "
+ "(ASTContext*){0} '{1}' for '{2}' in a NULL DeclContext",
+ m_ast_context, m_clang_ast_context->getDisplayName(), name);
else if (const NamedDecl *context_named_decl =
dyn_cast<NamedDecl>(context.m_decl_context))
- LLDB_LOGF(log,
- "ClangASTSource::FindExternalVisibleDecls[%u] on "
- "(ASTContext*)%p for '%s' in '%s'",
- current_id, static_cast<void *>(m_ast_context),
- name.GetCString(),
- context_named_decl->getNameAsString().c_str());
+ LLDB_LOG(log,
+ "ClangASTSource::FindExternalVisibleDecls on "
+ "(ASTContext*){0} '{1}' for '{2}' in '{3}'",
+ m_ast_context, m_clang_ast_context->getDisplayName(), name,
+ context_named_decl->getName());
else
- LLDB_LOGF(log,
- "ClangASTSource::FindExternalVisibleDecls[%u] on "
- "(ASTContext*)%p for '%s' in a '%s'",
- current_id, static_cast<void *>(m_ast_context),
- name.GetCString(), context.m_decl_context->getDeclKindName());
+ LLDB_LOG(log,
+ "ClangASTSource::FindExternalVisibleDecls on "
+ "(ASTContext*){0} '{1}' for '{2}' in a '{3}'",
+ m_ast_context, m_clang_ast_context->getDisplayName(), name,
+ context.m_decl_context->getDeclKindName());
}
- context.m_namespace_map = std::make_shared<ClangASTImporter::NamespaceMap>();
-
- if (const NamespaceDecl *namespace_context =
- dyn_cast<NamespaceDecl>(context.m_decl_context)) {
- ClangASTImporter::NamespaceMapSP namespace_map = m_ast_importer_sp ?
- m_ast_importer_sp->GetNamespaceMap(namespace_context) : nullptr;
-
- if (log && log->GetVerbose())
- LLDB_LOGF(log, " CAS::FEVD[%u] Inspecting namespace map %p (%d entries)",
- current_id, static_cast<void *>(namespace_map.get()),
- static_cast<int>(namespace_map->size()));
-
- if (!namespace_map)
- return;
-
- for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(),
- e = namespace_map->end();
- i != e; ++i) {
- LLDB_LOGF(log, " CAS::FEVD[%u] Searching namespace %s in module %s",
- current_id, i->second.GetName().AsCString(),
- i->first->GetFileSpec().GetFilename().GetCString());
-
- FindExternalVisibleDecls(context, i->first, i->second, current_id);
- }
+ if (isa<NamespaceDecl>(context.m_decl_context)) {
+ LookupInNamespace(context);
} else if (isa<ObjCInterfaceDecl>(context.m_decl_context)) {
FindObjCPropertyAndIvarDecls(context);
} else if (!isa<TranslationUnitDecl>(context.m_decl_context)) {
@@ -614,18 +544,15 @@ void ClangASTSource::FindExternalVisibleDecls(NameSearchContext &context) {
} else {
CompilerDeclContext namespace_decl;
- LLDB_LOGF(log, " CAS::FEVD[%u] Searching the root namespace", current_id);
+ LLDB_LOG(log, " CAS::FEVD Searching the root namespace");
- FindExternalVisibleDecls(context, lldb::ModuleSP(), namespace_decl,
- current_id);
+ FindExternalVisibleDecls(context, lldb::ModuleSP(), namespace_decl);
}
if (!context.m_namespace_map->empty()) {
if (log && log->GetVerbose())
- LLDB_LOGF(log,
- " CAS::FEVD[%u] Registering namespace map %p (%d entries)",
- current_id, static_cast<void *>(context.m_namespace_map.get()),
- static_cast<int>(context.m_namespace_map->size()));
+ LLDB_LOG(log, " CAS::FEVD Registering namespace map {0} ({1} entries)",
+ context.m_namespace_map.get(), context.m_namespace_map->size());
NamespaceDecl *clang_namespace_decl =
AddNamespace(context, context.m_namespace_map);
@@ -658,7 +585,7 @@ bool ClangASTSource::IgnoreName(const ConstString name,
void ClangASTSource::FindExternalVisibleDecls(
NameSearchContext &context, lldb::ModuleSP module_sp,
- CompilerDeclContext &namespace_decl, unsigned int current_id) {
+ CompilerDeclContext &namespace_decl) {
assert(m_ast_context);
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
@@ -672,196 +599,113 @@ void ClangASTSource::FindExternalVisibleDecls(
if (!m_target)
return;
- if (module_sp && namespace_decl) {
- CompilerDeclContext found_namespace_decl;
-
- if (SymbolFile *symbol_file = module_sp->GetSymbolFile()) {
- found_namespace_decl = symbol_file->FindNamespace(name, &namespace_decl);
+ FillNamespaceMap(context, module_sp, namespace_decl);
- if (found_namespace_decl) {
- context.m_namespace_map->push_back(
- std::pair<lldb::ModuleSP, CompilerDeclContext>(
- module_sp, found_namespace_decl));
-
- LLDB_LOGF(log, " CAS::FEVD[%u] Found namespace %s in module %s",
- current_id, name.GetCString(),
- module_sp->GetFileSpec().GetFilename().GetCString());
- }
- }
- } else {
- const ModuleList &target_images = m_target->GetImages();
- std::lock_guard<std::recursive_mutex> guard(target_images.GetMutex());
+ if (context.m_found_type)
+ return;
- for (size_t i = 0, e = target_images.GetSize(); i < e; ++i) {
- lldb::ModuleSP image = target_images.GetModuleAtIndexUnlocked(i);
+ TypeList types;
+ const bool exact_match = true;
+ llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
+ if (module_sp && namespace_decl)
+ module_sp->FindTypesInNamespace(name, namespace_decl, 1, types);
+ else {
+ m_target->GetImages().FindTypes(module_sp.get(), name, exact_match, 1,
+ searched_symbol_files, types);
+ }
- if (!image)
- continue;
+ if (size_t num_types = types.GetSize()) {
+ for (size_t ti = 0; ti < num_types; ++ti) {
+ lldb::TypeSP type_sp = types.GetTypeAtIndex(ti);
- CompilerDeclContext found_namespace_decl;
+ if (log) {
+ const char *name_string = type_sp->GetName().GetCString();
- SymbolFile *symbol_file = image->GetSymbolFile();
+ LLDB_LOG(log, " CAS::FEVD Matching type found for \"{0}\": {1}", name,
+ (name_string ? name_string : "<anonymous>"));
+ }
- if (!symbol_file)
- continue;
+ CompilerType full_type = type_sp->GetFullCompilerType();
- found_namespace_decl = symbol_file->FindNamespace(name, &namespace_decl);
+ CompilerType copied_clang_type(GuardedCopyType(full_type));
- if (found_namespace_decl) {
- context.m_namespace_map->push_back(
- std::pair<lldb::ModuleSP, CompilerDeclContext>(
- image, found_namespace_decl));
+ if (!copied_clang_type) {
+ LLDB_LOG(log, " CAS::FEVD - Couldn't export a type");
- LLDB_LOGF(log, " CAS::FEVD[%u] Found namespace %s in module %s",
- current_id, name.GetCString(),
- image->GetFileSpec().GetFilename().GetCString());
+ continue;
}
- }
- }
- do {
- if (context.m_found.type)
- break;
+ context.AddTypeDecl(copied_clang_type);
- TypeList types;
- const bool exact_match = true;
- llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
- if (module_sp && namespace_decl)
- module_sp->FindTypesInNamespace(name, &namespace_decl, 1, types);
- else {
- m_target->GetImages().FindTypes(module_sp.get(), name, exact_match, 1,
- searched_symbol_files, types);
+ context.m_found_type = true;
+ break;
}
+ }
- if (size_t num_types = types.GetSize()) {
- for (size_t ti = 0; ti < num_types; ++ti) {
- lldb::TypeSP type_sp = types.GetTypeAtIndex(ti);
-
- if (log) {
- const char *name_string = type_sp->GetName().GetCString();
+ if (!context.m_found_type) {
+ // Try the modules next.
+ FindDeclInModules(context, name);
+ }
- LLDB_LOGF(log, " CAS::FEVD[%u] Matching type found for \"%s\": %s",
- current_id, name.GetCString(),
- (name_string ? name_string : "<anonymous>"));
- }
+ if (!context.m_found_type) {
+ FindDeclInObjCRuntime(context, name);
+ }
+}
- CompilerType full_type = type_sp->GetFullCompilerType();
+void ClangASTSource::FillNamespaceMap(
+ NameSearchContext &context, lldb::ModuleSP module_sp,
+ const CompilerDeclContext &namespace_decl) {
+ const ConstString name(context.m_decl_name.getAsString().c_str());
+ if (IgnoreName(name, true))
+ return;
- CompilerType copied_clang_type(GuardedCopyType(full_type));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- if (!copied_clang_type) {
- LLDB_LOGF(log, " CAS::FEVD[%u] - Couldn't export a type",
- current_id);
+ if (module_sp && namespace_decl) {
+ CompilerDeclContext found_namespace_decl;
- continue;
- }
+ if (SymbolFile *symbol_file = module_sp->GetSymbolFile()) {
+ found_namespace_decl = symbol_file->FindNamespace(name, namespace_decl);
- context.AddTypeDecl(copied_clang_type);
+ if (found_namespace_decl) {
+ context.m_namespace_map->push_back(
+ std::pair<lldb::ModuleSP, CompilerDeclContext>(
+ module_sp, found_namespace_decl));
- context.m_found.type = true;
- break;
+ LLDB_LOG(log, " CAS::FEVD Found namespace {0} in module {1}", name,
+ module_sp->GetFileSpec().GetFilename());
}
}
+ return;
+ }
- if (!context.m_found.type) {
- // Try the modules next.
-
- do {
- if (ClangModulesDeclVendor *modules_decl_vendor =
- m_target->GetClangModulesDeclVendor()) {
- bool append = false;
- uint32_t max_matches = 1;
- std::vector<clang::NamedDecl *> decls;
-
- if (!modules_decl_vendor->FindDecls(name, append, max_matches, decls))
- break;
-
- if (log) {
- LLDB_LOGF(log,
- " CAS::FEVD[%u] Matching entity found for \"%s\" in "
- "the modules",
- current_id, name.GetCString());
- }
-
- clang::NamedDecl *const decl_from_modules = decls[0];
-
- if (llvm::isa<clang::TypeDecl>(decl_from_modules) ||
- llvm::isa<clang::ObjCContainerDecl>(decl_from_modules) ||
- llvm::isa<clang::EnumConstantDecl>(decl_from_modules)) {
- clang::Decl *copied_decl = CopyDecl(decl_from_modules);
- clang::NamedDecl *copied_named_decl =
- copied_decl ? dyn_cast<clang::NamedDecl>(copied_decl) : nullptr;
-
- if (!copied_named_decl) {
- LLDB_LOGF(
- log,
- " CAS::FEVD[%u] - Couldn't export a type from the modules",
- current_id);
-
- break;
- }
-
- context.AddNamedDecl(copied_named_decl);
-
- context.m_found.type = true;
- }
- }
- } while (false);
- }
-
- if (!context.m_found.type) {
- do {
- // Couldn't find any types elsewhere. Try the Objective-C runtime if
- // one exists.
-
- lldb::ProcessSP process(m_target->GetProcessSP());
-
- if (!process)
- break;
-
- ObjCLanguageRuntime *language_runtime(
- ObjCLanguageRuntime::Get(*process));
-
- if (!language_runtime)
- break;
-
- DeclVendor *decl_vendor = language_runtime->GetDeclVendor();
+ const ModuleList &target_images = m_target->GetImages();
+ std::lock_guard<std::recursive_mutex> guard(target_images.GetMutex());
- if (!decl_vendor)
- break;
+ for (size_t i = 0, e = target_images.GetSize(); i < e; ++i) {
+ lldb::ModuleSP image = target_images.GetModuleAtIndexUnlocked(i);
- bool append = false;
- uint32_t max_matches = 1;
- std::vector<clang::NamedDecl *> decls;
+ if (!image)
+ continue;
- auto *clang_decl_vendor = llvm::cast<ClangDeclVendor>(decl_vendor);
- if (!clang_decl_vendor->FindDecls(name, append, max_matches, decls))
- break;
+ CompilerDeclContext found_namespace_decl;
- if (log) {
- LLDB_LOGF(
- log,
- " CAS::FEVD[%u] Matching type found for \"%s\" in the runtime",
- current_id, name.GetCString());
- }
+ SymbolFile *symbol_file = image->GetSymbolFile();
- clang::Decl *copied_decl = CopyDecl(decls[0]);
- clang::NamedDecl *copied_named_decl =
- copied_decl ? dyn_cast<clang::NamedDecl>(copied_decl) : nullptr;
+ if (!symbol_file)
+ continue;
- if (!copied_named_decl) {
- LLDB_LOGF(log,
- " CAS::FEVD[%u] - Couldn't export a type from the runtime",
- current_id);
+ found_namespace_decl = symbol_file->FindNamespace(name, namespace_decl);
- break;
- }
+ if (found_namespace_decl) {
+ context.m_namespace_map->push_back(
+ std::pair<lldb::ModuleSP, CompilerDeclContext>(image,
+ found_namespace_decl));
- context.AddNamedDecl(copied_named_decl);
- } while (false);
+ LLDB_LOG(log, " CAS::FEVD Found namespace {0} in module {1}", name,
+ image->GetFileSpec().GetFilename());
}
-
- } while (false);
+ }
}
template <class D> class TaggedASTDecl {
@@ -915,8 +759,8 @@ DeclFromParser<D> DeclFromUser<D>::Import(ClangASTSource &source) {
}
bool ClangASTSource::FindObjCMethodDeclsWithOrigin(
- unsigned int current_id, NameSearchContext &context,
- ObjCInterfaceDecl *original_interface_decl, const char *log_info) {
+ NameSearchContext &context, ObjCInterfaceDecl *original_interface_decl,
+ const char *log_info) {
const DeclarationName &decl_name(context.m_decl_name);
clang::ASTContext *original_ctx = &original_interface_decl->getASTContext();
@@ -951,7 +795,7 @@ bool ClangASTSource::FindObjCMethodDeclsWithOrigin(
llvm::SmallVector<NamedDecl *, 1> methods;
- ClangASTContext::GetCompleteDecl(original_ctx, original_interface_decl);
+ TypeSystemClang::GetCompleteDecl(original_ctx, original_interface_decl);
if (ObjCMethodDecl *instance_method_decl =
original_interface_decl->lookupInstanceMethod(original_selector)) {
@@ -987,7 +831,7 @@ bool ClangASTSource::FindObjCMethodDeclsWithOrigin(
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- LLDB_LOG(log, " CAS::FOMD[{0}] found ({1}) {2}", current_id, log_info,
+ LLDB_LOG(log, " CAS::FOMD found ({0}) {1}", log_info,
ClangUtil::DumpDecl(copied_method_decl));
context.AddNamedDecl(copied_method_decl);
@@ -996,11 +840,91 @@ bool ClangASTSource::FindObjCMethodDeclsWithOrigin(
return true;
}
-void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
+void ClangASTSource::FindDeclInModules(NameSearchContext &context,
+ ConstString name) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- static unsigned int invocation_id = 0;
- unsigned int current_id = invocation_id++;
+ ClangModulesDeclVendor *modules_decl_vendor =
+ m_target->GetClangModulesDeclVendor();
+ if (!modules_decl_vendor)
+ return;
+
+ bool append = false;
+ uint32_t max_matches = 1;
+ std::vector<clang::NamedDecl *> decls;
+
+ if (!modules_decl_vendor->FindDecls(name, append, max_matches, decls))
+ return;
+
+ LLDB_LOG(log, " CAS::FEVD Matching entity found for \"{0}\" in the modules",
+ name);
+
+ clang::NamedDecl *const decl_from_modules = decls[0];
+
+ if (llvm::isa<clang::TypeDecl>(decl_from_modules) ||
+ llvm::isa<clang::ObjCContainerDecl>(decl_from_modules) ||
+ llvm::isa<clang::EnumConstantDecl>(decl_from_modules)) {
+ clang::Decl *copied_decl = CopyDecl(decl_from_modules);
+ clang::NamedDecl *copied_named_decl =
+ copied_decl ? dyn_cast<clang::NamedDecl>(copied_decl) : nullptr;
+
+ if (!copied_named_decl) {
+ LLDB_LOG(log, " CAS::FEVD - Couldn't export a type from the modules");
+
+ return;
+ }
+
+ context.AddNamedDecl(copied_named_decl);
+
+ context.m_found_type = true;
+ }
+}
+
+void ClangASTSource::FindDeclInObjCRuntime(NameSearchContext &context,
+ ConstString name) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+
+ lldb::ProcessSP process(m_target->GetProcessSP());
+
+ if (!process)
+ return;
+
+ ObjCLanguageRuntime *language_runtime(ObjCLanguageRuntime::Get(*process));
+
+ if (!language_runtime)
+ return;
+
+ DeclVendor *decl_vendor = language_runtime->GetDeclVendor();
+
+ if (!decl_vendor)
+ return;
+
+ bool append = false;
+ uint32_t max_matches = 1;
+ std::vector<clang::NamedDecl *> decls;
+
+ auto *clang_decl_vendor = llvm::cast<ClangDeclVendor>(decl_vendor);
+ if (!clang_decl_vendor->FindDecls(name, append, max_matches, decls))
+ return;
+
+ LLDB_LOG(log, " CAS::FEVD Matching type found for \"{0}\" in the runtime",
+ name);
+
+ clang::Decl *copied_decl = CopyDecl(decls[0]);
+ clang::NamedDecl *copied_named_decl =
+ copied_decl ? dyn_cast<clang::NamedDecl>(copied_decl) : nullptr;
+
+ if (!copied_named_decl) {
+ LLDB_LOG(log, " CAS::FEVD - Couldn't export a type from the runtime");
+
+ return;
+ }
+
+ context.AddNamedDecl(copied_named_decl);
+}
+
+void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
const DeclarationName &decl_name(context.m_decl_name);
const DeclContext *decl_ctx(context.m_decl_context);
@@ -1020,8 +944,8 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
ObjCInterfaceDecl *original_interface_decl =
dyn_cast<ObjCInterfaceDecl>(original.decl);
- if (FindObjCMethodDeclsWithOrigin(current_id, context,
- original_interface_decl, "at origin"))
+ if (FindObjCMethodDeclsWithOrigin(context, original_interface_decl,
+ "at origin"))
return; // found it, no need to look any further
} while (false);
@@ -1046,12 +970,11 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
ConstString selector_name(ss.GetString());
- LLDB_LOGF(log,
- "ClangASTSource::FindObjCMethodDecls[%d] on (ASTContext*)%p "
- "for selector [%s %s]",
- current_id, static_cast<void *>(m_ast_context),
- interface_decl->getNameAsString().c_str(),
- selector_name.AsCString());
+ LLDB_LOG(log,
+ "ClangASTSource::FindObjCMethodDecls on (ASTContext*){0} '{1}' "
+ "for selector [{2} {3}]",
+ m_ast_context, m_clang_ast_context->getDisplayName(),
+ interface_decl->getName(), selector_name);
SymbolContextList sc_list;
const bool include_symbols = false;
@@ -1148,7 +1071,7 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
continue;
ObjCMethodDecl *method_decl =
- ClangASTContext::DeclContextGetAsObjCMethodDecl(function_decl_ctx);
+ TypeSystemClang::DeclContextGetAsObjCMethodDecl(function_decl_ctx);
if (!method_decl)
continue;
@@ -1171,7 +1094,7 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
if (!copied_method_decl)
continue;
- LLDB_LOG(log, " CAS::FOMD[{0}] found (in symbols)\n{1}", current_id,
+ LLDB_LOG(log, " CAS::FOMD found (in symbols)\n{0}",
ClangUtil::DumpDecl(copied_method_decl));
context.AddNamedDecl(copied_method_decl);
@@ -1199,13 +1122,12 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
if (complete_interface_decl == interface_decl)
break; // already checked this one
- LLDB_LOGF(log,
- "CAS::FOPD[%d] trying origin "
- "(ObjCInterfaceDecl*)%p/(ASTContext*)%p...",
- current_id, static_cast<void *>(complete_interface_decl),
- static_cast<void *>(&complete_iface_decl->getASTContext()));
+ LLDB_LOG(log,
+ "CAS::FOPD trying origin "
+ "(ObjCInterfaceDecl*){0}/(ASTContext*){1}...",
+ complete_interface_decl, &complete_iface_decl->getASTContext());
- FindObjCMethodDeclsWithOrigin(current_id, context, complete_interface_decl,
+ FindObjCMethodDeclsWithOrigin(context, complete_interface_decl,
"in debug info");
return;
@@ -1232,8 +1154,8 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
if (!interface_decl_from_modules)
break;
- if (FindObjCMethodDeclsWithOrigin(
- current_id, context, interface_decl_from_modules, "in modules"))
+ if (FindObjCMethodDeclsWithOrigin(context, interface_decl_from_modules,
+ "in modules"))
return;
}
} while (false);
@@ -1273,13 +1195,13 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
if (!runtime_interface_decl)
break;
- FindObjCMethodDeclsWithOrigin(current_id, context, runtime_interface_decl,
+ FindObjCMethodDeclsWithOrigin(context, runtime_interface_decl,
"in runtime");
} while (false);
}
static bool FindObjCPropertyAndIvarDeclsWithOrigin(
- unsigned int current_id, NameSearchContext &context, ClangASTSource &source,
+ NameSearchContext &context, ClangASTSource &source,
DeclFromUser<const ObjCInterfaceDecl> &origin_iface_decl) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
@@ -1301,7 +1223,7 @@ static bool FindObjCPropertyAndIvarDeclsWithOrigin(
DeclFromParser<ObjCPropertyDecl> parser_property_decl(
origin_property_decl.Import(source));
if (parser_property_decl.IsValid()) {
- LLDB_LOG(log, " CAS::FOPD[{0}] found\n{1}", current_id,
+ LLDB_LOG(log, " CAS::FOPD found\n{0}",
ClangUtil::DumpDecl(parser_property_decl.decl));
context.AddNamedDecl(parser_property_decl.decl);
@@ -1316,10 +1238,8 @@ static bool FindObjCPropertyAndIvarDeclsWithOrigin(
DeclFromParser<ObjCIvarDecl> parser_ivar_decl(
origin_ivar_decl.Import(source));
if (parser_ivar_decl.IsValid()) {
- if (log) {
- LLDB_LOG(log, " CAS::FOPD[{0}] found\n{1}", current_id,
- ClangUtil::DumpDecl(parser_ivar_decl.decl));
- }
+ LLDB_LOG(log, " CAS::FOPD found\n{0}",
+ ClangUtil::DumpDecl(parser_ivar_decl.decl));
context.AddNamedDecl(parser_ivar_decl.decl);
found = true;
@@ -1332,9 +1252,6 @@ static bool FindObjCPropertyAndIvarDeclsWithOrigin(
void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- static unsigned int invocation_id = 0;
- unsigned int current_id = invocation_id++;
-
DeclFromParser<const ObjCInterfaceDecl> parser_iface_decl(
cast<ObjCInterfaceDecl>(context.m_decl_context));
DeclFromUser<const ObjCInterfaceDecl> origin_iface_decl(
@@ -1342,23 +1259,20 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
ConstString class_name(parser_iface_decl->getNameAsString().c_str());
- LLDB_LOGF(log,
- "ClangASTSource::FindObjCPropertyAndIvarDecls[%d] on "
- "(ASTContext*)%p for '%s.%s'",
- current_id, static_cast<void *>(m_ast_context),
- parser_iface_decl->getNameAsString().c_str(),
- context.m_decl_name.getAsString().c_str());
+ LLDB_LOG(log,
+ "ClangASTSource::FindObjCPropertyAndIvarDecls on "
+ "(ASTContext*){0} '{1}' for '{2}.{3}'",
+ m_ast_context, m_clang_ast_context->getDisplayName(),
+ parser_iface_decl->getName(), context.m_decl_name.getAsString());
- if (FindObjCPropertyAndIvarDeclsWithOrigin(
- current_id, context, *this, origin_iface_decl))
+ if (FindObjCPropertyAndIvarDeclsWithOrigin(context, *this, origin_iface_decl))
return;
- LLDB_LOGF(log,
- "CAS::FOPD[%d] couldn't find the property on origin "
- "(ObjCInterfaceDecl*)%p/(ASTContext*)%p, searching "
- "elsewhere...",
- current_id, static_cast<const void *>(origin_iface_decl.decl),
- static_cast<void *>(&origin_iface_decl->getASTContext()));
+ LLDB_LOG(log,
+ "CAS::FOPD couldn't find the property on origin "
+ "(ObjCInterfaceDecl*){0}/(ASTContext*){1}, searching "
+ "elsewhere...",
+ origin_iface_decl.decl, &origin_iface_decl->getASTContext());
SymbolContext null_sc;
TypeList type_list;
@@ -1379,14 +1293,12 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
if (complete_iface_decl.decl == origin_iface_decl.decl)
break; // already checked this one
- LLDB_LOGF(log,
- "CAS::FOPD[%d] trying origin "
- "(ObjCInterfaceDecl*)%p/(ASTContext*)%p...",
- current_id, static_cast<const void *>(complete_iface_decl.decl),
- static_cast<void *>(&complete_iface_decl->getASTContext()));
+ LLDB_LOG(log,
+ "CAS::FOPD trying origin "
+ "(ObjCInterfaceDecl*){0}/(ASTContext*){1}...",
+ complete_iface_decl.decl, &complete_iface_decl->getASTContext());
- FindObjCPropertyAndIvarDeclsWithOrigin(current_id, context, *this,
- complete_iface_decl);
+ FindObjCPropertyAndIvarDeclsWithOrigin(context, *this, complete_iface_decl);
return;
} while (false);
@@ -1414,14 +1326,13 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
if (!interface_decl_from_modules.IsValid())
break;
- LLDB_LOGF(
- log,
- "CAS::FOPD[%d] trying module "
- "(ObjCInterfaceDecl*)%p/(ASTContext*)%p...",
- current_id, static_cast<const void *>(interface_decl_from_modules.decl),
- static_cast<void *>(&interface_decl_from_modules->getASTContext()));
+ LLDB_LOG(log,
+ "CAS::FOPD[{0}] trying module "
+ "(ObjCInterfaceDecl*){0}/(ASTContext*){1}...",
+ interface_decl_from_modules.decl,
+ &interface_decl_from_modules->getASTContext());
- if (FindObjCPropertyAndIvarDeclsWithOrigin(current_id, context, *this,
+ if (FindObjCPropertyAndIvarDeclsWithOrigin(context, *this,
interface_decl_from_modules))
return;
} while (false);
@@ -1459,19 +1370,43 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
if (!interface_decl_from_runtime.IsValid())
break;
- LLDB_LOGF(
- log,
- "CAS::FOPD[%d] trying runtime "
- "(ObjCInterfaceDecl*)%p/(ASTContext*)%p...",
- current_id, static_cast<const void *>(interface_decl_from_runtime.decl),
- static_cast<void *>(&interface_decl_from_runtime->getASTContext()));
+ LLDB_LOG(log,
+ "CAS::FOPD[{0}] trying runtime "
+ "(ObjCInterfaceDecl*){0}/(ASTContext*){1}...",
+ interface_decl_from_runtime.decl,
+ &interface_decl_from_runtime->getASTContext());
- if (FindObjCPropertyAndIvarDeclsWithOrigin(
- current_id, context, *this, interface_decl_from_runtime))
+ if (FindObjCPropertyAndIvarDeclsWithOrigin(context, *this,
+ interface_decl_from_runtime))
return;
} while (false);
}
+void ClangASTSource::LookupInNamespace(NameSearchContext &context) {
+ const NamespaceDecl *namespace_context =
+ dyn_cast<NamespaceDecl>(context.m_decl_context);
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+
+ ClangASTImporter::NamespaceMapSP namespace_map =
+ m_ast_importer_sp->GetNamespaceMap(namespace_context);
+
+ LLDB_LOGV(log, " CAS::FEVD Inspecting namespace map {0} ({1} entries)",
+ namespace_map.get(), namespace_map->size());
+
+ if (!namespace_map)
+ return;
+
+ for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(),
+ e = namespace_map->end();
+ i != e; ++i) {
+ LLDB_LOG(log, " CAS::FEVD Searching namespace {0} in module {1}",
+ i->second.GetName(), i->first->GetFileSpec().GetFilename());
+
+ FindExternalVisibleDecls(context, i->first, i->second);
+ }
+}
+
typedef llvm::DenseMap<const FieldDecl *, uint64_t> FieldOffsetMap;
typedef llvm::DenseMap<const CXXRecordDecl *, CharUnits> BaseOffsetMap;
@@ -1557,17 +1492,14 @@ bool ClangASTSource::layoutRecordType(const RecordDecl *record, uint64_t &size,
FieldOffsetMap &field_offsets,
BaseOffsetMap &base_offsets,
BaseOffsetMap &virtual_base_offsets) {
- static unsigned int invocation_id = 0;
- unsigned int current_id = invocation_id++;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- LLDB_LOGF(log,
- "LayoutRecordType[%u] on (ASTContext*)%p for (RecordDecl*)%p "
- "[name = '%s']",
- current_id, static_cast<void *>(m_ast_context),
- static_cast<const void *>(record),
- record->getNameAsString().c_str());
+ LLDB_LOG(log,
+ "LayoutRecordType on (ASTContext*){0} '{1}' for (RecordDecl*)"
+ "{3} [name = '{4}']",
+ m_ast_context, m_clang_ast_context->getDisplayName(), record,
+ record->getName());
DeclFromParser<const RecordDecl> parser_record(record);
DeclFromUser<const RecordDecl> origin_record(
@@ -1580,7 +1512,7 @@ bool ClangASTSource::layoutRecordType(const RecordDecl *record, uint64_t &size,
BaseOffsetMap origin_base_offsets;
BaseOffsetMap origin_virtual_base_offsets;
- ClangASTContext::GetCompleteDecl(
+ TypeSystemClang::GetCompleteDecl(
&origin_record->getASTContext(),
const_cast<RecordDecl *>(origin_record.decl));
@@ -1631,25 +1563,23 @@ bool ClangASTSource::layoutRecordType(const RecordDecl *record, uint64_t &size,
m_ast_context->getCharWidth();
if (log) {
- LLDB_LOGF(log, "LRT[%u] returned:", current_id);
- LLDB_LOGF(log, "LRT[%u] Original = (RecordDecl*)%p", current_id,
- static_cast<const void *>(origin_record.decl));
- LLDB_LOGF(log, "LRT[%u] Size = %" PRId64, current_id, size);
- LLDB_LOGF(log, "LRT[%u] Alignment = %" PRId64, current_id, alignment);
- LLDB_LOGF(log, "LRT[%u] Fields:", current_id);
+ LLDB_LOG(log, "LRT returned:");
+ LLDB_LOG(log, "LRT Original = (RecordDecl*)%p",
+ static_cast<const void *>(origin_record.decl));
+ LLDB_LOG(log, "LRT Size = %" PRId64, size);
+ LLDB_LOG(log, "LRT Alignment = %" PRId64, alignment);
+ LLDB_LOG(log, "LRT Fields:");
for (RecordDecl::field_iterator fi = record->field_begin(),
fe = record->field_end();
fi != fe; ++fi) {
- LLDB_LOGF(log,
- "LRT[%u] (FieldDecl*)%p, Name = '%s', Offset = %" PRId64
- " bits",
- current_id, static_cast<void *>(*fi),
- fi->getNameAsString().c_str(), field_offsets[*fi]);
+ LLDB_LOG(log,
+ "LRT (FieldDecl*){0}, Name = '{1}', Offset = {2} bits",
+ *fi, fi->getName(), field_offsets[*fi]);
}
DeclFromParser<const CXXRecordDecl> parser_cxx_record =
DynCast<const CXXRecordDecl>(parser_record);
if (parser_cxx_record.IsValid()) {
- LLDB_LOGF(log, "LRT[%u] Bases:", current_id);
+ LLDB_LOG(log, "LRT Bases:");
for (CXXRecordDecl::base_class_const_iterator
bi = parser_cxx_record->bases_begin(),
be = parser_cxx_record->bases_end();
@@ -1662,19 +1592,17 @@ bool ClangASTSource::layoutRecordType(const RecordDecl *record, uint64_t &size,
DeclFromParser<CXXRecordDecl> base_cxx_record =
DynCast<CXXRecordDecl>(base_record);
- LLDB_LOGF(
- log,
- "LRT[%u] %s(CXXRecordDecl*)%p, Name = '%s', Offset = %" PRId64
- " chars",
- current_id, (is_virtual ? "Virtual " : ""),
- static_cast<void *>(base_cxx_record.decl),
- base_cxx_record.decl->getNameAsString().c_str(),
- (is_virtual
- ? virtual_base_offsets[base_cxx_record.decl].getQuantity()
- : base_offsets[base_cxx_record.decl].getQuantity()));
+ LLDB_LOG(log,
+ "LRT {0}(CXXRecordDecl*){1}, Name = '{2}', Offset = "
+ "{3} chars",
+ (is_virtual ? "Virtual " : ""), base_cxx_record.decl,
+ base_cxx_record.decl->getName(),
+ (is_virtual
+ ? virtual_base_offsets[base_cxx_record.decl].getQuantity()
+ : base_offsets[base_cxx_record.decl].getQuantity()));
}
} else {
- LLDB_LOGF(log, "LRD[%u] Not a CXXRecord, so no bases", current_id);
+ LLDB_LOG(log, "LRD Not a CXXRecord, so no bases");
}
}
@@ -1684,25 +1612,21 @@ bool ClangASTSource::layoutRecordType(const RecordDecl *record, uint64_t &size,
void ClangASTSource::CompleteNamespaceMap(
ClangASTImporter::NamespaceMapSP &namespace_map, ConstString name,
ClangASTImporter::NamespaceMapSP &parent_map) const {
- static unsigned int invocation_id = 0;
- unsigned int current_id = invocation_id++;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
if (log) {
if (parent_map && parent_map->size())
- LLDB_LOGF(log,
- "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.GetName().AsCString());
+ LLDB_LOG(log,
+ "CompleteNamespaceMap on (ASTContext*){0} '{1}' Searching "
+ "for namespace {2} in namespace {3}",
+ m_ast_context, m_clang_ast_context->getDisplayName(), name,
+ parent_map->begin()->second.GetName());
else
- LLDB_LOGF(log,
- "CompleteNamespaceMap[%u] on (ASTContext*)%p Searching for "
- "namespace %s",
- current_id, static_cast<void *>(m_ast_context),
- name.GetCString());
+ LLDB_LOG(log,
+ "CompleteNamespaceMap on (ASTContext*){0} '{1}' Searching "
+ "for namespace {2}",
+ m_ast_context, m_clang_ast_context->getDisplayName(), name);
}
if (parent_map) {
@@ -1720,7 +1644,7 @@ void ClangASTSource::CompleteNamespaceMap(
continue;
found_namespace_decl =
- symbol_file->FindNamespace(name, &module_parent_namespace_decl);
+ symbol_file->FindNamespace(name, module_parent_namespace_decl);
if (!found_namespace_decl)
continue;
@@ -1728,9 +1652,8 @@ void ClangASTSource::CompleteNamespaceMap(
namespace_map->push_back(std::pair<lldb::ModuleSP, CompilerDeclContext>(
module_sp, found_namespace_decl));
- LLDB_LOGF(log, " CMN[%u] Found namespace %s in module %s", current_id,
- name.GetCString(),
- module_sp->GetFileSpec().GetFilename().GetCString());
+ LLDB_LOG(log, " CMN Found namespace {0} in module {1}", name,
+ module_sp->GetFileSpec().GetFilename());
}
} else {
const ModuleList &target_images = m_target->GetImages();
@@ -1752,7 +1675,7 @@ void ClangASTSource::CompleteNamespaceMap(
continue;
found_namespace_decl =
- symbol_file->FindNamespace(name, &null_namespace_decl);
+ symbol_file->FindNamespace(name, null_namespace_decl);
if (!found_namespace_decl)
continue;
@@ -1760,9 +1683,8 @@ void ClangASTSource::CompleteNamespaceMap(
namespace_map->push_back(std::pair<lldb::ModuleSP, CompilerDeclContext>(
image, found_namespace_decl));
- LLDB_LOGF(log, " CMN[%u] Found namespace %s in module %s", current_id,
- name.GetCString(),
- image->GetFileSpec().GetFilename().GetCString());
+ LLDB_LOG(log, " CMN[{0}] Found namespace {0} in module {1}", name,
+ image->GetFileSpec().GetFilename());
}
}
}
@@ -1776,11 +1698,11 @@ NamespaceDecl *ClangASTSource::AddNamespace(
const CompilerDeclContext &namespace_decl = namespace_decls->begin()->second;
clang::ASTContext *src_ast =
- ClangASTContext::DeclContextGetClangASTContext(namespace_decl);
+ TypeSystemClang::DeclContextGetTypeSystemClang(namespace_decl);
if (!src_ast)
return nullptr;
clang::NamespaceDecl *src_namespace_decl =
- ClangASTContext::DeclContextGetAsNamespaceDecl(namespace_decl);
+ TypeSystemClang::DeclContextGetAsNamespaceDecl(namespace_decl);
if (!src_namespace_decl)
return nullptr;
@@ -1804,42 +1726,21 @@ NamespaceDecl *ClangASTSource::AddNamespace(
}
clang::Decl *ClangASTSource::CopyDecl(Decl *src_decl) {
- if (m_ast_importer_sp) {
- return m_ast_importer_sp->CopyDecl(m_ast_context, src_decl);
- } else {
- lldbassert(0 && "No mechanism for copying a decl!");
- return nullptr;
- }
+ return m_ast_importer_sp->CopyDecl(m_ast_context, src_decl);
}
ClangASTImporter::DeclOrigin ClangASTSource::GetDeclOrigin(const clang::Decl *decl) {
- if (m_ast_importer_sp) {
- return m_ast_importer_sp->GetDeclOrigin(decl);
- } else {
- // this can happen early enough that no ExternalASTSource is installed.
- return ClangASTImporter::DeclOrigin();
- }
+ return m_ast_importer_sp->GetDeclOrigin(decl);
}
CompilerType ClangASTSource::GuardedCopyType(const CompilerType &src_type) {
- ClangASTContext *src_ast =
- llvm::dyn_cast_or_null<ClangASTContext>(src_type.GetTypeSystem());
+ TypeSystemClang *src_ast =
+ llvm::dyn_cast_or_null<TypeSystemClang>(src_type.GetTypeSystem());
if (src_ast == nullptr)
return CompilerType();
- SetImportInProgress(true);
-
- QualType copied_qual_type;
-
- if (m_ast_importer_sp) {
- copied_qual_type = ClangUtil::GetQualType(
- m_ast_importer_sp->CopyType(*m_clang_ast_context, src_type));
- } else {
- lldbassert(0 && "No mechanism for copying a type!");
- return CompilerType();
- }
-
- SetImportInProgress(false);
+ QualType copied_qual_type = ClangUtil::GetQualType(
+ m_ast_importer_sp->CopyType(*m_clang_ast_context, src_type));
if (copied_qual_type.getAsOpaquePtr() &&
copied_qual_type->getCanonicalTypeInternal().isNull())
@@ -1849,170 +1750,3 @@ CompilerType ClangASTSource::GuardedCopyType(const CompilerType &src_type) {
return m_clang_ast_context->GetType(copied_qual_type);
}
-
-clang::NamedDecl *NameSearchContext::AddVarDecl(const CompilerType &type) {
- assert(type && "Type for variable must be valid!");
-
- if (!type.IsValid())
- return nullptr;
-
- ClangASTContext *lldb_ast =
- llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
- if (!lldb_ast)
- return nullptr;
-
- IdentifierInfo *ii = m_decl_name.getAsIdentifierInfo();
-
- clang::ASTContext &ast = lldb_ast->getASTContext();
-
- clang::NamedDecl *Decl = VarDecl::Create(
- ast, const_cast<DeclContext *>(m_decl_context), SourceLocation(),
- SourceLocation(), ii, ClangUtil::GetQualType(type), nullptr, SC_Static);
- m_decls.push_back(Decl);
-
- return Decl;
-}
-
-clang::NamedDecl *NameSearchContext::AddFunDecl(const CompilerType &type,
- bool extern_c) {
- assert(type && "Type for variable must be valid!");
-
- if (!type.IsValid())
- return nullptr;
-
- if (m_function_types.count(type))
- return nullptr;
-
- ClangASTContext *lldb_ast =
- llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
- if (!lldb_ast)
- return nullptr;
-
- m_function_types.insert(type);
-
- QualType qual_type(ClangUtil::GetQualType(type));
-
- clang::ASTContext &ast = lldb_ast->getASTContext();
-
- const bool isInlineSpecified = false;
- const bool hasWrittenPrototype = true;
- const bool isConstexprSpecified = false;
-
- clang::DeclContext *context = const_cast<DeclContext *>(m_decl_context);
-
- if (extern_c) {
- context = LinkageSpecDecl::Create(
- ast, context, SourceLocation(), SourceLocation(),
- clang::LinkageSpecDecl::LanguageIDs::lang_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(), decl_name, qual_type,
- nullptr, SC_Extern, isInlineSpecified, hasWrittenPrototype,
- isConstexprSpecified ? CSK_constexpr : CSK_unspecified);
-
- // We have to do more than just synthesize the FunctionDecl. We have to
- // synthesize ParmVarDecls for all of the FunctionDecl's arguments. To do
- // this, we raid the function's FunctionProtoType for types.
-
- const FunctionProtoType *func_proto_type =
- qual_type.getTypePtr()->getAs<FunctionProtoType>();
-
- if (func_proto_type) {
- unsigned NumArgs = func_proto_type->getNumParams();
- unsigned ArgIndex;
-
- SmallVector<ParmVarDecl *, 5> parm_var_decls;
-
- for (ArgIndex = 0; ArgIndex < NumArgs; ++ArgIndex) {
- QualType arg_qual_type(func_proto_type->getParamType(ArgIndex));
-
- parm_var_decls.push_back(
- ParmVarDecl::Create(ast, const_cast<DeclContext *>(context),
- SourceLocation(), SourceLocation(), nullptr,
- arg_qual_type, nullptr, SC_Static, nullptr));
- }
-
- func_decl->setParams(ArrayRef<ParmVarDecl *>(parm_var_decls));
- } else {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
-
- LLDB_LOGF(log, "Function type wasn't a FunctionProtoType");
- }
-
- // If this is an operator (e.g. operator new or operator==), only insert the
- // declaration we inferred from the symbol if we can provide the correct
- // number of arguments. We shouldn't really inject random decl(s) for
- // functions that are analyzed semantically in a special way, otherwise we
- // will crash in clang.
- clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
- if (func_proto_type &&
- ClangASTContext::IsOperator(decl_name.getAsString().c_str(), op_kind)) {
- if (!ClangASTContext::CheckOverloadedOperatorKindParameterCount(
- false, op_kind, func_proto_type->getNumParams()))
- return nullptr;
- }
- m_decls.push_back(func_decl);
-
- return func_decl;
-}
-
-clang::NamedDecl *NameSearchContext::AddGenericFunDecl() {
- FunctionProtoType::ExtProtoInfo proto_info;
-
- proto_info.Variadic = true;
-
- QualType generic_function_type(m_ast_source.m_ast_context->getFunctionType(
- m_ast_source.m_ast_context->UnknownAnyTy, // result
- ArrayRef<QualType>(), // argument types
- proto_info));
-
- return AddFunDecl(
- m_ast_source.m_clang_ast_context->GetType(generic_function_type), true);
-}
-
-clang::NamedDecl *
-NameSearchContext::AddTypeDecl(const CompilerType &clang_type) {
- if (ClangUtil::IsClangType(clang_type)) {
- QualType qual_type = ClangUtil::GetQualType(clang_type);
-
- if (const TypedefType *typedef_type =
- llvm::dyn_cast<TypedefType>(qual_type)) {
- TypedefNameDecl *typedef_name_decl = typedef_type->getDecl();
-
- m_decls.push_back(typedef_name_decl);
-
- return (NamedDecl *)typedef_name_decl;
- } else if (const TagType *tag_type = qual_type->getAs<TagType>()) {
- TagDecl *tag_decl = tag_type->getDecl();
-
- m_decls.push_back(tag_decl);
-
- return tag_decl;
- } else if (const ObjCObjectType *objc_object_type =
- qual_type->getAs<ObjCObjectType>()) {
- ObjCInterfaceDecl *interface_decl = objc_object_type->getInterface();
-
- m_decls.push_back((NamedDecl *)interface_decl);
-
- return (NamedDecl *)interface_decl;
- }
- }
- return nullptr;
-}
-
-void NameSearchContext::AddLookupResult(clang::DeclContextLookupResult result) {
- for (clang::NamedDecl *decl : result)
- m_decls.push_back(decl);
-}
-
-void NameSearchContext::AddNamedDecl(clang::NamedDecl *decl) {
- m_decls.push_back(decl);
-}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
index 3149b4266b2f..14761fbeb26b 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
@@ -6,12 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ClangASTSource_h_
-#define liblldb_ClangASTSource_h_
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGASTSOURCE_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGASTSOURCE_H
#include <set>
-#include "lldb/Symbol/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/NameSearchContext.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/Target.h"
#include "clang/AST/ExternalASTSource.h"
@@ -42,7 +43,7 @@ public:
/// \param[in] importer
/// The ClangASTImporter to use.
ClangASTSource(const lldb::TargetSP &target,
- const lldb::ClangASTImporterSP &importer);
+ const std::shared_ptr<ClangASTImporter> &importer);
/// Destructor
~ClangASTSource() override;
@@ -60,7 +61,7 @@ public:
}
void MaterializeVisibleDecls(const clang::DeclContext *DC) { return; }
- void InstallASTContext(ClangASTContext &ast_context);
+ void InstallASTContext(TypeSystemClang &ast_context);
//
// APIs for ExternalASTSource
@@ -196,11 +197,6 @@ public:
clang::Sema *getSema();
- void SetImportInProgress(bool import_in_progress) {
- m_import_in_progress = import_in_progress;
- }
- bool GetImportInProgress() { return m_import_in_progress; }
-
void SetLookupsEnabled(bool lookups_enabled) {
m_lookups_enabled = lookups_enabled;
}
@@ -282,14 +278,9 @@ protected:
///
/// \param[in] namespace_decl
/// If valid and module is non-NULL, the parent namespace.
- ///
- /// \param[in] current_id
- /// The ID for the current FindExternalVisibleDecls invocation,
- /// for logging purposes.
void FindExternalVisibleDecls(NameSearchContext &context,
lldb::ModuleSP module,
- CompilerDeclContext &namespace_decl,
- unsigned int current_id);
+ CompilerDeclContext &namespace_decl);
/// Find all Objective-C methods matching a given selector.
///
@@ -307,7 +298,13 @@ protected:
/// is the containing object.
void FindObjCPropertyAndIvarDecls(NameSearchContext &context);
- /// A wrapper for ClangASTContext::CopyType that sets a flag that
+ /// Performs lookup into a namespace.
+ ///
+ /// \param context
+ /// The NameSearchContext for a lookup inside a namespace.
+ void LookupInNamespace(NameSearchContext &context);
+
+ /// A wrapper for TypeSystemClang::CopyType that sets a flag that
/// indicates that we should not respond to queries during import.
///
/// \param[in] src_type
@@ -331,7 +328,6 @@ public:
/// global lookup for performance reasons.
bool IgnoreName(const ConstString name, bool ignore_all_dollar_names);
-public:
/// Copies a single Decl into the parser's AST context.
///
/// \param[in] src_decl
@@ -346,139 +342,51 @@ public:
/// \param[in] decl
/// The Decl whose origin is to be found.
///
- /// \param[out] original_decl
- /// A pointer whose target is filled in with the original Decl.
- ///
- /// \param[in] original_ctx
- /// A pointer whose target is filled in with the original's ASTContext.
- ///
/// \return
/// True if lookup succeeded; false otherwise.
ClangASTImporter::DeclOrigin GetDeclOrigin(const clang::Decl *decl);
+ /// Returns the TypeSystem that uses this ClangASTSource instance as it's
+ /// ExternalASTSource.
+ TypeSystemClang *GetTypeSystem() const { return m_clang_ast_context; }
+
protected:
bool FindObjCMethodDeclsWithOrigin(
- unsigned int current_id, NameSearchContext &context,
+ NameSearchContext &context,
clang::ObjCInterfaceDecl *original_interface_decl, const char *log_info);
+ void FindDeclInModules(NameSearchContext &context, ConstString name);
+ void FindDeclInObjCRuntime(NameSearchContext &context, ConstString name);
+
+ /// Fills the namespace map of the given NameSearchContext.
+ ///
+ /// \param context The NameSearchContext with the namespace map to fill.
+ /// \param module_sp The module to search for namespaces or a nullptr if
+ /// the current target should be searched.
+ /// \param namespace_decl The DeclContext in which to search for namespaces.
+ void FillNamespaceMap(NameSearchContext &context, lldb::ModuleSP module_sp,
+ const CompilerDeclContext &namespace_decl);
+
+ clang::TagDecl *FindCompleteType(const clang::TagDecl *decl);
+
friend struct NameSearchContext;
- bool m_import_in_progress;
bool m_lookups_enabled;
/// The target to use in finding variables and types.
const lldb::TargetSP m_target;
/// The AST context requests are coming in for.
clang::ASTContext *m_ast_context;
- /// The ClangASTContext for m_ast_context.
- ClangASTContext *m_clang_ast_context;
+ /// The TypeSystemClang for m_ast_context.
+ TypeSystemClang *m_clang_ast_context;
/// The file manager paired with the AST context.
clang::FileManager *m_file_manager;
/// The target's AST importer.
- lldb::ClangASTImporterSP m_ast_importer_sp;
+ std::shared_ptr<ClangASTImporter> m_ast_importer_sp;
std::set<const clang::Decl *> m_active_lexical_decls;
std::set<const char *> m_active_lookups;
};
-/// \class NameSearchContext ClangASTSource.h
-/// "lldb/Expression/ClangASTSource.h" Container for all objects relevant to a
-/// single name lookup
-///
-/// LLDB needs to create Decls for entities it finds. This class communicates
-/// what name is being searched for and provides helper functions to construct
-/// Decls given appropriate type information.
-struct NameSearchContext {
- /// The AST source making the request.
- ClangASTSource &m_ast_source;
- /// The list of declarations already constructed.
- llvm::SmallVectorImpl<clang::NamedDecl *> &m_decls;
- /// The mapping of all namespaces found for this request back to their
- /// modules.
- ClangASTImporter::NamespaceMapSP m_namespace_map;
- /// The name being looked for.
- const clang::DeclarationName &m_decl_name;
- /// The DeclContext to put declarations into.
- const clang::DeclContext *m_decl_context;
- /// All the types of functions that have been reported, so we don't
- /// report conflicts.
- llvm::SmallSet<CompilerType, 5> m_function_types;
-
- struct {
- bool variable : 1;
- bool function_with_type_info : 1;
- bool function : 1;
- bool local_vars_nsp : 1;
- bool type : 1;
- } m_found;
-
- /// Constructor
- ///
- /// Initializes class variables.
- ///
- /// \param[in] astSource
- /// A reference to the AST source making a request.
- ///
- /// \param[in] decls
- /// A reference to a list into which new Decls will be placed. This
- /// list is typically empty when the function is called.
- ///
- /// \param[in] name
- /// The name being searched for (always an Identifier).
- ///
- /// \param[in] dc
- /// The DeclContext to register Decls in.
- NameSearchContext(ClangASTSource &astSource,
- llvm::SmallVectorImpl<clang::NamedDecl *> &decls,
- clang::DeclarationName &name, const clang::DeclContext *dc)
- : m_ast_source(astSource), m_decls(decls), m_decl_name(name),
- m_decl_context(dc) {
- memset(&m_found, 0, sizeof(m_found));
- }
-
- /// Create a VarDecl with the name being searched for and the provided type
- /// and register it in the right places.
- ///
- /// \param[in] type
- /// The opaque QualType for the VarDecl being registered.
- clang::NamedDecl *AddVarDecl(const CompilerType &type);
-
- /// Create a FunDecl with the name being searched for and the provided type
- /// and register it in the right places.
- ///
- /// \param[in] type
- /// The opaque QualType for the FunDecl being registered.
- ///
- /// \param[in] extern_c
- /// If true, build an extern "C" linkage specification for this.
- clang::NamedDecl *AddFunDecl(const CompilerType &type, bool extern_c = false);
-
- /// Create a FunDecl with the name being searched for and generic type (i.e.
- /// intptr_t NAME_GOES_HERE(...)) and register it in the right places.
- clang::NamedDecl *AddGenericFunDecl();
-
- /// Create a TypeDecl with the name being searched for and the provided type
- /// and register it in the right places.
- ///
- /// \param[in] compiler_type
- /// The opaque QualType for the TypeDecl being registered.
- clang::NamedDecl *AddTypeDecl(const CompilerType &compiler_type);
-
- /// Add Decls from the provided DeclContextLookupResult to the list of
- /// results.
- ///
- /// \param[in] result
- /// The DeclContextLookupResult, usually returned as the result
- /// of querying a DeclContext.
- void AddLookupResult(clang::DeclContextLookupResult result);
-
- /// Add a NamedDecl to the list of results.
- ///
- /// \param[in] decl
- /// The NamedDecl, usually returned as the result
- /// of querying a DeclContext.
- void AddNamedDecl(clang::NamedDecl *decl);
-};
-
} // namespace lldb_private
-#endif // liblldb_ClangASTSource_h_
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGASTSOURCE_H
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
index c87507a25855..867d4ff0a907 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.cpp
@@ -1,4 +1,4 @@
-//===-- ClangDeclVendor.cpp -------------------------------------*- C++ -*-===//
+//===-- ClangDeclVendor.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,9 @@
//===----------------------------------------------------------------------===//
#include "Plugins/ExpressionParser/Clang/ClangDeclVendor.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Utility/ConstString.h"
using namespace lldb_private;
@@ -22,7 +23,7 @@ uint32_t ClangDeclVendor::FindDecls(ConstString name, bool append,
std::vector<CompilerDecl> compiler_decls;
uint32_t ret = FindDecls(name, /*append*/ false, max_matches, compiler_decls);
for (CompilerDecl compiler_decl : compiler_decls) {
- clang::Decl *d = static_cast<clang::Decl *>(compiler_decl.GetOpaqueDecl());
+ clang::Decl *d = ClangUtil::GetDecl(compiler_decl);
clang::NamedDecl *nd = llvm::cast<clang::NamedDecl>(d);
decls.push_back(nd);
}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
index 0c888de08841..bf52bec4b1fa 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangDeclVendor.h
@@ -6,12 +6,15 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ClangDeclVendor_h_
-#define liblldb_ClangDeclVendor_h_
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGDECLVENDOR_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGDECLVENDOR_H
-#include "lldb/Core/ClangForward.h"
#include "lldb/Symbol/DeclVendor.h"
+namespace clang {
+class NamedDecl;
+}
+
namespace lldb_private {
// A clang specialized extension to DeclVendor.
@@ -32,7 +35,8 @@ public:
}
private:
- DISALLOW_COPY_AND_ASSIGN(ClangDeclVendor);
+ ClangDeclVendor(const ClangDeclVendor &) = delete;
+ const ClangDeclVendor &operator=(const ClangDeclVendor &) = delete;
};
} // namespace lldb_private
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h
index 48cd1c4b99fa..7459b715dbe2 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_ClangDiagnostic_h
-#define lldb_ClangDiagnostic_h
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGDIAGNOSTIC_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGDIAGNOSTIC_H
#include <vector>
@@ -47,4 +47,4 @@ private:
};
} // namespace lldb_private
-#endif /* lldb_ClangDiagnostic_h */
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGDIAGNOSTIC_H
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index bf3023be5f60..8c49898e1d6c 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -1,4 +1,4 @@
-//===-- ClangExpressionDeclMap.cpp -----------------------------*- C++ -*-===//
+//===-- ClangExpressionDeclMap.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -11,15 +11,15 @@
#include "ClangASTSource.h"
#include "ClangModulesDeclVendor.h"
#include "ClangPersistentVariables.h"
+#include "ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Expression/Materializer.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/CompilerDecl.h"
#include "lldb/Symbol/CompilerDeclContext.h"
@@ -65,8 +65,8 @@ const char *g_lldb_local_vars_namespace_cstr = "$__lldb_local_vars";
ClangExpressionDeclMap::ClangExpressionDeclMap(
bool keep_result_in_memory,
Materializer::PersistentVariableDelegate *result_delegate,
- const lldb::TargetSP &target, const lldb::ClangASTImporterSP &importer,
- ValueObject *ctx_obj)
+ const lldb::TargetSP &target,
+ const std::shared_ptr<ClangASTImporter> &importer, ValueObject *ctx_obj)
: ClangASTSource(target, importer), m_found_entities(), m_struct_members(),
m_keep_result_in_memory(keep_result_in_memory),
m_result_delegate(result_delegate), m_ctx_obj(ctx_obj), m_parser_vars(),
@@ -109,7 +109,7 @@ bool ClangExpressionDeclMap::WillParse(ExecutionContext &exe_ctx,
m_parser_vars->m_persistent_vars = llvm::cast<ClangPersistentVariables>(
target->GetPersistentExpressionStateForLanguage(eLanguageTypeC));
- if (!ClangASTContext::GetScratch(*target))
+ if (!TypeSystemClang::GetScratch(*target))
return false;
}
@@ -174,19 +174,14 @@ ClangExpressionDeclMap::TargetInfo ClangExpressionDeclMap::GetTargetInfo() {
return ret;
}
-TypeFromUser ClangExpressionDeclMap::DeportType(ClangASTContext &target,
- ClangASTContext &source,
+TypeFromUser ClangExpressionDeclMap::DeportType(TypeSystemClang &target,
+ TypeSystemClang &source,
TypeFromParser parser_type) {
- assert(&target == ClangASTContext::GetScratch(*m_target));
+ assert(&target == TypeSystemClang::GetScratch(*m_target));
assert((TypeSystem *)&source == parser_type.GetTypeSystem());
assert(&source.getASTContext() == m_ast_context);
- if (m_ast_importer_sp) {
- return TypeFromUser(m_ast_importer_sp->DeportType(target, parser_type));
- } else {
- lldbassert(0 && "No mechanism for deporting a type!");
- return TypeFromUser();
- }
+ return TypeFromUser(m_ast_importer_sp->DeportType(target, parser_type));
}
bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
@@ -196,8 +191,8 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
bool is_lvalue) {
assert(m_parser_vars.get());
- ClangASTContext *ast =
- llvm::dyn_cast_or_null<ClangASTContext>(parser_type.GetTypeSystem());
+ TypeSystemClang *ast =
+ llvm::dyn_cast_or_null<TypeSystemClang>(parser_type.GetTypeSystem());
if (ast == nullptr)
return false;
@@ -209,7 +204,7 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
if (target == nullptr)
return false;
- auto *clang_ast_context = ClangASTContext::GetScratch(*target);
+ auto *clang_ast_context = TypeSystemClang::GetScratch(*target);
if (!clang_ast_context)
return false;
@@ -231,7 +226,6 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
var->GetParserVars(GetParserID());
parser_vars->m_named_decl = decl;
- parser_vars->m_parser_type = parser_type;
var->EnableJITVars(GetParserID());
@@ -248,14 +242,14 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
if (target == nullptr)
return false;
- ClangASTContext *context = ClangASTContext::GetScratch(*target);
+ TypeSystemClang *context = TypeSystemClang::GetScratch(*target);
if (!context)
return false;
TypeFromUser user_type = DeportType(*context, *ast, parser_type);
if (!user_type.GetOpaqueQualType()) {
- LLDB_LOGF(log, "Persistent variable's type wasn't copied successfully");
+ LLDB_LOG(log, "Persistent variable's type wasn't copied successfully");
return false;
}
@@ -297,7 +291,7 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
var->m_flags |= ClangExpressionVariable::EVKeepInTarget;
}
- LLDB_LOGF(log, "Created persistent variable with flags 0x%hx", var->m_flags);
+ LLDB_LOG(log, "Created persistent variable with flags {0:x}", var->m_flags);
var->EnableParserVars(GetParserID());
@@ -305,7 +299,6 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
var->GetParserVars(GetParserID());
parser_vars->m_named_decl = decl;
- parser_vars->m_parser_type = parser_type;
return true;
}
@@ -339,9 +332,8 @@ bool ClangExpressionDeclMap::AddValueToStruct(const NamedDecl *decl,
if (!var)
return false;
- LLDB_LOGF(log, "Adding value for (NamedDecl*)%p [%s - %s] to the structure",
- static_cast<const void *>(decl), name.GetCString(),
- var->GetName().GetCString());
+ LLDB_LOG(log, "Adding value for (NamedDecl*)%p [%s - %s] to the structure",
+ decl, name, var->GetName());
// We know entity->m_parser_vars is valid because we used a parser variable
// to find it
@@ -355,8 +347,7 @@ bool ClangExpressionDeclMap::AddValueToStruct(const NamedDecl *decl,
llvm::cast<ClangExpressionVariable>(var)->GetJITVars(GetParserID())) {
// We already laid this out; do not touch
- LLDB_LOGF(log, "Already placed at 0x%llx",
- (unsigned long long)jit_vars->m_offset);
+ LLDB_LOG(log, "Already placed at {0:x}", jit_vars->m_offset);
}
llvm::cast<ClangExpressionVariable>(var)->EnableJITVars(GetParserID());
@@ -391,7 +382,7 @@ bool ClangExpressionDeclMap::AddValueToStruct(const NamedDecl *decl,
if (!err.Success())
return false;
- LLDB_LOGF(log, "Placed at 0x%llx", (unsigned long long)offset);
+ LLDB_LOG(log, "Placed at {0:x}", offset);
jit_vars->m_offset =
offset; // TODO DoStructLayout() should not change this.
@@ -600,7 +591,7 @@ addr_t ClangExpressionDeclMap::GetSymbolAddress(ConstString name,
lldb::VariableSP ClangExpressionDeclMap::FindGlobalVariable(
Target &target, ModuleSP &module, ConstString name,
- CompilerDeclContext *namespace_decl) {
+ const CompilerDeclContext &namespace_decl) {
VariableList vars;
if (module && namespace_decl)
@@ -613,7 +604,7 @@ lldb::VariableSP ClangExpressionDeclMap::FindGlobalVariable(
return vars.GetVariableAtIndex(0);
}
-ClangASTContext *ClangExpressionDeclMap::GetClangASTContext() {
+TypeSystemClang *ClangExpressionDeclMap::GetTypeSystemClang() {
StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
if (frame == nullptr)
return nullptr;
@@ -627,7 +618,7 @@ ClangASTContext *ClangExpressionDeclMap::GetClangASTContext() {
if (!frame_decl_context)
return nullptr;
- return llvm::dyn_cast_or_null<ClangASTContext>(
+ return llvm::dyn_cast_or_null<TypeSystemClang>(
frame_decl_context.GetTypeSystem());
}
@@ -641,34 +632,23 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- if (GetImportInProgress()) {
- if (log && log->GetVerbose())
- LLDB_LOGF(log, "Ignoring a query during an import");
- return;
- }
-
- static unsigned int invocation_id = 0;
- unsigned int current_id = invocation_id++;
-
if (log) {
if (!context.m_decl_context)
- LLDB_LOGF(log,
- "ClangExpressionDeclMap::FindExternalVisibleDecls[%u] for "
- "'%s' in a NULL DeclContext",
- current_id, name.GetCString());
+ LLDB_LOG(log,
+ "ClangExpressionDeclMap::FindExternalVisibleDecls for "
+ "'{0}' in a NULL DeclContext",
+ name);
else if (const NamedDecl *context_named_decl =
dyn_cast<NamedDecl>(context.m_decl_context))
- LLDB_LOGF(log,
- "ClangExpressionDeclMap::FindExternalVisibleDecls[%u] for "
- "'%s' in '%s'",
- current_id, name.GetCString(),
- context_named_decl->getNameAsString().c_str());
+ LLDB_LOG(log,
+ "ClangExpressionDeclMap::FindExternalVisibleDecls for "
+ "'{0}' in '{1}'",
+ name, context_named_decl->getNameAsString());
else
- LLDB_LOGF(log,
- "ClangExpressionDeclMap::FindExternalVisibleDecls[%u] for "
- "'%s' in a '%s'",
- current_id, name.GetCString(),
- context.m_decl_context->getDeclKindName());
+ LLDB_LOG(log,
+ "ClangExpressionDeclMap::FindExternalVisibleDecls for "
+ "'{0}' in a '{1}'",
+ name, context.m_decl_context->getDeclKindName());
}
if (const NamespaceDecl *namespace_context =
@@ -678,42 +658,31 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
CompilerDeclContext compiler_decl_ctx =
m_clang_ast_context->CreateDeclContext(
const_cast<clang::DeclContext *>(context.m_decl_context));
- FindExternalVisibleDecls(context, lldb::ModuleSP(), compiler_decl_ctx,
- current_id);
+ FindExternalVisibleDecls(context, lldb::ModuleSP(), compiler_decl_ctx);
return;
}
ClangASTImporter::NamespaceMapSP namespace_map =
- m_ast_importer_sp
- ? m_ast_importer_sp->GetNamespaceMap(namespace_context)
- : ClangASTImporter::NamespaceMapSP();
+ m_ast_importer_sp->GetNamespaceMap(namespace_context);
if (!namespace_map)
return;
- if (log && log->GetVerbose())
- log->Printf(" CEDM::FEVD[%u] Inspecting (NamespaceMap*)%p (%d entries)",
- current_id, static_cast<void *>(namespace_map.get()),
- (int)namespace_map->size());
+ LLDB_LOGV(log, " CEDM::FEVD Inspecting (NamespaceMap*){0:x} ({1} entries)",
+ namespace_map.get(), namespace_map->size());
- for (ClangASTImporter::NamespaceMap::iterator i = namespace_map->begin(),
- e = namespace_map->end();
- i != e; ++i) {
- if (log)
- log->Printf(" CEDM::FEVD[%u] Searching namespace %s in module %s",
- current_id, i->second.GetName().AsCString(),
- i->first->GetFileSpec().GetFilename().GetCString());
+ for (ClangASTImporter::NamespaceMapItem &n : *namespace_map) {
+ LLDB_LOG(log, " CEDM::FEVD Searching namespace {0} in module {1}",
+ n.second.GetName(), n.first->GetFileSpec().GetFilename());
- FindExternalVisibleDecls(context, i->first, i->second, current_id);
+ FindExternalVisibleDecls(context, n.first, n.second);
}
} else if (isa<TranslationUnitDecl>(context.m_decl_context)) {
CompilerDeclContext namespace_decl;
- if (log)
- log->Printf(" CEDM::FEVD[%u] Searching the root namespace", current_id);
+ LLDB_LOG(log, " CEDM::FEVD Searching the root namespace");
- FindExternalVisibleDecls(context, lldb::ModuleSP(), namespace_decl,
- current_id);
+ FindExternalVisibleDecls(context, lldb::ModuleSP(), namespace_decl);
}
ClangASTSource::FindExternalVisibleDecls(context);
@@ -734,7 +703,7 @@ clang::NamedDecl *ClangExpressionDeclMap::GetPersistentDecl(ConstString name) {
if (!target)
return nullptr;
- ClangASTContext::GetScratch(*target);
+ TypeSystemClang::GetScratch(*target);
if (!m_parser_vars->m_persistent_vars)
return nullptr;
@@ -742,8 +711,7 @@ clang::NamedDecl *ClangExpressionDeclMap::GetPersistentDecl(ConstString name) {
}
void ClangExpressionDeclMap::SearchPersistenDecls(NameSearchContext &context,
- const ConstString name,
- unsigned int current_id) {
+ const ConstString name) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
NamedDecl *persistent_decl = GetPersistentDecl(name);
@@ -766,14 +734,12 @@ void ClangExpressionDeclMap::SearchPersistenDecls(NameSearchContext &context,
MaybeRegisterFunctionBody(parser_function_decl);
}
- LLDB_LOGF(log, " CEDM::FEVD[%u] Found persistent decl %s", current_id,
- name.GetCString());
+ LLDB_LOG(log, " CEDM::FEVD Found persistent decl %s", name);
context.AddNamedDecl(parser_named_decl);
}
-void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context,
- unsigned int current_id) {
+void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
@@ -788,8 +754,7 @@ void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context,
if (!ctx_obj_ptr || status.Fail())
return;
- AddThisType(context, TypeFromUser(m_ctx_obj->GetCompilerType()),
- current_id);
+ AddContextClassType(context, TypeFromUser(m_ctx_obj->GetCompilerType()));
m_struct_vars->m_object_pointer_type =
TypeFromUser(ctx_obj_ptr->GetCompilerType());
@@ -814,7 +779,7 @@ void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context,
return;
clang::CXXMethodDecl *method_decl =
- ClangASTContext::DeclContextGetAsCXXMethodDecl(function_decl_ctx);
+ TypeSystemClang::DeclContextGetAsCXXMethodDecl(function_decl_ctx);
if (method_decl) {
clang::CXXRecordDecl *class_decl = method_decl->getParent();
@@ -824,10 +789,10 @@ void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context,
TypeFromUser class_user_type(class_qual_type.getAsOpaquePtr(),
function_decl_ctx.GetTypeSystem());
- LLDB_LOG(log, " CEDM::FEVD[{0}] Adding type for $__lldb_class: {1}",
- current_id, class_qual_type.getAsString());
+ LLDB_LOG(log, " CEDM::FEVD Adding type for $__lldb_class: {1}",
+ class_qual_type.getAsString());
- AddThisType(context, class_user_type, current_id);
+ AddContextClassType(context, class_user_type);
if (method_decl->isInstance()) {
// self is a pointer to the object
@@ -866,17 +831,16 @@ void ClangExpressionDeclMap::LookUpLldbClass(NameSearchContext &context,
TypeFromUser pointee_type =
this_type->GetForwardCompilerType().GetPointeeType();
- LLDB_LOG(log, " FEVD[{0}] Adding type for $__lldb_class: {1}", current_id,
+ LLDB_LOG(log, " FEVD Adding type for $__lldb_class: {1}",
ClangUtil::GetQualType(pointee_type).getAsString());
- AddThisType(context, pointee_type, current_id);
+ AddContextClassType(context, pointee_type);
TypeFromUser this_user_type(this_type->GetFullCompilerType());
m_struct_vars->m_object_pointer_type = this_user_type;
}
}
-void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context,
- unsigned int current_id) {
+void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
StackFrame *frame = m_parser_vars->m_exe_ctx.GetFramePtr();
@@ -887,7 +851,7 @@ void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context,
if (!ctx_obj_ptr || status.Fail())
return;
- AddOneType(context, TypeFromUser(m_ctx_obj->GetCompilerType()), current_id);
+ AddOneType(context, TypeFromUser(m_ctx_obj->GetCompilerType()));
m_struct_vars->m_object_pointer_type =
TypeFromUser(ctx_obj_ptr->GetCompilerType());
@@ -915,7 +879,7 @@ void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context,
return;
clang::ObjCMethodDecl *method_decl =
- ClangASTContext::DeclContextGetAsObjCMethodDecl(function_decl_ctx);
+ TypeSystemClang::DeclContextGetAsObjCMethodDecl(function_decl_ctx);
if (method_decl) {
ObjCInterfaceDecl *self_interface = method_decl->getClassInterface();
@@ -933,9 +897,9 @@ void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context,
function_decl_ctx.GetTypeSystem());
LLDB_LOG(log, " FEVD[{0}] Adding type for $__lldb_objc_class: {1}",
- current_id, ClangUtil::ToString(interface_type));
+ ClangUtil::ToString(interface_type));
- AddOneType(context, class_user_type, current_id);
+ AddOneType(context, class_user_type);
if (method_decl->isInstanceMethod()) {
// self is a pointer to the object
@@ -984,10 +948,10 @@ void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context,
CompilerType self_clang_type = self_type->GetFullCompilerType();
- if (ClangASTContext::IsObjCClassType(self_clang_type)) {
+ if (TypeSystemClang::IsObjCClassType(self_clang_type)) {
return;
}
- if (!ClangASTContext::IsObjCObjectPointerType(self_clang_type))
+ if (!TypeSystemClang::IsObjCObjectPointerType(self_clang_type))
return;
self_clang_type = self_clang_type.GetPointeeType();
@@ -995,11 +959,11 @@ void ClangExpressionDeclMap::LookUpLldbObjCClass(NameSearchContext &context,
return;
LLDB_LOG(log, " FEVD[{0}] Adding type for $__lldb_objc_class: {1}",
- current_id, ClangUtil::ToString(self_type->GetFullCompilerType()));
+ ClangUtil::ToString(self_type->GetFullCompilerType()));
TypeFromUser class_user_type(self_clang_type);
- AddOneType(context, class_user_type, current_id);
+ AddOneType(context, class_user_type);
TypeFromUser self_user_type(self_type->GetFullCompilerType());
@@ -1015,25 +979,25 @@ void ClangExpressionDeclMap::LookupLocalVarNamespace(
if (!frame_decl_context)
return;
- ClangASTContext *frame_ast = llvm::dyn_cast_or_null<ClangASTContext>(
+ TypeSystemClang *frame_ast = llvm::dyn_cast_or_null<TypeSystemClang>(
frame_decl_context.GetTypeSystem());
if (!frame_ast)
return;
clang::NamespaceDecl *namespace_decl =
m_clang_ast_context->GetUniqueNamespaceDeclaration(
- g_lldb_local_vars_namespace_cstr, nullptr);
+ g_lldb_local_vars_namespace_cstr, nullptr, OptionalClangModuleID());
if (!namespace_decl)
return;
name_context.AddNamedDecl(namespace_decl);
clang::DeclContext *ctxt = clang::Decl::castToDeclContext(namespace_decl);
ctxt->setHasExternalVisibleStorage(true);
- name_context.m_found.local_vars_nsp = true;
+ name_context.m_found_local_vars_nsp = true;
}
void ClangExpressionDeclMap::LookupInModulesDeclVendor(
- NameSearchContext &context, ConstString name, unsigned current_id) {
+ NameSearchContext &context, ConstString name) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
if (!m_target)
@@ -1054,16 +1018,14 @@ void ClangExpressionDeclMap::LookupInModulesDeclVendor(
clang::NamedDecl *const decl_from_modules = decls[0];
LLDB_LOG(log,
- " CAS::FEVD[{0}] Matching decl found for "
+ " CAS::FEVD Matching decl found for "
"\"{1}\" in the modules",
- current_id, name);
+ name);
clang::Decl *copied_decl = CopyDecl(decl_from_modules);
if (!copied_decl) {
- LLDB_LOG(log,
- " CAS::FEVD[{0}] - Couldn't export a "
- "declaration from the modules",
- current_id);
+ LLDB_LOG(log, " CAS::FEVD - Couldn't export a "
+ "declaration from the modules");
return;
}
@@ -1072,17 +1034,17 @@ void ClangExpressionDeclMap::LookupInModulesDeclVendor(
context.AddNamedDecl(copied_function);
- context.m_found.function_with_type_info = true;
- context.m_found.function = true;
+ context.m_found_function_with_type_info = true;
+ context.m_found_function = true;
} else if (auto copied_var = dyn_cast<clang::VarDecl>(copied_decl)) {
context.AddNamedDecl(copied_var);
- context.m_found.variable = true;
+ context.m_found_variable = true;
}
}
bool ClangExpressionDeclMap::LookupLocalVariable(
- NameSearchContext &context, ConstString name, unsigned current_id,
- SymbolContext &sym_ctx, CompilerDeclContext &namespace_decl) {
+ NameSearchContext &context, ConstString name, SymbolContext &sym_ctx,
+ const CompilerDeclContext &namespace_decl) {
if (sym_ctx.block == nullptr)
return false;
@@ -1117,8 +1079,8 @@ bool ClangExpressionDeclMap::LookupLocalVariable(
if (var && !variable_found) {
variable_found = true;
ValueObjectSP valobj = ValueObjectVariable::Create(frame, var);
- AddOneVariable(context, var, valobj, current_id);
- context.m_found.variable = true;
+ AddOneVariable(context, var, valobj);
+ context.m_found_variable = true;
}
}
return variable_found;
@@ -1148,7 +1110,7 @@ SymbolContextList ClangExpressionDeclMap::SearchFunctionsInSymbolContexts(
decl_infos.reserve(num_indices);
clang::DeclContext *frame_decl_ctx =
(clang::DeclContext *)frame_decl_context.GetOpaqueDeclContext();
- ClangASTContext *ast = llvm::dyn_cast_or_null<ClangASTContext>(
+ TypeSystemClang *ast = llvm::dyn_cast_or_null<TypeSystemClang>(
frame_decl_context.GetTypeSystem());
for (uint32_t index = 0; index < num_indices; ++index) {
@@ -1222,11 +1184,9 @@ SymbolContextList ClangExpressionDeclMap::SearchFunctionsInSymbolContexts(
return sc_func_list;
}
-void ClangExpressionDeclMap::LookupFunction(NameSearchContext &context,
- lldb::ModuleSP module_sp,
- ConstString name,
- CompilerDeclContext &namespace_decl,
- unsigned current_id) {
+void ClangExpressionDeclMap::LookupFunction(
+ NameSearchContext &context, lldb::ModuleSP module_sp, ConstString name,
+ const CompilerDeclContext &namespace_decl) {
if (!m_parser_vars)
return;
@@ -1246,7 +1206,7 @@ void ClangExpressionDeclMap::LookupFunction(NameSearchContext &context,
if (namespace_decl && module_sp) {
const bool include_symbols = false;
- module_sp->FindFunctions(name, &namespace_decl, eFunctionNameTypeBase,
+ module_sp->FindFunctions(name, namespace_decl, eFunctionNameTypeBase,
include_symbols, include_inlines, sc_list);
} else if (target && !namespace_decl) {
const bool include_symbols = true;
@@ -1304,9 +1264,9 @@ void ClangExpressionDeclMap::LookupFunction(NameSearchContext &context,
if (decl_ctx.IsClassMethod(nullptr, nullptr, nullptr))
continue;
- AddOneFunction(context, sym_ctx.function, nullptr, current_id);
- context.m_found.function_with_type_info = true;
- context.m_found.function = true;
+ AddOneFunction(context, sym_ctx.function, nullptr);
+ context.m_found_function_with_type_info = true;
+ context.m_found_function = true;
} else if (sym_ctx.symbol) {
if (sym_ctx.symbol->GetType() == eSymbolTypeReExported && target) {
sym_ctx.symbol = sym_ctx.symbol->ResolveReExportedSymbol(*target);
@@ -1321,26 +1281,26 @@ void ClangExpressionDeclMap::LookupFunction(NameSearchContext &context,
}
}
- if (!context.m_found.function_with_type_info) {
+ if (!context.m_found_function_with_type_info) {
for (clang::NamedDecl *decl : decls_from_modules) {
if (llvm::isa<clang::FunctionDecl>(decl)) {
clang::NamedDecl *copied_decl =
llvm::cast_or_null<FunctionDecl>(CopyDecl(decl));
if (copied_decl) {
context.AddNamedDecl(copied_decl);
- context.m_found.function_with_type_info = true;
+ context.m_found_function_with_type_info = true;
}
}
}
}
- if (!context.m_found.function_with_type_info) {
+ if (!context.m_found_function_with_type_info) {
if (extern_symbol) {
- AddOneFunction(context, nullptr, extern_symbol, current_id);
- context.m_found.function = true;
+ AddOneFunction(context, nullptr, extern_symbol);
+ context.m_found_function = true;
} else if (non_extern_symbol) {
- AddOneFunction(context, nullptr, non_extern_symbol, current_id);
- context.m_found.function = true;
+ AddOneFunction(context, nullptr, non_extern_symbol);
+ context.m_found_function = true;
}
}
}
@@ -1348,7 +1308,7 @@ void ClangExpressionDeclMap::LookupFunction(NameSearchContext &context,
void ClangExpressionDeclMap::FindExternalVisibleDecls(
NameSearchContext &context, lldb::ModuleSP module_sp,
- CompilerDeclContext &namespace_decl, unsigned int current_id) {
+ const CompilerDeclContext &namespace_decl) {
assert(m_ast_context);
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
@@ -1373,16 +1333,16 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
// Try the persistent decls, which take precedence over all else.
if (!namespace_decl)
- SearchPersistenDecls(context, name, current_id);
+ SearchPersistenDecls(context, name);
if (name.GetStringRef().startswith("$") && !namespace_decl) {
if (name == "$__lldb_class") {
- LookUpLldbClass(context, current_id);
+ LookUpLldbClass(context);
return;
}
if (name == "$__lldb_objc_class") {
- LookUpLldbObjCClass(context, current_id);
+ LookUpLldbObjCClass(context);
return;
}
if (name == g_lldb_local_vars_namespace_cstr) {
@@ -1402,7 +1362,7 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
m_parser_vars->m_persistent_vars->GetVariable(name));
if (pvar_sp) {
- AddOneVariable(context, pvar_sp, current_id);
+ AddOneVariable(context, pvar_sp);
return;
}
@@ -1415,10 +1375,9 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
reg_name));
if (reg_info) {
- LLDB_LOGF(log, " CEDM::FEVD[%u] Found register %s", current_id,
- reg_info->name);
+ LLDB_LOG(log, " CEDM::FEVD Found register {0}", reg_info->name);
- AddOneRegister(context, reg_info, current_id);
+ AddOneRegister(context, reg_info);
}
}
return;
@@ -1427,29 +1386,29 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
bool local_var_lookup = !namespace_decl || (namespace_decl.GetName() ==
g_lldb_local_vars_namespace_cstr);
if (frame && local_var_lookup)
- if (LookupLocalVariable(context, name, current_id, sym_ctx, namespace_decl))
+ if (LookupLocalVariable(context, name, sym_ctx, namespace_decl))
return;
if (target) {
ValueObjectSP valobj;
VariableSP var;
- var = FindGlobalVariable(*target, module_sp, name, &namespace_decl);
+ var = FindGlobalVariable(*target, module_sp, name, namespace_decl);
if (var) {
valobj = ValueObjectVariable::Create(target, var);
- AddOneVariable(context, var, valobj, current_id);
- context.m_found.variable = true;
+ AddOneVariable(context, var, valobj);
+ context.m_found_variable = true;
return;
}
}
- LookupFunction(context, module_sp, name, namespace_decl, current_id);
+ LookupFunction(context, module_sp, name, namespace_decl);
// Try the modules next.
- if (!context.m_found.function_with_type_info)
- LookupInModulesDeclVendor(context, name, current_id);
+ if (!context.m_found_function_with_type_info)
+ LookupInModulesDeclVendor(context, name);
- if (target && !context.m_found.variable && !namespace_decl) {
+ if (target && !context.m_found_variable && !namespace_decl) {
// We couldn't find a non-symbol variable for this. Now we'll hunt for a
// generic data symbol, and -- if it is found -- treat it as a variable.
Status error;
@@ -1471,8 +1430,8 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
m_ast_context->getDiagnostics().getCustomDiagID(
clang::DiagnosticsEngine::Level::Warning, "%0");
m_ast_context->getDiagnostics().Report(diag_id) << warning.c_str();
- AddOneGenericVariable(context, *data_symbol, current_id);
- context.m_found.variable = true;
+ AddOneGenericVariable(context, *data_symbol);
+ context.m_found_variable = true;
}
}
}
@@ -1486,25 +1445,22 @@ bool ClangExpressionDeclMap::GetVariableValue(VariableSP &var,
Type *var_type = var->GetType();
if (!var_type) {
- if (log)
- log->PutCString("Skipped a definition because it has no type");
+ LLDB_LOG(log, "Skipped a definition because it has no type");
return false;
}
CompilerType var_clang_type = var_type->GetFullCompilerType();
if (!var_clang_type) {
- if (log)
- log->PutCString("Skipped a definition because it has no Clang type");
+ LLDB_LOG(log, "Skipped a definition because it has no Clang type");
return false;
}
- ClangASTContext *clang_ast = llvm::dyn_cast_or_null<ClangASTContext>(
+ TypeSystemClang *clang_ast = llvm::dyn_cast_or_null<TypeSystemClang>(
var_type->GetForwardCompilerType().GetTypeSystem());
if (!clang_ast) {
- if (log)
- log->PutCString("Skipped a definition because it has no Clang AST");
+ LLDB_LOG(log, "Skipped a definition because it has no Clang AST");
return false;
}
@@ -1521,7 +1477,7 @@ bool ClangExpressionDeclMap::GetVariableValue(VariableSP &var,
const_value_extractor.GetByteSize());
var_location.SetValueType(Value::eValueTypeHostAddress);
} else {
- LLDB_LOGF(log, "Error evaluating constant variable: %s", err.AsCString());
+ LLDB_LOG(log, "Error evaluating constant variable: {0}", err.AsCString());
return false;
}
}
@@ -1529,8 +1485,8 @@ bool ClangExpressionDeclMap::GetVariableValue(VariableSP &var,
CompilerType type_to_use = GuardedCopyType(var_clang_type);
if (!type_to_use) {
- LLDB_LOGF(log,
- "Couldn't copy a variable's type into the parser's AST context");
+ LLDB_LOG(log,
+ "Couldn't copy a variable's type into the parser's AST context");
return false;
}
@@ -1567,8 +1523,7 @@ bool ClangExpressionDeclMap::GetVariableValue(VariableSP &var,
void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
VariableSP var,
- ValueObjectSP valobj,
- unsigned int current_id) {
+ ValueObjectSP valobj) {
assert(m_parser_vars.get());
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
@@ -1611,7 +1566,6 @@ void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
entity->EnableParserVars(GetParserID());
ClangExpressionVariable::ParserVars *parser_vars =
entity->GetParserVars(GetParserID());
- parser_vars->m_parser_type = pt;
parser_vars->m_named_decl = var_decl;
parser_vars->m_llvm_value = nullptr;
parser_vars->m_lldb_value = var_location;
@@ -1620,15 +1574,12 @@ void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
if (is_reference)
entity->m_flags |= ClangExpressionVariable::EVTypeIsReference;
- LLDB_LOG(log,
- " CEDM::FEVD[{0}] Found variable {1}, returned\n{2} (original {3})",
- current_id, decl_name, ClangUtil::DumpDecl(var_decl),
- ClangUtil::ToString(ut));
+ LLDB_LOG(log, " CEDM::FEVD Found variable {1}, returned\n{2} (original {3})",
+ decl_name, ClangUtil::DumpDecl(var_decl), ClangUtil::ToString(ut));
}
void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
- ExpressionVariableSP &pvar_sp,
- unsigned int current_id) {
+ ExpressionVariableSP &pvar_sp) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
TypeFromUser user_type(
@@ -1637,8 +1588,8 @@ void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
TypeFromParser parser_type(GuardedCopyType(user_type));
if (!parser_type.GetOpaqueQualType()) {
- LLDB_LOGF(log, " CEDM::FEVD[%u] Couldn't import type for pvar %s",
- current_id, pvar_sp->GetName().GetCString());
+ LLDB_LOG(log, " CEDM::FEVD Couldn't import type for pvar {0}",
+ pvar_sp->GetName());
return;
}
@@ -1650,18 +1601,16 @@ void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
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 = nullptr;
parser_vars->m_lldb_value.Clear();
- LLDB_LOG(log, " CEDM::FEVD[{0}] Added pvar {1}, returned\n{2}", current_id,
+ LLDB_LOG(log, " CEDM::FEVD Added pvar {1}, returned\n{2}",
pvar_sp->GetName(), ClangUtil::DumpDecl(var_decl));
}
void ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
- const Symbol &symbol,
- unsigned int current_id) {
+ const Symbol &symbol) {
assert(m_parser_vars.get());
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
@@ -1671,7 +1620,7 @@ void ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
if (target == nullptr)
return;
- ClangASTContext *scratch_ast_context = ClangASTContext::GetScratch(*target);
+ TypeSystemClang *scratch_ast_context = TypeSystemClang::GetScratch(*target);
if (!scratch_ast_context)
return;
@@ -1704,18 +1653,16 @@ void ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
parser_vars->m_lldb_value.GetScalar() = symbol_load_addr;
parser_vars->m_lldb_value.SetValueType(Value::eValueTypeLoadAddress);
- parser_vars->m_parser_type = parser_type;
parser_vars->m_named_decl = var_decl;
parser_vars->m_llvm_value = nullptr;
parser_vars->m_lldb_sym = &symbol;
- LLDB_LOG(log, " CEDM::FEVD[{0}] Found variable {1}, returned\n{2}",
- current_id, decl_name, ClangUtil::DumpDecl(var_decl));
+ LLDB_LOG(log, " CEDM::FEVD Found variable {1}, returned\n{2}", decl_name,
+ ClangUtil::DumpDecl(var_decl));
}
void ClangExpressionDeclMap::AddOneRegister(NameSearchContext &context,
- const RegisterInfo *reg_info,
- unsigned int current_id) {
+ const RegisterInfo *reg_info) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
CompilerType clang_type =
@@ -1723,8 +1670,8 @@ void ClangExpressionDeclMap::AddOneRegister(NameSearchContext &context,
reg_info->encoding, reg_info->byte_size * 8);
if (!clang_type) {
- LLDB_LOGF(log, " Tried to add a type for %s, but couldn't get one",
- context.m_decl_name.getAsString().c_str());
+ LLDB_LOG(log, " Tried to add a type for {0}, but couldn't get one",
+ context.m_decl_name.getAsString());
return;
}
@@ -1744,20 +1691,18 @@ void ClangExpressionDeclMap::AddOneRegister(NameSearchContext &context,
entity->EnableParserVars(GetParserID());
ClangExpressionVariable::ParserVars *parser_vars =
entity->GetParserVars(GetParserID());
- parser_vars->m_parser_type = parser_clang_type;
parser_vars->m_named_decl = var_decl;
parser_vars->m_llvm_value = nullptr;
parser_vars->m_lldb_value.Clear();
entity->m_flags |= ClangExpressionVariable::EVBareRegister;
- LLDB_LOG(log, " CEDM::FEVD[{0}] Added register {1}, returned\n{2}",
- current_id, context.m_decl_name.getAsString(),
- ClangUtil::DumpDecl(var_decl));
+ LLDB_LOG(log, " CEDM::FEVD Added register {1}, returned\n{2}",
+ context.m_decl_name.getAsString(), ClangUtil::DumpDecl(var_decl));
}
void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
- Function *function, Symbol *symbol,
- unsigned int current_id) {
+ Function *function,
+ Symbol *symbol) {
assert(m_parser_vars.get());
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
@@ -1780,7 +1725,7 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
if (!extern_c) {
TypeSystem *type_system = function->GetDeclContext().GetTypeSystem();
- if (llvm::isa<ClangASTContext>(type_system)) {
+ if (llvm::isa<TypeSystemClang>(type_system)) {
clang::DeclContext *src_decl_context =
(clang::DeclContext *)function->GetDeclContext()
.GetOpaqueDeclContext();
@@ -1800,9 +1745,9 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
function->DumpSymbolContext(&ss);
LLDB_LOG(log,
- " CEDM::FEVD[{0}] Imported decl for function template"
+ " CEDM::FEVD Imported decl for function template"
" {1} (description {2}), returned\n{3}",
- current_id, copied_function_template->getNameAsString(),
+ copied_function_template->getNameAsString(),
ss.GetData(),
ClangUtil::DumpDecl(copied_function_template));
}
@@ -1819,35 +1764,31 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
function->DumpSymbolContext(&ss);
LLDB_LOG(log,
- " CEDM::FEVD[{0}]] Imported decl for function {1} "
+ " CEDM::FEVD Imported decl for function {1} "
"(description {2}), returned\n{3}",
- current_id, copied_function_decl->getNameAsString(),
- ss.GetData(), ClangUtil::DumpDecl(copied_function_decl));
+ copied_function_decl->getNameAsString(), ss.GetData(),
+ ClangUtil::DumpDecl(copied_function_decl));
}
context.AddNamedDecl(copied_function_decl);
return;
} else {
- if (log) {
- LLDB_LOGF(log, " Failed to import the function decl for '%s'",
- src_function_decl->getName().str().c_str());
- }
+ LLDB_LOG(log, " Failed to import the function decl for '{0}'",
+ src_function_decl->getName());
}
}
}
}
if (!function_type) {
- if (log)
- log->PutCString(" Skipped a function because it has no type");
+ LLDB_LOG(log, " Skipped a function because it has no type");
return;
}
function_clang_type = function_type->GetFullCompilerType();
if (!function_clang_type) {
- if (log)
- log->PutCString(" Skipped a function because it has no Clang type");
+ LLDB_LOG(log, " Skipped a function because it has no Clang type");
return;
}
@@ -1858,24 +1799,17 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
function_decl = context.AddFunDecl(copied_function_type, extern_c);
if (!function_decl) {
- if (log) {
- LLDB_LOGF(
- log,
- " Failed to create a function decl for '%s' {0x%8.8" PRIx64 "}",
- function_type->GetName().GetCString(), function_type->GetID());
- }
+ LLDB_LOG(log, " Failed to create a function decl for '{0}' ({1:x})",
+ function_type->GetName(), function_type->GetID());
return;
}
} else {
// We failed to copy the type we found
- if (log) {
- LLDB_LOGF(log,
- " Failed to import the function type '%s' {0x%8.8" PRIx64
- "} into the expression parser AST contenxt",
- function_type->GetName().GetCString(),
- function_type->GetID());
- }
+ LLDB_LOG(log,
+ " Failed to import the function type '{0}' ({1:x})"
+ " into the expression parser AST contenxt",
+ function_type->GetName(), function_type->GetID());
return;
}
@@ -1884,8 +1818,7 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
function_decl = context.AddGenericFunDecl();
is_indirect_function = symbol->IsIndirect();
} else {
- if (log)
- log->PutCString(" AddOneFunction called with no function and no symbol");
+ LLDB_LOG(log, " AddOneFunction called with no function and no symbol");
return;
}
@@ -1931,25 +1864,22 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
Address::DumpStyleResolvedDescription);
LLDB_LOG(log,
- " CEDM::FEVD[{0}] Found {1} function {2} (description {3}), "
+ " CEDM::FEVD Found {1} function {2} (description {3}), "
"returned\n{4}",
- current_id, (function ? "specific" : "generic"), decl_name,
- ss.GetData(), ClangUtil::DumpDecl(function_decl));
+ (function ? "specific" : "generic"), decl_name, ss.GetData(),
+ ClangUtil::DumpDecl(function_decl));
}
}
-void ClangExpressionDeclMap::AddThisType(NameSearchContext &context,
- const TypeFromUser &ut,
- unsigned int current_id) {
+void ClangExpressionDeclMap::AddContextClassType(NameSearchContext &context,
+ const TypeFromUser &ut) {
CompilerType copied_clang_type = GuardedCopyType(ut);
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
if (!copied_clang_type) {
- if (log)
- LLDB_LOGF(
- log,
- "ClangExpressionDeclMap::AddThisType - Couldn't import the type");
+ LLDB_LOG(log,
+ "ClangExpressionDeclMap::AddThisType - Couldn't import the type");
return;
}
@@ -2009,16 +1939,14 @@ void ClangExpressionDeclMap::AddThisType(NameSearchContext &context,
}
void ClangExpressionDeclMap::AddOneType(NameSearchContext &context,
- const TypeFromUser &ut,
- unsigned int current_id) {
+ const TypeFromUser &ut) {
CompilerType copied_clang_type = GuardedCopyType(ut);
if (!copied_clang_type) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- if (log)
- LLDB_LOGF(
- log, "ClangExpressionDeclMap::AddOneType - Couldn't import the type");
+ LLDB_LOG(log,
+ "ClangExpressionDeclMap::AddOneType - Couldn't import the type");
return;
}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
index 722f5e15a2aa..6974535a8993 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ClangExpressionDeclMap_h_
-#define liblldb_ClangExpressionDeclMap_h_
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXPRESSIONDECLMAP_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXPRESSIONDECLMAP_H
#include <signal.h>
#include <stdint.h>
@@ -17,7 +17,6 @@
#include "ClangASTSource.h"
#include "ClangExpressionVariable.h"
-#include "lldb/Core/ClangForward.h"
#include "lldb/Core/Value.h"
#include "lldb/Expression/Materializer.h"
#include "lldb/Symbol/SymbolContext.h"
@@ -29,6 +28,8 @@
namespace lldb_private {
+class ClangPersistentVariables;
+
/// \class ClangExpressionDeclMap ClangExpressionDeclMap.h
/// "lldb/Expression/ClangExpressionDeclMap.h" Manages named entities that are
/// defined in LLDB's debug information.
@@ -79,8 +80,8 @@ public:
ClangExpressionDeclMap(
bool keep_result_in_memory,
Materializer::PersistentVariableDelegate *result_delegate,
- const lldb::TargetSP &target, const lldb::ClangASTImporterSP &importer,
- ValueObject *ctx_obj);
+ const lldb::TargetSP &target,
+ const std::shared_ptr<ClangASTImporter> &importer, ValueObject *ctx_obj);
/// Destructor
~ClangExpressionDeclMap() override;
@@ -274,14 +275,9 @@ public:
///
/// \param[in] namespace_decl
/// If valid and module is non-NULL, the parent namespace.
- ///
- /// \param[in] current_id
- /// The ID for the current FindExternalVisibleDecls invocation,
- /// for logging purposes.
void FindExternalVisibleDecls(NameSearchContext &context,
lldb::ModuleSP module,
- CompilerDeclContext &namespace_decl,
- unsigned int current_id);
+ const CompilerDeclContext &namespace_decl);
protected:
/// Retrieves the declaration with the given name from the storage of
@@ -335,7 +331,8 @@ private:
///that receives new top-level
///functions.
private:
- DISALLOW_COPY_AND_ASSIGN(ParserVars);
+ ParserVars(const ParserVars &) = delete;
+ const ParserVars &operator=(const ParserVars &) = delete;
};
std::unique_ptr<ParserVars> m_parser_vars;
@@ -394,32 +391,19 @@ private:
///
/// \param[in] name
/// The name of the entities that need to be found.
- ///
- /// \param[in] current_id
- /// The ID for the current FindExternalVisibleDecls invocation,
- /// for logging purposes.
- void SearchPersistenDecls(NameSearchContext &context, const ConstString name,
- unsigned int current_id);
+ void SearchPersistenDecls(NameSearchContext &context, const ConstString name);
/// Handles looking up $__lldb_class which requires special treatment.
///
/// \param[in] context
/// The NameSearchContext that can construct Decls for this name.
- ///
- /// \param[in] current_id
- /// The ID for the current FindExternalVisibleDecls invocation,
- /// for logging purposes.
- void LookUpLldbClass(NameSearchContext &context, unsigned int current_id);
+ void LookUpLldbClass(NameSearchContext &context);
/// Handles looking up $__lldb_objc_class which requires special treatment.
///
/// \param[in] context
/// The NameSearchContext that can construct Decls for this name.
- ///
- /// \param[in] current_id
- /// The ID for the current FindExternalVisibleDecls invocation,
- /// for logging purposes.
- void LookUpLldbObjCClass(NameSearchContext &context, unsigned int current_id);
+ void LookUpLldbObjCClass(NameSearchContext &context);
/// Handles looking up the synthetic namespace that contains our local
/// variables for the current frame.
@@ -438,12 +422,7 @@ private:
///
/// \param[in] name
/// The name of the entities that need to be found.
- ///
- /// \param[in] current_id
- /// The ID for the current FindExternalVisibleDecls invocation,
- /// for logging purposes.
- void LookupInModulesDeclVendor(NameSearchContext &context, ConstString name,
- unsigned current_id);
+ void LookupInModulesDeclVendor(NameSearchContext &context, ConstString name);
/// Looks up a local variable.
///
@@ -453,10 +432,6 @@ private:
/// \param[in] name
/// The name of the entities that need to be found.
///
- /// \param[in] current_id
- /// The ID for the current FindExternalVisibleDecls invocation,
- /// for logging purposes.
- ///
/// \param[in] sym_ctx
/// The current SymbolContext of this frame.
///
@@ -466,8 +441,8 @@ private:
/// \return
/// True iff a local variable was found.
bool LookupLocalVariable(NameSearchContext &context, ConstString name,
- unsigned current_id, SymbolContext &sym_ctx,
- CompilerDeclContext &namespace_decl);
+ SymbolContext &sym_ctx,
+ const CompilerDeclContext &namespace_decl);
/// Searches for functions in the given SymbolContextList.
///
@@ -499,13 +474,9 @@ private:
///
/// \param[in] namespace_decl
/// If valid and module is non-NULL, the parent namespace.
- ///
- /// \param[in] current_id
- /// The ID for the current FindExternalVisibleDecls invocation,
- /// for logging purposes.
void LookupFunction(NameSearchContext &context, lldb::ModuleSP module_sp,
- ConstString name, CompilerDeclContext &namespace_decl,
- unsigned current_id);
+ ConstString name,
+ const CompilerDeclContext &namespace_decl);
/// Given a target, find a variable that matches the given name and type.
///
@@ -523,9 +494,9 @@ private:
///
/// \return
/// The LLDB Variable found, or NULL if none was found.
- lldb::VariableSP FindGlobalVariable(Target &target, lldb::ModuleSP &module,
- ConstString name,
- CompilerDeclContext *namespace_decl);
+ lldb::VariableSP
+ FindGlobalVariable(Target &target, lldb::ModuleSP &module, ConstString name,
+ const CompilerDeclContext &namespace_decl);
/// Get the value of a variable in a given execution context and return the
/// associated Types if needed.
@@ -565,7 +536,7 @@ private:
/// \param[in] valobj
/// The LLDB ValueObject for that variable.
void AddOneVariable(NameSearchContext &context, lldb::VariableSP var,
- lldb::ValueObjectSP valobj, unsigned int current_id);
+ lldb::ValueObjectSP valobj);
/// Use the NameSearchContext to generate a Decl for the given persistent
/// variable, and put it in the list of found entities.
@@ -575,18 +546,12 @@ private:
///
/// \param[in] pvar_sp
/// The persistent variable that needs a Decl.
- ///
- /// \param[in] current_id
- /// The ID of the current invocation of FindExternalVisibleDecls
- /// for logging purposes.
void AddOneVariable(NameSearchContext &context,
- lldb::ExpressionVariableSP &pvar_sp,
- unsigned int current_id);
+ lldb::ExpressionVariableSP &pvar_sp);
/// Use the NameSearchContext to generate a Decl for the given LLDB symbol
/// (treated as a variable), and put it in the list of found entities.
- void AddOneGenericVariable(NameSearchContext &context, const Symbol &symbol,
- unsigned int current_id);
+ void AddOneGenericVariable(NameSearchContext &context, const Symbol &symbol);
/// Use the NameSearchContext to generate a Decl for the given function.
/// (Functions are not placed in the Tuple list.) Can handle both fully
@@ -602,8 +567,7 @@ private:
/// \param[in] sym
/// The Symbol that corresponds to a function that needs to be
/// created with generic type (unitptr_t foo(...)).
- void AddOneFunction(NameSearchContext &context, Function *fun, Symbol *sym,
- unsigned int current_id);
+ void AddOneFunction(NameSearchContext &context, Function *fun, Symbol *sym);
/// Use the NameSearchContext to generate a Decl for the given register.
///
@@ -612,8 +576,7 @@ private:
///
/// \param[in] reg_info
/// The information corresponding to that register.
- void AddOneRegister(NameSearchContext &context, const RegisterInfo *reg_info,
- unsigned int current_id);
+ void AddOneRegister(NameSearchContext &context, const RegisterInfo *reg_info);
/// Use the NameSearchContext to generate a Decl for the given type. (Types
/// are not placed in the Tuple list.)
@@ -623,38 +586,40 @@ private:
///
/// \param[in] type
/// The type that needs to be created.
- void AddOneType(NameSearchContext &context, const TypeFromUser &type,
- unsigned int current_id);
+ void AddOneType(NameSearchContext &context, const TypeFromUser &type);
- /// Generate a Decl for "*this" and add a member function declaration to it
- /// for the expression, then report it.
+ /// Adds the class in which the expression is evaluated to the lookup and
+ /// prepares the class to be used as a context for expression evaluation (for
+ /// example, it creates a fake member function that will contain the
+ /// expression LLDB is trying to evaluate).
///
/// \param[in] context
- /// The NameSearchContext to use when constructing the Decl.
+ /// The NameSearchContext to which the class should be added as a lookup
+ /// result.
///
/// \param[in] type
- /// The type for *this.
- void AddThisType(NameSearchContext &context, const TypeFromUser &type,
- unsigned int current_id);
+ /// The type of the class that serves as the evaluation context.
+ void AddContextClassType(NameSearchContext &context,
+ const TypeFromUser &type);
/// Move a type out of the current ASTContext into another, but make sure to
/// export all components of the type also.
///
/// \param[in] target
- /// The ClangASTContext to move to.
+ /// The TypeSystemClang to move to.
/// \param[in] source
- /// The ClangASTContext to move from. This is assumed to be going away.
+ /// The TypeSystemClang to move from. This is assumed to be going away.
/// \param[in] parser_type
/// The type as it appears in the source context.
///
/// \return
/// Returns the moved type, or an empty type if there was a problem.
- TypeFromUser DeportType(ClangASTContext &target, ClangASTContext &source,
+ TypeFromUser DeportType(TypeSystemClang &target, TypeSystemClang &source,
TypeFromParser parser_type);
- ClangASTContext *GetClangASTContext();
+ TypeSystemClang *GetTypeSystemClang();
};
} // namespace lldb_private
-#endif // liblldb_ClangExpressionDeclMap_h_
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXPRESSIONDECLMAP_H
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h
index 48da5abb9126..e33e5df22236 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h
@@ -6,21 +6,24 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ClangExpression_h_
-#define liblldb_ClangExpression_h_
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXPRESSIONHELPER_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXPRESSIONHELPER_H
#include <map>
#include <string>
#include <vector>
-
-#include "lldb/Core/ClangForward.h"
#include "lldb/Expression/ExpressionTypeSystemHelper.h"
#include "lldb/lldb-forward.h"
#include "lldb/lldb-private.h"
+namespace clang {
+class ASTConsumer;
+}
+
namespace lldb_private {
+class ClangExpressionDeclMap;
class RecordingMemoryManager;
// ClangExpressionHelper
@@ -57,4 +60,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_ClangExpression_h_
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXPRESSIONHELPER_H
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 8abd14942885..6ff028cf6980 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -1,4 +1,4 @@
-//===-- ClangExpressionParser.cpp -------------------------------*- C++ -*-===//
+//===-- ClangExpressionParser.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -67,6 +67,7 @@
#include "IRForTarget.h"
#include "ModuleDependencyCollector.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/Module.h"
@@ -75,7 +76,6 @@
#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/Language.h"
@@ -91,6 +91,7 @@
#include "lldb/Utility/StringList.h"
#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+#include "Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h"
#include <cctype>
#include <memory>
@@ -146,21 +147,40 @@ public:
llvm::StringRef getErrorString() { return m_error_stream.GetString(); }
};
+static void AddAllFixIts(ClangDiagnostic *diag, const clang::Diagnostic &Info) {
+ for (auto &fix_it : Info.getFixItHints()) {
+ if (fix_it.isNull())
+ continue;
+ diag->AddFixitHint(fix_it);
+ }
+}
+
class ClangDiagnosticManagerAdapter : public clang::DiagnosticConsumer {
public:
ClangDiagnosticManagerAdapter(DiagnosticOptions &opts) {
- DiagnosticOptions *m_options = new DiagnosticOptions(opts);
- m_options->ShowPresumedLoc = true;
- m_options->ShowLevel = false;
- m_os.reset(new llvm::raw_string_ostream(m_output));
- m_passthrough.reset(
- new clang::TextDiagnosticPrinter(*m_os, m_options, false));
+ DiagnosticOptions *options = new DiagnosticOptions(opts);
+ options->ShowPresumedLoc = true;
+ options->ShowLevel = false;
+ m_os = std::make_shared<llvm::raw_string_ostream>(m_output);
+ m_passthrough =
+ std::make_shared<clang::TextDiagnosticPrinter>(*m_os, options);
}
void ResetManager(DiagnosticManager *manager = nullptr) {
m_manager = manager;
}
+ /// Returns the last ClangDiagnostic message that the DiagnosticManager
+ /// received or a nullptr if the DiagnosticMangager hasn't seen any
+ /// Clang diagnostics yet.
+ ClangDiagnostic *MaybeGetLastClangDiag() const {
+ if (m_manager->Diagnostics().empty())
+ return nullptr;
+ lldb_private::Diagnostic *diag = m_manager->Diagnostics().back().get();
+ ClangDiagnostic *clang_diag = dyn_cast<ClangDiagnostic>(diag);
+ return clang_diag;
+ }
+
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
const clang::Diagnostic &Info) override {
if (!m_manager) {
@@ -180,6 +200,9 @@ public:
return;
}
+ // Update error/warning counters.
+ DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info);
+
// Render diagnostic message to m_output.
m_output.clear();
m_passthrough->HandleDiagnostic(DiagLevel, Info);
@@ -203,11 +226,29 @@ public:
case DiagnosticsEngine::Level::Note:
m_manager->AppendMessageToDiagnostic(m_output);
make_new_diagnostic = false;
+
+ // 'note:' diagnostics for errors and warnings can also contain Fix-Its.
+ // We add these Fix-Its to the last error diagnostic to make sure
+ // that we later have all Fix-Its related to an 'error' diagnostic when
+ // we apply them to the user expression.
+ auto *clang_diag = MaybeGetLastClangDiag();
+ // If we don't have a previous diagnostic there is nothing to do.
+ // If the previous diagnostic already has its own Fix-Its, assume that
+ // the 'note:' Fix-It is just an alternative way to solve the issue and
+ // ignore these Fix-Its.
+ if (!clang_diag || clang_diag->HasFixIts())
+ break;
+ // Ignore all Fix-Its that are not associated with an error.
+ if (clang_diag->GetSeverity() != eDiagnosticSeverityError)
+ break;
+ AddAllFixIts(clang_diag, Info);
+ break;
}
if (make_new_diagnostic) {
// ClangDiagnostic messages are expected to have no whitespace/newlines
// around them.
- std::string stripped_output = llvm::StringRef(m_output).trim();
+ std::string stripped_output =
+ std::string(llvm::StringRef(m_output).trim());
auto new_diagnostic = std::make_unique<ClangDiagnostic>(
stripped_output, severity, Info.getID());
@@ -216,20 +257,18 @@ public:
// enough context in an expression for the warning to be useful.
// FIXME: Should we try to filter out FixIts that apply to our generated
// code, and not the user's expression?
- if (severity == eDiagnosticSeverityError) {
- size_t num_fixit_hints = Info.getNumFixItHints();
- for (size_t i = 0; i < num_fixit_hints; i++) {
- const clang::FixItHint &fixit = Info.getFixItHint(i);
- if (!fixit.isNull())
- new_diagnostic->AddFixitHint(fixit);
- }
- }
+ if (severity == eDiagnosticSeverityError)
+ AddAllFixIts(new_diagnostic.get(), Info);
m_manager->AddDiagnostic(std::move(new_diagnostic));
}
}
- clang::TextDiagnosticPrinter *GetPassthrough() { return m_passthrough.get(); }
+ void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override {
+ m_passthrough->BeginSourceFile(LO, PP);
+ }
+
+ void EndSourceFile() override { m_passthrough->EndSourceFile(); }
private:
DiagnosticManager *m_manager = nullptr;
@@ -253,9 +292,9 @@ static void SetupModuleHeaderPaths(CompilerInstance *compiler,
}
llvm::SmallString<128> module_cache;
- auto props = ModuleList::GetGlobalModuleListProperties();
+ const auto &props = ModuleList::GetGlobalModuleListProperties();
props.GetClangModulesCachePath().GetPath(module_cache);
- search_opts.ModuleCachePath = module_cache.str();
+ search_opts.ModuleCachePath = std::string(module_cache.str());
LLDB_LOG(log, "Using module cache path: {0}", module_cache.c_str());
search_opts.ResourceDir = GetClangResourceDir().GetPath();
@@ -279,28 +318,27 @@ ClangExpressionParser::ClangExpressionParser(
// We can't compile expressions without a target. So if the exe_scope is
// null or doesn't have a target, then we just need to get out of here. I'll
- // lldb_assert and not make any of the compiler objects since
+ // lldbassert and not make any of the compiler objects since
// I can't return errors directly from the constructor. Further calls will
// check if the compiler was made and
// bag out if it wasn't.
if (!exe_scope) {
- lldb_assert(exe_scope, "Can't make an expression parser with a null scope.",
- __FUNCTION__, __FILE__, __LINE__);
+ lldbassert(exe_scope &&
+ "Can't make an expression parser with a null scope.");
return;
}
lldb::TargetSP target_sp;
target_sp = exe_scope->CalculateTarget();
if (!target_sp) {
- lldb_assert(target_sp.get(),
- "Can't make an expression parser with a null target.",
- __FUNCTION__, __FILE__, __LINE__);
+ lldbassert(target_sp.get() &&
+ "Can't make an expression parser with a null target.");
return;
}
// 1. Create a new compiler instance.
- m_compiler.reset(new CompilerInstance());
+ m_compiler = std::make_unique<CompilerInstance>();
// When capturing a reproducer, hook up the file collector with clang to
// collector modules and headers.
@@ -391,9 +429,13 @@ ClangExpressionParser::ClangExpressionParser(
// target. In this case, a specialized language runtime is available and we
// can query it for extra options. For 99% of use cases, this will not be
// needed and should be provided when basic platform detection is not enough.
- if (lang_rt)
+ // FIXME: Generalize this. Only RenderScriptRuntime currently supports this
+ // currently. Hardcoding this isn't ideal but it's better than LanguageRuntime
+ // having knowledge of clang::TargetOpts.
+ if (auto *renderscript_rt =
+ llvm::dyn_cast_or_null<RenderScriptRuntime>(lang_rt))
overridden_target_opts =
- lang_rt->GetOverrideExprOptions(m_compiler->getTargetOpts());
+ renderscript_rt->GetOverrideExprOptions(m_compiler->getTargetOpts());
if (overridden_target_opts)
if (log && log->GetVerbose()) {
@@ -606,11 +648,12 @@ ClangExpressionParser::ClangExpressionParser(
m_compiler->createASTContext();
clang::ASTContext &ast_context = m_compiler->getASTContext();
- m_ast_context.reset(new ClangASTContext(ast_context));
+ m_ast_context = std::make_unique<TypeSystemClang>(
+ "Expression ASTContext for '" + m_filename + "'", ast_context);
std::string module_name("$__lldb_module");
- m_llvm_context.reset(new LLVMContext());
+ m_llvm_context = std::make_unique<LLVMContext>();
m_code_generator.reset(CreateLLVMCodeGen(
m_compiler->getDiagnostics(), module_name,
m_compiler->getHeaderSearchOpts(), m_compiler->getPreprocessorOpts(),
@@ -631,11 +674,33 @@ class CodeComplete : public CodeCompleteConsumer {
std::string m_expr;
unsigned m_position = 0;
- CompletionRequest &m_request;
/// The printing policy we use when printing declarations for our completion
/// descriptions.
clang::PrintingPolicy m_desc_policy;
+ struct CompletionWithPriority {
+ CompletionResult::Completion completion;
+ /// See CodeCompletionResult::Priority;
+ unsigned Priority;
+
+ /// Establishes a deterministic order in a list of CompletionWithPriority.
+ /// The order returned here is the order in which the completions are
+ /// displayed to the user.
+ bool operator<(const CompletionWithPriority &o) const {
+ // High priority results should come first.
+ if (Priority != o.Priority)
+ return Priority > o.Priority;
+
+ // Identical priority, so just make sure it's a deterministic order.
+ return completion.GetUniqueKey() < o.completion.GetUniqueKey();
+ }
+ };
+
+ /// The stored completions.
+ /// Warning: These are in a non-deterministic order until they are sorted
+ /// and returned back to the caller.
+ std::vector<CompletionWithPriority> m_completions;
+
/// Returns true if the given character can be used in an identifier.
/// This also returns true for numbers because for completion we usually
/// just iterate backwards over iterators.
@@ -652,7 +717,7 @@ class CodeComplete : public CodeCompleteConsumer {
/// Drops all tokens in front of the expression that are unrelated for
/// the completion of the cmd line. 'unrelated' means here that the token
/// is not interested for the lldb completion API result.
- StringRef dropUnrelatedFrontTokens(StringRef cmd) {
+ StringRef dropUnrelatedFrontTokens(StringRef cmd) const {
if (cmd.empty())
return cmd;
@@ -673,18 +738,18 @@ class CodeComplete : public CodeCompleteConsumer {
}
/// Removes the last identifier token from the given cmd line.
- StringRef removeLastToken(StringRef cmd) {
+ StringRef removeLastToken(StringRef cmd) const {
while (!cmd.empty() && IsIdChar(cmd.back())) {
cmd = cmd.drop_back();
}
return cmd;
}
- /// Attemps to merge the given completion from the given position into the
+ /// Attempts to merge the given completion from the given position into the
/// existing command. Returns the completion string that can be returned to
/// the lldb completion API.
std::string mergeCompletion(StringRef existing, unsigned pos,
- StringRef completion) {
+ StringRef completion) const {
StringRef existing_command = existing.substr(0, pos);
// We rewrite the last token with the completion, so let's drop that
// token from the command.
@@ -706,11 +771,10 @@ public:
/// \param[out] position
/// The character position of the user cursor in the `expr` parameter.
///
- CodeComplete(CompletionRequest &request, clang::LangOptions ops,
- std::string expr, unsigned position)
+ CodeComplete(clang::LangOptions ops, std::string expr, unsigned position)
: CodeCompleteConsumer(CodeCompleteOptions()),
m_info(std::make_shared<GlobalCodeCompletionAllocator>()), m_expr(expr),
- m_position(position), m_request(request), m_desc_policy(ops) {
+ m_position(position), m_desc_policy(ops) {
// Ensure that the printing policy is producing a description that is as
// short as possible.
@@ -723,9 +787,6 @@ public:
m_desc_policy.Bool = true;
}
- /// Deregisters and destroys this code-completion consumer.
- ~CodeComplete() override {}
-
/// \name Code-completion filtering
/// Check if the result should be filtered out.
bool isResultFilteredOut(StringRef Filter,
@@ -753,6 +814,85 @@ public:
return true;
}
+private:
+ /// Generate the completion strings for the given CodeCompletionResult.
+ /// Note that this function has to process results that could come in
+ /// non-deterministic order, so this function should have no side effects.
+ /// To make this easier to enforce, this function and all its parameters
+ /// should always be const-qualified.
+ /// \return Returns llvm::None if no completion should be provided for the
+ /// given CodeCompletionResult.
+ llvm::Optional<CompletionWithPriority>
+ getCompletionForResult(const CodeCompletionResult &R) const {
+ std::string ToInsert;
+ std::string Description;
+ // Handle the different completion kinds that come from the Sema.
+ switch (R.Kind) {
+ case CodeCompletionResult::RK_Declaration: {
+ const NamedDecl *D = R.Declaration;
+ ToInsert = R.Declaration->getNameAsString();
+ // If we have a function decl that has no arguments we want to
+ // complete the empty parantheses for the user. If the function has
+ // arguments, we at least complete the opening bracket.
+ if (const FunctionDecl *F = dyn_cast<FunctionDecl>(D)) {
+ if (F->getNumParams() == 0)
+ ToInsert += "()";
+ else
+ ToInsert += "(";
+ raw_string_ostream OS(Description);
+ F->print(OS, m_desc_policy, false);
+ OS.flush();
+ } else if (const VarDecl *V = dyn_cast<VarDecl>(D)) {
+ Description = V->getType().getAsString(m_desc_policy);
+ } else if (const FieldDecl *F = dyn_cast<FieldDecl>(D)) {
+ Description = F->getType().getAsString(m_desc_policy);
+ } else if (const NamespaceDecl *N = dyn_cast<NamespaceDecl>(D)) {
+ // If we try to complete a namespace, then we can directly append
+ // the '::'.
+ if (!N->isAnonymousNamespace())
+ ToInsert += "::";
+ }
+ break;
+ }
+ case CodeCompletionResult::RK_Keyword:
+ ToInsert = R.Keyword;
+ break;
+ case CodeCompletionResult::RK_Macro:
+ ToInsert = R.Macro->getName().str();
+ break;
+ case CodeCompletionResult::RK_Pattern:
+ ToInsert = R.Pattern->getTypedText();
+ break;
+ }
+ // We also filter some internal lldb identifiers here. The user
+ // shouldn't see these.
+ if (llvm::StringRef(ToInsert).startswith("$__lldb_"))
+ return llvm::None;
+ if (ToInsert.empty())
+ return llvm::None;
+ // Merge the suggested Token into the existing command line to comply
+ // with the kind of result the lldb API expects.
+ std::string CompletionSuggestion =
+ mergeCompletion(m_expr, m_position, ToInsert);
+
+ CompletionResult::Completion completion(CompletionSuggestion, Description,
+ CompletionMode::Normal);
+ return {{completion, R.Priority}};
+ }
+
+public:
+ /// Adds the completions to the given CompletionRequest.
+ void GetCompletions(CompletionRequest &request) {
+ // Bring m_completions into a deterministic order and pass it on to the
+ // CompletionRequest.
+ llvm::sort(m_completions);
+
+ for (const CompletionWithPriority &C : m_completions)
+ request.AddCompletion(C.completion.GetCompletion(),
+ C.completion.GetDescription(),
+ C.completion.GetMode());
+ }
+
/// \name Code-completion callbacks
/// Process the finalized code-completion results.
void ProcessCodeCompleteResults(Sema &SemaRef, CodeCompletionContext Context,
@@ -771,59 +911,11 @@ public:
continue;
CodeCompletionResult &R = Results[I];
- std::string ToInsert;
- std::string Description;
- // Handle the different completion kinds that come from the Sema.
- switch (R.Kind) {
- case CodeCompletionResult::RK_Declaration: {
- const NamedDecl *D = R.Declaration;
- ToInsert = R.Declaration->getNameAsString();
- // If we have a function decl that has no arguments we want to
- // complete the empty parantheses for the user. If the function has
- // arguments, we at least complete the opening bracket.
- if (const FunctionDecl *F = dyn_cast<FunctionDecl>(D)) {
- if (F->getNumParams() == 0)
- ToInsert += "()";
- else
- ToInsert += "(";
- raw_string_ostream OS(Description);
- F->print(OS, m_desc_policy, false);
- OS.flush();
- } else if (const VarDecl *V = dyn_cast<VarDecl>(D)) {
- Description = V->getType().getAsString(m_desc_policy);
- } else if (const FieldDecl *F = dyn_cast<FieldDecl>(D)) {
- Description = F->getType().getAsString(m_desc_policy);
- } else if (const NamespaceDecl *N = dyn_cast<NamespaceDecl>(D)) {
- // If we try to complete a namespace, then we can directly append
- // the '::'.
- if (!N->isAnonymousNamespace())
- ToInsert += "::";
- }
- break;
- }
- case CodeCompletionResult::RK_Keyword:
- ToInsert = R.Keyword;
- break;
- case CodeCompletionResult::RK_Macro:
- ToInsert = R.Macro->getName().str();
- break;
- case CodeCompletionResult::RK_Pattern:
- ToInsert = R.Pattern->getTypedText();
- break;
- }
- // At this point all information is in the ToInsert string.
-
- // We also filter some internal lldb identifiers here. The user
- // shouldn't see these.
- if (StringRef(ToInsert).startswith("$__lldb_"))
+ llvm::Optional<CompletionWithPriority> CompletionAndPriority =
+ getCompletionForResult(R);
+ if (!CompletionAndPriority)
continue;
- if (!ToInsert.empty()) {
- // Merge the suggested Token into the existing command line to comply
- // with the kind of result the lldb API expects.
- std::string CompletionSuggestion =
- mergeCompletion(m_expr, m_position, ToInsert);
- m_request.AddCompletion(CompletionSuggestion, Description);
- }
+ m_completions.push_back(*CompletionAndPriority);
}
}
@@ -860,12 +952,13 @@ bool ClangExpressionParser::Complete(CompletionRequest &request, unsigned line,
// the LLVMUserExpression which exposes the right API. This should never fail
// as we always have a ClangUserExpression whenever we call this.
ClangUserExpression *llvm_expr = cast<ClangUserExpression>(&m_expr);
- CodeComplete CC(request, m_compiler->getLangOpts(), llvm_expr->GetUserText(),
+ CodeComplete CC(m_compiler->getLangOpts(), llvm_expr->GetUserText(),
typed_pos);
// We don't need a code generator for parsing.
m_code_generator.reset();
// Start parsing the expression with our custom code completion consumer.
ParseInternal(mgr, &CC, line, pos);
+ CC.GetCompletions(request);
return true;
}
@@ -881,7 +974,6 @@ ClangExpressionParser::ParseInternal(DiagnosticManager &diagnostic_manager,
ClangDiagnosticManagerAdapter *adapter =
static_cast<ClangDiagnosticManagerAdapter *>(
m_compiler->getDiagnostics().getClient());
- auto diag_buf = adapter->GetPassthrough();
adapter->ResetManager(&diagnostic_manager);
@@ -936,8 +1028,8 @@ ClangExpressionParser::ParseInternal(DiagnosticManager &diagnostic_manager,
source_mgr.setMainFileID(source_mgr.createFileID(std::move(memory_buffer)));
}
- diag_buf->BeginSourceFile(m_compiler->getLangOpts(),
- &m_compiler->getPreprocessor());
+ adapter->BeginSourceFile(m_compiler->getLangOpts(),
+ &m_compiler->getPreprocessor());
ClangExpressionHelper *type_system_helper =
dyn_cast<ClangExpressionHelper>(m_expr.GetTypeSystemHelper());
@@ -961,11 +1053,11 @@ ClangExpressionParser::ParseInternal(DiagnosticManager &diagnostic_manager,
std::unique_ptr<clang::ASTConsumer> Consumer;
if (ast_transformer) {
- Consumer.reset(new ASTConsumerForwarder(ast_transformer));
+ Consumer = std::make_unique<ASTConsumerForwarder>(ast_transformer);
} else if (m_code_generator) {
- Consumer.reset(new ASTConsumerForwarder(m_code_generator.get()));
+ Consumer = std::make_unique<ASTConsumerForwarder>(m_code_generator.get());
} else {
- Consumer.reset(new ASTConsumer());
+ Consumer = std::make_unique<ASTConsumer>();
}
clang::ASTContext &ast_context = m_compiler->getASTContext();
@@ -1022,9 +1114,9 @@ ClangExpressionParser::ParseInternal(DiagnosticManager &diagnostic_manager,
// original behavior of ParseAST (which also destroys the Sema after parsing).
m_compiler->setSema(nullptr);
- diag_buf->EndSourceFile();
+ adapter->EndSourceFile();
- unsigned num_errors = diag_buf->getNumErrors();
+ unsigned num_errors = adapter->getNumErrors();
if (m_pp_callbacks && m_pp_callbacks->hasErrors()) {
num_errors++;
@@ -1065,6 +1157,28 @@ ClangExpressionParser::GetClangTargetABI(const ArchSpec &target_arch) {
return abi;
}
+/// Applies the given Fix-It hint to the given commit.
+static void ApplyFixIt(const FixItHint &fixit, clang::edit::Commit &commit) {
+ // This is cobbed from clang::Rewrite::FixItRewriter.
+ if (fixit.CodeToInsert.empty()) {
+ if (fixit.InsertFromRange.isValid()) {
+ commit.insertFromRange(fixit.RemoveRange.getBegin(),
+ fixit.InsertFromRange, /*afterToken=*/false,
+ fixit.BeforePreviousInsertions);
+ return;
+ }
+ commit.remove(fixit.RemoveRange);
+ return;
+ }
+ if (fixit.RemoveRange.isTokenRange() ||
+ fixit.RemoveRange.getBegin() != fixit.RemoveRange.getEnd()) {
+ commit.replace(fixit.RemoveRange, fixit.CodeToInsert);
+ return;
+ }
+ commit.insert(fixit.RemoveRange.getBegin(), fixit.CodeToInsert,
+ /*afterToken=*/false, fixit.BeforePreviousInsertions);
+}
+
bool ClangExpressionParser::RewriteExpression(
DiagnosticManager &diagnostic_manager) {
clang::SourceManager &source_manager = m_compiler->getSourceManager();
@@ -1096,26 +1210,12 @@ bool ClangExpressionParser::RewriteExpression(
for (const auto &diag : diagnostic_manager.Diagnostics()) {
const auto *diagnostic = llvm::dyn_cast<ClangDiagnostic>(diag.get());
- if (diagnostic && diagnostic->HasFixIts()) {
- for (const FixItHint &fixit : diagnostic->FixIts()) {
- // This is cobbed from clang::Rewrite::FixItRewriter.
- if (fixit.CodeToInsert.empty()) {
- if (fixit.InsertFromRange.isValid()) {
- commit.insertFromRange(fixit.RemoveRange.getBegin(),
- fixit.InsertFromRange, /*afterToken=*/false,
- fixit.BeforePreviousInsertions);
- } else
- commit.remove(fixit.RemoveRange);
- } else {
- if (fixit.RemoveRange.isTokenRange() ||
- fixit.RemoveRange.getBegin() != fixit.RemoveRange.getEnd())
- commit.replace(fixit.RemoveRange, fixit.CodeToInsert);
- else
- commit.insert(fixit.RemoveRange.getBegin(), fixit.CodeToInsert,
- /*afterToken=*/false, fixit.BeforePreviousInsertions);
- }
- }
- }
+ if (!diagnostic)
+ continue;
+ if (!diagnostic->HasFixIts())
+ continue;
+ for (const FixItHint &fixit : diagnostic->FixIts())
+ ApplyFixIt(fixit, commit);
}
// FIXME - do we want to try to propagate specific errors here?
@@ -1230,18 +1330,13 @@ lldb_private::Status ClangExpressionParser::PrepareForExecution(
type_system_helper->DeclMap(); // result can be NULL
if (decl_map) {
- Target *target = exe_ctx.GetTargetPtr();
- auto &error_stream = target->GetDebugger().GetErrorStream();
+ StreamString error_stream;
IRForTarget ir_for_target(decl_map, m_expr.NeedsVariableResolution(),
*execution_unit_sp, error_stream,
function_name.AsCString());
- bool ir_can_run =
- ir_for_target.runOnModule(*execution_unit_sp->GetModule());
-
- if (!ir_can_run) {
- err.SetErrorString(
- "The expression could not be prepared to run in the target");
+ if (!ir_for_target.runOnModule(*execution_unit_sp->GetModule())) {
+ err.SetErrorString(error_stream.GetString());
return err;
}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
index 4a410cecb94a..6afee22da8d1 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
@@ -6,10 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ClangExpressionParser_h_
-#define liblldb_ClangExpressionParser_h_
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXPRESSIONPARSER_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXPRESSIONPARSER_H
-#include "lldb/Core/ClangForward.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/ExpressionParser.h"
#include "lldb/Utility/ArchSpec.h"
@@ -19,13 +18,20 @@
#include <string>
#include <vector>
+namespace llvm {
+class LLVMContext;
+}
+
namespace clang {
+class CodeGenerator;
class CodeCompleteConsumer;
-}
+class CompilerInstance;
+} // namespace clang
namespace lldb_private {
class IRExecutionUnit;
+class TypeSystemClang;
/// \class ClangExpressionParser ClangExpressionParser.h
/// "lldb/Expression/ClangExpressionParser.h" Encapsulates an instance of
@@ -171,7 +177,7 @@ private:
class LLDBPreprocessorCallbacks;
LLDBPreprocessorCallbacks *m_pp_callbacks; ///< Called when the preprocessor
///encounters module imports
- std::unique_ptr<ClangASTContext> m_ast_context;
+ std::unique_ptr<TypeSystemClang> m_ast_context;
std::vector<std::string> m_include_directories;
/// File name used for the user expression.
@@ -179,4 +185,4 @@ private:
};
}
-#endif // liblldb_ClangExpressionParser_h_
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXPRESSIONPARSER_H
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
index 7ebb5fee1ec6..a429963277d1 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
@@ -1,4 +1,4 @@
-//===-- ClangExpressionSourceCode.cpp ---------------------------*- C++ -*-===//
+//===-- ClangExpressionSourceCode.cpp -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,6 +9,7 @@
#include "ClangExpressionSourceCode.h"
#include "clang/Basic/CharInfo.h"
+#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/Lexer.h"
#include "llvm/ADT/StringRef.h"
@@ -173,8 +174,8 @@ static void AddMacros(const DebugMacros *dm, CompileUnit *comp_unit,
lldb_private::ClangExpressionSourceCode::ClangExpressionSourceCode(
llvm::StringRef filename, llvm::StringRef name, llvm::StringRef prefix,
- llvm::StringRef body, Wrapping wrap)
- : ExpressionSourceCode(name, prefix, body, wrap) {
+ llvm::StringRef body, Wrapping wrap, WrapKind wrap_kind)
+ : ExpressionSourceCode(name, prefix, body, wrap), m_wrap_kind(wrap_kind) {
// Use #line markers to pretend that we have a single-line source file
// containing only the user expression. This will hide our wrapper code
// from the user when we render diagnostics with Clang.
@@ -260,10 +261,9 @@ TokenVerifier::TokenVerifier(std::string body) {
}
}
-static void AddLocalVariableDecls(const lldb::VariableListSP &var_list_sp,
- StreamString &stream,
- const std::string &expr,
- lldb::LanguageType wrapping_language) {
+void ClangExpressionSourceCode::AddLocalVariableDecls(
+ const lldb::VariableListSP &var_list_sp, StreamString &stream,
+ const std::string &expr) const {
TokenVerifier tokens(expr);
for (size_t i = 0; i < var_list_sp->GetSize(); i++) {
@@ -280,13 +280,12 @@ static void AddLocalVariableDecls(const lldb::VariableListSP &var_list_sp,
if (!expr.empty() && !tokens.hasToken(var_name.GetStringRef()))
continue;
- if ((var_name == "self" || var_name == "_cmd") &&
- (wrapping_language == lldb::eLanguageTypeObjC ||
- wrapping_language == lldb::eLanguageTypeObjC_plus_plus))
+ const bool is_objc = m_wrap_kind == WrapKind::ObjCInstanceMethod ||
+ m_wrap_kind == WrapKind::ObjCStaticMethod;
+ if ((var_name == "self" || var_name == "_cmd") && is_objc)
continue;
- if (var_name == "this" &&
- wrapping_language == lldb::eLanguageTypeC_plus_plus)
+ if (var_name == "this" && m_wrap_kind == WrapKind::CppMemberFunction)
continue;
stream.Printf("using $__lldb_local_vars::%s;\n", var_name.AsCString());
@@ -294,9 +293,8 @@ static void AddLocalVariableDecls(const lldb::VariableListSP &var_list_sp,
}
bool ClangExpressionSourceCode::GetText(
- std::string &text, lldb::LanguageType wrapping_language, bool static_method,
- ExecutionContext &exe_ctx, bool add_locals, bool force_add_all_locals,
- llvm::ArrayRef<std::string> modules) const {
+ std::string &text, ExecutionContext &exe_ctx, bool add_locals,
+ bool force_add_all_locals, llvm::ArrayRef<std::string> modules) const {
const char *target_specific_defines = "typedef signed char BOOL;\n";
std::string module_macros;
@@ -373,21 +371,11 @@ bool ClangExpressionSourceCode::GetText(
lldb::VariableListSP var_list_sp =
frame->GetInScopeVariableList(false, true);
AddLocalVariableDecls(var_list_sp, lldb_local_var_decls,
- force_add_all_locals ? "" : m_body,
- wrapping_language);
+ force_add_all_locals ? "" : m_body);
}
}
if (m_wrap) {
- switch (wrapping_language) {
- default:
- return false;
- case lldb::eLanguageTypeC:
- case lldb::eLanguageTypeC_plus_plus:
- case lldb::eLanguageTypeObjC:
- break;
- }
-
// Generate a list of @import statements that will import the specified
// module into our expression.
std::string module_imports;
@@ -406,22 +394,12 @@ bool ClangExpressionSourceCode::GetText(
// First construct a tagged form of the user expression so we can find it
// later:
std::string tagged_body;
- switch (wrapping_language) {
- default:
- tagged_body = m_body;
- break;
- case lldb::eLanguageTypeC:
- case lldb::eLanguageTypeC_plus_plus:
- case lldb::eLanguageTypeObjC:
- tagged_body.append(m_start_marker);
- tagged_body.append(m_body);
- tagged_body.append(m_end_marker);
- break;
- }
- switch (wrapping_language) {
- default:
- break;
- case lldb::eLanguageTypeC:
+ tagged_body.append(m_start_marker);
+ tagged_body.append(m_body);
+ tagged_body.append(m_end_marker);
+
+ switch (m_wrap_kind) {
+ case WrapKind::Function:
wrap_stream.Printf("%s"
"void \n"
"%s(void *$__lldb_arg) \n"
@@ -432,7 +410,7 @@ bool ClangExpressionSourceCode::GetText(
module_imports.c_str(), m_name.c_str(),
lldb_local_var_decls.GetData(), tagged_body.c_str());
break;
- case lldb::eLanguageTypeC_plus_plus:
+ case WrapKind::CppMemberFunction:
wrap_stream.Printf("%s"
"void \n"
"$__lldb_class::%s(void *$__lldb_arg) \n"
@@ -443,42 +421,42 @@ bool ClangExpressionSourceCode::GetText(
module_imports.c_str(), m_name.c_str(),
lldb_local_var_decls.GetData(), tagged_body.c_str());
break;
- case lldb::eLanguageTypeObjC:
- if (static_method) {
- wrap_stream.Printf(
- "%s"
- "@interface $__lldb_objc_class ($__lldb_category) \n"
- "+(void)%s:(void *)$__lldb_arg; \n"
- "@end \n"
- "@implementation $__lldb_objc_class ($__lldb_category) \n"
- "+(void)%s:(void *)$__lldb_arg \n"
- "{ \n"
- " %s; \n"
- "%s"
- "} \n"
- "@end \n",
- module_imports.c_str(), m_name.c_str(), m_name.c_str(),
- lldb_local_var_decls.GetData(), tagged_body.c_str());
- } else {
- wrap_stream.Printf(
- "%s"
- "@interface $__lldb_objc_class ($__lldb_category) \n"
- "-(void)%s:(void *)$__lldb_arg; \n"
- "@end \n"
- "@implementation $__lldb_objc_class ($__lldb_category) \n"
- "-(void)%s:(void *)$__lldb_arg \n"
- "{ \n"
- " %s; \n"
- "%s"
- "} \n"
- "@end \n",
- module_imports.c_str(), m_name.c_str(), m_name.c_str(),
- lldb_local_var_decls.GetData(), tagged_body.c_str());
- }
+ case WrapKind::ObjCInstanceMethod:
+ wrap_stream.Printf(
+ "%s"
+ "@interface $__lldb_objc_class ($__lldb_category) \n"
+ "-(void)%s:(void *)$__lldb_arg; \n"
+ "@end \n"
+ "@implementation $__lldb_objc_class ($__lldb_category) \n"
+ "-(void)%s:(void *)$__lldb_arg \n"
+ "{ \n"
+ " %s; \n"
+ "%s"
+ "} \n"
+ "@end \n",
+ module_imports.c_str(), m_name.c_str(), m_name.c_str(),
+ lldb_local_var_decls.GetData(), tagged_body.c_str());
+ break;
+
+ case WrapKind::ObjCStaticMethod:
+ wrap_stream.Printf(
+ "%s"
+ "@interface $__lldb_objc_class ($__lldb_category) \n"
+ "+(void)%s:(void *)$__lldb_arg; \n"
+ "@end \n"
+ "@implementation $__lldb_objc_class ($__lldb_category) \n"
+ "+(void)%s:(void *)$__lldb_arg \n"
+ "{ \n"
+ " %s; \n"
+ "%s"
+ "} \n"
+ "@end \n",
+ module_imports.c_str(), m_name.c_str(), m_name.c_str(),
+ lldb_local_var_decls.GetData(), tagged_body.c_str());
break;
}
- text = wrap_stream.GetString();
+ text = std::string(wrap_stream.GetString());
} else {
text.append(m_body);
}
@@ -487,17 +465,7 @@ bool ClangExpressionSourceCode::GetText(
}
bool ClangExpressionSourceCode::GetOriginalBodyBounds(
- std::string transformed_text, lldb::LanguageType wrapping_language,
- size_t &start_loc, size_t &end_loc) {
- switch (wrapping_language) {
- default:
- return false;
- case lldb::eLanguageTypeC:
- case lldb::eLanguageTypeC_plus_plus:
- case lldb::eLanguageTypeObjC:
- break;
- }
-
+ std::string transformed_text, size_t &start_loc, size_t &end_loc) {
start_loc = transformed_text.find(m_start_marker);
if (start_loc == std::string::npos)
return false;
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h
index 1d159670b962..9a54f0e3ad8d 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ClangExpressionSourceCode_h
-#define liblldb_ClangExpressionSourceCode_h
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXPRESSIONSOURCECODE_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXPRESSIONSOURCECODE_H
#include "lldb/Expression/Expression.h"
#include "lldb/Expression/ExpressionSourceCode.h"
@@ -28,20 +28,30 @@ public:
static const llvm::StringRef g_prefix_file_name;
static const char *g_expression_prefix;
+ /// The possible ways an expression can be wrapped.
+ enum class WrapKind {
+ /// Wrapped in a non-static member function of a C++ class.
+ CppMemberFunction,
+ /// Wrapped in an instance Objective-C method.
+ ObjCInstanceMethod,
+ /// Wrapped in a static Objective-C method.
+ ObjCStaticMethod,
+ /// Wrapped in a non-member function.
+ /// Note that this is also used for static member functions of a C++ class.
+ Function
+ };
+
static ClangExpressionSourceCode *CreateWrapped(llvm::StringRef filename,
llvm::StringRef prefix,
- llvm::StringRef body) {
+ llvm::StringRef body,
+ WrapKind wrap_kind) {
return new ClangExpressionSourceCode(filename, "$__lldb_expr", prefix, body,
- Wrap);
+ Wrap, wrap_kind);
}
/// Generates the source code that will evaluate the expression.
///
/// \param text output parameter containing the source code string.
- /// \param wrapping_language If the expression is supossed to be wrapped,
- /// then this is the language that should be used for that.
- /// \param static_method True iff the expression is valuated inside a static
- /// Objective-C method.
/// \param exe_ctx The execution context in which the expression will be
/// evaluated.
/// \param add_locals True iff local variables should be injected into the
@@ -51,8 +61,7 @@ public:
/// \param modules A list of (C++) modules that the expression should import.
///
/// \return true iff the source code was successfully generated.
- bool GetText(std::string &text, lldb::LanguageType wrapping_language,
- bool static_method, ExecutionContext &exe_ctx, bool add_locals,
+ bool GetText(std::string &text, ExecutionContext &exe_ctx, bool add_locals,
bool force_add_all_locals,
llvm::ArrayRef<std::string> modules) const;
@@ -60,19 +69,24 @@ public:
// passed to CreateWrapped. Return true if the bounds could be found. This
// will also work on text with FixItHints applied.
bool GetOriginalBodyBounds(std::string transformed_text,
- lldb::LanguageType wrapping_language,
size_t &start_loc, size_t &end_loc);
protected:
ClangExpressionSourceCode(llvm::StringRef filename, llvm::StringRef name,
llvm::StringRef prefix, llvm::StringRef body,
- Wrapping wrap);
+ Wrapping wrap, WrapKind wrap_kind);
private:
+ void AddLocalVariableDecls(const lldb::VariableListSP &var_list_sp,
+ StreamString &stream,
+ const std::string &expr) const;
+
/// String marking the start of the user expression.
std::string m_start_marker;
/// String marking the end of the user expression.
std::string m_end_marker;
+ /// How the expression has been wrapped.
+ const WrapKind m_wrap_kind;
};
} // namespace lldb_private
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
index b5a2c80b5349..9af92e194da9 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
@@ -1,4 +1,4 @@
-//===-- ClangExpressionVariable.cpp -----------------------------*- C++ -*-===//
+//===-- ClangExpressionVariable.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
index 0e6de28ee4df..58d589962abe 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ClangExpressionVariable_h_
-#define liblldb_ClangExpressionVariable_h_
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXPRESSIONVARIABLE_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXPRESSIONVARIABLE_H
#include <signal.h>
#include <stdint.h>
@@ -19,7 +19,6 @@
#include "llvm/Support/Casting.h"
-#include "lldb/Core/ClangForward.h"
#include "lldb/Core/Value.h"
#include "lldb/Expression/ExpressionVariable.h"
#include "lldb/Symbol/TaggedASTType.h"
@@ -30,6 +29,10 @@ namespace llvm {
class Value;
}
+namespace clang {
+class NamedDecl;
+}
+
namespace lldb_private {
class ValueObjectConstResult;
@@ -114,11 +117,9 @@ public:
class ParserVars {
public:
ParserVars()
- : m_parser_type(), m_named_decl(nullptr), m_llvm_value(nullptr),
+ : m_named_decl(nullptr), m_llvm_value(nullptr),
m_lldb_value(), m_lldb_var(), m_lldb_sym(nullptr) {}
- TypeFromParser
- m_parser_type; ///< The type of the variable according to the parser
const clang::NamedDecl
*m_named_decl; ///< The Decl corresponding to this variable
llvm::Value *m_llvm_value; ///< The IR value corresponding to this variable;
@@ -196,9 +197,11 @@ public:
}
/// Members
- DISALLOW_COPY_AND_ASSIGN(ClangExpressionVariable);
+ ClangExpressionVariable(const ClangExpressionVariable &) = delete;
+ const ClangExpressionVariable &
+ operator=(const ClangExpressionVariable &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ClangExpressionVariable_h_
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXPRESSIONVARIABLE_H
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp
new file mode 100644
index 000000000000..390afb458b5a
--- /dev/null
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.cpp
@@ -0,0 +1,88 @@
+//===-- ClangExternalASTSourceCallbacks.cpp -------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclObjC.h"
+
+using namespace lldb_private;
+
+char ClangExternalASTSourceCallbacks::ID;
+
+void ClangExternalASTSourceCallbacks::CompleteType(clang::TagDecl *tag_decl) {
+ m_ast.CompleteTagDecl(tag_decl);
+}
+
+void ClangExternalASTSourceCallbacks::CompleteType(
+ clang::ObjCInterfaceDecl *objc_decl) {
+ m_ast.CompleteObjCInterfaceDecl(objc_decl);
+}
+
+bool ClangExternalASTSourceCallbacks::layoutRecordType(
+ const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
+ llvm::DenseMap<const clang::FieldDecl *, uint64_t> &FieldOffsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &BaseOffsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
+ &VirtualBaseOffsets) {
+ return m_ast.LayoutRecordType(Record, Size, Alignment, FieldOffsets,
+ BaseOffsets, VirtualBaseOffsets);
+}
+
+void ClangExternalASTSourceCallbacks::FindExternalLexicalDecls(
+ const clang::DeclContext *decl_ctx,
+ llvm::function_ref<bool(clang::Decl::Kind)> IsKindWeWant,
+ llvm::SmallVectorImpl<clang::Decl *> &decls) {
+ if (decl_ctx) {
+ clang::TagDecl *tag_decl = llvm::dyn_cast<clang::TagDecl>(
+ const_cast<clang::DeclContext *>(decl_ctx));
+ if (tag_decl)
+ CompleteType(tag_decl);
+ }
+}
+
+bool ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName(
+ const clang::DeclContext *DC, clang::DeclarationName Name) {
+ llvm::SmallVector<clang::NamedDecl *, 4> decls;
+ // Objective-C methods are not added into the LookupPtr when they originate
+ // from an external source. SetExternalVisibleDeclsForName() adds them.
+ if (auto *oid = llvm::dyn_cast<clang::ObjCInterfaceDecl>(DC)) {
+ clang::ObjCContainerDecl::method_range noload_methods(oid->noload_decls());
+ for (auto *omd : noload_methods)
+ if (omd->getDeclName() == Name)
+ decls.push_back(omd);
+ }
+ return !SetExternalVisibleDeclsForName(DC, Name, decls).empty();
+}
+
+OptionalClangModuleID
+ClangExternalASTSourceCallbacks::RegisterModule(clang::Module *module) {
+ m_modules.push_back(module);
+ unsigned id = m_modules.size();
+ m_ids.insert({module, id});
+ return OptionalClangModuleID(id);
+}
+
+llvm::Optional<clang::ASTSourceDescriptor>
+ClangExternalASTSourceCallbacks::getSourceDescriptor(unsigned id) {
+ if (clang::Module *module = getModule(id))
+ return {*module};
+ return {};
+}
+
+clang::Module *ClangExternalASTSourceCallbacks::getModule(unsigned id) {
+ if (id && id <= m_modules.size())
+ return m_modules[id - 1];
+ return nullptr;
+}
+
+OptionalClangModuleID
+ClangExternalASTSourceCallbacks::GetIDForModule(clang::Module *module) {
+ return OptionalClangModuleID(m_ids[module]);
+}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h
new file mode 100644
index 000000000000..69088d9c82a5
--- /dev/null
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h
@@ -0,0 +1,66 @@
+//===-- ClangExternalASTSourceCallbacks.h -----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXTERNALASTSOURCECALLBACKS_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXTERNALASTSOURCECALLBACKS_H
+
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "clang/Basic/Module.h"
+
+namespace lldb_private {
+
+class ClangExternalASTSourceCallbacks : public clang::ExternalASTSource {
+ /// LLVM RTTI support.
+ static char ID;
+
+public:
+ /// LLVM RTTI support.
+ bool isA(const void *ClassID) const override { return ClassID == &ID; }
+ static bool classof(const clang::ExternalASTSource *s) { return s->isA(&ID); }
+
+ ClangExternalASTSourceCallbacks(TypeSystemClang &ast) : m_ast(ast) {}
+
+ 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 *DC,
+ clang::DeclarationName Name) override;
+
+ void CompleteType(clang::TagDecl *tag_decl) override;
+
+ void CompleteType(clang::ObjCInterfaceDecl *objc_decl) override;
+
+ bool layoutRecordType(
+ const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
+ llvm::DenseMap<const clang::FieldDecl *, uint64_t> &FieldOffsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
+ &BaseOffsets,
+ llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
+ &VirtualBaseOffsets) override;
+
+ TypeSystemClang &GetTypeSystem() const { return m_ast; }
+
+ /// Module-related methods.
+ /// \{
+ llvm::Optional<clang::ASTSourceDescriptor>
+ getSourceDescriptor(unsigned ID) override;
+ clang::Module *getModule(unsigned ID) override;
+ OptionalClangModuleID RegisterModule(clang::Module *module);
+ OptionalClangModuleID GetIDForModule(clang::Module *module);
+ /// \}
+private:
+ TypeSystemClang &m_ast;
+ std::vector<clang::Module *> m_modules;
+ llvm::DenseMap<clang::Module *, unsigned> m_ids;
+};
+
+} // namespace lldb_private
+
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXTERNALASTSOURCECALLBACKS_H
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
index 7f7c0a97f538..0c9ad2021035 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
@@ -1,4 +1,4 @@
-//===-- ClangFunctionCaller.cpp ---------------------------------*- C++ -*-===//
+//===-- ClangFunctionCaller.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -21,12 +21,12 @@
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/IR/Module.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Module.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"
@@ -209,8 +209,8 @@ ClangFunctionCaller::CompileFunction(lldb::ThreadSP thread_to_use_sp,
clang::ASTConsumer *
ClangFunctionCaller::ClangFunctionCallerHelper::ASTTransformer(
clang::ASTConsumer *passthrough) {
- m_struct_extractor.reset(new ASTStructExtractor(
- passthrough, m_owner.GetWrapperStructName(), m_owner));
+ m_struct_extractor = std::make_unique<ASTStructExtractor>(
+ passthrough, m_owner.GetWrapperStructName(), m_owner);
return m_struct_extractor.get();
}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h
index 150a913152d0..8060b8c0aedc 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h
@@ -6,13 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ClangFunctionCaller_h_
-#define liblldb_ClangFunctionCaller_h_
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGFUNCTIONCALLER_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGFUNCTIONCALLER_H
#include "ClangExpressionHelper.h"
#include "lldb/Core/Address.h"
-#include "lldb/Core/ClangForward.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Expression/FunctionCaller.h"
@@ -150,4 +149,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ClangFunctionCaller_h_
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGFUNCTIONCALLER_H
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
index 42d3f22014dd..8abb7e420575 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
@@ -1,4 +1,4 @@
-//===-- ClangHost.cpp -------------------------------------------*- C++ -*-===//
+//===-- ClangHost.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -67,10 +67,10 @@ static bool DefaultComputeClangResourceDirectory(FileSpec &lldb_shlib_spec,
llvm::sys::path::native(relative_path);
llvm::sys::path::append(clang_dir, relative_path);
if (!verify || VerifyClangPath(clang_dir)) {
- LLDB_LOGF(log,
- "DefaultComputeClangResourceDir: Setting ClangResourceDir "
- "to \"%s\", verify = %s",
- clang_dir.str().str().c_str(), verify ? "true" : "false");
+ LLDB_LOG(log,
+ "DefaultComputeClangResourceDir: Setting ClangResourceDir "
+ "to \"{0}\", verify = {1}",
+ clang_dir.str(), verify ? "true" : "false");
file_spec.GetDirectory().SetString(clang_dir);
FileSystem::Instance().Resolve(file_spec);
return true;
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.h
index 9d49188178cd..d6809909a625 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangHost.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGHOST_H
-#define LLDB_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGHOST_H
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGHOST_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGHOST_H
namespace lldb_private {
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index 0696c669f2e2..95acb883774d 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -1,4 +1,4 @@
-//===-- ClangModulesDeclVendor.cpp ------------------------------*- C++ -*-===//
+//===-- ClangModulesDeclVendor.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,11 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include <mutex>
-
#include "clang/Basic/TargetInfo.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Parse/Parser.h"
@@ -24,10 +23,10 @@
#include "ClangModulesDeclVendor.h"
#include "ModuleDependencyCollector.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/SourceModule.h"
#include "lldb/Target/Target.h"
@@ -37,6 +36,9 @@
#include "lldb/Utility/Reproducer.h"
#include "lldb/Utility/StreamString.h"
+#include <memory>
+#include <mutex>
+
using namespace lldb_private;
namespace {
@@ -54,10 +56,21 @@ public:
void DumpDiagnostics(Stream &error_stream);
+ void BeginSourceFile(const clang::LangOptions &LangOpts,
+ const clang::Preprocessor *PP = nullptr) override;
+ void EndSourceFile() override;
+
private:
typedef std::pair<clang::DiagnosticsEngine::Level, std::string>
IDAndDiagnostic;
std::vector<IDAndDiagnostic> m_diagnostics;
+ /// The DiagnosticPrinter used for creating the full diagnostic messages
+ /// that are stored in m_diagnostics.
+ std::shared_ptr<clang::TextDiagnosticPrinter> m_diag_printer;
+ /// Output stream of m_diag_printer.
+ std::shared_ptr<llvm::raw_string_ostream> m_os;
+ /// Output string filled by m_os. Will be reused for different diagnostics.
+ std::string m_output;
Log *m_log;
};
@@ -108,25 +121,30 @@ private:
typedef std::set<ModuleID> ImportedModuleSet;
ImportedModuleMap m_imported_modules;
ImportedModuleSet m_user_imported_modules;
- // We assume that every ASTContext has an ClangASTContext, so we also store
- // a custom ClangASTContext for our internal ASTContext.
- std::unique_ptr<ClangASTContext> m_ast_context;
+ // We assume that every ASTContext has an TypeSystemClang, so we also store
+ // a custom TypeSystemClang for our internal ASTContext.
+ std::unique_ptr<TypeSystemClang> m_ast_context;
};
} // anonymous namespace
StoringDiagnosticConsumer::StoringDiagnosticConsumer() {
m_log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+
+ clang::DiagnosticOptions *m_options = new clang::DiagnosticOptions();
+ m_os = std::make_shared<llvm::raw_string_ostream>(m_output);
+ m_diag_printer =
+ std::make_shared<clang::TextDiagnosticPrinter>(*m_os, m_options);
}
void StoringDiagnosticConsumer::HandleDiagnostic(
clang::DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &info) {
- llvm::SmallVector<char, 256> diagnostic_string;
+ // Print the diagnostic to m_output.
+ m_output.clear();
+ m_diag_printer->HandleDiagnostic(DiagLevel, info);
+ m_os->flush();
- info.FormatDiagnostic(diagnostic_string);
-
- m_diagnostics.push_back(
- IDAndDiagnostic(DiagLevel, std::string(diagnostic_string.data(),
- diagnostic_string.size())));
+ // Store the diagnostic for later.
+ m_diagnostics.push_back(IDAndDiagnostic(DiagLevel, m_output));
}
void StoringDiagnosticConsumer::ClearDiagnostics() { m_diagnostics.clear(); }
@@ -144,6 +162,15 @@ void StoringDiagnosticConsumer::DumpDiagnostics(Stream &error_stream) {
}
}
+void StoringDiagnosticConsumer::BeginSourceFile(
+ const clang::LangOptions &LangOpts, const clang::Preprocessor *PP) {
+ m_diag_printer->BeginSourceFile(LangOpts, PP);
+}
+
+void StoringDiagnosticConsumer::EndSourceFile() {
+ m_diag_printer->EndSourceFile();
+}
+
ClangModulesDeclVendor::ClangModulesDeclVendor()
: ClangDeclVendor(eClangModuleDeclVendor) {}
@@ -159,8 +186,10 @@ ClangModulesDeclVendorImpl::ClangModulesDeclVendorImpl(
m_compiler_instance(std::move(compiler_instance)),
m_parser(std::move(parser)) {
- // Initialize our ClangASTContext.
- m_ast_context.reset(new ClangASTContext(m_compiler_instance->getASTContext()));
+ // Initialize our TypeSystemClang.
+ m_ast_context =
+ std::make_unique<TypeSystemClang>("ClangModulesDeclVendor ASTContext",
+ m_compiler_instance->getASTContext());
}
void ClangModulesDeclVendorImpl::ReportModuleExportsHelper(
@@ -382,7 +411,7 @@ ClangModulesDeclVendorImpl::FindDecls(ConstString name, bool append,
if (num_matches >= max_matches)
return num_matches;
- decls.push_back(CompilerDecl(m_ast_context.get(), named_decl));
+ decls.push_back(m_ast_context->GetCompilerDecl(named_decl));
++num_matches;
}
@@ -601,10 +630,10 @@ ClangModulesDeclVendor::Create(Target &target) {
{
llvm::SmallString<128> path;
- auto props = ModuleList::GetGlobalModuleListProperties();
+ const auto &props = ModuleList::GetGlobalModuleListProperties();
props.GetClangModulesCachePath().GetPath(path);
std::string module_cache_argument("-fmodules-cache-path=");
- module_cache_argument.append(path.str());
+ module_cache_argument.append(std::string(path.str()));
compiler_invocation_arguments.push_back(module_cache_argument);
}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h
index e099b59041d8..f04d1b07f03d 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h
@@ -6,10 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ClangModulesDeclVendor_h
-#define liblldb_ClangModulesDeclVendor_h
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGMODULESDECLVENDOR_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGMODULESDECLVENDOR_H
-#include "lldb/Core/ClangForward.h"
#include "lldb/Symbol/SourceModule.h"
#include "lldb/Target/Platform.h"
@@ -113,4 +112,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_ClangModulesDeclVendor_h
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGMODULESDECLVENDOR_H
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
index 41d62a462ab4..42afac9edb0d 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
@@ -1,4 +1,4 @@
-//===-- ClangPersistentVariables.cpp ----------------------------*- C++ -*-===//
+//===-- ClangPersistentVariables.cpp --------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,9 +7,10 @@
//===----------------------------------------------------------------------===//
#include "ClangPersistentVariables.h"
+#include "ClangASTImporter.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Value.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Log.h"
@@ -82,7 +83,7 @@ ClangPersistentVariables::GetCompilerTypeFromPersistentDecl(
void ClangPersistentVariables::RegisterPersistentDecl(ConstString name,
clang::NamedDecl *decl,
- ClangASTContext *ctx) {
+ TypeSystemClang *ctx) {
PersistentDecl p = {decl, ctx};
m_persistent_decls.insert(std::make_pair(name.GetCString(), p));
@@ -99,3 +100,22 @@ clang::NamedDecl *
ClangPersistentVariables::GetPersistentDecl(ConstString name) {
return m_persistent_decls.lookup(name.GetCString()).m_decl;
}
+
+std::shared_ptr<ClangASTImporter>
+ClangPersistentVariables::GetClangASTImporter() {
+ if (!m_ast_importer_sp) {
+ m_ast_importer_sp = std::make_shared<ClangASTImporter>();
+ }
+ return m_ast_importer_sp;
+}
+
+ConstString
+ClangPersistentVariables::GetNextPersistentVariableName(bool is_error) {
+ llvm::SmallString<64> name;
+ {
+ llvm::raw_svector_ostream os(name);
+ os << GetPersistentVariablePrefix(is_error)
+ << m_next_persistent_variable_id++;
+ }
+ return ConstString(name);
+}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
index 434196b35fd5..f888b2d56e68 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ClangPersistentVariables_h_
-#define liblldb_ClangPersistentVariables_h_
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGPERSISTENTVARIABLES_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGPERSISTENTVARIABLES_H
#include "llvm/ADT/DenseMap.h"
@@ -18,6 +18,9 @@
namespace lldb_private {
+class ClangASTImporter;
+class TypeSystemClang;
+
/// \class ClangPersistentVariables ClangPersistentVariables.h
/// "lldb/Expression/ClangPersistentVariables.h" Manages persistent values
/// that need to be preserved between expression invocations.
@@ -36,6 +39,8 @@ public:
return pv->getKind() == PersistentExpressionState::eKindClang;
}
+ std::shared_ptr<ClangASTImporter> GetClangASTImporter();
+
lldb::ExpressionVariableSP
CreatePersistentVariable(const lldb::ValueObjectSP &valobj_sp) override;
@@ -46,9 +51,7 @@ public:
void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override;
- llvm::StringRef GetPersistentVariablePrefix(bool is_error) const override {
- return "$";
- }
+ ConstString GetNextPersistentVariableName(bool is_error = false) override;
/// Returns the next file name that should be used for user expressions.
std::string GetNextExprFileName() {
@@ -63,7 +66,7 @@ public:
GetCompilerTypeFromPersistentDecl(ConstString type_name) override;
void RegisterPersistentDecl(ConstString name, clang::NamedDecl *decl,
- ClangASTContext *ctx);
+ TypeSystemClang *ctx);
clang::NamedDecl *GetPersistentDecl(ConstString name);
@@ -75,6 +78,12 @@ public:
return m_hand_loaded_clang_modules;
}
+protected:
+ llvm::StringRef
+ GetPersistentVariablePrefix(bool is_error = false) const override {
+ return "$";
+ }
+
private:
/// The counter used by GetNextExprFileName.
uint32_t m_next_user_file_id = 0;
@@ -84,8 +93,8 @@ private:
struct PersistentDecl {
/// The persistent decl.
clang::NamedDecl *m_decl = nullptr;
- /// The ClangASTContext for the ASTContext of m_decl.
- ClangASTContext *m_context = nullptr;
+ /// The TypeSystemClang for the ASTContext of m_decl.
+ TypeSystemClang *m_context = nullptr;
};
typedef llvm::DenseMap<const char *, PersistentDecl> PersistentDeclMap;
@@ -96,8 +105,9 @@ private:
m_hand_loaded_clang_modules; ///< These are Clang modules we hand-loaded;
///these are the highest-
///< priority source for macros.
+ std::shared_ptr<ClangASTImporter> m_ast_importer_sp;
};
} // namespace lldb_private
-#endif // liblldb_ClangPersistentVariables_h_
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGPERSISTENTVARIABLES_H
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
index 6698797617a3..a28b4a7fb42c 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -1,4 +1,4 @@
-//===-- ClangUserExpression.cpp ---------------------------------*- C++ -*-===//
+//===-- ClangUserExpression.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -20,6 +20,7 @@
#include "ClangUserExpression.h"
#include "ASTResultSynthesizer.h"
+#include "ClangASTMetadata.h"
#include "ClangDiagnostic.h"
#include "ClangExpressionDeclMap.h"
#include "ClangExpressionParser.h"
@@ -27,6 +28,7 @@
#include "ClangPersistentVariables.h"
#include "CppModuleConfiguration.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
@@ -37,8 +39,6 @@
#include "lldb/Expression/Materializer.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/Block.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangASTMetadata.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -154,7 +154,7 @@ void ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Status &err) {
}
m_needs_object_ptr = true;
} else if (clang::CXXMethodDecl *method_decl =
- ClangASTContext::DeclContextGetAsCXXMethodDecl(decl_context)) {
+ TypeSystemClang::DeclContextGetAsCXXMethodDecl(decl_context)) {
if (m_allow_cxx && method_decl->isInstance()) {
if (m_enforce_valid_object) {
lldb::VariableListSP variable_list_sp(
@@ -183,7 +183,7 @@ void ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Status &err) {
m_needs_object_ptr = true;
}
} else if (clang::ObjCMethodDecl *method_decl =
- ClangASTContext::DeclContextGetAsObjCMethodDecl(
+ TypeSystemClang::DeclContextGetAsObjCMethodDecl(
decl_context)) {
if (m_allow_objc) {
if (m_enforce_valid_object) {
@@ -216,7 +216,7 @@ void ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Status &err) {
m_in_static_method = true;
}
} else if (clang::FunctionDecl *function_decl =
- ClangASTContext::DeclContextGetAsFunctionDecl(decl_context)) {
+ TypeSystemClang::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
@@ -224,7 +224,7 @@ void ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Status &err) {
// that here.
ClangASTMetadata *metadata =
- ClangASTContext::DeclContextGetMetaData(decl_context, function_decl);
+ TypeSystemClang::DeclContextGetMetaData(decl_context, function_decl);
if (metadata && metadata->HasObjectPtr()) {
lldb::LanguageType language = metadata->GetObjectPtrLanguage();
if (language == lldb::eLanguageTypeC_plus_plus) {
@@ -292,9 +292,9 @@ void ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Status &err) {
return;
}
- if (ClangASTContext::IsObjCClassType(self_clang_type)) {
+ if (TypeSystemClang::IsObjCClassType(self_clang_type)) {
return;
- } else if (ClangASTContext::IsObjCObjectPointerType(
+ } else if (TypeSystemClang::IsObjCObjectPointerType(
self_clang_type)) {
m_in_objectivec_method = true;
m_needs_object_ptr = true;
@@ -347,50 +347,70 @@ bool ClangUserExpression::SetupPersistentState(DiagnosticManager &diagnostic_man
return true;
}
-static void SetupDeclVendor(ExecutionContext &exe_ctx, Target *target) {
- if (ClangModulesDeclVendor *decl_vendor =
- target->GetClangModulesDeclVendor()) {
- auto *persistent_state = llvm::cast<ClangPersistentVariables>(
- target->GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeC));
- if (!persistent_state)
- return;
- const ClangModulesDeclVendor::ModuleVector &hand_imported_modules =
- persistent_state->GetHandLoadedClangModules();
- ClangModulesDeclVendor::ModuleVector modules_for_macros;
+static void SetupDeclVendor(ExecutionContext &exe_ctx, Target *target,
+ DiagnosticManager &diagnostic_manager) {
+ ClangModulesDeclVendor *decl_vendor = target->GetClangModulesDeclVendor();
+ if (!decl_vendor)
+ return;
- for (ClangModulesDeclVendor::ModuleID module : hand_imported_modules) {
- modules_for_macros.push_back(module);
- }
+ if (!target->GetEnableAutoImportClangModules())
+ return;
- if (target->GetEnableAutoImportClangModules()) {
- if (StackFrame *frame = exe_ctx.GetFramePtr()) {
- if (Block *block = frame->GetFrameBlock()) {
- SymbolContext sc;
+ auto *persistent_state = llvm::cast<ClangPersistentVariables>(
+ target->GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeC));
+ if (!persistent_state)
+ return;
- block->CalculateSymbolContext(&sc);
+ StackFrame *frame = exe_ctx.GetFramePtr();
+ if (!frame)
+ return;
- if (sc.comp_unit) {
- StreamString error_stream;
+ Block *block = frame->GetFrameBlock();
+ if (!block)
+ return;
+ SymbolContext sc;
- decl_vendor->AddModulesForCompileUnit(
- *sc.comp_unit, modules_for_macros, error_stream);
- }
- }
- }
- }
+ block->CalculateSymbolContext(&sc);
+
+ if (!sc.comp_unit)
+ return;
+ StreamString error_stream;
+
+ ClangModulesDeclVendor::ModuleVector modules_for_macros =
+ persistent_state->GetHandLoadedClangModules();
+ if (decl_vendor->AddModulesForCompileUnit(*sc.comp_unit, modules_for_macros,
+ error_stream))
+ return;
+
+ // Failed to load some modules, so emit the error stream as a diagnostic.
+ if (!error_stream.Empty()) {
+ // The error stream already contains several Clang diagnostics that might
+ // be either errors or warnings, so just print them all as one remark
+ // diagnostic to prevent that the message starts with "error: error:".
+ diagnostic_manager.PutString(eDiagnosticSeverityRemark,
+ error_stream.GetString());
+ return;
}
+
+ diagnostic_manager.PutString(eDiagnosticSeverityError,
+ "Unknown error while loading modules needed for "
+ "current compilation unit.");
}
-void ClangUserExpression::UpdateLanguageForExpr() {
- m_expr_lang = lldb::LanguageType::eLanguageTypeUnknown;
- if (m_options.GetExecutionPolicy() == eExecutionPolicyTopLevel)
- return;
+ClangExpressionSourceCode::WrapKind ClangUserExpression::GetWrapKind() const {
+ assert(m_options.GetExecutionPolicy() != eExecutionPolicyTopLevel &&
+ "Top level expressions aren't wrapped.");
+ using Kind = ClangExpressionSourceCode::WrapKind;
if (m_in_cplusplus_method)
- m_expr_lang = lldb::eLanguageTypeC_plus_plus;
- else if (m_in_objectivec_method)
- m_expr_lang = lldb::eLanguageTypeObjC;
- else
- m_expr_lang = lldb::eLanguageTypeC;
+ return Kind::CppMemberFunction;
+ else if (m_in_objectivec_method) {
+ if (m_in_static_method)
+ return Kind::ObjCStaticMethod;
+ return Kind::ObjCInstanceMethod;
+ }
+ // Not in any kind of 'special' function, so just wrap it in a normal C
+ // function.
+ return Kind::Function;
}
void ClangUserExpression::CreateSourceCode(
@@ -404,10 +424,9 @@ void ClangUserExpression::CreateSourceCode(
m_transformed_text = m_expr_text;
} else {
m_source_code.reset(ClangExpressionSourceCode::CreateWrapped(
- m_filename, prefix.c_str(), m_expr_text.c_str()));
+ m_filename, prefix, m_expr_text, GetWrapKind()));
- if (!m_source_code->GetText(m_transformed_text, m_expr_lang,
- m_in_static_method, exe_ctx, !m_ctx_obj,
+ if (!m_source_code->GetText(m_transformed_text, exe_ctx, !m_ctx_obj,
for_completion, modules_to_import)) {
diagnostic_manager.PutString(eDiagnosticSeverityError,
"couldn't construct expression body");
@@ -419,7 +438,7 @@ void ClangUserExpression::CreateSourceCode(
std::size_t original_start;
std::size_t original_end;
bool found_bounds = m_source_code->GetOriginalBodyBounds(
- m_transformed_text, m_expr_lang, original_start, original_end);
+ m_transformed_text, original_start, original_end);
if (found_bounds)
m_user_expression_start_pos = original_start;
}
@@ -530,7 +549,7 @@ bool ClangUserExpression::PrepareForParsing(
ApplyObjcCastHack(m_expr_text);
- SetupDeclVendor(exe_ctx, m_target);
+ SetupDeclVendor(exe_ctx, m_target, diagnostic_manager);
CppModuleConfiguration module_config = GetModuleConfig(m_language, exe_ctx);
llvm::ArrayRef<std::string> imported_modules =
@@ -544,7 +563,6 @@ bool ClangUserExpression::PrepareForParsing(
llvm::make_range(m_include_directories.begin(),
m_include_directories.end()));
- UpdateLanguageForExpr();
CreateSourceCode(diagnostic_manager, exe_ctx, imported_modules,
for_completion);
return true;
@@ -577,7 +595,7 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager,
// Parse the expression
//
- m_materializer_up.reset(new Materializer());
+ m_materializer_up = std::make_unique<Materializer>();
ResetDeclMap(exe_ctx, m_result_delegate, keep_result_in_memory);
@@ -616,15 +634,13 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager,
if (parser.RewriteExpression(diagnostic_manager)) {
size_t fixed_start;
size_t fixed_end;
- const std::string &fixed_expression =
- diagnostic_manager.GetFixedExpression();
+ m_fixed_text = diagnostic_manager.GetFixedExpression();
// Retrieve the original expression in case we don't have a top level
// expression (which has no surrounding source code).
- if (m_source_code &&
- m_source_code->GetOriginalBodyBounds(fixed_expression, m_expr_lang,
- fixed_start, fixed_end))
+ if (m_source_code && m_source_code->GetOriginalBodyBounds(
+ m_fixed_text, fixed_start, fixed_end))
m_fixed_text =
- fixed_expression.substr(fixed_start, fixed_end - fixed_start);
+ m_fixed_text.substr(fixed_start, fixed_end - fixed_start);
}
}
return false;
@@ -659,7 +675,7 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager,
const char *error_cstr = static_init_error.AsCString();
if (error_cstr && error_cstr[0])
diagnostic_manager.Printf(eDiagnosticSeverityError,
- "couldn't run static initializers: %s\n",
+ "%s\n",
error_cstr);
else
diagnostic_manager.PutString(eDiagnosticSeverityError,
@@ -767,7 +783,7 @@ bool ClangUserExpression::Complete(ExecutionContext &exe_ctx,
// Parse the expression
//
- m_materializer_up.reset(new Materializer());
+ m_materializer_up = std::make_unique<Materializer>();
ResetDeclMap(exe_ctx, m_result_delegate, /*keep result in memory*/ true);
@@ -896,16 +912,23 @@ void ClangUserExpression::ClangUserExpressionHelper::ResetDeclMap(
Materializer::PersistentVariableDelegate &delegate,
bool keep_result_in_memory,
ValueObject *ctx_obj) {
- m_expr_decl_map_up.reset(new ClangExpressionDeclMap(
- keep_result_in_memory, &delegate, exe_ctx.GetTargetSP(),
- exe_ctx.GetTargetRef().GetClangASTImporter(), ctx_obj));
+ std::shared_ptr<ClangASTImporter> ast_importer;
+ auto *state = exe_ctx.GetTargetSP()->GetPersistentExpressionStateForLanguage(
+ lldb::eLanguageTypeC);
+ if (state) {
+ auto *persistent_vars = llvm::cast<ClangPersistentVariables>(state);
+ ast_importer = persistent_vars->GetClangASTImporter();
+ }
+ m_expr_decl_map_up = std::make_unique<ClangExpressionDeclMap>(
+ keep_result_in_memory, &delegate, exe_ctx.GetTargetSP(), ast_importer,
+ ctx_obj);
}
clang::ASTConsumer *
ClangUserExpression::ClangUserExpressionHelper::ASTTransformer(
clang::ASTConsumer *passthrough) {
- m_result_synthesizer_up.reset(
- new ASTResultSynthesizer(passthrough, m_top_level, m_target));
+ m_result_synthesizer_up = std::make_unique<ASTResultSynthesizer>(
+ passthrough, m_top_level, m_target);
return m_result_synthesizer_up.get();
}
@@ -917,9 +940,7 @@ void ClangUserExpression::ClangUserExpressionHelper::CommitPersistentDecls() {
}
ConstString ClangUserExpression::ResultDelegate::GetName() {
- auto prefix = m_persistent_state->GetPersistentVariablePrefix();
- return m_persistent_state->GetNextPersistentVariableName(*m_target_sp,
- prefix);
+ return m_persistent_state->GetNextPersistentVariableName(false);
}
void ClangUserExpression::ResultDelegate::DidDematerialize(
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
index 00cbffa7fd6f..f734069655ef 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ClangUserExpression_h_
-#define liblldb_ClangUserExpression_h_
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGUSEREXPRESSION_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGUSEREXPRESSION_H
#include <vector>
@@ -20,7 +20,6 @@
#include "IRForTarget.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"
@@ -186,7 +185,8 @@ private:
ExecutionContext &exe_ctx,
std::vector<std::string> modules_to_import,
bool for_completion);
- void UpdateLanguageForExpr();
+ /// Defines how the current expression should be wrapped.
+ ClangExpressionSourceCode::WrapKind GetWrapKind() const;
bool SetupPersistentState(DiagnosticManager &diagnostic_manager,
ExecutionContext &exe_ctx);
bool PrepareForParsing(DiagnosticManager &diagnostic_manager,
@@ -209,8 +209,6 @@ private:
lldb::TargetSP m_target_sp;
};
- /// The language type of the current expression.
- lldb::LanguageType m_expr_lang = lldb::eLanguageTypeUnknown;
/// The include directories that should be used when parsing the expression.
std::vector<std::string> m_include_directories;
@@ -251,4 +249,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ClangUserExpression_h_
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGUSEREXPRESSION_H
diff --git a/lldb/source/Symbol/ClangUtil.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtil.cpp
index 52ea4f5111d6..a7f5dce8558f 100644
--- a/lldb/source/Symbol/ClangUtil.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtil.cpp
@@ -1,4 +1,4 @@
-//===-- ClangUtil.cpp -------------------------------------------*- C++ -*-===//
+//===-- ClangUtil.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,8 +8,8 @@
// types and decls.
//===----------------------------------------------------------------------===//
-#include "lldb/Symbol/ClangUtil.h"
-#include "lldb/Symbol/ClangASTContext.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
using namespace clang;
using namespace lldb_private;
@@ -19,7 +19,7 @@ bool ClangUtil::IsClangType(const CompilerType &ct) {
if (!ct)
return false;
- if (llvm::dyn_cast_or_null<ClangASTContext>(ct.GetTypeSystem()) == nullptr)
+ if (llvm::dyn_cast_or_null<TypeSystemClang>(ct.GetTypeSystem()) == nullptr)
return false;
if (!ct.GetOpaqueQualType())
@@ -28,6 +28,11 @@ bool ClangUtil::IsClangType(const CompilerType &ct) {
return true;
}
+clang::Decl *ClangUtil::GetDecl(const CompilerDecl &decl) {
+ assert(llvm::isa<TypeSystemClang>(decl.GetTypeSystem()));
+ return static_cast<clang::Decl *>(decl.GetOpaqueDecl());
+}
+
QualType ClangUtil::GetQualType(const CompilerType &ct) {
// Make sure we have a clang type before making a clang::QualType
if (!IsClangType(ct))
diff --git a/lldb/include/lldb/Symbol/ClangUtil.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtil.h
index 5ffbce340e59..50cae42bc7c2 100644
--- a/lldb/include/lldb/Symbol/ClangUtil.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtil.h
@@ -8,8 +8,8 @@
// types and decls.
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SYMBOL_CLANGUTIL_H
-#define LLDB_SYMBOL_CLANGUTIL_H
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGUTIL_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGUTIL_H
#include "clang/AST/DeclBase.h"
#include "clang/AST/Type.h"
@@ -24,6 +24,10 @@ namespace lldb_private {
struct ClangUtil {
static bool IsClangType(const CompilerType &ct);
+ /// Returns the clang::Decl of the given CompilerDecl.
+ /// CompilerDecl has to be valid and represent a clang::Decl.
+ static clang::Decl *GetDecl(const CompilerDecl &decl);
+
static clang::QualType GetQualType(const CompilerType &ct);
static clang::QualType GetCanonicalQualType(const CompilerType &ct);
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
index 199e4898e118..25ec982220a0 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
@@ -1,4 +1,4 @@
-//===-- ClangUtilityFunction.cpp ---------------------------------*- C++-*-===//
+//===-- ClangUtilityFunction.cpp ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -12,6 +12,7 @@
#include "ClangExpressionDeclMap.h"
#include "ClangExpressionParser.h"
#include "ClangExpressionSourceCode.h"
+#include "ClangPersistentVariables.h"
#include <stdio.h>
#if HAVE_SYS_TYPES_H
@@ -159,7 +160,14 @@ bool ClangUtilityFunction::Install(DiagnosticManager &diagnostic_manager,
void ClangUtilityFunction::ClangUtilityFunctionHelper::ResetDeclMap(
ExecutionContext &exe_ctx, bool keep_result_in_memory) {
- m_expr_decl_map_up.reset(new ClangExpressionDeclMap(
- keep_result_in_memory, nullptr, exe_ctx.GetTargetSP(),
- exe_ctx.GetTargetRef().GetClangASTImporter(), nullptr));
+ std::shared_ptr<ClangASTImporter> ast_importer;
+ auto *state = exe_ctx.GetTargetSP()->GetPersistentExpressionStateForLanguage(
+ lldb::eLanguageTypeC);
+ if (state) {
+ auto *persistent_vars = llvm::cast<ClangPersistentVariables>(state);
+ ast_importer = persistent_vars->GetClangASTImporter();
+ }
+ m_expr_decl_map_up = std::make_unique<ClangExpressionDeclMap>(
+ keep_result_in_memory, nullptr, exe_ctx.GetTargetSP(), ast_importer,
+ nullptr);
}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
index 9efaa0254c3e..1f2dd5fdbecc 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ClangUtilityFunction_h_
-#define liblldb_ClangUtilityFunction_h_
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGUTILITYFUNCTION_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGUTILITYFUNCTION_H
#include <map>
#include <string>
@@ -15,7 +15,6 @@
#include "ClangExpressionHelper.h"
-#include "lldb/Core/ClangForward.h"
#include "lldb/Expression/UtilityFunction.h"
#include "lldb/lldb-forward.h"
#include "lldb/lldb-private.h"
@@ -107,4 +106,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ClangUtilityFunction_h_
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGUTILITYFUNCTION_H
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
index 51ae73285b53..f1272c67d20f 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp
@@ -73,7 +73,7 @@ CppModuleConfiguration::CppModuleConfiguration(
llvm::SmallString<256> resource_dir;
llvm::sys::path::append(resource_dir, GetClangResourceDir().GetPath(),
"include");
- m_resource_inc = resource_dir.str();
+ m_resource_inc = std::string(resource_dir.str());
// This order matches the way Clang orders these directories.
m_include_dirs = {m_std_inc.Get(), m_resource_inc, m_c_inc.Get()};
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.h b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.h
index 8e892e37d0de..235ac2bd090c 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CppModuleConfiguration_h_
-#define liblldb_CppModuleConfiguration_h_
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CPPMODULECONFIGURATION_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CPPMODULECONFIGURATION_H
#include <lldb/Core/FileSpecList.h>
#include <llvm/Support/Regex.h>
@@ -56,7 +56,7 @@ class CppModuleConfiguration {
bool analyzeFile(const FileSpec &f);
public:
- /// Creates a configuraiton by analyzing the given list of used source files.
+ /// Creates a configuration by analyzing the given list of used source files.
///
/// Currently only looks at the used paths and doesn't actually access the
/// files on the disk.
diff --git a/lldb/source/Symbol/CxxModuleHandler.cpp b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
index 19e80e5036bc..2f8cf1846ee7 100644
--- a/lldb/source/Symbol/CxxModuleHandler.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp
@@ -1,4 +1,4 @@
-//===-- CxxModuleHandler.cpp ------------------------------------*- C++ -*-===//
+//===-- CxxModuleHandler.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Symbol/CxxModuleHandler.h"
+#include "Plugins/ExpressionParser/Clang/CxxModuleHandler.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Utility/Log.h"
#include "clang/Sema/Lookup.h"
#include "llvm/Support/Error.h"
@@ -18,7 +18,7 @@ using namespace clang;
CxxModuleHandler::CxxModuleHandler(ASTImporter &importer, ASTContext *target)
: m_importer(&importer),
- m_sema(ClangASTContext::GetASTContext(target)->getSema()) {
+ m_sema(TypeSystemClang::GetASTContext(target)->getSema()) {
std::initializer_list<const char *> supported_names = {
// containers
@@ -66,9 +66,9 @@ emulateLookupInCtxt(Sema &sema, llvm::StringRef name, DeclContext *ctxt) {
IdentifierInfo &ident = sema.getASTContext().Idents.get(name);
std::unique_ptr<LookupResult> lookup_result;
- lookup_result.reset(new LookupResult(sema, DeclarationName(&ident),
- SourceLocation(),
- Sema::LookupOrdinaryName));
+ lookup_result = std::make_unique<LookupResult>(sema, DeclarationName(&ident),
+ SourceLocation(),
+ Sema::LookupOrdinaryName);
// Usually during parsing we already encountered the scopes we would use. But
// here don't have these scopes so we have to emulate the behavior of the
@@ -186,7 +186,7 @@ llvm::Optional<Decl *> CxxModuleHandler::tryInstantiateStdTemplate(Decl *d) {
if (!td->getDeclContext()->isStdNamespace())
return {};
- // We have a whitelist of supported template names.
+ // We have a list of supported template names.
if (m_supported_templates.find(td->getName()) == m_supported_templates.end())
return {};
diff --git a/lldb/include/lldb/Symbol/CxxModuleHandler.h b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.h
index f4aef3666ece..6490af7f8978 100644
--- a/lldb/include/lldb/Symbol/CxxModuleHandler.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CxxModuleHandler_h_
-#define liblldb_CxxModuleHandler_h_
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CXXMODULEHANDLER_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CXXMODULEHANDLER_H
#include "clang/AST/ASTImporter.h"
#include "clang/Sema/Sema.h"
@@ -62,4 +62,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_CxxModuleHandler_h_
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CXXMODULEHANDLER_H
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
index d5ffb9529f36..b92f00ec2b63 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
@@ -1,4 +1,4 @@
-//===-- IRDynamicChecks.cpp -------------------------------------*- C++ -*-===//
+//===-- IRDynamicChecks.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -181,8 +181,8 @@ protected:
///
/// \param[in] inst
/// The instruction to be instrumented.
- void RegisterInstruction(llvm::Instruction &i) {
- m_to_instrument.push_back(&i);
+ void RegisterInstruction(llvm::Instruction &inst) {
+ m_to_instrument.push_back(&inst);
}
/// Determine whether a single instruction is interesting to instrument,
@@ -465,7 +465,7 @@ protected:
}
static llvm::Function *GetCalledFunction(llvm::CallInst *inst) {
- return GetFunction(inst->getCalledValue());
+ return GetFunction(inst->getCalledOperand());
}
bool InspectInstruction(llvm::Instruction &i) override {
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.h b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.h
index 5b9c8007ab76..a4de527e4512 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_IRDynamicChecks_h_
-#define liblldb_IRDynamicChecks_h_
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_IRDYNAMICCHECKS_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_IRDYNAMICCHECKS_H
#include "lldb/Expression/DynamicCheckerFunctions.h"
#include "lldb/lldb-types.h"
@@ -124,4 +124,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_IRDynamicChecks_h_
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_IRDYNAMICCHECKS_H
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index 103a7ee46f35..8511e554509a 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -1,4 +1,4 @@
-//===-- IRForTarget.cpp -----------------------------------------*- C++ -*-===//
+//===-- IRForTarget.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,7 +9,9 @@
#include "IRForTarget.h"
#include "ClangExpressionDeclMap.h"
+#include "ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/InstrTypes.h"
@@ -27,8 +29,6 @@
#include "lldb/Core/dwarf.h"
#include "lldb/Expression/IRExecutionUnit.h"
#include "lldb/Expression/IRInterpreter.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/DataBufferHeap.h"
@@ -283,17 +283,13 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
clang::QualType element_qual_type = pointer_pointertype->getPointeeType();
m_result_type = lldb_private::TypeFromParser(
- element_qual_type.getAsOpaquePtr(),
- lldb_private::ClangASTContext::GetASTContext(
- &result_decl->getASTContext()));
+ m_decl_map->GetTypeSystem()->GetType(element_qual_type));
} 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(),
- lldb_private::ClangASTContext::GetASTContext(
- &result_decl->getASTContext()));
+ m_decl_map->GetTypeSystem()->GetType(element_qual_type));
} else {
LLDB_LOG(log, "Expected result to have pointer type, but it did not");
@@ -305,9 +301,7 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
}
} else {
m_result_type = lldb_private::TypeFromParser(
- result_var->getType().getAsOpaquePtr(),
- lldb_private::ClangASTContext::GetASTContext(
- &result_decl->getASTContext()));
+ m_decl_map->GetTypeSystem()->GetType(result_var->getType()));
}
lldb::TargetSP target_sp(m_execution_unit.GetTarget());
@@ -433,7 +427,7 @@ bool IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str,
m_execution_unit.FindSymbol(g_CFStringCreateWithBytes_str,
missing_weak);
if (CFStringCreateWithBytes_addr == LLDB_INVALID_ADDRESS || missing_weak) {
- log->PutCString("Couldn't find CFStringCreateWithBytes in the target");
+ LLDB_LOG(log, "Couldn't find CFStringCreateWithBytes in the target");
m_error_stream.Printf("Error [IRForTarget]: Rewriting an Objective-C "
"constant string requires "
@@ -823,7 +817,8 @@ bool IRForTarget::RewriteObjCSelector(Instruction *selector_load) {
if (!omvn_initializer_array->isString())
return false;
- std::string omvn_initializer_string = omvn_initializer_array->getAsString();
+ std::string omvn_initializer_string =
+ std::string(omvn_initializer_array->getAsString());
LLDB_LOG(log, "Found Objective-C selector reference \"{0}\"",
omvn_initializer_string);
@@ -981,7 +976,8 @@ bool IRForTarget::RewriteObjCClassReference(Instruction *class_load) {
if (!ocn_initializer_array->isString())
return false;
- std::string ocn_initializer_string = ocn_initializer_array->getAsString();
+ std::string ocn_initializer_string =
+ std::string(ocn_initializer_array->getAsString());
LLDB_LOG(log, "Found Objective-C class reference \"{0}\"",
ocn_initializer_string);
@@ -1092,8 +1088,7 @@ bool IRForTarget::RewritePersistentAlloc(llvm::Instruction *persistent_alloc) {
clang::VarDecl *decl = reinterpret_cast<clang::VarDecl *>(ptr);
lldb_private::TypeFromParser result_decl_type(
- decl->getType().getAsOpaquePtr(),
- lldb_private::ClangASTContext::GetASTContext(&decl->getASTContext()));
+ m_decl_map->GetTypeSystem()->GetType(decl->getType()));
StringRef decl_name(decl->getName());
lldb_private::ConstString persistent_variable_name(decl_name.data(),
@@ -1125,7 +1120,9 @@ bool IRForTarget::RewritePersistentAlloc(llvm::Instruction *persistent_alloc) {
// Now, since the variable is a pointer variable, we will drop in a load of
// that pointer variable.
- LoadInst *persistent_load = new LoadInst(persistent_global, "", alloc);
+ LoadInst *persistent_load =
+ new LoadInst(persistent_global->getType()->getPointerElementType(),
+ persistent_global, "", alloc);
LLDB_LOG(log, "Replacing \"{0}\" with \"{1}\"", PrintValue(alloc),
PrintValue(persistent_load));
@@ -1223,10 +1220,8 @@ bool IRForTarget::MaybeHandleVariable(Value *llvm_value_ptr) {
if (value_decl == nullptr)
return false;
- lldb_private::CompilerType compiler_type(
- lldb_private::ClangASTContext::GetASTContext(
- &value_decl->getASTContext()),
- value_decl->getType().getAsOpaquePtr());
+ lldb_private::CompilerType compiler_type =
+ m_decl_map->GetTypeSystem()->GetType(value_decl->getType());
const Type *value_type = nullptr;
@@ -1400,7 +1395,7 @@ bool IRForTarget::RemoveCXAAtExit(BasicBlock &basic_block) {
if (func && func->getName() == "__cxa_atexit")
remove = true;
- llvm::Value *val = call->getCalledValue();
+ llvm::Value *val = call->getCalledOperand();
if (val && val->getName() == "__cxa_atexit")
remove = true;
@@ -1799,7 +1794,9 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) {
get_element_ptr, value->getType()->getPointerTo(), "",
entry_instruction);
- LoadInst *load = new LoadInst(bit_cast, "", entry_instruction);
+ LoadInst *load =
+ new LoadInst(bit_cast->getType()->getPointerElementType(),
+ bit_cast, "", entry_instruction);
return load;
} else {
@@ -1845,7 +1842,7 @@ bool IRForTarget::runOnModule(Module &llvm_module) {
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
m_module = &llvm_module;
- m_target_data.reset(new DataLayout(m_module));
+ m_target_data = std::make_unique<DataLayout>(m_module);
m_intptr_ty = llvm::Type::getIntNTy(m_module->getContext(),
m_target_data->getPointerSizeInBits());
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
index 262e8ee0c06c..ebfc0cae626c 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
@@ -7,10 +7,9 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_IRForTarget_h_
-#define liblldb_IRForTarget_h_
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_IRFORTARGET_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_IRFORTARGET_H
-#include "lldb/Core/ClangForward.h"
#include "lldb/Symbol/TaggedASTType.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/Status.h"
@@ -38,6 +37,10 @@ class DataLayout;
class Value;
}
+namespace clang {
+class NamedDecl;
+}
+
namespace lldb_private {
class ClangExpressionDeclMap;
class IRExecutionUnit;
@@ -506,4 +509,4 @@ private:
bool CompleteDataAllocation();
};
-#endif // liblldb_IRForTarget_h_
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_IRFORTARGET_H
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ModuleDependencyCollector.h b/lldb/source/Plugins/ExpressionParser/Clang/ModuleDependencyCollector.h
index 7553860f2492..b7b6640c4810 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ModuleDependencyCollector.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ModuleDependencyCollector.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ModuleDependencyCollector_h_
-#define liblldb_ModuleDependencyCollector_h_
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_MODULEDEPENDENCYCOLLECTOR_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_MODULEDEPENDENCYCOLLECTOR_H
#include "clang/Frontend/Utils.h"
#include "llvm/ADT/StringRef.h"
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp b/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp
new file mode 100644
index 000000000000..c1f88889f1dc
--- /dev/null
+++ b/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp
@@ -0,0 +1,179 @@
+//===-- NameSearchContext.cpp ---------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "NameSearchContext.h"
+#include "ClangUtil.h"
+
+using namespace clang;
+using namespace lldb_private;
+
+clang::NamedDecl *NameSearchContext::AddVarDecl(const CompilerType &type) {
+ assert(type && "Type for variable must be valid!");
+
+ if (!type.IsValid())
+ return nullptr;
+
+ TypeSystemClang *lldb_ast =
+ llvm::dyn_cast<TypeSystemClang>(type.GetTypeSystem());
+ if (!lldb_ast)
+ return nullptr;
+
+ IdentifierInfo *ii = m_decl_name.getAsIdentifierInfo();
+
+ clang::ASTContext &ast = lldb_ast->getASTContext();
+
+ clang::NamedDecl *Decl = VarDecl::Create(
+ ast, const_cast<DeclContext *>(m_decl_context), SourceLocation(),
+ SourceLocation(), ii, ClangUtil::GetQualType(type), nullptr, SC_Static);
+ m_decls.push_back(Decl);
+
+ return Decl;
+}
+
+clang::NamedDecl *NameSearchContext::AddFunDecl(const CompilerType &type,
+ bool extern_c) {
+ assert(type && "Type for variable must be valid!");
+
+ if (!type.IsValid())
+ return nullptr;
+
+ if (m_function_types.count(type))
+ return nullptr;
+
+ TypeSystemClang *lldb_ast =
+ llvm::dyn_cast<TypeSystemClang>(type.GetTypeSystem());
+ if (!lldb_ast)
+ return nullptr;
+
+ m_function_types.insert(type);
+
+ QualType qual_type(ClangUtil::GetQualType(type));
+
+ clang::ASTContext &ast = lldb_ast->getASTContext();
+
+ const bool isInlineSpecified = false;
+ const bool hasWrittenPrototype = true;
+ const bool isConstexprSpecified = false;
+
+ clang::DeclContext *context = const_cast<DeclContext *>(m_decl_context);
+
+ if (extern_c) {
+ context = LinkageSpecDecl::Create(
+ ast, context, SourceLocation(), SourceLocation(),
+ clang::LinkageSpecDecl::LanguageIDs::lang_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(), decl_name, qual_type,
+ nullptr, SC_Extern, isInlineSpecified, hasWrittenPrototype,
+ isConstexprSpecified ? CSK_constexpr : CSK_unspecified);
+
+ // We have to do more than just synthesize the FunctionDecl. We have to
+ // synthesize ParmVarDecls for all of the FunctionDecl's arguments. To do
+ // this, we raid the function's FunctionProtoType for types.
+
+ const FunctionProtoType *func_proto_type =
+ qual_type.getTypePtr()->getAs<FunctionProtoType>();
+
+ if (func_proto_type) {
+ unsigned NumArgs = func_proto_type->getNumParams();
+ unsigned ArgIndex;
+
+ SmallVector<ParmVarDecl *, 5> parm_var_decls;
+
+ for (ArgIndex = 0; ArgIndex < NumArgs; ++ArgIndex) {
+ QualType arg_qual_type(func_proto_type->getParamType(ArgIndex));
+
+ parm_var_decls.push_back(
+ ParmVarDecl::Create(ast, const_cast<DeclContext *>(context),
+ SourceLocation(), SourceLocation(), nullptr,
+ arg_qual_type, nullptr, SC_Static, nullptr));
+ }
+
+ func_decl->setParams(ArrayRef<ParmVarDecl *>(parm_var_decls));
+ } else {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+
+ LLDB_LOG(log, "Function type wasn't a FunctionProtoType");
+ }
+
+ // If this is an operator (e.g. operator new or operator==), only insert the
+ // declaration we inferred from the symbol if we can provide the correct
+ // number of arguments. We shouldn't really inject random decl(s) for
+ // functions that are analyzed semantically in a special way, otherwise we
+ // will crash in clang.
+ clang::OverloadedOperatorKind op_kind = clang::NUM_OVERLOADED_OPERATORS;
+ if (func_proto_type &&
+ TypeSystemClang::IsOperator(decl_name.getAsString().c_str(), op_kind)) {
+ if (!TypeSystemClang::CheckOverloadedOperatorKindParameterCount(
+ false, op_kind, func_proto_type->getNumParams()))
+ return nullptr;
+ }
+ m_decls.push_back(func_decl);
+
+ return func_decl;
+}
+
+clang::NamedDecl *NameSearchContext::AddGenericFunDecl() {
+ FunctionProtoType::ExtProtoInfo proto_info;
+
+ proto_info.Variadic = true;
+
+ QualType generic_function_type(
+ GetASTContext().getFunctionType(GetASTContext().UnknownAnyTy, // result
+ ArrayRef<QualType>(), // argument types
+ proto_info));
+
+ return AddFunDecl(m_clang_ts.GetType(generic_function_type), true);
+}
+
+clang::NamedDecl *
+NameSearchContext::AddTypeDecl(const CompilerType &clang_type) {
+ if (ClangUtil::IsClangType(clang_type)) {
+ QualType qual_type = ClangUtil::GetQualType(clang_type);
+
+ if (const TypedefType *typedef_type =
+ llvm::dyn_cast<TypedefType>(qual_type)) {
+ TypedefNameDecl *typedef_name_decl = typedef_type->getDecl();
+
+ m_decls.push_back(typedef_name_decl);
+
+ return (NamedDecl *)typedef_name_decl;
+ } else if (const TagType *tag_type = qual_type->getAs<TagType>()) {
+ TagDecl *tag_decl = tag_type->getDecl();
+
+ m_decls.push_back(tag_decl);
+
+ return tag_decl;
+ } else if (const ObjCObjectType *objc_object_type =
+ qual_type->getAs<ObjCObjectType>()) {
+ ObjCInterfaceDecl *interface_decl = objc_object_type->getInterface();
+
+ m_decls.push_back((NamedDecl *)interface_decl);
+
+ return (NamedDecl *)interface_decl;
+ }
+ }
+ return nullptr;
+}
+
+void NameSearchContext::AddLookupResult(clang::DeclContextLookupResult result) {
+ for (clang::NamedDecl *decl : result)
+ m_decls.push_back(decl);
+}
+
+void NameSearchContext::AddNamedDecl(clang::NamedDecl *decl) {
+ m_decls.push_back(decl);
+}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.h b/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.h
new file mode 100644
index 000000000000..dc8621dd6aba
--- /dev/null
+++ b/lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.h
@@ -0,0 +1,124 @@
+//===-- NameSearchContext.h -------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_NAME_SEARCH_CONTEXT_H
+#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_NAME_SEARCH_CONTEXT_H
+
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "lldb/Symbol/CompilerType.h"
+#include "llvm/ADT/SmallSet.h"
+
+namespace lldb_private {
+
+/// \class NameSearchContext ClangASTSource.h
+/// "lldb/Expression/ClangASTSource.h" Container for all objects relevant to a
+/// single name lookup
+///
+/// LLDB needs to create Decls for entities it finds. This class communicates
+/// what name is being searched for and provides helper functions to construct
+/// Decls given appropriate type information.
+struct NameSearchContext {
+ /// The type system of the AST from which the lookup originated.
+ TypeSystemClang &m_clang_ts;
+ /// The list of declarations already constructed.
+ llvm::SmallVectorImpl<clang::NamedDecl *> &m_decls;
+ /// The mapping of all namespaces found for this request back to their
+ /// modules.
+ ClangASTImporter::NamespaceMapSP m_namespace_map;
+ /// The name being looked for.
+ const clang::DeclarationName m_decl_name;
+ /// The DeclContext to put declarations into.
+ const clang::DeclContext *m_decl_context;
+ /// All the types of functions that have been reported, so we don't
+ /// report conflicts.
+ llvm::SmallSet<CompilerType, 5> m_function_types;
+
+ bool m_found_variable = false;
+ bool m_found_function_with_type_info = false;
+ bool m_found_function = false;
+ bool m_found_local_vars_nsp = false;
+ bool m_found_type = false;
+
+ /// Constructor
+ ///
+ /// Initializes class variables.
+ ///
+ /// \param[in] clang_ts
+ /// The TypeSystemClang from which the request originates.
+ ///
+ /// \param[in] decls
+ /// A reference to a list into which new Decls will be placed. This
+ /// list is typically empty when the function is called.
+ ///
+ /// \param[in] name
+ /// The name being searched for (always an Identifier).
+ ///
+ /// \param[in] dc
+ /// The DeclContext to register Decls in.
+ NameSearchContext(TypeSystemClang &clang_ts,
+ llvm::SmallVectorImpl<clang::NamedDecl *> &decls,
+ clang::DeclarationName name, const clang::DeclContext *dc)
+ : m_clang_ts(clang_ts), m_decls(decls),
+ m_namespace_map(std::make_shared<ClangASTImporter::NamespaceMap>()),
+ m_decl_name(name), m_decl_context(dc) {
+ ;
+ }
+
+ /// Create a VarDecl with the name being searched for and the provided type
+ /// and register it in the right places.
+ ///
+ /// \param[in] type
+ /// The opaque QualType for the VarDecl being registered.
+ clang::NamedDecl *AddVarDecl(const CompilerType &type);
+
+ /// Create a FunDecl with the name being searched for and the provided type
+ /// and register it in the right places.
+ ///
+ /// \param[in] type
+ /// The opaque QualType for the FunDecl being registered.
+ ///
+ /// \param[in] extern_c
+ /// If true, build an extern "C" linkage specification for this.
+ clang::NamedDecl *AddFunDecl(const CompilerType &type, bool extern_c = false);
+
+ /// Create a FunDecl with the name being searched for and generic type (i.e.
+ /// intptr_t NAME_GOES_HERE(...)) and register it in the right places.
+ clang::NamedDecl *AddGenericFunDecl();
+
+ /// Create a TypeDecl with the name being searched for and the provided type
+ /// and register it in the right places.
+ ///
+ /// \param[in] compiler_type
+ /// The opaque QualType for the TypeDecl being registered.
+ clang::NamedDecl *AddTypeDecl(const CompilerType &compiler_type);
+
+ /// Add Decls from the provided DeclContextLookupResult to the list of
+ /// results.
+ ///
+ /// \param[in] result
+ /// The DeclContextLookupResult, usually returned as the result
+ /// of querying a DeclContext.
+ void AddLookupResult(clang::DeclContextLookupResult result);
+
+ /// Add a NamedDecl to the list of results.
+ ///
+ /// \param[in] decl
+ /// The NamedDecl, usually returned as the result
+ /// of querying a DeclContext.
+ void AddNamedDecl(clang::NamedDecl *decl);
+
+private:
+ clang::ASTContext &GetASTContext() const {
+ return m_clang_ts.getASTContext();
+ }
+};
+
+} // namespace lldb_private
+
+#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_NAME_SEARCH_CONTEXT_H
diff --git a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
index ff142e6f35ff..555912780df9 100644
--- a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -1,4 +1,4 @@
-//===-- EmulateInstructionARM.cpp -------------------------------*- C++ -*-===//
+//===-- EmulateInstructionARM.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -30,6 +30,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE_ADV(EmulateInstructionARM, InstructionARM)
+
// Convenient macro definitions.
#define APSR_C Bit32(m_opcode_cpsr, CPSR_C_POS)
#define APSR_V Bit32(m_opcode_cpsr, CPSR_V_POS)
@@ -603,9 +605,6 @@ static uint32_t CountITSize(uint32_t ITMask) {
// First count the trailing zeros of the IT mask.
uint32_t TZ = llvm::countTrailingZeros(ITMask);
if (TZ > 3) {
-#ifdef LLDB_CONFIGURATION_DEBUG
- printf("Encoding error: IT Mask '0000'\n");
-#endif
return 0;
}
return (4 - TZ);
@@ -620,15 +619,9 @@ bool ITSession::InitIT(uint32_t bits7_0) {
// A8.6.50 IT
unsigned short FirstCond = Bits32(bits7_0, 7, 4);
if (FirstCond == 0xF) {
-#ifdef LLDB_CONFIGURATION_DEBUG
- printf("Encoding error: IT FirstCond '1111'\n");
-#endif
return false;
}
if (FirstCond == 0xE && ITCounter != 1) {
-#ifdef LLDB_CONFIGURATION_DEBUG
- printf("Encoding error: IT FirstCond '1110' && Mask != '1000'\n");
-#endif
return false;
}
@@ -7230,7 +7223,7 @@ bool EmulateInstructionARM::EmulateLDRHImmediate(const uint32_t opcode,
return true;
}
-// LDRH (literal) caculates an address from the PC value and an immediate
+// LDRH (literal) calculates an address from the PC value and an immediate
// offset, loads a halfword from memory,
// zero-extends it to form a 32-bit word, and writes it to a register.
bool EmulateInstructionARM::EmulateLDRHLiteral(const uint32_t opcode,
@@ -8516,7 +8509,7 @@ bool EmulateInstructionARM::EmulateSXTH(const uint32_t opcode,
return true;
}
-// UXTB extracts an 8-bit value from a register, zero-extneds it to 32 bits, and
+// UXTB extracts an 8-bit value from a register, zero-extends it to 32 bits, and
// writes the result to the destination
// register. You can specify a rotation by 0, 8, 16, or 24 bits before
// extracting the 8-bit value.
@@ -14368,7 +14361,7 @@ bool EmulateInstructionARM::EvaluateInstruction(uint32_t evaluate_options) {
if (!success)
return false;
- if (auto_advance_pc && (after_pc_value == orig_pc_value)) {
+ if (after_pc_value == orig_pc_value) {
after_pc_value += m_opcode.GetByteSize();
EmulateInstruction::Context context;
diff --git a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
index 13d7fc061bea..d15d80c97e38 100644
--- a/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
+++ b/lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_EmulateInstructionARM_h_
-#define lldb_EmulateInstructionARM_h_
+#ifndef LLDB_SOURCE_PLUGINS_INSTRUCTION_ARM_EMULATEINSTRUCTIONARM_H
+#define LLDB_SOURCE_PLUGINS_INSTRUCTION_ARM_EMULATEINSTRUCTIONARM_H
#include "Plugins/Process/Utility/ARMDefines.h"
#include "lldb/Core/EmulateInstruction.h"
@@ -783,4 +783,4 @@ protected:
} // namespace lldb_private
-#endif // lldb_EmulateInstructionARM_h_
+#endif // LLDB_SOURCE_PLUGINS_INSTRUCTION_ARM_EMULATEINSTRUCTIONARM_H
diff --git a/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp b/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
index 11c7677c201a..aef08baa8ae9 100644
--- a/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
+++ b/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
@@ -1,4 +1,4 @@
-//===-- EmulationStateARM.cpp -----------------------------------*- C++ -*-===//
+//===-- EmulationStateARM.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.h b/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.h
index e5af37a21504..955c7c642058 100644
--- a/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.h
+++ b/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_EmulationStateARM_h_
-#define lldb_EmulationStateARM_h_
+#ifndef LLDB_SOURCE_PLUGINS_INSTRUCTION_ARM_EMULATIONSTATEARM_H
+#define LLDB_SOURCE_PLUGINS_INSTRUCTION_ARM_EMULATIONSTATEARM_H
#include <map>
@@ -73,7 +73,8 @@ private:
// uint32_t to a data buffer heap
// type.
- DISALLOW_COPY_AND_ASSIGN(EmulationStateARM);
+ EmulationStateARM(const EmulationStateARM &) = delete;
+ const EmulationStateARM &operator=(const EmulationStateARM &) = delete;
};
-#endif // lldb_EmulationStateARM_h_
+#endif // LLDB_SOURCE_PLUGINS_INSTRUCTION_ARM_EMULATIONSTATEARM_H
diff --git a/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp b/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
index 3e06fca2504c..9b0c06bcccab 100644
--- a/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
+++ b/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
@@ -1,4 +1,4 @@
-//===-- EmulateInstructionARM64.cpp ------------------------------*- C++-*-===//
+//===-- EmulateInstructionARM64.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,8 +8,6 @@
#include "EmulateInstructionARM64.h"
-#include <stdlib.h>
-
#include "lldb/Core/Address.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Symbol/UnwindPlan.h"
@@ -18,10 +16,14 @@
#include "lldb/Utility/RegisterValue.h"
#include "lldb/Utility/Stream.h"
+#include "llvm/Support/CheckedArithmetic.h"
+
#include "Plugins/Process/Utility/ARMDefines.h"
#include "Plugins/Process/Utility/ARMUtils.h"
#include "Plugins/Process/Utility/lldb-arm64-register-enums.h"
+#include <cstdlib>
+
#define GPR_OFFSET(idx) ((idx)*8)
#define GPR_OFFSET_NAME(reg) 0
#define FPU_OFFSET(idx) ((idx)*16)
@@ -47,6 +49,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE_ADV(EmulateInstructionARM64, InstructionARM64)
+
static bool LLDBTableGetRegisterInfo(uint32_t reg_num, RegisterInfo &reg_info) {
if (reg_num >= llvm::array_lengthof(g_register_infos_arm64_le))
return false;
@@ -83,23 +87,6 @@ static inline uint64_t LSL(uint64_t x, integer shift) {
return x << shift;
}
-// AddWithCarry()
-// ===============
-static inline uint64_t
-AddWithCarry(uint32_t N, uint64_t x, uint64_t y, bit carry_in,
- EmulateInstructionARM64::ProcState &proc_state) {
- uint64_t unsigned_sum = UInt(x) + UInt(y) + UInt(carry_in);
- int64_t signed_sum = SInt(x) + SInt(y) + UInt(carry_in);
- uint64_t result = unsigned_sum;
- if (N < 64)
- result = Bits64(result, N - 1, 0);
- proc_state.N = Bit64(result, N - 1);
- proc_state.Z = IsZero(result);
- proc_state.C = UInt(result) == unsigned_sum;
- proc_state.V = SInt(result) == signed_sum;
- return result;
-}
-
// ConstrainUnpredictable()
// ========================
@@ -415,20 +402,12 @@ bool EmulateInstructionARM64::EvaluateInstruction(uint32_t evaluate_options) {
if (opcode_data == nullptr)
return false;
- // printf ("opcode template for 0x%8.8x: %s\n", opcode, opcode_data->name);
const bool auto_advance_pc =
evaluate_options & eEmulateInstructionOptionAutoAdvancePC;
m_ignore_conditions =
evaluate_options & eEmulateInstructionOptionIgnoreConditions;
bool success = false;
- // if (m_opcode_cpsr == 0 || m_ignore_conditions == false)
- // {
- // m_opcode_cpsr = ReadRegisterUnsigned (eRegisterKindLLDB,
- // gpr_cpsr_arm64,
- // 0,
- // &success);
- // }
// Only return false if we are unable to read the CPSR if we care about
// conditions
@@ -454,7 +433,7 @@ bool EmulateInstructionARM64::EvaluateInstruction(uint32_t evaluate_options) {
if (!success)
return false;
- if (auto_advance_pc && (new_pc_value == orig_pc_value)) {
+ if (new_pc_value == orig_pc_value) {
EmulateInstruction::Context context;
context.type = eContextAdvancePC;
context.SetNoArgs();
@@ -588,6 +567,24 @@ bool EmulateInstructionARM64::ConditionHolds(const uint32_t cond) {
return result;
}
+uint64_t EmulateInstructionARM64::
+AddWithCarry(uint32_t N, uint64_t x, uint64_t y, bit carry_in,
+ EmulateInstructionARM64::ProcState &proc_state) {
+ uint64_t unsigned_sum = UInt(x) + UInt(y) + UInt(carry_in);
+ llvm::Optional<int64_t> signed_sum = llvm::checkedAdd(SInt(x), SInt(y));
+ bool overflow = !signed_sum;
+ if (!overflow)
+ overflow |= !llvm::checkedAdd(*signed_sum, SInt(carry_in));
+ uint64_t result = unsigned_sum;
+ if (N < 64)
+ result = Bits64(result, N - 1, 0);
+ proc_state.N = Bit64(result, N - 1);
+ proc_state.Z = IsZero(result);
+ proc_state.C = UInt(result) != unsigned_sum;
+ proc_state.V = overflow;
+ return result;
+}
+
bool EmulateInstructionARM64::EmulateADDSUBImm(const uint32_t opcode) {
// integer d = UInt(Rd);
// integer n = UInt(Rn);
@@ -783,10 +780,6 @@ bool EmulateInstructionARM64::EmulateLDPSTP(const uint32_t opcode) {
RegisterValue data_Rt;
RegisterValue data_Rt2;
-
- // if (vector)
- // CheckFPEnabled(false);
-
RegisterInfo reg_info_base;
RegisterInfo reg_info_Rt;
RegisterInfo reg_info_Rt2;
diff --git a/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h b/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h
index 03a57a2cf92b..11ad8a99b0fc 100644
--- a/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h
+++ b/lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef EmulateInstructionARM64_h_
-#define EmulateInstructionARM64_h_
+#ifndef LLDB_SOURCE_PLUGINS_INSTRUCTION_ARM64_EMULATEINSTRUCTIONARM64_H
+#define LLDB_SOURCE_PLUGINS_INSTRUCTION_ARM64_EMULATEINSTRUCTIONARM64_H
#include "Plugins/Process/Utility/ARMDefines.h"
#include "lldb/Core/EmulateInstruction.h"
@@ -152,6 +152,9 @@ public:
} ProcState;
protected:
+ static uint64_t AddWithCarry(uint32_t N, uint64_t x, uint64_t y, bool carry_in,
+ EmulateInstructionARM64::ProcState &proc_state);
+
typedef struct {
uint32_t mask;
uint32_t value;
@@ -189,4 +192,4 @@ protected:
bool m_ignore_conditions;
};
-#endif // EmulateInstructionARM64_h_
+#endif // LLDB_SOURCE_PLUGINS_INSTRUCTION_ARM64_EMULATEINSTRUCTIONARM64_H
diff --git a/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp b/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
index b55eeb0eaf46..d4cb726fc7e5 100644
--- a/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
+++ b/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
@@ -1,4 +1,4 @@
-//===-- EmulateInstructionMIPS.cpp -------------------------------*- C++-*-===//
+//===-- EmulateInstructionMIPS.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -40,6 +40,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE_ADV(EmulateInstructionMIPS, InstructionMIPS)
+
#define UInt(x) ((uint64_t)x)
#define integer int64_t
@@ -157,8 +159,8 @@ EmulateInstructionMIPS::EmulateInstructionMIPS(
target->createMCSubtargetInfo(triple.getTriple(), cpu, features));
assert(m_asm_info.get() && m_subtype_info.get());
- m_context.reset(
- new llvm::MCContext(m_asm_info.get(), m_reg_info.get(), nullptr));
+ m_context = std::make_unique<llvm::MCContext>(m_asm_info.get(),
+ m_reg_info.get(), nullptr);
assert(m_context.get());
m_disasm.reset(target->createMCDisassembler(*m_subtype_info, *m_context));
diff --git a/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h b/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h
index cd447ae4975e..61291c729879 100644
--- a/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h
+++ b/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef EmulateInstructionMIPS_h_
-#define EmulateInstructionMIPS_h_
+#ifndef LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS_EMULATEINSTRUCTIONMIPS_H
+#define LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS_EMULATEINSTRUCTIONMIPS_H
namespace llvm {
class MCDisassembler;
@@ -203,7 +203,7 @@ protected:
bool nonvolatile_reg_p(uint32_t regnum);
- const char *GetRegisterName(unsigned reg_num, bool altnernate_name);
+ const char *GetRegisterName(unsigned reg_num, bool alternate_name);
private:
std::unique_ptr<llvm::MCDisassembler> m_disasm;
@@ -218,4 +218,4 @@ private:
bool m_use_alt_disaasm;
};
-#endif // EmulateInstructionMIPS_h_
+#endif // LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS_EMULATEINSTRUCTIONMIPS_H
diff --git a/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp b/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
index 3baf942bc17f..4ccaf0de0758 100644
--- a/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
+++ b/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
@@ -1,4 +1,4 @@
-//===-- EmulateInstructionMIPS64.cpp -----------------------------*- C++-*-===//
+//===-- EmulateInstructionMIPS64.cpp --------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -40,6 +40,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE_ADV(EmulateInstructionMIPS64, InstructionMIPS64)
+
#define UInt(x) ((uint64_t)x)
#define integer int64_t
@@ -161,8 +163,8 @@ EmulateInstructionMIPS64::EmulateInstructionMIPS64(
target->createMCSubtargetInfo(triple.getTriple(), cpu, features));
assert(m_asm_info.get() && m_subtype_info.get());
- m_context.reset(
- new llvm::MCContext(m_asm_info.get(), m_reg_info.get(), nullptr));
+ m_context = std::make_unique<llvm::MCContext>(m_asm_info.get(),
+ m_reg_info.get(), nullptr);
assert(m_context.get());
m_disasm.reset(target->createMCDisassembler(*m_subtype_info, *m_context));
diff --git a/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h b/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h
index 953a0935bd06..c4ae2296c5dd 100644
--- a/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h
+++ b/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef EmulateInstructionMIPS64_h_
-#define EmulateInstructionMIPS64_h_
+#ifndef LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS64_EMULATEINSTRUCTIONMIPS64_H
+#define LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS64_EMULATEINSTRUCTIONMIPS64_H
#include "lldb/Core/EmulateInstruction.h"
#include "lldb/Interpreter/OptionValue.h"
@@ -168,7 +168,7 @@ protected:
bool nonvolatile_reg_p(uint64_t regnum);
- const char *GetRegisterName(unsigned reg_num, bool altnernate_name);
+ const char *GetRegisterName(unsigned reg_num, bool alternate_name);
private:
std::unique_ptr<llvm::MCDisassembler> m_disasm;
@@ -179,4 +179,4 @@ private:
std::unique_ptr<llvm::MCInstrInfo> m_insn_info;
};
-#endif // EmulateInstructionMIPS64_h_
+#endif // LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS64_EMULATEINSTRUCTIONMIPS64_H
diff --git a/lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp b/lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp
index 4b8d8dd2228c..5d97513c0be7 100644
--- a/lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp
+++ b/lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp
@@ -1,4 +1,4 @@
-//===-- EmulateInstructionPPC64.cpp ------------------------------*- C++-*-===//
+//===-- EmulateInstructionPPC64.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -25,6 +25,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE_ADV(EmulateInstructionPPC64, InstructionPPC64)
+
EmulateInstructionPPC64::EmulateInstructionPPC64(const ArchSpec &arch)
: EmulateInstruction(arch) {}
@@ -196,7 +198,7 @@ bool EmulateInstructionPPC64::EvaluateInstruction(uint32_t evaluate_options) {
if (!success)
return false;
- if (auto_advance_pc && (new_pc_value == orig_pc_value)) {
+ if (new_pc_value == orig_pc_value) {
EmulateInstruction::Context context;
context.type = eContextAdvancePC;
context.SetNoArgs();
diff --git a/lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h b/lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h
index bf239770b933..02d2bce8f05e 100644
--- a/lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h
+++ b/lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef EmulateInstructionPPC64_h_
-#define EmulateInstructionPPC64_h_
+#ifndef LLDB_SOURCE_PLUGINS_INSTRUCTION_PPC64_EMULATEINSTRUCTIONPPC64_H
+#define LLDB_SOURCE_PLUGINS_INSTRUCTION_PPC64_EMULATEINSTRUCTIONPPC64_H
#include "lldb/Core/EmulateInstruction.h"
#include "lldb/Interpreter/OptionValue.h"
@@ -89,4 +89,4 @@ private:
} // namespace lldb_private
-#endif // EmulateInstructionPPC64_h_
+#endif // LLDB_SOURCE_PLUGINS_INSTRUCTION_PPC64_EMULATEINSTRUCTIONPPC64_H
diff --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
index 2e5dd5989e77..e78ea3a68483 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp
+++ b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp
@@ -1,4 +1,4 @@
-//===-- ASanRuntime.cpp -----------------------------------------*- C++ -*-===//
+//===-- InstrumentationRuntimeASan.cpp ------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "ASanRuntime.h"
+#include "InstrumentationRuntimeASan.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Debugger.h"
@@ -30,40 +30,42 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(InstrumentationRuntimeASan)
+
lldb::InstrumentationRuntimeSP
-AddressSanitizerRuntime::CreateInstance(const lldb::ProcessSP &process_sp) {
- return InstrumentationRuntimeSP(new AddressSanitizerRuntime(process_sp));
+InstrumentationRuntimeASan::CreateInstance(const lldb::ProcessSP &process_sp) {
+ return InstrumentationRuntimeSP(new InstrumentationRuntimeASan(process_sp));
}
-void AddressSanitizerRuntime::Initialize() {
+void InstrumentationRuntimeASan::Initialize() {
PluginManager::RegisterPlugin(
GetPluginNameStatic(), "AddressSanitizer instrumentation runtime plugin.",
CreateInstance, GetTypeStatic);
}
-void AddressSanitizerRuntime::Terminate() {
+void InstrumentationRuntimeASan::Terminate() {
PluginManager::UnregisterPlugin(CreateInstance);
}
-lldb_private::ConstString AddressSanitizerRuntime::GetPluginNameStatic() {
+lldb_private::ConstString InstrumentationRuntimeASan::GetPluginNameStatic() {
return ConstString("AddressSanitizer");
}
-lldb::InstrumentationRuntimeType AddressSanitizerRuntime::GetTypeStatic() {
+lldb::InstrumentationRuntimeType InstrumentationRuntimeASan::GetTypeStatic() {
return eInstrumentationRuntimeTypeAddressSanitizer;
}
-AddressSanitizerRuntime::~AddressSanitizerRuntime() { Deactivate(); }
+InstrumentationRuntimeASan::~InstrumentationRuntimeASan() { Deactivate(); }
const RegularExpression &
-AddressSanitizerRuntime::GetPatternForRuntimeLibrary() {
+InstrumentationRuntimeASan::GetPatternForRuntimeLibrary() {
// FIXME: This shouldn't include the "dylib" suffix.
static RegularExpression regex(
llvm::StringRef("libclang_rt.asan_(.*)_dynamic\\.dylib"));
return regex;
}
-bool AddressSanitizerRuntime::CheckIfRuntimeIsValid(
+bool InstrumentationRuntimeASan::CheckIfRuntimeIsValid(
const lldb::ModuleSP module_sp) {
const Symbol *symbol = module_sp->FindFirstSymbolWithNameAndType(
ConstString("__asan_get_alloc_stack"), lldb::eSymbolTypeAny);
@@ -108,7 +110,7 @@ t.description = __asan_get_report_description();
t
)";
-StructuredData::ObjectSP AddressSanitizerRuntime::RetrieveReportData() {
+StructuredData::ObjectSP InstrumentationRuntimeASan::RetrieveReportData() {
ProcessSP process_sp = GetProcessSP();
if (!process_sp)
return StructuredData::ObjectSP();
@@ -189,11 +191,11 @@ StructuredData::ObjectSP AddressSanitizerRuntime::RetrieveReportData() {
}
std::string
-AddressSanitizerRuntime::FormatDescription(StructuredData::ObjectSP report) {
- std::string description = report->GetAsDictionary()
- ->GetValueForKey("description")
- ->GetAsString()
- ->GetValue();
+InstrumentationRuntimeASan::FormatDescription(StructuredData::ObjectSP report) {
+ std::string description = std::string(report->GetAsDictionary()
+ ->GetValueForKey("description")
+ ->GetAsString()
+ ->GetValue());
return llvm::StringSwitch<std::string>(description)
.Case("heap-use-after-free", "Use of deallocated memory")
.Case("heap-buffer-overflow", "Heap buffer overflow")
@@ -235,15 +237,15 @@ AddressSanitizerRuntime::FormatDescription(StructuredData::ObjectSP report) {
.Default("AddressSanitizer detected: " + description);
}
-bool AddressSanitizerRuntime::NotifyBreakpointHit(
+bool InstrumentationRuntimeASan::NotifyBreakpointHit(
void *baton, StoppointCallbackContext *context, user_id_t break_id,
user_id_t break_loc_id) {
assert(baton && "null baton");
if (!baton)
return false;
- AddressSanitizerRuntime *const instance =
- static_cast<AddressSanitizerRuntime *>(baton);
+ InstrumentationRuntimeASan *const instance =
+ static_cast<InstrumentationRuntimeASan *>(baton);
ProcessSP process_sp = instance->GetProcessSP();
@@ -275,7 +277,7 @@ bool AddressSanitizerRuntime::NotifyBreakpointHit(
return false; // Let target run
}
-void AddressSanitizerRuntime::Activate() {
+void InstrumentationRuntimeASan::Activate() {
if (IsActive())
return;
@@ -305,7 +307,7 @@ void AddressSanitizerRuntime::Activate() {
process_sp->GetTarget()
.CreateBreakpoint(symbol_address, internal, hardware)
.get();
- breakpoint->SetCallback(AddressSanitizerRuntime::NotifyBreakpointHit, this,
+ breakpoint->SetCallback(InstrumentationRuntimeASan::NotifyBreakpointHit, this,
true);
breakpoint->SetBreakpointKind("address-sanitizer-report");
SetBreakpointID(breakpoint->GetID());
@@ -313,7 +315,7 @@ void AddressSanitizerRuntime::Activate() {
SetActive(true);
}
-void AddressSanitizerRuntime::Deactivate() {
+void InstrumentationRuntimeASan::Deactivate() {
if (GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
ProcessSP process_sp = GetProcessSP();
if (process_sp) {
diff --git a/lldb/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.h
index 0771e624ff6b..cde0a9613350 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h
+++ b/lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.h
@@ -1,4 +1,4 @@
-//===-- ASanRuntime.h -------------------------------------------*- C++ -*-===//
+//===-- InstrumentationRuntimeASan.h ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_AddressSanitizerRuntime_h_
-#define liblldb_AddressSanitizerRuntime_h_
+#ifndef LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_ASAN_INSTRUMENTATIONRUNTIMEASAN_H
+#define LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_ASAN_INSTRUMENTATIONRUNTIMEASAN_H
#include "lldb/Target/InstrumentationRuntime.h"
#include "lldb/Target/Process.h"
@@ -16,9 +16,9 @@
namespace lldb_private {
-class AddressSanitizerRuntime : public lldb_private::InstrumentationRuntime {
+class InstrumentationRuntimeASan : public lldb_private::InstrumentationRuntime {
public:
- ~AddressSanitizerRuntime() override;
+ ~InstrumentationRuntimeASan() override;
static lldb::InstrumentationRuntimeSP
CreateInstance(const lldb::ProcessSP &process_sp);
@@ -40,7 +40,7 @@ public:
uint32_t GetPluginVersion() override { return 1; }
private:
- AddressSanitizerRuntime(const lldb::ProcessSP &process_sp)
+ InstrumentationRuntimeASan(const lldb::ProcessSP &process_sp)
: lldb_private::InstrumentationRuntime(process_sp) {}
const RegularExpression &GetPatternForRuntimeLibrary() override;
@@ -63,4 +63,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_AddressSanitizerRuntime_h_
+#endif // LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_ASAN_INSTRUMENTATIONRUNTIMEASAN_H
diff --git a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
index b73b6c095368..72d28c347457 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp
+++ b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
@@ -1,4 +1,4 @@
-//===-- MainThreadCheckerRuntime.cpp ----------------------------*- C++ -*-===//
+//===-- InstrumentationRuntimeMainThreadChecker.cpp -----------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,9 @@
//
//===----------------------------------------------------------------------===//
-#include "MainThreadCheckerRuntime.h"
+#include "InstrumentationRuntimeMainThreadChecker.h"
+#include "Plugins/Process/Utility/HistoryThread.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
@@ -22,47 +23,54 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/RegularExpression.h"
-#include "Plugins/Process/Utility/HistoryThread.h"
#include <memory>
using namespace lldb;
using namespace lldb_private;
-MainThreadCheckerRuntime::~MainThreadCheckerRuntime() {
+LLDB_PLUGIN_DEFINE(InstrumentationRuntimeMainThreadChecker)
+
+InstrumentationRuntimeMainThreadChecker::
+ ~InstrumentationRuntimeMainThreadChecker() {
Deactivate();
}
lldb::InstrumentationRuntimeSP
-MainThreadCheckerRuntime::CreateInstance(const lldb::ProcessSP &process_sp) {
- return InstrumentationRuntimeSP(new MainThreadCheckerRuntime(process_sp));
+InstrumentationRuntimeMainThreadChecker::CreateInstance(
+ const lldb::ProcessSP &process_sp) {
+ return InstrumentationRuntimeSP(
+ new InstrumentationRuntimeMainThreadChecker(process_sp));
}
-void MainThreadCheckerRuntime::Initialize() {
+void InstrumentationRuntimeMainThreadChecker::Initialize() {
PluginManager::RegisterPlugin(
- GetPluginNameStatic(), "MainThreadChecker instrumentation runtime plugin.",
- CreateInstance, GetTypeStatic);
+ GetPluginNameStatic(),
+ "MainThreadChecker instrumentation runtime plugin.", CreateInstance,
+ GetTypeStatic);
}
-void MainThreadCheckerRuntime::Terminate() {
+void InstrumentationRuntimeMainThreadChecker::Terminate() {
PluginManager::UnregisterPlugin(CreateInstance);
}
-lldb_private::ConstString MainThreadCheckerRuntime::GetPluginNameStatic() {
+lldb_private::ConstString
+InstrumentationRuntimeMainThreadChecker::GetPluginNameStatic() {
return ConstString("MainThreadChecker");
}
-lldb::InstrumentationRuntimeType MainThreadCheckerRuntime::GetTypeStatic() {
+lldb::InstrumentationRuntimeType
+InstrumentationRuntimeMainThreadChecker::GetTypeStatic() {
return eInstrumentationRuntimeTypeMainThreadChecker;
}
const RegularExpression &
-MainThreadCheckerRuntime::GetPatternForRuntimeLibrary() {
+InstrumentationRuntimeMainThreadChecker::GetPatternForRuntimeLibrary() {
static RegularExpression regex(llvm::StringRef("libMainThreadChecker.dylib"));
return regex;
}
-bool MainThreadCheckerRuntime::CheckIfRuntimeIsValid(
+bool InstrumentationRuntimeMainThreadChecker::CheckIfRuntimeIsValid(
const lldb::ModuleSP module_sp) {
static ConstString test_sym("__main_thread_checker_on_report");
const Symbol *symbol =
@@ -71,7 +79,8 @@ bool MainThreadCheckerRuntime::CheckIfRuntimeIsValid(
}
StructuredData::ObjectSP
-MainThreadCheckerRuntime::RetrieveReportData(ExecutionContextRef exe_ctx_ref) {
+InstrumentationRuntimeMainThreadChecker::RetrieveReportData(
+ ExecutionContextRef exe_ctx_ref) {
ProcessSP process_sp = GetProcessSP();
if (!process_sp)
return StructuredData::ObjectSP();
@@ -148,15 +157,15 @@ MainThreadCheckerRuntime::RetrieveReportData(ExecutionContextRef exe_ctx_ref) {
return dict_sp;
}
-bool MainThreadCheckerRuntime::NotifyBreakpointHit(
+bool InstrumentationRuntimeMainThreadChecker::NotifyBreakpointHit(
void *baton, StoppointCallbackContext *context, user_id_t break_id,
user_id_t break_loc_id) {
assert(baton && "null baton");
if (!baton)
return false; ///< false => resume execution.
- MainThreadCheckerRuntime *const instance =
- static_cast<MainThreadCheckerRuntime *>(baton);
+ InstrumentationRuntimeMainThreadChecker *const instance =
+ static_cast<InstrumentationRuntimeMainThreadChecker *>(baton);
ProcessSP process_sp = instance->GetProcessSP();
ThreadSP thread_sp = context->exe_ctx_ref.GetThreadSP();
@@ -171,10 +180,10 @@ bool MainThreadCheckerRuntime::NotifyBreakpointHit(
instance->RetrieveReportData(context->exe_ctx_ref);
if (report) {
- std::string description = report->GetAsDictionary()
- ->GetValueForKey("description")
- ->GetAsString()
- ->GetValue();
+ std::string description = std::string(report->GetAsDictionary()
+ ->GetValueForKey("description")
+ ->GetAsString()
+ ->GetValue());
thread_sp->SetStopInfo(
InstrumentationRuntimeStopInfo::CreateStopReasonWithInstrumentationData(
*thread_sp, description, report));
@@ -184,7 +193,7 @@ bool MainThreadCheckerRuntime::NotifyBreakpointHit(
return false;
}
-void MainThreadCheckerRuntime::Activate() {
+void InstrumentationRuntimeMainThreadChecker::Activate() {
if (IsActive())
return;
@@ -215,15 +224,15 @@ void MainThreadCheckerRuntime::Activate() {
.CreateBreakpoint(symbol_address, /*internal=*/true,
/*hardware=*/false)
.get();
- breakpoint->SetCallback(MainThreadCheckerRuntime::NotifyBreakpointHit, this,
- true);
+ breakpoint->SetCallback(
+ InstrumentationRuntimeMainThreadChecker::NotifyBreakpointHit, this, true);
breakpoint->SetBreakpointKind("main-thread-checker-report");
SetBreakpointID(breakpoint->GetID());
SetActive(true);
}
-void MainThreadCheckerRuntime::Deactivate() {
+void InstrumentationRuntimeMainThreadChecker::Deactivate() {
SetActive(false);
auto BID = GetBreakpointID();
@@ -237,7 +246,7 @@ void MainThreadCheckerRuntime::Deactivate() {
}
lldb::ThreadCollectionSP
-MainThreadCheckerRuntime::GetBacktracesFromExtendedStopInfo(
+InstrumentationRuntimeMainThreadChecker::GetBacktracesFromExtendedStopInfo(
StructuredData::ObjectSP info) {
ThreadCollectionSP threads;
threads = std::make_shared<ThreadCollection>();
@@ -245,7 +254,7 @@ MainThreadCheckerRuntime::GetBacktracesFromExtendedStopInfo(
ProcessSP process_sp = GetProcessSP();
if (info->GetObjectForDotSeparatedPath("instrumentation_class")
- ->GetStringValue() != "MainThreadChecker")
+ ->GetStringValue() != "MainThreadChecker")
return threads;
std::vector<lldb::addr_t> PCs;
diff --git a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h
new file mode 100644
index 000000000000..1435ae8d367f
--- /dev/null
+++ b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h
@@ -0,0 +1,68 @@
+//===-- InstrumentationRuntimeMainThreadChecker.h----------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_MAINTHREADCHECKER_INSTRUMENTATIONRUNTIMEMAINTHREADCHECKER_H
+#define LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_MAINTHREADCHECKER_INSTRUMENTATIONRUNTIMEMAINTHREADCHECKER_H
+
+#include "lldb/Target/ABI.h"
+#include "lldb/Target/InstrumentationRuntime.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-private.h"
+
+namespace lldb_private {
+
+class InstrumentationRuntimeMainThreadChecker
+ : public lldb_private::InstrumentationRuntime {
+public:
+ ~InstrumentationRuntimeMainThreadChecker() override;
+
+ static lldb::InstrumentationRuntimeSP
+ CreateInstance(const lldb::ProcessSP &process_sp);
+
+ static void Initialize();
+
+ static void Terminate();
+
+ static lldb_private::ConstString GetPluginNameStatic();
+
+ static lldb::InstrumentationRuntimeType GetTypeStatic();
+
+ lldb_private::ConstString GetPluginName() override {
+ return GetPluginNameStatic();
+ }
+
+ virtual lldb::InstrumentationRuntimeType GetType() { return GetTypeStatic(); }
+
+ uint32_t GetPluginVersion() override { return 1; }
+
+ lldb::ThreadCollectionSP
+ GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info) override;
+
+private:
+ InstrumentationRuntimeMainThreadChecker(const lldb::ProcessSP &process_sp)
+ : lldb_private::InstrumentationRuntime(process_sp) {}
+
+ const RegularExpression &GetPatternForRuntimeLibrary() override;
+
+ bool CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp) override;
+
+ void Activate() override;
+
+ void Deactivate();
+
+ static bool NotifyBreakpointHit(void *baton,
+ StoppointCallbackContext *context,
+ lldb::user_id_t break_id,
+ lldb::user_id_t break_loc_id);
+
+ StructuredData::ObjectSP RetrieveReportData(ExecutionContextRef exe_ctx_ref);
+};
+
+} // namespace lldb_private
+
+#endif // LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_MAINTHREADCHECKER_INSTRUMENTATIONRUNTIMEMAINTHREADCHECKER_H
diff --git a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h
deleted file mode 100644
index 1dcbc0f6bc89..000000000000
--- a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h
+++ /dev/null
@@ -1,67 +0,0 @@
-//===-- MainThreadCheckerRuntime.h ------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_MainThreadCheckerRuntime_h_
-#define liblldb_MainThreadCheckerRuntime_h_
-
-#include "lldb/Target/ABI.h"
-#include "lldb/Target/InstrumentationRuntime.h"
-#include "lldb/Utility/StructuredData.h"
-#include "lldb/lldb-private.h"
-
-namespace lldb_private {
-
- class MainThreadCheckerRuntime : public lldb_private::InstrumentationRuntime {
- public:
- ~MainThreadCheckerRuntime() override;
-
- static lldb::InstrumentationRuntimeSP
- CreateInstance(const lldb::ProcessSP &process_sp);
-
- static void Initialize();
-
- static void Terminate();
-
- static lldb_private::ConstString GetPluginNameStatic();
-
- static lldb::InstrumentationRuntimeType GetTypeStatic();
-
- lldb_private::ConstString GetPluginName() override {
- return GetPluginNameStatic();
- }
-
- virtual lldb::InstrumentationRuntimeType GetType() { return GetTypeStatic(); }
-
- uint32_t GetPluginVersion() override { return 1; }
-
- lldb::ThreadCollectionSP
- GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info) override;
-
- private:
- MainThreadCheckerRuntime(const lldb::ProcessSP &process_sp)
- : lldb_private::InstrumentationRuntime(process_sp) {}
-
- const RegularExpression &GetPatternForRuntimeLibrary() override;
-
- bool CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp) override;
-
- void Activate() override;
-
- void Deactivate();
-
- static bool NotifyBreakpointHit(void *baton,
- StoppointCallbackContext *context,
- lldb::user_id_t break_id,
- lldb::user_id_t break_loc_id);
-
- StructuredData::ObjectSP RetrieveReportData(ExecutionContextRef exe_ctx_ref);
- };
-
-} // namespace lldb_private
-
-#endif // liblldb_MainThreadCheckerRuntime_h_
diff --git a/lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
index 45a3aeeb204e..50f0faefa0f4 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp
+++ b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
@@ -1,4 +1,4 @@
-//===-- TSanRuntime.cpp -----------------------------------------*- C++ -*-===//
+//===-- InstrumentationRuntimeTSan.cpp ------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "TSanRuntime.h"
+#include "InstrumentationRuntimeTSan.h"
#include "Plugins/Process/Utility/HistoryThread.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
@@ -35,30 +35,32 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(InstrumentationRuntimeTSan)
+
lldb::InstrumentationRuntimeSP
-ThreadSanitizerRuntime::CreateInstance(const lldb::ProcessSP &process_sp) {
- return InstrumentationRuntimeSP(new ThreadSanitizerRuntime(process_sp));
+InstrumentationRuntimeTSan::CreateInstance(const lldb::ProcessSP &process_sp) {
+ return InstrumentationRuntimeSP(new InstrumentationRuntimeTSan(process_sp));
}
-void ThreadSanitizerRuntime::Initialize() {
+void InstrumentationRuntimeTSan::Initialize() {
PluginManager::RegisterPlugin(
GetPluginNameStatic(), "ThreadSanitizer instrumentation runtime plugin.",
CreateInstance, GetTypeStatic);
}
-void ThreadSanitizerRuntime::Terminate() {
+void InstrumentationRuntimeTSan::Terminate() {
PluginManager::UnregisterPlugin(CreateInstance);
}
-lldb_private::ConstString ThreadSanitizerRuntime::GetPluginNameStatic() {
+lldb_private::ConstString InstrumentationRuntimeTSan::GetPluginNameStatic() {
return ConstString("ThreadSanitizer");
}
-lldb::InstrumentationRuntimeType ThreadSanitizerRuntime::GetTypeStatic() {
+lldb::InstrumentationRuntimeType InstrumentationRuntimeTSan::GetTypeStatic() {
return eInstrumentationRuntimeTypeThreadSanitizer;
}
-ThreadSanitizerRuntime::~ThreadSanitizerRuntime() { Deactivate(); }
+InstrumentationRuntimeTSan::~InstrumentationRuntimeTSan() { Deactivate(); }
const char *thread_sanitizer_retrieve_report_data_prefix = R"(
extern "C"
@@ -84,7 +86,7 @@ extern "C"
int *running, const char **name, int *parent_tid,
void **trace, unsigned long trace_size);
int __tsan_get_report_unique_tid(void *report, unsigned long idx, int *tid);
-
+
// TODO: dlsym won't work on Windows.
void *dlsym(void* handle, const char* symbol);
int (*ptr__tsan_get_report_loc_object_type)(void *report, unsigned long idx, const char **object_type);
@@ -97,15 +99,15 @@ struct data {
void *report;
const char *description;
int report_count;
-
+
void *sleep_trace[REPORT_TRACE_SIZE];
-
+
int stack_count;
struct {
int idx;
void *trace[REPORT_TRACE_SIZE];
} stacks[REPORT_ARRAY_SIZE];
-
+
int mop_count;
struct {
int idx;
@@ -116,7 +118,7 @@ struct data {
void *addr;
void *trace[REPORT_TRACE_SIZE];
} mops[REPORT_ARRAY_SIZE];
-
+
int loc_count;
struct {
int idx;
@@ -130,7 +132,7 @@ struct data {
void *trace[REPORT_TRACE_SIZE];
const char *object_type;
} locs[REPORT_ARRAY_SIZE];
-
+
int mutex_count;
struct {
int idx;
@@ -139,7 +141,7 @@ struct data {
int destroyed;
void *trace[REPORT_TRACE_SIZE];
} mutexes[REPORT_ARRAY_SIZE];
-
+
int thread_count;
struct {
int idx;
@@ -150,7 +152,7 @@ struct data {
int parent_tid;
void *trace[REPORT_TRACE_SIZE];
} threads[REPORT_ARRAY_SIZE];
-
+
int unique_tid_count;
struct {
int idx;
@@ -299,8 +301,8 @@ static user_id_t Renumber(uint64_t id,
return IT->second;
}
-StructuredData::ObjectSP
-ThreadSanitizerRuntime::RetrieveReportData(ExecutionContextRef exe_ctx_ref) {
+StructuredData::ObjectSP InstrumentationRuntimeTSan::RetrieveReportData(
+ ExecutionContextRef exe_ctx_ref) {
ProcessSP process_sp = GetProcessSP();
if (!process_sp)
return StructuredData::ObjectSP();
@@ -486,11 +488,11 @@ ThreadSanitizerRuntime::RetrieveReportData(ExecutionContextRef exe_ctx_ref) {
}
std::string
-ThreadSanitizerRuntime::FormatDescription(StructuredData::ObjectSP report) {
- std::string description = report->GetAsDictionary()
- ->GetValueForKey("issue_type")
- ->GetAsString()
- ->GetValue();
+InstrumentationRuntimeTSan::FormatDescription(StructuredData::ObjectSP report) {
+ std::string description = std::string(report->GetAsDictionary()
+ ->GetValueForKey("issue_type")
+ ->GetAsString()
+ ->GetValue());
if (description == "data-race") {
return "Data race";
@@ -536,7 +538,7 @@ static std::string Sprintf(const char *format, ...) {
va_start(args, format);
s.PrintfVarArg(format, args);
va_end(args);
- return s.GetString();
+ return std::string(s.GetString());
}
static std::string GetSymbolNameFromAddress(ProcessSP process_sp, addr_t addr) {
@@ -564,15 +566,14 @@ static void GetSymbolDeclarationFromAddress(ProcessSP process_sp, addr_t addr,
if (!symbol)
return;
- ConstString sym_name = symbol->GetMangled().GetName(
- lldb::eLanguageTypeUnknown, Mangled::ePreferMangled);
+ ConstString sym_name = symbol->GetMangled().GetName(Mangled::ePreferMangled);
ModuleSP module = symbol->CalculateSymbolContextModule();
if (!module)
return;
VariableList var_list;
- module->FindGlobalVariables(sym_name, nullptr, 1U, var_list);
+ module->FindGlobalVariables(sym_name, CompilerDeclContext(), 1U, var_list);
if (var_list.GetSize() < 1)
return;
@@ -580,7 +581,7 @@ static void GetSymbolDeclarationFromAddress(ProcessSP process_sp, addr_t addr,
decl = var->GetDeclaration();
}
-addr_t ThreadSanitizerRuntime::GetFirstNonInternalFramePc(
+addr_t InstrumentationRuntimeTSan::GetFirstNonInternalFramePc(
StructuredData::ObjectSP trace, bool skip_one_frame) {
ProcessSP process_sp = GetProcessSP();
ModuleSP runtime_module_sp = GetRuntimeModuleSP();
@@ -609,13 +610,13 @@ addr_t ThreadSanitizerRuntime::GetFirstNonInternalFramePc(
}
std::string
-ThreadSanitizerRuntime::GenerateSummary(StructuredData::ObjectSP report) {
+InstrumentationRuntimeTSan::GenerateSummary(StructuredData::ObjectSP report) {
ProcessSP process_sp = GetProcessSP();
- std::string summary = report->GetAsDictionary()
- ->GetValueForKey("description")
- ->GetAsString()
- ->GetValue();
+ std::string summary = std::string(report->GetAsDictionary()
+ ->GetValueForKey("description")
+ ->GetAsString()
+ ->GetValue());
bool skip_one_frame =
report->GetObjectForDotSeparatedPath("issue_type")->GetStringValue() ==
"external-race";
@@ -657,10 +658,10 @@ ThreadSanitizerRuntime::GenerateSummary(StructuredData::ObjectSP report) {
->GetValueForKey("locs")
->GetAsArray()
->GetItemAtIndex(0);
- std::string object_type = loc->GetAsDictionary()
- ->GetValueForKey("object_type")
- ->GetAsString()
- ->GetValue();
+ std::string object_type = std::string(loc->GetAsDictionary()
+ ->GetValueForKey("object_type")
+ ->GetAsString()
+ ->GetValue());
if (!object_type.empty()) {
summary = "Race on " + object_type + " object";
}
@@ -695,8 +696,8 @@ ThreadSanitizerRuntime::GenerateSummary(StructuredData::ObjectSP report) {
return summary;
}
-addr_t
-ThreadSanitizerRuntime::GetMainRacyAddress(StructuredData::ObjectSP report) {
+addr_t InstrumentationRuntimeTSan::GetMainRacyAddress(
+ StructuredData::ObjectSP report) {
addr_t result = (addr_t)-1;
report->GetObjectForDotSeparatedPath("mops")->GetAsArray()->ForEach(
@@ -711,7 +712,7 @@ ThreadSanitizerRuntime::GetMainRacyAddress(StructuredData::ObjectSP report) {
return (result == (addr_t)-1) ? 0 : result;
}
-std::string ThreadSanitizerRuntime::GetLocationDescription(
+std::string InstrumentationRuntimeTSan::GetLocationDescription(
StructuredData::ObjectSP report, addr_t &global_addr,
std::string &global_name, std::string &filename, uint32_t &line) {
std::string result = "";
@@ -726,8 +727,8 @@ std::string ThreadSanitizerRuntime::GetLocationDescription(
->GetValueForKey("locs")
->GetAsArray()
->GetItemAtIndex(0);
- std::string type =
- loc->GetAsDictionary()->GetValueForKey("type")->GetStringValue();
+ std::string type = std::string(
+ loc->GetAsDictionary()->GetValueForKey("type")->GetStringValue());
if (type == "global") {
global_addr = loc->GetAsDictionary()
->GetValueForKey("address")
@@ -756,10 +757,10 @@ std::string ThreadSanitizerRuntime::GetLocationDescription(
->GetValueForKey("size")
->GetAsInteger()
->GetValue();
- std::string object_type = loc->GetAsDictionary()
- ->GetValueForKey("object_type")
- ->GetAsString()
- ->GetValue();
+ std::string object_type = std::string(loc->GetAsDictionary()
+ ->GetValueForKey("object_type")
+ ->GetAsString()
+ ->GetValue());
if (!object_type.empty()) {
result = Sprintf("Location is a %ld-byte %s object at 0x%llx", size,
object_type.c_str(), addr);
@@ -791,15 +792,15 @@ std::string ThreadSanitizerRuntime::GetLocationDescription(
return result;
}
-bool ThreadSanitizerRuntime::NotifyBreakpointHit(
+bool InstrumentationRuntimeTSan::NotifyBreakpointHit(
void *baton, StoppointCallbackContext *context, user_id_t break_id,
user_id_t break_loc_id) {
assert(baton && "null baton");
if (!baton)
return false;
- ThreadSanitizerRuntime *const instance =
- static_cast<ThreadSanitizerRuntime *>(baton);
+ InstrumentationRuntimeTSan *const instance =
+ static_cast<InstrumentationRuntimeTSan *>(baton);
ProcessSP process_sp = instance->GetProcessSP();
@@ -873,12 +874,13 @@ bool ThreadSanitizerRuntime::NotifyBreakpointHit(
return false; // Let target run
}
-const RegularExpression &ThreadSanitizerRuntime::GetPatternForRuntimeLibrary() {
+const RegularExpression &
+InstrumentationRuntimeTSan::GetPatternForRuntimeLibrary() {
static RegularExpression regex(llvm::StringRef("libclang_rt.tsan_"));
return regex;
}
-bool ThreadSanitizerRuntime::CheckIfRuntimeIsValid(
+bool InstrumentationRuntimeTSan::CheckIfRuntimeIsValid(
const lldb::ModuleSP module_sp) {
static ConstString g_tsan_get_current_report("__tsan_get_current_report");
const Symbol *symbol = module_sp->FindFirstSymbolWithNameAndType(
@@ -886,7 +888,7 @@ bool ThreadSanitizerRuntime::CheckIfRuntimeIsValid(
return symbol != nullptr;
}
-void ThreadSanitizerRuntime::Activate() {
+void InstrumentationRuntimeTSan::Activate() {
if (IsActive())
return;
@@ -916,7 +918,7 @@ void ThreadSanitizerRuntime::Activate() {
process_sp->GetTarget()
.CreateBreakpoint(symbol_address, internal, hardware)
.get();
- breakpoint->SetCallback(ThreadSanitizerRuntime::NotifyBreakpointHit, this,
+ breakpoint->SetCallback(InstrumentationRuntimeTSan::NotifyBreakpointHit, this,
true);
breakpoint->SetBreakpointKind("thread-sanitizer-report");
SetBreakpointID(breakpoint->GetID());
@@ -924,7 +926,7 @@ void ThreadSanitizerRuntime::Activate() {
SetActive(true);
}
-void ThreadSanitizerRuntime::Deactivate() {
+void InstrumentationRuntimeTSan::Deactivate() {
if (GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
ProcessSP process_sp = GetProcessSP();
if (process_sp) {
@@ -977,8 +979,8 @@ static std::string GenerateThreadName(const std::string &path,
}
if (path == "locs") {
- std::string type =
- o->GetAsDictionary()->GetValueForKey("type")->GetStringValue();
+ std::string type = std::string(
+ o->GetAsDictionary()->GetValueForKey("type")->GetStringValue());
int thread_id =
o->GetObjectForDotSeparatedPath("thread_id")->GetIntegerValue();
int fd =
@@ -1043,7 +1045,7 @@ static void AddThreadsForPath(const std::string &path,
}
lldb::ThreadCollectionSP
-ThreadSanitizerRuntime::GetBacktracesFromExtendedStopInfo(
+InstrumentationRuntimeTSan::GetBacktracesFromExtendedStopInfo(
StructuredData::ObjectSP info) {
ThreadCollectionSP threads;
threads = std::make_shared<ThreadCollection>();
diff --git a/lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.h
index db8bb1db7996..35a878d90aff 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h
+++ b/lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.h
@@ -1,4 +1,4 @@
-//===-- TSanRuntime.h -------------------------------------------*- C++ -*-===//
+//===-- InstrumentationRuntimeTSan.h ----------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadSanitizerRuntime_h_
-#define liblldb_ThreadSanitizerRuntime_h_
+#ifndef LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_TSAN_INSTRUMENTATIONRUNTIMETSAN_H
+#define LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_TSAN_INSTRUMENTATIONRUNTIMETSAN_H
#include "lldb/Target/ABI.h"
#include "lldb/Target/InstrumentationRuntime.h"
@@ -16,9 +16,9 @@
namespace lldb_private {
-class ThreadSanitizerRuntime : public lldb_private::InstrumentationRuntime {
+class InstrumentationRuntimeTSan : public lldb_private::InstrumentationRuntime {
public:
- ~ThreadSanitizerRuntime() override;
+ ~InstrumentationRuntimeTSan() override;
static lldb::InstrumentationRuntimeSP
CreateInstance(const lldb::ProcessSP &process_sp);
@@ -43,7 +43,7 @@ public:
GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info) override;
private:
- ThreadSanitizerRuntime(const lldb::ProcessSP &process_sp)
+ InstrumentationRuntimeTSan(const lldb::ProcessSP &process_sp)
: lldb_private::InstrumentationRuntime(process_sp) {}
const RegularExpression &GetPatternForRuntimeLibrary() override;
@@ -78,4 +78,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ThreadSanitizerRuntime_h_
+#endif // LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_TSAN_INSTRUMENTATIONRUNTIMETSAN_H
diff --git a/lldb/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp b/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
index 137ecab224bc..b60eb53f3d4a 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp
+++ b/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
@@ -1,4 +1,4 @@
-//===-- UBSanRuntime.cpp ----------------------------------------*- C++ -*-===//
+//===-- InstrumentationRuntimeUBSan.cpp -----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "UBSanRuntime.h"
+#include "InstrumentationRuntimeUBSan.h"
#include "Plugins/Process/Utility/HistoryThread.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
@@ -36,35 +36,31 @@
using namespace lldb;
using namespace lldb_private;
-UndefinedBehaviorSanitizerRuntime::~UndefinedBehaviorSanitizerRuntime() {
- Deactivate();
-}
+LLDB_PLUGIN_DEFINE(InstrumentationRuntimeUBSan)
+
+InstrumentationRuntimeUBSan::~InstrumentationRuntimeUBSan() { Deactivate(); }
lldb::InstrumentationRuntimeSP
-UndefinedBehaviorSanitizerRuntime::CreateInstance(
- const lldb::ProcessSP &process_sp) {
- return InstrumentationRuntimeSP(
- new UndefinedBehaviorSanitizerRuntime(process_sp));
+InstrumentationRuntimeUBSan::CreateInstance(const lldb::ProcessSP &process_sp) {
+ return InstrumentationRuntimeSP(new InstrumentationRuntimeUBSan(process_sp));
}
-void UndefinedBehaviorSanitizerRuntime::Initialize() {
+void InstrumentationRuntimeUBSan::Initialize() {
PluginManager::RegisterPlugin(
GetPluginNameStatic(),
"UndefinedBehaviorSanitizer instrumentation runtime plugin.",
CreateInstance, GetTypeStatic);
}
-void UndefinedBehaviorSanitizerRuntime::Terminate() {
+void InstrumentationRuntimeUBSan::Terminate() {
PluginManager::UnregisterPlugin(CreateInstance);
}
-lldb_private::ConstString
-UndefinedBehaviorSanitizerRuntime::GetPluginNameStatic() {
+lldb_private::ConstString InstrumentationRuntimeUBSan::GetPluginNameStatic() {
return ConstString("UndefinedBehaviorSanitizer");
}
-lldb::InstrumentationRuntimeType
-UndefinedBehaviorSanitizerRuntime::GetTypeStatic() {
+lldb::InstrumentationRuntimeType InstrumentationRuntimeUBSan::GetTypeStatic() {
return eInstrumentationRuntimeTypeUndefinedBehaviorSanitizer;
}
@@ -110,7 +106,7 @@ static std::string RetrieveString(ValueObjectSP return_value_sp,
return str;
}
-StructuredData::ObjectSP UndefinedBehaviorSanitizerRuntime::RetrieveReportData(
+StructuredData::ObjectSP InstrumentationRuntimeUBSan::RetrieveReportData(
ExecutionContextRef exe_ctx_ref) {
ProcessSP process_sp = GetProcessSP();
if (!process_sp)
@@ -187,9 +183,10 @@ StructuredData::ObjectSP UndefinedBehaviorSanitizerRuntime::RetrieveReportData(
static std::string GetStopReasonDescription(StructuredData::ObjectSP report) {
llvm::StringRef stop_reason_description_ref;
- report->GetAsDictionary()->GetValueForKeyAsString("description",
- stop_reason_description_ref);
- std::string stop_reason_description = stop_reason_description_ref;
+ report->GetAsDictionary()->GetValueForKeyAsString(
+ "description", stop_reason_description_ref);
+ std::string stop_reason_description =
+ std::string(stop_reason_description_ref);
if (!stop_reason_description.size()) {
stop_reason_description = "Undefined behavior detected";
@@ -202,15 +199,15 @@ static std::string GetStopReasonDescription(StructuredData::ObjectSP report) {
return stop_reason_description;
}
-bool UndefinedBehaviorSanitizerRuntime::NotifyBreakpointHit(
+bool InstrumentationRuntimeUBSan::NotifyBreakpointHit(
void *baton, StoppointCallbackContext *context, user_id_t break_id,
user_id_t break_loc_id) {
assert(baton && "null baton");
if (!baton)
return false; ///< false => resume execution.
- UndefinedBehaviorSanitizerRuntime *const instance =
- static_cast<UndefinedBehaviorSanitizerRuntime *>(baton);
+ InstrumentationRuntimeUBSan *const instance =
+ static_cast<InstrumentationRuntimeUBSan *>(baton);
ProcessSP process_sp = instance->GetProcessSP();
ThreadSP thread_sp = context->exe_ctx_ref.GetThreadSP();
@@ -235,12 +232,12 @@ bool UndefinedBehaviorSanitizerRuntime::NotifyBreakpointHit(
}
const RegularExpression &
-UndefinedBehaviorSanitizerRuntime::GetPatternForRuntimeLibrary() {
+InstrumentationRuntimeUBSan::GetPatternForRuntimeLibrary() {
static RegularExpression regex(llvm::StringRef("libclang_rt\\.(a|t|ub)san_"));
return regex;
}
-bool UndefinedBehaviorSanitizerRuntime::CheckIfRuntimeIsValid(
+bool InstrumentationRuntimeUBSan::CheckIfRuntimeIsValid(
const lldb::ModuleSP module_sp) {
static ConstString ubsan_test_sym("__ubsan_on_report");
const Symbol *symbol = module_sp->FindFirstSymbolWithNameAndType(
@@ -249,7 +246,7 @@ bool UndefinedBehaviorSanitizerRuntime::CheckIfRuntimeIsValid(
}
// FIXME: Factor out all the logic we have in common with the {a,t}san plugins.
-void UndefinedBehaviorSanitizerRuntime::Activate() {
+void InstrumentationRuntimeUBSan::Activate() {
if (IsActive())
return;
@@ -280,15 +277,15 @@ void UndefinedBehaviorSanitizerRuntime::Activate() {
.CreateBreakpoint(symbol_address, /*internal=*/true,
/*hardware=*/false)
.get();
- breakpoint->SetCallback(
- UndefinedBehaviorSanitizerRuntime::NotifyBreakpointHit, this, true);
+ breakpoint->SetCallback(InstrumentationRuntimeUBSan::NotifyBreakpointHit,
+ this, true);
breakpoint->SetBreakpointKind("undefined-behavior-sanitizer-report");
SetBreakpointID(breakpoint->GetID());
SetActive(true);
}
-void UndefinedBehaviorSanitizerRuntime::Deactivate() {
+void InstrumentationRuntimeUBSan::Deactivate() {
SetActive(false);
auto BID = GetBreakpointID();
@@ -302,7 +299,7 @@ void UndefinedBehaviorSanitizerRuntime::Deactivate() {
}
lldb::ThreadCollectionSP
-UndefinedBehaviorSanitizerRuntime::GetBacktracesFromExtendedStopInfo(
+InstrumentationRuntimeUBSan::GetBacktracesFromExtendedStopInfo(
StructuredData::ObjectSP info) {
ThreadCollectionSP threads;
threads = std::make_shared<ThreadCollection>();
diff --git a/lldb/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h b/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.h
index 1d854b7bf06f..813c30069600 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h
+++ b/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.h
@@ -1,4 +1,4 @@
-//===-- UBSanRuntime.h ------------------------------------------*- C++ -*-===//
+//===-- InstrumentationRuntimeUBSan.h ---------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_UndefinedBehaviorSanitizerRuntime_h_
-#define liblldb_UndefinedBehaviorSanitizerRuntime_h_
+#ifndef LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_UBSAN_INSTRUMENTATIONRUNTIMEUBSAN_H
+#define LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_UBSAN_INSTRUMENTATIONRUNTIMEUBSAN_H
#include "lldb/Target/ABI.h"
#include "lldb/Target/InstrumentationRuntime.h"
@@ -16,10 +16,10 @@
namespace lldb_private {
-class UndefinedBehaviorSanitizerRuntime
+class InstrumentationRuntimeUBSan
: public lldb_private::InstrumentationRuntime {
public:
- ~UndefinedBehaviorSanitizerRuntime() override;
+ ~InstrumentationRuntimeUBSan() override;
static lldb::InstrumentationRuntimeSP
CreateInstance(const lldb::ProcessSP &process_sp);
@@ -44,7 +44,7 @@ public:
GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info) override;
private:
- UndefinedBehaviorSanitizerRuntime(const lldb::ProcessSP &process_sp)
+ InstrumentationRuntimeUBSan(const lldb::ProcessSP &process_sp)
: lldb_private::InstrumentationRuntime(process_sp) {}
const RegularExpression &GetPatternForRuntimeLibrary() override;
@@ -65,4 +65,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_UndefinedBehaviorSanitizerRuntime_h_
+#endif // LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_UBSAN_INSTRUMENTATIONRUNTIMEUBSAN_H
diff --git a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
index fff44123539f..cbeef600ba9b 100644
--- a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
+++ b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
@@ -1,4 +1,4 @@
-//===-- JITLoaderGDB.cpp ----------------------------------------*- C++ -*-===//
+//===-- JITLoaderGDB.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -32,6 +32,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(JITLoaderGDB)
+
// Debug Interface Structures
enum jit_actions_t { JIT_NOACTION = 0, JIT_REGISTER_FN, JIT_UNREGISTER_FN };
@@ -132,9 +134,9 @@ bool ReadJITEntry(const addr_t from_addr, Process *process,
DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
process->GetByteOrder(), sizeof(ptr_t));
lldb::offset_t offset = 0;
- entry->next_entry = extractor.GetPointer(&offset);
- entry->prev_entry = extractor.GetPointer(&offset);
- entry->symfile_addr = extractor.GetPointer(&offset);
+ entry->next_entry = extractor.GetAddress(&offset);
+ entry->prev_entry = extractor.GetAddress(&offset);
+ entry->symfile_addr = extractor.GetAddress(&offset);
offset = llvm::alignTo(offset, uint64_align_bytes);
entry->symfile_size = extractor.GetU64(&offset);
diff --git a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.h b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.h
index 2a2537c3edd4..42377f435293 100644
--- a/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.h
+++ b/lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_JITLoaderGDB_h_
-#define liblldb_JITLoaderGDB_h_
+#ifndef LLDB_SOURCE_PLUGINS_JITLOADER_GDB_JITLOADERGDB_H
+#define LLDB_SOURCE_PLUGINS_JITLOADER_GDB_JITLOADERGDB_H
#include <map>
@@ -77,4 +77,4 @@ private:
lldb::addr_t m_jit_descriptor_addr;
};
-#endif // liblldb_JITLoaderGDB_h_
+#endif // LLDB_SOURCE_PLUGINS_JITLOADER_GDB_JITLOADERGDB_H
diff --git a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
index 5cfd978774fd..42f6bd9ffb7b 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -1,4 +1,4 @@
-//===-- BlockPointer.cpp ----------------------------------------*- C++ -*-===//
+//===-- BlockPointer.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,14 +8,14 @@
#include "BlockPointer.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangASTImporter.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/Target.h"
-
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/Log.h"
@@ -45,18 +45,24 @@ public:
if (auto err = type_system_or_err.takeError()) {
LLDB_LOG_ERROR(
lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS),
- std::move(err), "Failed to get scratch ClangASTContext");
+ std::move(err), "Failed to get scratch TypeSystemClang");
return;
}
- ClangASTContext *clang_ast_context =
- llvm::dyn_cast<ClangASTContext>(&type_system_or_err.get());
+ TypeSystemClang *clang_ast_context =
+ llvm::dyn_cast<TypeSystemClang>(&type_system_or_err.get());
if (!clang_ast_context) {
return;
}
- ClangASTImporterSP clang_ast_importer = target_sp->GetClangASTImporter();
+ std::shared_ptr<ClangASTImporter> clang_ast_importer;
+ auto *state = target_sp->GetPersistentExpressionStateForLanguage(
+ lldb::eLanguageTypeC_plus_plus);
+ if (state) {
+ auto *persistent_vars = llvm::cast<ClangPersistentVariables>(state);
+ clang_ast_importer = persistent_vars->GetClangASTImporter();
+ }
if (!clang_ast_importer) {
return;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.h b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.h
index 624c17a6a6af..23f3f7b34b4f 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_BlockPointer_h_
-#define liblldb_BlockPointer_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_BLOCKPOINTER_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_BLOCKPOINTER_H
#include "lldb/lldb-forward.h"
@@ -22,4 +22,4 @@ BlockPointerSyntheticFrontEndCreator(CXXSyntheticChildren *,
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_BlockPointer_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_BLOCKPOINTER_H
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 4385a60f5862..08e43ae6b3e8 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1,4 +1,4 @@
-//===-- CPlusPlusLanguage.cpp -----------------------------------*- C++ -*-===//
+//===-- CPlusPlusLanguage.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -43,6 +43,8 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
+LLDB_PLUGIN_DEFINE(CPlusPlusLanguage)
+
void CPlusPlusLanguage::Initialize() {
PluginManager::RegisterPlugin(GetPluginNameStatic(), "C++ Language",
CreateInstance);
@@ -68,7 +70,9 @@ uint32_t CPlusPlusLanguage::GetPluginVersion() { return 1; }
// Static Functions
Language *CPlusPlusLanguage::CreateInstance(lldb::LanguageType language) {
- if (Language::LanguageIsCPlusPlus(language))
+ // Use plugin for C++ but not for Objective-C++ (which has its own plugin).
+ if (Language::LanguageIsCPlusPlus(language) &&
+ language != eLanguageTypeObjC_plus_plus)
return new CPlusPlusLanguage();
return nullptr;
}
@@ -125,7 +129,7 @@ static bool IsTrivialBasename(const llvm::StringRef &basename) {
return false; // Empty string or "~"
if (!std::isalpha(basename[idx]) && basename[idx] != '_')
- return false; // First charater (after removing the possible '~'') isn't in
+ return false; // First character (after removing the possible '~'') isn't in
// [A-Za-z_]
// Read all characters matching [A-Za-z_0-9]
@@ -230,7 +234,7 @@ std::string CPlusPlusLanguage::MethodName::GetScopeQualifiedName() {
if (!m_parsed)
Parse();
if (m_context.empty())
- return m_basename;
+ return std::string(m_basename);
std::string res;
res += m_context;
@@ -609,6 +613,15 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
"shared_ptr synthetic children",
ConstString("^(std::__[[:alnum:]]+::)shared_ptr<.+>(( )?&)?$"),
stl_synth_flags, true);
+
+ ConstString libcxx_std_unique_ptr_regex(
+ "^std::__[[:alnum:]]+::unique_ptr<.+>(( )?&)?$");
+ AddCXXSynthetic(
+ cpp_category_sp,
+ lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEndCreator,
+ "unique_ptr synthetic children", libcxx_std_unique_ptr_regex,
+ stl_synth_flags, true);
+
AddCXXSynthetic(
cpp_category_sp,
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator,
@@ -713,6 +726,10 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
"libc++ std::weak_ptr summary provider",
ConstString("^std::__[[:alnum:]]+::weak_ptr<.+>(( )?&)?$"),
stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibcxxUniquePointerSummaryProvider,
+ "libc++ std::unique_ptr summary provider",
+ libcxx_std_unique_ptr_regex, stl_summary_flags, true);
AddCXXSynthetic(
cpp_category_sp,
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
index 4ed45bc904ce..89dea08a2c53 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CPlusPlusLanguage_h_
-#define liblldb_CPlusPlusLanguage_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_CPLUSPLUSLANGUAGE_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_CPLUSPLUSLANGUAGE_H
#include <set>
#include <vector>
@@ -133,4 +133,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_CPlusPlusLanguage_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_CPLUSPLUSLANGUAGE_H
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
index 932db17b964a..eca36fff18f8 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
@@ -1,4 +1,4 @@
-//===-- CPlusPlusNameParser.cpp ---------------------------------*- C++ -*-===//
+//===-- CPlusPlusNameParser.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -329,6 +329,37 @@ bool CPlusPlusNameParser::ConsumeOperator() {
}
const auto &token = Peek();
+
+ // When clang generates debug info it adds template parameters to names.
+ // Since clang doesn't add a space between the name and the template parameter
+ // in some cases we are not generating valid C++ names e.g.:
+ //
+ // operator<<A::B>
+ //
+ // In some of these cases we will not parse them correctly. This fixes the
+ // issue by detecting this case and inserting tok::less in place of
+ // tok::lessless and returning successfully that we consumed the operator.
+ if (token.getKind() == tok::lessless) {
+ // Make sure we have more tokens before attempting to look ahead one more.
+ if (m_next_token_index + 1 < m_tokens.size()) {
+ // Look ahead two tokens.
+ clang::Token n_token = m_tokens[m_next_token_index + 1];
+ // If we find ( or < then this is indeed operator<< no need for fix.
+ if (n_token.getKind() != tok::l_paren && n_token.getKind() != tok::less) {
+ clang::Token tmp_tok;
+ tmp_tok.startToken();
+ tmp_tok.setLength(1);
+ tmp_tok.setLocation(token.getLocation().getLocWithOffset(1));
+ tmp_tok.setKind(tok::less);
+
+ m_tokens[m_next_token_index] = tmp_tok;
+
+ start_position.Remove();
+ return true;
+ }
+ }
+ }
+
switch (token.getKind()) {
case tok::kw_new:
case tok::kw_delete:
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
index 414c3a009157..6fe6b12725b0 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
@@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CPlusPlusNameParser_h_
-#define liblldb_CPlusPlusNameParser_h_
-
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_CPLUSPLUSNAMEPARSER_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_CPLUSPLUSNAMEPARSER_H
#include "clang/Lex/Lexer.h"
#include "llvm/ADT/Optional.h"
@@ -174,4 +173,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_CPlusPlusNameParser_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_CPLUSPLUSNAMEPARSER_H
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp b/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
index 3ea7589d8e4a..41bbd2b01a1e 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
@@ -1,4 +1,4 @@
-//===-- CxxStringTypes.cpp --------------------------------------*- C++ -*-===//
+//===-- CxxStringTypes.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,13 +10,13 @@
#include "llvm/Support/ConvertUTF.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.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/Time.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.h b/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.h
index 35498b3b568f..2713ded45929 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/CxxStringTypes.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CxxStringTypes_h_
-#define liblldb_CxxStringTypes_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_CXXSTRINGTYPES_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_CXXSTRINGTYPES_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -46,4 +46,4 @@ bool WCharSummaryProvider(ValueObject &valobj, Stream &stream,
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_CxxStringTypes_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_CXXSTRINGTYPES_H
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index ecadaef7a87e..84dd09a47d8a 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxx.cpp ----------------------------------------------*- C++ -*-===//
+//===-- LibCxx.cpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,7 +8,6 @@
#include "LibCxx.h"
-#include "llvm/ADT/ScopeExit.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/FormatEntity.h"
#include "lldb/Core/ValueObject.h"
@@ -17,7 +16,6 @@
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/DataFormatters/VectorIterator.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
@@ -27,6 +25,7 @@
#include "lldb/Utility/Stream.h"
#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
using namespace lldb;
using namespace lldb_private;
@@ -145,6 +144,43 @@ bool lldb_private::formatters::LibcxxSmartPointerSummaryProvider(
return true;
}
+bool lldb_private::formatters::LibcxxUniquePointerSummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+ ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
+ if (!valobj_sp)
+ return false;
+
+ ValueObjectSP ptr_sp(
+ valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true));
+ if (!ptr_sp)
+ return false;
+
+ ptr_sp = GetValueOfLibCXXCompressedPair(*ptr_sp);
+ if (!ptr_sp)
+ return false;
+
+ if (ptr_sp->GetValueAsUnsigned(0) == 0) {
+ stream.Printf("nullptr");
+ return true;
+ } else {
+ bool print_pointee = false;
+ Status error;
+ ValueObjectSP pointee_sp = ptr_sp->Dereference(error);
+ if (pointee_sp && error.Success()) {
+ if (pointee_sp->DumpPrintableRepresentation(
+ stream, ValueObject::eValueObjectRepresentationStyleSummary,
+ lldb::eFormatInvalid,
+ ValueObject::PrintableRepresentationSpecialCases::eDisable,
+ false))
+ print_pointee = true;
+ }
+ if (!print_pointee)
+ stream.Printf("ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
+ }
+
+ return true;
+}
+
/*
(lldb) fr var ibeg --raw --ptr-depth 1
(std::__1::__map_iterator<std::__1::__tree_iterator<std::__1::pair<int,
@@ -241,8 +277,8 @@ bool lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() {
auto addr(m_pair_ptr->GetValueAsUnsigned(LLDB_INVALID_ADDRESS));
m_pair_ptr = nullptr;
if (addr && addr != LLDB_INVALID_ADDRESS) {
- ClangASTContext *ast_ctx =
- llvm::dyn_cast_or_null<ClangASTContext>(pair_type.GetTypeSystem());
+ TypeSystemClang *ast_ctx =
+ llvm::dyn_cast_or_null<TypeSystemClang>(pair_type.GetTypeSystem());
if (!ast_ctx)
return false;
CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(
@@ -450,6 +486,67 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator(
: nullptr);
}
+lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
+ LibcxxUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
+ : SyntheticChildrenFrontEnd(*valobj_sp), m_compressed_pair_sp() {
+ if (valobj_sp)
+ Update();
+}
+
+lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
+ ~LibcxxUniquePtrSyntheticFrontEnd() = default;
+
+SyntheticChildrenFrontEnd *
+lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEndCreator(
+ CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
+ return (valobj_sp ? new LibcxxUniquePtrSyntheticFrontEnd(valobj_sp)
+ : nullptr);
+}
+
+size_t lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
+ CalculateNumChildren() {
+ return (m_compressed_pair_sp ? 1 : 0);
+}
+
+lldb::ValueObjectSP
+lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::GetChildAtIndex(
+ size_t idx) {
+ if (!m_compressed_pair_sp)
+ return lldb::ValueObjectSP();
+
+ if (idx != 0)
+ return lldb::ValueObjectSP();
+
+ return m_compressed_pair_sp;
+}
+
+bool lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::Update() {
+ ValueObjectSP valobj_sp = m_backend.GetSP();
+ if (!valobj_sp)
+ return false;
+
+ ValueObjectSP ptr_sp(
+ valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true));
+ if (!ptr_sp)
+ return false;
+
+ m_compressed_pair_sp = GetValueOfLibCXXCompressedPair(*ptr_sp);
+
+ return false;
+}
+
+bool lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
+ MightHaveChildren() {
+ return true;
+}
+
+size_t lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
+ GetIndexOfChildWithName(ConstString name) {
+ if (name == "__value_")
+ return 0;
+ return UINT32_MAX;
+}
+
bool lldb_private::formatters::LibcxxContainerSummaryProvider(
ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
if (valobj.IsPointerType()) {
@@ -469,22 +566,20 @@ enum LibcxxStringLayoutMode {
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) {
+/// Determine the size in bytes of \p valobj (a libc++ std::string object) and
+/// extract its data payload. Return the size + payload pair.
+static llvm::Optional<std::pair<uint64_t, ValueObjectSP>>
+ExtractLibcxxStringInfo(ValueObject &valobj) {
ValueObjectSP D(valobj.GetChildAtIndexPath({0, 0, 0, 0}));
if (!D)
- return false;
+ return {};
ValueObjectSP layout_decider(
D->GetChildAtIndexPath(llvm::ArrayRef<size_t>({0, 0})));
// this child should exist
if (!layout_decider)
- return false;
+ return {};
ConstString g_data_name("__data_");
ConstString g_size_name("__size_");
@@ -498,13 +593,13 @@ static bool ExtractLibcxxStringInfo(ValueObject &valobj,
if (layout == eLibcxxStringLayoutModeDSC) {
ValueObjectSP size_mode(D->GetChildAtIndexPath({1, 1, 0}));
if (!size_mode)
- return false;
+ return {};
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;
+ return {};
}
size_mode_value = (size_mode->GetValueAsUnsigned(0));
@@ -512,7 +607,7 @@ static bool ExtractLibcxxStringInfo(ValueObject &valobj,
} else {
ValueObjectSP size_mode(D->GetChildAtIndexPath({1, 0, 0}));
if (!size_mode)
- return false;
+ return {};
size_mode_value = (size_mode->GetValueAsUnsigned(0));
short_mode = ((size_mode_value & 1) == 0);
@@ -521,36 +616,58 @@ static bool ExtractLibcxxStringInfo(ValueObject &valobj,
if (short_mode) {
ValueObjectSP s(D->GetChildAtIndex(1, true));
if (!s)
- return false;
- location_sp = s->GetChildAtIndex(
+ return {};
+ ValueObjectSP 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;
+ const uint64_t size = (layout == eLibcxxStringLayoutModeDSC)
+ ? size_mode_value
+ : ((size_mode_value >> 1) % 256);
+
+ // When the small-string optimization takes place, the data must fit in the
+ // inline string buffer (23 bytes on x86_64/Darwin). If it doesn't, it's
+ // likely that the string isn't initialized and we're reading garbage.
+ ExecutionContext exe_ctx(location_sp->GetExecutionContextRef());
+ const llvm::Optional<uint64_t> max_bytes =
+ location_sp->GetCompilerType().GetByteSize(
+ exe_ctx.GetBestExecutionContextScope());
+ if (!max_bytes || size > *max_bytes || !location_sp)
+ return {};
+
+ return std::make_pair(size, location_sp);
}
+
+ ValueObjectSP l(D->GetChildAtIndex(0, true));
+ if (!l)
+ return {};
+ // we can use the layout_decider object as the data pointer
+ ValueObjectSP location_sp = (layout == eLibcxxStringLayoutModeDSC)
+ ? layout_decider
+ : l->GetChildAtIndex(2, true);
+ ValueObjectSP size_vo(l->GetChildAtIndex(1, true));
+ const unsigned capacity_index =
+ (layout == eLibcxxStringLayoutModeDSC) ? 2 : 0;
+ ValueObjectSP capacity_vo(l->GetChildAtIndex(capacity_index, true));
+ if (!size_vo || !location_sp || !capacity_vo)
+ return {};
+ const uint64_t size = size_vo->GetValueAsUnsigned(LLDB_INVALID_OFFSET);
+ const uint64_t capacity =
+ capacity_vo->GetValueAsUnsigned(LLDB_INVALID_OFFSET);
+ if (size == LLDB_INVALID_OFFSET || capacity == LLDB_INVALID_OFFSET ||
+ capacity < size)
+ return {};
+ return std::make_pair(size, location_sp);
}
bool lldb_private::formatters::LibcxxWStringSummaryProvider(
ValueObject &valobj, Stream &stream,
const TypeSummaryOptions &summary_options) {
- uint64_t size = 0;
- ValueObjectSP location_sp;
- if (!ExtractLibcxxStringInfo(valobj, location_sp, size))
+ auto string_info = ExtractLibcxxStringInfo(valobj);
+ if (!string_info)
return false;
+ uint64_t size;
+ ValueObjectSP location_sp;
+ std::tie(size, location_sp) = *string_info;
+
if (size == 0) {
stream.Printf("L\"\"");
return true;
@@ -558,10 +675,8 @@ bool lldb_private::formatters::LibcxxWStringSummaryProvider(
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) {
@@ -569,11 +684,15 @@ bool lldb_private::formatters::LibcxxWStringSummaryProvider(
options.SetIsTruncated(true);
}
}
- location_sp->GetPointeeData(extractor, 0, size);
+
+ DataExtractor extractor;
+ const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size);
+ if (bytes_read < size)
+ return false;
// std::wstring::size() is measured in 'characters', not bytes
- ClangASTContext *ast_context =
- ClangASTContext::GetScratch(*valobj.GetTargetSP());
+ TypeSystemClang *ast_context =
+ TypeSystemClang::GetScratch(*valobj.GetTargetSP());
if (!ast_context)
return false;
@@ -591,40 +710,35 @@ bool lldb_private::formatters::LibcxxWStringSummaryProvider(
switch (*wchar_t_size) {
case 1:
- StringPrinter::ReadBufferAndDumpToStream<
+ return StringPrinter::ReadBufferAndDumpToStream<
lldb_private::formatters::StringPrinter::StringElementType::UTF8>(
options);
break;
case 2:
- lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStream<
+ return StringPrinter::ReadBufferAndDumpToStream<
lldb_private::formatters::StringPrinter::StringElementType::UTF16>(
options);
break;
case 4:
- lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStream<
+ return StringPrinter::ReadBufferAndDumpToStream<
lldb_private::formatters::StringPrinter::StringElementType::UTF32>(
options);
- break;
-
- default:
- stream.Printf("size for wchar_t is not valid");
- return true;
}
-
- return true;
+ return false;
}
template <StringPrinter::StringElementType element_type>
bool LibcxxStringSummaryProvider(ValueObject &valobj, Stream &stream,
const TypeSummaryOptions &summary_options,
- std::string prefix_token = "") {
- uint64_t size = 0;
- ValueObjectSP location_sp;
-
- if (!ExtractLibcxxStringInfo(valobj, location_sp, size))
+ std::string prefix_token) {
+ auto string_info = ExtractLibcxxStringInfo(valobj);
+ if (!string_info)
return false;
+ uint64_t size;
+ ValueObjectSP location_sp;
+ std::tie(size, location_sp) = *string_info;
if (size == 0) {
stream.Printf("\"\"");
@@ -636,7 +750,6 @@ bool LibcxxStringSummaryProvider(ValueObject &valobj, Stream &stream,
StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
- DataExtractor extractor;
if (summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) {
const auto max_size = valobj.GetTargetSP()->GetMaximumSizeOfStringSummary();
if (size > max_size) {
@@ -644,41 +757,55 @@ bool LibcxxStringSummaryProvider(ValueObject &valobj, Stream &stream,
options.SetIsTruncated(true);
}
}
- location_sp->GetPointeeData(extractor, 0, size);
+
+ DataExtractor extractor;
+ const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size);
+ if (bytes_read < size)
+ return false;
options.SetData(extractor);
options.SetStream(&stream);
-
if (prefix_token.empty())
options.SetPrefixToken(nullptr);
else
options.SetPrefixToken(prefix_token);
-
options.SetQuote('"');
options.SetSourceSize(size);
options.SetBinaryZeroIsTerminator(false);
- StringPrinter::ReadBufferAndDumpToStream<element_type>(options);
+ return StringPrinter::ReadBufferAndDumpToStream<element_type>(options);
+}
+template <StringPrinter::StringElementType element_type>
+static bool formatStringImpl(ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &summary_options,
+ std::string prefix_token) {
+ StreamString scratch_stream;
+ const bool success = LibcxxStringSummaryProvider<element_type>(
+ valobj, scratch_stream, summary_options, prefix_token);
+ if (success)
+ stream << scratch_stream.GetData();
+ else
+ stream << "Summary Unavailable";
return true;
}
bool lldb_private::formatters::LibcxxStringSummaryProviderASCII(
ValueObject &valobj, Stream &stream,
const TypeSummaryOptions &summary_options) {
- return LibcxxStringSummaryProvider<StringPrinter::StringElementType::ASCII>(
- valobj, stream, summary_options);
+ return formatStringImpl<StringPrinter::StringElementType::ASCII>(
+ valobj, stream, summary_options, "");
}
bool lldb_private::formatters::LibcxxStringSummaryProviderUTF16(
ValueObject &valobj, Stream &stream,
const TypeSummaryOptions &summary_options) {
- return LibcxxStringSummaryProvider<StringPrinter::StringElementType::UTF16>(
+ return formatStringImpl<StringPrinter::StringElementType::UTF16>(
valobj, stream, summary_options, "u");
}
bool lldb_private::formatters::LibcxxStringSummaryProviderUTF32(
ValueObject &valobj, Stream &stream,
const TypeSummaryOptions &summary_options) {
- return LibcxxStringSummaryProvider<StringPrinter::StringElementType::UTF32>(
+ return formatStringImpl<StringPrinter::StringElementType::UTF32>(
valobj, stream, summary_options, "U");
}
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
index 214f5512e4a5..ea5a7c178178 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_LibCxx_h_
-#define liblldb_LibCxx_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXX_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXX_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -43,6 +43,10 @@ bool LibcxxSmartPointerSummaryProvider(
const TypeSummaryOptions
&options); // libc++ std::shared_ptr<> and std::weak_ptr<>
+// libc++ std::unique_ptr<>
+bool LibcxxUniquePointerSummaryProvider(ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options);
+
bool LibcxxFunctionSummaryProvider(
ValueObject &valobj, Stream &stream,
const TypeSummaryOptions &options); // libc++ std::function<>
@@ -107,6 +111,26 @@ private:
lldb::ByteOrder m_byte_order;
};
+class LibcxxUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+ LibcxxUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+ size_t CalculateNumChildren() override;
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+ bool Update() override;
+
+ bool MightHaveChildren() override;
+
+ size_t GetIndexOfChildWithName(ConstString name) override;
+
+ ~LibcxxUniquePtrSyntheticFrontEnd() override;
+
+private:
+ lldb::ValueObjectSP m_compressed_pair_sp;
+};
+
SyntheticChildrenFrontEnd *
LibcxxBitsetSyntheticFrontEndCreator(CXXSyntheticChildren *,
lldb::ValueObjectSP);
@@ -116,6 +140,10 @@ LibcxxSharedPtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
lldb::ValueObjectSP);
SyntheticChildrenFrontEnd *
+LibcxxUniquePtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP);
+
+SyntheticChildrenFrontEnd *
LibcxxStdVectorSyntheticFrontEndCreator(CXXSyntheticChildren *,
lldb::ValueObjectSP);
@@ -156,4 +184,4 @@ LibcxxVariantFrontEndCreator(CXXSyntheticChildren *,
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_LibCxx_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXX_H
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
index b4e7a1703e46..45d4322e93d7 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
@@ -1,5 +1,4 @@
-//===-- LibCxxAtomic.cpp ------------------------------------------*- C++
-//-*-===//
+//===-- LibCxxAtomic.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "LibCxxAtomic.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
using namespace lldb;
using namespace lldb_private;
@@ -101,8 +101,6 @@ public:
size_t GetIndexOfChildWithName(ConstString name) override;
- lldb::ValueObjectSP GetSyntheticValue() override;
-
private:
ValueObject *m_real_child;
};
@@ -128,26 +126,20 @@ bool lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
size_t lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
CalculateNumChildren() {
- return m_real_child ? m_real_child->GetNumChildren() : 0;
+ return m_real_child ? 1 : 0;
}
lldb::ValueObjectSP
lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::GetChildAtIndex(
size_t idx) {
- return m_real_child ? m_real_child->GetChildAtIndex(idx, true) : nullptr;
+ if (idx == 0)
+ return m_real_child->GetSP()->Clone(ConstString("Value"));
+ return nullptr;
}
size_t lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
GetIndexOfChildWithName(ConstString name) {
- return m_real_child ? m_real_child->GetIndexOfChildWithName(name)
- : UINT32_MAX;
-}
-
-lldb::ValueObjectSP lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
- GetSyntheticValue() {
- if (m_real_child && m_real_child->CanProvideValue())
- return m_real_child->GetSP();
- return nullptr;
+ return formatters::ExtractIndexFromString(name.GetCString());
}
SyntheticChildrenFrontEnd *
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h b/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h
index 8be833dd82f6..6fcceb645c7b 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_LibCxxAtomic_h_
-#define liblldb_LibCxxAtomic_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXXATOMIC_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXXATOMIC_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -30,4 +30,4 @@ LibcxxAtomicSyntheticFrontEndCreator(CXXSyntheticChildren *,
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_LibCxxAtomic_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXXATOMIC_H
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
index 78c453cd1b3c..6de4637a6a4a 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxBitset.cpp ----------------------------------------*- C++ -*-===//
+//===-- LibCxxBitset.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,8 @@
//===----------------------------------------------------------------------===//
#include "LibCxx.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Target.h"
using namespace lldb;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
index 79c7434f617f..65e88d114fcc 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxInitializerList.cpp -------------------------------*- C++ -*-===//
+//===-- LibCxxInitializerList.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
index f5281f2ce532..0d5ae16a0b29 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxList.cpp ------------------------------------------*- C++ -*-===//
+//===-- LibCxxList.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,10 +8,10 @@
#include "LibCxx.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Endian.h"
@@ -290,15 +290,6 @@ ValueObjectSP ForwardListFrontEnd::GetChildAtIndex(size_t idx) {
m_element_type);
}
-static ValueObjectSP GetValueOfCompressedPair(ValueObject &pair) {
- ValueObjectSP value = pair.GetChildMemberWithName(ConstString("__value_"), true);
- if (! value) {
- // pre-r300140 member name
- value = pair.GetChildMemberWithName(ConstString("__first_"), true);
- }
- return value;
-}
-
bool ForwardListFrontEnd::Update() {
AbstractListFrontEnd::Update();
@@ -311,7 +302,7 @@ bool ForwardListFrontEnd::Update() {
m_backend.GetChildMemberWithName(ConstString("__before_begin_"), true));
if (!impl_sp)
return false;
- impl_sp = GetValueOfCompressedPair(*impl_sp);
+ impl_sp = GetValueOfLibCXXCompressedPair(*impl_sp);
if (!impl_sp)
return false;
m_head = impl_sp->GetChildMemberWithName(ConstString("__next_"), true).get();
@@ -332,7 +323,7 @@ size_t ListFrontEnd::CalculateNumChildren() {
ValueObjectSP size_alloc(
m_backend.GetChildMemberWithName(ConstString("__size_alloc_"), true));
if (size_alloc) {
- ValueObjectSP value = GetValueOfCompressedPair(*size_alloc);
+ ValueObjectSP value = GetValueOfLibCXXCompressedPair(*size_alloc);
if (value) {
m_count = value->GetValueAsUnsigned(UINT32_MAX);
}
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
index f6d8d4d9a7eb..64a199e24e4a 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxMap.cpp -------------------------------------------*- C++ -*-===//
+//===-- LibCxxMap.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,10 +8,10 @@
#include "LibCxx.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Endian.h"
@@ -298,8 +298,8 @@ void lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetValueOffset(
UINT32_MAX) {
m_skip_size = bit_offset / 8u;
} else {
- ClangASTContext *ast_ctx =
- llvm::dyn_cast_or_null<ClangASTContext>(node_type.GetTypeSystem());
+ TypeSystemClang *ast_ctx =
+ llvm::dyn_cast_or_null<TypeSystemClang>(node_type.GetTypeSystem());
if (!ast_ctx)
return;
CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp
index b1ad171d0b0c..c0c819632851 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxOptional.cpp --------------------------------------*- C++ -*-===//
+//===-- LibCxxOptional.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -26,11 +26,12 @@ public:
bool MightHaveChildren() override { return true; }
bool Update() override;
- size_t CalculateNumChildren() override { return m_size; }
+ size_t CalculateNumChildren() override { return m_has_value ? 1U : 0U; }
ValueObjectSP GetChildAtIndex(size_t idx) override;
private:
- size_t m_size = 0;
+ /// True iff the option contains a value.
+ bool m_has_value = false;
};
} // namespace
@@ -44,13 +45,13 @@ bool OptionalFrontEnd::Update() {
// __engaged_ is a bool flag and is true if the optional contains a value.
// Converting it to unsigned gives us a size of 1 if it contains a value
// and 0 if not.
- m_size = engaged_sp->GetValueAsUnsigned(0);
+ m_has_value = engaged_sp->GetValueAsUnsigned(0) == 1;
return false;
}
ValueObjectSP OptionalFrontEnd::GetChildAtIndex(size_t idx) {
- if (idx >= m_size)
+ if (!m_has_value)
return ValueObjectSP();
// __val_ contains the underlying value of an optional if it has one.
@@ -71,7 +72,7 @@ ValueObjectSP OptionalFrontEnd::GetChildAtIndex(size_t idx) {
if (!holder_type)
return ValueObjectSP();
- return val_sp->Clone(ConstString(llvm::formatv("Value").str()));
+ return val_sp->Clone(ConstString("Value"));
}
SyntheticChildrenFrontEnd *
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
index 2f06d684f953..616ffdca107d 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxQueue.cpp -----------------------------------------*- C++ -*-===//
+//===-- LibCxxQueue.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
index 45294e25f0f5..a113fe98c6b6 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxTuple.cpp -----------------------------------------*- C++ -*-===//
+//===-- LibCxxTuple.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
index b2c38c915c81..3a441973fc73 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxUnorderedMap.cpp ----------------------------------*- C++ -*-===//
+//===-- LibCxxUnorderedMap.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,10 +8,10 @@
#include "LibCxx.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Endian.h"
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
index 62945bd3ce80..951bf2896fb0 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxVariant.cpp --------------------------------------*- C++ -*-===//
+//===-- LibCxxVariant.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -60,10 +60,10 @@ using namespace lldb_private;
namespace {
// libc++ std::variant index could have one of three states
-// 1) VALID, we can obtain it and its not variant_npos
-// 2) INVALID, we can't obtain it or it is not a type we expect
-// 3) NPOS, its value is variant_npos which means the variant has no value
-enum class LibcxxVariantIndexValidity { VALID, INVALID, NPOS };
+// 1) Valid, we can obtain it and its not variant_npos
+// 2) Invalid, we can't obtain it or it is not a type we expect
+// 3) NPos, its value is variant_npos which means the variant has no value
+enum class LibcxxVariantIndexValidity { Valid, Invalid, NPos };
LibcxxVariantIndexValidity
LibcxxVariantGetIndexValidity(ValueObjectSP &impl_sp) {
@@ -71,14 +71,14 @@ LibcxxVariantGetIndexValidity(ValueObjectSP &impl_sp) {
impl_sp->GetChildMemberWithName(ConstString("__index"), true));
if (!index_sp)
- return LibcxxVariantIndexValidity::INVALID;
+ return LibcxxVariantIndexValidity::Invalid;
int64_t index_value = index_sp->GetValueAsSigned(0);
if (index_value == -1)
- return LibcxxVariantIndexValidity::NPOS;
+ return LibcxxVariantIndexValidity::NPos;
- return LibcxxVariantIndexValidity::VALID;
+ return LibcxxVariantIndexValidity::Valid;
}
llvm::Optional<uint64_t> LibcxxVariantIndexValue(ValueObjectSP &impl_sp) {
@@ -129,10 +129,10 @@ bool LibcxxVariantSummaryProvider(ValueObject &valobj, Stream &stream,
LibcxxVariantIndexValidity validity = LibcxxVariantGetIndexValidity(impl_sp);
- if (validity == LibcxxVariantIndexValidity::INVALID)
+ if (validity == LibcxxVariantIndexValidity::Invalid)
return false;
- if (validity == LibcxxVariantIndexValidity::NPOS) {
+ if (validity == LibcxxVariantIndexValidity::NPos) {
stream.Printf(" No Value");
return true;
}
@@ -159,7 +159,7 @@ bool LibcxxVariantSummaryProvider(ValueObject &valobj, Stream &stream,
if (!template_type)
return false;
- stream.Printf(" Active Type = %s ", template_type.GetTypeName().GetCString());
+ stream << " Active Type = " << template_type.GetDisplayTypeName() << " ";
return true;
}
@@ -196,10 +196,10 @@ bool VariantFrontEnd::Update() {
LibcxxVariantIndexValidity validity = LibcxxVariantGetIndexValidity(impl_sp);
- if (validity == LibcxxVariantIndexValidity::INVALID)
+ if (validity == LibcxxVariantIndexValidity::Invalid)
return false;
- if (validity == LibcxxVariantIndexValidity::NPOS)
+ if (validity == LibcxxVariantIndexValidity::NPos)
return true;
m_size = 1;
@@ -242,7 +242,7 @@ ValueObjectSP VariantFrontEnd::GetChildAtIndex(size_t idx) {
if (!head_value)
return ValueObjectSP();
- return head_value->Clone(ConstString(ConstString("Value").AsCString()));
+ return head_value->Clone(ConstString("Value"));
}
SyntheticChildrenFrontEnd *
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.h b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.h
index 65db5aeaa99d..b4c27ccb9d77 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_LibCxxVariant_h_
-#define liblldb_LibCxxVariant_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXXVARIANT_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXXVARIANT_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -27,4 +27,4 @@ SyntheticChildrenFrontEnd *LibcxxVariantFrontEndCreator(CXXSyntheticChildren *,
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_LibCxxVariant_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBCXXVARIANT_H
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
index bcd7442bc669..43f76b0df810 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxVector.cpp ----------------------------------------*- C++ -*-===//
+//===-- LibCxxVector.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
index 0e0f6663c924..b4af67ecee0d 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
@@ -1,4 +1,4 @@
-//===-- LibStdcpp.cpp -------------------------------------------*- C++ -*-===//
+//===-- LibStdcpp.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,11 +8,11 @@
#include "LibStdcpp.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/DataFormatters/VectorIterator.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Endian.h"
@@ -259,6 +259,7 @@ bool lldb_private::formatters::LibStdcppStringSummaryProvider(
if (error.Fail())
return false;
options.SetSourceSize(size_of_data);
+ options.SetHasSourceSize(true);
if (!StringPrinter::ReadStringAndDumpToStream<
StringPrinter::StringElementType::UTF8>(options)) {
@@ -319,6 +320,7 @@ bool lldb_private::formatters::LibStdcppWStringSummaryProvider(
if (error.Fail())
return false;
options.SetSourceSize(size_of_data);
+ options.SetHasSourceSize(true);
options.SetPrefixToken("L");
switch (wchar_size) {
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h
index e7f88d667c14..9e41aa0ffc01 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_LibStdCpp_h_
-#define liblldb_LibStdCpp_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBSTDCPP_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBSTDCPP_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -56,4 +56,4 @@ LibStdcppUniquePtrSyntheticFrontEndCreator(CXXSyntheticChildren *,
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_LibStdCpp_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_LIBSTDCPP_H
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
index 0ac7b8f8e02b..7ba59ff9d1ad 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
@@ -1,4 +1,4 @@
-//===-- LibStdcppTuple.cpp --------------------------------------*- C++ -*-===//
+//===-- LibStdcppTuple.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
index cceb511cdc46..0b34b4e2fc89 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
@@ -1,4 +1,4 @@
-//===-- LibStdcppUniquePointer.cpp ------------------------------*- C++ -*-===//
+//===-- LibStdcppUniquePointer.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp b/lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp
index 248c51acea42..b24bcc1344e2 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp
@@ -1,4 +1,4 @@
-//===-- MSVCUndecoratedNameParser.cpp ---------------------------*- C++ -*-===//
+//===-- MSVCUndecoratedNameParser.cpp -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h b/lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h
index 6e20877cae1b..e5b60a0a1d5b 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_MSVCUndecoratedNameParser_h_
-#define liblldb_MSVCUndecoratedNameParser_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_MSVCUNDECORATEDNAMEPARSER_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_CPLUSPLUS_MSVCUNDECORATEDNAMEPARSER_H
#include <vector>
diff --git a/lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp b/lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp
index 3e77b1646739..aaf578c6f728 100644
--- a/lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp
+++ b/lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp
@@ -1,4 +1,4 @@
-//===-- ClangHighlighter.cpp ------------------------------------*- C++ -*-===//
+//===-- ClangHighlighter.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -13,6 +13,7 @@
#include "lldb/Utility/AnsiTerminal.h"
#include "lldb/Utility/StreamString.h"
+#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/Lexer.h"
#include "llvm/ADT/StringSet.h"
diff --git a/lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.h b/lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.h
index f459f9424697..5257c728ca5c 100644
--- a/lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.h
+++ b/lldb/source/Plugins/Language/ClangCommon/ClangHighlighter.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ClangHighlighter_h_
-#define liblldb_ClangHighlighter_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_CLANGCOMMON_CLANGHIGHLIGHTER_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_CLANGCOMMON_CLANGHIGHLIGHTER_H
#include "lldb/Utility/Stream.h"
#include "llvm/ADT/StringSet.h"
@@ -34,4 +34,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_ClangHighlighter_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_CLANGCOMMON_CLANGHIGHLIGHTER_H
diff --git a/lldb/source/Plugins/Language/ObjC/CF.cpp b/lldb/source/Plugins/Language/ObjC/CF.cpp
index 5bca260616ea..2610468b17fd 100644
--- a/lldb/source/Plugins/Language/ObjC/CF.cpp
+++ b/lldb/source/Plugins/Language/ObjC/CF.cpp
@@ -1,5 +1,4 @@
-//===-- CF.cpp ----------------------------------------------------*- C++
-//-*-===//
+//===-- CF.cpp ------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,10 +8,10 @@
#include "CF.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
@@ -30,7 +29,7 @@ using namespace lldb_private::formatters;
bool lldb_private::formatters::CFAbsoluteTimeSummaryProvider(
ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
time_t epoch = GetOSXEpoch();
- epoch = epoch + (time_t)valobj.GetValueAsUnsigned(0);
+ epoch = epoch + (time_t)valobj.GetValueAsSigned(0);
tm *tm_date = localtime(&epoch);
if (!tm_date)
return false;
diff --git a/lldb/source/Plugins/Language/ObjC/CF.h b/lldb/source/Plugins/Language/ObjC/CF.h
index 2abb56d407eb..6165e1c235bc 100644
--- a/lldb/source/Plugins/Language/ObjC/CF.h
+++ b/lldb/source/Plugins/Language/ObjC/CF.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CF_h_
-#define liblldb_CF_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_CF_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_CF_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -29,4 +29,4 @@ bool CFAbsoluteTimeSummaryProvider(ValueObject &valobj, Stream &stream,
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_CF_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_CF_H
diff --git a/lldb/source/Plugins/Language/ObjC/CFBasicHash.cpp b/lldb/source/Plugins/Language/ObjC/CFBasicHash.cpp
new file mode 100644
index 000000000000..42cda0146f2e
--- /dev/null
+++ b/lldb/source/Plugins/Language/ObjC/CFBasicHash.cpp
@@ -0,0 +1,114 @@
+#include "CFBasicHash.h"
+
+#include "lldb/Utility/Endian.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+bool CFBasicHash::IsValid() const {
+ if (m_address != LLDB_INVALID_ADDRESS) {
+ if (m_ptr_size == 4 && m_ht_32)
+ return true;
+ else if (m_ptr_size == 8 && m_ht_64)
+ return true;
+ else
+ return false;
+ }
+ return false;
+}
+
+bool CFBasicHash::Update(addr_t addr, ExecutionContextRef exe_ctx_rf) {
+ if (addr == LLDB_INVALID_ADDRESS || !addr)
+ return false;
+
+ m_address = addr;
+ m_exe_ctx_ref = exe_ctx_rf;
+ m_ptr_size =
+ m_exe_ctx_ref.GetTargetSP()->GetArchitecture().GetAddressByteSize();
+ m_byte_order = m_exe_ctx_ref.GetTargetSP()->GetArchitecture().GetByteOrder();
+
+ if (m_ptr_size == 4)
+ return UpdateFor(m_ht_32);
+ else if (m_ptr_size == 8)
+ return UpdateFor(m_ht_64);
+ return false;
+
+ llvm_unreachable(
+ "Unsupported architecture. Only 32bits and 64bits supported.");
+}
+
+template <typename T>
+bool CFBasicHash::UpdateFor(std::unique_ptr<__CFBasicHash<T>> &m_ht) {
+ if (m_byte_order != endian::InlHostByteOrder())
+ return false;
+
+ Status error;
+ Target *target = m_exe_ctx_ref.GetTargetSP().get();
+ addr_t addr = m_address.GetLoadAddress(target);
+ size_t size = sizeof(typename __CFBasicHash<T>::RuntimeBase) +
+ sizeof(typename __CFBasicHash<T>::Bits);
+
+ m_ht = std::make_unique<__CFBasicHash<T>>();
+ m_exe_ctx_ref.GetProcessSP()->ReadMemory(addr, m_ht.get(),
+ size, error);
+ if (error.Fail())
+ return false;
+
+ m_mutable = !(m_ht->base.cfinfoa & (1 << 6));
+ m_multi = m_ht->bits.counts_offset;
+ m_type = static_cast<HashType>(m_ht->bits.keys_offset);
+ addr_t ptr_offset = addr + size;
+ size_t ptr_count = GetPointerCount();
+ size = ptr_count * sizeof(T);
+
+ m_exe_ctx_ref.GetProcessSP()->ReadMemory(ptr_offset, m_ht->pointers, size,
+ error);
+
+ if (error.Fail()) {
+ m_ht = nullptr;
+ return false;
+ }
+
+ return true;
+}
+
+size_t CFBasicHash::GetCount() const {
+ if (!IsValid())
+ return 0;
+
+ if (!m_multi)
+ return (m_ptr_size == 4) ? m_ht_32->bits.used_buckets
+ : m_ht_64->bits.used_buckets;
+
+ // FIXME: Add support for multi
+ return 0;
+}
+
+size_t CFBasicHash::GetPointerCount() const {
+ if (!IsValid())
+ return 0;
+
+ if (m_multi)
+ return 3; // Bits::counts_offset;
+ return (m_type == HashType::dict) + 1;
+}
+
+addr_t CFBasicHash::GetKeyPointer() const {
+ if (!IsValid())
+ return LLDB_INVALID_ADDRESS;
+
+ if (m_ptr_size == 4)
+ return m_ht_32->pointers[m_ht_32->bits.keys_offset];
+
+ return m_ht_64->pointers[m_ht_64->bits.keys_offset];
+}
+
+addr_t CFBasicHash::GetValuePointer() const {
+ if (!IsValid())
+ return LLDB_INVALID_ADDRESS;
+
+ if (m_ptr_size == 4)
+ return m_ht_32->pointers[0];
+
+ return m_ht_64->pointers[0];
+}
diff --git a/lldb/source/Plugins/Language/ObjC/CFBasicHash.h b/lldb/source/Plugins/Language/ObjC/CFBasicHash.h
new file mode 100644
index 000000000000..fd30f5f7845f
--- /dev/null
+++ b/lldb/source/Plugins/Language/ObjC/CFBasicHash.h
@@ -0,0 +1,76 @@
+//===-- CFBasicHash.h -------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_CFBASICHASH_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_CFBASICHASH_H
+
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+
+namespace lldb_private {
+
+class CFBasicHash {
+public:
+ enum class HashType { set = 0, dict };
+
+ CFBasicHash() = default;
+ ~CFBasicHash() = default;
+
+ bool Update(lldb::addr_t addr, ExecutionContextRef exe_ctx_rf);
+
+ bool IsValid() const;
+
+ bool IsMutable() const { return m_mutable; };
+ bool IsMultiVariant() const { return m_multi; }
+ HashType GetType() const { return m_type; }
+
+ size_t GetCount() const;
+ lldb::addr_t GetKeyPointer() const;
+ lldb::addr_t GetValuePointer() const;
+
+private:
+ template <typename T> struct __CFBasicHash {
+ struct RuntimeBase {
+ T cfisa;
+ T cfinfoa;
+ } base;
+
+ struct Bits {
+ uint16_t __reserved0;
+ uint16_t __reserved1 : 2;
+ uint16_t keys_offset : 1;
+ uint16_t counts_offset : 2;
+ uint16_t counts_width : 2;
+ uint16_t __reserved2 : 9;
+ uint32_t used_buckets; // number of used buckets
+ uint64_t deleted : 16; // number of elements deleted
+ uint64_t num_buckets_idx : 8; // index to number of buckets
+ uint64_t __reserved3 : 40;
+ uint64_t __reserved4;
+ } bits;
+
+ T pointers[3];
+ };
+ template <typename T> bool UpdateFor(std::unique_ptr<__CFBasicHash<T>> &m_ht);
+
+ size_t GetPointerCount() const;
+
+ uint32_t m_ptr_size = UINT32_MAX;
+ lldb::ByteOrder m_byte_order = lldb::eByteOrderInvalid;
+ Address m_address = LLDB_INVALID_ADDRESS;
+ std::unique_ptr<__CFBasicHash<uint32_t>> m_ht_32 = nullptr;
+ std::unique_ptr<__CFBasicHash<uint64_t>> m_ht_64 = nullptr;
+ ExecutionContextRef m_exe_ctx_ref;
+ bool m_mutable = true;
+ bool m_multi = false;
+ HashType m_type;
+};
+
+} // namespace lldb_private
+
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_CFBASICHASH_H
diff --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
index 8a81abbaedbe..648fc4adf24f 100644
--- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -1,4 +1,4 @@
-//===-- Cocoa.cpp -----------------------------------------------*- C++ -*-===//
+//===-- Cocoa.cpp ---------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,6 +8,7 @@
#include "Cocoa.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Mangled.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
@@ -15,7 +16,6 @@
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/Host/Time.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/ProcessStructReader.h"
@@ -818,13 +818,14 @@ bool lldb_private::formatters::NSDateSummaryProvider(
static const ConstString g___NSDate("__NSDate");
static const ConstString g___NSTaggedDate("__NSTaggedDate");
static const ConstString g_NSCalendarDate("NSCalendarDate");
+ static const ConstString g_NSConstantDate("NSConstantDate");
if (class_name.IsEmpty())
return false;
uint64_t info_bits = 0, value_bits = 0;
if ((class_name == g_NSDate) || (class_name == g___NSDate) ||
- (class_name == g___NSTaggedDate)) {
+ (class_name == g___NSTaggedDate) || (class_name == g_NSConstantDate)) {
if (descriptor->GetTaggedPointerInfo(&info_bits, &value_bits)) {
date_value_bits = ((value_bits << 8) | (info_bits << 4));
memcpy(&date_value, &date_value_bits, sizeof(date_value_bits));
@@ -850,8 +851,14 @@ bool lldb_private::formatters::NSDateSummaryProvider(
} else
return false;
- if (date_value == -63114076800) {
- stream.Printf("0001-12-30 00:00:00 +0000");
+ // FIXME: It seems old dates are not formatted according to NSDate's calendar
+ // so we hardcode distantPast's value so that it looks like LLDB is doing
+ // the right thing.
+
+ // The relative time in seconds from Cocoa Epoch to [NSDate distantPast].
+ const double RelSecondsFromCocoaEpochToNSDateDistantPast = -63114076800;
+ if (date_value == RelSecondsFromCocoaEpochToNSDateDistantPast) {
+ stream.Printf("0001-01-01 00:00:00 UTC");
return true;
}
@@ -867,7 +874,7 @@ bool lldb_private::formatters::NSDateSummaryProvider(
// is generally true and POSIXly happy, but might break if a library vendor
// decides to get creative
time_t epoch = GetOSXEpoch();
- epoch = epoch + (time_t)date_value;
+ epoch = epoch + static_cast<time_t>(std::floor(date_value));
tm *tm_date = gmtime(&epoch);
if (!tm_date)
return false;
@@ -902,8 +909,7 @@ bool lldb_private::formatters::ObjCClassSummaryProvider(
if (class_name.IsEmpty())
return false;
- if (ConstString cs =
- Mangled(class_name).GetDemangledName(lldb::eLanguageTypeUnknown))
+ if (ConstString cs = Mangled(class_name).GetDemangledName())
class_name = cs;
stream.Printf("%s", class_name.AsCString("<unknown class>"));
diff --git a/lldb/source/Plugins/Language/ObjC/Cocoa.h b/lldb/source/Plugins/Language/ObjC/Cocoa.h
index 388e6f03aa0f..a195d622ce58 100644
--- a/lldb/source/Plugins/Language/ObjC/Cocoa.h
+++ b/lldb/source/Plugins/Language/ObjC/Cocoa.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Cocoa_h_
-#define liblldb_Cocoa_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_COCOA_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_COCOA_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -113,4 +113,4 @@ public:
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_Cocoa_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_COCOA_H
diff --git a/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp b/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp
index 247429da1b06..ac2f45b8354f 100644
--- a/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp
+++ b/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp
@@ -1,5 +1,4 @@
-//===-- CoreMedia.cpp --------------------------------------------*- C++
-//-*-===//
+//===-- CoreMedia.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Language/ObjC/CoreMedia.h b/lldb/source/Plugins/Language/ObjC/CoreMedia.h
index 79abb67b9d7e..7fd8560d20e1 100644
--- a/lldb/source/Plugins/Language/ObjC/CoreMedia.h
+++ b/lldb/source/Plugins/Language/ObjC/CoreMedia.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CoreMedia_h_
-#define liblldb_CoreMedia_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_COREMEDIA_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_COREMEDIA_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -22,4 +22,4 @@ bool CMTimeSummaryProvider(ValueObject &valobj, Stream &stream,
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_CF_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_COREMEDIA_H
diff --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
index 73335aff2fd7..8d648d8a0861 100644
--- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
@@ -1,4 +1,4 @@
-//===-- NSArray.cpp ---------------------------------------------*- C++ -*-===//
+//===-- NSArray.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,16 +7,17 @@
//===----------------------------------------------------------------------===//
#include "clang/AST/ASTContext.h"
+#include "clang/Basic/TargetInfo.h"
#include "Cocoa.h"
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Expression/FunctionCaller.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
@@ -97,42 +98,46 @@ private:
};
namespace Foundation1010 {
- struct DataDescriptor_32 {
- uint32_t _used;
- uint32_t _offset;
- uint32_t _size : 28;
- uint64_t _priv1 : 4;
- uint32_t _priv2;
- uint32_t _data;
- };
-
- struct DataDescriptor_64 {
- uint64_t _used;
- uint64_t _offset;
- uint64_t _size : 60;
- uint64_t _priv1 : 4;
- uint32_t _priv2;
- uint64_t _data;
- };
+ namespace {
+ struct DataDescriptor_32 {
+ uint32_t _used;
+ uint32_t _offset;
+ uint32_t _size : 28;
+ uint64_t _priv1 : 4;
+ uint32_t _priv2;
+ uint32_t _data;
+ };
+
+ struct DataDescriptor_64 {
+ uint64_t _used;
+ uint64_t _offset;
+ uint64_t _size : 60;
+ uint64_t _priv1 : 4;
+ uint32_t _priv2;
+ uint64_t _data;
+ };
+ }
using NSArrayMSyntheticFrontEnd =
GenericNSArrayMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>;
}
namespace Foundation1428 {
- struct DataDescriptor_32 {
- uint32_t _used;
- uint32_t _offset;
- uint32_t _size;
- uint32_t _data;
- };
-
- struct DataDescriptor_64 {
- uint64_t _used;
- uint64_t _offset;
- uint64_t _size;
- uint64_t _data;
- };
+ namespace {
+ struct DataDescriptor_32 {
+ uint32_t _used;
+ uint32_t _offset;
+ uint32_t _size;
+ uint32_t _data;
+ };
+
+ struct DataDescriptor_64 {
+ uint64_t _used;
+ uint64_t _offset;
+ uint64_t _size;
+ uint64_t _data;
+ };
+ }
using NSArrayMSyntheticFrontEnd =
GenericNSArrayMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>;
@@ -436,7 +441,7 @@ lldb_private::formatters::NSArrayMSyntheticFrontEndBase::NSArrayMSyntheticFrontE
: SyntheticChildrenFrontEnd(*valobj_sp), m_exe_ctx_ref(), m_ptr_size(8),
m_id_type() {
if (valobj_sp) {
- auto *clang_ast_context = ClangASTContext::GetScratch(
+ auto *clang_ast_context = TypeSystemClang::GetScratch(
*valobj_sp->GetExecutionContextRef().GetTargetSP());
if (clang_ast_context)
m_id_type = CompilerType(
@@ -528,7 +533,7 @@ lldb_private::formatters::NSArrayMSyntheticFrontEndBase::GetIndexOfChildWithName
template <typename D32, typename D64>
lldb_private::formatters::
GenericNSArrayMSyntheticFrontEnd<D32, D64>::
- ~GenericNSArrayMSyntheticFrontEnd() {
+ ~GenericNSArrayMSyntheticFrontEnd<D32, D64>() {
delete m_data_32;
m_data_32 = nullptr;
delete m_data_64;
@@ -584,7 +589,7 @@ lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
if (valobj_sp) {
CompilerType type = valobj_sp->GetCompilerType();
if (type) {
- auto *clang_ast_context = ClangASTContext::GetScratch(
+ auto *clang_ast_context = TypeSystemClang::GetScratch(
*valobj_sp->GetExecutionContextRef().GetTargetSP());
if (clang_ast_context)
m_id_type = clang_ast_context->GetType(
@@ -595,7 +600,7 @@ lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
template <typename D32, typename D64, bool Inline>
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
- ~GenericNSArrayISyntheticFrontEnd() {
+ ~GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>() {
delete m_data_32;
m_data_32 = nullptr;
delete m_data_64;
@@ -753,7 +758,7 @@ lldb_private::formatters::NSArray1SyntheticFrontEnd::GetChildAtIndex(
if (idx == 0) {
auto *clang_ast_context =
- ClangASTContext::GetScratch(*m_backend.GetTargetSP());
+ TypeSystemClang::GetScratch(*m_backend.GetTargetSP());
if (clang_ast_context) {
CompilerType id_type(
clang_ast_context->GetBasicType(lldb::eBasicTypeObjCID));
diff --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
index ae00674c49f3..3dc07678f92f 100644
--- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
@@ -1,4 +1,4 @@
-//===-- NSDictionary.cpp ----------------------------------------*- C++ -*-===//
+//===-- NSDictionary.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,14 +10,15 @@
#include "clang/AST/DeclCXX.h"
+#include "CFBasicHash.h"
#include "NSDictionary.h"
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
@@ -65,7 +66,7 @@ NSDictionary_Additionals::GetAdditionalSynthetics() {
static CompilerType GetLLDBNSPairType(TargetSP target_sp) {
CompilerType compiler_type;
- ClangASTContext *target_ast_context = ClangASTContext::GetScratch(*target_sp);
+ TypeSystemClang *target_ast_context = TypeSystemClang::GetScratch(*target_sp);
if (target_ast_context) {
ConstString g___lldb_autogen_nspair("__lldb_autogen_nspair");
@@ -76,18 +77,19 @@ static CompilerType GetLLDBNSPairType(TargetSP target_sp) {
if (!compiler_type) {
compiler_type = target_ast_context->CreateRecordType(
- nullptr, lldb::eAccessPublic, g___lldb_autogen_nspair.GetCString(),
- clang::TTK_Struct, lldb::eLanguageTypeC);
+ nullptr, OptionalClangModuleID(), lldb::eAccessPublic,
+ g___lldb_autogen_nspair.GetCString(), clang::TTK_Struct,
+ lldb::eLanguageTypeC);
if (compiler_type) {
- ClangASTContext::StartTagDeclarationDefinition(compiler_type);
+ TypeSystemClang::StartTagDeclarationDefinition(compiler_type);
CompilerType id_compiler_type =
target_ast_context->GetBasicType(eBasicTypeObjCID);
- ClangASTContext::AddFieldToRecordType(
+ TypeSystemClang::AddFieldToRecordType(
compiler_type, "key", id_compiler_type, lldb::eAccessPublic, 0);
- ClangASTContext::AddFieldToRecordType(
+ TypeSystemClang::AddFieldToRecordType(
compiler_type, "value", id_compiler_type, lldb::eAccessPublic, 0);
- ClangASTContext::CompleteTagDeclarationDefinition(compiler_type);
+ TypeSystemClang::CompleteTagDeclarationDefinition(compiler_type);
}
}
}
@@ -139,6 +141,37 @@ private:
std::vector<DictionaryItemDescriptor> m_children;
};
+class NSCFDictionarySyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+ NSCFDictionarySyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+ size_t CalculateNumChildren() override;
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+ bool Update() override;
+
+ bool MightHaveChildren() override;
+
+ size_t GetIndexOfChildWithName(ConstString name) override;
+
+private:
+ struct DictionaryItemDescriptor {
+ lldb::addr_t key_ptr;
+ lldb::addr_t val_ptr;
+ lldb::ValueObjectSP valobj_sp;
+ };
+
+ ExecutionContextRef m_exe_ctx_ref;
+ uint8_t m_ptr_size;
+ lldb::ByteOrder m_order;
+
+ CFBasicHash m_hashtable;
+
+ CompilerType m_pair_type;
+ std::vector<DictionaryItemDescriptor> m_children;
+};
+
class NSDictionary1SyntheticFrontEnd : public SyntheticChildrenFrontEnd {
public:
NSDictionary1SyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
@@ -245,64 +278,67 @@ namespace Foundation1100 {
}
namespace Foundation1428 {
- struct DataDescriptor_32 {
- uint32_t _used : 26;
- uint32_t _kvo : 1;
- uint32_t _size;
- uint32_t _buffer;
- uint64_t GetSize() { return _size; }
- };
-
- struct DataDescriptor_64 {
- uint64_t _used : 58;
- uint32_t _kvo : 1;
- uint64_t _size;
- uint64_t _buffer;
- uint64_t GetSize() { return _size; }
- };
-
-
-
+ namespace {
+ struct DataDescriptor_32 {
+ uint32_t _used : 26;
+ uint32_t _kvo : 1;
+ uint32_t _size;
+ uint32_t _buffer;
+ uint64_t GetSize() { return _size; }
+ };
+
+ struct DataDescriptor_64 {
+ uint64_t _used : 58;
+ uint32_t _kvo : 1;
+ uint64_t _size;
+ uint64_t _buffer;
+ uint64_t GetSize() { return _size; }
+ };
+ }
+
using NSDictionaryMSyntheticFrontEnd =
GenericNSDictionaryMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>;
}
namespace Foundation1437 {
- static const uint64_t NSDictionaryCapacities[] = {
- 0, 3, 7, 13, 23, 41, 71, 127, 191, 251, 383, 631, 1087, 1723,
- 2803, 4523, 7351, 11959, 19447, 31231, 50683, 81919, 132607,
- 214519, 346607, 561109, 907759, 1468927, 2376191, 3845119,
- 6221311, 10066421, 16287743, 26354171, 42641881, 68996069,
- 111638519, 180634607, 292272623, 472907251
- };
-
- static const size_t NSDictionaryNumSizeBuckets = sizeof(NSDictionaryCapacities) / sizeof(uint64_t);
-
- struct DataDescriptor_32 {
- uint32_t _buffer;
- uint32_t _muts;
- uint32_t _used : 25;
- uint32_t _kvo : 1;
- uint32_t _szidx : 6;
+ namespace {
+ static const uint64_t NSDictionaryCapacities[] = {
+ 0, 3, 7, 13, 23, 41, 71, 127, 191, 251, 383, 631, 1087, 1723,
+ 2803, 4523, 7351, 11959, 19447, 31231, 50683, 81919, 132607,
+ 214519, 346607, 561109, 907759, 1468927, 2376191, 3845119,
+ 6221311, 10066421, 16287743, 26354171, 42641881, 68996069,
+ 111638519, 180634607, 292272623, 472907251
+ };
+
+ static const size_t NSDictionaryNumSizeBuckets =
+ sizeof(NSDictionaryCapacities) / sizeof(uint64_t);
+
+ struct DataDescriptor_32 {
+ uint32_t _buffer;
+ uint32_t _muts;
+ uint32_t _used : 25;
+ uint32_t _kvo : 1;
+ uint32_t _szidx : 6;
- uint64_t GetSize() {
- return (_szidx) >= NSDictionaryNumSizeBuckets ?
- 0 : NSDictionaryCapacities[_szidx];
- }
- };
-
- struct DataDescriptor_64 {
- uint64_t _buffer;
- uint32_t _muts;
- uint32_t _used : 25;
- uint32_t _kvo : 1;
- uint32_t _szidx : 6;
+ uint64_t GetSize() {
+ return (_szidx) >= NSDictionaryNumSizeBuckets ?
+ 0 : NSDictionaryCapacities[_szidx];
+ }
+ };
+
+ struct DataDescriptor_64 {
+ uint64_t _buffer;
+ uint32_t _muts;
+ uint32_t _used : 25;
+ uint32_t _kvo : 1;
+ uint32_t _szidx : 6;
- uint64_t GetSize() {
- return (_szidx) >= NSDictionaryNumSizeBuckets ?
- 0 : NSDictionaryCapacities[_szidx];
- }
- };
+ uint64_t GetSize() {
+ return (_szidx) >= NSDictionaryNumSizeBuckets ?
+ 0 : NSDictionaryCapacities[_szidx];
+ }
+ };
+ }
using NSDictionaryMSyntheticFrontEnd =
GenericNSDictionaryMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>;
@@ -375,7 +411,9 @@ bool lldb_private::formatters::NSDictionarySummaryProvider(
static const ConstString g_DictionaryMImmutable("__NSDictionaryM_Immutable");
static const ConstString g_Dictionary1("__NSSingleEntryDictionaryI");
static const ConstString g_Dictionary0("__NSDictionary0");
- static const ConstString g_DictionaryCF("__NSCFDictionary");
+ static const ConstString g_DictionaryCF("__CFDictionary");
+ static const ConstString g_DictionaryNSCF("__NSCFDictionary");
+ static const ConstString g_DictionaryCFRef("CFDictionaryRef");
if (class_name.IsEmpty())
return false;
@@ -386,9 +424,9 @@ bool lldb_private::formatters::NSDictionarySummaryProvider(
ptr_size, 0, error);
if (error.Fail())
return false;
+
value &= (is_64bit ? ~0xFC00000000000000UL : ~0xFC000000U);
- } else if (class_name == g_DictionaryM || class_name == g_DictionaryMLegacy ||
- class_name == g_DictionaryCF) {
+ } else if (class_name == g_DictionaryM || class_name == g_DictionaryMLegacy) {
AppleObjCRuntime *apple_runtime =
llvm::dyn_cast_or_null<AppleObjCRuntime>(runtime);
Status error;
@@ -406,8 +444,15 @@ bool lldb_private::formatters::NSDictionarySummaryProvider(
value = 1;
} else if (class_name == g_Dictionary0) {
value = 0;
- }
- else {
+ } else if (class_name == g_DictionaryCF ||
+ class_name == g_DictionaryNSCF ||
+ class_name == g_DictionaryCFRef) {
+ ExecutionContext exe_ctx(process_sp);
+ CFBasicHash cfbh;
+ if (!cfbh.Update(valobj_addr, exe_ctx))
+ return false;
+ value = cfbh.GetCount();
+ } else {
auto &map(NSDictionary_Additionals::GetAdditionalSummaries());
for (auto &candidate : map) {
if (candidate.first && candidate.first->Match(class_name))
@@ -465,6 +510,9 @@ lldb_private::formatters::NSDictionarySyntheticFrontEndCreator(
static const ConstString g_DictionaryImmutable("__NSDictionaryM_Immutable");
static const ConstString g_DictionaryMLegacy("__NSDictionaryM_Legacy");
static const ConstString g_Dictionary0("__NSDictionary0");
+ static const ConstString g_DictionaryCF("__CFDictionary");
+ static const ConstString g_DictionaryNSCF("__NSCFDictionary");
+ static const ConstString g_DictionaryCFRef("CFDictionaryRef");
if (class_name.IsEmpty())
return nullptr;
@@ -483,6 +531,10 @@ lldb_private::formatters::NSDictionarySyntheticFrontEndCreator(
return (new Foundation1100::NSDictionaryMSyntheticFrontEnd(valobj_sp));
} else if (class_name == g_Dictionary1) {
return (new NSDictionary1SyntheticFrontEnd(valobj_sp));
+ } else if (class_name == g_DictionaryCF ||
+ class_name == g_DictionaryNSCF ||
+ class_name == g_DictionaryCFRef) {
+ return (new NSCFDictionarySyntheticFrontEnd(valobj_sp));
} else {
auto &map(NSDictionary_Additionals::GetAdditionalSynthetics());
for (auto &candidate : map) {
@@ -640,6 +692,140 @@ lldb_private::formatters::NSDictionaryISyntheticFrontEnd::GetChildAtIndex(
return dict_item.valobj_sp;
}
+lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::
+ NSCFDictionarySyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
+ : SyntheticChildrenFrontEnd(*valobj_sp), m_exe_ctx_ref(), m_ptr_size(8),
+ m_order(lldb::eByteOrderInvalid), m_hashtable(), m_pair_type() {}
+
+size_t lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::
+ GetIndexOfChildWithName(ConstString name) {
+ const char *item_name = name.GetCString();
+ const uint32_t idx = ExtractIndexFromString(item_name);
+ if (idx < UINT32_MAX && idx >= CalculateNumChildren())
+ return UINT32_MAX;
+ return idx;
+}
+
+size_t lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::
+ CalculateNumChildren() {
+ if (!m_hashtable.IsValid())
+ return 0;
+ return m_hashtable.GetCount();
+}
+
+bool lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::Update() {
+ m_children.clear();
+ ValueObjectSP valobj_sp = m_backend.GetSP();
+ m_ptr_size = 0;
+ if (!valobj_sp)
+ return false;
+ m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
+
+ lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
+ if (!process_sp)
+ return false;
+ m_ptr_size = process_sp->GetAddressByteSize();
+ m_order = process_sp->GetByteOrder();
+ return m_hashtable.Update(valobj_sp->GetValueAsUnsigned(0), m_exe_ctx_ref);
+}
+
+bool lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::
+ MightHaveChildren() {
+ return true;
+}
+
+lldb::ValueObjectSP
+lldb_private::formatters::NSCFDictionarySyntheticFrontEnd::GetChildAtIndex(
+ size_t idx) {
+ lldb::addr_t m_keys_ptr = m_hashtable.GetKeyPointer();
+ lldb::addr_t m_values_ptr = m_hashtable.GetValuePointer();
+
+ const uint32_t num_children = CalculateNumChildren();
+
+ if (idx >= num_children)
+ return lldb::ValueObjectSP();
+
+ if (m_children.empty()) {
+ ProcessSP process_sp = m_exe_ctx_ref.GetProcessSP();
+ if (!process_sp)
+ return lldb::ValueObjectSP();
+
+ Status error;
+ lldb::addr_t key_at_idx = 0, val_at_idx = 0;
+
+ uint32_t tries = 0;
+ uint32_t test_idx = 0;
+
+ // Iterate over inferior memory, reading key/value pointers by shifting each
+ // cursor by test_index * m_ptr_size. Returns an empty ValueObject if a read
+ // fails, otherwise, continue until the number of tries matches the number
+ // of childen.
+ while (tries < num_children) {
+ key_at_idx = m_keys_ptr + (test_idx * m_ptr_size);
+ val_at_idx = m_values_ptr + (test_idx * m_ptr_size);
+
+ key_at_idx = process_sp->ReadPointerFromMemory(key_at_idx, error);
+ if (error.Fail())
+ return lldb::ValueObjectSP();
+ val_at_idx = process_sp->ReadPointerFromMemory(val_at_idx, error);
+ if (error.Fail())
+ return lldb::ValueObjectSP();
+
+ test_idx++;
+
+ if (!key_at_idx || !val_at_idx)
+ continue;
+ tries++;
+
+ DictionaryItemDescriptor descriptor = {key_at_idx, val_at_idx,
+ lldb::ValueObjectSP()};
+
+ m_children.push_back(descriptor);
+ }
+ }
+
+ if (idx >= m_children.size()) // should never happen
+ return lldb::ValueObjectSP();
+
+ DictionaryItemDescriptor &dict_item = m_children[idx];
+ if (!dict_item.valobj_sp) {
+ if (!m_pair_type.IsValid()) {
+ TargetSP target_sp(m_backend.GetTargetSP());
+ if (!target_sp)
+ return ValueObjectSP();
+ m_pair_type = GetLLDBNSPairType(target_sp);
+ }
+ if (!m_pair_type.IsValid())
+ return ValueObjectSP();
+
+ DataBufferSP buffer_sp(new DataBufferHeap(2 * m_ptr_size, 0));
+
+ switch (m_ptr_size) {
+ case 0: // architecture has no clue - fail
+ return lldb::ValueObjectSP();
+ case 4: {
+ uint32_t *data_ptr = reinterpret_cast<uint32_t *>(buffer_sp->GetBytes());
+ *data_ptr = dict_item.key_ptr;
+ *(data_ptr + 1) = dict_item.val_ptr;
+ } break;
+ case 8: {
+ uint64_t *data_ptr = reinterpret_cast<uint64_t *>(buffer_sp->GetBytes());
+ *data_ptr = dict_item.key_ptr;
+ *(data_ptr + 1) = dict_item.val_ptr;
+ } break;
+ default:
+ lldbassert(false && "pointer size is not 4 nor 8");
+ }
+
+ StreamString idx_name;
+ idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
+ DataExtractor data(buffer_sp, m_order, m_ptr_size);
+ dict_item.valobj_sp = CreateValueObjectFromData(idx_name.GetString(), data,
+ m_exe_ctx_ref, m_pair_type);
+ }
+ return dict_item.valobj_sp;
+}
+
lldb_private::formatters::NSDictionary1SyntheticFrontEnd::
NSDictionary1SyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
: SyntheticChildrenFrontEnd(*valobj_sp.get()), m_pair(nullptr) {}
@@ -724,7 +910,7 @@ lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::
template <typename D32, typename D64>
lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::
- ~GenericNSDictionaryMSyntheticFrontEnd() {
+ ~GenericNSDictionaryMSyntheticFrontEnd<D32,D64>() {
delete m_data_32;
m_data_32 = nullptr;
delete m_data_64;
@@ -732,8 +918,8 @@ lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::
}
template <typename D32, typename D64>
-size_t
-lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>:: GetIndexOfChildWithName(ConstString name) {
+size_t lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<
+ D32, D64>::GetIndexOfChildWithName(ConstString name) {
const char *item_name = name.GetCString();
uint32_t idx = ExtractIndexFromString(item_name);
if (idx < UINT32_MAX && idx >= CalculateNumChildren())
@@ -782,7 +968,7 @@ lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::
}
if (error.Fail())
return false;
- return false;
+ return true;
}
template <typename D32, typename D64>
@@ -794,9 +980,8 @@ lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::
template <typename D32, typename D64>
lldb::ValueObjectSP
-lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::
- GetChildAtIndex(
- size_t idx) {
+lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<
+ D32, D64>::GetChildAtIndex(size_t idx) {
lldb::addr_t m_keys_ptr;
lldb::addr_t m_values_ptr;
if (m_data_32) {
@@ -884,7 +1069,6 @@ lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::
return dict_item.valobj_sp;
}
-
lldb_private::formatters::Foundation1100::
NSDictionaryMSyntheticFrontEnd::
NSDictionaryMSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
diff --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.h b/lldb/source/Plugins/Language/ObjC/NSDictionary.h
index 44d56f9c2c68..57dacd6759d2 100644
--- a/lldb/source/Plugins/Language/ObjC/NSDictionary.h
+++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.h
@@ -1,5 +1,4 @@
-//===-- NSDictionary.h ---------------------------------------------------*- C++
-//-*-===//
+//===-- NSDictionary.h ------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_NSDictionary_h_
-#define liblldb_NSDictionary_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_NSDICTIONARY_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_NSDICTIONARY_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -91,4 +90,4 @@ public:
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_NSDictionary_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_NSDICTIONARY_H
diff --git a/lldb/source/Plugins/Language/ObjC/NSError.cpp b/lldb/source/Plugins/Language/ObjC/NSError.cpp
index 94a97c8ad039..aa1103cb342c 100644
--- a/lldb/source/Plugins/Language/ObjC/NSError.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSError.cpp
@@ -1,4 +1,4 @@
-//===-- NSError.cpp ---------------------------------------------*- C++ -*-===//
+//===-- NSError.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,10 +10,10 @@
#include "Cocoa.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
@@ -87,7 +87,7 @@ bool lldb_private::formatters::NSError_SummaryProvider(
ValueObjectSP domain_str_sp = ValueObject::CreateValueObjectFromData(
"domain_str", isw.GetAsData(process_sp->GetByteOrder()),
valobj.GetExecutionContextRef(),
- ClangASTContext::GetScratch(process_sp->GetTarget())
+ TypeSystemClang::GetScratch(process_sp->GetTarget())
->GetBasicType(lldb::eBasicTypeVoid)
.GetPointerType());
@@ -156,7 +156,7 @@ public:
m_child_sp = CreateValueObjectFromData(
"_userInfo", isw.GetAsData(process_sp->GetByteOrder()),
m_backend.GetExecutionContextRef(),
- ClangASTContext::GetScratch(process_sp->GetTarget())
+ TypeSystemClang::GetScratch(process_sp->GetTarget())
->GetBasicType(lldb::eBasicTypeObjCID));
return false;
}
diff --git a/lldb/source/Plugins/Language/ObjC/NSException.cpp b/lldb/source/Plugins/Language/ObjC/NSException.cpp
index 9150787361c5..c6bae5e1c008 100644
--- a/lldb/source/Plugins/Language/ObjC/NSException.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSException.cpp
@@ -1,4 +1,4 @@
-//===-- NSException.cpp -----------------------------------------*- C++ -*-===//
+//===-- NSException.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -13,7 +13,6 @@
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
@@ -23,6 +22,7 @@
#include "Plugins/Language/ObjC/NSString.h"
#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
using namespace lldb;
using namespace lldb_private;
@@ -69,7 +69,7 @@ static bool ExtractFields(ValueObject &valobj, ValueObjectSP *name_sp,
InferiorSizedWord userinfo_isw(userinfo, *process_sp);
InferiorSizedWord reserved_isw(reserved, *process_sp);
- auto *clang_ast_context = ClangASTContext::GetScratch(process_sp->GetTarget());
+ auto *clang_ast_context = TypeSystemClang::GetScratch(process_sp->GetTarget());
if (!clang_ast_context)
return false;
diff --git a/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp b/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp
index 587dd13870a0..d962f39611b6 100644
--- a/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp
@@ -1,4 +1,4 @@
-//===-- NSIndexPath.cpp -----------------------------------------*- C++ -*-===//
+//===-- NSIndexPath.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,11 +8,11 @@
#include "Cocoa.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.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/Process.h"
#include "lldb/Target/Target.h"
@@ -53,7 +53,7 @@ public:
if (!type_system)
return false;
- ClangASTContext *ast = ClangASTContext::GetScratch(
+ TypeSystemClang *ast = TypeSystemClang::GetScratch(
*m_backend.GetExecutionContextRef().GetTargetSP());
if (!ast)
return false;
diff --git a/lldb/source/Plugins/Language/ObjC/NSSet.cpp b/lldb/source/Plugins/Language/ObjC/NSSet.cpp
index ebaa990fb74b..4dbbe6fbddff 100644
--- a/lldb/source/Plugins/Language/ObjC/NSSet.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSSet.cpp
@@ -1,4 +1,4 @@
-//===-- NSSet.cpp -----------------------------------------------*- C++ -*-===//
+//===-- NSSet.cpp ---------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,12 +7,13 @@
//===----------------------------------------------------------------------===//
#include "NSSet.h"
+#include "CFBasicHash.h"
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
@@ -79,6 +80,36 @@ private:
std::vector<SetItemDescriptor> m_children;
};
+class NSCFSetSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+ NSCFSetSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+ size_t CalculateNumChildren() override;
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+ bool Update() override;
+
+ bool MightHaveChildren() override;
+
+ size_t GetIndexOfChildWithName(ConstString name) override;
+
+private:
+ struct SetItemDescriptor {
+ lldb::addr_t item_ptr;
+ lldb::ValueObjectSP valobj_sp;
+ };
+
+ ExecutionContextRef m_exe_ctx_ref;
+ uint8_t m_ptr_size;
+ lldb::ByteOrder m_order;
+
+ CFBasicHash m_hashtable;
+
+ CompilerType m_pair_type;
+ std::vector<SetItemDescriptor> m_children;
+};
+
template <typename D32, typename D64>
class GenericNSSetMSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
public:
@@ -245,21 +276,25 @@ bool lldb_private::formatters::NSSetSummaryProvider(
uint64_t value = 0;
- ConstString class_name_cs = descriptor->GetClassName();
- const char *class_name = class_name_cs.GetCString();
+ ConstString class_name(descriptor->GetClassName());
- if (!class_name || !*class_name)
+ static const ConstString g_SetI("__NSSetI");
+ static const ConstString g_OrderedSetI("__NSOrderedSetI");
+ static const ConstString g_SetM("__NSSetM");
+ static const ConstString g_SetCF("__NSCFSet");
+ static const ConstString g_SetCFRef("CFSetRef");
+
+ if (class_name.IsEmpty())
return false;
- if (!strcmp(class_name, "__NSSetI") ||
- !strcmp(class_name, "__NSOrderedSetI")) {
+ if (class_name == g_SetI || class_name == g_OrderedSetI) {
Status error;
value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size,
ptr_size, 0, error);
if (error.Fail())
return false;
value &= (is_64bit ? ~0xFC00000000000000UL : ~0xFC000000U);
- } else if (!strcmp(class_name, "__NSSetM")) {
+ } else if (class_name == g_SetM) {
AppleObjCRuntime *apple_runtime =
llvm::dyn_cast_or_null<AppleObjCRuntime>(runtime);
Status error;
@@ -272,9 +307,15 @@ bool lldb_private::formatters::NSSetSummaryProvider(
}
if (error.Fail())
return false;
+ } else if (class_name == g_SetCF || class_name == g_SetCFRef) {
+ ExecutionContext exe_ctx(process_sp);
+ CFBasicHash cfbh;
+ if (!cfbh.Update(valobj_addr, exe_ctx))
+ return false;
+ value = cfbh.GetCount();
} else {
auto &map(NSSet_Additionals::GetAdditionalSummaries());
- auto iter = map.find(class_name_cs), end = map.end();
+ auto iter = map.find(class_name), end = map.end();
if (iter != end)
return iter->second(valobj, stream, options);
else
@@ -321,16 +362,20 @@ lldb_private::formatters::NSSetSyntheticFrontEndCreator(
if (!descriptor || !descriptor->IsValid())
return nullptr;
- ConstString class_name_cs = descriptor->GetClassName();
- const char *class_name = class_name_cs.GetCString();
+ ConstString class_name = descriptor->GetClassName();
- if (!class_name || !*class_name)
+ static const ConstString g_SetI("__NSSetI");
+ static const ConstString g_OrderedSetI("__NSOrderedSetI");
+ static const ConstString g_SetM("__NSSetM");
+ static const ConstString g_SetCF("__NSCFSet");
+ static const ConstString g_SetCFRef("CFSetRef");
+
+ if (class_name.IsEmpty())
return nullptr;
- if (!strcmp(class_name, "__NSSetI") ||
- !strcmp(class_name, "__NSOrderedSetI")) {
+ if (class_name == g_SetI || class_name == g_OrderedSetI) {
return (new NSSetISyntheticFrontEnd(valobj_sp));
- } else if (!strcmp(class_name, "__NSSetM")) {
+ } else if (class_name == g_SetM) {
AppleObjCRuntime *apple_runtime =
llvm::dyn_cast_or_null<AppleObjCRuntime>(runtime);
if (apple_runtime) {
@@ -343,9 +388,11 @@ lldb_private::formatters::NSSetSyntheticFrontEndCreator(
} else {
return (new Foundation1300::NSSetMSyntheticFrontEnd(valobj_sp));
}
+ } else if (class_name == g_SetCF || class_name == g_SetCFRef) {
+ return (new NSCFSetSyntheticFrontEnd(valobj_sp));
} else {
auto &map(NSSet_Additionals::GetAdditionalSynthetics());
- auto iter = map.find(class_name_cs), end = map.end();
+ auto iter = map.find(class_name), end = map.end();
if (iter != end)
return iter->second(synth, valobj_sp);
return nullptr;
@@ -475,16 +522,18 @@ lldb_private::formatters::NSSetISyntheticFrontEnd::GetChildAtIndex(size_t idx) {
auto ptr_size = process_sp->GetAddressByteSize();
DataBufferHeap buffer(ptr_size, 0);
switch (ptr_size) {
- case 0: // architecture has no clue?? - fail
+ case 0: // architecture has no clue - fail
return lldb::ValueObjectSP();
case 4:
- *((uint32_t *)buffer.GetBytes()) = (uint32_t)set_item.item_ptr;
+ *reinterpret_cast<uint32_t *>(buffer.GetBytes()) =
+ static_cast<uint32_t>(set_item.item_ptr);
break;
case 8:
- *((uint64_t *)buffer.GetBytes()) = (uint64_t)set_item.item_ptr;
+ *reinterpret_cast<uint64_t *>(buffer.GetBytes()) =
+ static_cast<uint64_t>(set_item.item_ptr);
break;
default:
- assert(false && "pointer size is not 4 nor 8 - get out of here ASAP");
+ lldbassert(false && "pointer size is not 4 nor 8");
}
StreamString idx_name;
idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
@@ -501,6 +550,128 @@ lldb_private::formatters::NSSetISyntheticFrontEnd::GetChildAtIndex(size_t idx) {
return set_item.valobj_sp;
}
+lldb_private::formatters::NSCFSetSyntheticFrontEnd::NSCFSetSyntheticFrontEnd(
+ lldb::ValueObjectSP valobj_sp)
+ : SyntheticChildrenFrontEnd(*valobj_sp), m_exe_ctx_ref(), m_ptr_size(8),
+ m_order(lldb::eByteOrderInvalid), m_hashtable(), m_pair_type() {}
+
+size_t
+lldb_private::formatters::NSCFSetSyntheticFrontEnd::GetIndexOfChildWithName(
+ ConstString name) {
+ const char *item_name = name.GetCString();
+ const uint32_t idx = ExtractIndexFromString(item_name);
+ if (idx < UINT32_MAX && idx >= CalculateNumChildren())
+ return UINT32_MAX;
+ return idx;
+}
+
+size_t
+lldb_private::formatters::NSCFSetSyntheticFrontEnd::CalculateNumChildren() {
+ if (!m_hashtable.IsValid())
+ return 0;
+ return m_hashtable.GetCount();
+}
+
+bool lldb_private::formatters::NSCFSetSyntheticFrontEnd::Update() {
+ m_children.clear();
+ ValueObjectSP valobj_sp = m_backend.GetSP();
+ m_ptr_size = 0;
+ if (!valobj_sp)
+ return false;
+ m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
+
+ lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
+ if (!process_sp)
+ return false;
+ m_ptr_size = process_sp->GetAddressByteSize();
+ m_order = process_sp->GetByteOrder();
+ return m_hashtable.Update(valobj_sp->GetValueAsUnsigned(0), m_exe_ctx_ref);
+}
+
+bool lldb_private::formatters::NSCFSetSyntheticFrontEnd::MightHaveChildren() {
+ return true;
+}
+
+lldb::ValueObjectSP
+lldb_private::formatters::NSCFSetSyntheticFrontEnd::GetChildAtIndex(
+ size_t idx) {
+ lldb::addr_t m_values_ptr = m_hashtable.GetValuePointer();
+
+ const uint32_t num_children = CalculateNumChildren();
+
+ if (idx >= num_children)
+ return lldb::ValueObjectSP();
+
+ if (m_children.empty()) {
+ ProcessSP process_sp = m_exe_ctx_ref.GetProcessSP();
+ if (!process_sp)
+ return lldb::ValueObjectSP();
+
+ Status error;
+ lldb::addr_t val_at_idx = 0;
+
+ uint32_t tries = 0;
+ uint32_t test_idx = 0;
+
+ // Iterate over inferior memory, reading value pointers by shifting the
+ // cursor by test_index * m_ptr_size. Returns an empty ValueObject if a read
+ // fails, otherwise, continue until the number of tries matches the number
+ // of childen.
+ while (tries < num_children) {
+ val_at_idx = m_values_ptr + (test_idx * m_ptr_size);
+
+ val_at_idx = process_sp->ReadPointerFromMemory(val_at_idx, error);
+ if (error.Fail())
+ return lldb::ValueObjectSP();
+
+ test_idx++;
+
+ if (!val_at_idx)
+ continue;
+ tries++;
+
+ SetItemDescriptor descriptor = {val_at_idx, lldb::ValueObjectSP()};
+
+ m_children.push_back(descriptor);
+ }
+ }
+
+ if (idx >= m_children.size()) // should never happen
+ return lldb::ValueObjectSP();
+
+ SetItemDescriptor &set_item = m_children[idx];
+ if (!set_item.valobj_sp) {
+
+ DataBufferSP buffer_sp(new DataBufferHeap(m_ptr_size, 0));
+
+ switch (m_ptr_size) {
+ case 0: // architecture has no clue - fail
+ return lldb::ValueObjectSP();
+ case 4:
+ *reinterpret_cast<uint32_t *>(buffer_sp->GetBytes()) =
+ static_cast<uint32_t>(set_item.item_ptr);
+ break;
+ case 8:
+ *reinterpret_cast<uint64_t *>(buffer_sp->GetBytes()) =
+ static_cast<uint64_t>(set_item.item_ptr);
+ break;
+ default:
+ lldbassert(false && "pointer size is not 4 nor 8");
+ }
+ StreamString idx_name;
+ idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
+
+ DataExtractor data(buffer_sp, m_order, m_ptr_size);
+
+ set_item.valobj_sp = CreateValueObjectFromData(
+ idx_name.GetString(), data, m_exe_ctx_ref,
+ m_backend.GetCompilerType().GetBasicTypeFromAST(
+ lldb::eBasicTypeObjCID));
+ }
+
+ return set_item.valobj_sp;
+}
+
template <typename D32, typename D64>
lldb_private::formatters::
GenericNSSetMSyntheticFrontEnd<D32, D64>::GenericNSSetMSyntheticFrontEnd(
@@ -513,7 +684,7 @@ lldb_private::formatters::
template <typename D32, typename D64>
lldb_private::formatters::
- GenericNSSetMSyntheticFrontEnd<D32, D64>::~GenericNSSetMSyntheticFrontEnd() {
+ GenericNSSetMSyntheticFrontEnd<D32, D64>::~GenericNSSetMSyntheticFrontEnd<D32, D64>() {
delete m_data_32;
m_data_32 = nullptr;
delete m_data_64;
diff --git a/lldb/source/Plugins/Language/ObjC/NSSet.h b/lldb/source/Plugins/Language/ObjC/NSSet.h
index f11b6d406dec..3ad1f694befe 100644
--- a/lldb/source/Plugins/Language/ObjC/NSSet.h
+++ b/lldb/source/Plugins/Language/ObjC/NSSet.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_NSSet_h_
-#define liblldb_NSSet_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_NSSET_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_NSSET_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -36,4 +36,4 @@ public:
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_NSSet_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_NSSET_H
diff --git a/lldb/source/Plugins/Language/ObjC/NSString.cpp b/lldb/source/Plugins/Language/ObjC/NSString.cpp
index ce54d657374b..b9d0d73cbc2e 100644
--- a/lldb/source/Plugins/Language/ObjC/NSString.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSString.cpp
@@ -1,5 +1,4 @@
-//===-- NSString.cpp ----------------------------------------------*- C++
-//-*-===//
+//===-- NSString.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,11 +8,11 @@
#include "NSString.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/StringPrinter.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/Target.h"
@@ -35,7 +34,7 @@ NSString_Additionals::GetAdditionalSummaries() {
static CompilerType GetNSPathStore2Type(Target &target) {
static ConstString g_type_name("__lldb_autogen_nspathstore2");
- ClangASTContext *ast_ctx = ClangASTContext::GetScratch(target);
+ TypeSystemClang *ast_ctx = TypeSystemClang::GetScratch(target);
if (!ast_ctx)
return CompilerType();
@@ -171,11 +170,11 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetStream(&stream);
options.SetQuote('"');
options.SetSourceSize(explicit_length);
+ options.SetHasSourceSize(has_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 {
@@ -183,11 +182,11 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetProcessSP(process_sp);
options.SetStream(&stream);
options.SetSourceSize(explicit_length);
+ options.SetHasSourceSize(has_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);
}
@@ -200,9 +199,9 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetStream(&stream);
options.SetQuote('"');
options.SetSourceSize(explicit_length);
+ options.SetHasSourceSize(has_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) {
@@ -222,11 +221,11 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetStream(&stream);
options.SetQuote('"');
options.SetSourceSize(explicit_length);
+ options.SetHasSourceSize(has_explicit_length);
options.SetNeedsZeroTermination(!has_explicit_length);
options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
options.SetBinaryZeroIsTerminator(!has_explicit_length);
- options.SetLanguage(summary_options.GetLanguage());
return StringPrinter::ReadStringAndDumpToStream<
StringPrinter::StringElementType::UTF16>(options);
} else if (is_path_store) {
@@ -242,11 +241,11 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetStream(&stream);
options.SetQuote('"');
options.SetSourceSize(explicit_length);
+ options.SetHasSourceSize(has_explicit_length);
options.SetNeedsZeroTermination(!has_explicit_length);
options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
options.SetBinaryZeroIsTerminator(!has_explicit_length);
- options.SetLanguage(summary_options.GetLanguage());
return StringPrinter::ReadStringAndDumpToStream<
StringPrinter::StringElementType::UTF16>(options);
} else if (is_inline) {
@@ -264,11 +263,11 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetProcessSP(process_sp);
options.SetStream(&stream);
options.SetSourceSize(explicit_length);
+ options.SetHasSourceSize(has_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);
@@ -287,9 +286,9 @@ bool lldb_private::formatters::NSStringSummaryProvider(
options.SetProcessSP(process_sp);
options.SetStream(&stream);
options.SetSourceSize(explicit_length);
+ options.SetHasSourceSize(has_explicit_length);
options.SetIgnoreMaxLength(summary_options.GetCapping() ==
TypeSummaryCapping::eTypeSummaryUncapped);
- options.SetLanguage(summary_options.GetLanguage());
return StringPrinter::ReadStringAndDumpToStream<
StringPrinter::StringElementType::ASCII>(options);
}
diff --git a/lldb/source/Plugins/Language/ObjC/NSString.h b/lldb/source/Plugins/Language/ObjC/NSString.h
index 699d8eb36f88..a68cc6c056b0 100644
--- a/lldb/source/Plugins/Language/ObjC/NSString.h
+++ b/lldb/source/Plugins/Language/ObjC/NSString.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_NSString_h_
-#define liblldb_NSString_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_NSSTRING_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_NSSTRING_H
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
@@ -39,4 +39,4 @@ public:
} // namespace formatters
} // namespace lldb_private
-#endif // liblldb_CF_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_NSSTRING_H
diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
index 3be548ad4144..29391daaab93 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -1,4 +1,4 @@
-//===-- ObjCLanguage.cpp ----------------------------------------*- C++ -*-===//
+//===-- ObjCLanguage.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,12 +10,12 @@
#include "ObjCLanguage.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/ConstString.h"
@@ -37,6 +37,8 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
+LLDB_PLUGIN_DEFINE(ObjCLanguage)
+
void ObjCLanguage::Initialize() {
PluginManager::RegisterPlugin(GetPluginNameStatic(), "Objective-C Language",
CreateInstance);
@@ -446,6 +448,10 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) {
appkit_flags);
AddCXXSummary(objc_category_sp,
lldb_private::formatters::NSDictionarySummaryProvider<true>,
+ "NSDictionary summary provider", ConstString("__CFDictionary"),
+ appkit_flags);
+ AddCXXSummary(objc_category_sp,
+ lldb_private::formatters::NSDictionarySummaryProvider<true>,
"NSDictionary summary provider",
ConstString("CFMutableDictionaryRef"), appkit_flags);
@@ -466,6 +472,9 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) {
"__NSCFSet summary", ConstString("__NSCFSet"), appkit_flags);
AddCXXSummary(objc_category_sp,
lldb_private::formatters::NSSetSummaryProvider<false>,
+ "__CFSet summary", ConstString("__CFSet"), 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>,
@@ -582,6 +591,11 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) {
lldb_private::formatters::NSDictionarySyntheticFrontEndCreator,
"NSDictionary synthetic children", ConstString("CFMutableDictionaryRef"),
ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(
+ objc_category_sp,
+ lldb_private::formatters::NSDictionarySyntheticFrontEndCreator,
+ "NSDictionary synthetic children", ConstString("__CFDictionary"),
+ ScriptedSyntheticChildren::Flags());
AddCXXSynthetic(objc_category_sp,
lldb_private::formatters::NSErrorSyntheticFrontEndCreator,
@@ -604,6 +618,15 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) {
lldb_private::formatters::NSSetSyntheticFrontEndCreator,
"__NSSetM synthetic children", ConstString("__NSSetM"),
ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp,
+ lldb_private::formatters::NSSetSyntheticFrontEndCreator,
+ "__NSCFSet synthetic children", ConstString("__NSCFSet"),
+ ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp,
+ lldb_private::formatters::NSSetSyntheticFrontEndCreator,
+ "CFSetRef synthetic children", ConstString("CFSetRef"),
+ ScriptedSyntheticChildren::Flags());
+
AddCXXSynthetic(
objc_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator,
"NSMutableSet synthetic children", ConstString("NSMutableSet"),
@@ -620,6 +643,10 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) {
objc_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator,
"__NSOrderedSetM synthetic children", ConstString("__NSOrderedSetM"),
ScriptedSyntheticChildren::Flags());
+ AddCXXSynthetic(objc_category_sp,
+ lldb_private::formatters::NSSetSyntheticFrontEndCreator,
+ "__CFSet synthetic children", ConstString("__CFSet"),
+ ScriptedSyntheticChildren::Flags());
AddCXXSynthetic(objc_category_sp,
lldb_private::formatters::NSIndexPathSyntheticFrontEndCreator,
diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
index 3e2cc0972993..bed62a5c447a 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ObjCLanguage_h_
-#define liblldb_ObjCLanguage_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_OBJCLANGUAGE_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_OBJCLANGUAGE_H
#include <cstring>
#include <vector>
@@ -160,4 +160,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_ObjCLanguage_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_OBJC_OBJCLANGUAGE_H
diff --git a/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
index 81b3c5807c41..0a4017eda434 100644
--- a/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
@@ -1,5 +1,4 @@
-//===-- ObjCPlusPlusLanguage.cpp --------------------------------------*- C++
-//-*-===//
+//===-- ObjCPlusPlusLanguage.cpp ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -15,6 +14,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(ObjCPlusPlusLanguage)
+
bool ObjCPlusPlusLanguage::IsSourceFile(llvm::StringRef file_path) const {
const auto suffixes = {".h", ".mm"};
for (auto suffix : suffixes) {
diff --git a/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h b/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
index 6224a3f47b3b..4b3d23653347 100644
--- a/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
+++ b/lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ObjCPlusPlusLanguage_h_
-#define liblldb_ObjCPlusPlusLanguage_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGE_OBJCPLUSPLUS_OBJCPLUSPLUSLANGUAGE_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGE_OBJCPLUSPLUS_OBJCPLUSPLUSLANGUAGE_H
#include "Plugins/Language/ClangCommon/ClangHighlighter.h"
#include "lldb/Target/Language.h"
@@ -48,4 +48,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_CPlusPlusLanguage_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGE_OBJCPLUSPLUS_OBJCPLUSPLUSLANGUAGE_H
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index d556aae1c458..8aa803a8553e 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -1,4 +1,4 @@
-//===-- CPPLanguageRuntime.cpp
+//===-- CPPLanguageRuntime.cpp---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -20,7 +20,6 @@
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/UniqueCStringMap.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/ExecutionContext.h"
@@ -44,7 +43,7 @@ CPPLanguageRuntime::~CPPLanguageRuntime() {}
CPPLanguageRuntime::CPPLanguageRuntime(Process *process)
: LanguageRuntime(process) {}
-bool CPPLanguageRuntime::IsWhitelistedRuntimeValue(ConstString name) {
+bool CPPLanguageRuntime::IsAllowedRuntimeValue(ConstString name) {
return name == g_this;
}
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h
index abdd79fcd7b9..5b00590e6301 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_CPPLanguageRuntime_h_
-#define liblldb_CPPLanguageRuntime_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_CPLUSPLUS_CPPLANGUAGERUNTIME_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_CPLUSPLUS_CPPLANGUAGERUNTIME_H
#include <vector>
@@ -69,7 +69,7 @@ public:
/// Obtain a ThreadPlan to get us into C++ constructs such as std::function.
///
/// \param[in] thread
- /// Curent thrad of execution.
+ /// Current thrad of execution.
///
/// \param[in] stop_others
/// True if other threads should pause during execution.
@@ -79,7 +79,7 @@ public:
lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
bool stop_others) override;
- bool IsWhitelistedRuntimeValue(ConstString name) override;
+ bool IsAllowedRuntimeValue(ConstString name) override;
protected:
// Classes that inherit from CPPLanguageRuntime can see and modify these
CPPLanguageRuntime(Process *process);
@@ -90,9 +90,10 @@ private:
OperatorStringToCallableInfoMap CallableLookupCache;
- DISALLOW_COPY_AND_ASSIGN(CPPLanguageRuntime);
+ CPPLanguageRuntime(const CPPLanguageRuntime &) = delete;
+ const CPPLanguageRuntime &operator=(const CPPLanguageRuntime &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_CPPLanguageRuntime_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_CPLUSPLUS_CPPLANGUAGERUNTIME_H
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
index 9efb021caa83..3ab32641d9c1 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
@@ -1,5 +1,4 @@
-//===-- ItaniumABILanguageRuntime.cpp --------------------------------------*-
-//C++ -*-===//
+//===-- ItaniumABILanguageRuntime.cpp -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,6 +8,7 @@
#include "ItaniumABILanguageRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Mangled.h"
#include "lldb/Core/Module.h"
@@ -21,7 +21,6 @@
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/CommandObjectMultiword.h"
#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/TypeList.h"
@@ -41,6 +40,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE_ADV(ItaniumABILanguageRuntime, CXXItaniumABI)
+
static const char *vtable_demangled_prefix = "vtable for ";
char ItaniumABILanguageRuntime::ID = 0;
@@ -73,9 +74,7 @@ TypeAndOrName ItaniumABILanguageRuntime::GetTypeInfoFromVTableAddress(
Symbol *symbol = sc.symbol;
if (symbol != nullptr) {
const char *name =
- symbol->GetMangled()
- .GetDemangledName(lldb::eLanguageTypeC_plus_plus)
- .AsCString();
+ symbol->GetMangled().GetDemangledName().AsCString();
if (name && strstr(name, vtable_demangled_prefix) == name) {
Log *log(
lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
@@ -118,7 +117,7 @@ TypeAndOrName ItaniumABILanguageRuntime::GetTypeInfoFromVTableAddress(
if (class_types.GetSize() == 1) {
type_sp = class_types.GetTypeAtIndex(0);
if (type_sp) {
- if (ClangASTContext::IsCXXClassType(
+ if (TypeSystemClang::IsCXXClassType(
type_sp->GetForwardCompilerType())) {
LLDB_LOGF(
log,
@@ -150,7 +149,7 @@ TypeAndOrName ItaniumABILanguageRuntime::GetTypeInfoFromVTableAddress(
for (i = 0; i < class_types.GetSize(); i++) {
type_sp = class_types.GetTypeAtIndex(i);
if (type_sp) {
- if (ClangASTContext::IsCXXClassType(
+ if (TypeSystemClang::IsCXXClassType(
type_sp->GetForwardCompilerType())) {
LLDB_LOGF(
log,
@@ -238,7 +237,7 @@ bool ItaniumABILanguageRuntime::GetDynamicTypeAndAddress(
if (!type)
return true;
- if (ClangASTContext::AreTypesSame(in_value.GetCompilerType(), type)) {
+ if (TypeSystemClang::AreTypesSame(in_value.GetCompilerType(), type)) {
// The dynamic type we found was the same type, so we don't have a
// dynamic type here...
return false;
@@ -358,8 +357,7 @@ protected:
Mangled mangled(name);
if (mangled.GuessLanguage() == lldb::eLanguageTypeC_plus_plus) {
- ConstString demangled(
- mangled.GetDisplayDemangledName(lldb::eLanguageTypeC_plus_plus));
+ ConstString demangled(mangled.GetDisplayDemangledName());
demangled_any = true;
result.AppendMessageWithFormat("%s ---> %s\n", entry.c_str(),
demangled.GetCString());
@@ -420,12 +418,13 @@ lldb_private::ConstString ItaniumABILanguageRuntime::GetPluginName() {
uint32_t ItaniumABILanguageRuntime::GetPluginVersion() { return 1; }
BreakpointResolverSP ItaniumABILanguageRuntime::CreateExceptionResolver(
- Breakpoint *bkpt, bool catch_bp, bool throw_bp) {
+ const BreakpointSP &bkpt, bool catch_bp, bool throw_bp) {
return CreateExceptionResolver(bkpt, catch_bp, throw_bp, false);
}
BreakpointResolverSP ItaniumABILanguageRuntime::CreateExceptionResolver(
- Breakpoint *bkpt, bool catch_bp, bool throw_bp, bool for_expressions) {
+ const BreakpointSP &bkpt, bool catch_bp, bool throw_bp,
+ bool for_expressions) {
// One complication here is that most users DON'T want to stop at
// __cxa_allocate_expression, but until we can do anything better with
// predicting unwinding the expression parser does. So we have two forms of
@@ -536,8 +535,8 @@ ValueObjectSP ItaniumABILanguageRuntime::GetExceptionObjectForThread(
if (!thread_sp->SafeToCallFunctions())
return {};
- ClangASTContext *clang_ast_context =
- ClangASTContext::GetScratch(m_process->GetTarget());
+ TypeSystemClang *clang_ast_context =
+ TypeSystemClang::GetScratch(m_process->GetTarget());
if (!clang_ast_context)
return {};
diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
index 97cc81b8681f..d591527d9257 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ItaniumABILanguageRuntime_h_
-#define liblldb_ItaniumABILanguageRuntime_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_CPLUSPLUS_ITANIUMABI_ITANIUMABILANGUAGERUNTIME_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_CPLUSPLUS_ITANIUMABI_ITANIUMABILANGUAGERUNTIME_H
#include <map>
#include <mutex>
@@ -66,9 +66,9 @@ public:
bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override;
- lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt,
- bool catch_bp,
- bool throw_bp) override;
+ lldb::BreakpointResolverSP
+ CreateExceptionResolver(const lldb::BreakpointSP &bkpt,
+ bool catch_bp, bool throw_bp) override;
lldb::SearchFilterSP CreateExceptionSearchFilter() override;
@@ -81,10 +81,9 @@ public:
uint32_t GetPluginVersion() override;
protected:
- lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt,
- bool catch_bp,
- bool throw_bp,
- bool for_expressions);
+ lldb::BreakpointResolverSP
+ CreateExceptionResolver(const lldb::BreakpointSP &bkpt,
+ bool catch_bp, bool throw_bp, bool for_expressions);
lldb::BreakpointSP CreateExceptionBreakpoint(bool catch_bp, bool throw_bp,
bool for_expressions,
@@ -114,4 +113,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ItaniumABILanguageRuntime_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_CPLUSPLUS_ITANIUMABI_ITANIUMABILANGUAGERUNTIME_H
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
index 859b693477a9..bdd5c29db848 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
@@ -1,5 +1,4 @@
-//===-- AppleObjCClassDescriptorV2.cpp -----------------------------*- C++
-//-*-===//
+//===-- AppleObjCClassDescriptorV2.cpp ------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -17,7 +16,7 @@ using namespace lldb_private;
bool ClassDescriptorV2::Read_objc_class(
Process *process, std::unique_ptr<objc_class_t> &objc_class) const {
- objc_class.reset(new objc_class_t);
+ objc_class = std::make_unique<objc_class_t>();
bool ret = objc_class->Read(process, m_objc_class_ptr);
@@ -198,14 +197,14 @@ bool ClassDescriptorV2::Read_class_row(
return false;
if (class_row_t_flags & RW_REALIZED) {
- class_rw.reset(new class_rw_t);
+ class_rw = std::make_unique<class_rw_t>();
if (!class_rw->Read(process, objc_class.m_data_ptr)) {
class_rw.reset();
return false;
}
- class_ro.reset(new class_ro_t);
+ class_ro = std::make_unique<class_ro_t>();
if (!class_ro->Read(process, class_rw->m_ro_ptr)) {
class_rw.reset();
@@ -213,7 +212,7 @@ bool ClassDescriptorV2::Read_class_row(
return false;
}
} else {
- class_ro.reset(new class_ro_t);
+ class_ro = std::make_unique<class_ro_t>();
if (!class_ro->Read(process, objc_class.m_data_ptr)) {
class_ro.reset();
@@ -242,15 +241,20 @@ bool ClassDescriptorV2::method_list_t::Read(Process *process,
lldb::offset_t cursor = 0;
- m_entsize = extractor.GetU32_unchecked(&cursor) & ~(uint32_t)3;
+ uint32_t entsize = extractor.GetU32_unchecked(&cursor);
+ m_is_small = (entsize & 0x80000000) != 0;
+ m_has_direct_selector = (entsize & 0x40000000) != 0;
+ m_entsize = entsize & 0xfffc;
m_count = extractor.GetU32_unchecked(&cursor);
m_first_ptr = addr + cursor;
return true;
}
-bool ClassDescriptorV2::method_t::Read(Process *process, lldb::addr_t addr) {
- size_t size = GetSize(process);
+bool ClassDescriptorV2::method_t::Read(Process *process, lldb::addr_t addr,
+ bool is_small, bool has_direct_sel) {
+ size_t ptr_size = process->GetAddressByteSize();
+ size_t size = GetSize(process, is_small);
DataBufferHeap buffer(size, '\0');
Status error;
@@ -261,13 +265,30 @@ bool ClassDescriptorV2::method_t::Read(Process *process, lldb::addr_t addr) {
}
DataExtractor extractor(buffer.GetBytes(), size, process->GetByteOrder(),
- process->GetAddressByteSize());
-
+ ptr_size);
lldb::offset_t cursor = 0;
- m_name_ptr = extractor.GetAddress_unchecked(&cursor);
- m_types_ptr = extractor.GetAddress_unchecked(&cursor);
- m_imp_ptr = extractor.GetAddress_unchecked(&cursor);
+ if (is_small) {
+ uint32_t nameref_offset = extractor.GetU32_unchecked(&cursor);
+ uint32_t types_offset = extractor.GetU32_unchecked(&cursor);
+ uint32_t imp_offset = extractor.GetU32_unchecked(&cursor);
+
+ m_name_ptr = addr + nameref_offset;
+
+ if (!has_direct_sel) {
+ // The SEL offset points to a SELRef. We need to dereference twice.
+ m_name_ptr = process->ReadUnsignedIntegerFromMemory(m_name_ptr, ptr_size,
+ 0, error);
+ if (!error.Success())
+ return false;
+ }
+ m_types_ptr = addr + 4 + types_offset;
+ m_imp_ptr = addr + 8 + imp_offset;
+ } else {
+ m_name_ptr = extractor.GetAddress_unchecked(&cursor);
+ m_types_ptr = extractor.GetAddress_unchecked(&cursor);
+ m_imp_ptr = extractor.GetAddress_unchecked(&cursor);
+ }
process->ReadCStringFromMemory(m_name_ptr, m_name, error);
if (error.Fail()) {
@@ -358,19 +379,24 @@ bool ClassDescriptorV2::Describe(
if (instance_method_func) {
std::unique_ptr<method_list_t> base_method_list;
- base_method_list.reset(new method_list_t);
+ base_method_list = std::make_unique<method_list_t>();
if (!base_method_list->Read(process, class_ro->m_baseMethods_ptr))
return false;
- if (base_method_list->m_entsize != method_t::GetSize(process))
+ bool is_small = base_method_list->m_is_small;
+ bool has_direct_selector = base_method_list->m_has_direct_selector;
+
+ if (base_method_list->m_entsize != method_t::GetSize(process, is_small))
return false;
std::unique_ptr<method_t> method;
- method.reset(new method_t);
+ method = std::make_unique<method_t>();
for (uint32_t i = 0, e = base_method_list->m_count; i < e; ++i) {
- method->Read(process, base_method_list->m_first_ptr +
- (i * base_method_list->m_entsize));
+ method->Read(process,
+ base_method_list->m_first_ptr +
+ (i * base_method_list->m_entsize),
+ is_small, has_direct_selector);
if (instance_method_func(method->m_name.c_str(), method->m_types.c_str()))
break;
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
index b8ba9dbb65f4..9ef21c6e7208 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_AppleObjCClassDescriptorV2_h_
-#define liblldb_AppleObjCClassDescriptorV2_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCCLASSDESCRIPTORV2_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCCLASSDESCRIPTORV2_H
#include <mutex>
@@ -133,7 +133,9 @@ private:
};
struct method_list_t {
- uint32_t m_entsize;
+ uint16_t m_entsize;
+ bool m_is_small;
+ bool m_has_direct_selector;
uint32_t m_count;
lldb::addr_t m_first_ptr;
@@ -148,15 +150,19 @@ private:
std::string m_name;
std::string m_types;
- static size_t GetSize(Process *process) {
- size_t ptr_size = process->GetAddressByteSize();
+ static size_t GetSize(Process *process, bool is_small) {
+ size_t field_size;
+ if (is_small)
+ field_size = 4; // uint32_t relative indirect fields
+ else
+ field_size = process->GetAddressByteSize();
- return ptr_size // SEL name;
- + ptr_size // const char *types;
- + ptr_size; // IMP imp;
+ return field_size // SEL name;
+ + field_size // const char *types;
+ + field_size; // IMP imp;
}
- bool Read(Process *process, lldb::addr_t addr);
+ bool Read(Process *process, lldb::addr_t addr, bool, bool);
};
struct ivar_list_t {
@@ -328,4 +334,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_AppleObjCClassDescriptorV2_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCCLASSDESCRIPTORV2_H
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
index 73843063606c..7b331307c0f7 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
@@ -1,4 +1,4 @@
-//===-- AppleObjCDeclVendor.cpp ---------------------------------*- C++ -*-===//
+//===-- AppleObjCDeclVendor.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,10 +8,10 @@
#include "AppleObjCDeclVendor.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
#include "lldb/Core/Module.h"
-#include "lldb/Symbol/ClangASTMetadata.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/Log.h"
@@ -30,17 +30,14 @@ public:
bool FindExternalVisibleDeclsByName(const clang::DeclContext *decl_ctx,
clang::DeclarationName name) override {
- static unsigned int invocation_id = 0;
- unsigned int current_id = invocation_id++;
Log *log(GetLogIfAllCategoriesSet(
LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel?
if (log) {
LLDB_LOGF(log,
- "AppleObjCExternalASTSource::FindExternalVisibleDeclsByName[%"
- "u] on (ASTContext*)%p Looking for %s in (%sDecl*)%p",
- current_id,
+ "AppleObjCExternalASTSource::FindExternalVisibleDeclsByName"
+ " on (ASTContext*)%p Looking for %s in (%sDecl*)%p",
static_cast<void *>(&decl_ctx->getParentASTContext()),
name.getAsString().c_str(), decl_ctx->getDeclKindName(),
static_cast<const void *>(decl_ctx));
@@ -70,44 +67,37 @@ public:
}
void CompleteType(clang::TagDecl *tag_decl) override {
- static unsigned int invocation_id = 0;
- unsigned int current_id = invocation_id++;
Log *log(GetLogIfAllCategoriesSet(
LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel?
LLDB_LOGF(log,
- "AppleObjCExternalASTSource::CompleteType[%u] on "
+ "AppleObjCExternalASTSource::CompleteType on "
"(ASTContext*)%p Completing (TagDecl*)%p named %s",
- current_id, static_cast<void *>(&tag_decl->getASTContext()),
+ static_cast<void *>(&tag_decl->getASTContext()),
static_cast<void *>(tag_decl), tag_decl->getName().str().c_str());
- LLDB_LOG(log, " AOEAS::CT[{0}] Before:\n{1}", current_id,
- ClangUtil::DumpDecl(tag_decl));
+ LLDB_LOG(log, " AOEAS::CT Before:\n{1}", ClangUtil::DumpDecl(tag_decl));
- LLDB_LOG(log, " AOEAS::CT[{1}] After:{1}", current_id,
- ClangUtil::DumpDecl(tag_decl));
+ LLDB_LOG(log, " AOEAS::CT After:{1}", ClangUtil::DumpDecl(tag_decl));
return;
}
void CompleteType(clang::ObjCInterfaceDecl *interface_decl) override {
- static unsigned int invocation_id = 0;
- unsigned int current_id = invocation_id++;
Log *log(GetLogIfAllCategoriesSet(
LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel?
if (log) {
LLDB_LOGF(log,
- "AppleObjCExternalASTSource::CompleteType[%u] on "
+ "AppleObjCExternalASTSource::CompleteType on "
"(ASTContext*)%p Completing (ObjCInterfaceDecl*)%p named %s",
- current_id,
static_cast<void *>(&interface_decl->getASTContext()),
static_cast<void *>(interface_decl),
interface_decl->getName().str().c_str());
- LLDB_LOGF(log, " AOEAS::CT[%u] Before:", current_id);
+ LLDB_LOGF(log, " AOEAS::CT Before:");
LLDB_LOG(log, " [CT] {0}", ClangUtil::DumpDecl(interface_decl));
}
@@ -143,10 +133,9 @@ private:
AppleObjCDeclVendor::AppleObjCDeclVendor(ObjCLanguageRuntime &runtime)
: ClangDeclVendor(eAppleObjCDeclVendor), m_runtime(runtime),
- m_ast_ctx(runtime.GetProcess()
- ->GetTarget()
- .GetArchitecture()
- .GetTriple()),
+ m_ast_ctx(
+ "AppleObjCDeclVendor AST",
+ runtime.GetProcess()->GetTarget().GetArchitecture().GetTriple()),
m_type_realizer_sp(m_runtime.GetEncodingToType()) {
m_external_source = new AppleObjCExternalASTSource(*this);
llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> external_source_owning_ptr(
@@ -309,7 +298,7 @@ public:
}
clang::ObjCMethodDecl *
- BuildMethod(ClangASTContext &clang_ast_ctxt,
+ BuildMethod(TypeSystemClang &clang_ast_ctxt,
clang::ObjCInterfaceDecl *interface_decl, const char *name,
bool instance,
ObjCLanguageRuntime::EncodingToTypeSP type_realizer_sp) {
@@ -538,15 +527,13 @@ bool AppleObjCDeclVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) {
uint32_t AppleObjCDeclVendor::FindDecls(ConstString name, bool append,
uint32_t max_matches,
std::vector<CompilerDecl> &decls) {
- static unsigned int invocation_id = 0;
- unsigned int current_id = invocation_id++;
Log *log(GetLogIfAllCategoriesSet(
LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel?
- LLDB_LOGF(log, "AppleObjCDeclVendor::FindDecls [%u] ('%s', %s, %u, )",
- current_id, (const char *)name.AsCString(),
- append ? "true" : "false", max_matches);
+ LLDB_LOGF(log, "AppleObjCDeclVendor::FindDecls ('%s', %s, %u, )",
+ (const char *)name.AsCString(), append ? "true" : "false",
+ max_matches);
if (!append)
decls.clear();
@@ -579,24 +566,21 @@ uint32_t AppleObjCDeclVendor::FindDecls(ConstString name, bool append,
isa_value = metadata->GetISAPtr();
LLDB_LOG(log,
- "AOCTV::FT [%u] Found %s (isa 0x%" PRIx64
- ") in the ASTContext",
- current_id, result_iface_type.getAsString(), isa_value);
+ "AOCTV::FT Found %s (isa 0x%" PRIx64 ") in the ASTContext",
+ result_iface_type.getAsString(), isa_value);
}
- decls.push_back(CompilerDecl(&m_ast_ctx, result_iface_decl));
+ decls.push_back(m_ast_ctx.GetCompilerDecl(result_iface_decl));
ret++;
break;
} else {
- LLDB_LOGF(log,
- "AOCTV::FT [%u] There's something in the ASTContext, but "
- "it's not something we know about",
- current_id);
+ LLDB_LOGF(log, "AOCTV::FT There's something in the ASTContext, but "
+ "it's not something we know about");
break;
}
} else if (log) {
- LLDB_LOGF(log, "AOCTV::FT [%u] Couldn't find %s in the ASTContext",
- current_id, name.AsCString());
+ LLDB_LOGF(log, "AOCTV::FT Couldn't find %s in the ASTContext",
+ name.AsCString());
}
// It's not. If it exists, we have to put it into our ASTContext.
@@ -604,7 +588,7 @@ uint32_t AppleObjCDeclVendor::FindDecls(ConstString name, bool append,
ObjCLanguageRuntime::ObjCISA isa = m_runtime.GetISA(name);
if (!isa) {
- LLDB_LOGF(log, "AOCTV::FT [%u] Couldn't find the isa", current_id);
+ LLDB_LOGF(log, "AOCTV::FT Couldn't find the isa");
break;
}
@@ -613,9 +597,9 @@ uint32_t AppleObjCDeclVendor::FindDecls(ConstString name, bool append,
if (!iface_decl) {
LLDB_LOGF(log,
- "AOCTV::FT [%u] Couldn't get the Objective-C interface for "
+ "AOCTV::FT Couldn't get the Objective-C interface for "
"isa 0x%" PRIx64,
- current_id, (uint64_t)isa);
+ (uint64_t)isa);
break;
}
@@ -623,11 +607,11 @@ uint32_t AppleObjCDeclVendor::FindDecls(ConstString name, bool append,
if (log) {
clang::QualType new_iface_type = ast_ctx.getObjCInterfaceType(iface_decl);
- LLDB_LOG(log, "AOCTV::FT [{0}] Created {1} (isa 0x{2:x})", current_id,
+ LLDB_LOG(log, "AOCTV::FT Created {1} (isa 0x{2:x})",
new_iface_type.getAsString(), (uint64_t)isa);
}
- decls.push_back(CompilerDecl(&m_ast_ctx, iface_decl));
+ decls.push_back(m_ast_ctx.GetCompilerDecl(iface_decl));
ret++;
break;
} while (false);
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
index f49ca3540c2c..c1201b985814 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
@@ -6,14 +6,14 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_AppleObjCDeclVendor_h_
-#define liblldb_AppleObjCDeclVendor_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCDECLVENDOR_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCDECLVENDOR_H
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/lldb-private.h"
#include "Plugins/ExpressionParser/Clang/ClangDeclVendor.h"
#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
namespace lldb_private {
@@ -37,7 +37,7 @@ private:
bool FinishDecl(clang::ObjCInterfaceDecl *decl);
ObjCLanguageRuntime &m_runtime;
- ClangASTContext m_ast_ctx;
+ TypeSystemClang m_ast_ctx;
ObjCLanguageRuntime::EncodingToTypeSP m_type_realizer_sp;
AppleObjCExternalASTSource *m_external_source;
@@ -50,4 +50,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_AppleObjCDeclVendor_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCDECLVENDOR_H
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index 7076959bee97..22ea83a57beb 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -1,5 +1,4 @@
-//===-- AppleObjCRuntime.cpp -------------------------------------*- C++
-//-*-===//
+//===-- AppleObjCRuntime.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,10 +7,12 @@
//===----------------------------------------------------------------------===//
#include "AppleObjCRuntime.h"
+#include "AppleObjCRuntimeV1.h"
+#include "AppleObjCRuntimeV2.h"
#include "AppleObjCTrampolineHandler.h"
-
-#include "clang/AST/Type.h"
-
+#include "Plugins/Language/ObjC/NSString.h"
+#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
+#include "Plugins/Process/Utility/HistoryThread.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
@@ -22,7 +23,6 @@
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
@@ -35,16 +35,17 @@
#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StreamString.h"
+#include "clang/AST/Type.h"
-#include "Plugins/Process/Utility/HistoryThread.h"
-#include "Plugins/Language/ObjC/NSString.h"
-#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include <vector>
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(AppleObjCRuntime)
+
char AppleObjCRuntime::ID = 0;
AppleObjCRuntime::~AppleObjCRuntime() {}
@@ -55,6 +56,16 @@ AppleObjCRuntime::AppleObjCRuntime(Process *process)
ReadObjCLibraryIfNeeded(process->GetTarget().GetImages());
}
+void AppleObjCRuntime::Initialize() {
+ AppleObjCRuntimeV2::Initialize();
+ AppleObjCRuntimeV1::Initialize();
+}
+
+void AppleObjCRuntime::Terminate() {
+ AppleObjCRuntimeV2::Terminate();
+ AppleObjCRuntimeV1::Terminate();
+}
+
bool AppleObjCRuntime::GetObjectDescription(Stream &str, ValueObject &valobj) {
CompilerType compiler_type(valobj.GetCompilerType());
bool is_signed;
@@ -105,13 +116,13 @@ bool AppleObjCRuntime::GetObjectDescription(Stream &strm, Value &value,
Target *target = exe_ctx.GetTargetPtr();
CompilerType compiler_type = value.GetCompilerType();
if (compiler_type) {
- if (!ClangASTContext::IsObjCObjectPointerType(compiler_type)) {
+ if (!TypeSystemClang::IsObjCObjectPointerType(compiler_type)) {
strm.Printf("Value doesn't point to an ObjC object.\n");
return false;
}
} else {
// If it is not a pointer, see if we can make it into a pointer.
- ClangASTContext *ast_context = ClangASTContext::GetScratch(*target);
+ TypeSystemClang *ast_context = TypeSystemClang::GetScratch(*target);
if (!ast_context)
return false;
@@ -126,7 +137,7 @@ bool AppleObjCRuntime::GetObjectDescription(Stream &strm, Value &value,
arg_value_list.PushValue(value);
// This is the return value:
- ClangASTContext *ast_context = ClangASTContext::GetScratch(*target);
+ TypeSystemClang *ast_context = TypeSystemClang::GetScratch(*target);
if (!ast_context)
return false;
@@ -239,7 +250,8 @@ Address *AppleObjCRuntime::GetPrintForDebuggerAddr() {
contexts.GetContextAtIndex(0, context);
- m_PrintForDebugger_addr.reset(new Address(context.symbol->GetAddress()));
+ m_PrintForDebugger_addr =
+ std::make_unique<Address>(context.symbol->GetAddress());
}
return m_PrintForDebugger_addr.get();
@@ -335,8 +347,8 @@ bool AppleObjCRuntime::ReadObjCLibrary(const ModuleSP &module_sp) {
// Maybe check here and if we have a handler already, and the UUID of this
// module is the same as the one in the current module, then we don't have to
// reread it?
- m_objc_trampoline_handler_up.reset(
- new AppleObjCTrampolineHandler(m_process->shared_from_this(), module_sp));
+ m_objc_trampoline_handler_up = std::make_unique<AppleObjCTrampolineHandler>(
+ m_process->shared_from_this(), module_sp);
if (m_objc_trampoline_handler_up != nullptr) {
m_read_objc_library = true;
return true;
@@ -479,7 +491,7 @@ ValueObjectSP AppleObjCRuntime::GetExceptionObjectForThread(
auto descriptor = GetClassDescriptor(*cpp_exception);
if (!descriptor || !descriptor->IsValid()) return ValueObjectSP();
-
+
while (descriptor) {
ConstString class_name(descriptor->GetClassName());
if (class_name == "NSException")
@@ -490,19 +502,32 @@ ValueObjectSP AppleObjCRuntime::GetExceptionObjectForThread(
return ValueObjectSP();
}
+/// Utility method for error handling in GetBacktraceThreadFromException.
+/// \param msg The message to add to the log.
+/// \return An invalid ThreadSP to be returned from
+/// GetBacktraceThreadFromException.
+LLVM_NODISCARD
+static ThreadSP FailExceptionParsing(llvm::StringRef msg) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE));
+ LLDB_LOG(log, "Failed getting backtrace from exception: {0}", msg);
+ return ThreadSP();
+}
+
ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException(
lldb::ValueObjectSP exception_sp) {
ValueObjectSP reserved_dict =
exception_sp->GetChildMemberWithName(ConstString("reserved"), true);
- if (!reserved_dict) return ThreadSP();
+ if (!reserved_dict)
+ return FailExceptionParsing("Failed to get 'reserved' member.");
reserved_dict = reserved_dict->GetSyntheticValue();
- if (!reserved_dict) return ThreadSP();
+ if (!reserved_dict)
+ return FailExceptionParsing("Failed to get synthetic value.");
- ClangASTContext *clang_ast_context =
- ClangASTContext::GetScratch(*exception_sp->GetTargetSP());
+ TypeSystemClang *clang_ast_context =
+ TypeSystemClang::GetScratch(*exception_sp->GetTargetSP());
if (!clang_ast_context)
- return ThreadSP();
+ return FailExceptionParsing("Failed to get scratch AST.");
CompilerType objc_id =
clang_ast_context->GetBasicType(lldb::eBasicTypeObjCID);
ValueObjectSP return_addresses;
@@ -527,8 +552,8 @@ ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException(
if (error.Fail()) return ThreadSP();
lldb::offset_t data_offset = 0;
- auto dict_entry_key = data.GetPointer(&data_offset);
- auto dict_entry_value = data.GetPointer(&data_offset);
+ auto dict_entry_key = data.GetAddress(&data_offset);
+ auto dict_entry_value = data.GetAddress(&data_offset);
auto key_nsstring = objc_object_from_address(dict_entry_key, "key");
StreamString key_summary;
@@ -543,15 +568,22 @@ ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException(
}
}
- if (!return_addresses) return ThreadSP();
+ if (!return_addresses)
+ return FailExceptionParsing("Failed to get return addresses.");
auto frames_value =
return_addresses->GetChildMemberWithName(ConstString("_frames"), true);
+ if (!frames_value)
+ return FailExceptionParsing("Failed to get frames_value.");
addr_t frames_addr = frames_value->GetValueAsUnsigned(0);
auto count_value =
return_addresses->GetChildMemberWithName(ConstString("_cnt"), true);
+ if (!count_value)
+ return FailExceptionParsing("Failed to get count_value.");
size_t count = count_value->GetValueAsUnsigned(0);
auto ignore_value =
return_addresses->GetChildMemberWithName(ConstString("_ignore"), true);
+ if (!ignore_value)
+ return FailExceptionParsing("Failed to get ignore_value.");
size_t ignore = ignore_value->GetValueAsUnsigned(0);
size_t ptr_size = m_process->GetAddressByteSize();
@@ -563,7 +595,8 @@ ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException(
pcs.push_back(pc);
}
- if (pcs.empty()) return ThreadSP();
+ if (pcs.empty())
+ return FailExceptionParsing("Failed to get PC list.");
ThreadSP new_thread_sp(new HistoryThread(*m_process, 0, pcs));
m_process->GetExtendedThreadList().AddThread(new_thread_sp);
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
index 79ac53e1e440..e9790871e8c4 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_AppleObjCRuntime_h_
-#define liblldb_AppleObjCRuntime_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIME_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIME_H
#include "llvm/ADT/Optional.h"
@@ -31,6 +31,10 @@ public:
static char ID;
+ static void Initialize();
+
+ static void Terminate();
+
bool isA(const void *ClassID) const override {
return ClassID == &ID || ObjCLanguageRuntime::isA(ClassID);
}
@@ -84,7 +88,7 @@ public:
bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override;
lldb::SearchFilterSP CreateExceptionSearchFilter() override;
-
+
static std::tuple<FileSpec, ConstString> GetExceptionThrowLocation();
lldb::ValueObjectSP GetExceptionObjectForThread(
@@ -97,7 +101,7 @@ public:
virtual void GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true,
lldb::addr_t &cf_false);
-
+
virtual bool IsTaggedPointer (lldb::addr_t addr) { return false; }
protected:
@@ -128,4 +132,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_AppleObjCRuntime_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIME_H
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
index 88bfe2ce0203..8202686597ae 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
@@ -1,5 +1,4 @@
-//===-- AppleObjCRuntimeV1.cpp --------------------------------------*- C++
-//-*-===//
+//===-- AppleObjCRuntimeV1.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -13,12 +12,12 @@
#include "clang/AST/Type.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/UtilityFunction.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
@@ -106,8 +105,8 @@ ConstString AppleObjCRuntimeV1::GetPluginName() {
uint32_t AppleObjCRuntimeV1::GetPluginVersion() { return 1; }
BreakpointResolverSP
-AppleObjCRuntimeV1::CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp,
- bool throw_bp) {
+AppleObjCRuntimeV1::CreateExceptionResolver(const BreakpointSP &bkpt,
+ bool catch_bp, bool throw_bp) {
BreakpointResolverSP resolver_sp;
if (throw_bp)
@@ -363,7 +362,7 @@ void AppleObjCRuntimeV1::UpdateISAToDescriptorMapIfNeeded() {
lldb::offset_t offset = addr_size; // Skip prototype
const uint32_t count = data.GetU32(&offset);
const uint32_t num_buckets = data.GetU32(&offset);
- const addr_t buckets_ptr = data.GetPointer(&offset);
+ const addr_t buckets_ptr = data.GetAddress(&offset);
if (m_hash_signature.NeedsUpdate(count, num_buckets, buckets_ptr)) {
m_hash_signature.UpdateSignature(count, num_buckets, buckets_ptr);
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
index 6fdae63d4126..d8725d0f57ce 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_AppleObjCRuntimeV1_h_
-#define liblldb_AppleObjCRuntimeV1_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIMEV1_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIMEV1_H
#include "AppleObjCRuntime.h"
#include "lldb/lldb-private.h"
@@ -113,9 +113,9 @@ public:
DeclVendor *GetDeclVendor() override;
protected:
- lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt,
- bool catch_bp,
- bool throw_bp) override;
+ lldb::BreakpointResolverSP
+ CreateExceptionResolver(const lldb::BreakpointSP &bkpt,
+ bool catch_bp, bool throw_bp) override;
class HashTableSignature {
public:
@@ -153,4 +153,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_AppleObjCRuntimeV1_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIMEV1_H
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index 4015f10c4966..ac9a09394021 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -1,4 +1,4 @@
-//===-- AppleObjCRuntimeV2.cpp ----------------------------------*- C++ -*-===//
+//===-- AppleObjCRuntimeV2.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -15,12 +15,11 @@
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h"
-#include "lldb/Core/ClangForward.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/lldb-enumerations.h"
-#include "lldb/Core/ClangForward.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
@@ -35,7 +34,6 @@
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionValueBoolean.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/TypeList.h"
@@ -64,6 +62,7 @@
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h"
+#include "clang/Basic/TargetInfo.h"
#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
@@ -582,8 +581,8 @@ protected:
case 0:
break;
case 1: {
- regex_up.reset(new RegularExpression(
- llvm::StringRef::withNullAsEmpty(command.GetArgumentAtIndex(0))));
+ regex_up = std::make_unique<RegularExpression>(
+ llvm::StringRef::withNullAsEmpty(command.GetArgumentAtIndex(0)));
if (!regex_up->IsValid()) {
result.AppendError(
"invalid argument - please provide a valid regular expression");
@@ -826,8 +825,8 @@ lldb_private::ConstString AppleObjCRuntimeV2::GetPluginName() {
uint32_t AppleObjCRuntimeV2::GetPluginVersion() { return 1; }
BreakpointResolverSP
-AppleObjCRuntimeV2::CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp,
- bool throw_bp) {
+AppleObjCRuntimeV2::CreateExceptionResolver(const BreakpointSP &bkpt,
+ bool catch_bp, bool throw_bp) {
BreakpointResolverSP resolver_sp;
if (throw_bp)
@@ -897,12 +896,12 @@ size_t AppleObjCRuntimeV2::GetByteOffsetForIvar(CompilerType &parent_ast_type,
const char *ivar_name) {
uint32_t ivar_offset = LLDB_INVALID_IVAR_OFFSET;
- const char *class_name = parent_ast_type.GetConstTypeName().AsCString();
- if (class_name && class_name[0] && ivar_name && ivar_name[0]) {
+ ConstString class_name = parent_ast_type.GetTypeName();
+ if (!class_name.IsEmpty() && ivar_name && ivar_name[0]) {
// Make the objective C V2 mangled name for the ivar offset from the class
// name and ivar name
std::string buffer("OBJC_IVAR_$_");
- buffer.append(class_name);
+ buffer.append(class_name.AsCString());
buffer.push_back('.');
buffer.append(ivar_name);
ConstString ivar_const_str(buffer.c_str());
@@ -1176,6 +1175,28 @@ AppleObjCRuntimeV2::GetClassDescriptorFromISA(ObjCISA isa) {
return class_descriptor_sp;
}
+static std::pair<bool, ConstString> ObjCGetClassNameRaw(
+ AppleObjCRuntime::ObjCISA isa,
+ Process *process) {
+ StreamString expr_string;
+ std::string input = std::to_string(isa);
+ expr_string.Printf("(const char *)objc_debug_class_getNameRaw(%s)",
+ input.c_str());
+
+ ValueObjectSP result_sp;
+ EvaluateExpressionOptions eval_options;
+ eval_options.SetLanguage(lldb::eLanguageTypeObjC);
+ eval_options.SetResultIsInternal(true);
+ eval_options.SetGenerateDebugInfo(true);
+ eval_options.SetTimeout(process->GetUtilityExpressionTimeout());
+ auto eval_result = process->GetTarget().EvaluateExpression(
+ expr_string.GetData(),
+ process->GetThreadList().GetSelectedThread()->GetSelectedFrame().get(),
+ result_sp, eval_options);
+ ConstString type_name(result_sp->GetSummaryAsCString());
+ return std::make_pair(eval_result == eExpressionCompleted, type_name);
+}
+
ObjCLanguageRuntime::ClassDescriptorSP
AppleObjCRuntimeV2::GetClassDescriptor(ValueObject &valobj) {
ClassDescriptorSP objc_class_sp;
@@ -1192,32 +1213,43 @@ AppleObjCRuntimeV2::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.GetCompilerType().IsValid()) {
- addr_t isa_pointer = valobj.GetPointerValue();
+ if (!valobj.GetCompilerType().IsValid())
+ return objc_class_sp;
+ addr_t isa_pointer = valobj.GetPointerValue();
- // tagged pointer
- if (IsTaggedPointer(isa_pointer)) {
- return m_tagged_pointer_vendor_up->GetClassDescriptor(isa_pointer);
- } else {
- ExecutionContext exe_ctx(valobj.GetExecutionContextRef());
+ // tagged pointer
+ if (IsTaggedPointer(isa_pointer))
+ return m_tagged_pointer_vendor_up->GetClassDescriptor(isa_pointer);
+ ExecutionContext exe_ctx(valobj.GetExecutionContextRef());
- Process *process = exe_ctx.GetProcessPtr();
- if (process) {
- Status error;
- ObjCISA isa = process->ReadPointerFromMemory(isa_pointer, error);
- if (isa != LLDB_INVALID_ADDRESS) {
- objc_class_sp = GetClassDescriptorFromISA(isa);
- if (isa && !objc_class_sp) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- LLDB_LOGF(log,
- "0x%" PRIx64
- ": AppleObjCRuntimeV2::GetClassDescriptor() ISA was "
- "not in class descriptor cache 0x%" PRIx64,
- isa_pointer, isa);
- }
- }
- }
- }
+ Process *process = exe_ctx.GetProcessPtr();
+ if (!process)
+ return objc_class_sp;
+
+ Status error;
+ ObjCISA isa = process->ReadPointerFromMemory(isa_pointer, error);
+ if (isa == LLDB_INVALID_ADDRESS)
+ return objc_class_sp;
+
+ objc_class_sp = GetClassDescriptorFromISA(isa);
+
+ if (objc_class_sp)
+ return objc_class_sp;
+ else {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS |
+ LIBLLDB_LOG_TYPES));
+ LLDB_LOGF(log,
+ "0x%" PRIx64
+ ": AppleObjCRuntimeV2::GetClassDescriptor() ISA was "
+ "not in class descriptor cache 0x%" PRIx64,
+ isa_pointer, isa);
+ }
+
+ ClassDescriptorSP descriptor_sp(new ClassDescriptorV2(*this, isa, nullptr));
+ auto resolved = ObjCGetClassNameRaw(isa, process);
+ if (resolved.first == true) {
+ AddClass(isa, descriptor_sp, resolved.second.AsCString());
+ objc_class_sp = descriptor_sp;
}
return objc_class_sp;
}
@@ -1301,7 +1333,7 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic(
return DescriptorMapUpdateResult::Fail();
thread_sp->CalculateExecutionContext(exe_ctx);
- ClangASTContext *ast = ClangASTContext::GetScratch(process->GetTarget());
+ TypeSystemClang *ast = TypeSystemClang::GetScratch(process->GetTarget());
if (!ast)
return DescriptorMapUpdateResult::Fail();
@@ -1434,8 +1466,6 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic(
Value return_value;
return_value.SetValueType(Value::eValueTypeScalar);
- // return_value.SetContext (Value::eContextTypeClangType,
- // clang_uint32_t_type);
return_value.SetCompilerType(clang_uint32_t_type);
return_value.GetScalar() = 0;
@@ -1499,7 +1529,7 @@ uint32_t AppleObjCRuntimeV2::ParseClassInfoArray(const DataExtractor &data,
// Iterate through all ClassInfo structures
lldb::offset_t offset = 0;
for (uint32_t i = 0; i < num_class_infos; ++i) {
- ObjCISA isa = data.GetPointer(&offset);
+ ObjCISA isa = data.GetAddress(&offset);
if (isa == 0) {
if (should_log)
@@ -1563,7 +1593,7 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() {
return DescriptorMapUpdateResult::Fail();
thread_sp->CalculateExecutionContext(exe_ctx);
- ClangASTContext *ast = ClangASTContext::GetScratch(process->GetTarget());
+ TypeSystemClang *ast = TypeSystemClang::GetScratch(process->GetTarget());
if (!ast)
return DescriptorMapUpdateResult::Fail();
@@ -1660,13 +1690,11 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() {
// Next make the function caller for our implementation utility function.
Value value;
value.SetValueType(Value::eValueTypeScalar);
- // value.SetContext (Value::eContextTypeClangType, clang_void_pointer_type);
value.SetCompilerType(clang_void_pointer_type);
arguments.PushValue(value);
arguments.PushValue(value);
value.SetValueType(Value::eValueTypeScalar);
- // value.SetContext (Value::eContextTypeClangType, clang_uint32_t_type);
value.SetCompilerType(clang_uint32_t_type);
arguments.PushValue(value);
arguments.PushValue(value);
@@ -1732,8 +1760,6 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() {
Value return_value;
return_value.SetValueType(Value::eValueTypeScalar);
- // return_value.SetContext (Value::eContextTypeClangType,
- // clang_uint32_t_type);
return_value.SetCompilerType(clang_uint32_t_type);
return_value.GetScalar() = 0;
@@ -1980,7 +2006,7 @@ void AppleObjCRuntimeV2::WarnIfNoClassesCached(
DeclVendor *AppleObjCRuntimeV2::GetDeclVendor() {
if (!m_decl_vendor_up)
- m_decl_vendor_up.reset(new AppleObjCDeclVendor(*this));
+ m_decl_vendor_up = std::make_unique<AppleObjCDeclVendor>(*this);
return m_decl_vendor_up.get();
}
@@ -2477,7 +2503,7 @@ bool AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA(
ObjCISA isa, ObjCISA &ret_isa) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES));
- LLDB_LOGF(log, "AOCRT::NPI Evalulate(isa = 0x%" PRIx64 ")", (uint64_t)isa);
+ LLDB_LOGF(log, "AOCRT::NPI Evaluate(isa = 0x%" PRIx64 ")", (uint64_t)isa);
if ((isa & ~m_objc_debug_isa_class_mask) == 0)
return false;
@@ -2550,7 +2576,7 @@ bool AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA(
lldb::offset_t offset = 0;
for (unsigned i = 0; i != num_new_classes; ++i)
- m_indexed_isa_cache.push_back(data.GetPointer(&offset));
+ m_indexed_isa_cache.push_back(data.GetAddress(&offset));
}
}
@@ -2558,7 +2584,7 @@ bool AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA(
if (index > m_indexed_isa_cache.size())
return false;
- LLDB_LOGF(log, "AOCRT::NPI Evalulate(ret_isa = 0x%" PRIx64 ")",
+ LLDB_LOGF(log, "AOCRT::NPI Evaluate(ret_isa = 0x%" PRIx64 ")",
(uint64_t)m_indexed_isa_cache[index]);
ret_isa = m_indexed_isa_cache[index];
@@ -2642,8 +2668,8 @@ class ObjCExceptionRecognizedStackFrame : public RecognizedStackFrame {
const lldb::ABISP &abi = process_sp->GetABI();
if (!abi) return;
- ClangASTContext *clang_ast_context =
- ClangASTContext::GetScratch(process_sp->GetTarget());
+ TypeSystemClang *clang_ast_context =
+ TypeSystemClang::GetScratch(process_sp->GetTarget());
if (!clang_ast_context)
return;
CompilerType voidstar =
@@ -2668,6 +2694,8 @@ class ObjCExceptionRecognizedStackFrame : public RecognizedStackFrame {
m_arguments = ValueObjectListSP(new ValueObjectList());
m_arguments->Append(exception);
+
+ m_stop_desc = "hit Objective-C exception";
}
ValueObjectSP exception;
@@ -2689,8 +2717,10 @@ static void RegisterObjCExceptionRecognizer() {
FileSpec module;
ConstString function;
std::tie(module, function) = AppleObjCRuntime::GetExceptionThrowLocation();
+ std::vector<ConstString> symbols = {function};
StackFrameRecognizerManager::AddRecognizer(
StackFrameRecognizerSP(new ObjCExceptionThrowFrameRecognizer()),
- module.GetFilename(), function, /*first_instruction_only*/ true);
+ module.GetFilename(), symbols,
+ /*first_instruction_only*/ true);
});
}
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
index 785bb3938d2c..99264d556da5 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_AppleObjCRuntimeV2_h_
-#define liblldb_AppleObjCRuntimeV2_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIMEV2_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIMEV2_H
#include <map>
#include <memory>
@@ -103,9 +103,9 @@ public:
static const ObjCLanguageRuntime::ObjCISA g_objc_Tagged_ISA_NSDate = 6;
protected:
- lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt,
- bool catch_bp,
- bool throw_bp) override;
+ lldb::BreakpointResolverSP
+ CreateExceptionResolver(const lldb::BreakpointSP &bkpt,
+ bool catch_bp, bool throw_bp) override;
private:
class HashTableSignature {
@@ -162,7 +162,8 @@ private:
friend class AppleObjCRuntimeV2;
- DISALLOW_COPY_AND_ASSIGN(NonPointerISACache);
+ NonPointerISACache(const NonPointerISACache &) = delete;
+ const NonPointerISACache &operator=(const NonPointerISACache &) = delete;
};
class TaggedPointerVendorV2
@@ -181,7 +182,9 @@ private:
: TaggedPointerVendor(), m_runtime(runtime) {}
private:
- DISALLOW_COPY_AND_ASSIGN(TaggedPointerVendorV2);
+ TaggedPointerVendorV2(const TaggedPointerVendorV2 &) = delete;
+ const TaggedPointerVendorV2 &
+ operator=(const TaggedPointerVendorV2 &) = delete;
};
class TaggedPointerVendorRuntimeAssisted : public TaggedPointerVendorV2 {
@@ -212,7 +215,10 @@ private:
friend class AppleObjCRuntimeV2::TaggedPointerVendorV2;
- DISALLOW_COPY_AND_ASSIGN(TaggedPointerVendorRuntimeAssisted);
+ TaggedPointerVendorRuntimeAssisted(
+ const TaggedPointerVendorRuntimeAssisted &) = delete;
+ const TaggedPointerVendorRuntimeAssisted &
+ operator=(const TaggedPointerVendorRuntimeAssisted &) = delete;
};
class TaggedPointerVendorExtended
@@ -250,7 +256,9 @@ private:
friend class AppleObjCRuntimeV2::TaggedPointerVendorV2;
- DISALLOW_COPY_AND_ASSIGN(TaggedPointerVendorExtended);
+ TaggedPointerVendorExtended(const TaggedPointerVendorExtended &) = delete;
+ const TaggedPointerVendorExtended &
+ operator=(const TaggedPointerVendorExtended &) = delete;
};
class TaggedPointerVendorLegacy : public TaggedPointerVendorV2 {
@@ -266,7 +274,9 @@ private:
friend class AppleObjCRuntimeV2::TaggedPointerVendorV2;
- DISALLOW_COPY_AND_ASSIGN(TaggedPointerVendorLegacy);
+ TaggedPointerVendorLegacy(const TaggedPointerVendorLegacy &) = delete;
+ const TaggedPointerVendorLegacy &
+ operator=(const TaggedPointerVendorLegacy &) = delete;
};
struct DescriptorMapUpdateResult {
@@ -337,4 +347,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_AppleObjCRuntimeV2_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCRUNTIMEV2_H
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
index 36f95c063b81..c96768c9f585 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
@@ -1,5 +1,4 @@
-//===-- AppleObjCTrampolineHandler.cpp ----------------------------*- C++
-//-*-===//
+//===-- AppleObjCTrampolineHandler.cpp ------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,6 +9,7 @@
#include "AppleObjCTrampolineHandler.h"
#include "AppleThreadPlanStepThroughObjCTrampoline.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
@@ -19,7 +19,6 @@
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/UserExpression.h"
#include "lldb/Expression/UtilityFunction.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/ExecutionContext.h"
@@ -319,7 +318,7 @@ void AppleObjCTrampolineHandler::AppleObjCVTables::VTableRegion::SetUpRegion() {
const uint16_t descriptor_size = data.GetU16(&offset);
const size_t num_descriptors = data.GetU32(&offset);
- m_next_region = data.GetPointer(&offset);
+ m_next_region = data.GetAddress(&offset);
// If the header size is 0, that means we've come in too early before this
// data is set up.
@@ -521,8 +520,8 @@ bool AppleObjCTrampolineHandler::AppleObjCVTables::RefreshTrampolines(
Process *process = exe_ctx.GetProcessPtr();
const ABI *abi = process->GetABI().get();
- ClangASTContext *clang_ast_context =
- ClangASTContext::GetScratch(process->GetTarget());
+ TypeSystemClang *clang_ast_context =
+ TypeSystemClang::GetScratch(process->GetTarget());
if (!clang_ast_context)
return false;
@@ -548,7 +547,7 @@ bool AppleObjCTrampolineHandler::AppleObjCVTables::RefreshTrampolines(
error = argument_values.GetValueAtIndex(0)->GetValueAsData(&exe_ctx, data,
nullptr);
lldb::offset_t offset = 0;
- lldb::addr_t region_addr = data.GetPointer(&offset);
+ lldb::addr_t region_addr = data.GetAddress(&offset);
if (region_addr != 0)
vtable_handler->ReadRegions(region_addr);
@@ -657,6 +656,27 @@ const AppleObjCTrampolineHandler::DispatchFunction
DispatchFunction::eFixUpFixed},
};
+// This is the table of ObjC "accelerated dispatch" functions. They are a set
+// of objc methods that are "seldom overridden" and so the compiler replaces the
+// objc_msgSend with a call to one of the dispatch functions. That will check
+// whether the method has been overridden, and directly call the Foundation
+// implementation if not.
+// This table is supposed to be complete. If ones get added in the future, we
+// will have to add them to the table.
+const char *AppleObjCTrampolineHandler::g_opt_dispatch_names[] = {
+ "objc_alloc",
+ "objc_autorelease",
+ "objc_release",
+ "objc_retain",
+ "objc_alloc_init",
+ "objc_allocWithZone",
+ "objc_opt_class",
+ "objc_opt_isKindOfClass",
+ "objc_opt_new",
+ "objc_opt_respondsToSelector",
+ "objc_opt_self",
+};
+
AppleObjCTrampolineHandler::AppleObjCTrampolineHandler(
const ProcessSP &process_sp, const ModuleSP &objc_module_sp)
: m_process_wp(), m_objc_module_sp(objc_module_sp),
@@ -751,9 +771,24 @@ AppleObjCTrampolineHandler::AppleObjCTrampolineHandler(
m_msgSend_map.insert(std::pair<lldb::addr_t, int>(sym_addr, i));
}
}
+
+ // Similarly, cache the addresses of the "optimized dispatch" function.
+ for (size_t i = 0; i != llvm::array_lengthof(g_opt_dispatch_names); i++) {
+ ConstString name_const_str(g_opt_dispatch_names[i]);
+ const Symbol *msgSend_symbol =
+ m_objc_module_sp->FindFirstSymbolWithNameAndType(name_const_str,
+ eSymbolTypeCode);
+ if (msgSend_symbol && msgSend_symbol->ValueIsAddress()) {
+ lldb::addr_t sym_addr =
+ msgSend_symbol->GetAddressRef().GetOpcodeLoadAddress(target);
+
+ m_opt_dispatch_map.emplace(sym_addr, i);
+ }
+ }
// Build our vtable dispatch handler here:
- m_vtables_up.reset(new AppleObjCVTables(process_sp, m_objc_module_sp));
+ m_vtables_up =
+ std::make_unique<AppleObjCVTables>(process_sp, m_objc_module_sp);
if (m_vtables_up)
m_vtables_up->ReadRegions();
}
@@ -804,8 +839,8 @@ AppleObjCTrampolineHandler::SetupDispatchFunction(Thread &thread,
}
// Next make the runner function for our implementation utility function.
- ClangASTContext *clang_ast_context =
- ClangASTContext::GetScratch(thread.GetProcess()->GetTarget());
+ TypeSystemClang *clang_ast_context =
+ TypeSystemClang::GetScratch(thread.GetProcess()->GetTarget());
if (!clang_ast_context)
return LLDB_INVALID_ADDRESS;
@@ -846,45 +881,53 @@ AppleObjCTrampolineHandler::SetupDispatchFunction(Thread &thread,
return args_addr;
}
+const AppleObjCTrampolineHandler::DispatchFunction *
+AppleObjCTrampolineHandler::FindDispatchFunction(lldb::addr_t addr) {
+ MsgsendMap::iterator pos;
+ pos = m_msgSend_map.find(addr);
+ if (pos != m_msgSend_map.end()) {
+ return &g_dispatch_functions[(*pos).second];
+ }
+ return nullptr;
+}
+
+void
+AppleObjCTrampolineHandler::ForEachDispatchFunction(
+ std::function<void(lldb::addr_t,
+ const DispatchFunction &)> callback) {
+ for (auto elem : m_msgSend_map) {
+ callback(elem.first, g_dispatch_functions[elem.second]);
+ }
+}
+
ThreadPlanSP
AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread,
bool stop_others) {
ThreadPlanSP ret_plan_sp;
lldb::addr_t curr_pc = thread.GetRegisterContext()->GetPC();
- DispatchFunction this_dispatch;
- bool found_it = false;
+ DispatchFunction vtable_dispatch
+ = {"vtable", 0, false, false, DispatchFunction::eFixUpFixed};
// First step is to look and see if we are in one of the known ObjC
// dispatch functions. We've already compiled a table of same, so
// consult it.
- MsgsendMap::iterator pos;
- pos = m_msgSend_map.find(curr_pc);
- if (pos != m_msgSend_map.end()) {
- this_dispatch = g_dispatch_functions[(*pos).second];
- found_it = true;
- }
-
+ const DispatchFunction *this_dispatch = FindDispatchFunction(curr_pc);
+
// Next check to see if we are in a vtable region:
- if (!found_it) {
+ if (!this_dispatch && m_vtables_up) {
uint32_t flags;
- if (m_vtables_up) {
- found_it = m_vtables_up->IsAddressInVTables(curr_pc, flags);
- if (found_it) {
- this_dispatch.name = "vtable";
- this_dispatch.stret_return =
- (flags & AppleObjCVTables::eOBJC_TRAMPOLINE_STRET) ==
- AppleObjCVTables::eOBJC_TRAMPOLINE_STRET;
- this_dispatch.is_super = false;
- this_dispatch.is_super2 = false;
- this_dispatch.fixedup = DispatchFunction::eFixUpFixed;
- }
+ if (m_vtables_up->IsAddressInVTables(curr_pc, flags)) {
+ vtable_dispatch.stret_return =
+ (flags & AppleObjCVTables::eOBJC_TRAMPOLINE_STRET) ==
+ AppleObjCVTables::eOBJC_TRAMPOLINE_STRET;
+ this_dispatch = &vtable_dispatch;
}
}
- if (found_it) {
+ if (this_dispatch) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
// We are decoding a method dispatch. First job is to pull the
@@ -901,7 +944,7 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread,
TargetSP target_sp(thread.CalculateTarget());
- ClangASTContext *clang_ast_context = ClangASTContext::GetScratch(*target_sp);
+ TypeSystemClang *clang_ast_context = TypeSystemClang::GetScratch(*target_sp);
if (!clang_ast_context)
return ret_plan_sp;
@@ -921,7 +964,7 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread,
// the return struct pointer, and the object is the second, and
// the selector is the third. Otherwise the object is the first
// and the selector the second.
- if (this_dispatch.stret_return) {
+ if (this_dispatch->stret_return) {
obj_index = 1;
sel_index = 2;
argument_values.PushValue(void_ptr_value);
@@ -963,8 +1006,8 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread,
// run-to-address plan directly. Otherwise we have to figure out
// where the implementation lives.
- if (this_dispatch.is_super) {
- if (this_dispatch.is_super2) {
+ if (this_dispatch->is_super) {
+ if (this_dispatch->is_super2) {
// In the objc_msgSendSuper2 case, we don't get the object
// directly, we get a structure containing the object and the
// class to which the super message is being sent. So we need
@@ -1087,25 +1130,25 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread,
// flag_value.SetContext (Value::eContextTypeClangType, clang_int_type);
flag_value.SetCompilerType(clang_int_type);
- if (this_dispatch.stret_return)
+ if (this_dispatch->stret_return)
flag_value.GetScalar() = 1;
else
flag_value.GetScalar() = 0;
dispatch_values.PushValue(flag_value);
- if (this_dispatch.is_super)
+ if (this_dispatch->is_super)
flag_value.GetScalar() = 1;
else
flag_value.GetScalar() = 0;
dispatch_values.PushValue(flag_value);
- if (this_dispatch.is_super2)
+ if (this_dispatch->is_super2)
flag_value.GetScalar() = 1;
else
flag_value.GetScalar() = 0;
dispatch_values.PushValue(flag_value);
- switch (this_dispatch.fixedup) {
+ switch (this_dispatch->fixedup) {
case DispatchFunction::eFixUpNone:
flag_value.GetScalar() = 0;
dispatch_values.PushValue(flag_value);
@@ -1135,7 +1178,7 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread,
// stop_others value passed in to us here:
const bool trampoline_stop_others = false;
ret_plan_sp = std::make_shared<AppleThreadPlanStepThroughObjCTrampoline>(
- thread, this, dispatch_values, isa_addr, sel_addr,
+ thread, *this, dispatch_values, isa_addr, sel_addr,
trampoline_stop_others);
if (log) {
StreamString s;
@@ -1144,6 +1187,26 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread,
}
}
}
+
+ // Finally, check if we have hit an "optimized dispatch" function. This will
+ // either directly call the base implementation or dispatch an objc_msgSend
+ // if the method has been overridden. So we just do a "step in/step out",
+ // setting a breakpoint on objc_msgSend, and if we hit the msgSend, we
+ // will automatically step in again. That's the job of the
+ // AppleThreadPlanStepThroughDirectDispatch.
+ if (!this_dispatch && !ret_plan_sp) {
+ MsgsendMap::iterator pos;
+ pos = m_opt_dispatch_map.find(curr_pc);
+ if (pos != m_opt_dispatch_map.end()) {
+
+ const char *opt_name = g_opt_dispatch_names[(*pos).second];
+
+ bool trampoline_stop_others = false;
+ LazyBool step_in_should_stop = eLazyBoolCalculate;
+ ret_plan_sp = std::make_shared<AppleThreadPlanStepThroughDirectDispatch> (
+ thread, *this, opt_name, trampoline_stop_others, step_in_should_stop);
+ }
+ }
return ret_plan_sp;
}
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h
index d120d671eeb3..27aebd8594df 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_AppleObjCTrampolineHandler_h_
-#define lldb_AppleObjCTrampolineHandler_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCTRAMPOLINEHANDLER_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCTRAMPOLINEHANDLER_H
#include <map>
#include <mutex>
@@ -47,6 +47,9 @@ public:
lldb::addr_t SetupDispatchFunction(Thread &thread,
ValueList &dispatch_values);
+ const DispatchFunction *FindDispatchFunction(lldb::addr_t addr);
+ void ForEachDispatchFunction(std::function<void(lldb::addr_t,
+ const DispatchFunction &)>);
private:
static const char *g_lookup_implementation_function_name;
@@ -96,7 +99,6 @@ private:
void Dump(Stream &s);
- public:
bool m_valid;
AppleObjCVTables *m_owner;
lldb::addr_t m_header_addr;
@@ -136,11 +138,13 @@ private:
};
static const DispatchFunction g_dispatch_functions[];
+ static const char *g_opt_dispatch_names[];
- typedef std::map<lldb::addr_t, int> MsgsendMap; // This table maps an dispatch
+ using MsgsendMap = std::map<lldb::addr_t, int>; // This table maps an dispatch
// fn address to the index in
// g_dispatch_functions
MsgsendMap m_msgSend_map;
+ MsgsendMap m_opt_dispatch_map;
lldb::ProcessWP m_process_wp;
lldb::ModuleSP m_objc_module_sp;
const char *m_lookup_implementation_function_code;
@@ -155,4 +159,4 @@ private:
} // namespace lldb_private
-#endif // lldb_AppleObjCTrampolineHandler_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCTRAMPOLINEHANDLER_H
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
index 66f04bef6cbd..b19d3d90d4b7 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
@@ -1,4 +1,4 @@
-//===-- AppleObjCTypeEncodingParser.cpp -------------------------*- C++ -*-===//
+//===-- AppleObjCTypeEncodingParser.cpp -----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,13 +8,15 @@
#include "AppleObjCTypeEncodingParser.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangUtil.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/StringLexer.h"
+#include "clang/Basic/TargetInfo.h"
+
#include <vector>
using namespace lldb_private;
@@ -23,17 +25,16 @@ AppleObjCTypeEncodingParser::AppleObjCTypeEncodingParser(
ObjCLanguageRuntime &runtime)
: ObjCLanguageRuntime::EncodingToType(), m_runtime(runtime) {
if (!m_scratch_ast_ctx_up)
- m_scratch_ast_ctx_up.reset(new ClangASTContext(runtime.GetProcess()
- ->GetTarget()
- .GetArchitecture()
- .GetTriple()));
+ m_scratch_ast_ctx_up = std::make_unique<TypeSystemClang>(
+ "AppleObjCTypeEncodingParser ASTContext",
+ runtime.GetProcess()->GetTarget().GetArchitecture().GetTriple());
}
std::string AppleObjCTypeEncodingParser::ReadStructName(StringLexer &type) {
StreamString buffer;
while (type.HasAtLeast(1) && type.Peek() != '=')
buffer.Printf("%c", type.Next());
- return buffer.GetString();
+ return std::string(buffer.GetString());
}
std::string AppleObjCTypeEncodingParser::ReadQuotedString(StringLexer &type) {
@@ -43,7 +44,7 @@ std::string AppleObjCTypeEncodingParser::ReadQuotedString(StringLexer &type) {
StringLexer::Character next = type.Next();
UNUSED_IF_ASSERT_DISABLED(next);
assert(next == '"');
- return buffer.GetString();
+ return std::string(buffer.GetString());
}
uint32_t AppleObjCTypeEncodingParser::ReadNumber(StringLexer &type) {
@@ -61,7 +62,7 @@ AppleObjCTypeEncodingParser::StructElement::StructElement()
: name(""), type(clang::QualType()), bitfield(0) {}
AppleObjCTypeEncodingParser::StructElement
-AppleObjCTypeEncodingParser::ReadStructElement(ClangASTContext &ast_ctx,
+AppleObjCTypeEncodingParser::ReadStructElement(TypeSystemClang &ast_ctx,
StringLexer &type,
bool for_expression) {
StructElement retval;
@@ -76,19 +77,19 @@ AppleObjCTypeEncodingParser::ReadStructElement(ClangASTContext &ast_ctx,
}
clang::QualType AppleObjCTypeEncodingParser::BuildStruct(
- ClangASTContext &ast_ctx, StringLexer &type, bool for_expression) {
+ TypeSystemClang &ast_ctx, StringLexer &type, bool for_expression) {
return BuildAggregate(ast_ctx, type, for_expression, '{', '}',
clang::TTK_Struct);
}
clang::QualType AppleObjCTypeEncodingParser::BuildUnion(
- ClangASTContext &ast_ctx, StringLexer &type, bool for_expression) {
+ TypeSystemClang &ast_ctx, StringLexer &type, bool for_expression) {
return BuildAggregate(ast_ctx, type, for_expression, '(', ')',
clang::TTK_Union);
}
clang::QualType AppleObjCTypeEncodingParser::BuildAggregate(
- ClangASTContext &ast_ctx, StringLexer &type, bool for_expression,
+ TypeSystemClang &ast_ctx, StringLexer &type, bool for_expression,
char opener, char closer, uint32_t kind) {
if (!type.NextIf(opener))
return clang::QualType();
@@ -123,29 +124,30 @@ clang::QualType AppleObjCTypeEncodingParser::BuildAggregate(
return clang::QualType(); // This is where we bail out. Sorry!
CompilerType union_type(ast_ctx.CreateRecordType(
- nullptr, lldb::eAccessPublic, name, kind, lldb::eLanguageTypeC));
+ nullptr, OptionalClangModuleID(), lldb::eAccessPublic, name, kind,
+ lldb::eLanguageTypeC));
if (union_type) {
- ClangASTContext::StartTagDeclarationDefinition(union_type);
+ TypeSystemClang::StartTagDeclarationDefinition(union_type);
unsigned int count = 0;
for (auto element : elements) {
if (element.name.empty()) {
StreamString elem_name;
elem_name.Printf("__unnamed_%u", count);
- element.name = elem_name.GetString();
+ element.name = std::string(elem_name.GetString());
}
- ClangASTContext::AddFieldToRecordType(
+ TypeSystemClang::AddFieldToRecordType(
union_type, element.name.c_str(), ast_ctx.GetType(element.type),
lldb::eAccessPublic, element.bitfield);
++count;
}
- ClangASTContext::CompleteTagDeclarationDefinition(union_type);
+ TypeSystemClang::CompleteTagDeclarationDefinition(union_type);
}
return ClangUtil::GetQualType(union_type);
}
clang::QualType AppleObjCTypeEncodingParser::BuildArray(
- ClangASTContext &ast_ctx, StringLexer &type, bool for_expression) {
+ TypeSystemClang &ast_ctx, StringLexer &type, bool for_expression) {
if (!type.NextIf('['))
return clang::QualType();
uint32_t size = ReadNumber(type);
@@ -163,7 +165,7 @@ clang::QualType AppleObjCTypeEncodingParser::BuildArray(
// consume but ignore the type info and always return an 'id'; if anything,
// dynamic typing will resolve things for us anyway
clang::QualType AppleObjCTypeEncodingParser::BuildObjCObjectPointerType(
- ClangASTContext &clang_ast_ctx, StringLexer &type, bool for_expression) {
+ TypeSystemClang &clang_ast_ctx, StringLexer &type, bool for_expression) {
if (!type.NextIf('@'))
return clang::QualType();
@@ -247,7 +249,7 @@ clang::QualType AppleObjCTypeEncodingParser::BuildObjCObjectPointerType(
}
clang::QualType
-AppleObjCTypeEncodingParser::BuildType(ClangASTContext &clang_ast_ctx,
+AppleObjCTypeEncodingParser::BuildType(TypeSystemClang &clang_ast_ctx,
StringLexer &type, bool for_expression,
uint32_t *bitfield_bit_size) {
if (!type.HasAtLeast(1))
@@ -353,7 +355,7 @@ AppleObjCTypeEncodingParser::BuildType(ClangASTContext &clang_ast_ctx,
}
}
-CompilerType AppleObjCTypeEncodingParser::RealizeType(ClangASTContext &ast_ctx,
+CompilerType AppleObjCTypeEncodingParser::RealizeType(TypeSystemClang &ast_ctx,
const char *name,
bool for_expression) {
if (name && name[0]) {
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h
index e43711bf4ee4..9a108967e1ab 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_AppleObjCTypeEncodingParser_h_
-#define liblldb_AppleObjCTypeEncodingParser_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCTYPEENCODINGPARSER_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCTYPEENCODINGPARSER_H
#include "clang/AST/ASTContext.h"
@@ -22,7 +22,7 @@ public:
AppleObjCTypeEncodingParser(ObjCLanguageRuntime &runtime);
~AppleObjCTypeEncodingParser() override = default;
- CompilerType RealizeType(ClangASTContext &ast_ctx, const char *name,
+ CompilerType RealizeType(TypeSystemClang &ast_ctx, const char *name,
bool for_expression) override;
private:
@@ -35,29 +35,29 @@ private:
~StructElement() = default;
};
- clang::QualType BuildType(ClangASTContext &clang_ast_ctx, StringLexer &type,
+ clang::QualType BuildType(TypeSystemClang &clang_ast_ctx, StringLexer &type,
bool for_expression,
uint32_t *bitfield_bit_size = nullptr);
- clang::QualType BuildStruct(ClangASTContext &ast_ctx, StringLexer &type,
+ clang::QualType BuildStruct(TypeSystemClang &ast_ctx, StringLexer &type,
bool for_expression);
- clang::QualType BuildAggregate(ClangASTContext &clang_ast_ctx,
+ clang::QualType BuildAggregate(TypeSystemClang &clang_ast_ctx,
StringLexer &type, bool for_expression,
char opener, char closer, uint32_t kind);
- clang::QualType BuildUnion(ClangASTContext &ast_ctx, StringLexer &type,
+ clang::QualType BuildUnion(TypeSystemClang &ast_ctx, StringLexer &type,
bool for_expression);
- clang::QualType BuildArray(ClangASTContext &ast_ctx, StringLexer &type,
+ clang::QualType BuildArray(TypeSystemClang &ast_ctx, StringLexer &type,
bool for_expression);
std::string ReadStructName(StringLexer &type);
- StructElement ReadStructElement(ClangASTContext &ast_ctx, StringLexer &type,
+ StructElement ReadStructElement(TypeSystemClang &ast_ctx, StringLexer &type,
bool for_expression);
- clang::QualType BuildObjCObjectPointerType(ClangASTContext &clang_ast_ctx,
+ clang::QualType BuildObjCObjectPointerType(TypeSystemClang &clang_ast_ctx,
StringLexer &type,
bool for_expression);
@@ -70,4 +70,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_AppleObjCTypeEncodingParser_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLEOBJCTYPEENCODINGPARSER_H
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
index af630eee7265..653e007c7b5f 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
@@ -1,4 +1,4 @@
-//===-- AppleThreadPlanStepThroughObjCTrampoline.cpp
+//===-- AppleThreadPlanStepThroughObjCTrampoline.cpp-----------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -29,7 +29,7 @@ using namespace lldb_private;
// ThreadPlanStepThroughObjCTrampoline constructor
AppleThreadPlanStepThroughObjCTrampoline::
AppleThreadPlanStepThroughObjCTrampoline(
- Thread &thread, AppleObjCTrampolineHandler *trampoline_handler,
+ Thread &thread, AppleObjCTrampolineHandler &trampoline_handler,
ValueList &input_values, lldb::addr_t isa_addr, lldb::addr_t sel_addr,
bool stop_others)
: ThreadPlan(ThreadPlan::eKindGeneric,
@@ -48,31 +48,30 @@ void AppleThreadPlanStepThroughObjCTrampoline::DidPush() {
// Setting up the memory space for the called function text might require
// allocations, i.e. a nested function call. This needs to be done as a
// PreResumeAction.
- m_thread.GetProcess()->AddPreResumeAction(PreResumeInitializeFunctionCaller,
- (void *)this);
+ m_process.AddPreResumeAction(PreResumeInitializeFunctionCaller, (void *)this);
}
bool AppleThreadPlanStepThroughObjCTrampoline::InitializeFunctionCaller() {
if (!m_func_sp) {
DiagnosticManager diagnostics;
m_args_addr =
- m_trampoline_handler->SetupDispatchFunction(m_thread, m_input_values);
+ m_trampoline_handler.SetupDispatchFunction(GetThread(), m_input_values);
if (m_args_addr == LLDB_INVALID_ADDRESS) {
return false;
}
m_impl_function =
- m_trampoline_handler->GetLookupImplementationFunctionCaller();
+ m_trampoline_handler.GetLookupImplementationFunctionCaller();
ExecutionContext exc_ctx;
EvaluateExpressionOptions options;
options.SetUnwindOnError(true);
options.SetIgnoreBreakpoints(true);
options.SetStopOthers(m_stop_others);
- m_thread.CalculateExecutionContext(exc_ctx);
+ GetThread().CalculateExecutionContext(exc_ctx);
m_func_sp = m_impl_function->GetThreadPlanToCallFunction(
exc_ctx, m_args_addr, options, diagnostics);
m_func_sp->SetOkayToDiscard(true);
- m_thread.QueueThreadPlan(m_func_sp, false);
+ PushPlan(m_func_sp);
}
return true;
}
@@ -132,7 +131,7 @@ bool AppleThreadPlanStepThroughObjCTrampoline::ShouldStop(Event *event_ptr) {
if (!m_run_to_sp) {
Value target_addr_value;
ExecutionContext exc_ctx;
- m_thread.CalculateExecutionContext(exc_ctx);
+ GetThread().CalculateExecutionContext(exc_ctx);
m_impl_function->FetchFunctionResults(exc_ctx, m_args_addr,
target_addr_value);
m_impl_function->DeallocateFunctionResults(exc_ctx, m_args_addr);
@@ -145,19 +144,19 @@ bool AppleThreadPlanStepThroughObjCTrampoline::ShouldStop(Event *event_ptr) {
SetPlanComplete();
return true;
}
- if (m_trampoline_handler->AddrIsMsgForward(target_addr)) {
+ if (m_trampoline_handler.AddrIsMsgForward(target_addr)) {
LLDB_LOGF(log,
"Implementation lookup returned msgForward function: 0x%" PRIx64
", stopping.",
target_addr);
- SymbolContext sc = m_thread.GetStackFrameAtIndex(0)->GetSymbolContext(
+ SymbolContext sc = GetThread().GetStackFrameAtIndex(0)->GetSymbolContext(
eSymbolContextEverything);
Status status;
const bool abort_other_plans = false;
const bool first_insn = true;
const uint32_t frame_idx = 0;
- m_run_to_sp = m_thread.QueueThreadPlanForStepOutNoShouldStop(
+ m_run_to_sp = GetThread().QueueThreadPlanForStepOutNoShouldStop(
abort_other_plans, &sc, first_insn, m_stop_others, eVoteNoOpinion,
eVoteNoOpinion, frame_idx, status);
if (m_run_to_sp && status.Success())
@@ -180,11 +179,10 @@ bool AppleThreadPlanStepThroughObjCTrampoline::ShouldStop(Event *event_ptr) {
// Extract the target address from the value:
m_run_to_sp = std::make_shared<ThreadPlanRunToAddress>(
- m_thread, target_so_addr, m_stop_others);
- m_thread.QueueThreadPlan(m_run_to_sp, false);
- m_run_to_sp->SetPrivate(true);
+ GetThread(), target_so_addr, m_stop_others);
+ PushPlan(m_run_to_sp);
return false;
- } else if (m_thread.IsThreadPlanDone(m_run_to_sp.get())) {
+ } else if (GetThread().IsThreadPlanDone(m_run_to_sp.get())) {
// Third stage, work the run to target plan.
SetPlanComplete();
return true;
@@ -199,3 +197,227 @@ bool AppleThreadPlanStepThroughObjCTrampoline::MischiefManaged() {
}
bool AppleThreadPlanStepThroughObjCTrampoline::WillStop() { return true; }
+
+// Objective-C uses optimized dispatch functions for some common and seldom
+// overridden methods. For instance
+// [object respondsToSelector:];
+// will get compiled to:
+// objc_opt_respondsToSelector(object);
+// This checks whether the selector has been overridden, directly calling the
+// implementation if it hasn't and calling objc_msgSend if it has.
+//
+// We need to get into the overridden implementation. We'll do that by
+// setting a breakpoint on objc_msgSend, and doing a "step out". If we stop
+// at objc_msgSend, we can step through to the target of the send, and see if
+// that's a place we want to stop.
+//
+// A couple of complexities. The checking code might call some other method,
+// so we might see objc_msgSend more than once. Also, these optimized dispatch
+// functions might dispatch more than one message at a time (e.g. alloc followed
+// by init.) So we can't give up at the first objc_msgSend.
+// That means among other things that we have to handle the "ShouldStopHere" -
+// since we can't just return control to the plan that's controlling us on the
+// first step.
+
+AppleThreadPlanStepThroughDirectDispatch ::
+ AppleThreadPlanStepThroughDirectDispatch(
+ Thread &thread, AppleObjCTrampolineHandler &handler,
+ llvm::StringRef dispatch_func_name, bool stop_others,
+ LazyBool step_in_avoids_code_without_debug_info)
+ : ThreadPlanStepOut(thread, nullptr, true /* first instruction */,
+ stop_others, eVoteNoOpinion, eVoteNoOpinion,
+ 0 /* Step out of zeroth frame */,
+ eLazyBoolNo /* Our parent plan will decide this
+ when we are done */
+ ,
+ true /* Run to branch for inline step out */,
+ false /* Don't gather the return value */),
+ m_trampoline_handler(handler),
+ m_dispatch_func_name(std::string(dispatch_func_name)),
+ m_at_msg_send(false), m_stop_others(stop_others) {
+ // Set breakpoints on the dispatch functions:
+ auto bkpt_callback = [&] (lldb::addr_t addr,
+ const AppleObjCTrampolineHandler
+ ::DispatchFunction &dispatch) {
+ m_msgSend_bkpts.push_back(GetTarget().CreateBreakpoint(addr,
+ true /* internal */,
+ false /* hard */));
+ m_msgSend_bkpts.back()->SetThreadID(GetThread().GetID());
+ };
+ handler.ForEachDispatchFunction(bkpt_callback);
+
+ // We'll set the step-out plan in the DidPush so it gets queued in the right
+ // order.
+
+ bool avoid_nodebug = true;
+
+ switch (step_in_avoids_code_without_debug_info) {
+ case eLazyBoolYes:
+ avoid_nodebug = true;
+ break;
+ case eLazyBoolNo:
+ avoid_nodebug = false;
+ break;
+ case eLazyBoolCalculate:
+ avoid_nodebug = GetThread().GetStepInAvoidsNoDebug();
+ break;
+ }
+ if (avoid_nodebug)
+ GetFlags().Set(ThreadPlanShouldStopHere::eStepInAvoidNoDebug);
+ else
+ GetFlags().Clear(ThreadPlanShouldStopHere::eStepInAvoidNoDebug);
+ // We only care about step in. Our parent plan will figure out what to
+ // do when we've stepped out again.
+ GetFlags().Clear(ThreadPlanShouldStopHere::eStepOutAvoidNoDebug);
+}
+
+AppleThreadPlanStepThroughDirectDispatch::
+ ~AppleThreadPlanStepThroughDirectDispatch() {
+ for (BreakpointSP bkpt_sp : m_msgSend_bkpts) {
+ GetTarget().RemoveBreakpointByID(bkpt_sp->GetID());
+ }
+}
+
+void AppleThreadPlanStepThroughDirectDispatch::GetDescription(
+ Stream *s, lldb::DescriptionLevel level) {
+ switch (level) {
+ case lldb::eDescriptionLevelBrief:
+ s->PutCString("Step through ObjC direct dispatch function.");
+ break;
+ default:
+ s->Printf("Step through ObjC direct dispatch '%s' using breakpoints: ",
+ m_dispatch_func_name.c_str());
+ bool first = true;
+ for (auto bkpt_sp : m_msgSend_bkpts) {
+ if (!first) {
+ s->PutCString(", ");
+ }
+ first = false;
+ s->Printf("%d", bkpt_sp->GetID());
+ }
+ (*s) << ".";
+ break;
+ }
+}
+
+bool
+AppleThreadPlanStepThroughDirectDispatch::DoPlanExplainsStop(Event *event_ptr) {
+ if (ThreadPlanStepOut::DoPlanExplainsStop(event_ptr))
+ return true;
+
+ StopInfoSP stop_info_sp = GetPrivateStopInfo();
+
+ // Check if the breakpoint is one of ours msgSend dispatch breakpoints.
+
+ StopReason stop_reason = eStopReasonNone;
+ if (stop_info_sp)
+ stop_reason = stop_info_sp->GetStopReason();
+
+ // See if this is one of our msgSend breakpoints:
+ if (stop_reason == eStopReasonBreakpoint) {
+ ProcessSP process_sp = GetThread().GetProcess();
+ uint64_t break_site_id = stop_info_sp->GetValue();
+ BreakpointSiteSP site_sp
+ = process_sp->GetBreakpointSiteList().FindByID(break_site_id);
+ // Some other plan might have deleted the site's last owner before this
+ // got to us. In which case, it wasn't our breakpoint...
+ if (!site_sp)
+ return false;
+
+ for (BreakpointSP break_sp : m_msgSend_bkpts) {
+ if (site_sp->IsBreakpointAtThisSite(break_sp->GetID())) {
+ // If we aren't the only one with a breakpoint on this site, then we
+ // should just stop and return control to the user.
+ if (site_sp->GetNumberOfOwners() > 1) {
+ SetPlanComplete(true);
+ return false;
+ }
+ m_at_msg_send = true;
+ return true;
+ }
+ }
+ }
+
+ // We're done here. If one of our sub-plans explained the stop, they
+ // would have already answered true to PlanExplainsStop, and if they were
+ // done, we'll get called to figure out what to do in ShouldStop...
+ return false;
+}
+
+bool AppleThreadPlanStepThroughDirectDispatch
+ ::DoWillResume(lldb::StateType resume_state, bool current_plan) {
+ ThreadPlanStepOut::DoWillResume(resume_state, current_plan);
+ m_at_msg_send = false;
+ return true;
+}
+
+bool AppleThreadPlanStepThroughDirectDispatch::ShouldStop(Event *event_ptr) {
+ // If step out plan finished, that means we didn't find our way into a method
+ // implementation. Either we went directly to the default implementation,
+ // of the overridden implementation didn't have debug info.
+ // So we should mark ourselves as done.
+ const bool step_out_should_stop = ThreadPlanStepOut::ShouldStop(event_ptr);
+ if (step_out_should_stop) {
+ SetPlanComplete(true);
+ return true;
+ }
+
+ // If we have a step through plan, then w're in the process of getting
+ // through an ObjC msgSend. If we arrived at the target function, then
+ // check whether we have debug info, and if we do, stop.
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+ if (m_objc_step_through_sp && m_objc_step_through_sp->IsPlanComplete()) {
+ // If the plan failed for some reason, we should probably just let the
+ // step over plan get us out of here... We don't need to do anything about
+ // the step through plan, it is done and will get popped when we continue.
+ if (!m_objc_step_through_sp->PlanSucceeded()) {
+ LLDB_LOGF(log, "ObjC Step through plan failed. Stepping out.");
+ }
+ Status error;
+ if (InvokeShouldStopHereCallback(eFrameCompareYounger, error)) {
+ SetPlanComplete(true);
+ return true;
+ }
+ // If we didn't want to stop at this msgSend, there might be another so
+ // we should just continue on with the step out and see if our breakpoint
+ // triggers again.
+ m_objc_step_through_sp.reset();
+ for (BreakpointSP bkpt_sp : m_msgSend_bkpts) {
+ bkpt_sp->SetEnabled(true);
+ }
+ return false;
+ }
+
+ // If we hit an msgSend breakpoint, then we should queue the step through
+ // plan:
+
+ if (m_at_msg_send) {
+ LanguageRuntime *objc_runtime
+ = GetThread().GetProcess()->GetLanguageRuntime(eLanguageTypeObjC);
+ // There's no way we could have gotten here without an ObjC language
+ // runtime.
+ assert(objc_runtime);
+ m_objc_step_through_sp
+ = objc_runtime->GetStepThroughTrampolinePlan(GetThread(), m_stop_others);
+ // If we failed to find the target for this dispatch, just keep going and
+ // let the step out complete.
+ if (!m_objc_step_through_sp) {
+ LLDB_LOG(log, "Couldn't find target for message dispatch, continuing.");
+ return false;
+ }
+ // Otherwise push the step through plan and continue.
+ GetThread().QueueThreadPlan(m_objc_step_through_sp, false);
+ for (BreakpointSP bkpt_sp : m_msgSend_bkpts) {
+ bkpt_sp->SetEnabled(false);
+ }
+ return false;
+ }
+ return true;
+}
+
+bool AppleThreadPlanStepThroughDirectDispatch::MischiefManaged() {
+ if (IsPlanComplete())
+ return true;
+ return ThreadPlanStepOut::MischiefManaged();
+}
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
index 96f37851a35f..89aed89f1ab1 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
@@ -6,12 +6,15 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_AppleThreadPlanStepThroughObjCTrampoline_h_
-#define lldb_AppleThreadPlanStepThroughObjCTrampoline_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLETHREADPLANSTEPTHROUGHOBJCTRAMPOLINE_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLETHREADPLANSTEPTHROUGHOBJCTRAMPOLINE_H
#include "AppleObjCTrampolineHandler.h"
#include "lldb/Core/Value.h"
#include "lldb/Target/ThreadPlan.h"
+#include "lldb/Target/ThreadPlanStepInRange.h"
+#include "lldb/Target/ThreadPlanStepOut.h"
+#include "lldb/Target/ThreadPlanShouldStopHere.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-types.h"
@@ -20,7 +23,7 @@ namespace lldb_private {
class AppleThreadPlanStepThroughObjCTrampoline : public ThreadPlan {
public:
AppleThreadPlanStepThroughObjCTrampoline(
- Thread &thread, AppleObjCTrampolineHandler *trampoline_handler,
+ Thread &thread, AppleObjCTrampolineHandler &trampoline_handler,
ValueList &values, lldb::addr_t isa_addr, lldb::addr_t sel_addr,
bool stop_others);
@@ -52,25 +55,62 @@ protected:
private:
bool InitializeFunctionCaller();
- AppleObjCTrampolineHandler *m_trampoline_handler; // FIXME - ensure this
- // doesn't go away on us?
- // SP maybe?
- lldb::addr_t m_args_addr; // Stores the address for our step through function
- // result structure.
- // lldb::addr_t m_object_addr; // This is only for Description.
+ AppleObjCTrampolineHandler &m_trampoline_handler; /// The handler itself.
+ lldb::addr_t m_args_addr; /// Stores the address for our step through function
+ /// result structure.
ValueList m_input_values;
- lldb::addr_t m_isa_addr; // isa_addr and sel_addr are the keys we will use to
- // cache the implementation.
+ lldb::addr_t m_isa_addr; /// isa_addr and sel_addr are the keys we will use to
+ /// cache the implementation.
lldb::addr_t m_sel_addr;
- lldb::ThreadPlanSP m_func_sp; // This is the function call plan. We fill it
- // at start, then set it
- // to NULL when this plan is done. That way we know to go to:
- lldb::ThreadPlanSP m_run_to_sp; // The plan that runs to the target.
- FunctionCaller *m_impl_function; // This is a pointer to a impl function that
- // is owned by the client that pushes this plan.
- bool m_stop_others;
+ lldb::ThreadPlanSP m_func_sp; /// This is the function call plan. We fill it
+ /// at start, then set it to NULL when this plan
+ /// is done. That way we know to go on to:
+ lldb::ThreadPlanSP m_run_to_sp; /// The plan that runs to the target.
+ FunctionCaller *m_impl_function; /// This is a pointer to a impl function that
+ /// is owned by the client that pushes this
+ /// plan.
+ bool m_stop_others; /// Whether we should stop other threads.
+};
+
+class AppleThreadPlanStepThroughDirectDispatch: public ThreadPlanStepOut {
+public:
+ AppleThreadPlanStepThroughDirectDispatch(
+ Thread &thread, AppleObjCTrampolineHandler &handler,
+ llvm::StringRef dispatch_func_name, bool stop_others,
+ LazyBool step_in_avoids_code_without_debug_info);
+
+ ~AppleThreadPlanStepThroughDirectDispatch() override;
+
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
+
+ bool ShouldStop(Event *event_ptr) override;
+
+ bool StopOthers() override { return m_stop_others; }
+
+ bool MischiefManaged() override;
+
+ bool DoWillResume(lldb::StateType resume_state, bool current_plan) override;
+
+ void SetFlagsToDefault() override {
+ GetFlags().Set(ThreadPlanStepInRange::GetDefaultFlagsValue());
+ }
+
+protected:
+ bool DoPlanExplainsStop(Event *event_ptr) override;
+
+ AppleObjCTrampolineHandler &m_trampoline_handler;
+ std::string m_dispatch_func_name; /// Which dispatch function we're stepping
+ /// through.
+ lldb::ThreadPlanSP m_objc_step_through_sp; /// When we hit an objc_msgSend,
+ /// we'll use this plan to get to
+ /// its target.
+ std::vector<lldb::BreakpointSP> m_msgSend_bkpts; /// Breakpoints on the objc
+ /// dispatch functions.
+ bool m_at_msg_send; /// Are we currently handling an msg_send
+ bool m_stop_others; /// Whether we should stop other threads.
+
};
} // namespace lldb_private
-#endif // lldb_AppleThreadPlanStepThroughObjCTrampoline_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_APPLEOBJCRUNTIME_APPLETHREADPLANSTEPTHROUGHOBJCTRAMPOLINE_H
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
index 9eb493f83c84..2ccf9b33f9d8 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
@@ -1,4 +1,4 @@
-//===-- ObjCLanguageRuntime.cpp ---------------------------------*- C++ -*-===//
+//===-- ObjCLanguageRuntime.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,11 +9,11 @@
#include "ObjCLanguageRuntime.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/MappedHash.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/ValueObject.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/Type.h"
@@ -41,7 +41,7 @@ ObjCLanguageRuntime::ObjCLanguageRuntime(Process *process)
m_isa_to_descriptor_stop_id(UINT32_MAX), m_complete_class_cache(),
m_negative_complete_class_cache() {}
-bool ObjCLanguageRuntime::IsWhitelistedRuntimeValue(ConstString name) {
+bool ObjCLanguageRuntime::IsAllowedRuntimeValue(ConstString name) {
static ConstString g_self = ConstString("self");
static ConstString g_cmd = ConstString("_cmd");
return name == g_self || name == g_cmd;
@@ -127,9 +127,9 @@ ObjCLanguageRuntime::LookupInCompleteClassCache(ConstString &name) {
for (uint32_t i = 0; i < types.GetSize(); ++i) {
TypeSP type_sp(types.GetTypeAtIndex(i));
- if (ClangASTContext::IsObjCObjectOrInterfaceType(
+ if (TypeSystemClang::IsObjCObjectOrInterfaceType(
type_sp->GetForwardCompilerType())) {
- if (type_sp->IsCompleteObjCClass()) {
+ if (TypePayloadClang(type_sp->GetPayload()).IsCompleteObjCClass()) {
m_complete_class_cache[name] = type_sp;
return type_sp;
}
@@ -387,9 +387,9 @@ ObjCLanguageRuntime::GetRuntimeType(CompilerType base_type) {
CompilerType class_type;
bool is_pointer_type = false;
- if (ClangASTContext::IsObjCObjectPointerType(base_type, &class_type))
+ if (TypeSystemClang::IsObjCObjectPointerType(base_type, &class_type))
is_pointer_type = true;
- else if (ClangASTContext::IsObjCObjectOrInterfaceType(base_type))
+ else if (TypeSystemClang::IsObjCObjectOrInterfaceType(base_type))
class_type = base_type;
else
return llvm::None;
@@ -397,7 +397,7 @@ ObjCLanguageRuntime::GetRuntimeType(CompilerType base_type) {
if (!class_type)
return llvm::None;
- ConstString class_name(class_type.GetConstTypeName());
+ ConstString class_name(class_type.GetTypeName());
if (!class_name)
return llvm::None;
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
index b9a4d5dae08a..c43acf54bbcd 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ObjCLanguageRuntime_h_
-#define liblldb_ObjCLanguageRuntime_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_OBJCLANGUAGERUNTIME_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_OBJCLANGUAGERUNTIME_H
#include <functional>
#include <map>
@@ -17,7 +17,6 @@
#include "llvm/Support/Casting.h"
#include "lldb/Breakpoint/BreakpointPrecondition.h"
-#include "lldb/Core/ClangForward.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/ThreadSafeDenseMap.h"
#include "lldb/Symbol/CompilerType.h"
@@ -29,6 +28,7 @@ class CommandObjectObjC_ClassTable_Dump;
namespace lldb_private {
+class TypeSystemClang;
class UtilityFunction;
class ObjCLanguageRuntime : public LanguageRuntime {
@@ -144,12 +144,12 @@ public:
public:
virtual ~EncodingToType();
- virtual CompilerType RealizeType(ClangASTContext &ast_ctx, const char *name,
+ virtual CompilerType RealizeType(TypeSystemClang &ast_ctx, const char *name,
bool for_expression) = 0;
virtual CompilerType RealizeType(const char *name, bool for_expression);
protected:
- std::unique_ptr<ClangASTContext> m_scratch_ast_ctx_up;
+ std::unique_ptr<TypeSystemClang> m_scratch_ast_ctx_up;
};
class ObjCExceptionPrecondition : public BreakpointPrecondition {
@@ -186,7 +186,8 @@ public:
TaggedPointerVendor() = default;
private:
- DISALLOW_COPY_AND_ASSIGN(TaggedPointerVendor);
+ TaggedPointerVendor(const TaggedPointerVendor &) = delete;
+ const TaggedPointerVendor &operator=(const TaggedPointerVendor &) = delete;
};
~ObjCLanguageRuntime() override;
@@ -299,7 +300,7 @@ public:
/// Check whether the name is "self" or "_cmd" and should show up in
/// "frame variable".
- bool IsWhitelistedRuntimeValue(ConstString name) override;
+ bool IsAllowedRuntimeValue(ConstString name) override;
protected:
// Classes that inherit from ObjCLanguageRuntime can see and modify these
@@ -417,9 +418,10 @@ protected:
void ReadObjCLibraryIfNeeded(const ModuleList &module_list);
- DISALLOW_COPY_AND_ASSIGN(ObjCLanguageRuntime);
+ ObjCLanguageRuntime(const ObjCLanguageRuntime &) = delete;
+ const ObjCLanguageRuntime &operator=(const ObjCLanguageRuntime &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_ObjCLanguageRuntime_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_OBJC_OBJCLANGUAGERUNTIME_H
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
index b396781e6726..6858c7134d33 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
@@ -1,4 +1,4 @@
-//===-- RenderScriptExpressionOpts.cpp --------------------------*- C++ -*-===//
+//===-- RenderScriptExpressionOpts.cpp ------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -86,7 +86,7 @@ bool RenderScriptRuntimeModulePass::runOnModule(llvm::Module &module) {
llvm::StringRef real_triple =
m_process_ptr->GetTarget().GetArchitecture().GetTriple().getTriple();
const llvm::Target *target_info =
- llvm::TargetRegistry::lookupTarget(real_triple, err);
+ llvm::TargetRegistry::lookupTarget(std::string(real_triple), err);
if (!target_info) {
if (log)
log->Warning("couldn't determine real target architecture: '%s'",
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h
index 3ec4e37b6db0..52da677128e2 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_RENDERSCRIPT_EXPROPTS_H
-#define LLDB_RENDERSCRIPT_EXPROPTS_H
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_RENDERSCRIPT_RENDERSCRIPTRUNTIME_RENDERSCRIPTEXPRESSIONOPTS_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_RENDERSCRIPT_RENDERSCRIPTRUNTIME_RENDERSCRIPTEXPRESSIONOPTS_H
#include "llvm/IR/Module.h"
#include "llvm/Support/TargetRegistry.h"
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
index 4edb8dec6082..dd9312234d8b 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -1,4 +1,4 @@
-//===-- RenderScriptRuntime.cpp ---------------------------------*- C++ -*-===//
+//===-- RenderScriptRuntime.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -46,6 +46,8 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_renderscript;
+LLDB_PLUGIN_DEFINE(RenderScriptRuntime)
+
#define FMT_COORD "(%" PRIu32 ", %" PRIu32 ", %" PRIu32 ")"
char RenderScriptRuntime::ID = 0;
@@ -791,6 +793,9 @@ RenderScriptRuntime::CreateInstance(Process *process,
Searcher::CallbackReturn
RSBreakpointResolver::SearchCallback(SearchFilter &filter,
SymbolContext &context, Address *) {
+ BreakpointSP breakpoint_sp = GetBreakpoint();
+ assert(breakpoint_sp);
+
ModuleSP module = context.module_sp;
if (!module || !IsRenderScriptScriptModule(module))
@@ -811,7 +816,7 @@ RSBreakpointResolver::SearchCallback(SearchFilter &filter,
if (kernel_sym) {
Address bp_addr = kernel_sym->GetAddress();
if (filter.AddressPasses(bp_addr))
- m_breakpoint->AddLocation(bp_addr);
+ breakpoint_sp->AddLocation(bp_addr);
}
return Searcher::eCallbackReturnContinue;
@@ -821,6 +826,9 @@ Searcher::CallbackReturn
RSReduceBreakpointResolver::SearchCallback(lldb_private::SearchFilter &filter,
lldb_private::SymbolContext &context,
Address *) {
+ BreakpointSP breakpoint_sp = GetBreakpoint();
+ assert(breakpoint_sp);
+
// We need to have access to the list of reductions currently parsed, as
// reduce names don't actually exist as symbols in a module. They are only
// identifiable by parsing the .rs.info packet, or finding the expand symbol.
@@ -867,7 +875,7 @@ RSReduceBreakpointResolver::SearchCallback(lldb_private::SearchFilter &filter,
if (!SkipPrologue(module, address)) {
LLDB_LOGF(log, "%s: Error trying to skip prologue", __FUNCTION__);
}
- m_breakpoint->AddLocation(address, &new_bp);
+ breakpoint_sp->AddLocation(address, &new_bp);
LLDB_LOGF(log, "%s: %s reduction breakpoint on %s in %s",
__FUNCTION__, new_bp ? "new" : "existing",
kernel_name.GetCString(),
@@ -882,7 +890,8 @@ RSReduceBreakpointResolver::SearchCallback(lldb_private::SearchFilter &filter,
Searcher::CallbackReturn RSScriptGroupBreakpointResolver::SearchCallback(
SearchFilter &filter, SymbolContext &context, Address *addr) {
- if (!m_breakpoint)
+ BreakpointSP breakpoint_sp = GetBreakpoint();
+ if (!breakpoint_sp)
return eCallbackReturnContinue;
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
@@ -892,7 +901,8 @@ Searcher::CallbackReturn RSScriptGroupBreakpointResolver::SearchCallback(
return Searcher::eCallbackReturnContinue;
std::vector<std::string> names;
- m_breakpoint->GetNames(names);
+ Breakpoint& breakpoint = *breakpoint_sp;
+ breakpoint.GetNames(names);
if (names.empty())
return eCallbackReturnContinue;
@@ -932,7 +942,7 @@ Searcher::CallbackReturn RSScriptGroupBreakpointResolver::SearchCallback(
}
bool new_bp;
- m_breakpoint->AddLocation(address, &new_bp);
+ breakpoint.AddLocation(address, &new_bp);
LLDB_LOGF(log, "%s: Placed %sbreakpoint on %s", __FUNCTION__,
new_bp ? "new " : "", k.m_name.AsCString());
@@ -1029,8 +1039,8 @@ bool RenderScriptRuntime::CouldHaveDynamicValue(ValueObject &in_value) {
}
lldb::BreakpointResolverSP
-RenderScriptRuntime::CreateExceptionResolver(Breakpoint *bp, bool catch_bp,
- bool throw_bp) {
+RenderScriptRuntime::CreateExceptionResolver(const lldb::BreakpointSP &bp,
+ bool catch_bp, bool throw_bp) {
BreakpointResolverSP resolver_sp;
return resolver_sp;
}
@@ -1513,7 +1523,7 @@ void RenderScriptRuntime::CaptureScriptInit(RuntimeHook *hook,
script->type = ScriptDetails::eScriptC;
script->cache_dir = cache_dir;
script->res_name = res_name;
- script->shared_lib = strm.GetString();
+ script->shared_lib = std::string(strm.GetString());
script->context = addr_t(args[eRsContext]);
}
@@ -3129,7 +3139,7 @@ void RenderScriptRuntime::DumpKernels(Stream &strm) const {
strm.Printf("Resource '%s':", module->m_resname.c_str());
strm.EOL();
for (const auto &kernel : module->m_kernels) {
- strm.Indent(kernel.m_name.AsCString());
+ strm.Indent(kernel.m_name.GetStringRef());
strm.EOL();
}
}
@@ -3939,9 +3949,10 @@ void RSModuleDescriptor::Dump(Stream &strm) const {
}
void RSGlobalDescriptor::Dump(Stream &strm) const {
- strm.Indent(m_name.AsCString());
+ strm.Indent(m_name.GetStringRef());
VariableList var_list;
- m_module->m_module->FindGlobalVariables(m_name, nullptr, 1U, var_list);
+ m_module->m_module->FindGlobalVariables(m_name, CompilerDeclContext(), 1U,
+ var_list);
if (var_list.GetSize() == 1) {
auto var = var_list.GetVariableAtIndex(0);
auto type = var->GetType();
@@ -3964,12 +3975,12 @@ void RSGlobalDescriptor::Dump(Stream &strm) const {
}
void RSKernelDescriptor::Dump(Stream &strm) const {
- strm.Indent(m_name.AsCString());
+ strm.Indent(m_name.GetStringRef());
strm.EOL();
}
void RSReductionDescriptor::Dump(lldb_private::Stream &stream) const {
- stream.Indent(m_reduce_name.AsCString());
+ stream.Indent(m_reduce_name.GetStringRef());
stream.IndentMore();
stream.EOL();
stream.Indent();
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
index c3740ba55a11..5e3726548369 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RenderScriptRuntime_h_
-#define liblldb_RenderScriptRuntime_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_RENDERSCRIPT_RENDERSCRIPTRUNTIME_RENDERSCRIPTRUNTIME_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_RENDERSCRIPT_RENDERSCRIPTRUNTIME_RENDERSCRIPTRUNTIME_H
#include <array>
#include <map>
@@ -24,6 +24,10 @@
#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
+namespace clang {
+class TargetOptions;
+}
+
namespace lldb_private {
namespace lldb_renderscript {
@@ -54,7 +58,7 @@ struct RSCoordinate {
// for .expand kernels as a fallback.
class RSBreakpointResolver : public BreakpointResolver {
public:
- RSBreakpointResolver(Breakpoint *bp, ConstString name)
+ RSBreakpointResolver(const lldb::BreakpointSP &bp, ConstString name)
: BreakpointResolver(bp, BreakpointResolver::NameResolver),
m_kernel_name(name) {}
@@ -73,9 +77,9 @@ public:
lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
lldb::BreakpointResolverSP
- CopyForBreakpoint(Breakpoint &breakpoint) override {
+ CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override {
lldb::BreakpointResolverSP ret_sp(
- new RSBreakpointResolver(&breakpoint, m_kernel_name));
+ new RSBreakpointResolver(breakpoint, m_kernel_name));
return ret_sp;
}
@@ -96,7 +100,7 @@ public:
};
RSReduceBreakpointResolver(
- Breakpoint *breakpoint, ConstString reduce_name,
+ const lldb::BreakpointSP &breakpoint, ConstString reduce_name,
std::vector<lldb_renderscript::RSModuleDescriptorSP> *rs_modules,
int kernel_types = eKernelTypeAll)
: BreakpointResolver(breakpoint, BreakpointResolver::NameResolver),
@@ -123,9 +127,9 @@ public:
lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
lldb::BreakpointResolverSP
- CopyForBreakpoint(Breakpoint &breakpoint) override {
+ CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override {
lldb::BreakpointResolverSP ret_sp(new RSReduceBreakpointResolver(
- &breakpoint, m_reduce_name, m_rsmodules, m_kernel_types));
+ breakpoint, m_reduce_name, m_rsmodules, m_kernel_types));
return ret_sp;
}
@@ -246,7 +250,8 @@ typedef std::vector<RSScriptGroupDescriptorSP> RSScriptGroupList;
class RSScriptGroupBreakpointResolver : public BreakpointResolver {
public:
- RSScriptGroupBreakpointResolver(Breakpoint *bp, ConstString name,
+ RSScriptGroupBreakpointResolver(const lldb::BreakpointSP &bp,
+ ConstString name,
const RSScriptGroupList &groups,
bool stop_on_all)
: BreakpointResolver(bp, BreakpointResolver::NameResolver),
@@ -268,9 +273,9 @@ public:
lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
lldb::BreakpointResolverSP
- CopyForBreakpoint(Breakpoint &breakpoint) override {
+ CopyForBreakpoint(lldb::BreakpointSP &breakpoint) override {
lldb::BreakpointResolverSP ret_sp(new RSScriptGroupBreakpointResolver(
- &breakpoint, m_group_name, m_script_groups, m_stop_on_all));
+ breakpoint, m_group_name, m_script_groups, m_stop_on_all));
return ret_sp;
}
@@ -343,9 +348,9 @@ public:
bool CouldHaveDynamicValue(ValueObject &in_value) override;
- lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bp,
- bool catch_bp,
- bool throw_bp) override;
+ lldb::BreakpointResolverSP
+ CreateExceptionResolver(const lldb::BreakpointSP &bp,
+ bool catch_bp, bool throw_bp) override;
bool LoadModule(const lldb::ModuleSP &module_sp);
@@ -402,6 +407,8 @@ public:
return false;
}
+ bool GetOverrideExprOptions(clang::TargetOptions &prototype);
+
// PluginInterface protocol
lldb_private::ConstString GetPluginName() override;
@@ -421,7 +428,8 @@ protected:
void InitSearchFilter(lldb::TargetSP target) {
if (!m_filtersp)
- m_filtersp.reset(new SearchFilterForUnconstrainedSearches(target));
+ m_filtersp =
+ std::make_shared<SearchFilterForUnconstrainedSearches>(target);
}
void FixupScriptDetails(lldb_renderscript::RSModuleDescriptorSP rsmodule_sp);
@@ -577,11 +585,9 @@ private:
// any previous stored allocation which has the same address.
AllocationDetails *CreateAllocation(lldb::addr_t address);
- bool GetOverrideExprOptions(clang::TargetOptions &prototype) override;
-
bool GetIRPasses(LLVMUserExpression::IRPasses &passes) override;
};
} // namespace lldb_private
-#endif // liblldb_RenderScriptRuntime_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_RENDERSCRIPT_RENDERSCRIPTRUNTIME_RENDERSCRIPTRUNTIME_H
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp
index 45d0d028d047..b6f8b20c90c3 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp
@@ -1,4 +1,4 @@
-//===-- RenderScriptScriptGroup.cpp -----------------------------*- C++ -*-===//
+//===-- RenderScriptScriptGroup.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.h b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.h
index c25e240f6d52..03d3a7823a98 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.h
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.h
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RenderScriptScriptGroup_h_
-#define liblldb_RenderScriptScriptGroup_h_
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_RENDERSCRIPT_RENDERSCRIPTRUNTIME_RENDERSCRIPTSCRIPTGROUP_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_RENDERSCRIPT_RENDERSCRIPTRUNTIME_RENDERSCRIPTSCRIPTGROUP_H
#include "lldb/Interpreter/CommandInterpreter.h"
lldb::CommandObjectSP NewCommandObjectRenderScriptScriptGroup(
lldb_private::CommandInterpreter &interpreter);
-#endif // liblldb_RenderScriptScriptGroup_h_
+#endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_RENDERSCRIPT_RENDERSCRIPTRUNTIME_RENDERSCRIPTSCRIPTGROUP_H
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
index 4ddff3ad9c4c..f51190e0c82c 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
@@ -1,4 +1,4 @@
-//===-- RenderScriptx86ABIFixups.cpp ----------------------------*- C++ -*-===//
+//===-- RenderScriptx86ABIFixups.cpp --------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,7 +10,6 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/BasicBlock.h"
-#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instruction.h"
@@ -158,12 +157,11 @@ bool fixupX86StructRetCalls(llvm::Module &module) {
assert(new_func_type &&
"failed to clone functionType for Renderscript ABI fixup");
- llvm::CallSite call_site(call_inst);
llvm::Function *func = call_inst->getCalledFunction();
assert(func && "cannot resolve function in RenderScriptRuntime");
// Copy the original call arguments
- std::vector<llvm::Value *> new_call_args(call_site.arg_begin(),
- call_site.arg_end());
+ std::vector<llvm::Value *> new_call_args(call_inst->arg_begin(),
+ call_inst->arg_end());
// Allocate enough space to store the return value of the original function
// we pass a pointer to this allocation as the StructRet param, and then
@@ -189,15 +187,17 @@ bool fixupX86StructRetCalls(llvm::Module &module) {
->setName("new_func_ptr_load_cast");
// load the new function address ready for a jump
llvm::LoadInst *new_func_addr_load =
- new llvm::LoadInst(new_func_ptr, "load_func_pointer", call_inst);
+ new llvm::LoadInst(new_func_ptr->getType()->getPointerElementType(),
+ new_func_ptr, "load_func_pointer", call_inst);
// and create a callinstruction from it
llvm::CallInst *new_call_inst =
llvm::CallInst::Create(new_func_type, new_func_addr_load, new_call_args,
"new_func_call", call_inst);
new_call_inst->setCallingConv(call_inst->getCallingConv());
new_call_inst->setTailCall(call_inst->isTailCall());
- llvm::LoadInst *lldb_save_result_address =
- new llvm::LoadInst(return_value_alloc, "save_return_val", call_inst);
+ llvm::LoadInst *lldb_save_result_address = new llvm::LoadInst(
+ return_value_alloc->getType()->getPointerElementType(),
+ return_value_alloc, "save_return_val", call_inst);
// Now remove the old broken call
call_inst->replaceAllUsesWith(lldb_save_result_address);
diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.h b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.h
index a5efc999aea4..7836fff4a3a9 100644
--- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.h
+++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_RENDERSCRIPT_X86_H
-#define LLDB_RENDERSCRIPT_X86_H
+#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_RENDERSCRIPT_RENDERSCRIPTRUNTIME_RENDERSCRIPTX86ABIFIXUPS_H
+#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_RENDERSCRIPT_RENDERSCRIPTRUNTIME_RENDERSCRIPTX86ABIFIXUPS_H
#include "llvm/IR/Module.h"
diff --git a/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp b/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
index e0d2c5d0eef8..333113a0b17a 100644
--- a/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
+++ b/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
@@ -1,4 +1,4 @@
-//===-- MemoryHistoryASan.cpp -----------------------------------*- C++ -*-===//
+//===-- MemoryHistoryASan.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -28,6 +28,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(MemoryHistoryASan)
+
MemoryHistorySP MemoryHistoryASan::CreateInstance(const ProcessSP &process_sp) {
if (!process_sp.get())
return nullptr;
@@ -136,7 +138,12 @@ static void CreateHistoryThreadFromValueObject(ProcessSP process_sp,
pcs.push_back(pc);
}
- HistoryThread *history_thread = new HistoryThread(*process_sp, tid, pcs);
+ // The ASAN runtime already massages the return addresses into call
+ // addresses, we don't want LLDB's unwinder to try to locate the previous
+ // instruction again as this might lead to us reporting a different line.
+ bool pcs_are_call_addresses = true;
+ HistoryThread *history_thread =
+ new HistoryThread(*process_sp, tid, pcs, pcs_are_call_addresses);
ThreadSP new_thread_sp(history_thread);
std::ostringstream thread_name_with_number;
thread_name_with_number << thread_name << " Thread " << tid;
diff --git a/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h b/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h
index 266576b0cd96..e9fe37d344a4 100644
--- a/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h
+++ b/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_MemoryHistoryASan_h_
-#define liblldb_MemoryHistoryASan_h_
+#ifndef LLDB_SOURCE_PLUGINS_MEMORYHISTORY_ASAN_MEMORYHISTORYASAN_H
+#define LLDB_SOURCE_PLUGINS_MEMORYHISTORY_ASAN_MEMORYHISTORYASAN_H
#include "lldb/Target/ABI.h"
#include "lldb/Target/MemoryHistory.h"
@@ -45,4 +45,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_MemoryHistoryASan_h_
+#endif // LLDB_SOURCE_PLUGINS_MEMORYHISTORY_ASAN_MEMORYHISTORYASAN_H
diff --git a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
index 512b5bebf07f..83cf9f8bd269 100644
--- a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
+++ b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
@@ -1,4 +1,4 @@
-//===-- ObjectContainerBSDArchive.cpp ---------------------------*- C++ -*-===//
+//===-- ObjectContainerBSDArchive.cpp -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -40,6 +40,8 @@ typedef struct ar_hdr {
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(ObjectContainerBSDArchive)
+
ObjectContainerBSDArchive::Object::Object()
: ar_name(), modification_time(0), uid(0), gid(0), mode(0), size(0),
file_offset(0), file_size(0) {}
@@ -86,7 +88,7 @@ ObjectContainerBSDArchive::Object::Extract(const DataExtractor &data,
return LLDB_INVALID_OFFSET;
str.assign((const char *)data.GetData(&offset, 16), 16);
- if (str.find("#1/") == 0) {
+ if (llvm::StringRef(str).startswith("#1/")) {
// If the name is longer than 16 bytes, or contains an embedded space then
// it will use this format where the length of the name is here and the
// name characters are after this header.
diff --git a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
index 5d9c01315a66..f6862afff8a0 100644
--- a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
+++ b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ObjectContainerBSDArchive_h_
-#define liblldb_ObjectContainerBSDArchive_h_
+#ifndef LLDB_SOURCE_PLUGINS_OBJECTCONTAINER_BSD_ARCHIVE_OBJECTCONTAINERBSDARCHIVE_H
+#define LLDB_SOURCE_PLUGINS_OBJECTCONTAINER_BSD_ARCHIVE_OBJECTCONTAINERBSDARCHIVE_H
#include "lldb/Core/UniqueCStringMap.h"
#include "lldb/Symbol/ObjectContainer.h"
@@ -174,4 +174,4 @@ protected:
Archive::shared_ptr m_archive_sp;
};
-#endif // liblldb_ObjectContainerBSDArchive_h_
+#endif // LLDB_SOURCE_PLUGINS_OBJECTCONTAINER_BSD_ARCHIVE_OBJECTCONTAINERBSDARCHIVE_H
diff --git a/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp b/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
index b83b2efb492f..bd8eeedce57d 100644
--- a/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
+++ b/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
@@ -1,4 +1,4 @@
-//===-- BreakpadRecords.cpp ----------------------------------- -*- C++ -*-===//
+//===-- BreakpadRecords.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -205,7 +205,7 @@ llvm::Optional<InfoRecord> InfoRecord::parse(llvm::StringRef Line) {
// use this as the UUID. Otherwise, we should revert back to the module ID.
UUID ID;
if (Line.trim().empty()) {
- if (Str.empty() || ID.SetFromStringRef(Str, Str.size() / 2) != Str.size())
+ if (Str.empty() || !ID.SetFromStringRef(Str))
return llvm::None;
}
return InfoRecord(std::move(ID));
diff --git a/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.h b/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.h
index 27bef975125d..1620a1210b84 100644
--- a/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.h
+++ b/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_PLUGINS_OBJECTFILE_BREAKPAD_BREAKPADRECORDS_H
-#define LLDB_PLUGINS_OBJECTFILE_BREAKPAD_BREAKPADRECORDS_H
+#ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_BREAKPAD_BREAKPADRECORDS_H
+#define LLDB_SOURCE_PLUGINS_OBJECTFILE_BREAKPAD_BREAKPADRECORDS_H
#include "lldb/Utility/UUID.h"
#include "lldb/lldb-types.h"
@@ -183,4 +183,4 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const StackWinRecord &R);
} // namespace breakpad
} // namespace lldb_private
-#endif // LLDB_PLUGINS_OBJECTFILE_BREAKPAD_BREAKPADRECORDS_H
+#endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_BREAKPAD_BREAKPADRECORDS_H
diff --git a/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp b/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
index 3b9e0e2092a9..7a9163ddb880 100644
--- a/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
+++ b/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
@@ -1,4 +1,4 @@
-//===-- ObjectFileBreakpad.cpp -------------------------------- -*- C++ -*-===//
+//===-- ObjectFileBreakpad.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -16,6 +16,8 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::breakpad;
+LLDB_PLUGIN_DEFINE(ObjectFileBreakpad)
+
namespace {
struct Header {
ArchSpec arch;
diff --git a/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h b/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
index cb4bba01fb71..8724feaa422d 100644
--- a/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
+++ b/lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_PLUGINS_OBJECTFILE_BREAKPAD_OBJECTFILEBREAKPAD_H
-#define LLDB_PLUGINS_OBJECTFILE_BREAKPAD_OBJECTFILEBREAKPAD_H
+#ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_BREAKPAD_OBJECTFILEBREAKPAD_H
+#define LLDB_SOURCE_PLUGINS_OBJECTFILE_BREAKPAD_OBJECTFILEBREAKPAD_H
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Utility/ArchSpec.h"
@@ -103,4 +103,4 @@ private:
} // namespace breakpad
} // namespace lldb_private
-#endif // LLDB_PLUGINS_OBJECTFILE_BREAKPAD_OBJECTFILEBREAKPAD_H
+#endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_BREAKPAD_OBJECTFILEBREAKPAD_H
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
index aa9871071b0e..f0496beba2ef 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
@@ -1,4 +1,4 @@
-//===-- ELFHeader.cpp ----------------------------------------- -*- C++ -*-===//
+//===-- ELFHeader.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
index bb228e269d40..963cc850736f 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
+++ b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
@@ -17,8 +17,8 @@
/// reading both 32 and 64 bit instances of the object.
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ELFHeader_h_
-#define liblldb_ELFHeader_h_
+#ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_ELF_ELFHEADER_H
+#define LLDB_SOURCE_PLUGINS_OBJECTFILE_ELF_ELFHEADER_H
#include "llvm/BinaryFormat/ELF.h"
@@ -391,4 +391,4 @@ struct ELFRela {
} // End namespace elf.
-#endif // #ifndef liblldb_ELFHeader_h_
+#endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_ELF_ELFHEADER_H
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 8b62afa18cd6..bca575b7f884 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1,4 +1,4 @@
-//===-- ObjectFileELF.cpp ------------------------------------- -*- C++ -*-===//
+//===-- ObjectFileELF.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -51,6 +51,8 @@ using namespace lldb_private;
using namespace elf;
using namespace llvm::ELF;
+LLDB_PLUGIN_DEFINE(ObjectFileELF)
+
namespace {
// ELF note owner definitions
@@ -206,7 +208,9 @@ unsigned ELFRelocation::RelocAddend64(const ELFRelocation &rel) {
} // end anonymous namespace
-static user_id_t SegmentID(size_t PHdrIndex) { return ~PHdrIndex; }
+static user_id_t SegmentID(size_t PHdrIndex) {
+ return ~user_id_t(PHdrIndex);
+}
bool ELFNote::Parse(const DataExtractor &data, lldb::offset_t *offset) {
// Read all fields.
@@ -537,7 +541,8 @@ size_t ObjectFileELF::GetModuleSpecifications(
__FUNCTION__, file.GetPath().c_str());
}
- data_sp = MapFileData(file, -1, file_offset);
+ if (data_sp->GetByteSize() < length)
+ data_sp = MapFileData(file, -1, file_offset);
if (data_sp)
data.SetData(data_sp);
// In case there is header extension in the section #0, the header we
@@ -576,8 +581,7 @@ size_t ObjectFileELF::GetModuleSpecifications(
func_cat,
"Calculating module crc32 %s with size %" PRIu64 " KiB",
file.GetLastPathComponent().AsCString(),
- (FileSystem::Instance().GetByteSize(file) - file_offset) /
- 1024);
+ (length - file_offset) / 1024);
// For core files - which usually don't happen to have a
// gnu_debuglink, and are pretty bulky - calculating whole
@@ -899,7 +903,7 @@ size_t ObjectFileELF::ParseDependentModules() {
if (m_filespec_up)
return m_filespec_up->GetSize();
- m_filespec_up.reset(new FileSpecList());
+ m_filespec_up = std::make_unique<FileSpecList>();
if (!ParseSectionHeaders())
return 0;
@@ -1235,7 +1239,7 @@ void ObjectFileELF::ParseARMAttributes(DataExtractor &data, uint64_t length,
lldb::offset_t Offset = 0;
uint8_t FormatVersion = data.GetU8(&Offset);
- if (FormatVersion != llvm::ARMBuildAttrs::Format_Version)
+ if (FormatVersion != llvm::ELFAttrs::Format_Version)
return;
Offset = Offset + sizeof(uint32_t); // Section Length
@@ -1588,6 +1592,7 @@ static SectionType GetSectionTypeFromName(llvm::StringRef Name) {
.Case("str.dwo", eSectionTypeDWARFDebugStrDwo)
.Case("str_offsets", eSectionTypeDWARFDebugStrOffsets)
.Case("str_offsets.dwo", eSectionTypeDWARFDebugStrOffsetsDwo)
+ .Case("tu_index", eSectionTypeDWARFDebugTuIndex)
.Case("types", eSectionTypeDWARFDebugTypes)
.Case("types.dwo", eSectionTypeDWARFDebugTypesDwo)
.Default(eSectionTypeOther);
@@ -1696,7 +1701,7 @@ class VMAddressProvider {
public:
VMAddressProvider(ObjectFile::Type Type, llvm::StringRef SegmentName)
- : ObjectType(Type), SegmentName(SegmentName) {}
+ : ObjectType(Type), SegmentName(std::string(SegmentName)) {}
std::string GetNextSegmentName() const {
return llvm::formatv("{0}[{1}]", SegmentName, SegmentCount).str();
@@ -2230,8 +2235,7 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id,
if (!mangled_name.empty())
mangled.SetMangledName(ConstString((mangled_name + suffix).str()));
- ConstString demangled =
- mangled.GetDemangledName(lldb::eLanguageTypeUnknown);
+ ConstString demangled = mangled.GetDemangledName();
llvm::StringRef demangled_name = demangled.GetStringRef();
if (!demangled_name.empty())
mangled.SetDemangledName(ConstString((demangled_name + suffix).str()));
@@ -2713,7 +2717,7 @@ Symtab *ObjectFileELF::GetSymtab() {
Section *symtab =
section_list->FindSectionByType(eSectionTypeELFSymbolTable, true).get();
if (symtab) {
- m_symtab_up.reset(new Symtab(symtab->GetObjectFile()));
+ m_symtab_up = std::make_unique<Symtab>(symtab->GetObjectFile());
symbol_id += ParseSymbolTable(m_symtab_up.get(), symbol_id, symtab);
}
@@ -2730,7 +2734,7 @@ Symtab *ObjectFileELF::GetSymtab() {
.get();
if (dynsym) {
if (!m_symtab_up)
- m_symtab_up.reset(new Symtab(dynsym->GetObjectFile()));
+ m_symtab_up = std::make_unique<Symtab>(dynsym->GetObjectFile());
symbol_id += ParseSymbolTable(m_symtab_up.get(), symbol_id, dynsym);
}
}
@@ -2757,7 +2761,8 @@ Symtab *ObjectFileELF::GetSymtab() {
assert(reloc_header);
if (m_symtab_up == nullptr)
- m_symtab_up.reset(new Symtab(reloc_section->GetObjectFile()));
+ m_symtab_up =
+ std::make_unique<Symtab>(reloc_section->GetObjectFile());
ParseTrampolineSymbols(m_symtab_up.get(), symbol_id, reloc_header,
reloc_id);
@@ -2767,17 +2772,17 @@ Symtab *ObjectFileELF::GetSymtab() {
if (DWARFCallFrameInfo *eh_frame =
GetModule()->GetUnwindTable().GetEHFrameInfo()) {
if (m_symtab_up == nullptr)
- m_symtab_up.reset(new Symtab(this));
+ m_symtab_up = std::make_unique<Symtab>(this);
ParseUnwindSymbols(m_symtab_up.get(), eh_frame);
}
// If we still don't have any symtab then create an empty instance to avoid
// do the section lookup next time.
if (m_symtab_up == nullptr)
- m_symtab_up.reset(new Symtab(this));
+ m_symtab_up = std::make_unique<Symtab>(this);
// In the event that there's no symbol entry for the entry point we'll
- // artifically create one. We delegate to the symtab object the figuring
+ // artificially create one. We delegate to the symtab object the figuring
// out of the proper size, this will usually make it span til the next
// symbol it finds in the section. This means that if there are missing
// symbols the entry point might span beyond its function definition.
@@ -2874,7 +2879,7 @@ void ObjectFileELF::ParseUnwindSymbols(Symtab *symbol_table,
return;
// First we save the new symbols into a separate list and add them to the
- // symbol table after we colleced all symbols we want to add. This is
+ // symbol table after we collected all symbols we want to add. This is
// neccessary because adding a new symbol invalidates the internal index of
// the symtab what causing the next lookup to be slow because it have to
// recalculate the index first.
@@ -2953,7 +2958,8 @@ void ObjectFileELF::Dump(Stream *s) {
s->EOL();
SectionList *section_list = GetSectionList();
if (section_list)
- section_list->Dump(s, nullptr, true, UINT32_MAX);
+ section_list->Dump(s->AsRawOstream(), s->GetIndentLevel(), nullptr, true,
+ UINT32_MAX);
Symtab *symtab = GetSymtab();
if (symtab)
symtab->Dump(s, nullptr, eSortOrderNone);
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
index 3b273896cb59..062271f1caf0 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ObjectFileELF_h_
-#define liblldb_ObjectFileELF_h_
+#ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_ELF_OBJECTFILEELF_H
+#define LLDB_SOURCE_PLUGINS_OBJECTFILE_ELF_OBJECTFILEELF_H
#include <stdint.h>
@@ -328,9 +328,6 @@ private:
/// section index 0 is never valid).
lldb::user_id_t GetSectionIndexByName(const char *name);
- // Returns the ID of the first section that has the given type.
- lldb::user_id_t GetSectionIndexByType(unsigned type);
-
/// Returns the section header with the given id or NULL.
const ELFSectionHeaderInfo *GetSectionHeaderByIndex(lldb::user_id_t id);
@@ -397,4 +394,4 @@ private:
std::shared_ptr<ObjectFileELF> GetGnuDebugDataObjectFile();
};
-#endif // liblldb_ObjectFileELF_h_
+#endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_ELF_OBJECTFILEELF_H
diff --git a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
index c55b96d9110b..93c2c9f945fe 100644
--- a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
+++ b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
@@ -1,4 +1,4 @@
-//===-- ObjectFileJIT.cpp ---------------------------------------*- C++ -*-===//
+//===-- ObjectFileJIT.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -39,6 +39,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(ObjectFileJIT)
+
char ObjectFileJIT::ID;
void ObjectFileJIT::Initialize() {
@@ -118,7 +120,7 @@ Symtab *ObjectFileJIT::GetSymtab() {
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
if (m_symtab_up == nullptr) {
- m_symtab_up.reset(new Symtab(this));
+ m_symtab_up = std::make_unique<Symtab>(this);
std::lock_guard<std::recursive_mutex> symtab_guard(
m_symtab_up->GetMutex());
ObjectFileJITDelegateSP delegate_sp(m_delegate_wp.lock());
@@ -137,7 +139,7 @@ bool ObjectFileJIT::IsStripped() {
void ObjectFileJIT::CreateSections(SectionList &unified_section_list) {
if (!m_sections_up) {
- m_sections_up.reset(new SectionList());
+ m_sections_up = std::make_unique<SectionList>();
ObjectFileJITDelegateSP delegate_sp(m_delegate_wp.lock());
if (delegate_sp) {
delegate_sp->PopulateSectionList(this, *m_sections_up);
@@ -161,7 +163,8 @@ void ObjectFileJIT::Dump(Stream *s) {
SectionList *sections = GetSectionList();
if (sections)
- sections->Dump(s, nullptr, true, UINT32_MAX);
+ sections->Dump(s->AsRawOstream(), s->GetIndentLevel(), nullptr, true,
+ UINT32_MAX);
if (m_symtab_up)
m_symtab_up->Dump(s, nullptr, eSortOrderNone);
diff --git a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
index c992683cfc3c..a3a1acea916a 100644
--- a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
+++ b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ObjectFileJIT_h_
-#define liblldb_ObjectFileJIT_h_
+#ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_JIT_OBJECTFILEJIT_H
+#define LLDB_SOURCE_PLUGINS_OBJECTFILE_JIT_OBJECTFILEJIT_H
#include "lldb/Core/Address.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -104,4 +104,4 @@ protected:
lldb::ObjectFileJITDelegateWP m_delegate_wp;
};
-#endif // liblldb_ObjectFileJIT_h_
+#endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_JIT_OBJECTFILEJIT_H
diff --git a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
new file mode 100644
index 000000000000..91150fa02ebc
--- /dev/null
+++ b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
@@ -0,0 +1,466 @@
+//===-- ObjectFileWasm.cpp ------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "ObjectFileWasm.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Section.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/SectionLoadList.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Log.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/BinaryFormat/Magic.h"
+#include "llvm/BinaryFormat/Wasm.h"
+#include "llvm/Support/Endian.h"
+#include "llvm/Support/Format.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::wasm;
+
+LLDB_PLUGIN_DEFINE(ObjectFileWasm)
+
+static const uint32_t kWasmHeaderSize =
+ sizeof(llvm::wasm::WasmMagic) + sizeof(llvm::wasm::WasmVersion);
+
+/// Checks whether the data buffer starts with a valid Wasm module header.
+static bool ValidateModuleHeader(const DataBufferSP &data_sp) {
+ if (!data_sp || data_sp->GetByteSize() < kWasmHeaderSize)
+ return false;
+
+ if (llvm::identify_magic(toStringRef(data_sp->GetData())) !=
+ llvm::file_magic::wasm_object)
+ return false;
+
+ uint8_t *Ptr = data_sp->GetBytes() + sizeof(llvm::wasm::WasmMagic);
+
+ uint32_t version = llvm::support::endian::read32le(Ptr);
+ return version == llvm::wasm::WasmVersion;
+}
+
+static llvm::Optional<ConstString>
+GetWasmString(llvm::DataExtractor &data, llvm::DataExtractor::Cursor &c) {
+ // A Wasm string is encoded as a vector of UTF-8 codes.
+ // Vectors are encoded with their u32 length followed by the element
+ // sequence.
+ uint64_t len = data.getULEB128(c);
+ if (!c) {
+ consumeError(c.takeError());
+ return llvm::None;
+ }
+
+ if (len >= (uint64_t(1) << 32)) {
+ return llvm::None;
+ }
+
+ llvm::SmallVector<uint8_t, 32> str_storage;
+ data.getU8(c, str_storage, len);
+ if (!c) {
+ consumeError(c.takeError());
+ return llvm::None;
+ }
+
+ llvm::StringRef str = toStringRef(makeArrayRef(str_storage));
+ return ConstString(str);
+}
+
+char ObjectFileWasm::ID;
+
+void ObjectFileWasm::Initialize() {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(),
+ GetPluginDescriptionStatic(), CreateInstance,
+ CreateMemoryInstance, GetModuleSpecifications);
+}
+
+void ObjectFileWasm::Terminate() {
+ PluginManager::UnregisterPlugin(CreateInstance);
+}
+
+ConstString ObjectFileWasm::GetPluginNameStatic() {
+ static ConstString g_name("wasm");
+ return g_name;
+}
+
+ObjectFile *
+ObjectFileWasm::CreateInstance(const ModuleSP &module_sp, DataBufferSP &data_sp,
+ offset_t data_offset, const FileSpec *file,
+ offset_t file_offset, offset_t length) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
+
+ if (!data_sp) {
+ data_sp = MapFileData(*file, length, file_offset);
+ if (!data_sp) {
+ LLDB_LOGF(log, "Failed to create ObjectFileWasm instance for file %s",
+ file->GetPath().c_str());
+ return nullptr;
+ }
+ data_offset = 0;
+ }
+
+ assert(data_sp);
+ if (!ValidateModuleHeader(data_sp)) {
+ LLDB_LOGF(log,
+ "Failed to create ObjectFileWasm instance: invalid Wasm header");
+ return nullptr;
+ }
+
+ // Update the data to contain the entire file if it doesn't contain it
+ // already.
+ if (data_sp->GetByteSize() < length) {
+ data_sp = MapFileData(*file, length, file_offset);
+ if (!data_sp) {
+ LLDB_LOGF(log,
+ "Failed to create ObjectFileWasm instance: cannot read file %s",
+ file->GetPath().c_str());
+ return nullptr;
+ }
+ data_offset = 0;
+ }
+
+ std::unique_ptr<ObjectFileWasm> objfile_up(new ObjectFileWasm(
+ module_sp, data_sp, data_offset, file, file_offset, length));
+ ArchSpec spec = objfile_up->GetArchitecture();
+ if (spec && objfile_up->SetModulesArchitecture(spec)) {
+ LLDB_LOGF(log,
+ "%p ObjectFileWasm::CreateInstance() module = %p (%s), file = %s",
+ static_cast<void *>(objfile_up.get()),
+ static_cast<void *>(objfile_up->GetModule().get()),
+ objfile_up->GetModule()->GetSpecificationDescription().c_str(),
+ file ? file->GetPath().c_str() : "<NULL>");
+ return objfile_up.release();
+ }
+
+ LLDB_LOGF(log, "Failed to create ObjectFileWasm instance");
+ return nullptr;
+}
+
+ObjectFile *ObjectFileWasm::CreateMemoryInstance(const ModuleSP &module_sp,
+ DataBufferSP &data_sp,
+ const ProcessSP &process_sp,
+ addr_t header_addr) {
+ if (!ValidateModuleHeader(data_sp))
+ return nullptr;
+
+ std::unique_ptr<ObjectFileWasm> objfile_up(
+ new ObjectFileWasm(module_sp, data_sp, process_sp, header_addr));
+ ArchSpec spec = objfile_up->GetArchitecture();
+ if (spec && objfile_up->SetModulesArchitecture(spec))
+ return objfile_up.release();
+ return nullptr;
+}
+
+bool ObjectFileWasm::DecodeNextSection(lldb::offset_t *offset_ptr) {
+ // Buffer sufficient to read a section header and find the pointer to the next
+ // section.
+ const uint32_t kBufferSize = 1024;
+ DataExtractor section_header_data = ReadImageData(*offset_ptr, kBufferSize);
+
+ llvm::DataExtractor data = section_header_data.GetAsLLVM();
+ llvm::DataExtractor::Cursor c(0);
+
+ // Each section consists of:
+ // - a one-byte section id,
+ // - the u32 size of the contents, in bytes,
+ // - the actual contents.
+ uint8_t section_id = data.getU8(c);
+ uint64_t payload_len = data.getULEB128(c);
+ if (!c)
+ return !llvm::errorToBool(c.takeError());
+
+ if (payload_len >= (uint64_t(1) << 32))
+ return false;
+
+ if (section_id == llvm::wasm::WASM_SEC_CUSTOM) {
+ // Custom sections have the id 0. Their contents consist of a name
+ // identifying the custom section, followed by an uninterpreted sequence
+ // of bytes.
+ lldb::offset_t prev_offset = c.tell();
+ llvm::Optional<ConstString> sect_name = GetWasmString(data, c);
+ if (!sect_name)
+ return false;
+
+ if (payload_len < c.tell() - prev_offset)
+ return false;
+
+ uint32_t section_length = payload_len - (c.tell() - prev_offset);
+ m_sect_infos.push_back(section_info{*offset_ptr + c.tell(), section_length,
+ section_id, *sect_name});
+ *offset_ptr += (c.tell() + section_length);
+ } else if (section_id <= llvm::wasm::WASM_SEC_EVENT) {
+ m_sect_infos.push_back(section_info{*offset_ptr + c.tell(),
+ static_cast<uint32_t>(payload_len),
+ section_id, ConstString()});
+ *offset_ptr += (c.tell() + payload_len);
+ } else {
+ // Invalid section id.
+ return false;
+ }
+ return true;
+}
+
+bool ObjectFileWasm::DecodeSections() {
+ lldb::offset_t offset = kWasmHeaderSize;
+ if (IsInMemory()) {
+ offset += m_memory_addr;
+ }
+
+ while (DecodeNextSection(&offset))
+ ;
+ return true;
+}
+
+size_t ObjectFileWasm::GetModuleSpecifications(
+ const FileSpec &file, DataBufferSP &data_sp, offset_t data_offset,
+ offset_t file_offset, offset_t length, ModuleSpecList &specs) {
+ if (!ValidateModuleHeader(data_sp)) {
+ return 0;
+ }
+
+ ModuleSpec spec(file, ArchSpec("wasm32-unknown-unknown-wasm"));
+ specs.Append(spec);
+ return 1;
+}
+
+ObjectFileWasm::ObjectFileWasm(const ModuleSP &module_sp, DataBufferSP &data_sp,
+ offset_t data_offset, const FileSpec *file,
+ offset_t offset, offset_t length)
+ : ObjectFile(module_sp, file, offset, length, data_sp, data_offset),
+ m_arch("wasm32-unknown-unknown-wasm") {
+ m_data.SetAddressByteSize(4);
+}
+
+ObjectFileWasm::ObjectFileWasm(const lldb::ModuleSP &module_sp,
+ lldb::DataBufferSP &header_data_sp,
+ const lldb::ProcessSP &process_sp,
+ lldb::addr_t header_addr)
+ : ObjectFile(module_sp, process_sp, header_addr, header_data_sp),
+ m_arch("wasm32-unknown-unknown-wasm") {}
+
+bool ObjectFileWasm::ParseHeader() {
+ // We already parsed the header during initialization.
+ return true;
+}
+
+Symtab *ObjectFileWasm::GetSymtab() { return nullptr; }
+
+void ObjectFileWasm::CreateSections(SectionList &unified_section_list) {
+ if (m_sections_up)
+ return;
+
+ m_sections_up = std::make_unique<SectionList>();
+
+ if (m_sect_infos.empty()) {
+ DecodeSections();
+ }
+
+ for (const section_info &sect_info : m_sect_infos) {
+ SectionType section_type = eSectionTypeOther;
+ ConstString section_name;
+ offset_t file_offset = sect_info.offset & 0xffffffff;
+ addr_t vm_addr = file_offset;
+ size_t vm_size = sect_info.size;
+
+ if (llvm::wasm::WASM_SEC_CODE == sect_info.id) {
+ section_type = eSectionTypeCode;
+ section_name = ConstString("code");
+
+ // A code address in DWARF for WebAssembly is the offset of an
+ // instruction relative within the Code section of the WebAssembly file.
+ // For this reason Section::GetFileAddress() must return zero for the
+ // Code section.
+ vm_addr = 0;
+ } else {
+ section_type =
+ llvm::StringSwitch<SectionType>(sect_info.name.GetStringRef())
+ .Case(".debug_abbrev", eSectionTypeDWARFDebugAbbrev)
+ .Case(".debug_addr", eSectionTypeDWARFDebugAddr)
+ .Case(".debug_aranges", eSectionTypeDWARFDebugAranges)
+ .Case(".debug_cu_index", eSectionTypeDWARFDebugCuIndex)
+ .Case(".debug_frame", eSectionTypeDWARFDebugFrame)
+ .Case(".debug_info", eSectionTypeDWARFDebugInfo)
+ .Case(".debug_line", eSectionTypeDWARFDebugLine)
+ .Case(".debug_line_str", eSectionTypeDWARFDebugLineStr)
+ .Case(".debug_loc", eSectionTypeDWARFDebugLoc)
+ .Case(".debug_loclists", eSectionTypeDWARFDebugLocLists)
+ .Case(".debug_macinfo", eSectionTypeDWARFDebugMacInfo)
+ .Case(".debug_macro", eSectionTypeDWARFDebugMacro)
+ .Case(".debug_names", eSectionTypeDWARFDebugNames)
+ .Case(".debug_pubnames", eSectionTypeDWARFDebugPubNames)
+ .Case(".debug_pubtypes", eSectionTypeDWARFDebugPubTypes)
+ .Case(".debug_ranges", eSectionTypeDWARFDebugRanges)
+ .Case(".debug_rnglists", eSectionTypeDWARFDebugRngLists)
+ .Case(".debug_str", eSectionTypeDWARFDebugStr)
+ .Case(".debug_str_offsets", eSectionTypeDWARFDebugStrOffsets)
+ .Case(".debug_types", eSectionTypeDWARFDebugTypes)
+ .Default(eSectionTypeOther);
+ if (section_type == eSectionTypeOther)
+ continue;
+ section_name = sect_info.name;
+ if (!IsInMemory()) {
+ vm_size = 0;
+ vm_addr = 0;
+ }
+ }
+
+ SectionSP section_sp(
+ new Section(GetModule(), // Module to which this section belongs.
+ this, // ObjectFile to which this section belongs and
+ // should read section data from.
+ section_type, // Section ID.
+ section_name, // Section name.
+ section_type, // Section type.
+ vm_addr, // VM address.
+ vm_size, // VM size in bytes of this section.
+ file_offset, // Offset of this section in the file.
+ sect_info.size, // Size of the section as found in the file.
+ 0, // Alignment of the section
+ 0, // Flags for this section.
+ 1)); // Number of host bytes per target byte
+ m_sections_up->AddSection(section_sp);
+ unified_section_list.AddSection(section_sp);
+ }
+}
+
+bool ObjectFileWasm::SetLoadAddress(Target &target, lldb::addr_t load_address,
+ bool value_is_offset) {
+ /// In WebAssembly, linear memory is disjointed from code space. The VM can
+ /// load multiple instances of a module, which logically share the same code.
+ /// We represent a wasm32 code address with 64-bits, like:
+ /// 63 32 31 0
+ /// +---------------+---------------+
+ /// + module_id | offset |
+ /// +---------------+---------------+
+ /// where the lower 32 bits represent a module offset (relative to the module
+ /// start not to the beginning of the code section) and the higher 32 bits
+ /// uniquely identify the module in the WebAssembly VM.
+ /// In other words, we assume that each WebAssembly module is loaded by the
+ /// engine at a 64-bit address that starts at the boundary of 4GB pages, like
+ /// 0x0000000400000000 for module_id == 4.
+ /// These 64-bit addresses will be used to request code ranges for a specific
+ /// module from the WebAssembly engine.
+
+ assert(m_memory_addr == LLDB_INVALID_ADDRESS ||
+ m_memory_addr == load_address);
+
+ ModuleSP module_sp = GetModule();
+ if (!module_sp)
+ return false;
+
+ DecodeSections();
+
+ size_t num_loaded_sections = 0;
+ SectionList *section_list = GetSectionList();
+ if (!section_list)
+ return false;
+
+ const size_t num_sections = section_list->GetSize();
+ for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) {
+ SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx));
+ if (target.SetSectionLoadAddress(
+ section_sp, load_address | section_sp->GetFileOffset())) {
+ ++num_loaded_sections;
+ }
+ }
+
+ return num_loaded_sections > 0;
+}
+
+DataExtractor ObjectFileWasm::ReadImageData(offset_t offset, uint32_t size) {
+ DataExtractor data;
+ if (m_file) {
+ if (offset < GetByteSize()) {
+ size = std::min(static_cast<uint64_t>(size), GetByteSize() - offset);
+ auto buffer_sp = MapFileData(m_file, size, offset);
+ return DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize());
+ }
+ } else {
+ ProcessSP process_sp(m_process_wp.lock());
+ if (process_sp) {
+ auto data_up = std::make_unique<DataBufferHeap>(size, 0);
+ Status readmem_error;
+ size_t bytes_read = process_sp->ReadMemory(
+ offset, data_up->GetBytes(), data_up->GetByteSize(), readmem_error);
+ if (bytes_read > 0) {
+ DataBufferSP buffer_sp(data_up.release());
+ data.SetData(buffer_sp, 0, buffer_sp->GetByteSize());
+ }
+ }
+ }
+
+ data.SetByteOrder(GetByteOrder());
+ return data;
+}
+
+llvm::Optional<FileSpec> ObjectFileWasm::GetExternalDebugInfoFileSpec() {
+ static ConstString g_sect_name_external_debug_info("external_debug_info");
+
+ for (const section_info &sect_info : m_sect_infos) {
+ if (g_sect_name_external_debug_info == sect_info.name) {
+ const uint32_t kBufferSize = 1024;
+ DataExtractor section_header_data =
+ ReadImageData(sect_info.offset, kBufferSize);
+ llvm::DataExtractor data = section_header_data.GetAsLLVM();
+ llvm::DataExtractor::Cursor c(0);
+ llvm::Optional<ConstString> symbols_url = GetWasmString(data, c);
+ if (symbols_url)
+ return FileSpec(symbols_url->GetStringRef());
+ }
+ }
+ return llvm::None;
+}
+
+void ObjectFileWasm::Dump(Stream *s) {
+ ModuleSP module_sp(GetModule());
+ if (!module_sp)
+ return;
+
+ std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
+
+ llvm::raw_ostream &ostream = s->AsRawOstream();
+ ostream << static_cast<void *>(this) << ": ";
+ s->Indent();
+ ostream << "ObjectFileWasm, file = '";
+ m_file.Dump(ostream);
+ ostream << "', arch = ";
+ ostream << GetArchitecture().GetArchitectureName() << "\n";
+
+ SectionList *sections = GetSectionList();
+ if (sections) {
+ sections->Dump(s->AsRawOstream(), s->GetIndentLevel(), nullptr, true,
+ UINT32_MAX);
+ }
+ ostream << "\n";
+ DumpSectionHeaders(ostream);
+ ostream << "\n";
+}
+
+void ObjectFileWasm::DumpSectionHeader(llvm::raw_ostream &ostream,
+ const section_info_t &sh) {
+ ostream << llvm::left_justify(sh.name.GetStringRef(), 16) << " "
+ << llvm::format_hex(sh.offset, 10) << " "
+ << llvm::format_hex(sh.size, 10) << " " << llvm::format_hex(sh.id, 6)
+ << "\n";
+}
+
+void ObjectFileWasm::DumpSectionHeaders(llvm::raw_ostream &ostream) {
+ ostream << "Section Headers\n";
+ ostream << "IDX name addr size id\n";
+ ostream << "==== ---------------- ---------- ---------- ------\n";
+
+ uint32_t idx = 0;
+ for (auto pos = m_sect_infos.begin(); pos != m_sect_infos.end();
+ ++pos, ++idx) {
+ ostream << "[" << llvm::format_decimal(idx, 2) << "] ";
+ ObjectFileWasm::DumpSectionHeader(ostream, *pos);
+ }
+}
diff --git a/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
new file mode 100644
index 000000000000..b6e906a7b15f
--- /dev/null
+++ b/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
@@ -0,0 +1,151 @@
+//===-- ObjectFileWasm.h ----------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_WASM_OBJECTFILEWASM_H
+#define LLDB_SOURCE_PLUGINS_OBJECTFILE_WASM_OBJECTFILEWASM_H
+
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Utility/ArchSpec.h"
+
+namespace lldb_private {
+namespace wasm {
+
+/// Generic Wasm object file reader.
+///
+/// This class provides a generic wasm32 reader plugin implementing the
+/// ObjectFile protocol.
+class ObjectFileWasm : public ObjectFile {
+public:
+ static void Initialize();
+ static void Terminate();
+
+ static ConstString GetPluginNameStatic();
+ static const char *GetPluginDescriptionStatic() {
+ return "WebAssembly object file reader.";
+ }
+
+ static ObjectFile *
+ CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
+ lldb::offset_t data_offset, const FileSpec *file,
+ lldb::offset_t file_offset, lldb::offset_t length);
+
+ static ObjectFile *CreateMemoryInstance(const lldb::ModuleSP &module_sp,
+ lldb::DataBufferSP &data_sp,
+ const lldb::ProcessSP &process_sp,
+ lldb::addr_t header_addr);
+
+ static size_t GetModuleSpecifications(const FileSpec &file,
+ lldb::DataBufferSP &data_sp,
+ lldb::offset_t data_offset,
+ lldb::offset_t file_offset,
+ lldb::offset_t length,
+ ModuleSpecList &specs);
+
+ /// PluginInterface protocol.
+ /// \{
+ ConstString GetPluginName() override { return GetPluginNameStatic(); }
+ uint32_t GetPluginVersion() override { return 1; }
+ /// \}
+
+ /// LLVM RTTI support
+ /// \{
+ static char ID;
+ bool isA(const void *ClassID) const override {
+ return ClassID == &ID || ObjectFile::isA(ClassID);
+ }
+ static bool classof(const ObjectFile *obj) { return obj->isA(&ID); }
+ /// \}
+
+ /// ObjectFile Protocol.
+ /// \{
+ bool ParseHeader() override;
+
+ lldb::ByteOrder GetByteOrder() const override {
+ return m_arch.GetByteOrder();
+ }
+
+ bool IsExecutable() const override { return false; }
+
+ uint32_t GetAddressByteSize() const override {
+ return m_arch.GetAddressByteSize();
+ }
+
+ AddressClass GetAddressClass(lldb::addr_t file_addr) override {
+ return AddressClass::eInvalid;
+ }
+
+ Symtab *GetSymtab() override;
+
+ bool IsStripped() override { return !!GetExternalDebugInfoFileSpec(); }
+
+ void CreateSections(SectionList &unified_section_list) override;
+
+ void Dump(Stream *s) override;
+
+ ArchSpec GetArchitecture() override { return m_arch; }
+
+ UUID GetUUID() override { return m_uuid; }
+
+ uint32_t GetDependentModules(FileSpecList &files) override { return 0; }
+
+ Type CalculateType() override { return eTypeSharedLibrary; }
+
+ Strata CalculateStrata() override { return eStrataUser; }
+
+ bool SetLoadAddress(lldb_private::Target &target, lldb::addr_t value,
+ bool value_is_offset) override;
+
+ lldb_private::Address GetBaseAddress() override {
+ return IsInMemory() ? Address(m_memory_addr) : Address(0);
+ }
+ /// \}
+
+ /// A Wasm module that has external DWARF debug information should contain a
+ /// custom section named "external_debug_info", whose payload is an UTF-8
+ /// encoded string that points to a Wasm module that contains the debug
+ /// information for this module.
+ llvm::Optional<FileSpec> GetExternalDebugInfoFileSpec();
+
+private:
+ ObjectFileWasm(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
+ lldb::offset_t data_offset, const FileSpec *file,
+ lldb::offset_t offset, lldb::offset_t length);
+ ObjectFileWasm(const lldb::ModuleSP &module_sp,
+ lldb::DataBufferSP &header_data_sp,
+ const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
+
+ /// Wasm section decoding routines.
+ /// \{
+ bool DecodeNextSection(lldb::offset_t *offset_ptr);
+ bool DecodeSections();
+ /// \}
+
+ /// Read a range of bytes from the Wasm module.
+ DataExtractor ReadImageData(lldb::offset_t offset, uint32_t size);
+
+ typedef struct section_info {
+ lldb::offset_t offset;
+ uint32_t size;
+ uint32_t id;
+ ConstString name;
+ } section_info_t;
+
+ /// Wasm section header dump routines.
+ /// \{
+ void DumpSectionHeader(llvm::raw_ostream &ostream, const section_info_t &sh);
+ void DumpSectionHeaders(llvm::raw_ostream &ostream);
+ /// \}
+
+ std::vector<section_info_t> m_sect_infos;
+ ArchSpec m_arch;
+ UUID m_uuid;
+};
+
+} // namespace wasm
+} // namespace lldb_private
+#endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_WASM_OBJECTFILEWASM_H
diff --git a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
index b04ac61c99a1..417aa2e21436 100644
--- a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
+++ b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
@@ -1,4 +1,4 @@
-//===-- OperatingSystemPython.cpp --------------------------------*- C++-*-===//
+//===-- OperatingSystemPython.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -39,6 +39,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(OperatingSystemPython)
+
void OperatingSystemPython::Initialize() {
PluginManager::RegisterPlugin(GetPluginNameStatic(),
GetPluginDescriptionStatic(), CreateInstance,
@@ -337,7 +339,7 @@ OperatingSystemPython::CreateRegisterContextForThread(Thread *thread,
m_interpreter->OSPlugin_RegisterContextData(m_python_object_sp,
thread->GetID());
if (reg_context_data) {
- std::string value = reg_context_data->GetValue();
+ std::string value = std::string(reg_context_data->GetValue());
DataBufferSP data_sp(new DataBufferHeap(value.c_str(), value.length()));
if (data_sp->GetByteSize()) {
RegisterContextMemory *reg_ctx_memory = new RegisterContextMemory(
diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
index 261f44c230f9..97c2f22b505f 100644
--- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
+++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
@@ -1,4 +1,4 @@
-//===-- PlatformFreeBSD.cpp -------------------------------------*- C++ -*-===//
+//===-- PlatformFreeBSD.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -36,6 +36,8 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::platform_freebsd;
+LLDB_PLUGIN_DEFINE(PlatformFreeBSD)
+
static uint32_t g_initialize_count = 0;
diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
index e3a3aa7145f0..56f2f2771d12 100644
--- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
+++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_PlatformFreeBSD_h_
-#define liblldb_PlatformFreeBSD_h_
+#ifndef LLDB_SOURCE_PLUGINS_PLATFORM_FREEBSD_PLATFORMFREEBSD_H
+#define LLDB_SOURCE_PLUGINS_PLATFORM_FREEBSD_PLATFORMFREEBSD_H
#include "Plugins/Platform/POSIX/PlatformPOSIX.h"
@@ -62,10 +62,11 @@ public:
lldb::addr_t offset) override;
private:
- DISALLOW_COPY_AND_ASSIGN(PlatformFreeBSD);
+ PlatformFreeBSD(const PlatformFreeBSD &) = delete;
+ const PlatformFreeBSD &operator=(const PlatformFreeBSD &) = delete;
};
} // namespace platform_freebsd
} // namespace lldb_private
-#endif // liblldb_PlatformFreeBSD_h_
+#endif // LLDB_SOURCE_PLUGINS_PLATFORM_FREEBSD_PLATFORMFREEBSD_H
diff --git a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
index 53f819e6a272..caebd79c853e 100644
--- a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
+++ b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
@@ -1,4 +1,4 @@
-//===-- PlatformNetBSD.cpp -------------------------------------*- C++ -*-===//
+//===-- PlatformNetBSD.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -34,6 +34,8 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::platform_netbsd;
+LLDB_PLUGIN_DEFINE(PlatformNetBSD)
+
static uint32_t g_initialize_count = 0;
@@ -329,14 +331,14 @@ PlatformNetBSD::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
// Hook up process PTY if we have one (which we should for local debugging
// with llgs).
- int pty_fd = launch_info.GetPTY().ReleaseMasterFileDescriptor();
+ int pty_fd = launch_info.GetPTY().ReleasePrimaryFileDescriptor();
if (pty_fd != PseudoTerminal::invalid_fd) {
process_sp->SetSTDIOFileDescriptor(pty_fd);
LLDB_LOG(log, "hooked up STDIO pty to process");
} else
LLDB_LOG(log, "not using process STDIO pty");
} else {
- LLDB_LOG(log, "process launch failed: {0}", error);
+ LLDB_LOG(log, "{0}", error);
// FIXME figure out appropriate cleanup here. Do we delete the target? Do
// we delete the process? Does our caller do that?
}
diff --git a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
index 0584d92d6c99..d53e58418884 100644
--- a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
+++ b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_PlatformNetBSD_h_
-#define liblldb_PlatformNetBSD_h_
+#ifndef LLDB_SOURCE_PLUGINS_PLATFORM_NETBSD_PLATFORMNETBSD_H
+#define LLDB_SOURCE_PLUGINS_PLATFORM_NETBSD_PLATFORMNETBSD_H
#include "Plugins/Platform/POSIX/PlatformPOSIX.h"
@@ -60,10 +60,11 @@ public:
lldb::addr_t offset) override;
private:
- DISALLOW_COPY_AND_ASSIGN(PlatformNetBSD);
+ PlatformNetBSD(const PlatformNetBSD &) = delete;
+ const PlatformNetBSD &operator=(const PlatformNetBSD &) = delete;
};
} // namespace platform_netbsd
} // namespace lldb_private
-#endif // liblldb_PlatformNetBSD_h_
+#endif // LLDB_SOURCE_PLUGINS_PLATFORM_NETBSD_PLATFORMNETBSD_H
diff --git a/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp b/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
index 1b63e2da0a4f..a743970990a6 100644
--- a/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
+++ b/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
@@ -1,4 +1,4 @@
-//===-- PlatformOpenBSD.cpp -------------------------------------*- C++ -*-===//
+//===-- PlatformOpenBSD.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -34,6 +34,8 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::platform_openbsd;
+LLDB_PLUGIN_DEFINE(PlatformOpenBSD)
+
static uint32_t g_initialize_count = 0;
diff --git a/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h b/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
index 3cb724f30325..9cfe32c3720c 100644
--- a/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
+++ b/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_PlatformOpenBSD_h_
-#define liblldb_PlatformOpenBSD_h_
+#ifndef LLDB_SOURCE_PLUGINS_PLATFORM_OPENBSD_PLATFORMOPENBSD_H
+#define LLDB_SOURCE_PLUGINS_PLATFORM_OPENBSD_PLATFORMOPENBSD_H
#include "Plugins/Platform/POSIX/PlatformPOSIX.h"
@@ -54,10 +54,11 @@ public:
lldb::addr_t offset) override;
private:
- DISALLOW_COPY_AND_ASSIGN(PlatformOpenBSD);
+ PlatformOpenBSD(const PlatformOpenBSD &) = delete;
+ const PlatformOpenBSD &operator=(const PlatformOpenBSD &) = delete;
};
} // namespace platform_openbsd
} // namespace lldb_private
-#endif // liblldb_PlatformOpenBSD_h_
+#endif // LLDB_SOURCE_PLUGINS_PLATFORM_OPENBSD_PLATFORMOPENBSD_H
diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index 2b64be63a623..180ea1d2cfd1 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -1,4 +1,4 @@
-//===-- PlatformPOSIX.cpp ---------------------------------------*- C++ -*-===//
+//===-- PlatformPOSIX.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,9 +8,9 @@
#include "PlatformPOSIX.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
@@ -22,7 +22,6 @@
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/ProcessLaunchInfo.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
@@ -64,148 +63,6 @@ lldb_private::OptionGroupOptions *PlatformPOSIX::GetConnectionOptions(
return m_options.at(&interpreter).get();
}
-Status
-PlatformPOSIX::ResolveExecutable(const ModuleSpec &module_spec,
- lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr) {
- Status 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 exe_file, resolve the executable location based
- // on the current path variables
- if (!FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) {
- resolved_module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
- resolved_module_spec.GetFileSpec().SetFile(exe_path,
- FileSpec::Style::native);
- FileSystem::Instance().Resolve(resolved_module_spec.GetFileSpec());
- }
-
- if (!FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec()))
- FileSystem::Instance().ResolveExecutableLocation(
- resolved_module_spec.GetFileSpec());
-
- // Resolve any executable within a bundle on MacOSX
- Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
-
- if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec()))
- error.Clear();
- else {
- const uint32_t permissions = FileSystem::Instance().GetPermissions(
- resolved_module_spec.GetFileSpec());
- if (permissions && (permissions & eFilePermissionsEveryoneR) == 0)
- error.SetErrorStringWithFormat(
- "executable '%s' is not readable",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
- 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 (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec()))
- error.Clear();
- else
- error.SetErrorStringWithFormat("the platform is not currently "
- "connected, and '%s' doesn't exist in "
- "the system root.",
- exe_path);
- }
- }
-
- if (error.Success()) {
- if (resolved_module_spec.GetArchitecture().IsValid()) {
- error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
- module_search_paths_ptr, nullptr, nullptr);
- if (error.Fail()) {
- // If we failed, it may be because the vendor and os aren't known. If
- // that is the case, try setting them to the host architecture and give
- // it another try.
- llvm::Triple &module_triple =
- resolved_module_spec.GetArchitecture().GetTriple();
- bool is_vendor_specified =
- (module_triple.getVendor() != llvm::Triple::UnknownVendor);
- bool is_os_specified =
- (module_triple.getOS() != llvm::Triple::UnknownOS);
- if (!is_vendor_specified || !is_os_specified) {
- const llvm::Triple &host_triple =
- HostInfo::GetArchitecture(HostInfo::eArchKindDefault).GetTriple();
-
- if (!is_vendor_specified)
- module_triple.setVendorName(host_triple.getVendorName());
- if (!is_os_specified)
- module_triple.setOSName(host_triple.getOSName());
-
- error = ModuleList::GetSharedModule(resolved_module_spec,
- exe_module_sp, module_search_paths_ptr, nullptr, nullptr);
- }
- }
-
- // TODO find out why exe_module_sp might be NULL
- if (error.Fail() || !exe_module_sp || !exe_module_sp->GetObjectFile()) {
- 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, nullptr, nullptr);
- // 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 (FileSystem::Instance().Readable(
- resolved_module_spec.GetFileSpec())) {
- error.SetErrorStringWithFormat(
- "'%s' doesn't contain any '%s' platform architectures: %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- GetPluginName().GetCString(), arch_names.GetData());
- } else {
- error.SetErrorStringWithFormat(
- "'%s' is not readable",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- }
- }
-
- return error;
-}
-
static uint32_t chown_file(Platform *platform, const char *path,
uint32_t uid = UINT32_MAX,
uint32_t gid = UINT32_MAX) {
@@ -429,7 +286,7 @@ std::string PlatformPOSIX::GetPlatformSpecificConnectionInformation() {
if (GetLocalCacheDirectory() && *GetLocalCacheDirectory())
stream.Printf("cache dir: %s", GetLocalCacheDirectory());
if (stream.GetSize())
- return stream.GetString();
+ return std::string(stream.GetString());
else
return "";
}
@@ -679,7 +536,7 @@ PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
static const char *dlopen_wrapper_name = "__lldb_dlopen_wrapper";
Process *process = exe_ctx.GetProcessSP().get();
// Insert the dlopen shim defines into our generic expression:
- std::string expr(GetLibdlFunctionDeclarations(process));
+ std::string expr(std::string(GetLibdlFunctionDeclarations(process)));
expr.append(dlopen_wrapper_code);
Status utility_error;
DiagnosticManager diagnostics;
@@ -706,7 +563,7 @@ PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
FunctionCaller *do_dlopen_function = nullptr;
// Fetch the clang types we will need:
- ClangASTContext *ast = ClangASTContext::GetScratch(process->GetTarget());
+ TypeSystemClang *ast = TypeSystemClang::GetScratch(process->GetTarget());
if (!ast)
return nullptr;
@@ -950,9 +807,9 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process *process,
Value return_value;
// Fetch the clang types we will need:
- ClangASTContext *ast = ClangASTContext::GetScratch(process->GetTarget());
+ TypeSystemClang *ast = TypeSystemClang::GetScratch(process->GetTarget());
if (!ast) {
- error.SetErrorString("dlopen error: Unable to get ClangASTContext");
+ error.SetErrorString("dlopen error: Unable to get TypeSystemClang");
return LLDB_INVALID_IMAGE_TOKEN;
}
diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
index 5858f99088e6..72c54f4147c2 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_PlatformPOSIX_h_
-#define liblldb_PlatformPOSIX_h_
+#ifndef LLDB_SOURCE_PLUGINS_PLATFORM_POSIX_PLATFORMPOSIX_H
+#define LLDB_SOURCE_PLUGINS_PLATFORM_POSIX_PLATFORMPOSIX_H
#include <map>
#include <memory>
@@ -37,10 +37,6 @@ public:
const lldb::UnixSignalsSP &GetRemoteUnixSignals() override;
- lldb_private::Status ResolveExecutable(
- const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr) override;
-
lldb::ProcessSP Attach(lldb_private::ProcessAttachInfo &attach_info,
lldb_private::Debugger &debugger,
lldb_private::Target *target, // Can be nullptr, if
@@ -105,7 +101,8 @@ protected:
llvm::StringRef GetLibdlFunctionDeclarations(lldb_private::Process *process);
private:
- DISALLOW_COPY_AND_ASSIGN(PlatformPOSIX);
+ PlatformPOSIX(const PlatformPOSIX &) = delete;
+ const PlatformPOSIX &operator=(const PlatformPOSIX &) = delete;
};
-#endif // liblldb_PlatformPOSIX_h_
+#endif // LLDB_SOURCE_PLUGINS_PLATFORM_POSIX_PLATFORMPOSIX_H
diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index 1e62ddfe94fd..21bf7f4ac46d 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -1,4 +1,4 @@
-//===-- PlatformRemoteGDBServer.cpp -----------------------------*- C++ -*-===//
+//===-- PlatformRemoteGDBServer.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -35,6 +35,8 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::platform_gdb_server;
+LLDB_PLUGIN_DEFINE_ADV(PlatformRemoteGDBServer, PlatformGDB)
+
static bool g_initialized = false;
void PlatformRemoteGDBServer::Initialize() {
@@ -286,40 +288,55 @@ Status PlatformRemoteGDBServer::ConnectRemote(Args &args) {
"execute 'platform disconnect' to close the "
"current connection",
GetHostname());
+ return error;
+ }
+
+ if (args.GetArgumentCount() != 1) {
+ error.SetErrorString(
+ "\"platform connect\" takes a single argument: <connect-url>");
+ return error;
+ }
+
+ const char *url = args.GetArgumentAtIndex(0);
+ if (!url)
+ return Status("URL is null.");
+
+ int port;
+ llvm::StringRef scheme, hostname, pathname;
+ if (!UriParser::Parse(url, scheme, hostname, port, pathname))
+ return Status("Invalid URL: %s", url);
+
+ // We're going to reuse the hostname when we connect to the debugserver.
+ m_platform_scheme = std::string(scheme);
+ m_platform_hostname = std::string(hostname);
+
+ m_gdb_client.SetConnection(std::make_unique<ConnectionFileDescriptor>());
+ if (repro::Reproducer::Instance().IsReplaying()) {
+ error = m_gdb_replay_server.Connect(m_gdb_client);
+ if (error.Success())
+ m_gdb_replay_server.StartAsyncThread();
} else {
- if (args.GetArgumentCount() == 1) {
- m_gdb_client.SetConnection(new ConnectionFileDescriptor());
- // we're going to reuse the hostname when we connect to the debugserver
- int port;
- std::string path;
- const char *url = args.GetArgumentAtIndex(0);
- if (!url)
- return Status("URL is null.");
- llvm::StringRef scheme, hostname, pathname;
- if (!UriParser::Parse(url, scheme, hostname, port, pathname))
- return Status("Invalid URL: %s", url);
- m_platform_scheme = scheme;
- m_platform_hostname = hostname;
- path = pathname;
-
- const ConnectionStatus status = m_gdb_client.Connect(url, &error);
- if (status == eConnectionStatusSuccess) {
- if (m_gdb_client.HandshakeWithServer(&error)) {
- m_gdb_client.GetHostInfo();
- // If a working directory was set prior to connecting, send it down
- // now
- if (m_working_dir)
- m_gdb_client.SetWorkingDir(m_working_dir);
- } else {
- m_gdb_client.Disconnect();
- if (error.Success())
- error.SetErrorString("handshake failed");
- }
- }
- } else {
- error.SetErrorString(
- "\"platform connect\" takes a single argument: <connect-url>");
+ if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator()) {
+ repro::GDBRemoteProvider &provider =
+ g->GetOrCreate<repro::GDBRemoteProvider>();
+ m_gdb_client.SetPacketRecorder(provider.GetNewPacketRecorder());
}
+ m_gdb_client.Connect(url, &error);
+ }
+
+ if (error.Fail())
+ return error;
+
+ if (m_gdb_client.HandshakeWithServer(&error)) {
+ m_gdb_client.GetHostInfo();
+ // If a working directory was set prior to connecting, send it down
+ // now.
+ if (m_working_dir)
+ m_gdb_client.SetWorkingDir(m_working_dir);
+ } else {
+ m_gdb_client.Disconnect();
+ if (error.Success())
+ error.SetErrorString("handshake failed");
}
return error;
}
@@ -486,10 +503,10 @@ lldb::ProcessSP PlatformRemoteGDBServer::DebugProcess(
"gdb-remote", nullptr);
if (process_sp) {
- error = process_sp->ConnectRemote(nullptr, connect_url.c_str());
+ error = process_sp->ConnectRemote(connect_url.c_str());
// Retry the connect remote one time...
if (error.Fail())
- error = process_sp->ConnectRemote(nullptr, connect_url.c_str());
+ error = process_sp->ConnectRemote(connect_url.c_str());
if (error.Success())
error = process_sp->Launch(launch_info);
else if (debugserver_pid != LLDB_INVALID_PROCESS_ID) {
@@ -572,7 +589,7 @@ lldb::ProcessSP PlatformRemoteGDBServer::Attach(
target->CreateProcess(attach_info.GetListenerForProcess(debugger),
"gdb-remote", nullptr);
if (process_sp) {
- error = process_sp->ConnectRemote(nullptr, connect_url.c_str());
+ error = process_sp->ConnectRemote(connect_url.c_str());
if (error.Success()) {
ListenerSP listener_sp = attach_info.GetHijackListener();
if (listener_sp)
@@ -725,7 +742,8 @@ const UnixSignalsSP &PlatformRemoteGDBServer::GetRemoteUnixSignals() {
response.GetResponseType() != response.eResponse)
return m_remote_signals_sp;
- auto object_sp = StructuredData::ParseJSON(response.GetStringRef());
+ auto object_sp =
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
if (!object_sp || !object_sp->IsValid())
return m_remote_signals_sp;
@@ -772,7 +790,7 @@ const UnixSignalsSP &PlatformRemoteGDBServer::GetRemoteUnixSignals() {
std::string description{""};
object_sp = dict->GetValueForKey("description");
if (object_sp && object_sp->IsValid())
- description = object_sp->GetStringValue();
+ description = std::string(object_sp->GetStringValue());
remote_signals_sp->AddSignal(signo, name.str().c_str(), suppress, stop,
notify, description.c_str());
@@ -811,7 +829,7 @@ std::string PlatformRemoteGDBServer::MakeUrl(const char *scheme,
result.Printf(":%u", port);
if (path)
result.Write(path, strlen(path));
- return result.GetString();
+ return std::string(result.GetString());
}
lldb::ProcessSP PlatformRemoteGDBServer::ConnectProcess(
diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
index 13edcbab9f59..0602be1fa377 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
@@ -7,13 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_PlatformRemoteGDBServer_h_
-#define liblldb_PlatformRemoteGDBServer_h_
+#ifndef LLDB_SOURCE_PLUGINS_PLATFORM_GDB_SERVER_PLATFORMREMOTEGDBSERVER_H
+#define LLDB_SOURCE_PLUGINS_PLATFORM_GDB_SERVER_PLATFORMREMOTEGDBSERVER_H
#include <string>
-#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h"
#include "Plugins/Process/Utility/GDBRemoteSignals.h"
+#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h"
+#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h"
#include "lldb/Target/Platform.h"
namespace lldb_private {
@@ -164,6 +165,7 @@ public:
protected:
process_gdb_remote::GDBRemoteCommunicationClient m_gdb_client;
+ process_gdb_remote::GDBRemoteCommunicationReplayServer m_gdb_replay_server;
std::string m_platform_description; // After we connect we can get a more
// complete description of what we are
// connected to
@@ -192,10 +194,12 @@ private:
llvm::Optional<std::string> DoGetUserName(UserIDResolver::id_t uid) override;
llvm::Optional<std::string> DoGetGroupName(UserIDResolver::id_t uid) override;
- DISALLOW_COPY_AND_ASSIGN(PlatformRemoteGDBServer);
+ PlatformRemoteGDBServer(const PlatformRemoteGDBServer &) = delete;
+ const PlatformRemoteGDBServer &
+ operator=(const PlatformRemoteGDBServer &) = delete;
};
} // namespace platform_gdb_server
} // namespace lldb_private
-#endif // liblldb_PlatformRemoteGDBServer_h_
+#endif // LLDB_SOURCE_PLUGINS_PLATFORM_GDB_SERVER_PLATFORMREMOTEGDBSERVER_H
diff --git a/lldb/source/Plugins/Plugins.def.in b/lldb/source/Plugins/Plugins.def.in
new file mode 100644
index 000000000000..bf54598fb2f3
--- /dev/null
+++ b/lldb/source/Plugins/Plugins.def.in
@@ -0,0 +1,37 @@
+/*===- lldb/source/Plugin/Plugins.def ---------------------------*- C++ -*-===*\
+|* *|
+|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
+|* Exceptions. *|
+|* See https://llvm.org/LICENSE.txt for license information. *|
+|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
+|* *|
+|*===----------------------------------------------------------------------===*|
+|* *|
+|* This file enumerates all of the plugins supported by this build of LLDB. *|
+|* Clients of this file should define the LLDB_PLUGIN macro to be a *|
+|* function-like macro with a single parameter (the name of the plugin) *|
+|* including this file will then enumerate all of the plugins. Script *|
+|* interpreter plugins can be enumerated separately by defining *|
+|* LLDB_SCRIPT_PLUGIN in which case they are not part of LLDB_PLUGIN. *|
+|* *|
+|* *|
+|* The set of plugins supported by LLDB is generated at configuration *|
+|* time, at which point this header is generated. Do not modify this *|
+|* header directly. *|
+|* *|
+\*===----------------------------------------------------------------------===*/
+
+#ifndef LLDB_PLUGIN
+# error Please define the macro LLDB_PLUGIN(PluginName)
+#endif
+
+#ifndef LLDB_SCRIPT_PLUGIN
+#define LLDB_SCRIPT_PLUGIN(p) LLDB_PLUGIN(p)
+#endif
+
+@LLDB_ENUM_PLUGINS@
+@LLDB_PROCESS_WINDOWS_PLUGIN@
+@LLDB_PROCESS_GDB_PLUGIN@
+
+#undef LLDB_PLUGIN
+#undef LLDB_SCRIPT_PLUGIN
diff --git a/lldb/source/Plugins/Process/Darwin/CFBundle.cpp b/lldb/source/Plugins/Process/Darwin/CFBundle.cpp
deleted file mode 100644
index 3cdd2fa575e7..000000000000
--- a/lldb/source/Plugins/Process/Darwin/CFBundle.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-//===-- CFBundle.cpp --------------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Created by Greg Clayton on 1/16/08.
-//
-//===----------------------------------------------------------------------===//
-
-#include "CFBundle.h"
-#include "CFString.h"
-
-// CFBundle constructor
-CFBundle::CFBundle(const char *path)
- : CFReleaser<CFBundleRef>(), m_bundle_url() {
- if (path && path[0])
- SetPath(path);
-}
-
-// CFBundle copy constructor
-CFBundle::CFBundle(const CFBundle &rhs)
- : CFReleaser<CFBundleRef>(rhs), m_bundle_url(rhs.m_bundle_url) {}
-
-// CFBundle copy constructor
-CFBundle &CFBundle::operator=(const CFBundle &rhs) {
- *this = rhs;
- return *this;
-}
-
-// Destructor
-CFBundle::~CFBundle() {}
-
-// Set the path for a bundle by supplying a
-bool CFBundle::SetPath(const char *path) {
- CFAllocatorRef alloc = kCFAllocatorDefault;
- // Release our old bundle and ULR
- reset(); // This class is a CFReleaser<CFBundleRef>
- m_bundle_url.reset();
- // Make a CFStringRef from the supplied path
- CFString cf_path;
- cf_path.SetFileSystemRepresentation(path);
- if (cf_path.get()) {
- // Make our Bundle URL
- m_bundle_url.reset(::CFURLCreateWithFileSystemPath(
- alloc, cf_path.get(), kCFURLPOSIXPathStyle, true));
- if (m_bundle_url.get()) {
- reset(::CFBundleCreate(alloc, m_bundle_url.get()));
- }
- }
- return get() != NULL;
-}
-
-CFStringRef CFBundle::GetIdentifier() const {
- CFBundleRef bundle = get();
- if (bundle != NULL)
- return ::CFBundleGetIdentifier(bundle);
- return NULL;
-}
-
-CFURLRef CFBundle::CopyExecutableURL() const {
- CFBundleRef bundle = get();
- if (bundle != NULL)
- return CFBundleCopyExecutableURL(bundle);
- return NULL;
-}
diff --git a/lldb/source/Plugins/Process/Darwin/CFBundle.h b/lldb/source/Plugins/Process/Darwin/CFBundle.h
deleted file mode 100644
index f49dc30f1f8f..000000000000
--- a/lldb/source/Plugins/Process/Darwin/CFBundle.h
+++ /dev/null
@@ -1,35 +0,0 @@
-//===-- CFBundle.h ----------------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Created by Greg Clayton on 1/16/08.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef __CFBundle_h__
-#define __CFBundle_h__
-
-#include "CFUtils.h"
-
-class CFBundle : public CFReleaser<CFBundleRef> {
-public:
- // Constructors and Destructors
- CFBundle(const char *path = NULL);
- CFBundle(const CFBundle &rhs);
- CFBundle &operator=(const CFBundle &rhs);
- virtual ~CFBundle();
- bool SetPath(const char *path);
-
- CFStringRef GetIdentifier() const;
-
- CFURLRef CopyExecutableURL() const;
-
-protected:
- CFReleaser<CFURLRef> m_bundle_url;
-};
-
-#endif // #ifndef __CFBundle_h__
diff --git a/lldb/source/Plugins/Process/Darwin/CFString.cpp b/lldb/source/Plugins/Process/Darwin/CFString.cpp
deleted file mode 100644
index 4dcc05c86657..000000000000
--- a/lldb/source/Plugins/Process/Darwin/CFString.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-//===-- CFString.cpp --------------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Created by Greg Clayton on 1/16/08.
-//
-//===----------------------------------------------------------------------===//
-
-#include "CFString.h"
-#include <glob.h>
-#include <string>
-
-// CFString constructor
-CFString::CFString(CFStringRef s) : CFReleaser<CFStringRef>(s) {}
-
-// CFString copy constructor
-CFString::CFString(const CFString &rhs) : CFReleaser<CFStringRef>(rhs) {}
-
-// CFString copy constructor
-CFString &CFString::operator=(const CFString &rhs) {
- if (this != &rhs)
- *this = rhs;
- return *this;
-}
-
-CFString::CFString(const char *cstr, CFStringEncoding cstr_encoding)
- : CFReleaser<CFStringRef>() {
- if (cstr && cstr[0]) {
- reset(
- ::CFStringCreateWithCString(kCFAllocatorDefault, cstr, cstr_encoding));
- }
-}
-
-// Destructor
-CFString::~CFString() {}
-
-const char *CFString::GetFileSystemRepresentation(std::string &s) {
- return CFString::FileSystemRepresentation(get(), s);
-}
-
-CFStringRef CFString::SetFileSystemRepresentation(const char *path) {
- CFStringRef new_value = NULL;
- if (path && path[0])
- new_value =
- ::CFStringCreateWithFileSystemRepresentation(kCFAllocatorDefault, path);
- reset(new_value);
- return get();
-}
-
-CFStringRef CFString::SetFileSystemRepresentationFromCFType(CFTypeRef cf_type) {
- CFStringRef new_value = NULL;
- if (cf_type != NULL) {
- CFTypeID cf_type_id = ::CFGetTypeID(cf_type);
-
- if (cf_type_id == ::CFStringGetTypeID()) {
- // Retain since we are using the existing object
- new_value = (CFStringRef)::CFRetain(cf_type);
- } else if (cf_type_id == ::CFURLGetTypeID()) {
- new_value =
- ::CFURLCopyFileSystemPath((CFURLRef)cf_type, kCFURLPOSIXPathStyle);
- }
- }
- reset(new_value);
- return get();
-}
-
-CFStringRef
-CFString::SetFileSystemRepresentationAndExpandTilde(const char *path) {
- std::string expanded_path;
- if (CFString::GlobPath(path, expanded_path))
- SetFileSystemRepresentation(expanded_path.c_str());
- else
- reset();
- return get();
-}
-
-const char *CFString::UTF8(std::string &str) {
- return CFString::UTF8(get(), str);
-}
-
-// Static function that puts a copy of the UTF8 contents of CF_STR into STR and
-// returns the C string pointer that is contained in STR when successful, else
-// NULL is returned. This allows the std::string parameter to own the extracted
-// string,
-// and also allows that string to be returned as a C string pointer that can be
-// used.
-
-const char *CFString::UTF8(CFStringRef cf_str, std::string &str) {
- if (cf_str) {
- const CFStringEncoding encoding = kCFStringEncodingUTF8;
- CFIndex max_utf8_str_len = CFStringGetLength(cf_str);
- max_utf8_str_len =
- CFStringGetMaximumSizeForEncoding(max_utf8_str_len, encoding);
- if (max_utf8_str_len > 0) {
- str.resize(max_utf8_str_len);
- if (!str.empty()) {
- if (CFStringGetCString(cf_str, &str[0], str.size(), encoding)) {
- str.resize(strlen(str.c_str()));
- return str.c_str();
- }
- }
- }
- }
- return NULL;
-}
-
-// Static function that puts a copy of the file system representation of CF_STR
-// into STR and returns the C string pointer that is contained in STR when
-// successful, else NULL is returned. This allows the std::string parameter to
-// own the extracted string, and also allows that string to be returned as a C
-// string pointer that can be used.
-
-const char *CFString::FileSystemRepresentation(CFStringRef cf_str,
- std::string &str) {
- if (cf_str) {
- CFIndex max_length =
- ::CFStringGetMaximumSizeOfFileSystemRepresentation(cf_str);
- if (max_length > 0) {
- str.resize(max_length);
- if (!str.empty()) {
- if (::CFStringGetFileSystemRepresentation(cf_str, &str[0],
- str.size())) {
- str.erase(::strlen(str.c_str()));
- return str.c_str();
- }
- }
- }
- }
- str.erase();
- return NULL;
-}
-
-CFIndex CFString::GetLength() const {
- CFStringRef str = get();
- if (str)
- return CFStringGetLength(str);
- return 0;
-}
-
-const char *CFString::GlobPath(const char *path, std::string &expanded_path) {
- glob_t globbuf;
- if (::glob(path, GLOB_TILDE, NULL, &globbuf) == 0) {
- expanded_path = globbuf.gl_pathv[0];
- ::globfree(&globbuf);
- } else
- expanded_path.clear();
-
- return expanded_path.c_str();
-}
diff --git a/lldb/source/Plugins/Process/Darwin/CFString.h b/lldb/source/Plugins/Process/Darwin/CFString.h
deleted file mode 100644
index d1bd5682689e..000000000000
--- a/lldb/source/Plugins/Process/Darwin/CFString.h
+++ /dev/null
@@ -1,40 +0,0 @@
-//===-- CFString.h ----------------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Created by Greg Clayton on 1/16/08.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef __CFString_h__
-#define __CFString_h__
-
-#include "CFUtils.h"
-#include <iosfwd>
-
-class CFString : public CFReleaser<CFStringRef> {
-public:
- // Constructors and Destructors
- CFString(CFStringRef cf_str = NULL);
- CFString(const char *s, CFStringEncoding encoding = kCFStringEncodingUTF8);
- CFString(const CFString &rhs);
- CFString &operator=(const CFString &rhs);
- virtual ~CFString();
-
- const char *GetFileSystemRepresentation(std::string &str);
- CFStringRef SetFileSystemRepresentation(const char *path);
- CFStringRef SetFileSystemRepresentationFromCFType(CFTypeRef cf_type);
- CFStringRef SetFileSystemRepresentationAndExpandTilde(const char *path);
- const char *UTF8(std::string &str);
- CFIndex GetLength() const;
- static const char *UTF8(CFStringRef cf_str, std::string &str);
- static const char *FileSystemRepresentation(CFStringRef cf_str,
- std::string &str);
- static const char *GlobPath(const char *path, std::string &expanded_path);
-};
-
-#endif // #ifndef __CFString_h__
diff --git a/lldb/source/Plugins/Process/Darwin/CFUtils.h b/lldb/source/Plugins/Process/Darwin/CFUtils.h
deleted file mode 100644
index b567524ce63a..000000000000
--- a/lldb/source/Plugins/Process/Darwin/CFUtils.h
+++ /dev/null
@@ -1,75 +0,0 @@
-//===-- CFUtils.h -----------------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Created by Greg Clayton on 3/5/07.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef __CFUtils_h__
-#define __CFUtils_h__
-
-#include <CoreFoundation/CoreFoundation.h>
-
-#ifdef __cplusplus
-
-// Templatized CF helper class that can own any CF pointer and will
-// call CFRelease() on any valid pointer it owns unless that pointer is
-// explicitly released using the release() member function.
-template <class T> class CFReleaser {
-public:
- // Type names for the avlue
- typedef T element_type;
-
- // Constructors and destructors
- CFReleaser(T ptr = NULL) : _ptr(ptr) {}
- CFReleaser(const CFReleaser &copy) : _ptr(copy.get()) {
- if (get())
- ::CFRetain(get());
- }
- virtual ~CFReleaser() { reset(); }
-
- // Assignments
- CFReleaser &operator=(const CFReleaser<T> &copy) {
- if (copy != *this) {
- // Replace our owned pointer with the new one
- reset(copy.get());
- // Retain the current pointer that we own
- if (get())
- ::CFRetain(get());
- }
- }
- // Get the address of the contained type
- T *ptr_address() { return &_ptr; }
-
- // Access the pointer itself
- const T get() const { return _ptr; }
- T get() { return _ptr; }
-
- // Set a new value for the pointer and CFRelease our old
- // value if we had a valid one.
- void reset(T ptr = NULL) {
- if (ptr != _ptr) {
- if (_ptr != NULL)
- ::CFRelease(_ptr);
- _ptr = ptr;
- }
- }
-
- // Release ownership without calling CFRelease
- T release() {
- T tmp = _ptr;
- _ptr = NULL;
- return tmp;
- }
-
-private:
- element_type _ptr;
-};
-
-#endif // #ifdef __cplusplus
-#endif // #ifndef __CFUtils_h__
diff --git a/lldb/source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp b/lldb/source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp
deleted file mode 100644
index f70ef97a2bc5..000000000000
--- a/lldb/source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp
+++ /dev/null
@@ -1,638 +0,0 @@
-//===-- DarwinProcessLauncher.cpp -------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-//
-// DarwinProcessLauncher.cpp
-// lldb
-//
-// Created by Todd Fiala on 8/30/16.
-//
-//
-
-#include "DarwinProcessLauncher.h"
-
-// C includes
-#include <spawn.h>
-#include <sys/ptrace.h>
-#include <sys/stat.h>
-#include <sys/sysctl.h>
-
-#ifndef _POSIX_SPAWN_DISABLE_ASLR
-#define _POSIX_SPAWN_DISABLE_ASLR 0x0100
-#endif
-
-// LLDB includes
-#include "lldb/lldb-enumerations.h"
-
-#include "lldb/Host/PseudoTerminal.h"
-#include "lldb/Target/ProcessLaunchInfo.h"
-#include "lldb/Utility/Log.h"
-#include "lldb/Utility/Status.h"
-#include "lldb/Utility/StreamString.h"
-#include "llvm/Support/Errno.h"
-
-#include "CFBundle.h"
-#include "CFString.h"
-
-using namespace lldb;
-using namespace lldb_private;
-using namespace lldb_private::process_darwin;
-using namespace lldb_private::darwin_process_launcher;
-
-namespace {
-static LaunchFlavor g_launch_flavor = LaunchFlavor::Default;
-}
-
-namespace lldb_private {
-namespace darwin_process_launcher {
-
-static uint32_t GetCPUTypeForLocalProcess(::pid_t pid) {
- int mib[CTL_MAXNAME] = {
- 0,
- };
- size_t len = CTL_MAXNAME;
- if (::sysctlnametomib("sysctl.proc_cputype", mib, &len))
- return 0;
-
- mib[len] = pid;
- len++;
-
- cpu_type_t cpu;
- size_t cpu_len = sizeof(cpu);
- if (::sysctl(mib, static_cast<u_int>(len), &cpu, &cpu_len, 0, 0))
- cpu = 0;
- return cpu;
-}
-
-static bool ResolveExecutablePath(const char *path, char *resolved_path,
- size_t resolved_path_size) {
- if (path == NULL || path[0] == '\0')
- return false;
-
- char max_path[PATH_MAX];
- std::string result;
- CFString::GlobPath(path, result);
-
- if (result.empty())
- result = path;
-
- struct stat path_stat;
- if (::stat(path, &path_stat) == 0) {
- if ((path_stat.st_mode & S_IFMT) == S_IFDIR) {
- CFBundle bundle(path);
- CFReleaser<CFURLRef> url(bundle.CopyExecutableURL());
- if (url.get()) {
- if (::CFURLGetFileSystemRepresentation(
- url.get(), true, (UInt8 *)resolved_path, resolved_path_size))
- return true;
- }
- }
- }
-
- if (realpath(path, max_path)) {
- // Found the path relatively...
- ::strncpy(resolved_path, max_path, resolved_path_size);
- return strlen(resolved_path) + 1 < resolved_path_size;
- } else {
- // Not a relative path, check the PATH environment variable if the
- const char *PATH = getenv("PATH");
- if (PATH) {
- const char *curr_path_start = PATH;
- const char *curr_path_end;
- while (curr_path_start && *curr_path_start) {
- curr_path_end = strchr(curr_path_start, ':');
- if (curr_path_end == NULL) {
- result.assign(curr_path_start);
- curr_path_start = NULL;
- } else if (curr_path_end > curr_path_start) {
- size_t len = curr_path_end - curr_path_start;
- result.assign(curr_path_start, len);
- curr_path_start += len + 1;
- } else
- break;
-
- result += '/';
- result += path;
- struct stat s;
- if (stat(result.c_str(), &s) == 0) {
- ::strncpy(resolved_path, result.c_str(), resolved_path_size);
- return result.size() + 1 < resolved_path_size;
- }
- }
- }
- }
- return false;
-}
-
-// TODO check if we have a general purpose fork and exec. We may be
-// able to get rid of this entirely.
-static Status ForkChildForPTraceDebugging(const char *path, char const *argv[],
- char const *envp[], ::pid_t *pid,
- int *pty_fd) {
- Status error;
- if (!path || !argv || !envp || !pid || !pty_fd) {
- error.SetErrorString("invalid arguments");
- return error;
- }
-
- // Use a fork that ties the child process's stdin/out/err to a pseudo
- // terminal so we can read it in our MachProcess::STDIOThread as unbuffered
- // io.
- PseudoTerminal pty;
- char fork_error[256];
- memset(fork_error, 0, sizeof(fork_error));
- *pid = static_cast<::pid_t>(pty.Fork(fork_error, sizeof(fork_error)));
- if (*pid < 0) {
- // Status during fork.
- *pid = static_cast<::pid_t>(LLDB_INVALID_PROCESS_ID);
- error.SetErrorStringWithFormat("%s(): fork failed: %s", __FUNCTION__,
- fork_error);
- return error;
- } else if (pid == 0) {
- // Child process
-
- // Debug this process.
- ::ptrace(PT_TRACE_ME, 0, 0, 0);
-
- // Get BSD signals as mach exceptions.
- ::ptrace(PT_SIGEXC, 0, 0, 0);
-
- // If our parent is setgid, lets make sure we don't inherit those extra
- // powers due to nepotism.
- if (::setgid(getgid()) == 0) {
- // Let the child have its own process group. We need to execute this call
- // in both the child and parent to avoid a race condition between the two
- // processes.
-
- // Set the child process group to match its pid.
- ::setpgid(0, 0);
-
- // Sleep a bit to before the exec call.
- ::sleep(1);
-
- // Turn this process into the given executable.
- ::execv(path, (char *const *)argv);
- }
- // Exit with error code. Child process should have taken over in above exec
- // call and if the exec fails it will exit the child process below.
- ::exit(127);
- } else {
- // Parent process
- // Let the child have its own process group. We need to execute this call
- // in both the child and parent to avoid a race condition between the two
- // processes.
-
- // Set the child process group to match its pid
- ::setpgid(*pid, *pid);
- if (pty_fd) {
- // Release our master pty file descriptor so the pty class doesn't close
- // it and so we can continue to use it in our STDIO thread
- *pty_fd = pty.ReleaseMasterFileDescriptor();
- }
- }
- return error;
-}
-
-static Status
-CreatePosixSpawnFileAction(const FileAction &action,
- posix_spawn_file_actions_t *file_actions) {
- Status error;
-
- // Log it.
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log) {
- StreamString stream;
- stream.PutCString("converting file action for posix_spawn(): ");
- action.Dump(stream);
- stream.Flush();
- log->PutCString(stream.GetString().c_str());
- }
-
- // Validate args.
- if (!file_actions) {
- error.SetErrorString("mandatory file_actions arg is null");
- return error;
- }
-
- // Build the posix file action.
- switch (action.GetAction()) {
- case FileAction::eFileActionOpen: {
- const int error_code = ::posix_spawn_file_actions_addopen(
- file_actions, action.GetFD(), action.GetPath(),
- action.GetActionArgument(), 0);
- if (error_code != 0) {
- error.SetError(error_code, eErrorTypePOSIX);
- return error;
- }
- break;
- }
-
- case FileAction::eFileActionClose: {
- const int error_code =
- ::posix_spawn_file_actions_addclose(file_actions, action.GetFD());
- if (error_code != 0) {
- error.SetError(error_code, eErrorTypePOSIX);
- return error;
- }
- break;
- }
-
- case FileAction::eFileActionDuplicate: {
- const int error_code = ::posix_spawn_file_actions_adddup2(
- file_actions, action.GetFD(), action.GetActionArgument());
- if (error_code != 0) {
- error.SetError(error_code, eErrorTypePOSIX);
- return error;
- }
- break;
- }
-
- case FileAction::eFileActionNone:
- default:
- LLDB_LOGF(log, "%s(): unsupported file action %u", __FUNCTION__,
- action.GetAction());
- break;
- }
-
- return error;
-}
-
-static Status PosixSpawnChildForPTraceDebugging(const char *path,
- ProcessLaunchInfo &launch_info,
- ::pid_t *pid,
- cpu_type_t *actual_cpu_type) {
- Status error;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-
- if (!pid) {
- error.SetErrorStringWithFormat("%s(): pid arg cannot be null",
- __FUNCTION__);
- return error;
- }
-
- posix_spawnattr_t attr;
- short flags;
- if (log) {
- StreamString stream;
- stream.Printf("%s(path='%s',...)\n", __FUNCTION__, path);
- launch_info.Dump(stream, nullptr);
- stream.Flush();
- log->PutCString(stream.GetString().c_str());
- }
-
- int error_code;
- if ((error_code = ::posix_spawnattr_init(&attr)) != 0) {
- LLDB_LOGF(log, "::posix_spawnattr_init(&attr) failed");
- error.SetError(error_code, eErrorTypePOSIX);
- return error;
- }
-
- // Ensure we clean up the spawnattr structure however we exit this function.
- std::unique_ptr<posix_spawnattr_t, int (*)(posix_spawnattr_t *)> spawnattr_up(
- &attr, ::posix_spawnattr_destroy);
-
- flags = POSIX_SPAWN_START_SUSPENDED | POSIX_SPAWN_SETSIGDEF |
- POSIX_SPAWN_SETSIGMASK;
- if (launch_info.GetFlags().Test(eLaunchFlagDisableASLR))
- flags |= _POSIX_SPAWN_DISABLE_ASLR;
-
- sigset_t no_signals;
- sigset_t all_signals;
- sigemptyset(&no_signals);
- sigfillset(&all_signals);
- ::posix_spawnattr_setsigmask(&attr, &no_signals);
- ::posix_spawnattr_setsigdefault(&attr, &all_signals);
-
- if ((error_code = ::posix_spawnattr_setflags(&attr, flags)) != 0) {
- LLDB_LOG(log,
- "::posix_spawnattr_setflags(&attr, "
- "POSIX_SPAWN_START_SUSPENDED{0}) failed: {1}",
- flags & _POSIX_SPAWN_DISABLE_ASLR ? " | _POSIX_SPAWN_DISABLE_ASLR"
- : "",
- llvm::sys::StrError(error_code));
- error.SetError(error_code, eErrorTypePOSIX);
- return error;
- }
-
-#if !defined(__arm__)
-
- // We don't need to do this for ARM, and we really shouldn't now that we have
- // multiple CPU subtypes and no posix_spawnattr call that allows us to set
- // which CPU subtype to launch...
- cpu_type_t desired_cpu_type = launch_info.GetArchitecture().GetMachOCPUType();
- if (desired_cpu_type != LLDB_INVALID_CPUTYPE) {
- size_t ocount = 0;
- error_code =
- ::posix_spawnattr_setbinpref_np(&attr, 1, &desired_cpu_type, &ocount);
- if (error_code != 0) {
- LLDB_LOG(log,
- "::posix_spawnattr_setbinpref_np(&attr, 1, "
- "cpu_type = {0:x8}, count => {1}): {2}",
- desired_cpu_type, ocount, llvm::sys::StrError(error_code));
- error.SetError(error_code, eErrorTypePOSIX);
- return error;
- }
- if (ocount != 1) {
- error.SetErrorStringWithFormat("posix_spawnattr_setbinpref_np "
- "did not set the expected number "
- "of cpu_type entries: expected 1 "
- "but was %zu",
- ocount);
- return error;
- }
- }
-#endif
-
- posix_spawn_file_actions_t file_actions;
- if ((error_code = ::posix_spawn_file_actions_init(&file_actions)) != 0) {
- LLDB_LOG(log, "::posix_spawn_file_actions_init(&file_actions) failed: {0}",
- llvm::sys::StrError(error_code));
- error.SetError(error_code, eErrorTypePOSIX);
- return error;
- }
-
- // Ensure we clean up file actions however we exit this. When the
- // file_actions_up below goes out of scope, we'll get our file action
- // cleanup.
- std::unique_ptr<posix_spawn_file_actions_t,
- int (*)(posix_spawn_file_actions_t *)>
- file_actions_up(&file_actions, ::posix_spawn_file_actions_destroy);
-
- // We assume the caller has setup the file actions appropriately. We are not
- // in the business of figuring out what we really need here. lldb-server will
- // have already called FinalizeFileActions() as well to button these up
- // properly.
- const size_t num_actions = launch_info.GetNumFileActions();
- for (size_t action_index = 0; action_index < num_actions; ++action_index) {
- const FileAction *const action =
- launch_info.GetFileActionAtIndex(action_index);
- if (!action)
- continue;
-
- error = CreatePosixSpawnFileAction(*action, &file_actions);
- if (!error.Success()) {
- LLDB_LOGF(log,
- "%s(): error converting FileAction to posix_spawn "
- "file action: %s",
- __FUNCTION__, error.AsCString());
- return error;
- }
- }
-
- // TODO: Verify if we can set the working directory back immediately
- // after the posix_spawnp call without creating a race condition???
- const char *const working_directory =
- launch_info.GetWorkingDirectory().GetCString();
- if (working_directory && working_directory[0])
- ::chdir(working_directory);
-
- auto argv = launch_info.GetArguments().GetArgumentVector();
- auto envp = launch_info.GetEnvironmentEntries().GetArgumentVector();
- error_code = ::posix_spawnp(pid, path, &file_actions, &attr,
- (char *const *)argv, (char *const *)envp);
- if (error_code != 0) {
- LLDB_LOG(log,
- "::posix_spawnp(pid => {0}, path = '{1}', file_actions "
- "= {2}, attr = {3}, argv = {4}, envp = {5}) failed: {6}",
- pid, path, &file_actions, &attr, argv, envp,
- llvm::sys::StrError(error_code));
- error.SetError(error_code, eErrorTypePOSIX);
- return error;
- }
-
- // Validate we got a pid.
- if (pid == LLDB_INVALID_PROCESS_ID) {
- error.SetErrorString("posix_spawn() did not indicate a failure but it "
- "failed to return a pid, aborting.");
- return error;
- }
-
- if (actual_cpu_type) {
- *actual_cpu_type = GetCPUTypeForLocalProcess(*pid);
- LLDB_LOGF(log,
- "%s(): cpu type for launched process pid=%i: "
- "cpu_type=0x%8.8x",
- __FUNCTION__, *pid, *actual_cpu_type);
- }
-
- return error;
-}
-
-Status LaunchInferior(ProcessLaunchInfo &launch_info, int *pty_master_fd,
- LaunchFlavor *launch_flavor) {
- Status error;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-
- if (!launch_flavor) {
- error.SetErrorString("mandatory launch_flavor field was null");
- return error;
- }
-
- if (log) {
- StreamString stream;
- stream.Printf("NativeProcessDarwin::%s(): launching with the "
- "following launch info:",
- __FUNCTION__);
- launch_info.Dump(stream, nullptr);
- stream.Flush();
- log->PutCString(stream.GetString().c_str());
- }
-
- // Retrieve the binary name given to us.
- char given_path[PATH_MAX];
- given_path[0] = '\0';
- launch_info.GetExecutableFile().GetPath(given_path, sizeof(given_path));
-
- // Determine the manner in which we'll launch.
- *launch_flavor = g_launch_flavor;
- if (*launch_flavor == LaunchFlavor::Default) {
- // Our default launch method is posix spawn
- *launch_flavor = LaunchFlavor::PosixSpawn;
-#if defined WITH_FBS
- // Check if we have an app bundle, if so launch using BackBoard Services.
- if (strstr(given_path, ".app")) {
- *launch_flavor = eLaunchFlavorFBS;
- }
-#elif defined WITH_BKS
- // Check if we have an app bundle, if so launch using BackBoard Services.
- if (strstr(given_path, ".app")) {
- *launch_flavor = eLaunchFlavorBKS;
- }
-#elif defined WITH_SPRINGBOARD
- // Check if we have an app bundle, if so launch using SpringBoard.
- if (strstr(given_path, ".app")) {
- *launch_flavor = eLaunchFlavorSpringBoard;
- }
-#endif
- }
-
- // Attempt to resolve the binary name to an absolute path.
- char resolved_path[PATH_MAX];
- resolved_path[0] = '\0';
-
- LLDB_LOGF(log, "%s(): attempting to resolve given binary path: \"%s\"",
- __FUNCTION__, given_path);
-
- // If we fail to resolve the path to our executable, then just use what we
- // were given and hope for the best
- if (!ResolveExecutablePath(given_path, resolved_path,
- sizeof(resolved_path))) {
- LLDB_LOGF(log,
- "%s(): failed to resolve binary path, using "
- "what was given verbatim and hoping for the best",
- __FUNCTION__);
- ::strncpy(resolved_path, given_path, sizeof(resolved_path));
- } else {
- LLDB_LOGF(log, "%s(): resolved given binary path to: \"%s\"", __FUNCTION__,
- resolved_path);
- }
-
- char launch_err_str[PATH_MAX];
- launch_err_str[0] = '\0';
-
- // TODO figure out how to handle QSetProcessEvent
- // const char *process_event = ctx.GetProcessEvent();
-
- // Ensure the binary is there.
- struct stat path_stat;
- if (::stat(resolved_path, &path_stat) == -1) {
- error.SetErrorToErrno();
- return error;
- }
-
- // Fork a child process for debugging
- // state_callback(eStateLaunching);
-
- const auto argv = launch_info.GetArguments().GetConstArgumentVector();
- const auto envp =
- launch_info.GetEnvironmentEntries().GetConstArgumentVector();
-
- switch (*launch_flavor) {
- case LaunchFlavor::ForkExec: {
- ::pid_t pid = LLDB_INVALID_PROCESS_ID;
- error = ForkChildForPTraceDebugging(resolved_path, argv, envp, &pid,
- pty_master_fd);
- if (error.Success()) {
- launch_info.SetProcessID(static_cast<lldb::pid_t>(pid));
- } else {
- // Reset any variables that might have been set during a failed launch
- // attempt.
- if (pty_master_fd)
- *pty_master_fd = -1;
-
- // We're done.
- return error;
- }
- } break;
-
-#ifdef WITH_FBS
- case LaunchFlavor::FBS: {
- const char *app_ext = strstr(path, ".app");
- if (app_ext && (app_ext[4] == '\0' || app_ext[4] == '/')) {
- std::string app_bundle_path(path, app_ext + strlen(".app"));
- m_flags |= eMachProcessFlagsUsingFBS;
- if (BoardServiceLaunchForDebug(app_bundle_path.c_str(), argv, envp,
- no_stdio, disable_aslr, event_data,
- launch_err) != 0)
- return m_pid; // A successful SBLaunchForDebug() returns and assigns a
- // non-zero m_pid.
- else
- break; // We tried a FBS launch, but didn't succeed lets get out
- }
- } break;
-#endif
-
-#ifdef WITH_BKS
- case LaunchFlavor::BKS: {
- const char *app_ext = strstr(path, ".app");
- if (app_ext && (app_ext[4] == '\0' || app_ext[4] == '/')) {
- std::string app_bundle_path(path, app_ext + strlen(".app"));
- m_flags |= eMachProcessFlagsUsingBKS;
- if (BoardServiceLaunchForDebug(app_bundle_path.c_str(), argv, envp,
- no_stdio, disable_aslr, event_data,
- launch_err) != 0)
- return m_pid; // A successful SBLaunchForDebug() returns and assigns a
- // non-zero m_pid.
- else
- break; // We tried a BKS launch, but didn't succeed lets get out
- }
- } break;
-#endif
-
-#ifdef WITH_SPRINGBOARD
- case LaunchFlavor::SpringBoard: {
- // .../whatever.app/whatever ?
- // Or .../com.apple.whatever.app/whatever -- be careful of ".app" in
- // "com.apple.whatever" here
- const char *app_ext = strstr(path, ".app/");
- if (app_ext == NULL) {
- // .../whatever.app ?
- int len = strlen(path);
- if (len > 5) {
- if (strcmp(path + len - 4, ".app") == 0) {
- app_ext = path + len - 4;
- }
- }
- }
- if (app_ext) {
- std::string app_bundle_path(path, app_ext + strlen(".app"));
- if (SBLaunchForDebug(app_bundle_path.c_str(), argv, envp, no_stdio,
- disable_aslr, launch_err) != 0)
- return m_pid; // A successful SBLaunchForDebug() returns and assigns a
- // non-zero m_pid.
- else
- break; // We tried a springboard launch, but didn't succeed lets get out
- }
- } break;
-#endif
-
- case LaunchFlavor::PosixSpawn: {
- ::pid_t pid = LLDB_INVALID_PROCESS_ID;
-
- // Retrieve paths for stdin/stdout/stderr.
- cpu_type_t actual_cpu_type = 0;
- error = PosixSpawnChildForPTraceDebugging(resolved_path, launch_info, &pid,
- &actual_cpu_type);
- if (error.Success()) {
- launch_info.SetProcessID(static_cast<lldb::pid_t>(pid));
- if (pty_master_fd)
- *pty_master_fd = launch_info.GetPTY().ReleaseMasterFileDescriptor();
- } else {
- // Reset any variables that might have been set during a failed launch
- // attempt.
- if (pty_master_fd)
- *pty_master_fd = -1;
-
- // We're done.
- return error;
- }
- break;
- }
-
- default:
- // Invalid launch flavor.
- error.SetErrorStringWithFormat("NativeProcessDarwin::%s(): unknown "
- "launch flavor %d",
- __FUNCTION__, (int)*launch_flavor);
- return error;
- }
-
- if (launch_info.GetProcessID() == LLDB_INVALID_PROCESS_ID) {
- // If we don't have a valid process ID and no one has set the error, then
- // return a generic error.
- if (error.Success())
- error.SetErrorStringWithFormat("%s(): failed to launch, no reason "
- "specified",
- __FUNCTION__);
- }
-
- // We're done with the launch side of the operation.
- return error;
-}
-}
-} // namespaces
diff --git a/lldb/source/Plugins/Process/Darwin/DarwinProcessLauncher.h b/lldb/source/Plugins/Process/Darwin/DarwinProcessLauncher.h
deleted file mode 100644
index 0e65b56a143e..000000000000
--- a/lldb/source/Plugins/Process/Darwin/DarwinProcessLauncher.h
+++ /dev/null
@@ -1,48 +0,0 @@
-//===-- DarwinProcessLauncher.h ---------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef DarwinProcessLauncher_h
-#define DarwinProcessLauncher_h
-
-// C headers
-#include <mach/machine.h>
-#include <sys/types.h>
-
-// C++ headers
-#include <functional>
-
-// LLDB headers
-#include "lldb/lldb-enumerations.h"
-#include "lldb/lldb-forward.h"
-
-#include "LaunchFlavor.h"
-
-namespace lldb_private {
-namespace darwin_process_launcher {
-// =============================================================================
-/// Launches a process for debugging.
-///
-/// \param[inout] launch_info
-/// Specifies details about the process to launch (e.g. path, architecture,
-/// etc.). On output, includes the launched ProcessID (pid).
-///
-/// \param[out] pty_master_fd
-/// Returns the master side of the pseudo-terminal used to communicate
-/// with stdin/stdout from the launched process. May be nullptr.
-///
-/// \param[out] launch_flavor
-/// Contains the launch flavor used when launching the process.
-// =============================================================================
-Status
-LaunchInferior(ProcessLaunchInfo &launch_info, int *pty_master_fd,
- lldb_private::process_darwin::LaunchFlavor *launch_flavor);
-
-} // darwin_process_launcher
-} // lldb_private
-
-#endif /* DarwinProcessLauncher_h */
diff --git a/lldb/source/Plugins/Process/Darwin/LaunchFlavor.h b/lldb/source/Plugins/Process/Darwin/LaunchFlavor.h
deleted file mode 100644
index cfd76d1b9c3c..000000000000
--- a/lldb/source/Plugins/Process/Darwin/LaunchFlavor.h
+++ /dev/null
@@ -1,32 +0,0 @@
-//===-- LaunchFlavor.h ---------------------------------------- -*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LaunchFlavor_h
-#define LaunchFlavor_h
-
-namespace lldb_private {
-namespace process_darwin {
-
-enum class LaunchFlavor {
- Default = 0,
- PosixSpawn = 1,
- ForkExec = 2,
-#ifdef WITH_SPRINGBOARD
- SpringBoard = 3,
-#endif
-#ifdef WITH_BKS
- BKS = 4,
-#endif
-#ifdef WITH_FBS
- FBS = 5
-#endif
-};
-}
-} // namespaces
-
-#endif /* LaunchFlavor_h */
diff --git a/lldb/source/Plugins/Process/Darwin/MachException.cpp b/lldb/source/Plugins/Process/Darwin/MachException.cpp
deleted file mode 100644
index 073ad64b300c..000000000000
--- a/lldb/source/Plugins/Process/Darwin/MachException.cpp
+++ /dev/null
@@ -1,514 +0,0 @@
-//===-- MachException.cpp ---------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Created by Greg Clayton on 6/18/07.
-//
-//===----------------------------------------------------------------------===//
-
-#include "MachException.h"
-
-// C includes
-#include <errno.h>
-#include <sys/ptrace.h>
-#include <sys/types.h>
-
-// C++ includes
-#include <mutex>
-
-// LLDB includes
-#include "lldb/Target/UnixSignals.h"
-#include "lldb/Utility/LLDBAssert.h"
-#include "lldb/Utility/Log.h"
-#include "lldb/Utility/Status.h"
-#include "lldb/Utility/Stream.h"
-
-using namespace lldb;
-using namespace lldb_private;
-using namespace lldb_private::process_darwin;
-
-// Routine mach_exception_raise
-extern "C" kern_return_t
-catch_mach_exception_raise(mach_port_t exception_port, mach_port_t thread,
- mach_port_t task, exception_type_t exception,
- mach_exception_data_t code,
- mach_msg_type_number_t codeCnt);
-
-extern "C" kern_return_t catch_mach_exception_raise_state(
- mach_port_t exception_port, exception_type_t exception,
- const mach_exception_data_t code, mach_msg_type_number_t codeCnt,
- int *flavor, const thread_state_t old_state,
- mach_msg_type_number_t old_stateCnt, thread_state_t new_state,
- mach_msg_type_number_t *new_stateCnt);
-
-// Routine mach_exception_raise_state_identity
-extern "C" kern_return_t catch_mach_exception_raise_state_identity(
- mach_port_t exception_port, mach_port_t thread, mach_port_t task,
- exception_type_t exception, mach_exception_data_t code,
- mach_msg_type_number_t codeCnt, int *flavor, thread_state_t old_state,
- mach_msg_type_number_t old_stateCnt, thread_state_t new_state,
- mach_msg_type_number_t *new_stateCnt);
-
-extern "C" boolean_t mach_exc_server(mach_msg_header_t *InHeadP,
- mach_msg_header_t *OutHeadP);
-
-static MachException::Data *g_message = NULL;
-
-extern "C" kern_return_t catch_mach_exception_raise_state(
- mach_port_t exc_port, exception_type_t exc_type,
- const mach_exception_data_t exc_data, mach_msg_type_number_t exc_data_count,
- int *flavor, const thread_state_t old_state,
- mach_msg_type_number_t old_stateCnt, thread_state_t new_state,
- mach_msg_type_number_t *new_stateCnt) {
- // TODO change to LIBLLDB_LOG_EXCEPTION
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
- if (log) {
- LLDB_LOGF(log,
- "::%s(exc_port = 0x%4.4x, exc_type = %d (%s), "
- "exc_data = 0x%llx, exc_data_count = %d)",
- __FUNCTION__, exc_port, exc_type, MachException::Name(exc_type),
- (uint64_t)exc_data, exc_data_count);
- }
- return KERN_FAILURE;
-}
-
-extern "C" kern_return_t catch_mach_exception_raise_state_identity(
- mach_port_t exc_port, mach_port_t thread_port, mach_port_t task_port,
- exception_type_t exc_type, mach_exception_data_t exc_data,
- mach_msg_type_number_t exc_data_count, int *flavor,
- thread_state_t old_state, mach_msg_type_number_t old_stateCnt,
- thread_state_t new_state, mach_msg_type_number_t *new_stateCnt) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
- if (log) {
- LLDB_LOGF(log,
- "::%s(exc_port = 0x%4.4x, thd_port = 0x%4.4x, "
- "tsk_port = 0x%4.4x, exc_type = %d (%s), exc_data[%d] = "
- "{ 0x%llx, 0x%llx })",
- __FUNCTION__, exc_port, thread_port, task_port, exc_type,
- MachException::Name(exc_type), exc_data_count,
- (uint64_t)(exc_data_count > 0 ? exc_data[0] : 0xBADDBADD),
- (uint64_t)(exc_data_count > 1 ? exc_data[1] : 0xBADDBADD));
- }
-
- return KERN_FAILURE;
-}
-
-extern "C" kern_return_t
-catch_mach_exception_raise(mach_port_t exc_port, mach_port_t thread_port,
- mach_port_t task_port, exception_type_t exc_type,
- mach_exception_data_t exc_data,
- mach_msg_type_number_t exc_data_count) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
- if (log) {
- LLDB_LOGF(log,
- "::%s(exc_port = 0x%4.4x, thd_port = 0x%4.4x, "
- "tsk_port = 0x%4.4x, exc_type = %d (%s), exc_data[%d] "
- "= { 0x%llx, 0x%llx })",
- __FUNCTION__, exc_port, thread_port, task_port, exc_type,
- MachException::Name(exc_type), exc_data_count,
- (uint64_t)(exc_data_count > 0 ? exc_data[0] : 0xBADDBADD),
- (uint64_t)(exc_data_count > 1 ? exc_data[1] : 0xBADDBADD));
- }
-
- if (task_port == g_message->task_port) {
- g_message->task_port = task_port;
- g_message->thread_port = thread_port;
- g_message->exc_type = exc_type;
- g_message->exc_data.resize(exc_data_count);
- ::memcpy(&g_message->exc_data[0], exc_data,
- g_message->exc_data.size() * sizeof(mach_exception_data_type_t));
- return KERN_SUCCESS;
- }
- return KERN_FAILURE;
-}
-
-bool MachException::Data::GetStopInfo(struct ThreadStopInfo *stop_info,
- const UnixSignals &signals,
- Stream &stream) const {
- if (!stop_info)
- return false;
-
- // Zero out the structure.
- memset(stop_info, 0, sizeof(struct ThreadStopInfo));
-
- if (exc_type == 0) {
- stop_info->reason = eStopReasonInvalid;
- return true;
- }
-
- // We always stop with a mach exception.
- stop_info->reason = eStopReasonException;
- // Save the EXC_XXXX exception type.
- stop_info->details.exception.type = exc_type;
-
- // Fill in a text description
- const char *exc_name = MachException::Name(exc_type);
- if (exc_name)
- stream.Printf("%s", exc_name);
- else
- stream.Printf("%i", exc_type);
-
- stop_info->details.exception.data_count = exc_data.size();
-
- int soft_signal = SoftSignal();
- if (soft_signal) {
- const char *sig_str = signals.GetSignalAsCString(soft_signal);
- stream.Printf(" EXC_SOFT_SIGNAL( %i ( %s ))", soft_signal,
- sig_str ? sig_str : "unknown signal");
- } else {
- // No special disassembly for exception data, just print it.
- size_t idx;
- stream.Printf(" data[%llu] = {",
- (uint64_t)stop_info->details.exception.data_count);
-
- for (idx = 0; idx < stop_info->details.exception.data_count; ++idx) {
- stream.Printf(
- "0x%llx%c", (uint64_t)exc_data[idx],
- ((idx + 1 == stop_info->details.exception.data_count) ? '}' : ','));
- }
- }
-
- // Copy the exception data
- for (size_t i = 0; i < stop_info->details.exception.data_count; i++)
- stop_info->details.exception.data[i] = exc_data[i];
-
- return true;
-}
-
-Status MachException::Message::Receive(mach_port_t port,
- mach_msg_option_t options,
- mach_msg_timeout_t timeout,
- mach_port_t notify_port) {
- Status error;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
-
- mach_msg_timeout_t mach_msg_timeout =
- options & MACH_RCV_TIMEOUT ? timeout : 0;
- if (log && ((options & MACH_RCV_TIMEOUT) == 0)) {
- // Dump this log message if we have no timeout in case it never returns
- LLDB_LOGF(log,
- "::mach_msg(msg->{bits = %#x, size = %u remote_port = %#x, "
- "local_port = %#x, reserved = 0x%x, id = 0x%x}, "
- "option = %#x, send_size = 0, rcv_size = %llu, "
- "rcv_name = %#x, timeout = %u, notify = %#x)",
- exc_msg.hdr.msgh_bits, exc_msg.hdr.msgh_size,
- exc_msg.hdr.msgh_remote_port, exc_msg.hdr.msgh_local_port,
- exc_msg.hdr.msgh_reserved, exc_msg.hdr.msgh_id, options,
- (uint64_t)sizeof(exc_msg.data), port, mach_msg_timeout,
- notify_port);
- }
-
- mach_msg_return_t mach_err =
- ::mach_msg(&exc_msg.hdr,
- options, // options
- 0, // Send size
- sizeof(exc_msg.data), // Receive size
- port, // exception port to watch for
- // exception on
- mach_msg_timeout, // timeout in msec (obeyed only
- // if MACH_RCV_TIMEOUT is ORed
- // into the options parameter)
- notify_port);
- error.SetError(mach_err, eErrorTypeMachKernel);
-
- // Dump any errors we get
- if (error.Fail() && log) {
- LLDB_LOGF(log,
- "::mach_msg(msg->{bits = %#x, size = %u remote_port = %#x, "
- "local_port = %#x, reserved = 0x%x, id = 0x%x}, "
- "option = %#x, send_size = %u, rcv_size = %lu, rcv_name "
- "= %#x, timeout = %u, notify = %#x) failed: %s",
- exc_msg.hdr.msgh_bits, exc_msg.hdr.msgh_size,
- exc_msg.hdr.msgh_remote_port, exc_msg.hdr.msgh_local_port,
- exc_msg.hdr.msgh_reserved, exc_msg.hdr.msgh_id, options, 0,
- sizeof(exc_msg.data), port, mach_msg_timeout, notify_port,
- error.AsCString());
- }
- return error;
-}
-
-void MachException::Message::Dump(Stream &stream) const {
- stream.Printf(" exc_msg { bits = 0x%8.8x size = 0x%8.8x remote-port = "
- "0x%8.8x local-port = 0x%8.8x reserved = 0x%8.8x id = "
- "0x%8.8x }\n",
- exc_msg.hdr.msgh_bits, exc_msg.hdr.msgh_size,
- exc_msg.hdr.msgh_remote_port, exc_msg.hdr.msgh_local_port,
- exc_msg.hdr.msgh_reserved, exc_msg.hdr.msgh_id);
-
- stream.Printf(" reply_msg { bits = 0x%8.8x size = 0x%8.8x remote-port = "
- "0x%8.8x local-port = 0x%8.8x reserved = 0x%8.8x id = "
- "0x%8.8x }",
- reply_msg.hdr.msgh_bits, reply_msg.hdr.msgh_size,
- reply_msg.hdr.msgh_remote_port, reply_msg.hdr.msgh_local_port,
- reply_msg.hdr.msgh_reserved, reply_msg.hdr.msgh_id);
-}
-
-bool MachException::Message::CatchExceptionRaise(task_t task) {
- bool success = false;
- state.task_port = task;
- g_message = &state;
- // The exc_server function is the MIG generated server handling function to
- // handle messages from the kernel relating to the occurrence of an exception
- // in a thread. Such messages are delivered to the exception port set via
- // thread_set_exception_ports or task_set_exception_ports. When an exception
- // occurs in a thread, the thread sends an exception message to its exception
- // port, blocking in the kernel waiting for the receipt of a reply. The
- // exc_server function performs all necessary argument handling for this
- // kernel message and calls catch_exception_raise,
- // catch_exception_raise_state or catch_exception_raise_state_identity, which
- // should handle the exception. If the called routine returns KERN_SUCCESS, a
- // reply message will be sent, allowing the thread to continue from the point
- // of the exception; otherwise, no reply message is sent and the called
- // routine must have dealt with the exception thread directly.
- if (mach_exc_server(&exc_msg.hdr, &reply_msg.hdr)) {
- success = true;
- } else {
- Log *log(
- GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
- LLDB_LOGF(log,
- "MachException::Message::%s(): mach_exc_server "
- "returned zero...",
- __FUNCTION__);
- }
- g_message = NULL;
- return success;
-}
-
-Status MachException::Message::Reply(::pid_t inferior_pid, task_t inferior_task,
- int signal) {
- // Reply to the exception...
- Status error;
-
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
-
- // If we had a soft signal, we need to update the thread first so it can
- // continue without signaling
- int soft_signal = state.SoftSignal();
- if (soft_signal) {
- int state_pid = -1;
- if (inferior_task == state.task_port) {
- // This is our task, so we can update the signal to send to it
- state_pid = inferior_pid;
- soft_signal = signal;
- } else {
- auto mach_err = ::pid_for_task(state.task_port, &state_pid);
- if (mach_err) {
- error.SetError(mach_err, eErrorTypeMachKernel);
- LLDB_LOGF(log,
- "MachException::Message::%s(): pid_for_task() "
- "failed: %s",
- __FUNCTION__, error.AsCString());
- return error;
- }
- }
-
- lldbassert(state_pid != -1);
- if (state_pid != -1) {
- errno = 0;
- caddr_t thread_port_caddr = (caddr_t)(uintptr_t)state.thread_port;
- if (::ptrace(PT_THUPDATE, state_pid, thread_port_caddr, soft_signal) != 0)
- error.SetError(errno, eErrorTypePOSIX);
-
- if (!error.Success()) {
- LLDB_LOGF(log,
- "::ptrace(request = PT_THUPDATE, pid = "
- "0x%4.4x, tid = 0x%4.4x, signal = %i)",
- state_pid, state.thread_port, soft_signal);
- return error;
- }
- }
- }
-
- LLDB_LOGF(log,
- "::mach_msg ( msg->{bits = %#x, size = %u, remote_port "
- "= %#x, local_port = %#x, reserved = 0x%x, id = 0x%x}, "
- "option = %#x, send_size = %u, rcv_size = %u, rcv_name "
- "= %#x, timeout = %u, notify = %#x)",
- reply_msg.hdr.msgh_bits, reply_msg.hdr.msgh_size,
- reply_msg.hdr.msgh_remote_port, reply_msg.hdr.msgh_local_port,
- reply_msg.hdr.msgh_reserved, reply_msg.hdr.msgh_id,
- MACH_SEND_MSG | MACH_SEND_INTERRUPT, reply_msg.hdr.msgh_size, 0,
- MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
-
- auto mach_err =
- ::mach_msg(&reply_msg.hdr, MACH_SEND_MSG | MACH_SEND_INTERRUPT,
- reply_msg.hdr.msgh_size, 0, MACH_PORT_NULL,
- MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
- if (mach_err)
- error.SetError(mach_err, eErrorTypeMachKernel);
-
- // Log our error if we have one.
- if (error.Fail() && log) {
- if (error.GetError() == MACH_SEND_INTERRUPTED) {
- log->PutCString("::mach_msg() - send interrupted");
- // TODO: keep retrying to reply???
- } else if (state.task_port == inferior_task) {
- LLDB_LOGF(log,
- "mach_msg(): returned an error when replying "
- "to a mach exception: error = %u (%s)",
- error.GetError(), error.AsCString());
- } else {
- LLDB_LOGF(log, "::mach_msg() - failed (child of task): %u (%s)",
- error.GetError(), error.AsCString());
- }
- }
-
- return error;
-}
-
-#define PREV_EXC_MASK_ALL \
- (EXC_MASK_BAD_ACCESS | EXC_MASK_BAD_INSTRUCTION | EXC_MASK_ARITHMETIC | \
- EXC_MASK_EMULATION | EXC_MASK_SOFTWARE | EXC_MASK_BREAKPOINT | \
- EXC_MASK_SYSCALL | EXC_MASK_MACH_SYSCALL | EXC_MASK_RPC_ALERT | \
- EXC_MASK_MACHINE)
-
-// Don't listen for EXC_RESOURCE, it should really get handled by the system
-// handler.
-
-#ifndef EXC_RESOURCE
-#define EXC_RESOURCE 11
-#endif
-
-#ifndef EXC_MASK_RESOURCE
-#define EXC_MASK_RESOURCE (1 << EXC_RESOURCE)
-#endif
-
-#define LLDB_EXC_MASK (EXC_MASK_ALL & ~EXC_MASK_RESOURCE)
-
-Status MachException::PortInfo::Save(task_t task) {
- Status error;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
-
- LLDB_LOGF(log, "MachException::PortInfo::%s(task = 0x%4.4x)", __FUNCTION__,
- task);
-
- // Be careful to be able to have debugserver built on a newer OS than what it
- // is currently running on by being able to start with all exceptions and
- // back off to just what is supported on the current system
- mask = LLDB_EXC_MASK;
-
- count = (sizeof(ports) / sizeof(ports[0]));
- auto mach_err = ::task_get_exception_ports(task, mask, masks, &count, ports,
- behaviors, flavors);
- if (mach_err)
- error.SetError(mach_err, eErrorTypeMachKernel);
-
- if (log) {
- if (error.Success()) {
- LLDB_LOGF(log,
- "::task_get_exception_ports(task = 0x%4.4x, mask = "
- "0x%x, maskCnt => %u, ports, behaviors, flavors)",
- task, mask, count);
- } else {
- LLDB_LOGF(log,
- "::task_get_exception_ports(task = 0x%4.4x, mask = 0x%x, "
- "maskCnt => %u, ports, behaviors, flavors) error: %u (%s)",
- task, mask, count, error.GetError(), error.AsCString());
- }
- }
-
- if ((error.GetError() == KERN_INVALID_ARGUMENT) &&
- (mask != PREV_EXC_MASK_ALL)) {
- mask = PREV_EXC_MASK_ALL;
- count = (sizeof(ports) / sizeof(ports[0]));
- mach_err = ::task_get_exception_ports(task, mask, masks, &count, ports,
- behaviors, flavors);
- error.SetError(mach_err, eErrorTypeMachKernel);
- if (log) {
- if (error.Success()) {
- LLDB_LOGF(log,
- "::task_get_exception_ports(task = 0x%4.4x, "
- "mask = 0x%x, maskCnt => %u, ports, behaviors, "
- "flavors)",
- task, mask, count);
- } else {
- LLDB_LOGF(log,
- "::task_get_exception_ports(task = 0x%4.4x, mask = "
- "0x%x, maskCnt => %u, ports, behaviors, flavors) "
- "error: %u (%s)",
- task, mask, count, error.GetError(), error.AsCString());
- }
- }
- }
- if (error.Fail()) {
- mask = 0;
- count = 0;
- }
- return error;
-}
-
-Status MachException::PortInfo::Restore(task_t task) {
- Status error;
-
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
-
- LLDB_LOGF(log, "MachException::PortInfo::Restore(task = 0x%4.4x)", task);
-
- uint32_t i = 0;
- if (count > 0) {
- for (i = 0; i < count; i++) {
- auto mach_err = ::task_set_exception_ports(task, masks[i], ports[i],
- behaviors[i], flavors[i]);
- if (mach_err)
- error.SetError(mach_err, eErrorTypeMachKernel);
- if (log) {
- if (error.Success()) {
- LLDB_LOGF(log,
- "::task_set_exception_ports(task = 0x%4.4x, "
- "exception_mask = 0x%8.8x, new_port = 0x%4.4x, "
- "behavior = 0x%8.8x, new_flavor = 0x%8.8x)",
- task, masks[i], ports[i], behaviors[i], flavors[i]);
- } else {
- LLDB_LOGF(log,
- "::task_set_exception_ports(task = 0x%4.4x, "
- "exception_mask = 0x%8.8x, new_port = 0x%4.4x, "
- "behavior = 0x%8.8x, new_flavor = 0x%8.8x): "
- "error %u (%s)",
- task, masks[i], ports[i], behaviors[i], flavors[i],
- error.GetError(), error.AsCString());
- }
- }
-
- // Bail if we encounter any errors
- if (error.Fail())
- break;
- }
- }
-
- count = 0;
- return error;
-}
-
-const char *MachException::Name(exception_type_t exc_type) {
- switch (exc_type) {
- case EXC_BAD_ACCESS:
- return "EXC_BAD_ACCESS";
- case EXC_BAD_INSTRUCTION:
- return "EXC_BAD_INSTRUCTION";
- case EXC_ARITHMETIC:
- return "EXC_ARITHMETIC";
- case EXC_EMULATION:
- return "EXC_EMULATION";
- case EXC_SOFTWARE:
- return "EXC_SOFTWARE";
- case EXC_BREAKPOINT:
- return "EXC_BREAKPOINT";
- case EXC_SYSCALL:
- return "EXC_SYSCALL";
- case EXC_MACH_SYSCALL:
- return "EXC_MACH_SYSCALL";
- case EXC_RPC_ALERT:
- return "EXC_RPC_ALERT";
-#ifdef EXC_CRASH
- case EXC_CRASH:
- return "EXC_CRASH";
-#endif
- default:
- break;
- }
- return NULL;
-}
diff --git a/lldb/source/Plugins/Process/Darwin/MachException.h b/lldb/source/Plugins/Process/Darwin/MachException.h
deleted file mode 100644
index 18e49173b020..000000000000
--- a/lldb/source/Plugins/Process/Darwin/MachException.h
+++ /dev/null
@@ -1,139 +0,0 @@
-//===-- MachException.h -----------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Created by Greg Clayton on 6/18/07.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef __MachException_h__
-#define __MachException_h__
-
-#include <mach/mach.h>
-#include <vector>
-
-#include "lldb/Host/Debug.h"
-#include "lldb/lldb-private-forward.h"
-#include "lldb/lldb-types.h"
-
-namespace lldb_private {
-namespace process_darwin {
-
-typedef union MachMessageTag {
- mach_msg_header_t hdr;
- char data[1024];
-} MachMessage;
-
-class MachException {
-public:
- struct PortInfo {
- exception_mask_t mask; // the exception mask for this device which may be a
- // subset of EXC_MASK_ALL...
- exception_mask_t masks[EXC_TYPES_COUNT];
- mach_port_t ports[EXC_TYPES_COUNT];
- exception_behavior_t behaviors[EXC_TYPES_COUNT];
- thread_state_flavor_t flavors[EXC_TYPES_COUNT];
- mach_msg_type_number_t count;
-
- Status Save(task_t task);
-
- Status Restore(task_t task);
- };
-
- struct Data {
- task_t task_port;
- thread_t thread_port;
- exception_type_t exc_type;
- std::vector<mach_exception_data_type_t> exc_data;
- Data()
- : task_port(TASK_NULL), thread_port(THREAD_NULL), exc_type(0),
- exc_data() {}
-
- void Clear() {
- task_port = TASK_NULL;
- thread_port = THREAD_NULL;
- exc_type = 0;
- exc_data.clear();
- }
-
- bool IsValid() const {
- return task_port != TASK_NULL && thread_port != THREAD_NULL &&
- exc_type != 0;
- }
-
- // Return the SoftSignal for this MachException data, or zero if there is
- // none
- int SoftSignal() const {
- if (exc_type == EXC_SOFTWARE && exc_data.size() == 2 &&
- exc_data[0] == EXC_SOFT_SIGNAL)
- return static_cast<int>(exc_data[1]);
- return 0;
- }
-
- bool IsBreakpoint() const {
- return (exc_type == EXC_BREAKPOINT ||
- ((exc_type == EXC_SOFTWARE) && exc_data[0] == 1));
- }
-
- bool GetStopInfo(ThreadStopInfo *stop_info, const UnixSignals &signals,
- Stream &stream) const;
- };
-
- struct Message {
- MachMessage exc_msg;
- MachMessage reply_msg;
- Data state;
-
- Message() : state() {
- memset(&exc_msg, 0, sizeof(exc_msg));
- memset(&reply_msg, 0, sizeof(reply_msg));
- }
-
- bool CatchExceptionRaise(task_t task);
-
- Status Reply(::pid_t inferior_pid, task_t inferior_task, int signal);
-
- Status Receive(mach_port_t receive_port, mach_msg_option_t options,
- mach_msg_timeout_t timeout,
- mach_port_t notify_port = MACH_PORT_NULL);
-
- void Dump(Stream &stream) const;
-
- typedef std::vector<Message> collection;
- typedef collection::iterator iterator;
- typedef collection::const_iterator const_iterator;
- };
-
- enum {
- e_actionForward, // Forward signal to inferior process
- e_actionStop, // Stop when this signal is received
- };
- struct Action {
- task_t task_port; // Set to TASK_NULL for any TASK
- thread_t thread_port; // Set to THREAD_NULL for any thread
- exception_type_t exc_mask; // Mach exception mask to watch for
- std::vector<mach_exception_data_type_t> exc_data_mask; // Mask to apply to
- // exception data, or
- // empty to ignore
- // exc_data value for
- // exception
- std::vector<mach_exception_data_type_t> exc_data_value; // Value to compare
- // to exception data
- // after masking, or
- // empty to ignore
- // exc_data value
- // for exception
- uint8_t flags; // Action flags describing what to do with the exception
- };
-
- static const char *Name(exception_type_t exc_type);
-};
-
-} // namespace process_darwin
-} // namespace lldb_private
-
-#endif
diff --git a/lldb/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp b/lldb/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp
deleted file mode 100644
index 18dbdda9a33b..000000000000
--- a/lldb/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp
+++ /dev/null
@@ -1,1535 +0,0 @@
-//===-- NativeProcessDarwin.cpp ---------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "NativeProcessDarwin.h"
-
-// C includes
-#include <mach/mach_init.h>
-#include <mach/mach_traps.h>
-#include <sys/ptrace.h>
-#include <sys/stat.h>
-#include <sys/sysctl.h>
-#include <sys/types.h>
-
-// C++ includes
-// LLDB includes
-#include "lldb/Host/PseudoTerminal.h"
-#include "lldb/Target/ProcessLaunchInfo.h"
-#include "lldb/Utility/Log.h"
-#include "lldb/Utility/State.h"
-#include "lldb/Utility/StreamString.h"
-
-#include "CFBundle.h"
-#include "CFString.h"
-#include "DarwinProcessLauncher.h"
-
-#include "MachException.h"
-
-#include "llvm/Support/FileSystem.h"
-
-using namespace lldb;
-using namespace lldb_private;
-using namespace lldb_private::process_darwin;
-using namespace lldb_private::darwin_process_launcher;
-
-// Hidden Impl
-
-namespace {
-struct hack_task_dyld_info {
- mach_vm_address_t all_image_info_addr;
- mach_vm_size_t all_image_info_size;
-};
-}
-
-// Public Static Methods
-
-Status NativeProcessProtocol::Launch(
- ProcessLaunchInfo &launch_info,
- NativeProcessProtocol::NativeDelegate &native_delegate, MainLoop &mainloop,
- NativeProcessProtocolSP &native_process_sp) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-
- Status error;
-
- // Verify the working directory is valid if one was specified.
- FileSpec working_dir(launch_info.GetWorkingDirectory());
- if (working_dir) {
- FileInstance::Instance().Resolve(working_dir);
- if (!FileSystem::Instance().IsDirectory(working_dir)) {
- error.SetErrorStringWithFormat("No such file or directory: %s",
- working_dir.GetCString());
- return error;
- }
- }
-
- // Launch the inferior.
- int pty_master_fd = -1;
- LaunchFlavor launch_flavor = LaunchFlavor::Default;
-
- error = LaunchInferior(launch_info, &pty_master_fd, &launch_flavor);
-
- // Handle launch failure.
- if (!error.Success()) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s() failed to launch process: "
- "%s",
- __FUNCTION__, error.AsCString());
- return error;
- }
-
- // Handle failure to return a pid.
- if (launch_info.GetProcessID() == LLDB_INVALID_PROCESS_ID) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s() launch succeeded but no "
- "pid was returned! Aborting.",
- __FUNCTION__);
- return error;
- }
-
- // Create the Darwin native process impl.
- std::shared_ptr<NativeProcessDarwin> np_darwin_sp(
- new NativeProcessDarwin(launch_info.GetProcessID(), pty_master_fd));
- if (!np_darwin_sp->RegisterNativeDelegate(native_delegate)) {
- native_process_sp.reset();
- error.SetErrorStringWithFormat("failed to register the native delegate");
- return error;
- }
-
- // Finalize the processing needed to debug the launched process with a
- // NativeProcessDarwin instance.
- error = np_darwin_sp->FinalizeLaunch(launch_flavor, mainloop);
- if (!error.Success()) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s() aborting, failed to finalize"
- " the launching of the process: %s",
- __FUNCTION__, error.AsCString());
- return error;
- }
-
- // Return the process and process id to the caller through the launch args.
- native_process_sp = np_darwin_sp;
- return error;
-}
-
-Status NativeProcessProtocol::Attach(
- lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate,
- MainLoop &mainloop, NativeProcessProtocolSP &native_process_sp) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- LLDB_LOGF(log, "NativeProcessDarwin::%s(pid = %" PRIi64 ")", __FUNCTION__,
- pid);
-
- // Retrieve the architecture for the running process.
- ArchSpec process_arch;
- Status error = ResolveProcessArchitecture(pid, process_arch);
- if (!error.Success())
- return error;
-
- // TODO get attach to return this value.
- const int pty_master_fd = -1;
- std::shared_ptr<NativeProcessDarwin> native_process_darwin_sp(
- new NativeProcessDarwin(pid, pty_master_fd));
-
- if (!native_process_darwin_sp->RegisterNativeDelegate(native_delegate)) {
- error.SetErrorStringWithFormat("failed to register the native "
- "delegate");
- return error;
- }
-
- native_process_darwin_sp->AttachToInferior(mainloop, pid, error);
- if (!error.Success())
- return error;
-
- native_process_sp = native_process_darwin_sp;
- return error;
-}
-
-// ctor/dtor
-
-NativeProcessDarwin::NativeProcessDarwin(lldb::pid_t pid, int pty_master_fd)
- : NativeProcessProtocol(pid), m_task(TASK_NULL), m_did_exec(false),
- m_cpu_type(0), m_exception_port(MACH_PORT_NULL), m_exc_port_info(),
- m_exception_thread(nullptr), m_exception_messages_mutex(),
- m_sent_interrupt_signo(0), m_auto_resume_signo(0), m_thread_list(),
- m_thread_actions(), m_waitpid_pipe(), m_waitpid_thread(nullptr),
- m_waitpid_reader_handle() {
- // TODO add this to the NativeProcessProtocol constructor.
- m_terminal_fd = pty_master_fd;
-}
-
-NativeProcessDarwin::~NativeProcessDarwin() {}
-
-// Instance methods
-
-Status NativeProcessDarwin::FinalizeLaunch(LaunchFlavor launch_flavor,
- MainLoop &main_loop) {
- Status error;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-
- error = StartExceptionThread();
- if (!error.Success()) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): failure starting the "
- "mach exception port monitor thread: %s",
- __FUNCTION__, error.AsCString());
-
- // Terminate the inferior process. There's nothing meaningful we can do if
- // we can't receive signals and exceptions. Since we launched the process,
- // it's fair game for us to kill it.
- ::ptrace(PT_KILL, m_pid, 0, 0);
- SetState(eStateExited);
-
- return error;
- }
-
- StartSTDIOThread();
-
- if (launch_flavor == LaunchFlavor::PosixSpawn) {
- SetState(eStateAttaching);
- errno = 0;
- int err = ::ptrace(PT_ATTACHEXC, m_pid, 0, 0);
- if (err == 0) {
- // m_flags |= eMachProcessFlagsAttached;
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): successfully spawned "
- "process with pid %" PRIu64,
- __FUNCTION__, m_pid);
- } else {
- error.SetErrorToErrno();
- SetState(eStateExited);
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): error: failed to "
- "attach to spawned pid %" PRIu64 " (error=%d (%s))",
- __FUNCTION__, m_pid, (int)error.GetError(), error.AsCString());
- return error;
- }
- }
-
- LLDB_LOGF(log, "NativeProcessDarwin::%s(): new pid is %" PRIu64 "...",
- __FUNCTION__, m_pid);
-
- // Spawn a thread to reap our child inferior process...
- error = StartWaitpidThread(main_loop);
- if (error.Fail()) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): failed to start waitpid() "
- "thread: %s",
- __FUNCTION__, error.AsCString());
- kill(SIGKILL, static_cast<::pid_t>(m_pid));
- return error;
- }
-
- if (TaskPortForProcessID(error) == TASK_NULL) {
- // We failed to get the task for our process ID which is bad. Kill our
- // process; otherwise, it will be stopped at the entry point and get
- // reparented to someone else and never go away.
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): could not get task port "
- "for process, sending SIGKILL and exiting: %s",
- __FUNCTION__, error.AsCString());
- kill(SIGKILL, static_cast<::pid_t>(m_pid));
- return error;
- }
-
- // Indicate that we're stopped, as we always launch suspended.
- SetState(eStateStopped);
-
- // Success.
- return error;
-}
-
-Status NativeProcessDarwin::SaveExceptionPortInfo() {
- return m_exc_port_info.Save(m_task);
-}
-
-bool NativeProcessDarwin::ProcessUsingSpringBoard() const {
- // TODO implement flags
- // return (m_flags & eMachProcessFlagsUsingSBS) != 0;
- return false;
-}
-
-bool NativeProcessDarwin::ProcessUsingBackBoard() const {
- // TODO implement flags
- // return (m_flags & eMachProcessFlagsUsingBKS) != 0;
- return false;
-}
-
-// Called by the exception thread when an exception has been received from our
-// process. The exception message is completely filled and the exception data
-// has already been copied.
-void NativeProcessDarwin::ExceptionMessageReceived(
- const MachException::Message &message) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
-
- std::lock_guard<std::recursive_mutex> locker(m_exception_messages_mutex);
- if (m_exception_messages.empty()) {
- // Suspend the task the moment we receive our first exception message.
- SuspendTask();
- }
-
- // Use a locker to automatically unlock our mutex in case of exceptions Add
- // the exception to our internal exception stack
- m_exception_messages.push_back(message);
-
- LLDB_LOGF(log, "NativeProcessDarwin::%s(): new queued message count: %lu",
- __FUNCTION__, m_exception_messages.size());
-}
-
-void *NativeProcessDarwin::ExceptionThread(void *arg) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
- if (!arg) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): cannot run mach exception "
- "thread, mandatory process arg was null",
- __FUNCTION__);
- return nullptr;
- }
-
- return reinterpret_cast<NativeProcessDarwin *>(arg)->DoExceptionThread();
-}
-
-void *NativeProcessDarwin::DoExceptionThread() {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
-
- LLDB_LOGF(log, "NativeProcessDarwin::%s(arg=%p) starting thread...",
- __FUNCTION__, this);
-
- pthread_setname_np("exception monitoring thread");
-
- // Ensure we don't get CPU starved.
- MaybeRaiseThreadPriority();
-
- // We keep a count of the number of consecutive exceptions received so we
- // know to grab all exceptions without a timeout. We do this to get a bunch
- // of related exceptions on our exception port so we can process then
- // together. When we have multiple threads, we can get an exception per
- // thread and they will come in consecutively. The main loop in this thread
- // can stop periodically if needed to service things related to this process.
- //
- // [did we lose some words here?]
- //
- // flag set in the options, so we will wait forever for an exception on
- // 0 our exception port. After we get one exception, we then will use the
- // MACH_RCV_TIMEOUT option with a zero timeout to grab all other current
- // exceptions for our process. After we have received the last pending
- // exception, we will get a timeout which enables us to then notify our main
- // thread that we have an exception bundle available. We then wait for the
- // main thread to tell this exception thread to start trying to get
- // exceptions messages again and we start again with a mach_msg read with
- // infinite timeout.
- //
- // We choose to park a thread on this, rather than polling, because the
- // polling is expensive. On devices, we need to minimize overhead caused by
- // the process monitor.
- uint32_t num_exceptions_received = 0;
- Status error;
- task_t task = m_task;
- mach_msg_timeout_t periodic_timeout = 0;
-
-#if defined(WITH_SPRINGBOARD) && !defined(WITH_BKS)
- mach_msg_timeout_t watchdog_elapsed = 0;
- mach_msg_timeout_t watchdog_timeout = 60 * 1000;
- ::pid_t pid = (::pid_t)process->GetID();
- CFReleaser<SBSWatchdogAssertionRef> watchdog;
-
- if (process->ProcessUsingSpringBoard()) {
- // Request a renewal for every 60 seconds if we attached using SpringBoard.
- watchdog.reset(::SBSWatchdogAssertionCreateForPID(nullptr, pid, 60));
- LLDB_LOGF(log,
- "::SBSWatchdogAssertionCreateForPID(NULL, %4.4x, 60) "
- "=> %p",
- pid, watchdog.get());
-
- if (watchdog.get()) {
- ::SBSWatchdogAssertionRenew(watchdog.get());
-
- CFTimeInterval watchdogRenewalInterval =
- ::SBSWatchdogAssertionGetRenewalInterval(watchdog.get());
- LLDB_LOGF(log,
- "::SBSWatchdogAssertionGetRenewalInterval(%p) => "
- "%g seconds",
- watchdog.get(), watchdogRenewalInterval);
- if (watchdogRenewalInterval > 0.0) {
- watchdog_timeout = (mach_msg_timeout_t)watchdogRenewalInterval * 1000;
- if (watchdog_timeout > 3000) {
- // Give us a second to renew our timeout.
- watchdog_timeout -= 1000;
- } else if (watchdog_timeout > 1000) {
- // Give us a quarter of a second to renew our timeout.
- watchdog_timeout -= 250;
- }
- }
- }
- if (periodic_timeout == 0 || periodic_timeout > watchdog_timeout)
- periodic_timeout = watchdog_timeout;
- }
-#endif // #if defined (WITH_SPRINGBOARD) && !defined (WITH_BKS)
-
-#ifdef WITH_BKS
- CFReleaser<BKSWatchdogAssertionRef> watchdog;
- if (process->ProcessUsingBackBoard()) {
- ::pid_t pid = process->GetID();
- CFAllocatorRef alloc = kCFAllocatorDefault;
- watchdog.reset(::BKSWatchdogAssertionCreateForPID(alloc, pid));
- }
-#endif // #ifdef WITH_BKS
-
- // Do we want to use a weak pointer to the NativeProcessDarwin here, in which
- // case we can guarantee we don't whack the process monitor if we race
- // between this thread and the main one on shutdown?
- while (IsExceptionPortValid()) {
- ::pthread_testcancel();
-
- MachException::Message exception_message;
-
- if (num_exceptions_received > 0) {
- // We don't want a timeout here, just receive as many exceptions as we
- // can since we already have one. We want to get all currently available
- // exceptions for this task at once.
- error = exception_message.Receive(
- GetExceptionPort(),
- MACH_RCV_MSG | MACH_RCV_INTERRUPT | MACH_RCV_TIMEOUT, 0);
- } else if (periodic_timeout > 0) {
- // We need to stop periodically in this loop, so try and get a mach
- // message with a valid timeout (ms).
- error = exception_message.Receive(GetExceptionPort(),
- MACH_RCV_MSG | MACH_RCV_INTERRUPT |
- MACH_RCV_TIMEOUT,
- periodic_timeout);
- } else {
- // We don't need to parse all current exceptions or stop periodically,
- // just wait for an exception forever.
- error = exception_message.Receive(GetExceptionPort(),
- MACH_RCV_MSG | MACH_RCV_INTERRUPT, 0);
- }
-
- if (error.Success()) {
- // We successfully received an exception.
- if (exception_message.CatchExceptionRaise(task)) {
- ++num_exceptions_received;
- ExceptionMessageReceived(exception_message);
- }
- } else {
- if (error.GetError() == MACH_RCV_INTERRUPTED) {
- // We were interrupted.
-
- // If we have no task port we should exit this thread, as it implies
- // the inferior went down.
- if (!IsExceptionPortValid()) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): the inferior "
- "exception port is no longer valid, "
- "canceling exception thread...",
- __FUNCTION__);
- // Should we be setting a process state here?
- break;
- }
-
- // Make sure the inferior task is still valid.
- if (IsTaskValid()) {
- // Task is still ok.
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): interrupted, but "
- "the inferior task iss till valid, "
- "continuing...",
- __FUNCTION__);
- continue;
- } else {
- // The inferior task is no longer valid. Time to exit as the process
- // has gone away.
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): the inferior task "
- "has exited, and so will we...",
- __FUNCTION__);
- // Does this race at all with our waitpid()?
- SetState(eStateExited);
- break;
- }
- } else if (error.GetError() == MACH_RCV_TIMED_OUT) {
- // We timed out when waiting for exceptions.
-
- if (num_exceptions_received > 0) {
- // We were receiving all current exceptions with a timeout of zero.
- // It is time to go back to our normal looping mode.
- num_exceptions_received = 0;
-
- // Notify our main thread we have a complete exception message bundle
- // available. Get the possibly updated task port back from the
- // process in case we exec'ed and our task port changed.
- task = ExceptionMessageBundleComplete();
-
- // In case we use a timeout value when getting exceptions, make sure
- // our task is still valid.
- if (IsTaskValid(task)) {
- // Task is still ok.
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): got a timeout, "
- "continuing...",
- __FUNCTION__);
- continue;
- } else {
- // The inferior task is no longer valid. Time to exit as the
- // process has gone away.
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): the inferior "
- "task has exited, and so will we...",
- __FUNCTION__);
- // Does this race at all with our waitpid()?
- SetState(eStateExited);
- break;
- }
- }
-
-#if defined(WITH_SPRINGBOARD) && !defined(WITH_BKS)
- if (watchdog.get()) {
- watchdog_elapsed += periodic_timeout;
- if (watchdog_elapsed >= watchdog_timeout) {
- LLDB_LOGF(log, "SBSWatchdogAssertionRenew(%p)", watchdog.get());
- ::SBSWatchdogAssertionRenew(watchdog.get());
- watchdog_elapsed = 0;
- }
- }
-#endif
- } else {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): continuing after "
- "receiving an unexpected error: %u (%s)",
- __FUNCTION__, error.GetError(), error.AsCString());
- // TODO: notify of error?
- }
- }
- }
-
-#if defined(WITH_SPRINGBOARD) && !defined(WITH_BKS)
- if (watchdog.get()) {
- // TODO: change SBSWatchdogAssertionRelease to SBSWatchdogAssertionCancel
- // when we
- // all are up and running on systems that support it. The SBS framework has
- // a #define that will forward SBSWatchdogAssertionRelease to
- // SBSWatchdogAssertionCancel for now so it should still build either way.
- DNBLogThreadedIf(LOG_TASK, "::SBSWatchdogAssertionRelease(%p)",
- watchdog.get());
- ::SBSWatchdogAssertionRelease(watchdog.get());
- }
-#endif // #if defined (WITH_SPRINGBOARD) && !defined (WITH_BKS)
-
- LLDB_LOGF(log, "NativeProcessDarwin::%s(%p): thread exiting...", __FUNCTION__,
- this);
- return nullptr;
-}
-
-Status NativeProcessDarwin::StartExceptionThread() {
- Status error;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- LLDB_LOGF(log, "NativeProcessDarwin::%s() called", __FUNCTION__);
-
- // Make sure we've looked up the inferior port.
- TaskPortForProcessID(error);
-
- // Ensure the inferior task is valid.
- if (!IsTaskValid()) {
- error.SetErrorStringWithFormat("cannot start exception thread: "
- "task 0x%4.4x is not valid",
- m_task);
- return error;
- }
-
- // Get the mach port for the process monitor.
- mach_port_t task_self = mach_task_self();
-
- // Allocate an exception port that we will use to track our child process
- auto mach_err = ::mach_port_allocate(task_self, MACH_PORT_RIGHT_RECEIVE,
- &m_exception_port);
- error.SetError(mach_err, eErrorTypeMachKernel);
- if (error.Fail()) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): mach_port_allocate("
- "task_self=0x%4.4x, MACH_PORT_RIGHT_RECEIVE, "
- "&m_exception_port) failed: %u (%s)",
- __FUNCTION__, task_self, error.GetError(), error.AsCString());
- return error;
- }
-
- // Add the ability to send messages on the new exception port
- mach_err = ::mach_port_insert_right(
- task_self, m_exception_port, m_exception_port, MACH_MSG_TYPE_MAKE_SEND);
- error.SetError(mach_err, eErrorTypeMachKernel);
- if (error.Fail()) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): mach_port_insert_right("
- "task_self=0x%4.4x, m_exception_port=0x%4.4x, "
- "m_exception_port=0x%4.4x, MACH_MSG_TYPE_MAKE_SEND) "
- "failed: %u (%s)",
- __FUNCTION__, task_self, m_exception_port, m_exception_port,
- error.GetError(), error.AsCString());
- return error;
- }
-
- // Save the original state of the exception ports for our child process.
- error = SaveExceptionPortInfo();
- if (error.Fail() || (m_exc_port_info.mask == 0)) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): SaveExceptionPortInfo() "
- "failed, cannot install exception handler: %s",
- __FUNCTION__, error.AsCString());
- return error;
- }
-
- // Set the ability to get all exceptions on this port.
- mach_err = ::task_set_exception_ports(
- m_task, m_exc_port_info.mask, m_exception_port,
- EXCEPTION_DEFAULT | MACH_EXCEPTION_CODES, THREAD_STATE_NONE);
- error.SetError(mach_err, eErrorTypeMachKernel);
- if (error.Fail()) {
- LLDB_LOGF(log,
- "::task_set_exception_ports (task = 0x%4.4x, "
- "exception_mask = 0x%8.8x, new_port = 0x%4.4x, "
- "behavior = 0x%8.8x, new_flavor = 0x%8.8x) failed: "
- "%u (%s)",
- m_task, m_exc_port_info.mask, m_exception_port,
- (EXCEPTION_DEFAULT | MACH_EXCEPTION_CODES), THREAD_STATE_NONE,
- error.GetError(), error.AsCString());
- return error;
- }
-
- // Create the exception thread.
- auto pthread_err =
- ::pthread_create(&m_exception_thread, nullptr, ExceptionThread, this);
- error.SetError(pthread_err, eErrorTypePOSIX);
- if (error.Fail()) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): failed to create Mach "
- "exception-handling thread: %u (%s)",
- __FUNCTION__, error.GetError(), error.AsCString());
- }
-
- return error;
-}
-
-lldb::addr_t
-NativeProcessDarwin::GetDYLDAllImageInfosAddress(Status &error) const {
- error.Clear();
-
- struct hack_task_dyld_info dyld_info;
- mach_msg_type_number_t count = TASK_DYLD_INFO_COUNT;
- // Make sure that COUNT isn't bigger than our hacked up struct
- // hack_task_dyld_info. If it is, then make COUNT smaller to match.
- if (count > (sizeof(struct hack_task_dyld_info) / sizeof(natural_t))) {
- count = (sizeof(struct hack_task_dyld_info) / sizeof(natural_t));
- }
-
- TaskPortForProcessID(error);
- if (error.Fail())
- return LLDB_INVALID_ADDRESS;
-
- auto mach_err =
- ::task_info(m_task, TASK_DYLD_INFO, (task_info_t)&dyld_info, &count);
- error.SetError(mach_err, eErrorTypeMachKernel);
- if (error.Success()) {
- // We now have the address of the all image infos structure.
- return dyld_info.all_image_info_addr;
- }
-
- // We don't have it.
- return LLDB_INVALID_ADDRESS;
-}
-
-uint32_t NativeProcessDarwin::GetCPUTypeForLocalProcess(::pid_t pid) {
- int mib[CTL_MAXNAME] = {
- 0,
- };
- size_t len = CTL_MAXNAME;
-
- if (::sysctlnametomib("sysctl.proc_cputype", mib, &len))
- return 0;
-
- mib[len] = pid;
- len++;
-
- cpu_type_t cpu;
- size_t cpu_len = sizeof(cpu);
- if (::sysctl(mib, static_cast<u_int>(len), &cpu, &cpu_len, 0, 0))
- cpu = 0;
- return cpu;
-}
-
-uint32_t NativeProcessDarwin::GetCPUType() const {
- if (m_cpu_type == 0 && m_pid != 0)
- m_cpu_type = GetCPUTypeForLocalProcess(m_pid);
- return m_cpu_type;
-}
-
-task_t NativeProcessDarwin::ExceptionMessageBundleComplete() {
- // We have a complete bundle of exceptions for our child process.
- Status error;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
-
- std::lock_guard<std::recursive_mutex> locker(m_exception_messages_mutex);
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): processing %lu exception "
- "messages.",
- __FUNCTION__, m_exception_messages.size());
-
- if (m_exception_messages.empty()) {
- // Not particularly useful...
- return m_task;
- }
-
- bool auto_resume = false;
- m_did_exec = false;
-
- // First check for any SIGTRAP and make sure we didn't exec
- const task_t task = m_task;
- size_t i;
- if (m_pid != 0) {
- bool received_interrupt = false;
- uint32_t num_task_exceptions = 0;
- for (i = 0; i < m_exception_messages.size(); ++i) {
- if (m_exception_messages[i].state.task_port != task) {
- // This is an exception that is not for our inferior, ignore.
- continue;
- }
-
- // This is an exception for the inferior.
- ++num_task_exceptions;
- const int signo = m_exception_messages[i].state.SoftSignal();
- if (signo == SIGTRAP) {
- // SIGTRAP could mean that we exec'ed. We need to check the
- // dyld all_image_infos.infoArray to see if it is NULL and if so, say
- // that we exec'ed.
- const addr_t aii_addr = GetDYLDAllImageInfosAddress(error);
- if (aii_addr == LLDB_INVALID_ADDRESS)
- break;
-
- const addr_t info_array_count_addr = aii_addr + 4;
- uint32_t info_array_count = 0;
- size_t bytes_read = 0;
- Status read_error;
- read_error = ReadMemory(info_array_count_addr, // source addr
- &info_array_count, // dest addr
- 4, // byte count
- bytes_read); // #bytes read
- if (read_error.Success() && (bytes_read == 4)) {
- if (info_array_count == 0) {
- // We got the all infos address, and there are zero entries. We
- // think we exec'd.
- m_did_exec = true;
-
- // Force the task port to update itself in case the task port
- // changed after exec
- const task_t old_task = m_task;
- const bool force_update = true;
- const task_t new_task = TaskPortForProcessID(error, force_update);
- if (old_task != new_task) {
- LLDB_LOGF(log,
- "exec: inferior task port changed "
- "from 0x%4.4x to 0x%4.4x",
- old_task, new_task);
- }
- }
- } else {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s() warning: "
- "failed to read all_image_infos."
- "infoArrayCount from 0x%8.8llx",
- __FUNCTION__, info_array_count_addr);
- }
- } else if ((m_sent_interrupt_signo != 0) &&
- (signo == m_sent_interrupt_signo)) {
- // We just received the interrupt that we sent to ourselves.
- received_interrupt = true;
- }
- }
-
- if (m_did_exec) {
- cpu_type_t process_cpu_type = GetCPUTypeForLocalProcess(m_pid);
- if (m_cpu_type != process_cpu_type) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): arch changed from "
- "0x%8.8x to 0x%8.8x",
- __FUNCTION__, m_cpu_type, process_cpu_type);
- m_cpu_type = process_cpu_type;
- // TODO figure out if we need to do something here.
- // DNBArchProtocol::SetArchitecture (process_cpu_type);
- }
- m_thread_list.Clear();
-
- // TODO hook up breakpoints.
- // m_breakpoints.DisableAll();
- }
-
- if (m_sent_interrupt_signo != 0) {
- if (received_interrupt) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): process "
- "successfully interrupted with signal %i",
- __FUNCTION__, m_sent_interrupt_signo);
-
- // Mark that we received the interrupt signal
- m_sent_interrupt_signo = 0;
- // Now check if we had a case where:
- // 1 - We called NativeProcessDarwin::Interrupt() but we stopped
- // for another reason.
- // 2 - We called NativeProcessDarwin::Resume() (but still
- // haven't gotten the interrupt signal).
- // 3 - We are now incorrectly stopped because we are handling
- // the interrupt signal we missed.
- // 4 - We might need to resume if we stopped only with the
- // interrupt signal that we never handled.
- if (m_auto_resume_signo != 0) {
- // Only auto_resume if we stopped with _only_ the interrupt signal.
- if (num_task_exceptions == 1) {
- auto_resume = true;
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): auto "
- "resuming due to unhandled interrupt "
- "signal %i",
- __FUNCTION__, m_auto_resume_signo);
- }
- m_auto_resume_signo = 0;
- }
- } else {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): didn't get signal "
- "%i after MachProcess::Interrupt()",
- __FUNCTION__, m_sent_interrupt_signo);
- }
- }
- }
-
- // Let all threads recover from stopping and do any clean up based on the
- // previous thread state (if any).
- m_thread_list.ProcessDidStop(*this);
-
- // Let each thread know of any exceptions
- for (i = 0; i < m_exception_messages.size(); ++i) {
- // Let the thread list forward all exceptions on down to each thread.
- if (m_exception_messages[i].state.task_port == task) {
- // This exception is for our inferior.
- m_thread_list.NotifyException(m_exception_messages[i].state);
- }
-
- if (log) {
- StreamString stream;
- m_exception_messages[i].Dump(stream);
- stream.Flush();
- log->PutCString(stream.GetString().c_str());
- }
- }
-
- if (log) {
- StreamString stream;
- m_thread_list.Dump(stream);
- stream.Flush();
- log->PutCString(stream.GetString().c_str());
- }
-
- bool step_more = false;
- if (m_thread_list.ShouldStop(step_more) && (auto_resume == false)) {
-// TODO - need to hook up event system here. !!!!
-#if 0
- // Wait for the eEventProcessRunningStateChanged event to be reset
- // before changing state to stopped to avoid race condition with very
- // fast start/stops.
- struct timespec timeout;
-
- //DNBTimer::OffsetTimeOfDay(&timeout, 0, 250 * 1000); // Wait for 250 ms
- DNBTimer::OffsetTimeOfDay(&timeout, 1, 0); // Wait for 250 ms
- m_events.WaitForEventsToReset(eEventProcessRunningStateChanged,
- &timeout);
-#endif
- SetState(eStateStopped);
- } else {
- // Resume without checking our current state.
- PrivateResume();
- }
-
- return m_task;
-}
-
-void NativeProcessDarwin::StartSTDIOThread() {
- // TODO implement
-}
-
-Status NativeProcessDarwin::StartWaitpidThread(MainLoop &main_loop) {
- Status error;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-
- // Strategy: create a thread that sits on waitpid(), waiting for the inferior
- // process to die, reaping it in the process. Arrange for the thread to have
- // a pipe file descriptor that it can send a byte over when the waitpid
- // completes. Have the main loop have a read object for the other side of
- // the pipe, and have the callback for the read do the process termination
- // message sending.
-
- // Create a single-direction communication channel.
- const bool child_inherits = false;
- error = m_waitpid_pipe.CreateNew(child_inherits);
- if (error.Fail()) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): failed to create waitpid "
- "communication pipe: %s",
- __FUNCTION__, error.AsCString());
- return error;
- }
-
- // Hook up the waitpid reader callback.
-
- // TODO make PipePOSIX derive from IOObject. This is goofy here.
- const bool transfer_ownership = false;
- auto io_sp = IOObjectSP(new NativeFile(m_waitpid_pipe.GetReadFileDescriptor(),
- transfer_ownership));
- m_waitpid_reader_handle = main_loop.RegisterReadObject(
- io_sp, [this](MainLoopBase &) { HandleWaitpidResult(); }, error);
-
- // Create the thread.
- auto pthread_err =
- ::pthread_create(&m_waitpid_thread, nullptr, WaitpidThread, this);
- error.SetError(pthread_err, eErrorTypePOSIX);
- if (error.Fail()) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): failed to create waitpid "
- "handling thread: %u (%s)",
- __FUNCTION__, error.GetError(), error.AsCString());
- return error;
- }
-
- return error;
-}
-
-void *NativeProcessDarwin::WaitpidThread(void *arg) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (!arg) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): cannot run waitpid "
- "thread, mandatory process arg was null",
- __FUNCTION__);
- return nullptr;
- }
-
- return reinterpret_cast<NativeProcessDarwin *>(arg)->DoWaitpidThread();
-}
-
-void NativeProcessDarwin::MaybeRaiseThreadPriority() {
-#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
- struct sched_param thread_param;
- int thread_sched_policy;
- if (pthread_getschedparam(pthread_self(), &thread_sched_policy,
- &thread_param) == 0) {
- thread_param.sched_priority = 47;
- pthread_setschedparam(pthread_self(), thread_sched_policy, &thread_param);
- }
-#endif
-}
-
-void *NativeProcessDarwin::DoWaitpidThread() {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-
- if (m_pid == LLDB_INVALID_PROCESS_ID) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): inferior process ID is "
- "not set, cannot waitpid on it",
- __FUNCTION__);
- return nullptr;
- }
-
- // Name the thread.
- pthread_setname_np("waitpid thread");
-
- // Ensure we don't get CPU starved.
- MaybeRaiseThreadPriority();
-
- Status error;
- int status = -1;
-
- while (1) {
- // Do a waitpid.
- ::pid_t child_pid = ::waitpid(m_pid, &status, 0);
- if (child_pid < 0)
- error.SetErrorToErrno();
- if (error.Fail()) {
- if (error.GetError() == EINTR) {
- // This is okay, we can keep going.
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): waitpid(pid = %" PRIu64
- ", &status, 0) interrupted, continuing",
- __FUNCTION__, m_pid);
- continue;
- }
-
- // This error is not okay, abort.
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): waitpid(pid = %" PRIu64
- ", &status, 0) aborting due to error: %u (%s)",
- __FUNCTION__, m_pid, error.GetError(), error.AsCString());
- break;
- }
-
- // Log the successful result.
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): waitpid(pid = %" PRIu64
- ", &status, 0) => %i, status = %i",
- __FUNCTION__, m_pid, child_pid, status);
-
- // Handle the result.
- if (WIFSTOPPED(status)) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): waitpid(pid = %" PRIu64
- ") received a stop, continuing waitpid() loop",
- __FUNCTION__, m_pid);
- continue;
- } else // if (WIFEXITED(status) || WIFSIGNALED(status))
- {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(pid = %" PRIu64 "): "
- "waitpid thread is setting exit status for pid = "
- "%i to %i",
- __FUNCTION__, m_pid, child_pid, status);
-
- error = SendInferiorExitStatusToMainLoop(child_pid, status);
- return nullptr;
- }
- }
-
- // We should never exit as long as our child process is alive. If we get
- // here, something completely unexpected went wrong and we should exit.
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): internal error: waitpid thread "
- "exited out of its main loop in an unexpected way. pid = %" PRIu64
- ". Sending exit status of -1.",
- __FUNCTION__, m_pid);
-
- error = SendInferiorExitStatusToMainLoop((::pid_t)m_pid, -1);
- return nullptr;
-}
-
-Status NativeProcessDarwin::SendInferiorExitStatusToMainLoop(::pid_t pid,
- int status) {
- Status error;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-
- size_t bytes_written = 0;
-
- // Send the pid.
- error = m_waitpid_pipe.Write(&pid, sizeof(pid), bytes_written);
- if (error.Fail() || (bytes_written < sizeof(pid))) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s() - failed to write "
- "waitpid exiting pid to the pipe. Client will not "
- "hear about inferior exit status!",
- __FUNCTION__);
- return error;
- }
-
- // Send the status.
- bytes_written = 0;
- error = m_waitpid_pipe.Write(&status, sizeof(status), bytes_written);
- if (error.Fail() || (bytes_written < sizeof(status))) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s() - failed to write "
- "waitpid exit result to the pipe. Client will not "
- "hear about inferior exit status!",
- __FUNCTION__);
- }
- return error;
-}
-
-Status NativeProcessDarwin::HandleWaitpidResult() {
- Status error;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-
- // Read the pid.
- const bool notify_status = true;
-
- ::pid_t pid = -1;
- size_t bytes_read = 0;
- error = m_waitpid_pipe.Read(&pid, sizeof(pid), bytes_read);
- if (error.Fail() || (bytes_read < sizeof(pid))) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s() - failed to read "
- "waitpid exiting pid from the pipe. Will notify "
- "as if parent process died with exit status -1.",
- __FUNCTION__);
- SetExitStatus(WaitStatus(WaitStatus::Exit, -1), notify_status);
- return error;
- }
-
- // Read the status.
- int status = -1;
- error = m_waitpid_pipe.Read(&status, sizeof(status), bytes_read);
- if (error.Fail() || (bytes_read < sizeof(status))) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s() - failed to read "
- "waitpid exit status from the pipe. Will notify "
- "as if parent process died with exit status -1.",
- __FUNCTION__);
- SetExitStatus(WaitStatus(WaitStatus::Exit, -1), notify_status);
- return error;
- }
-
- // Notify the monitor that our state has changed.
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): main loop received waitpid "
- "exit status info: pid=%i (%s), status=%i",
- __FUNCTION__, pid,
- (pid == m_pid) ? "the inferior" : "not the inferior", status);
-
- SetExitStatus(WaitStatus::Decode(status), notify_status);
- return error;
-}
-
-task_t NativeProcessDarwin::TaskPortForProcessID(Status &error,
- bool force) const {
- if ((m_task == TASK_NULL) || force) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (m_pid == LLDB_INVALID_PROCESS_ID) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): cannot get task due "
- "to invalid pid",
- __FUNCTION__);
- return TASK_NULL;
- }
-
- const uint32_t num_retries = 10;
- const uint32_t usec_interval = 10000;
-
- mach_port_t task_self = mach_task_self();
- task_t task = TASK_NULL;
-
- for (uint32_t i = 0; i < num_retries; i++) {
- kern_return_t err = ::task_for_pid(task_self, m_pid, &task);
- if (err == 0) {
- // Succeeded. Save and return it.
- error.Clear();
- m_task = task;
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): ::task_for_pid("
- "stub_port = 0x%4.4x, pid = %llu, &task) "
- "succeeded: inferior task port = 0x%4.4x",
- __FUNCTION__, task_self, m_pid, m_task);
- return m_task;
- } else {
- // Failed to get the task for the inferior process.
- error.SetError(err, eErrorTypeMachKernel);
- if (log) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): ::task_for_pid("
- "stub_port = 0x%4.4x, pid = %llu, &task) "
- "failed, err = 0x%8.8x (%s)",
- __FUNCTION__, task_self, m_pid, err, error.AsCString());
- }
- }
-
- // Sleep a bit and try again
- ::usleep(usec_interval);
- }
-
- // We failed to get the task for the inferior process. Ensure that it is
- // cleared out.
- m_task = TASK_NULL;
- }
- return m_task;
-}
-
-void NativeProcessDarwin::AttachToInferior(MainLoop &mainloop, lldb::pid_t pid,
- Status &error) {
- error.SetErrorString("TODO: implement");
-}
-
-Status NativeProcessDarwin::PrivateResume() {
- Status error;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-
- std::lock_guard<std::recursive_mutex> locker(m_exception_messages_mutex);
- m_auto_resume_signo = m_sent_interrupt_signo;
-
- if (log) {
- if (m_auto_resume_signo)
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): task 0x%x resuming (with "
- "unhandled interrupt signal %i)...",
- __FUNCTION__, m_task, m_auto_resume_signo);
- else
- LLDB_LOGF(log, "NativeProcessDarwin::%s(): task 0x%x resuming...",
- __FUNCTION__, m_task);
- }
-
- error = ReplyToAllExceptions();
- if (error.Fail()) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): aborting, failed to "
- "reply to exceptions: %s",
- __FUNCTION__, error.AsCString());
- return error;
- }
- // bool stepOverBreakInstruction = step;
-
- // Let the thread prepare to resume and see if any threads want us to step
- // over a breakpoint instruction (ProcessWillResume will modify the value of
- // stepOverBreakInstruction).
- m_thread_list.ProcessWillResume(*this, m_thread_actions);
-
- // Set our state accordingly
- if (m_thread_actions.NumActionsWithState(eStateStepping))
- SetState(eStateStepping);
- else
- SetState(eStateRunning);
-
- // Now resume our task.
- error = ResumeTask();
- return error;
-}
-
-Status NativeProcessDarwin::ReplyToAllExceptions() {
- Status error;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
-
- TaskPortForProcessID(error);
- if (error.Fail()) {
- LLDB_LOGF(log, "NativeProcessDarwin::%s(): no task port, aborting",
- __FUNCTION__);
- return error;
- }
-
- std::lock_guard<std::recursive_mutex> locker(m_exception_messages_mutex);
- if (m_exception_messages.empty()) {
- // We're done.
- return error;
- }
-
- size_t index = 0;
- for (auto &message : m_exception_messages) {
- if (log) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): replying to exception "
- "%zu...",
- __FUNCTION__, index++);
- }
-
- int thread_reply_signal = 0;
-
- const tid_t tid =
- m_thread_list.GetThreadIDByMachPortNumber(message.state.thread_port);
- const ResumeAction *action = nullptr;
- if (tid != LLDB_INVALID_THREAD_ID)
- action = m_thread_actions.GetActionForThread(tid, false);
-
- if (action) {
- thread_reply_signal = action->signal;
- if (thread_reply_signal)
- m_thread_actions.SetSignalHandledForThread(tid);
- }
-
- error = message.Reply(m_pid, m_task, thread_reply_signal);
- if (error.Fail() && log) {
- // We log any error here, but we don't stop the exception response
- // handling.
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): failed to reply to "
- "exception: %s",
- __FUNCTION__, error.AsCString());
- error.Clear();
- }
- }
-
- // Erase all exception message as we should have used and replied to them all
- // already.
- m_exception_messages.clear();
- return error;
-}
-
-Status NativeProcessDarwin::ResumeTask() {
- Status error;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-
- TaskPortForProcessID(error);
- if (error.Fail()) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): failed to get task port "
- "for process when attempting to resume: %s",
- __FUNCTION__, error.AsCString());
- return error;
- }
- if (m_task == TASK_NULL) {
- error.SetErrorString("task port retrieval succeeded but task port is "
- "null when attempting to resume the task");
- return error;
- }
-
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): requesting resume of task "
- "0x%4.4x",
- __FUNCTION__, m_task);
-
- // Get the BasicInfo struct to verify that we're suspended before we try to
- // resume the task.
- struct task_basic_info task_info;
- error = GetTaskBasicInfo(m_task, &task_info);
- if (error.Fail()) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): failed to get task "
- "BasicInfo when attempting to resume: %s",
- __FUNCTION__, error.AsCString());
- return error;
- }
-
- // task_resume isn't counted like task_suspend calls are, so if the task is
- // not suspended, don't try and resume it since it is already running
- if (task_info.suspend_count > 0) {
- auto mach_err = ::task_resume(m_task);
- error.SetError(mach_err, eErrorTypeMachKernel);
- if (log) {
- if (error.Success())
- LLDB_LOGF(log, "::task_resume(target_task = 0x%4.4x): success", m_task);
- else
- LLDB_LOGF(log, "::task_resume(target_task = 0x%4.4x) error: %s", m_task,
- error.AsCString());
- }
- } else {
- LLDB_LOGF(log,
- "::task_resume(target_task = 0x%4.4x): ignored, "
- "already running",
- m_task);
- }
-
- return error;
-}
-
-bool NativeProcessDarwin::IsTaskValid() const {
- if (m_task == TASK_NULL)
- return false;
-
- struct task_basic_info task_info;
- return GetTaskBasicInfo(m_task, &task_info).Success();
-}
-
-bool NativeProcessDarwin::IsTaskValid(task_t task) const {
- if (task == TASK_NULL)
- return false;
-
- struct task_basic_info task_info;
- return GetTaskBasicInfo(task, &task_info).Success();
-}
-
-mach_port_t NativeProcessDarwin::GetExceptionPort() const {
- return m_exception_port;
-}
-
-bool NativeProcessDarwin::IsExceptionPortValid() const {
- return MACH_PORT_VALID(m_exception_port);
-}
-
-Status
-NativeProcessDarwin::GetTaskBasicInfo(task_t task,
- struct task_basic_info *info) const {
- Status error;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-
- // Validate args.
- if (info == NULL) {
- error.SetErrorStringWithFormat("NativeProcessDarwin::%s(): mandatory "
- "info arg is null",
- __FUNCTION__);
- return error;
- }
-
- // Grab the task if we don't already have it.
- if (task == TASK_NULL) {
- error.SetErrorStringWithFormat("NativeProcessDarwin::%s(): given task "
- "is invalid",
- __FUNCTION__);
- }
-
- mach_msg_type_number_t count = TASK_BASIC_INFO_COUNT;
- auto err = ::task_info(m_task, TASK_BASIC_INFO, (task_info_t)info, &count);
- error.SetError(err, eErrorTypeMachKernel);
- if (error.Fail()) {
- LLDB_LOGF(log,
- "::task_info(target_task = 0x%4.4x, "
- "flavor = TASK_BASIC_INFO, task_info_out => %p, "
- "task_info_outCnt => %u) failed: %u (%s)",
- m_task, info, count, error.GetError(), error.AsCString());
- return error;
- }
-
- Log *verbose_log(
- GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE));
- if (verbose_log) {
- float user = (float)info->user_time.seconds +
- (float)info->user_time.microseconds / 1000000.0f;
- float system = (float)info->user_time.seconds +
- (float)info->user_time.microseconds / 1000000.0f;
- verbose_LLDB_LOGF(log,
- "task_basic_info = { suspend_count = %i, "
- "virtual_size = 0x%8.8llx, resident_size = "
- "0x%8.8llx, user_time = %f, system_time = %f }",
- info->suspend_count, (uint64_t)info->virtual_size,
- (uint64_t)info->resident_size, user, system);
- }
- return error;
-}
-
-Status NativeProcessDarwin::SuspendTask() {
- Status error;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-
- if (m_task == TASK_NULL) {
- error.SetErrorString("task port is null, cannot suspend task");
- LLDB_LOGF(log, "NativeProcessDarwin::%s() failed: %s", __FUNCTION__,
- error.AsCString());
- return error;
- }
-
- auto mach_err = ::task_suspend(m_task);
- error.SetError(mach_err, eErrorTypeMachKernel);
- if (error.Fail() && log)
- LLDB_LOGF(log, "::task_suspend(target_task = 0x%4.4x)", m_task);
-
- return error;
-}
-
-Status NativeProcessDarwin::Resume(const ResumeActionList &resume_actions) {
- Status error;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-
- LLDB_LOGF(log, "NativeProcessDarwin::%s() called", __FUNCTION__);
-
- if (CanResume()) {
- m_thread_actions = resume_actions;
- error = PrivateResume();
- return error;
- }
-
- auto state = GetState();
- if (state == eStateRunning) {
- LLDB_LOGF(log,
- "NativeProcessDarwin::%s(): task 0x%x is already "
- "running, ignoring...",
- __FUNCTION__, TaskPortForProcessID(error));
- return error;
- }
-
- // We can't resume from this state.
- error.SetErrorStringWithFormat("task 0x%x has state %s, can't resume",
- TaskPortForProcessID(error),
- StateAsCString(state));
- return error;
-}
-
-Status NativeProcessDarwin::Halt() {
- Status error;
- error.SetErrorString("TODO: implement");
- return error;
-}
-
-Status NativeProcessDarwin::Detach() {
- Status error;
- error.SetErrorString("TODO: implement");
- return error;
-}
-
-Status NativeProcessDarwin::Signal(int signo) {
- Status error;
- error.SetErrorString("TODO: implement");
- return error;
-}
-
-Status NativeProcessDarwin::Interrupt() {
- Status error;
- error.SetErrorString("TODO: implement");
- return error;
-}
-
-Status NativeProcessDarwin::Kill() {
- Status error;
- error.SetErrorString("TODO: implement");
- return error;
-}
-
-Status NativeProcessDarwin::GetMemoryRegionInfo(lldb::addr_t load_addr,
- MemoryRegionInfo &range_info) {
- Status error;
- error.SetErrorString("TODO: implement");
- return error;
-}
-
-Status NativeProcessDarwin::ReadMemory(lldb::addr_t addr, void *buf,
- size_t size, size_t &bytes_read) {
- Status error;
- error.SetErrorString("TODO: implement");
- return error;
-}
-
-Status NativeProcessDarwin::ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf,
- size_t size,
- size_t &bytes_read) {
- Status error;
- error.SetErrorString("TODO: implement");
- return error;
-}
-
-Status NativeProcessDarwin::WriteMemory(lldb::addr_t addr, const void *buf,
- size_t size, size_t &bytes_written) {
- Status error;
- error.SetErrorString("TODO: implement");
- return error;
-}
-
-Status NativeProcessDarwin::AllocateMemory(size_t size, uint32_t permissions,
- lldb::addr_t &addr) {
- Status error;
- error.SetErrorString("TODO: implement");
- return error;
-}
-
-Status NativeProcessDarwin::DeallocateMemory(lldb::addr_t addr) {
- Status error;
- error.SetErrorString("TODO: implement");
- return error;
-}
-
-lldb::addr_t NativeProcessDarwin::GetSharedLibraryInfoAddress() {
- return LLDB_INVALID_ADDRESS;
-}
-
-size_t NativeProcessDarwin::UpdateThreads() { return 0; }
-
-bool NativeProcessDarwin::GetArchitecture(ArchSpec &arch) const {
- return false;
-}
-
-Status NativeProcessDarwin::SetBreakpoint(lldb::addr_t addr, uint32_t size,
- bool hardware) {
- Status error;
- error.SetErrorString("TODO: implement");
- return error;
-}
-
-void NativeProcessDarwin::DoStopIDBumped(uint32_t newBumpId) {}
-
-Status NativeProcessDarwin::GetLoadedModuleFileSpec(const char *module_path,
- FileSpec &file_spec) {
- Status error;
- error.SetErrorString("TODO: implement");
- return error;
-}
-
-Status NativeProcessDarwin::GetFileLoadAddress(const llvm::StringRef &file_name,
- lldb::addr_t &load_addr) {
- Status error;
- error.SetErrorString("TODO: implement");
- return error;
-}
-
-// NativeProcessProtocol protected interface
-Status NativeProcessDarwin::GetSoftwareBreakpointTrapOpcode(
- size_t trap_opcode_size_hint, size_t &actual_opcode_size,
- const uint8_t *&trap_opcode_bytes) {
- Status error;
- error.SetErrorString("TODO: implement");
- return error;
-}
diff --git a/lldb/source/Plugins/Process/Darwin/NativeProcessDarwin.h b/lldb/source/Plugins/Process/Darwin/NativeProcessDarwin.h
deleted file mode 100644
index 6741d4ddc5d8..000000000000
--- a/lldb/source/Plugins/Process/Darwin/NativeProcessDarwin.h
+++ /dev/null
@@ -1,337 +0,0 @@
-//===-- NativeProcessDarwin.h --------------------------------- -*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef NativeProcessDarwin_h
-#define NativeProcessDarwin_h
-
-// NOTE: this code should only be compiled on Apple Darwin systems. It is
-// not cross-platform code and is not intended to build on any other platform.
-// Therefore, platform-specific headers and code are okay here.
-
-// C includes
-#include <mach/mach_types.h>
-
-// C++ includes
-#include <mutex>
-#include <unordered_set>
-
-#include "lldb/Host/Debug.h"
-#include "lldb/Host/HostThread.h"
-#include "lldb/Host/Pipe.h"
-#include "lldb/Host/common/NativeProcessProtocol.h"
-#include "lldb/Target/MemoryRegionInfo.h"
-#include "lldb/Utility/ArchSpec.h"
-#include "lldb/Utility/FileSpec.h"
-#include "lldb/lldb-types.h"
-
-#include "LaunchFlavor.h"
-#include "MachException.h"
-#include "NativeThreadDarwin.h"
-#include "NativeThreadListDarwin.h"
-
-namespace lldb_private {
-class Status;
-class Scalar;
-
-namespace process_darwin {
-
-/// \class NativeProcessDarwin
-/// Manages communication with the inferior (debugee) process.
-///
-/// Upon construction, this class prepares and launches an inferior process
-/// for debugging.
-///
-/// Changes in the inferior process state are broadcasted.
-class NativeProcessDarwin : public NativeProcessProtocol {
- friend Status NativeProcessProtocol::Launch(
- ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate,
- MainLoop &mainloop, NativeProcessProtocolSP &process_sp);
-
- friend Status NativeProcessProtocol::Attach(
- lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate,
- MainLoop &mainloop, NativeProcessProtocolSP &process_sp);
-
-public:
- ~NativeProcessDarwin() override;
-
- // NativeProcessProtocol Interface
- Status Resume(const ResumeActionList &resume_actions) override;
-
- Status Halt() override;
-
- Status Detach() override;
-
- Status Signal(int signo) override;
-
- Status Interrupt() override;
-
- Status Kill() override;
-
- Status GetMemoryRegionInfo(lldb::addr_t load_addr,
- MemoryRegionInfo &range_info) override;
-
- Status ReadMemory(lldb::addr_t addr, void *buf, size_t size,
- size_t &bytes_read) override;
-
- Status ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size,
- size_t &bytes_read) override;
-
- Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size,
- size_t &bytes_written) override;
-
- Status AllocateMemory(size_t size, uint32_t permissions,
- lldb::addr_t &addr) override;
-
- Status DeallocateMemory(lldb::addr_t addr) override;
-
- lldb::addr_t GetSharedLibraryInfoAddress() override;
-
- size_t UpdateThreads() override;
-
- bool GetArchitecture(ArchSpec &arch) const override;
-
- Status SetBreakpoint(lldb::addr_t addr, uint32_t size,
- bool hardware) override;
-
- void DoStopIDBumped(uint32_t newBumpId) override;
-
- Status GetLoadedModuleFileSpec(const char *module_path,
- FileSpec &file_spec) override;
-
- Status GetFileLoadAddress(const llvm::StringRef &file_name,
- lldb::addr_t &load_addr) override;
-
- NativeThreadDarwinSP GetThreadByID(lldb::tid_t id);
-
- task_t GetTask() const { return m_task; }
-
- // Interface used by NativeRegisterContext-derived classes.
- static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr,
- void *data = nullptr, size_t data_size = 0,
- long *result = nullptr);
-
- bool SupportHardwareSingleStepping() const;
-
-protected:
- // NativeProcessProtocol protected interface
- Status
- GetSoftwareBreakpointTrapOpcode(size_t trap_opcode_size_hint,
- size_t &actual_opcode_size,
- const uint8_t *&trap_opcode_bytes) override;
-
-private:
- /// Mach task-related Member Variables
-
- // The task port for the inferior process.
- mutable task_t m_task;
-
- // True if the inferior process did an exec since we started
- // monitoring it.
- bool m_did_exec;
-
- // The CPU type of this process.
- mutable cpu_type_t m_cpu_type;
-
- /// Exception/Signal Handling Member Variables
-
- // Exception port on which we will receive child exceptions
- mach_port_t m_exception_port;
-
- // Saved state of the child exception port prior to us installing
- // our own intercepting port.
- MachException::PortInfo m_exc_port_info;
-
- // The thread that runs the Mach exception read and reply handler.
- pthread_t m_exception_thread;
-
- // TODO see if we can remove this if we get the exception collection
- // and distribution to happen in a single-threaded fashion.
- std::recursive_mutex m_exception_messages_mutex;
-
- // A collection of exception messages caught when listening to the
- // exception port.
- MachException::Message::collection m_exception_messages;
-
- // When we call MachProcess::Interrupt(), we want to send this
- // signal (if non-zero).
- int m_sent_interrupt_signo;
-
- // If we resume the process and still haven't received our
- // interrupt signal (if this is non-zero).
- int m_auto_resume_signo;
-
- /// Thread-related Member Variables
- NativeThreadListDarwin m_thread_list;
- ResumeActionList m_thread_actions;
-
- /// Process Lifetime Member Variable
-
- // The pipe over which the waitpid thread and the main loop will
- // communicate.
- Pipe m_waitpid_pipe;
-
- // The thread that runs the waitpid handler.
- pthread_t m_waitpid_thread;
-
- // waitpid reader callback handle.
- MainLoop::ReadHandleUP m_waitpid_reader_handle;
-
- // Private Instance Methods
- NativeProcessDarwin(lldb::pid_t pid, int pty_master_fd);
-
- /// Finalize the launch.
- ///
- /// This method associates the NativeProcessDarwin instance with the host
- /// process that was just launched. It peforms actions like attaching a
- /// listener to the inferior exception port, ptracing the process, and the
- /// like.
- ///
- /// \param[in] launch_flavor
- /// The launch flavor that was used to launch the process.
- ///
- /// \param[in] main_loop
- /// The main loop that will run the process monitor. Work
- /// that needs to be done (e.g. reading files) gets registered
- /// here along with callbacks to process the work.
- ///
- /// \return
- /// Any error that occurred during the aforementioned
- /// operations. Failure here will force termination of the
- /// launched process and debugging session.
- Status FinalizeLaunch(LaunchFlavor launch_flavor, MainLoop &main_loop);
-
- Status SaveExceptionPortInfo();
-
- void ExceptionMessageReceived(const MachException::Message &message);
-
- void MaybeRaiseThreadPriority();
-
- Status StartExceptionThread();
-
- Status SendInferiorExitStatusToMainLoop(::pid_t pid, int status);
-
- Status HandleWaitpidResult();
-
- bool ProcessUsingSpringBoard() const;
-
- bool ProcessUsingBackBoard() const;
-
- static void *ExceptionThread(void *arg);
-
- void *DoExceptionThread();
-
- lldb::addr_t GetDYLDAllImageInfosAddress(Status &error) const;
-
- static uint32_t GetCPUTypeForLocalProcess(::pid_t pid);
-
- uint32_t GetCPUType() const;
-
- task_t ExceptionMessageBundleComplete();
-
- void StartSTDIOThread();
-
- Status StartWaitpidThread(MainLoop &main_loop);
-
- static void *WaitpidThread(void *arg);
-
- void *DoWaitpidThread();
-
- task_t TaskPortForProcessID(Status &error, bool force = false) const;
-
- /// Attaches to an existing process. Forms the implementation of
- /// Process::DoAttach.
- void AttachToInferior(MainLoop &mainloop, lldb::pid_t pid, Status &error);
-
- ::pid_t Attach(lldb::pid_t pid, Status &error);
-
- Status PrivateResume();
-
- Status ReplyToAllExceptions();
-
- Status ResumeTask();
-
- bool IsTaskValid() const;
-
- bool IsTaskValid(task_t task) const;
-
- mach_port_t GetExceptionPort() const;
-
- bool IsExceptionPortValid() const;
-
- Status GetTaskBasicInfo(task_t task, struct task_basic_info *info) const;
-
- Status SuspendTask();
-
- static Status SetDefaultPtraceOpts(const lldb::pid_t);
-
- static void *MonitorThread(void *baton);
-
- void MonitorCallback(lldb::pid_t pid, bool exited, int signal, int status);
-
- void WaitForNewThread(::pid_t tid);
-
- void MonitorSIGTRAP(const siginfo_t &info, NativeThreadDarwin &thread);
-
- void MonitorTrace(NativeThreadDarwin &thread);
-
- void MonitorBreakpoint(NativeThreadDarwin &thread);
-
- void MonitorWatchpoint(NativeThreadDarwin &thread, uint32_t wp_index);
-
- void MonitorSignal(const siginfo_t &info, NativeThreadDarwin &thread,
- bool exited);
-
- Status SetupSoftwareSingleStepping(NativeThreadDarwin &thread);
-
- bool HasThreadNoLock(lldb::tid_t thread_id);
-
- bool StopTrackingThread(lldb::tid_t thread_id);
-
- NativeThreadDarwinSP AddThread(lldb::tid_t thread_id);
-
- Status GetSoftwareBreakpointPCOffset(uint32_t &actual_opcode_size);
-
- Status FixupBreakpointPCAsNeeded(NativeThreadDarwin &thread);
-
- /// Writes a siginfo_t structure corresponding to the given thread
- /// ID to the memory region pointed to by \p siginfo.
- Status GetSignalInfo(lldb::tid_t tid, void *siginfo);
-
- /// Writes the raw event message code (vis-a-vis PTRACE_GETEVENTMSG)
- /// corresponding to the given thread ID to the memory pointed to by @p
- /// message.
- Status GetEventMessage(lldb::tid_t tid, unsigned long *message);
-
- void NotifyThreadDeath(lldb::tid_t tid);
-
- Status Detach(lldb::tid_t tid);
-
- // This method is requests a stop on all threads which are still
- // running. It sets up a deferred delegate notification, which will
- // fire once threads report as stopped. The triggerring_tid will be
- // set as the current thread (main stop reason).
- void StopRunningThreads(lldb::tid_t triggering_tid);
-
- // Notify the delegate if all threads have stopped.
- void SignalIfAllThreadsStopped();
-
- // Resume the given thread, optionally passing it the given signal.
- // The type of resume operation (continue, single-step) depends on
- // the state parameter.
- Status ResumeThread(NativeThreadDarwin &thread, lldb::StateType state,
- int signo);
-
- void ThreadWasCreated(NativeThreadDarwin &thread);
-
- void SigchldHandler();
-};
-
-} // namespace process_darwin
-} // namespace lldb_private
-
-#endif /* NativeProcessDarwin_h */
diff --git a/lldb/source/Plugins/Process/Darwin/NativeThreadDarwin.cpp b/lldb/source/Plugins/Process/Darwin/NativeThreadDarwin.cpp
deleted file mode 100644
index bcd6d8c2c4c1..000000000000
--- a/lldb/source/Plugins/Process/Darwin/NativeThreadDarwin.cpp
+++ /dev/null
@@ -1,281 +0,0 @@
-//===-- NativeThreadDarwin.cpp -------------------------------- -*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "NativeThreadDarwin.h"
-
-// C includes
-#include <libproc.h>
-
-// LLDB includes
-#include "lldb/Utility/Stream.h"
-
-#include "NativeProcessDarwin.h"
-
-using namespace lldb;
-using namespace lldb_private;
-using namespace lldb_private::process_darwin;
-
-uint64_t NativeThreadDarwin::GetGloballyUniqueThreadIDForMachPortID(
- ::thread_t mach_port_id) {
- thread_identifier_info_data_t tident;
- mach_msg_type_number_t tident_count = THREAD_IDENTIFIER_INFO_COUNT;
-
- auto mach_err = ::thread_info(mach_port_id, THREAD_IDENTIFIER_INFO,
- (thread_info_t)&tident, &tident_count);
- if (mach_err != KERN_SUCCESS) {
- // When we fail to get thread info for the supposed port, assume it is
- // really a globally unique thread id already, or return the best thing we
- // can, which is the thread port.
- return mach_port_id;
- }
- return tident.thread_id;
-}
-
-NativeThreadDarwin::NativeThreadDarwin(NativeProcessDarwin *process,
- bool is_64_bit,
- lldb::tid_t unique_thread_id,
- ::thread_t mach_thread_port)
- : NativeThreadProtocol(process, unique_thread_id),
- m_mach_thread_port(mach_thread_port), m_basic_info(),
- m_proc_threadinfo() {}
-
-bool NativeThreadDarwin::GetIdentifierInfo() {
- // Don't try to get the thread info once and cache it for the life of the
- // thread. It changes over time, for instance if the thread name changes,
- // then the thread_handle also changes... So you have to refetch it every
- // time.
- mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT;
- kern_return_t kret = ::thread_info(m_mach_thread_port, THREAD_IDENTIFIER_INFO,
- (thread_info_t)&m_ident_info, &count);
- return kret == KERN_SUCCESS;
-
- return false;
-}
-
-std::string NativeThreadDarwin::GetName() {
- std::string name;
-
- if (GetIdentifierInfo()) {
- auto process_sp = GetProcess();
- if (!process_sp) {
- name = "<unavailable>";
- return name;
- }
-
- int len = ::proc_pidinfo(process_sp->GetID(), PROC_PIDTHREADINFO,
- m_ident_info.thread_handle, &m_proc_threadinfo,
- sizeof(m_proc_threadinfo));
-
- if (len && m_proc_threadinfo.pth_name[0])
- name = m_proc_threadinfo.pth_name;
- }
- return name;
-}
-
-lldb::StateType NativeThreadDarwin::GetState() {
- // TODO implement
- return eStateInvalid;
-}
-
-bool NativeThreadDarwin::GetStopReason(ThreadStopInfo &stop_info,
- std::string &description) {
- // TODO implement
- return false;
-}
-
-NativeRegisterContextSP NativeThreadDarwin::GetRegisterContext() {
- // TODO implement
- return NativeRegisterContextSP();
-}
-
-Status NativeThreadDarwin::SetWatchpoint(lldb::addr_t addr, size_t size,
- uint32_t watch_flags, bool hardware) {
- Status error;
- error.SetErrorString("not yet implemented");
- return error;
-}
-
-Status NativeThreadDarwin::RemoveWatchpoint(lldb::addr_t addr) {
- Status error;
- error.SetErrorString("not yet implemented");
- return error;
-}
-
-void NativeThreadDarwin::Dump(Stream &stream) const {
-// This is what we really want once we have the thread class wired up.
-#if 0
- DNBLogThreaded("[%3u] #%3u tid: 0x%8.8" PRIx64 ", pc: 0x%16.16" PRIx64 ", sp: 0x%16.16" PRIx64 ", user: %d.%6.6d, system: %d.%6.6d, cpu: %2d, policy: %2d, run_state: %2d (%s), flags: %2d, suspend_count: %2d (current %2d), sleep_time: %d",
- index,
- m_seq_id,
- m_unique_id,
- GetPC(INVALID_NUB_ADDRESS),
- GetSP(INVALID_NUB_ADDRESS),
- m_basic_info.user_time.seconds, m_basic_info.user_time.microseconds,
- m_basic_info.system_time.seconds, m_basic_info.system_time.microseconds,
- m_basic_info.cpu_usage,
- m_basic_info.policy,
- m_basic_info.run_state,
- thread_run_state,
- m_basic_info.flags,
- m_basic_info.suspend_count, m_suspend_count,
- m_basic_info.sleep_time);
-
-#else
- // Here's all we have right now.
- stream.Printf("tid: 0x%8.8" PRIx64 ", thread port: 0x%4.4x", GetID(),
- m_mach_thread_port);
-#endif
-}
-
-bool NativeThreadDarwin::NotifyException(MachException::Data &exc) {
-// TODO implement this.
-#if 0
- // Allow the arch specific protocol to process (MachException::Data &)exc
- // first before possible reassignment of m_stop_exception with exc. See
- // also MachThread::GetStopException().
- bool handled = m_arch_up->NotifyException(exc);
-
- if (m_stop_exception.IsValid())
- {
- // We may have more than one exception for a thread, but we need to
- // only remember the one that we will say is the reason we stopped. We
- // may have been single stepping and also gotten a signal exception, so
- // just remember the most pertinent one.
- if (m_stop_exception.IsBreakpoint())
- m_stop_exception = exc;
- }
- else
- {
- m_stop_exception = exc;
- }
-
- return handled;
-#else
- // Pretend we handled it.
- return true;
-#endif
-}
-
-bool NativeThreadDarwin::ShouldStop(bool &step_more) const {
-// TODO: implement this
-#if 0
- // See if this thread is at a breakpoint?
- DNBBreakpoint *bp = CurrentBreakpoint();
-
- if (bp)
- {
- // This thread is sitting at a breakpoint, ask the breakpoint if we
- // should be stopping here.
- return true;
- }
- else
- {
- if (m_arch_up->StepNotComplete())
- {
- step_more = true;
- return false;
- }
- // The thread state is used to let us know what the thread was trying
- // to do. MachThread::ThreadWillResume() will set the thread state to
- // various values depending if the thread was the current thread and if
- // it was to be single stepped, or resumed.
- if (GetState() == eStateRunning)
- {
- // If our state is running, then we should continue as we are in
- // the process of stepping over a breakpoint.
- return false;
- }
- else
- {
- // Stop if we have any kind of valid exception for this thread.
- if (GetStopException().IsValid())
- return true;
- }
- }
- return false;
-#else
- return false;
-#endif
-}
-
-void NativeThreadDarwin::ThreadDidStop() {
-// TODO implement this.
-#if 0
- // This thread has existed prior to resuming under debug nub control, and
- // has just been stopped. Do any cleanup that needs to be done after
- // running.
-
- // The thread state and breakpoint will still have the same values as they
- // had prior to resuming the thread, so it makes it easy to check if we
- // were trying to step a thread, or we tried to resume while being at a
- // breakpoint.
-
- // When this method gets called, the process state is still in the state it
- // was in while running so we can act accordingly.
- m_arch_up->ThreadDidStop();
-
-
- // We may have suspended this thread so the primary thread could step
- // without worrying about race conditions, so lets restore our suspend
- // count.
- RestoreSuspendCountAfterStop();
-
- // Update the basic information for a thread
- MachThread::GetBasicInfo(m_mach_port_number, &m_basic_info);
-
- if (m_basic_info.suspend_count > 0)
- SetState(eStateSuspended);
- else
- SetState(eStateStopped);
-#endif
-}
-
-bool NativeThreadDarwin::MachPortNumberIsValid(::thread_t thread) {
- return thread != (::thread_t)(0);
-}
-
-const struct thread_basic_info *NativeThreadDarwin::GetBasicInfo() const {
- if (GetBasicInfo(m_mach_thread_port, &m_basic_info))
- return &m_basic_info;
- return NULL;
-}
-
-bool NativeThreadDarwin::GetBasicInfo(::thread_t thread,
- struct thread_basic_info *basicInfoPtr) {
- if (MachPortNumberIsValid(thread)) {
- unsigned int info_count = THREAD_BASIC_INFO_COUNT;
- kern_return_t err = ::thread_info(thread, THREAD_BASIC_INFO,
- (thread_info_t)basicInfoPtr, &info_count);
- if (err == KERN_SUCCESS)
- return true;
- }
- ::memset(basicInfoPtr, 0, sizeof(struct thread_basic_info));
- return false;
-}
-
-bool NativeThreadDarwin::IsUserReady() const {
- if (m_basic_info.run_state == 0)
- GetBasicInfo();
-
- switch (m_basic_info.run_state) {
- default:
- case TH_STATE_UNINTERRUPTIBLE:
- break;
-
- case TH_STATE_RUNNING:
- case TH_STATE_STOPPED:
- case TH_STATE_WAITING:
- case TH_STATE_HALTED:
- return true;
- }
- return false;
-}
-
-NativeProcessDarwinSP NativeThreadDarwin::GetNativeProcessDarwinSP() {
- return std::static_pointer_cast<NativeProcessDarwin>(GetProcess());
-}
diff --git a/lldb/source/Plugins/Process/Darwin/NativeThreadDarwin.h b/lldb/source/Plugins/Process/Darwin/NativeThreadDarwin.h
deleted file mode 100644
index 616a9a7b9bf0..000000000000
--- a/lldb/source/Plugins/Process/Darwin/NativeThreadDarwin.h
+++ /dev/null
@@ -1,165 +0,0 @@
-//===-- NativeThreadDarwin.h ---------------------------------- -*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef NativeThreadDarwin_H
-#define NativeThreadDarwin_H
-
-// C includes
-#include <mach/mach_types.h>
-#include <sched.h>
-#include <sys/proc_info.h>
-
-// C++ includes
-#include <map>
-#include <memory>
-#include <string>
-
-// LLDB includes
-#include "lldb/Host/common/NativeThreadProtocol.h"
-#include "lldb/lldb-private-forward.h"
-
-#include "MachException.h"
-
-namespace lldb_private {
-namespace process_darwin {
-
-class NativeProcessDarwin;
-using NativeProcessDarwinSP = std::shared_ptr<NativeProcessDarwin>;
-
-class NativeThreadListDarwin;
-
-class NativeThreadDarwin : public NativeThreadProtocol {
- friend class NativeProcessDarwin;
- friend class NativeThreadListDarwin;
-
-public:
- static uint64_t
- GetGloballyUniqueThreadIDForMachPortID(::thread_t mach_port_id);
-
- NativeThreadDarwin(NativeProcessDarwin *process, bool is_64_bit,
- lldb::tid_t unique_thread_id = 0,
- ::thread_t mach_thread_port = 0);
-
- // NativeThreadProtocol Interface
- std::string GetName() override;
-
- lldb::StateType GetState() override;
-
- bool GetStopReason(ThreadStopInfo &stop_info,
- std::string &description) override;
-
- NativeRegisterContextSP GetRegisterContext() override;
-
- Status SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags,
- bool hardware) override;
-
- Status RemoveWatchpoint(lldb::addr_t addr) override;
-
- // New methods that are fine for others to call.
- void Dump(Stream &stream) const;
-
-private:
- // Interface for friend classes
-
- /// Resumes the thread. If \p signo is anything but
- /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
- Status Resume(uint32_t signo);
-
- /// Single steps the thread. If \p signo is anything but
- /// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
- Status SingleStep(uint32_t signo);
-
- bool NotifyException(MachException::Data &exc);
-
- bool ShouldStop(bool &step_more) const;
-
- void ThreadDidStop();
-
- void SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr);
-
- /// Return true if the thread is stopped.
- /// If stopped by a signal, indicate the signo in the signo
- /// argument. Otherwise, return LLDB_INVALID_SIGNAL_NUMBER.
- bool IsStopped(int *signo);
-
- const struct thread_basic_info *GetBasicInfo() const;
-
- static bool GetBasicInfo(::thread_t thread,
- struct thread_basic_info *basicInfoPtr);
-
- bool IsUserReady() const;
-
- void SetStoppedByExec();
-
- void SetStoppedByBreakpoint();
-
- void SetStoppedByWatchpoint(uint32_t wp_index);
-
- bool IsStoppedAtBreakpoint();
-
- bool IsStoppedAtWatchpoint();
-
- void SetStoppedByTrace();
-
- void SetStoppedWithNoReason();
-
- void SetExited();
-
- Status RequestStop();
-
- /// Return the mach thread port number for this thread.
- ///
- /// \return
- /// The mach port number for this thread. Returns NULL_THREAD
- /// when the thread is invalid.
- thread_t GetMachPortNumber() const { return m_mach_thread_port; }
-
- static bool MachPortNumberIsValid(::thread_t thread);
-
- // Private interface
- bool GetIdentifierInfo();
-
- void MaybeLogStateChange(lldb::StateType new_state);
-
- NativeProcessDarwinSP GetNativeProcessDarwinSP();
-
- void SetStopped();
-
- inline void MaybePrepareSingleStepWorkaround();
-
- inline void MaybeCleanupSingleStepWorkaround();
-
- // Member Variables
-
- // The mach thread port for the thread.
- ::thread_t m_mach_thread_port;
-
- // The most recently-retrieved thread basic info.
- mutable ::thread_basic_info m_basic_info;
-
- struct proc_threadinfo m_proc_threadinfo;
-
- thread_identifier_info_data_t m_ident_info;
-
-#if 0
- lldb::StateType m_state;
- ThreadStopInfo m_stop_info;
- NativeRegisterContextSP m_reg_context_sp;
- std::string m_stop_description;
- using WatchpointIndexMap = std::map<lldb::addr_t, uint32_t>;
- WatchpointIndexMap m_watchpoint_index_map;
- // cpu_set_t m_original_cpu_set; // For single-step workaround.
-#endif
-};
-
-typedef std::shared_ptr<NativeThreadDarwin> NativeThreadDarwinSP;
-
-} // namespace process_darwin
-} // namespace lldb_private
-
-#endif // #ifndef NativeThreadDarwin_H
diff --git a/lldb/source/Plugins/Process/Darwin/NativeThreadListDarwin.cpp b/lldb/source/Plugins/Process/Darwin/NativeThreadListDarwin.cpp
deleted file mode 100644
index 1faa5b219cbc..000000000000
--- a/lldb/source/Plugins/Process/Darwin/NativeThreadListDarwin.cpp
+++ /dev/null
@@ -1,702 +0,0 @@
-//===-- NativeThreadListDarwin.cpp ------------------------------------*- C++
-//-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Created by Greg Clayton on 6/19/07.
-//
-//===----------------------------------------------------------------------===//
-
-#include "NativeThreadListDarwin.h"
-
-// C includes
-#include <inttypes.h>
-#include <mach/vm_map.h>
-#include <sys/sysctl.h>
-
-// LLDB includes
-#include "lldb/Utility/Log.h"
-#include "lldb/Utility/Status.h"
-#include "lldb/Utility/Stream.h"
-#include "lldb/lldb-enumerations.h"
-
-#include "NativeProcessDarwin.h"
-#include "NativeThreadDarwin.h"
-
-using namespace lldb;
-using namespace lldb_private;
-using namespace lldb_private::process_darwin;
-
-NativeThreadListDarwin::NativeThreadListDarwin()
- : m_threads(), m_threads_mutex(), m_is_64_bit(false) {}
-
-NativeThreadListDarwin::~NativeThreadListDarwin() {}
-
-// These methods will be accessed directly from NativeThreadDarwin
-#if 0
-nub_state_t
-NativeThreadListDarwin::GetState(nub_thread_t tid)
-{
- MachThreadSP thread_sp (GetThreadByID (tid));
- if (thread_sp)
- return thread_sp->GetState();
- return eStateInvalid;
-}
-
-const char *
-NativeThreadListDarwin::GetName (nub_thread_t tid)
-{
- MachThreadSP thread_sp (GetThreadByID (tid));
- if (thread_sp)
- return thread_sp->GetName();
- return NULL;
-}
-#endif
-
-// TODO: figure out if we need to add this to NativeThreadDarwin yet.
-#if 0
-ThreadInfo::QoS
-NativeThreadListDarwin::GetRequestedQoS (nub_thread_t tid, nub_addr_t tsd, uint64_t dti_qos_class_index)
-{
- MachThreadSP thread_sp (GetThreadByID (tid));
- if (thread_sp)
- return thread_sp->GetRequestedQoS(tsd, dti_qos_class_index);
- return ThreadInfo::QoS();
-}
-
-nub_addr_t
-NativeThreadListDarwin::GetPThreadT (nub_thread_t tid)
-{
- MachThreadSP thread_sp (GetThreadByID (tid));
- if (thread_sp)
- return thread_sp->GetPThreadT();
- return INVALID_NUB_ADDRESS;
-}
-
-nub_addr_t
-NativeThreadListDarwin::GetDispatchQueueT (nub_thread_t tid)
-{
- MachThreadSP thread_sp (GetThreadByID (tid));
- if (thread_sp)
- return thread_sp->GetDispatchQueueT();
- return INVALID_NUB_ADDRESS;
-}
-
-nub_addr_t
-NativeThreadListDarwin::GetTSDAddressForThread (nub_thread_t tid, uint64_t plo_pthread_tsd_base_address_offset, uint64_t plo_pthread_tsd_base_offset, uint64_t plo_pthread_tsd_entry_size)
-{
- MachThreadSP thread_sp (GetThreadByID (tid));
- if (thread_sp)
- return thread_sp->GetTSDAddressForThread(plo_pthread_tsd_base_address_offset, plo_pthread_tsd_base_offset, plo_pthread_tsd_entry_size);
- return INVALID_NUB_ADDRESS;
-}
-#endif
-
-// TODO implement these
-#if 0
-nub_thread_t
-NativeThreadListDarwin::SetCurrentThread(nub_thread_t tid)
-{
- MachThreadSP thread_sp (GetThreadByID (tid));
- if (thread_sp)
- {
- m_current_thread = thread_sp;
- return tid;
- }
- return INVALID_NUB_THREAD;
-}
-
-
-bool
-NativeThreadListDarwin::GetThreadStoppedReason(nub_thread_t tid, struct DNBThreadStopInfo *stop_info) const
-{
- MachThreadSP thread_sp (GetThreadByID (tid));
- if (thread_sp)
- return thread_sp->GetStopException().GetStopInfo(stop_info);
- return false;
-}
-
-bool
-NativeThreadListDarwin::GetIdentifierInfo (nub_thread_t tid, thread_identifier_info_data_t *ident_info)
-{
- thread_t mach_port_number = GetMachPortNumberByThreadID (tid);
-
- mach_msg_type_number_t count = THREAD_IDENTIFIER_INFO_COUNT;
- return ::thread_info (mach_port_number, THREAD_IDENTIFIER_INFO, (thread_info_t)ident_info, &count) == KERN_SUCCESS;
-}
-
-void
-NativeThreadListDarwin::DumpThreadStoppedReason (nub_thread_t tid) const
-{
- MachThreadSP thread_sp (GetThreadByID (tid));
- if (thread_sp)
- thread_sp->GetStopException().DumpStopReason();
-}
-
-const char *
-NativeThreadListDarwin::GetThreadInfo (nub_thread_t tid) const
-{
- MachThreadSP thread_sp (GetThreadByID (tid));
- if (thread_sp)
- return thread_sp->GetBasicInfoAsString();
- return NULL;
-}
-
-#endif
-
-NativeThreadDarwinSP
-NativeThreadListDarwin::GetThreadByID(lldb::tid_t tid) const {
- std::lock_guard<std::recursive_mutex> locker(m_threads_mutex);
- for (auto thread_sp : m_threads) {
- if (thread_sp && (thread_sp->GetID() == tid))
- return thread_sp;
- }
- return NativeThreadDarwinSP();
-}
-
-NativeThreadDarwinSP NativeThreadListDarwin::GetThreadByMachPortNumber(
- ::thread_t mach_port_number) const {
- std::lock_guard<std::recursive_mutex> locker(m_threads_mutex);
- for (auto thread_sp : m_threads) {
- if (thread_sp && (thread_sp->GetMachPortNumber() == mach_port_number))
- return thread_sp;
- }
- return NativeThreadDarwinSP();
-}
-
-lldb::tid_t NativeThreadListDarwin::GetThreadIDByMachPortNumber(
- ::thread_t mach_port_number) const {
- std::lock_guard<std::recursive_mutex> locker(m_threads_mutex);
- for (auto thread_sp : m_threads) {
- if (thread_sp && (thread_sp->GetMachPortNumber() == mach_port_number))
- return thread_sp->GetID();
- }
- return LLDB_INVALID_THREAD_ID;
-}
-
-// TODO implement
-#if 0
-thread_t
-NativeThreadListDarwin::GetMachPortNumberByThreadID (nub_thread_t globally_unique_id) const
-{
- PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
- MachThreadSP thread_sp;
- const size_t num_threads = m_threads.size();
- for (size_t idx = 0; idx < num_threads; ++idx)
- {
- if (m_threads[idx]->ThreadID() == globally_unique_id)
- {
- return m_threads[idx]->MachPortNumber();
- }
- }
- return 0;
-}
-
-bool
-NativeThreadListDarwin::GetRegisterValue (nub_thread_t tid, uint32_t set, uint32_t reg, DNBRegisterValue *reg_value ) const
-{
- MachThreadSP thread_sp (GetThreadByID (tid));
- if (thread_sp)
- return thread_sp->GetRegisterValue(set, reg, reg_value);
-
- return false;
-}
-
-bool
-NativeThreadListDarwin::SetRegisterValue (nub_thread_t tid, uint32_t set, uint32_t reg, const DNBRegisterValue *reg_value ) const
-{
- MachThreadSP thread_sp (GetThreadByID (tid));
- if (thread_sp)
- return thread_sp->SetRegisterValue(set, reg, reg_value);
-
- return false;
-}
-
-nub_size_t
-NativeThreadListDarwin::GetRegisterContext (nub_thread_t tid, void *buf, size_t buf_len)
-{
- MachThreadSP thread_sp (GetThreadByID (tid));
- if (thread_sp)
- return thread_sp->GetRegisterContext (buf, buf_len);
- return 0;
-}
-
-nub_size_t
-NativeThreadListDarwin::SetRegisterContext (nub_thread_t tid, const void *buf, size_t buf_len)
-{
- MachThreadSP thread_sp (GetThreadByID (tid));
- if (thread_sp)
- return thread_sp->SetRegisterContext (buf, buf_len);
- return 0;
-}
-
-uint32_t
-NativeThreadListDarwin::SaveRegisterState (nub_thread_t tid)
-{
- MachThreadSP thread_sp (GetThreadByID (tid));
- if (thread_sp)
- return thread_sp->SaveRegisterState ();
- return 0;
-}
-
-bool
-NativeThreadListDarwin::RestoreRegisterState (nub_thread_t tid, uint32_t save_id)
-{
- MachThreadSP thread_sp (GetThreadByID (tid));
- if (thread_sp)
- return thread_sp->RestoreRegisterState (save_id);
- return 0;
-}
-#endif
-
-size_t NativeThreadListDarwin::GetNumberOfThreads() const {
- std::lock_guard<std::recursive_mutex> locker(m_threads_mutex);
- return static_cast<size_t>(m_threads.size());
-}
-
-// TODO implement
-#if 0
-nub_thread_t
-NativeThreadListDarwin::ThreadIDAtIndex (nub_size_t idx) const
-{
- PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
- if (idx < m_threads.size())
- return m_threads[idx]->ThreadID();
- return INVALID_NUB_THREAD;
-}
-
-nub_thread_t
-NativeThreadListDarwin::CurrentThreadID ( )
-{
- MachThreadSP thread_sp;
- CurrentThread(thread_sp);
- if (thread_sp.get())
- return thread_sp->ThreadID();
- return INVALID_NUB_THREAD;
-}
-
-#endif
-
-bool NativeThreadListDarwin::NotifyException(MachException::Data &exc) {
- auto thread_sp = GetThreadByMachPortNumber(exc.thread_port);
- if (thread_sp) {
- thread_sp->NotifyException(exc);
- return true;
- }
- return false;
-}
-
-void NativeThreadListDarwin::Clear() {
- std::lock_guard<std::recursive_mutex> locker(m_threads_mutex);
- m_threads.clear();
-}
-
-uint32_t NativeThreadListDarwin::UpdateThreadList(NativeProcessDarwin &process,
- bool update,
- collection *new_threads) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
-
- std::lock_guard<std::recursive_mutex> locker(m_threads_mutex);
- LLDB_LOGF(log,
- "NativeThreadListDarwin::%s() (pid = %" PRIu64 ", update = "
- "%u) process stop count = %u",
- __FUNCTION__, process.GetID(), update, process.GetStopID());
-
- if (process.GetStopID() == 0) {
- // On our first stop, we'll record details like 32/64 bitness and select
- // the proper architecture implementation.
- //
- int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, (int)process.GetID()};
-
- struct kinfo_proc processInfo;
- size_t bufsize = sizeof(processInfo);
- if ((sysctl(mib, (unsigned)(sizeof(mib) / sizeof(int)), &processInfo,
- &bufsize, NULL, 0) == 0) &&
- (bufsize > 0)) {
- if (processInfo.kp_proc.p_flag & P_LP64)
- m_is_64_bit = true;
- }
-
-// TODO implement architecture selection and abstraction.
-#if 0
-#if defined(__i386__) || defined(__x86_64__)
- if (m_is_64_bit)
- DNBArchProtocol::SetArchitecture(CPU_TYPE_X86_64);
- else
- DNBArchProtocol::SetArchitecture(CPU_TYPE_I386);
-#elif defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
- if (m_is_64_bit)
- DNBArchProtocol::SetArchitecture(CPU_TYPE_ARM64);
- else
- DNBArchProtocol::SetArchitecture(CPU_TYPE_ARM);
-#endif
-#endif
- }
-
- if (m_threads.empty() || update) {
- thread_array_t thread_list = nullptr;
- mach_msg_type_number_t thread_list_count = 0;
- task_t task = process.GetTask();
-
- Status error;
- auto mach_err = ::task_threads(task, &thread_list, &thread_list_count);
- error.SetError(mach_err, eErrorTypeMachKernel);
- if (error.Fail()) {
- LLDB_LOGF(log,
- "::task_threads(task = 0x%4.4x, thread_list => %p, "
- "thread_list_count => %u) failed: %u (%s)",
- task, thread_list, thread_list_count, error.GetError(),
- error.AsCString());
- return 0;
- }
-
- if (thread_list_count > 0) {
- collection currThreads;
- size_t idx;
- // Iterator through the current thread list and see which threads we
- // already have in our list (keep them), which ones we don't (add them),
- // and which ones are not around anymore (remove them).
- for (idx = 0; idx < thread_list_count; ++idx) {
- // Get the Mach thread port.
- const ::thread_t mach_port_num = thread_list[idx];
-
- // Get the unique thread id for the mach port number.
- uint64_t unique_thread_id =
- NativeThreadDarwin::GetGloballyUniqueThreadIDForMachPortID(
- mach_port_num);
-
- // Retrieve the thread if it exists.
- auto thread_sp = GetThreadByID(unique_thread_id);
- if (thread_sp) {
- // We are already tracking it. Keep the existing native thread
- // instance.
- currThreads.push_back(thread_sp);
- } else {
- // We don't have a native thread instance for this thread. Create it
- // now.
- thread_sp.reset(new NativeThreadDarwin(
- &process, m_is_64_bit, unique_thread_id, mach_port_num));
-
- // Add the new thread regardless of its is user ready state. Make
- // sure the thread is ready to be displayed and shown to users before
- // we add this thread to our list...
- if (thread_sp->IsUserReady()) {
- if (new_threads)
- new_threads->push_back(thread_sp);
-
- currThreads.push_back(thread_sp);
- }
- }
- }
-
- m_threads.swap(currThreads);
- m_current_thread.reset();
-
- // Free the vm memory given to us by ::task_threads()
- vm_size_t thread_list_size =
- (vm_size_t)(thread_list_count * sizeof(::thread_t));
- ::vm_deallocate(::mach_task_self(), (vm_address_t)thread_list,
- thread_list_size);
- }
- }
- return static_cast<uint32_t>(m_threads.size());
-}
-
-// TODO implement
-#if 0
-
-void
-NativeThreadListDarwin::CurrentThread (MachThreadSP& thread_sp)
-{
- // locker will keep a mutex locked until it goes out of scope
- PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
- if (m_current_thread.get() == NULL)
- {
- // Figure out which thread is going to be our current thread. This is
- // currently done by finding the first thread in the list that has a
- // valid exception.
- const size_t num_threads = m_threads.size();
- for (uint32_t idx = 0; idx < num_threads; ++idx)
- {
- if (m_threads[idx]->GetStopException().IsValid())
- {
- m_current_thread = m_threads[idx];
- break;
- }
- }
- }
- thread_sp = m_current_thread;
-}
-
-#endif
-
-void NativeThreadListDarwin::Dump(Stream &stream) const {
- bool first = true;
-
- std::lock_guard<std::recursive_mutex> locker(m_threads_mutex);
- for (auto thread_sp : m_threads) {
- if (thread_sp) {
- // Handle newlines between thread entries.
- if (first)
- first = false;
- else
- stream.PutChar('\n');
- thread_sp->Dump(stream);
- }
- }
-}
-
-void NativeThreadListDarwin::ProcessWillResume(
- NativeProcessDarwin &process, const ResumeActionList &thread_actions) {
- std::lock_guard<std::recursive_mutex> locker(m_threads_mutex);
-
- // Update our thread list, because sometimes libdispatch or the kernel will
- // spawn threads while a task is suspended.
- NativeThreadListDarwin::collection new_threads;
-
-// TODO implement this.
-#if 0
- // First figure out if we were planning on running only one thread, and if
- // so, force that thread to resume.
- bool run_one_thread;
- thread_t solo_thread = THREAD_NULL;
- if ((thread_actions.GetSize() > 0) &&
- (thread_actions.NumActionsWithState(eStateStepping) +
- thread_actions.NumActionsWithState (eStateRunning) == 1))
- {
- run_one_thread = true;
- const DNBThreadResumeAction *action_ptr = thread_actions.GetFirst();
- size_t num_actions = thread_actions.GetSize();
- for (size_t i = 0; i < num_actions; i++, action_ptr++)
- {
- if (action_ptr->state == eStateStepping || action_ptr->state == eStateRunning)
- {
- solo_thread = action_ptr->tid;
- break;
- }
- }
- }
- else
- run_one_thread = false;
-#endif
-
- UpdateThreadList(process, true, &new_threads);
-
-#if 0
- DNBThreadResumeAction resume_new_threads = { -1U, eStateRunning, 0, INVALID_NUB_ADDRESS };
- // If we are planning to run only one thread, any new threads should be
- // suspended.
- if (run_one_thread)
- resume_new_threads.state = eStateSuspended;
-
- const size_t num_new_threads = new_threads.size();
- const size_t num_threads = m_threads.size();
- for (uint32_t idx = 0; idx < num_threads; ++idx)
- {
- MachThread *thread = m_threads[idx].get();
- bool handled = false;
- for (uint32_t new_idx = 0; new_idx < num_new_threads; ++new_idx)
- {
- if (thread == new_threads[new_idx].get())
- {
- thread->ThreadWillResume(&resume_new_threads);
- handled = true;
- break;
- }
- }
-
- if (!handled)
- {
- const DNBThreadResumeAction *thread_action = thread_actions.GetActionForThread (thread->ThreadID(), true);
- // There must always be a thread action for every thread.
- assert (thread_action);
- bool others_stopped = false;
- if (solo_thread == thread->ThreadID())
- others_stopped = true;
- thread->ThreadWillResume (thread_action, others_stopped);
- }
- }
-
- if (new_threads.size())
- {
- for (uint32_t idx = 0; idx < num_new_threads; ++idx)
- {
- DNBLogThreadedIf (LOG_THREAD, "NativeThreadListDarwin::ProcessWillResume (pid = %4.4x) stop-id=%u, resuming newly discovered thread: 0x%8.8" PRIx64 ", thread-is-user-ready=%i)",
- process->ProcessID(),
- process->StopCount(),
- new_threads[idx]->ThreadID(),
- new_threads[idx]->IsUserReady());
- }
- }
-#endif
-}
-
-uint32_t NativeThreadListDarwin::ProcessDidStop(NativeProcessDarwin &process) {
- std::lock_guard<std::recursive_mutex> locker(m_threads_mutex);
-
- // Update our thread list.
- UpdateThreadList(process, true);
-
- for (auto thread_sp : m_threads) {
- if (thread_sp)
- thread_sp->ThreadDidStop();
- }
- return (uint32_t)m_threads.size();
-}
-
-// Check each thread in our thread list to see if we should notify our client
-// of the current halt in execution.
-//
-// Breakpoints can have callback functions associated with them than can return
-// true to stop, or false to continue executing the inferior.
-//
-// RETURNS
-// true if we should stop and notify our clients
-// false if we should resume our child process and skip notification
-bool NativeThreadListDarwin::ShouldStop(bool &step_more) {
- std::lock_guard<std::recursive_mutex> locker(m_threads_mutex);
- for (auto thread_sp : m_threads) {
- if (thread_sp && thread_sp->ShouldStop(step_more))
- return true;
- }
- return false;
-}
-
-// Implement.
-#if 0
-
-void
-NativeThreadListDarwin::NotifyBreakpointChanged (const DNBBreakpoint *bp)
-{
- PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
- const size_t num_threads = m_threads.size();
- for (uint32_t idx = 0; idx < num_threads; ++idx)
- {
- m_threads[idx]->NotifyBreakpointChanged(bp);
- }
-}
-
-
-uint32_t
-NativeThreadListDarwin::EnableHardwareBreakpoint (const DNBBreakpoint* bp) const
-{
- if (bp != NULL)
- {
- const size_t num_threads = m_threads.size();
- for (uint32_t idx = 0; idx < num_threads; ++idx)
- m_threads[idx]->EnableHardwareBreakpoint(bp);
- }
- return INVALID_NUB_HW_INDEX;
-}
-
-bool
-NativeThreadListDarwin::DisableHardwareBreakpoint (const DNBBreakpoint* bp) const
-{
- if (bp != NULL)
- {
- const size_t num_threads = m_threads.size();
- for (uint32_t idx = 0; idx < num_threads; ++idx)
- m_threads[idx]->DisableHardwareBreakpoint(bp);
- }
- return false;
-}
-
-// DNBWatchpointSet() -> MachProcess::CreateWatchpoint() ->
-// MachProcess::EnableWatchpoint() ->
-// NativeThreadListDarwin::EnableHardwareWatchpoint().
-uint32_t
-NativeThreadListDarwin::EnableHardwareWatchpoint (const DNBBreakpoint* wp) const
-{
- uint32_t hw_index = INVALID_NUB_HW_INDEX;
- if (wp != NULL)
- {
- PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
- const size_t num_threads = m_threads.size();
- // On Mac OS X we have to prime the control registers for new threads.
- // We do this using the control register data for the first thread, for
- // lack of a better way of choosing.
- bool also_set_on_task = true;
- for (uint32_t idx = 0; idx < num_threads; ++idx)
- {
- if ((hw_index = m_threads[idx]->EnableHardwareWatchpoint(wp, also_set_on_task)) == INVALID_NUB_HW_INDEX)
- {
- // We know that idx failed for some reason. Let's rollback the
- // transaction for [0, idx).
- for (uint32_t i = 0; i < idx; ++i)
- m_threads[i]->RollbackTransForHWP();
- return INVALID_NUB_HW_INDEX;
- }
- also_set_on_task = false;
- }
- // Notify each thread to commit the pending transaction.
- for (uint32_t idx = 0; idx < num_threads; ++idx)
- m_threads[idx]->FinishTransForHWP();
-
- }
- return hw_index;
-}
-
-bool
-NativeThreadListDarwin::DisableHardwareWatchpoint (const DNBBreakpoint* wp) const
-{
- if (wp != NULL)
- {
- PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
- const size_t num_threads = m_threads.size();
-
- // On Mac OS X we have to prime the control registers for new threads.
- // We do this using the control register data for the first thread, for
- // lack of a better way of choosing.
- bool also_set_on_task = true;
- for (uint32_t idx = 0; idx < num_threads; ++idx)
- {
- if (!m_threads[idx]->DisableHardwareWatchpoint(wp, also_set_on_task))
- {
- // We know that idx failed for some reason. Let's rollback the
- // transaction for [0, idx).
- for (uint32_t i = 0; i < idx; ++i)
- m_threads[i]->RollbackTransForHWP();
- return false;
- }
- also_set_on_task = false;
- }
- // Notify each thread to commit the pending transaction.
- for (uint32_t idx = 0; idx < num_threads; ++idx)
- m_threads[idx]->FinishTransForHWP();
-
- return true;
- }
- return false;
-}
-
-uint32_t
-NativeThreadListDarwin::NumSupportedHardwareWatchpoints () const
-{
- PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
- const size_t num_threads = m_threads.size();
- // Use an arbitrary thread to retrieve the number of supported hardware
- // watchpoints.
- if (num_threads)
- return m_threads[0]->NumSupportedHardwareWatchpoints();
- return 0;
-}
-
-uint32_t
-NativeThreadListDarwin::GetThreadIndexForThreadStoppedWithSignal (const int signo) const
-{
- PTHREAD_MUTEX_LOCKER (locker, m_threads_mutex);
- uint32_t should_stop = false;
- const size_t num_threads = m_threads.size();
- for (uint32_t idx = 0; !should_stop && idx < num_threads; ++idx)
- {
- if (m_threads[idx]->GetStopException().SoftSignal () == signo)
- return idx;
- }
- return UINT32_MAX;
-}
-
-#endif
diff --git a/lldb/source/Plugins/Process/Darwin/NativeThreadListDarwin.h b/lldb/source/Plugins/Process/Darwin/NativeThreadListDarwin.h
deleted file mode 100644
index 9ab0a7c8c802..000000000000
--- a/lldb/source/Plugins/Process/Darwin/NativeThreadListDarwin.h
+++ /dev/null
@@ -1,138 +0,0 @@
-//===-- NativeThreadListDarwin.h --------------------------------------*- C++
-//-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// Created by Greg Clayton on 6/19/07.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef __NativeThreadListDarwin_h__
-#define __NativeThreadListDarwin_h__
-
-#include <memory>
-#include <mutex>
-#include <vector>
-
-#include "lldb/lldb-private-forward.h"
-#include "lldb/lldb-types.h"
-
-#include "MachException.h"
-
-// #include "ThreadInfo.h"
-
-namespace lldb_private {
-namespace process_darwin {
-
-class NativeBreakpointDarwin;
-class NativeProcessDarwin;
-
-class NativeThreadDarwin;
-using NativeThreadDarwinSP = std::shared_ptr<NativeThreadDarwin>;
-
-class NativeThreadListDarwin {
-public:
- NativeThreadListDarwin();
- ~NativeThreadListDarwin();
-
- void Clear();
-
- void Dump(Stream &stream) const;
-
-// These methods will be accessed directly from NativeThreadDarwin
-#if 0
- bool GetRegisterValue (nub_thread_t tid, uint32_t set, uint32_t reg, DNBRegisterValue *reg_value) const;
- bool SetRegisterValue (nub_thread_t tid, uint32_t set, uint32_t reg, const DNBRegisterValue *reg_value) const;
- nub_size_t GetRegisterContext (nub_thread_t tid, void *buf, size_t buf_len);
- nub_size_t SetRegisterContext (nub_thread_t tid, const void *buf, size_t buf_len);
- uint32_t SaveRegisterState (nub_thread_t tid);
- bool RestoreRegisterState (nub_thread_t tid, uint32_t save_id);
-#endif
-
- const char *GetThreadInfo(lldb::tid_t tid) const;
-
- void ProcessWillResume(NativeProcessDarwin &process,
- const ResumeActionList &thread_actions);
-
- uint32_t ProcessDidStop(NativeProcessDarwin &process);
-
- bool NotifyException(MachException::Data &exc);
-
- bool ShouldStop(bool &step_more);
-
-// These methods will be accessed directly from NativeThreadDarwin
-#if 0
- const char * GetName (nub_thread_t tid);
- nub_state_t GetState (nub_thread_t tid);
- nub_thread_t SetCurrentThread (nub_thread_t tid);
-#endif
-
-// TODO: figure out if we need to add this to NativeThreadDarwin yet.
-#if 0
- ThreadInfo::QoS GetRequestedQoS (nub_thread_t tid, nub_addr_t tsd, uint64_t dti_qos_class_index);
- nub_addr_t GetPThreadT (nub_thread_t tid);
- nub_addr_t GetDispatchQueueT (nub_thread_t tid);
- nub_addr_t GetTSDAddressForThread (nub_thread_t tid, uint64_t plo_pthread_tsd_base_address_offset, uint64_t plo_pthread_tsd_base_offset, uint64_t plo_pthread_tsd_entry_size);
-#endif
-
-// These methods will be accessed directly from NativeThreadDarwin
-#if 0
- bool GetThreadStoppedReason (nub_thread_t tid, struct DNBThreadStopInfo *stop_info) const;
- void DumpThreadStoppedReason (nub_thread_t tid) const;
- bool GetIdentifierInfo (nub_thread_t tid, thread_identifier_info_data_t *ident_info);
-#endif
-
- size_t GetNumberOfThreads() const;
-
- lldb::tid_t ThreadIDAtIndex(size_t idx) const;
-
- lldb::tid_t GetCurrentThreadID();
-
- NativeThreadDarwinSP GetCurrentThread();
-
- void NotifyBreakpointChanged(const NativeBreakpointDarwin *bp);
-
- uint32_t EnableHardwareBreakpoint(const NativeBreakpointDarwin *bp) const;
-
- bool DisableHardwareBreakpoint(const NativeBreakpointDarwin *bp) const;
-
- uint32_t EnableHardwareWatchpoint(const NativeBreakpointDarwin *wp) const;
-
- bool DisableHardwareWatchpoint(const NativeBreakpointDarwin *wp) const;
-
- uint32_t GetNumberOfSupportedHardwareWatchpoints() const;
-
- size_t GetThreadIndexForThreadStoppedWithSignal(const int signo) const;
-
- NativeThreadDarwinSP GetThreadByID(lldb::tid_t tid) const;
-
- NativeThreadDarwinSP
- GetThreadByMachPortNumber(::thread_t mach_port_number) const;
-
- lldb::tid_t GetThreadIDByMachPortNumber(::thread_t mach_port_number) const;
-
- thread_t GetMachPortNumberByThreadID(lldb::tid_t globally_unique_id) const;
-
-protected:
- typedef std::vector<NativeThreadDarwinSP> collection;
- typedef collection::iterator iterator;
- typedef collection::const_iterator const_iterator;
-
- // Consider having this return an lldb_private::Status.
- uint32_t UpdateThreadList(NativeProcessDarwin &process, bool update,
- collection *num_threads = nullptr);
-
- collection m_threads;
- mutable std::recursive_mutex m_threads_mutex;
- NativeThreadDarwinSP m_current_thread;
- bool m_is_64_bit;
-};
-
-} // namespace process_darwin
-} // namespace lldb_private
-
-#endif // #ifndef __NativeThreadListDarwin_h__
diff --git a/lldb/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp b/lldb/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp
index 0a49f96f54a1..48dbddb86cca 100644
--- a/lldb/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp
@@ -1,4 +1,4 @@
-//===-- FreeBSDThread.cpp ---------------------------------------*- C++ -*-===//
+//===-- FreeBSDThread.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -14,9 +14,6 @@
#include <sys/types.h>
#include <sys/user.h>
-#include "lldb/Target/UnixSignals.h"
-#include "lldb/Utility/State.h"
-
#include "FreeBSDThread.h"
#include "POSIXStopInfo.h"
#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
@@ -26,7 +23,6 @@
#include "Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h"
#include "Plugins/Process/Utility/RegisterInfoPOSIX_arm.h"
#include "Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h"
-#include "Plugins/Process/Utility/UnwindLLDB.h"
#include "ProcessFreeBSD.h"
#include "ProcessMonitor.h"
#include "RegisterContextPOSIXProcessMonitor_arm.h"
@@ -44,6 +40,8 @@
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
+#include "lldb/Target/UnixSignals.h"
+#include "lldb/Target/Unwind.h"
#include "lldb/Utility/State.h"
#include "llvm/ADT/SmallString.h"
@@ -166,7 +164,6 @@ lldb::RegisterContextSP FreeBSDThread::GetRegisterContext() {
assert(target_arch.GetTriple().getOS() == llvm::Triple::FreeBSD);
switch (target_arch.GetMachine()) {
case llvm::Triple::aarch64:
- reg_interface = new RegisterInfoPOSIX_arm64(target_arch);
break;
case llvm::Triple::arm:
reg_interface = new RegisterInfoPOSIX_arm(target_arch);
@@ -195,7 +192,8 @@ lldb::RegisterContextSP FreeBSDThread::GetRegisterContext() {
switch (target_arch.GetMachine()) {
case llvm::Triple::aarch64: {
RegisterContextPOSIXProcessMonitor_arm64 *reg_ctx =
- new RegisterContextPOSIXProcessMonitor_arm64(*this, 0, reg_interface);
+ new RegisterContextPOSIXProcessMonitor_arm64(
+ *this, std::make_unique<RegisterInfoPOSIX_arm64>(target_arch));
m_posix_thread = reg_ctx;
m_reg_context_sp.reset(reg_ctx);
break;
@@ -254,8 +252,7 @@ FreeBSDThread::CreateRegisterContextForFrame(lldb_private::StackFrame *frame) {
if (concrete_frame_idx == 0)
reg_ctx_sp = GetRegisterContext();
else {
- assert(GetUnwinder());
- reg_ctx_sp = GetUnwinder()->CreateRegisterContextForFrame(frame);
+ reg_ctx_sp = GetUnwinder().CreateRegisterContextForFrame(frame);
}
return reg_ctx_sp;
@@ -275,13 +272,6 @@ bool FreeBSDThread::CalculateStopInfo() {
return true;
}
-Unwind *FreeBSDThread::GetUnwinder() {
- if (!m_unwinder_up)
- m_unwinder_up.reset(new UnwindLLDB(*this));
-
- return m_unwinder_up.get();
-}
-
void FreeBSDThread::DidStop() {
// Don't set the thread state to stopped unless we really stopped.
}
diff --git a/lldb/source/Plugins/Process/FreeBSD/FreeBSDThread.h b/lldb/source/Plugins/Process/FreeBSD/FreeBSDThread.h
index 6d3c253a519e..774ffb511bc6 100644
--- a/lldb/source/Plugins/Process/FreeBSD/FreeBSDThread.h
+++ b/lldb/source/Plugins/Process/FreeBSD/FreeBSDThread.h
@@ -102,8 +102,6 @@ protected:
void ExitNotify(const ProcessMessage &message);
void ExecNotify(const ProcessMessage &message);
- lldb_private::Unwind *GetUnwinder() override;
-
// FreeBSDThread internal API.
// POSIXThread override
diff --git a/lldb/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp b/lldb/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp
index 71f012944a9a..4e6f3afda0ab 100644
--- a/lldb/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp
@@ -1,4 +1,4 @@
-//===-- POSIXStopInfo.cpp ---------------------------------------*- C++ -*-===//
+//===-- POSIXStopInfo.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
index 32e3320150f8..a44080640f6c 100644
--- a/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
@@ -1,5 +1,4 @@
-//===-- ProcessFreeBSD.cpp ----------------------------------------*- C++
-//-*-===//
+//===-- ProcessFreeBSD.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -57,6 +56,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(ProcessFreeBSD)
+
namespace {
UnixSignalsSP &GetFreeBSDSignals() {
static UnixSignalsSP s_freebsd_signals_sp(new FreeBSDSignals());
@@ -379,7 +380,8 @@ Status ProcessFreeBSD::DoLaunch(Module *module,
FileSpec stdout_file_spec{};
FileSpec stderr_file_spec{};
- const FileSpec dbg_pts_file_spec{launch_info.GetPTY().GetSlaveName(NULL, 0)};
+ const FileSpec dbg_pts_file_spec{
+ launch_info.GetPTY().GetSecondaryName(NULL, 0)};
file_action = launch_info.GetFileActionForFD(STDIN_FILENO);
stdin_file_spec =
diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp b/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
index ff3fb0a75e2d..6a9209d1214c 100644
--- a/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
@@ -1,4 +1,4 @@
-//===-- ProcessMonitor.cpp ------------------------------------ -*- C++ -*-===//
+//===-- ProcessMonitor.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -855,7 +855,7 @@ bool ProcessMonitor::Launch(LaunchArgs *args) {
// terminal has already dupped the tty descriptors to stdin/out/err. This
// closes original fd from which they were copied (and avoids leaking
// descriptors to the debugged process.
- terminal.CloseSlaveFileDescriptor();
+ terminal.CloseSecondaryFileDescriptor();
// Do not inherit setgid powers.
if (setgid(getgid()) != 0)
@@ -939,7 +939,7 @@ bool ProcessMonitor::Launch(LaunchArgs *args) {
#endif
// Release the master terminal descriptor and pass it off to the
// ProcessMonitor instance. Similarly stash the inferior pid.
- monitor->m_terminal_fd = terminal.ReleaseMasterFileDescriptor();
+ monitor->m_terminal_fd = terminal.ReleasePrimaryFileDescriptor();
monitor->m_pid = pid;
// Set the terminal fd to be in non blocking mode (it simplifies the
diff --git a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp
index f0c4526357cc..4216f68faf5c 100644
--- a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextPOSIXProcessMonitor_arm.cpp -----------*- C++ -*-===//
+//===-- RegisterContextPOSIXProcessMonitor_arm.cpp ------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp
index 147f4b56a804..d3eafae1e6de 100644
--- a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextPOSIXProcessMonitor_arm64.cpp -----------*- C++ -*-===//
+//===-- RegisterContextPOSIXProcessMonitor_arm64.cpp ----------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -22,9 +22,9 @@ using namespace lldb_private;
RegisterContextPOSIXProcessMonitor_arm64::
RegisterContextPOSIXProcessMonitor_arm64(
- lldb_private::Thread &thread, uint32_t concrete_frame_idx,
- lldb_private::RegisterInfoInterface *register_info)
- : RegisterContextPOSIX_arm64(thread, concrete_frame_idx, register_info) {}
+ lldb_private::Thread &thread,
+ std::unique_ptr<RegisterInfoPOSIX_arm64> register_info)
+ : RegisterContextPOSIX_arm64(thread, std::move(register_info)) {}
ProcessMonitor &RegisterContextPOSIXProcessMonitor_arm64::GetMonitor() {
lldb::ProcessSP base = CalculateProcess();
diff --git a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h
index d54d34e89cad..f100d905e28f 100644
--- a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h
+++ b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h
@@ -17,8 +17,8 @@ class RegisterContextPOSIXProcessMonitor_arm64
public POSIXBreakpointProtocol {
public:
RegisterContextPOSIXProcessMonitor_arm64(
- lldb_private::Thread &thread, uint32_t concrete_frame_idx,
- lldb_private::RegisterInfoInterface *register_info);
+ lldb_private::Thread &thread,
+ std::unique_ptr<RegisterInfoPOSIX_arm64> register_info);
protected:
bool ReadGPR();
diff --git a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp
index db9b5a6a038c..23c76f234c8e 100644
--- a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextPOSIXProcessMonitor_mips64.cpp -----------*- C++ -*-===//
+//===-- RegisterContextPOSIXProcessMonitor_mips64.cpp ---------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp
index 77694733fa39..f8342775a81b 100644
--- a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextPOSIXProcessMonitor_powerpc.cpp ----------*- C++ -*-===//
+//===-- RegisterContextPOSIXProcessMonitor_powerpc.cpp --------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp
index 3046d97f153c..b1739e1e3bd8 100644
--- a/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextPOSIXProcessMonitor_x86.cpp --------------*- C++ -*-===//
+//===-- RegisterContextPOSIXProcessMonitor_x86.cpp ------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
index 4313d27e11e9..5109022d80dd 100644
--- a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
+++ b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
@@ -1,4 +1,4 @@
-//===-- NativeProcessNetBSD.cpp ------------------------------- -*- C++ -*-===//
+//===-- NativeProcessNetBSD.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -95,7 +95,7 @@ NativeProcessNetBSD::Factory::Launch(ProcessLaunchInfo &launch_info,
Info.GetArchitecture().GetArchitectureName());
std::unique_ptr<NativeProcessNetBSD> process_up(new NativeProcessNetBSD(
- pid, launch_info.GetPTY().ReleaseMasterFileDescriptor(), native_delegate,
+ pid, launch_info.GetPTY().ReleasePrimaryFileDescriptor(), native_delegate,
Info.GetArchitecture(), mainloop));
// Enable event reporting
diff --git a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
index a8afa0b20305..03b505c19890 100644
--- a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
+++ b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
@@ -1,4 +1,4 @@
-//===-- NativeRegisterContextNetBSD.cpp -------------------------*- C++ -*-===//
+//===-- NativeRegisterContextNetBSD.cpp -----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
index 05a35401da46..ca4706a65657 100644
--- a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
+++ b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
@@ -1,4 +1,4 @@
-//===-- NativeRegisterContextNetBSD_x86_64.cpp ---------------*- C++ -*-===//
+//===-- NativeRegisterContextNetBSD_x86_64.cpp ----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#if defined(__x86_64__)
+#if defined(__i386__) || defined(__x86_64__)
#include "NativeRegisterContextNetBSD_x86_64.h"
@@ -16,6 +16,7 @@
#include "lldb/Utility/RegisterValue.h"
#include "lldb/Utility/Status.h"
+#include "Plugins/Process/Utility/RegisterContextNetBSD_i386.h"
#include "Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h"
// clang-format off
@@ -135,9 +136,84 @@ static_assert((sizeof(g_dbr_regnums_x86_64) / sizeof(g_dbr_regnums_x86_64[0])) -
k_num_dbr_registers_x86_64,
"g_dbr_regnums_x86_64 has wrong number of register infos");
+// x86 32-bit general purpose registers.
+const uint32_t g_gpr_regnums_i386[] = {
+ lldb_eax_i386, lldb_ebx_i386, lldb_ecx_i386, lldb_edx_i386,
+ lldb_edi_i386, lldb_esi_i386, lldb_ebp_i386, lldb_esp_i386,
+ lldb_eip_i386, lldb_eflags_i386, lldb_cs_i386, lldb_fs_i386,
+ lldb_gs_i386, lldb_ss_i386, lldb_ds_i386, lldb_es_i386,
+ lldb_ax_i386, lldb_bx_i386, lldb_cx_i386, lldb_dx_i386,
+ lldb_di_i386, lldb_si_i386, lldb_bp_i386, lldb_sp_i386,
+ lldb_ah_i386, lldb_bh_i386, lldb_ch_i386, lldb_dh_i386,
+ lldb_al_i386, lldb_bl_i386, lldb_cl_i386, lldb_dl_i386,
+ LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+static_assert((sizeof(g_gpr_regnums_i386) / sizeof(g_gpr_regnums_i386[0])) -
+ 1 ==
+ k_num_gpr_registers_i386,
+ "g_gpr_regnums_i386 has wrong number of register infos");
+
+// x86 32-bit floating point registers.
+const uint32_t g_fpu_regnums_i386[] = {
+ lldb_fctrl_i386, lldb_fstat_i386, lldb_ftag_i386, lldb_fop_i386,
+ lldb_fiseg_i386, lldb_fioff_i386, lldb_foseg_i386, lldb_fooff_i386,
+ lldb_mxcsr_i386, lldb_mxcsrmask_i386, lldb_st0_i386, lldb_st1_i386,
+ lldb_st2_i386, lldb_st3_i386, lldb_st4_i386, lldb_st5_i386,
+ lldb_st6_i386, lldb_st7_i386, lldb_mm0_i386, lldb_mm1_i386,
+ lldb_mm2_i386, lldb_mm3_i386, lldb_mm4_i386, lldb_mm5_i386,
+ lldb_mm6_i386, lldb_mm7_i386, lldb_xmm0_i386, lldb_xmm1_i386,
+ lldb_xmm2_i386, lldb_xmm3_i386, lldb_xmm4_i386, lldb_xmm5_i386,
+ lldb_xmm6_i386, lldb_xmm7_i386,
+ LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+static_assert((sizeof(g_fpu_regnums_i386) / sizeof(g_fpu_regnums_i386[0])) -
+ 1 ==
+ k_num_fpr_registers_i386,
+ "g_fpu_regnums_i386 has wrong number of register infos");
+
+// x86 64-bit registers available via XState.
+static const uint32_t g_xstate_regnums_i386[] = {
+ lldb_ymm0_i386, lldb_ymm1_i386, lldb_ymm2_i386, lldb_ymm3_i386,
+ lldb_ymm4_i386, lldb_ymm5_i386, lldb_ymm6_i386, lldb_ymm7_i386,
+ // Note: we currently do not provide them but this is needed to avoid
+ // unnamed groups in SBFrame::GetRegisterContext().
+ lldb_bnd0_i386, lldb_bnd1_i386, lldb_bnd2_i386,
+ lldb_bnd3_i386, lldb_bndcfgu_i386, lldb_bndstatus_i386,
+ LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+static_assert((sizeof(g_xstate_regnums_i386) / sizeof(g_xstate_regnums_i386[0])) -
+ 1 ==
+ k_num_avx_registers_i386 + k_num_mpx_registers_i386,
+ "g_xstate_regnums_i386 has wrong number of register infos");
+
+// x86 debug registers.
+static const uint32_t g_dbr_regnums_i386[] = {
+ lldb_dr0_i386, lldb_dr1_i386, lldb_dr2_i386, lldb_dr3_i386,
+ lldb_dr4_i386, lldb_dr5_i386, lldb_dr6_i386, lldb_dr7_i386,
+ LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+static_assert((sizeof(g_dbr_regnums_i386) / sizeof(g_dbr_regnums_i386[0])) -
+ 1 ==
+ k_num_dbr_registers_i386,
+ "g_dbr_regnums_i386 has wrong number of register infos");
+
+
// Number of register sets provided by this context.
enum { k_num_register_sets = 4 };
+// Register sets for x86 32-bit.
+static const RegisterSet g_reg_sets_i386[k_num_register_sets] = {
+ {"General Purpose Registers", "gpr", k_num_gpr_registers_i386,
+ g_gpr_regnums_i386},
+ {"Floating Point Registers", "fpu", k_num_fpr_registers_i386,
+ g_fpu_regnums_i386},
+ {"Extended State Registers", "xstate",
+ k_num_avx_registers_i386 + k_num_mpx_registers_i386,
+ g_xstate_regnums_i386},
+ {"Debug Registers", "dbr", k_num_dbr_registers_i386,
+ g_dbr_regnums_i386},
+};
+
// Register sets for x86 64-bit.
static const RegisterSet g_reg_sets_x86_64[k_num_register_sets] = {
{"General Purpose Registers", "gpr", k_num_gpr_registers_x86_64,
@@ -164,18 +240,23 @@ NativeRegisterContextNetBSD::CreateHostNativeRegisterContextNetBSD(
static RegisterInfoInterface *
CreateRegisterInfoInterface(const ArchSpec &target_arch) {
- assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) &&
- "Register setting path assumes this is a 64-bit host");
- // X86_64 hosts know how to work with 64-bit and 32-bit EXEs using the x86_64
- // register context.
- return new RegisterContextNetBSD_x86_64(target_arch);
+ if (HostInfo::GetArchitecture().GetAddressByteSize() == 4) {
+ // 32-bit hosts run with a RegisterContextNetBSD_i386 context.
+ return new RegisterContextNetBSD_i386(target_arch);
+ } else {
+ assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) &&
+ "Register setting path assumes this is a 64-bit host");
+ // X86_64 hosts know how to work with 64-bit and 32-bit EXEs using the x86_64
+ // register context.
+ return new RegisterContextNetBSD_x86_64(target_arch);
+ }
}
NativeRegisterContextNetBSD_x86_64::NativeRegisterContextNetBSD_x86_64(
const ArchSpec &target_arch, NativeThreadProtocol &native_thread)
: NativeRegisterContextNetBSD(native_thread,
CreateRegisterInfoInterface(target_arch)),
- m_gpr_x86_64(), m_fpr_x86_64(), m_dbr_x86_64() {}
+ m_gpr(), m_fpr(), m_dbr() {}
// CONSIDER after local and llgs debugging are merged, register set support can
// be moved into a base x86-64 class with IsRegisterSetAvailable made virtual.
@@ -192,6 +273,8 @@ uint32_t NativeRegisterContextNetBSD_x86_64::GetRegisterSetCount() const {
const RegisterSet *
NativeRegisterContextNetBSD_x86_64::GetRegisterSet(uint32_t set_index) const {
switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) {
+ case llvm::Triple::x86:
+ return &g_reg_sets_i386[set_index];
case llvm::Triple::x86_64:
return &g_reg_sets_x86_64[set_index];
default:
@@ -202,36 +285,162 @@ NativeRegisterContextNetBSD_x86_64::GetRegisterSet(uint32_t set_index) const {
return nullptr;
}
+static constexpr int RegNumX86ToX86_64(int regnum) {
+ switch (regnum) {
+ case lldb_eax_i386:
+ return lldb_rax_x86_64;
+ case lldb_ebx_i386:
+ return lldb_rbx_x86_64;
+ case lldb_ecx_i386:
+ return lldb_rcx_x86_64;
+ case lldb_edx_i386:
+ return lldb_rdx_x86_64;
+ case lldb_edi_i386:
+ return lldb_rdi_x86_64;
+ case lldb_esi_i386:
+ return lldb_rsi_x86_64;
+ case lldb_ebp_i386:
+ return lldb_rbp_x86_64;
+ case lldb_esp_i386:
+ return lldb_rsp_x86_64;
+ case lldb_eip_i386:
+ return lldb_rip_x86_64;
+ case lldb_eflags_i386:
+ return lldb_rflags_x86_64;
+ case lldb_cs_i386:
+ return lldb_cs_x86_64;
+ case lldb_fs_i386:
+ return lldb_fs_x86_64;
+ case lldb_gs_i386:
+ return lldb_gs_x86_64;
+ case lldb_ss_i386:
+ return lldb_ss_x86_64;
+ case lldb_ds_i386:
+ return lldb_ds_x86_64;
+ case lldb_es_i386:
+ return lldb_es_x86_64;
+ case lldb_fctrl_i386:
+ return lldb_fctrl_x86_64;
+ case lldb_fstat_i386:
+ return lldb_fstat_x86_64;
+ case lldb_ftag_i386:
+ return lldb_fstat_x86_64;
+ case lldb_fop_i386:
+ return lldb_fop_x86_64;
+ case lldb_fiseg_i386:
+ return lldb_fiseg_x86_64;
+ case lldb_fioff_i386:
+ return lldb_fioff_x86_64;
+ case lldb_foseg_i386:
+ return lldb_foseg_x86_64;
+ case lldb_fooff_i386:
+ return lldb_fooff_x86_64;
+ case lldb_mxcsr_i386:
+ return lldb_mxcsr_x86_64;
+ case lldb_mxcsrmask_i386:
+ return lldb_mxcsrmask_x86_64;
+ case lldb_st0_i386:
+ case lldb_st1_i386:
+ case lldb_st2_i386:
+ case lldb_st3_i386:
+ case lldb_st4_i386:
+ case lldb_st5_i386:
+ case lldb_st6_i386:
+ case lldb_st7_i386:
+ return lldb_st0_x86_64 + regnum - lldb_st0_i386;
+ case lldb_mm0_i386:
+ case lldb_mm1_i386:
+ case lldb_mm2_i386:
+ case lldb_mm3_i386:
+ case lldb_mm4_i386:
+ case lldb_mm5_i386:
+ case lldb_mm6_i386:
+ case lldb_mm7_i386:
+ return lldb_mm0_x86_64 + regnum - lldb_mm0_i386;
+ case lldb_xmm0_i386:
+ case lldb_xmm1_i386:
+ case lldb_xmm2_i386:
+ case lldb_xmm3_i386:
+ case lldb_xmm4_i386:
+ case lldb_xmm5_i386:
+ case lldb_xmm6_i386:
+ case lldb_xmm7_i386:
+ return lldb_xmm0_x86_64 + regnum - lldb_xmm0_i386;
+ case lldb_ymm0_i386:
+ case lldb_ymm1_i386:
+ case lldb_ymm2_i386:
+ case lldb_ymm3_i386:
+ case lldb_ymm4_i386:
+ case lldb_ymm5_i386:
+ case lldb_ymm6_i386:
+ case lldb_ymm7_i386:
+ return lldb_ymm0_x86_64 + regnum - lldb_ymm0_i386;
+ case lldb_dr0_i386:
+ case lldb_dr1_i386:
+ case lldb_dr2_i386:
+ case lldb_dr3_i386:
+ case lldb_dr4_i386:
+ case lldb_dr5_i386:
+ case lldb_dr6_i386:
+ case lldb_dr7_i386:
+ return lldb_dr0_x86_64 + regnum - lldb_dr0_i386;
+ default:
+ assert(false && "Unhandled i386 register.");
+ return 0;
+ }
+}
+
int NativeRegisterContextNetBSD_x86_64::GetSetForNativeRegNum(
int reg_num) const {
- if (reg_num <= k_last_gpr_x86_64)
- return GPRegSet;
- else if (reg_num <= k_last_fpr_x86_64)
- return FPRegSet;
- else if (reg_num <= k_last_avx_x86_64)
- return XStateRegSet; // AVX
- else if (reg_num <= k_last_mpxr_x86_64)
- return -1; // MPXR
- else if (reg_num <= k_last_mpxc_x86_64)
- return -1; // MPXC
- else if (reg_num <= lldb_dr7_x86_64)
- return DBRegSet; // DBR
- else
+ switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) {
+ case llvm::Triple::x86:
+ if (reg_num <= k_last_gpr_i386)
+ return GPRegSet;
+ else if (reg_num <= k_last_fpr_i386)
+ return FPRegSet;
+ else if (reg_num <= k_last_avx_i386)
+ return XStateRegSet; // AVX
+ else if (reg_num <= lldb_dr7_i386)
+ return DBRegSet; // DBR
+ else
+ return -1;
+ case llvm::Triple::x86_64:
+ if (reg_num <= k_last_gpr_x86_64)
+ return GPRegSet;
+ else if (reg_num <= k_last_fpr_x86_64)
+ return FPRegSet;
+ else if (reg_num <= k_last_avx_x86_64)
+ return XStateRegSet; // AVX
+ else if (reg_num <= k_last_mpxr_x86_64)
+ return -1; // MPXR
+ else if (reg_num <= k_last_mpxc_x86_64)
+ return -1; // MPXC
+ else if (reg_num <= lldb_dr7_x86_64)
+ return DBRegSet; // DBR
+ else
+ return -1;
+ default:
+ assert(false && "Unhandled target architecture.");
return -1;
+ }
}
Status NativeRegisterContextNetBSD_x86_64::ReadRegisterSet(uint32_t set) {
switch (set) {
case GPRegSet:
- return DoRegisterSet(PT_GETREGS, &m_gpr_x86_64);
+ return DoRegisterSet(PT_GETREGS, &m_gpr);
case FPRegSet:
- return DoRegisterSet(PT_GETFPREGS, &m_fpr_x86_64);
+#if defined(__x86_64__)
+ return DoRegisterSet(PT_GETFPREGS, &m_fpr);
+#else
+ return DoRegisterSet(PT_GETXMMREGS, &m_fpr);
+#endif
case DBRegSet:
- return DoRegisterSet(PT_GETDBREGS, &m_dbr_x86_64);
+ return DoRegisterSet(PT_GETDBREGS, &m_dbr);
case XStateRegSet:
#ifdef HAVE_XSTATE
{
- struct iovec iov = {&m_xstate_x86_64, sizeof(m_xstate_x86_64)};
+ struct iovec iov = {&m_xstate, sizeof(m_xstate)};
return DoRegisterSet(PT_GETXSTATE, &iov);
}
#else
@@ -244,15 +453,19 @@ Status NativeRegisterContextNetBSD_x86_64::ReadRegisterSet(uint32_t set) {
Status NativeRegisterContextNetBSD_x86_64::WriteRegisterSet(uint32_t set) {
switch (set) {
case GPRegSet:
- return DoRegisterSet(PT_SETREGS, &m_gpr_x86_64);
+ return DoRegisterSet(PT_SETREGS, &m_gpr);
case FPRegSet:
- return DoRegisterSet(PT_SETFPREGS, &m_fpr_x86_64);
+#if defined(__x86_64__)
+ return DoRegisterSet(PT_SETFPREGS, &m_fpr);
+#else
+ return DoRegisterSet(PT_SETXMMREGS, &m_fpr);
+#endif
case DBRegSet:
- return DoRegisterSet(PT_SETDBREGS, &m_dbr_x86_64);
+ return DoRegisterSet(PT_SETDBREGS, &m_dbr);
case XStateRegSet:
#ifdef HAVE_XSTATE
{
- struct iovec iov = {&m_xstate_x86_64, sizeof(m_xstate_x86_64)};
+ struct iovec iov = {&m_xstate, sizeof(m_xstate)};
return DoRegisterSet(PT_SETXSTATE, &iov);
}
#else
@@ -272,7 +485,7 @@ NativeRegisterContextNetBSD_x86_64::ReadRegister(const RegisterInfo *reg_info,
return error;
}
- const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
+ uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
if (reg == LLDB_INVALID_REGNUM) {
// This is likely an internal register for lldb use only and should not be
// directly queried.
@@ -291,112 +504,175 @@ NativeRegisterContextNetBSD_x86_64::ReadRegister(const RegisterInfo *reg_info,
return error;
}
+ switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) {
+ case llvm::Triple::x86_64:
+ break;
+ case llvm::Triple::x86:
+ reg = RegNumX86ToX86_64(reg);
+ break;
+ default:
+ assert(false && "Unhandled target architecture.");
+ error.SetErrorString("Unhandled target architecture.");
+ return error;
+ }
+
error = ReadRegisterSet(set);
if (error.Fail())
return error;
switch (reg) {
+#if defined(__x86_64__)
case lldb_rax_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RAX];
+ reg_value = (uint64_t)m_gpr.regs[_REG_RAX];
break;
case lldb_rbx_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RBX];
+ reg_value = (uint64_t)m_gpr.regs[_REG_RBX];
break;
case lldb_rcx_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RCX];
+ reg_value = (uint64_t)m_gpr.regs[_REG_RCX];
break;
case lldb_rdx_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RDX];
+ reg_value = (uint64_t)m_gpr.regs[_REG_RDX];
break;
case lldb_rdi_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RDI];
+ reg_value = (uint64_t)m_gpr.regs[_REG_RDI];
break;
case lldb_rsi_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RSI];
+ reg_value = (uint64_t)m_gpr.regs[_REG_RSI];
break;
case lldb_rbp_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RBP];
+ reg_value = (uint64_t)m_gpr.regs[_REG_RBP];
break;
case lldb_rsp_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RSP];
+ reg_value = (uint64_t)m_gpr.regs[_REG_RSP];
break;
case lldb_r8_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R8];
+ reg_value = (uint64_t)m_gpr.regs[_REG_R8];
break;
case lldb_r9_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R9];
+ reg_value = (uint64_t)m_gpr.regs[_REG_R9];
break;
case lldb_r10_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R10];
+ reg_value = (uint64_t)m_gpr.regs[_REG_R10];
break;
case lldb_r11_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R11];
+ reg_value = (uint64_t)m_gpr.regs[_REG_R11];
break;
case lldb_r12_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R12];
+ reg_value = (uint64_t)m_gpr.regs[_REG_R12];
break;
case lldb_r13_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R13];
+ reg_value = (uint64_t)m_gpr.regs[_REG_R13];
break;
case lldb_r14_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R14];
+ reg_value = (uint64_t)m_gpr.regs[_REG_R14];
break;
case lldb_r15_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R15];
+ reg_value = (uint64_t)m_gpr.regs[_REG_R15];
break;
case lldb_rip_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RIP];
+ reg_value = (uint64_t)m_gpr.regs[_REG_RIP];
break;
case lldb_rflags_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RFLAGS];
+ reg_value = (uint64_t)m_gpr.regs[_REG_RFLAGS];
break;
case lldb_cs_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_CS];
+ reg_value = (uint64_t)m_gpr.regs[_REG_CS];
break;
case lldb_fs_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_FS];
+ reg_value = (uint64_t)m_gpr.regs[_REG_FS];
break;
case lldb_gs_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_GS];
+ reg_value = (uint64_t)m_gpr.regs[_REG_GS];
break;
case lldb_ss_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_SS];
+ reg_value = (uint64_t)m_gpr.regs[_REG_SS];
break;
case lldb_ds_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_DS];
+ reg_value = (uint64_t)m_gpr.regs[_REG_DS];
break;
case lldb_es_x86_64:
- reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_ES];
+ reg_value = (uint64_t)m_gpr.regs[_REG_ES];
+ break;
+#else
+ case lldb_rax_x86_64:
+ reg_value = (uint32_t)m_gpr.r_eax;
break;
+ case lldb_rbx_x86_64:
+ reg_value = (uint32_t)m_gpr.r_ebx;
+ break;
+ case lldb_rcx_x86_64:
+ reg_value = (uint32_t)m_gpr.r_ecx;
+ break;
+ case lldb_rdx_x86_64:
+ reg_value = (uint32_t)m_gpr.r_edx;
+ break;
+ case lldb_rdi_x86_64:
+ reg_value = (uint32_t)m_gpr.r_edi;
+ break;
+ case lldb_rsi_x86_64:
+ reg_value = (uint32_t)m_gpr.r_esi;
+ break;
+ case lldb_rsp_x86_64:
+ reg_value = (uint32_t)m_gpr.r_esp;
+ break;
+ case lldb_rbp_x86_64:
+ reg_value = (uint32_t)m_gpr.r_ebp;
+ break;
+ case lldb_rip_x86_64:
+ reg_value = (uint32_t)m_gpr.r_eip;
+ break;
+ case lldb_rflags_x86_64:
+ reg_value = (uint32_t)m_gpr.r_eflags;
+ break;
+ case lldb_cs_x86_64:
+ reg_value = (uint32_t)m_gpr.r_cs;
+ break;
+ case lldb_fs_x86_64:
+ reg_value = (uint32_t)m_gpr.r_fs;
+ break;
+ case lldb_gs_x86_64:
+ reg_value = (uint32_t)m_gpr.r_gs;
+ break;
+ case lldb_ss_x86_64:
+ reg_value = (uint32_t)m_gpr.r_ss;
+ break;
+ case lldb_ds_x86_64:
+ reg_value = (uint32_t)m_gpr.r_ds;
+ break;
+ case lldb_es_x86_64:
+ reg_value = (uint32_t)m_gpr.r_es;
+ break;
+#endif
case lldb_fctrl_x86_64:
- reg_value = (uint16_t)m_fpr_x86_64.fxstate.fx_cw;
+ reg_value = (uint16_t)m_fpr.fxstate.fx_cw;
break;
case lldb_fstat_x86_64:
- reg_value = (uint16_t)m_fpr_x86_64.fxstate.fx_sw;
+ reg_value = (uint16_t)m_fpr.fxstate.fx_sw;
break;
case lldb_ftag_x86_64:
- reg_value = (uint8_t)m_fpr_x86_64.fxstate.fx_tw;
+ reg_value = (uint8_t)m_fpr.fxstate.fx_tw;
break;
case lldb_fop_x86_64:
- reg_value = (uint64_t)m_fpr_x86_64.fxstate.fx_opcode;
+ reg_value = (uint64_t)m_fpr.fxstate.fx_opcode;
break;
case lldb_fiseg_x86_64:
- reg_value = (uint64_t)m_fpr_x86_64.fxstate.fx_ip.fa_64;
+ reg_value = (uint64_t)m_fpr.fxstate.fx_ip.fa_64;
break;
case lldb_fioff_x86_64:
- reg_value = (uint32_t)m_fpr_x86_64.fxstate.fx_ip.fa_32.fa_off;
+ reg_value = (uint32_t)m_fpr.fxstate.fx_ip.fa_32.fa_off;
break;
case lldb_foseg_x86_64:
- reg_value = (uint64_t)m_fpr_x86_64.fxstate.fx_dp.fa_64;
+ reg_value = (uint64_t)m_fpr.fxstate.fx_dp.fa_64;
break;
case lldb_fooff_x86_64:
- reg_value = (uint32_t)m_fpr_x86_64.fxstate.fx_dp.fa_32.fa_off;
+ reg_value = (uint32_t)m_fpr.fxstate.fx_dp.fa_32.fa_off;
break;
case lldb_mxcsr_x86_64:
- reg_value = (uint32_t)m_fpr_x86_64.fxstate.fx_mxcsr;
+ reg_value = (uint32_t)m_fpr.fxstate.fx_mxcsr;
break;
case lldb_mxcsrmask_x86_64:
- reg_value = (uint32_t)m_fpr_x86_64.fxstate.fx_mxcsr_mask;
+ reg_value = (uint32_t)m_fpr.fxstate.fx_mxcsr_mask;
break;
case lldb_st0_x86_64:
case lldb_st1_x86_64:
@@ -406,7 +682,7 @@ NativeRegisterContextNetBSD_x86_64::ReadRegister(const RegisterInfo *reg_info,
case lldb_st5_x86_64:
case lldb_st6_x86_64:
case lldb_st7_x86_64:
- reg_value.SetBytes(&m_fpr_x86_64.fxstate.fx_87_ac[reg - lldb_st0_x86_64],
+ reg_value.SetBytes(&m_fpr.fxstate.fx_87_ac[reg - lldb_st0_x86_64],
reg_info->byte_size, endian::InlHostByteOrder());
break;
case lldb_mm0_x86_64:
@@ -417,7 +693,7 @@ NativeRegisterContextNetBSD_x86_64::ReadRegister(const RegisterInfo *reg_info,
case lldb_mm5_x86_64:
case lldb_mm6_x86_64:
case lldb_mm7_x86_64:
- reg_value.SetBytes(&m_fpr_x86_64.fxstate.fx_87_ac[reg - lldb_mm0_x86_64],
+ reg_value.SetBytes(&m_fpr.fxstate.fx_87_ac[reg - lldb_mm0_x86_64],
reg_info->byte_size, endian::InlHostByteOrder());
break;
case lldb_xmm0_x86_64:
@@ -436,7 +712,7 @@ NativeRegisterContextNetBSD_x86_64::ReadRegister(const RegisterInfo *reg_info,
case lldb_xmm13_x86_64:
case lldb_xmm14_x86_64:
case lldb_xmm15_x86_64:
- reg_value.SetBytes(&m_fpr_x86_64.fxstate.fx_xmm[reg - lldb_xmm0_x86_64],
+ reg_value.SetBytes(&m_fpr.fxstate.fx_xmm[reg - lldb_xmm0_x86_64],
reg_info->byte_size, endian::InlHostByteOrder());
break;
case lldb_ymm0_x86_64:
@@ -456,15 +732,15 @@ NativeRegisterContextNetBSD_x86_64::ReadRegister(const RegisterInfo *reg_info,
case lldb_ymm14_x86_64:
case lldb_ymm15_x86_64:
#ifdef HAVE_XSTATE
- if (!(m_xstate_x86_64.xs_rfbm & XCR0_SSE) ||
- !(m_xstate_x86_64.xs_rfbm & XCR0_YMM_Hi128)) {
+ if (!(m_xstate.xs_rfbm & XCR0_SSE) ||
+ !(m_xstate.xs_rfbm & XCR0_YMM_Hi128)) {
error.SetErrorStringWithFormat("register \"%s\" not supported by CPU/kernel",
reg_info->name);
} else {
uint32_t reg_index = reg - lldb_ymm0_x86_64;
YMMReg ymm = XStateToYMM(
- m_xstate_x86_64.xs_fxsave.fx_xmm[reg_index].xmm_bytes,
- m_xstate_x86_64.xs_ymm_hi128.xs_ymm[reg_index].ymm_bytes);
+ m_xstate.xs_fxsave.fx_xmm[reg_index].xmm_bytes,
+ m_xstate.xs_ymm_hi128.xs_ymm[reg_index].ymm_bytes);
reg_value.SetBytes(ymm.bytes, reg_info->byte_size,
endian::InlHostByteOrder());
}
@@ -480,7 +756,7 @@ NativeRegisterContextNetBSD_x86_64::ReadRegister(const RegisterInfo *reg_info,
case lldb_dr5_x86_64:
case lldb_dr6_x86_64:
case lldb_dr7_x86_64:
- reg_value = (uint64_t)m_dbr_x86_64.dr[reg - lldb_dr0_x86_64];
+ reg_value = (uint64_t)m_dbr.dr[reg - lldb_dr0_x86_64];
break;
}
@@ -497,7 +773,7 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
return error;
}
- const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
+ uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
if (reg == LLDB_INVALID_REGNUM) {
// This is likely an internal register for lldb use only and should not be
// directly queried.
@@ -516,112 +792,175 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
return error;
}
+ switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) {
+ case llvm::Triple::x86_64:
+ break;
+ case llvm::Triple::x86:
+ reg = RegNumX86ToX86_64(reg);
+ break;
+ default:
+ assert(false && "Unhandled target architecture.");
+ error.SetErrorString("Unhandled target architecture.");
+ return error;
+ }
+
error = ReadRegisterSet(set);
if (error.Fail())
return error;
switch (reg) {
+#if defined(__x86_64__)
case lldb_rax_x86_64:
- m_gpr_x86_64.regs[_REG_RAX] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_RAX] = reg_value.GetAsUInt64();
break;
case lldb_rbx_x86_64:
- m_gpr_x86_64.regs[_REG_RBX] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_RBX] = reg_value.GetAsUInt64();
break;
case lldb_rcx_x86_64:
- m_gpr_x86_64.regs[_REG_RCX] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_RCX] = reg_value.GetAsUInt64();
break;
case lldb_rdx_x86_64:
- m_gpr_x86_64.regs[_REG_RDX] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_RDX] = reg_value.GetAsUInt64();
break;
case lldb_rdi_x86_64:
- m_gpr_x86_64.regs[_REG_RDI] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_RDI] = reg_value.GetAsUInt64();
break;
case lldb_rsi_x86_64:
- m_gpr_x86_64.regs[_REG_RSI] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_RSI] = reg_value.GetAsUInt64();
break;
case lldb_rbp_x86_64:
- m_gpr_x86_64.regs[_REG_RBP] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_RBP] = reg_value.GetAsUInt64();
break;
case lldb_rsp_x86_64:
- m_gpr_x86_64.regs[_REG_RSP] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_RSP] = reg_value.GetAsUInt64();
break;
case lldb_r8_x86_64:
- m_gpr_x86_64.regs[_REG_R8] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_R8] = reg_value.GetAsUInt64();
break;
case lldb_r9_x86_64:
- m_gpr_x86_64.regs[_REG_R9] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_R9] = reg_value.GetAsUInt64();
break;
case lldb_r10_x86_64:
- m_gpr_x86_64.regs[_REG_R10] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_R10] = reg_value.GetAsUInt64();
break;
case lldb_r11_x86_64:
- m_gpr_x86_64.regs[_REG_R11] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_R11] = reg_value.GetAsUInt64();
break;
case lldb_r12_x86_64:
- m_gpr_x86_64.regs[_REG_R12] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_R12] = reg_value.GetAsUInt64();
break;
case lldb_r13_x86_64:
- m_gpr_x86_64.regs[_REG_R13] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_R13] = reg_value.GetAsUInt64();
break;
case lldb_r14_x86_64:
- m_gpr_x86_64.regs[_REG_R14] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_R14] = reg_value.GetAsUInt64();
break;
case lldb_r15_x86_64:
- m_gpr_x86_64.regs[_REG_R15] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_R15] = reg_value.GetAsUInt64();
break;
case lldb_rip_x86_64:
- m_gpr_x86_64.regs[_REG_RIP] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_RIP] = reg_value.GetAsUInt64();
break;
case lldb_rflags_x86_64:
- m_gpr_x86_64.regs[_REG_RFLAGS] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_RFLAGS] = reg_value.GetAsUInt64();
break;
case lldb_cs_x86_64:
- m_gpr_x86_64.regs[_REG_CS] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_CS] = reg_value.GetAsUInt64();
break;
case lldb_fs_x86_64:
- m_gpr_x86_64.regs[_REG_FS] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_FS] = reg_value.GetAsUInt64();
break;
case lldb_gs_x86_64:
- m_gpr_x86_64.regs[_REG_GS] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_GS] = reg_value.GetAsUInt64();
break;
case lldb_ss_x86_64:
- m_gpr_x86_64.regs[_REG_SS] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_SS] = reg_value.GetAsUInt64();
break;
case lldb_ds_x86_64:
- m_gpr_x86_64.regs[_REG_DS] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_DS] = reg_value.GetAsUInt64();
break;
case lldb_es_x86_64:
- m_gpr_x86_64.regs[_REG_ES] = reg_value.GetAsUInt64();
+ m_gpr.regs[_REG_ES] = reg_value.GetAsUInt64();
break;
+#else
+ case lldb_rax_x86_64:
+ m_gpr.r_eax = reg_value.GetAsUInt32();
+ break;
+ case lldb_rbx_x86_64:
+ m_gpr.r_ebx = reg_value.GetAsUInt32();
+ break;
+ case lldb_rcx_x86_64:
+ m_gpr.r_ecx = reg_value.GetAsUInt32();
+ break;
+ case lldb_rdx_x86_64:
+ m_gpr.r_edx = reg_value.GetAsUInt32();
+ break;
+ case lldb_rdi_x86_64:
+ m_gpr.r_edi = reg_value.GetAsUInt32();
+ break;
+ case lldb_rsi_x86_64:
+ m_gpr.r_esi = reg_value.GetAsUInt32();
+ break;
+ case lldb_rsp_x86_64:
+ m_gpr.r_esp = reg_value.GetAsUInt32();
+ break;
+ case lldb_rbp_x86_64:
+ m_gpr.r_ebp = reg_value.GetAsUInt32();
+ break;
+ case lldb_rip_x86_64:
+ m_gpr.r_eip = reg_value.GetAsUInt32();
+ break;
+ case lldb_rflags_x86_64:
+ m_gpr.r_eflags = reg_value.GetAsUInt32();
+ break;
+ case lldb_cs_x86_64:
+ m_gpr.r_cs = reg_value.GetAsUInt32();
+ break;
+ case lldb_fs_x86_64:
+ m_gpr.r_fs = reg_value.GetAsUInt32();
+ break;
+ case lldb_gs_x86_64:
+ m_gpr.r_gs = reg_value.GetAsUInt32();
+ break;
+ case lldb_ss_x86_64:
+ m_gpr.r_ss = reg_value.GetAsUInt32();
+ break;
+ case lldb_ds_x86_64:
+ m_gpr.r_ds = reg_value.GetAsUInt32();
+ break;
+ case lldb_es_x86_64:
+ m_gpr.r_es = reg_value.GetAsUInt32();
+ break;
+#endif
case lldb_fctrl_x86_64:
- m_fpr_x86_64.fxstate.fx_cw = reg_value.GetAsUInt16();
+ m_fpr.fxstate.fx_cw = reg_value.GetAsUInt16();
break;
case lldb_fstat_x86_64:
- m_fpr_x86_64.fxstate.fx_sw = reg_value.GetAsUInt16();
+ m_fpr.fxstate.fx_sw = reg_value.GetAsUInt16();
break;
case lldb_ftag_x86_64:
- m_fpr_x86_64.fxstate.fx_tw = reg_value.GetAsUInt8();
+ m_fpr.fxstate.fx_tw = reg_value.GetAsUInt8();
break;
case lldb_fop_x86_64:
- m_fpr_x86_64.fxstate.fx_opcode = reg_value.GetAsUInt16();
+ m_fpr.fxstate.fx_opcode = reg_value.GetAsUInt16();
break;
case lldb_fiseg_x86_64:
- m_fpr_x86_64.fxstate.fx_ip.fa_64 = reg_value.GetAsUInt64();
+ m_fpr.fxstate.fx_ip.fa_64 = reg_value.GetAsUInt64();
break;
case lldb_fioff_x86_64:
- m_fpr_x86_64.fxstate.fx_ip.fa_32.fa_off = reg_value.GetAsUInt32();
+ m_fpr.fxstate.fx_ip.fa_32.fa_off = reg_value.GetAsUInt32();
break;
case lldb_foseg_x86_64:
- m_fpr_x86_64.fxstate.fx_dp.fa_64 = reg_value.GetAsUInt64();
+ m_fpr.fxstate.fx_dp.fa_64 = reg_value.GetAsUInt64();
break;
case lldb_fooff_x86_64:
- m_fpr_x86_64.fxstate.fx_dp.fa_32.fa_off = reg_value.GetAsUInt32();
+ m_fpr.fxstate.fx_dp.fa_32.fa_off = reg_value.GetAsUInt32();
break;
case lldb_mxcsr_x86_64:
- m_fpr_x86_64.fxstate.fx_mxcsr = reg_value.GetAsUInt32();
+ m_fpr.fxstate.fx_mxcsr = reg_value.GetAsUInt32();
break;
case lldb_mxcsrmask_x86_64:
- m_fpr_x86_64.fxstate.fx_mxcsr_mask = reg_value.GetAsUInt32();
+ m_fpr.fxstate.fx_mxcsr_mask = reg_value.GetAsUInt32();
break;
case lldb_st0_x86_64:
case lldb_st1_x86_64:
@@ -631,7 +970,7 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
case lldb_st5_x86_64:
case lldb_st6_x86_64:
case lldb_st7_x86_64:
- ::memcpy(&m_fpr_x86_64.fxstate.fx_87_ac[reg - lldb_st0_x86_64],
+ ::memcpy(&m_fpr.fxstate.fx_87_ac[reg - lldb_st0_x86_64],
reg_value.GetBytes(), reg_value.GetByteSize());
break;
case lldb_mm0_x86_64:
@@ -642,7 +981,7 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
case lldb_mm5_x86_64:
case lldb_mm6_x86_64:
case lldb_mm7_x86_64:
- ::memcpy(&m_fpr_x86_64.fxstate.fx_87_ac[reg - lldb_mm0_x86_64],
+ ::memcpy(&m_fpr.fxstate.fx_87_ac[reg - lldb_mm0_x86_64],
reg_value.GetBytes(), reg_value.GetByteSize());
break;
case lldb_xmm0_x86_64:
@@ -661,7 +1000,7 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
case lldb_xmm13_x86_64:
case lldb_xmm14_x86_64:
case lldb_xmm15_x86_64:
- ::memcpy(&m_fpr_x86_64.fxstate.fx_xmm[reg - lldb_xmm0_x86_64],
+ ::memcpy(&m_fpr.fxstate.fx_xmm[reg - lldb_xmm0_x86_64],
reg_value.GetBytes(), reg_value.GetByteSize());
break;
case lldb_ymm0_x86_64:
@@ -681,8 +1020,8 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
case lldb_ymm14_x86_64:
case lldb_ymm15_x86_64:
#ifdef HAVE_XSTATE
- if (!(m_xstate_x86_64.xs_rfbm & XCR0_SSE) ||
- !(m_xstate_x86_64.xs_rfbm & XCR0_YMM_Hi128)) {
+ if (!(m_xstate.xs_rfbm & XCR0_SSE) ||
+ !(m_xstate.xs_rfbm & XCR0_YMM_Hi128)) {
error.SetErrorStringWithFormat("register \"%s\" not supported by CPU/kernel",
reg_info->name);
} else {
@@ -690,8 +1029,8 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
YMMReg ymm;
::memcpy(ymm.bytes, reg_value.GetBytes(), reg_value.GetByteSize());
YMMToXState(ymm,
- m_xstate_x86_64.xs_fxsave.fx_xmm[reg_index].xmm_bytes,
- m_xstate_x86_64.xs_ymm_hi128.xs_ymm[reg_index].ymm_bytes);
+ m_xstate.xs_fxsave.fx_xmm[reg_index].xmm_bytes,
+ m_xstate.xs_ymm_hi128.xs_ymm[reg_index].ymm_bytes);
}
#else
error.SetErrorString("XState not supported by the kernel");
@@ -705,7 +1044,7 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
case lldb_dr5_x86_64:
case lldb_dr6_x86_64:
case lldb_dr7_x86_64:
- m_dbr_x86_64.dr[reg - lldb_dr0_x86_64] = reg_value.GetAsUInt64();
+ m_dbr.dr[reg - lldb_dr0_x86_64] = reg_value.GetAsUInt64();
break;
}
@@ -722,7 +1061,7 @@ Status NativeRegisterContextNetBSD_x86_64::ReadAllRegisterValues(
return error;
uint8_t *dst = data_sp->GetBytes();
- ::memcpy(dst, &m_gpr_x86_64, GetRegisterInfoInterface().GetGPRSize());
+ ::memcpy(dst, &m_gpr, GetRegisterInfoInterface().GetGPRSize());
dst += GetRegisterInfoInterface().GetGPRSize();
return error;
@@ -742,7 +1081,7 @@ Status NativeRegisterContextNetBSD_x86_64::WriteAllRegisterValues(
if (data_sp->GetByteSize() != REG_CONTEXT_SIZE) {
error.SetErrorStringWithFormat(
"NativeRegisterContextNetBSD_x86_64::%s data_sp contained mismatched "
- "data size, expected %" PRIu64 ", actual %" PRIu64,
+ "data size, expected %zu, actual %" PRIu64,
__FUNCTION__, REG_CONTEXT_SIZE, data_sp->GetByteSize());
return error;
}
@@ -755,7 +1094,7 @@ Status NativeRegisterContextNetBSD_x86_64::WriteAllRegisterValues(
__FUNCTION__);
return error;
}
- ::memcpy(&m_gpr_x86_64, src, GetRegisterInfoInterface().GetGPRSize());
+ ::memcpy(&m_gpr, src, GetRegisterInfoInterface().GetGPRSize());
error = WriteRegisterSet(GPRegSet);
if (error.Fail())
@@ -765,13 +1104,25 @@ Status NativeRegisterContextNetBSD_x86_64::WriteAllRegisterValues(
return error;
}
+int NativeRegisterContextNetBSD_x86_64::GetDR(int num) const {
+ assert(num >= 0 && num <= 7);
+ switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) {
+ case llvm::Triple::x86:
+ return lldb_dr0_i386 + num;
+ case llvm::Triple::x86_64:
+ return lldb_dr0_x86_64 + num;
+ default:
+ return -1;
+ }
+}
+
Status NativeRegisterContextNetBSD_x86_64::IsWatchpointHit(uint32_t wp_index,
bool &is_hit) {
if (wp_index >= NumSupportedHardwareWatchpoints())
return Status("Watchpoint index out of range");
RegisterValue reg_value;
- const RegisterInfo *const reg_info = GetRegisterInfoAtIndex(lldb_dr6_x86_64);
+ const RegisterInfo *const reg_info = GetRegisterInfoAtIndex(GetDR(6));
Status error = ReadRegister(reg_info, reg_value);
if (error.Fail()) {
is_hit = false;
@@ -808,7 +1159,7 @@ Status NativeRegisterContextNetBSD_x86_64::IsWatchpointVacant(uint32_t wp_index,
return Status("Watchpoint index out of range");
RegisterValue reg_value;
- const RegisterInfo *const reg_info = GetRegisterInfoAtIndex(lldb_dr7_x86_64);
+ const RegisterInfo *const reg_info = GetRegisterInfoAtIndex(GetDR(7));
Status error = ReadRegister(reg_info, reg_value);
if (error.Fail()) {
is_vacant = false;
@@ -848,8 +1199,7 @@ Status NativeRegisterContextNetBSD_x86_64::SetHardwareWatchpointWithIndex(
if (!is_vacant)
return Status("Watchpoint index not vacant");
- const RegisterInfo *const reg_info_dr7 =
- GetRegisterInfoAtIndex(lldb_dr7_x86_64);
+ const RegisterInfo *const reg_info_dr7 = GetRegisterInfoAtIndex(GetDR(7));
RegisterValue dr7_value;
error = ReadRegister(reg_info_dr7, dr7_value);
if (error.Fail())
@@ -874,7 +1224,7 @@ Status NativeRegisterContextNetBSD_x86_64::SetHardwareWatchpointWithIndex(
control_bits |= enable_bit | rw_bits | size_bits;
const RegisterInfo *const reg_info_drN =
- GetRegisterInfoAtIndex(lldb_dr0_x86_64 + wp_index);
+ GetRegisterInfoAtIndex(GetDR(wp_index));
RegisterValue drN_value;
error = ReadRegister(reg_info_drN, drN_value);
if (error.Fail())
@@ -906,8 +1256,7 @@ bool NativeRegisterContextNetBSD_x86_64::ClearHardwareWatchpoint(
// for watchpoints 0, 1, 2, or 3, respectively, clear bits 0-1, 2-3, 4-5
// or 6-7 of the debug control register (DR7)
- const RegisterInfo *const reg_info_dr7 =
- GetRegisterInfoAtIndex(lldb_dr7_x86_64);
+ const RegisterInfo *const reg_info_dr7 = GetRegisterInfoAtIndex(GetDR(7));
RegisterValue reg_value;
Status error = ReadRegister(reg_info_dr7, reg_value);
if (error.Fail())
@@ -924,8 +1273,7 @@ Status NativeRegisterContextNetBSD_x86_64::ClearWatchpointHit(uint32_t wp_index)
// for watchpoints 0, 1, 2, or 3, respectively, check bits 0, 1, 2, or 3 of
// the debug status register (DR6)
- const RegisterInfo *const reg_info_dr6 =
- GetRegisterInfoAtIndex(lldb_dr6_x86_64);
+ const RegisterInfo *const reg_info_dr6 = GetRegisterInfoAtIndex(GetDR(6));
RegisterValue reg_value;
Status error = ReadRegister(reg_info_dr6, reg_value);
if (error.Fail())
@@ -940,8 +1288,7 @@ Status NativeRegisterContextNetBSD_x86_64::ClearAllHardwareWatchpoints() {
RegisterValue reg_value;
// clear bits {0-4} of the debug status register (DR6)
- const RegisterInfo *const reg_info_dr6 =
- GetRegisterInfoAtIndex(lldb_dr6_x86_64);
+ const RegisterInfo *const reg_info_dr6 = GetRegisterInfoAtIndex(GetDR(6));
Status error = ReadRegister(reg_info_dr6, reg_value);
if (error.Fail())
return error;
@@ -952,8 +1299,7 @@ Status NativeRegisterContextNetBSD_x86_64::ClearAllHardwareWatchpoints() {
return error;
// clear bits {0-7,16-31} of the debug control register (DR7)
- const RegisterInfo *const reg_info_dr7 =
- GetRegisterInfoAtIndex(lldb_dr7_x86_64);
+ const RegisterInfo *const reg_info_dr7 = GetRegisterInfoAtIndex(GetDR(7));
error = ReadRegister(reg_info_dr7, reg_value);
if (error.Fail())
return error;
@@ -988,7 +1334,7 @@ NativeRegisterContextNetBSD_x86_64::GetWatchpointAddress(uint32_t wp_index) {
return LLDB_INVALID_ADDRESS;
RegisterValue reg_value;
const RegisterInfo *const reg_info_drN =
- GetRegisterInfoAtIndex(lldb_dr0_x86_64 + wp_index);
+ GetRegisterInfoAtIndex(GetDR(wp_index));
if (ReadRegister(reg_info_drN, reg_value).Fail())
return LLDB_INVALID_ADDRESS;
return reg_value.GetAsUInt64();
@@ -1005,10 +1351,10 @@ Status NativeRegisterContextNetBSD_x86_64::CopyHardwareWatchpointsFrom(
Status res = r_source.ReadRegisterSet(DBRegSet);
if (!res.Fail()) {
// copy dbregs only if any watchpoints were set
- if ((r_source.m_dbr_x86_64.dr[7] & 0xFF) == 0)
+ if ((r_source.m_dbr.dr[7] & 0xFF) == 0)
return res;
- m_dbr_x86_64 = r_source.m_dbr_x86_64;
+ m_dbr = r_source.m_dbr;
res = WriteRegisterSet(DBRegSet);
}
return res;
diff --git a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
index 54b8a806267f..6c0632f3bce8 100644
--- a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
+++ b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#if defined(__x86_64__)
+#if defined(__i386__) || defined(__x86_64__)
#ifndef lldb_NativeRegisterContextNetBSD_x86_64_h
#define lldb_NativeRegisterContextNetBSD_x86_64_h
@@ -81,14 +81,19 @@ private:
enum { GPRegSet, FPRegSet, XStateRegSet, DBRegSet };
// Private member variables.
- struct reg m_gpr_x86_64;
- struct fpreg m_fpr_x86_64;
- struct dbreg m_dbr_x86_64;
+ struct reg m_gpr;
+#if defined(__x86_64__)
+ struct fpreg m_fpr;
+#else
+ struct xmmregs m_fpr;
+#endif
+ struct dbreg m_dbr;
#ifdef HAVE_XSTATE
- struct xstate m_xstate_x86_64;
+ struct xstate m_xstate;
#endif
int GetSetForNativeRegNum(int reg_num) const;
+ int GetDR(int num) const;
Status ReadRegisterSet(uint32_t set);
Status WriteRegisterSet(uint32_t set);
diff --git a/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp b/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
index dd2745d9330e..fe76fb40e0b3 100644
--- a/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
+++ b/lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
@@ -1,4 +1,4 @@
-//===-- NativeThreadNetBSD.cpp -------------------------------- -*- C++ -*-===//
+//===-- NativeThreadNetBSD.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/POSIX/CrashReason.cpp b/lldb/source/Plugins/Process/POSIX/CrashReason.cpp
index b872269fdfe1..579077b45bf9 100644
--- a/lldb/source/Plugins/Process/POSIX/CrashReason.cpp
+++ b/lldb/source/Plugins/Process/POSIX/CrashReason.cpp
@@ -1,4 +1,4 @@
-//===-- CrashReason.cpp -----------------------------------------*- C++ -*-===//
+//===-- CrashReason.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp
index 058dc5ae2338..117d12101a0b 100644
--- a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp
+++ b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.cpp
@@ -1,4 +1,4 @@
-//===-- NativeProcessELF.cpp ---------------------------------- -*- C++ -*-===//
+//===-- NativeProcessELF.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -107,6 +107,11 @@ lldb::addr_t NativeProcessELF::GetELFImageInfoAddress() {
return LLDB_INVALID_ADDRESS;
}
+template lldb::addr_t NativeProcessELF::GetELFImageInfoAddress<
+ llvm::ELF::Elf32_Ehdr, llvm::ELF::Elf32_Phdr, llvm::ELF::Elf32_Dyn>();
+template lldb::addr_t NativeProcessELF::GetELFImageInfoAddress<
+ llvm::ELF::Elf64_Ehdr, llvm::ELF::Elf64_Phdr, llvm::ELF::Elf64_Dyn>();
+
template <typename T>
llvm::Expected<SVR4LibraryInfo>
NativeProcessELF::ReadSVR4LibraryInfo(lldb::addr_t link_map_addr) {
diff --git a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.h b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.h
index 4fb513baebf0..dcfa9290ff50 100644
--- a/lldb/source/Plugins/Process/POSIX/NativeProcessELF.h
+++ b/lldb/source/Plugins/Process/POSIX/NativeProcessELF.h
@@ -48,6 +48,14 @@ protected:
llvm::Optional<lldb::addr_t> m_shared_library_info_addr;
};
+// Explicitly declare the two 32/64 bit templates that NativeProcessELF.cpp will
+// define. This allows us to keep the template definition here and usable
+// elsewhere.
+extern template lldb::addr_t NativeProcessELF::GetELFImageInfoAddress<
+ llvm::ELF::Elf32_Ehdr, llvm::ELF::Elf32_Phdr, llvm::ELF::Elf32_Dyn>();
+extern template lldb::addr_t NativeProcessELF::GetELFImageInfoAddress<
+ llvm::ELF::Elf64_Ehdr, llvm::ELF::Elf64_Phdr, llvm::ELF::Elf64_Dyn>();
+
} // namespace lldb_private
-#endif \ No newline at end of file
+#endif
diff --git a/lldb/source/Plugins/Process/POSIX/ProcessMessage.cpp b/lldb/source/Plugins/Process/POSIX/ProcessMessage.cpp
index 66286dd3d9e3..4e8c6f1ba2d2 100644
--- a/lldb/source/Plugins/Process/POSIX/ProcessMessage.cpp
+++ b/lldb/source/Plugins/Process/POSIX/ProcessMessage.cpp
@@ -1,4 +1,4 @@
-//===-- ProcessMessage.cpp --------------------------------------*- C++ -*-===//
+//===-- ProcessMessage.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp b/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
index a17558bfe7c6..f4d0803b264a 100644
--- a/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
+++ b/lldb/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
@@ -1,5 +1,4 @@
-//===-- ProcessPOSIXLog.cpp ---------------------------------------*- C++
-//-*-===//
+//===-- ProcessPOSIXLog.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/ARMDefines.h b/lldb/source/Plugins/Process/Utility/ARMDefines.h
index 1f7eb54d10e7..fd3965fade19 100644
--- a/lldb/source/Plugins/Process/Utility/ARMDefines.h
+++ b/lldb/source/Plugins/Process/Utility/ARMDefines.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_ARMDefines_h_
-#define lldb_ARMDefines_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_ARMDEFINES_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_ARMDEFINES_H
#include "llvm/Support/ErrorHandling.h"
@@ -188,4 +188,4 @@ static inline bool ARMConditionPassed(const uint32_t condition,
} // namespace lldb_private
-#endif // lldb_ARMDefines_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_ARMDEFINES_H
diff --git a/lldb/source/Plugins/Process/Utility/ARMUtils.h b/lldb/source/Plugins/Process/Utility/ARMUtils.h
index d860348818d3..bbe4c9a35fa6 100644
--- a/lldb/source/Plugins/Process/Utility/ARMUtils.h
+++ b/lldb/source/Plugins/Process/Utility/ARMUtils.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_ARMUtils_h_
-#define lldb_ARMUtils_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_ARMUTILS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_ARMUTILS_H
#include "ARMDefines.h"
#include "InstructionUtils.h"
@@ -371,4 +371,4 @@ static inline bool BadReg(uint32_t n) { return n == 13 || n == 15; }
} // namespace lldb_private
-#endif // lldb_ARMUtils_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_ARMUTILS_H
diff --git a/lldb/source/Plugins/Process/Utility/AuxVector.cpp b/lldb/source/Plugins/Process/Utility/AuxVector.cpp
index 25a1d0b5af06..685d9d0824f6 100644
--- a/lldb/source/Plugins/Process/Utility/AuxVector.cpp
+++ b/lldb/source/Plugins/Process/Utility/AuxVector.cpp
@@ -1,4 +1,4 @@
-//===-- AuxVector.cpp -------------------------------------------*- C++ -*-===//
+//===-- AuxVector.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/AuxVector.h b/lldb/source/Plugins/Process/Utility/AuxVector.h
index c16be68aedb1..c8c8b1249413 100644
--- a/lldb/source/Plugins/Process/Utility/AuxVector.h
+++ b/lldb/source/Plugins/Process/Utility/AuxVector.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_AuxVector_H_
-#define liblldb_AuxVector_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_AUXVECTOR_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_AUXVECTOR_H
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Log.h"
diff --git a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
index a86880af2260..443638aa39f6 100644
--- a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -1,4 +1,4 @@
-//===-- DynamicRegisterInfo.cpp ----------------------------*- C++ -*-===//
+//===-- DynamicRegisterInfo.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -742,6 +742,8 @@ const lldb_private::RegisterInfo *DynamicRegisterInfo::GetRegisterInfo(
for (auto &reg_info : m_regs) {
// We can use pointer comparison since we used a ConstString to set the
// "name" member in AddRegister()
+ assert(ConstString(reg_info.name).GetCString() == reg_info.name &&
+ "reg_info.name not from a ConstString?");
if (reg_info.name == reg_name.GetCString()) {
return &reg_info;
}
diff --git a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
index aacf547e187d..48939375a504 100644
--- a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
+++ b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_DynamicRegisterInfo_h_
-#define lldb_DynamicRegisterInfo_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_DYNAMICREGISTERINFO_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_DYNAMICREGISTERINFO_H
#include <map>
#include <vector>
@@ -90,4 +90,4 @@ protected:
// all registers
bool m_finalized = false;
};
-#endif // lldb_DynamicRegisterInfo_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_DYNAMICREGISTERINFO_H
diff --git a/lldb/source/Plugins/Process/Utility/FreeBSDSignals.cpp b/lldb/source/Plugins/Process/Utility/FreeBSDSignals.cpp
index 9f63a594e054..0a4bdc72b364 100644
--- a/lldb/source/Plugins/Process/Utility/FreeBSDSignals.cpp
+++ b/lldb/source/Plugins/Process/Utility/FreeBSDSignals.cpp
@@ -1,4 +1,4 @@
-//===-- FreeBSDSignals.cpp --------------------------------------*- C++ -*-===//
+//===-- FreeBSDSignals.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/FreeBSDSignals.h b/lldb/source/Plugins/Process/Utility/FreeBSDSignals.h
index 75462f3c76ff..c4c810e54985 100644
--- a/lldb/source/Plugins/Process/Utility/FreeBSDSignals.h
+++ b/lldb/source/Plugins/Process/Utility/FreeBSDSignals.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_FreeBSDSignals_H_
-#define liblldb_FreeBSDSignals_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_FREEBSDSIGNALS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_FREEBSDSIGNALS_H
#include "lldb/Target/UnixSignals.h"
@@ -24,4 +24,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_FreeBSDSignals_H_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_FREEBSDSIGNALS_H
diff --git a/lldb/source/Plugins/Process/Utility/GDBRemoteSignals.cpp b/lldb/source/Plugins/Process/Utility/GDBRemoteSignals.cpp
index ed35273ce3fe..427225c14d3b 100644
--- a/lldb/source/Plugins/Process/Utility/GDBRemoteSignals.cpp
+++ b/lldb/source/Plugins/Process/Utility/GDBRemoteSignals.cpp
@@ -1,4 +1,4 @@
-//===-- GDBRemoteSignals.cpp ------------------------------------*- C++ -*-===//
+//===-- GDBRemoteSignals.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/GDBRemoteSignals.h b/lldb/source/Plugins/Process/Utility/GDBRemoteSignals.h
index a02dd0604e67..d37757ab60a5 100644
--- a/lldb/source/Plugins/Process/Utility/GDBRemoteSignals.h
+++ b/lldb/source/Plugins/Process/Utility/GDBRemoteSignals.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_GDBRemoteSignals_H_
-#define liblldb_GDBRemoteSignals_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_GDBREMOTESIGNALS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_GDBREMOTESIGNALS_H
#include "lldb/Target/UnixSignals.h"
@@ -26,4 +26,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_GDBRemoteSignals_H_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_GDBREMOTESIGNALS_H
diff --git a/lldb/source/Plugins/Process/Utility/HistoryThread.cpp b/lldb/source/Plugins/Process/Utility/HistoryThread.cpp
index 295c17e474fb..d73b132539f1 100644
--- a/lldb/source/Plugins/Process/Utility/HistoryThread.cpp
+++ b/lldb/source/Plugins/Process/Utility/HistoryThread.cpp
@@ -1,4 +1,4 @@
-//===-- HistoryThread.cpp ---------------------------------------*- C++ -*-===//
+//===-- HistoryThread.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -25,12 +25,14 @@ using namespace lldb_private;
// Constructor
HistoryThread::HistoryThread(lldb_private::Process &process, lldb::tid_t tid,
- std::vector<lldb::addr_t> pcs)
+ std::vector<lldb::addr_t> pcs,
+ bool pcs_are_call_addresses)
: Thread(process, tid, true), m_framelist_mutex(), m_framelist(),
m_pcs(pcs), m_extended_unwind_token(LLDB_INVALID_ADDRESS), m_queue_name(),
m_thread_name(), m_originating_unique_thread_id(tid),
m_queue_id(LLDB_INVALID_QUEUE_ID) {
- m_unwinder_up.reset(new HistoryUnwind(*this, pcs));
+ m_unwinder_up =
+ std::make_unique<HistoryUnwind>(*this, pcs, pcs_are_call_addresses);
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
LLDB_LOGF(log, "%p HistoryThread::HistoryThread", static_cast<void *>(this));
}
diff --git a/lldb/source/Plugins/Process/Utility/HistoryThread.h b/lldb/source/Plugins/Process/Utility/HistoryThread.h
index 1e2658640172..a66e0f2d4207 100644
--- a/lldb/source/Plugins/Process/Utility/HistoryThread.h
+++ b/lldb/source/Plugins/Process/Utility/HistoryThread.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_HistoryThread_h_
-#define liblldb_HistoryThread_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_HISTORYTHREAD_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_HISTORYTHREAD_H
#include <mutex>
@@ -33,7 +33,8 @@ namespace lldb_private {
class HistoryThread : public lldb_private::Thread {
public:
HistoryThread(lldb_private::Process &process, lldb::tid_t tid,
- std::vector<lldb::addr_t> pcs);
+ std::vector<lldb::addr_t> pcs,
+ bool pcs_are_call_addresses = false);
~HistoryThread() override;
@@ -88,4 +89,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_HistoryThread_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_HISTORYTHREAD_H
diff --git a/lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp b/lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp
index 83fdb011f5a1..9b9522955de9 100644
--- a/lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp
+++ b/lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp
@@ -1,4 +1,4 @@
-//===-- HistoryUnwind.cpp ---------------------------------------*- C++ -*-===//
+//===-- HistoryUnwind.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -23,8 +23,10 @@ using namespace lldb_private;
// Constructor
-HistoryUnwind::HistoryUnwind(Thread &thread, std::vector<lldb::addr_t> pcs)
- : Unwind(thread), m_pcs(pcs) {}
+HistoryUnwind::HistoryUnwind(Thread &thread, std::vector<lldb::addr_t> pcs,
+ bool pcs_are_call_addresses)
+ : Unwind(thread), m_pcs(pcs),
+ m_pcs_are_call_addresses(pcs_are_call_addresses) {}
// Destructor
@@ -59,7 +61,10 @@ bool HistoryUnwind::DoGetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa,
if (frame_idx < m_pcs.size()) {
cfa = frame_idx;
pc = m_pcs[frame_idx];
- behaves_like_zeroth_frame = (frame_idx == 0);
+ if (m_pcs_are_call_addresses)
+ behaves_like_zeroth_frame = true;
+ else
+ behaves_like_zeroth_frame = (frame_idx == 0);
return true;
}
return false;
diff --git a/lldb/source/Plugins/Process/Utility/HistoryUnwind.h b/lldb/source/Plugins/Process/Utility/HistoryUnwind.h
index 4d16608bd8c2..cb72b5d0a176 100644
--- a/lldb/source/Plugins/Process/Utility/HistoryUnwind.h
+++ b/lldb/source/Plugins/Process/Utility/HistoryUnwind.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_HistoryUnwind_h_
-#define liblldb_HistoryUnwind_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_HISTORYUNWIND_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_HISTORYUNWIND_H
#include <vector>
@@ -18,7 +18,8 @@ namespace lldb_private {
class HistoryUnwind : public lldb_private::Unwind {
public:
- HistoryUnwind(Thread &thread, std::vector<lldb::addr_t> pcs);
+ HistoryUnwind(Thread &thread, std::vector<lldb::addr_t> pcs,
+ bool pcs_are_call_addresses = false);
~HistoryUnwind() override;
@@ -35,8 +36,11 @@ protected:
private:
std::vector<lldb::addr_t> m_pcs;
+ /// This boolean indicates that the PCs in the non-0 frames are call
+ /// addresses and not return addresses.
+ bool m_pcs_are_call_addresses;
};
} // namespace lldb_private
-#endif // liblldb_HistoryUnwind_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_HISTORYUNWIND_H
diff --git a/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp b/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
index ee939b01d350..0f331933f2ea 100644
--- a/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
+++ b/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
@@ -1,4 +1,4 @@
-//===-- InferiorCallPOSIX.cpp -----------------------------------*- C++ -*-===//
+//===-- InferiorCallPOSIX.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.h b/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.h
index 2008c5fe0b91..3623e10194f9 100644
--- a/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.h
+++ b/lldb/source/Plugins/Process/Utility/InferiorCallPOSIX.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_InferiorCallPOSIX_h_
-#define lldb_InferiorCallPOSIX_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_INFERIORCALLPOSIX_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_INFERIORCALLPOSIX_H
// Inferior execution of POSIX functions.
@@ -32,4 +32,4 @@ bool InferiorCallMunmap(Process *proc, lldb::addr_t addr, lldb::addr_t length);
} // namespace lldb_private
-#endif // lldb_InferiorCallPOSIX_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_INFERIORCALLPOSIX_H
diff --git a/lldb/source/Plugins/Process/Utility/InstructionUtils.h b/lldb/source/Plugins/Process/Utility/InstructionUtils.h
index f74933e691ee..55b89440700b 100644
--- a/lldb/source/Plugins/Process/Utility/InstructionUtils.h
+++ b/lldb/source/Plugins/Process/Utility/InstructionUtils.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_InstructionUtils_h_
-#define lldb_InstructionUtils_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_INSTRUCTIONUTILS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_INSTRUCTIONUTILS_H
#include <cassert>
#include <cstdint>
@@ -113,4 +113,4 @@ static inline int64_t SignedBits(const uint64_t value, const uint64_t msbit,
} // namespace lldb_private
-#endif // lldb_InstructionUtils_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_INSTRUCTIONUTILS_H
diff --git a/lldb/source/Plugins/Process/Utility/LinuxProcMaps.cpp b/lldb/source/Plugins/Process/Utility/LinuxProcMaps.cpp
index 1ba432aa542b..0c7d9ddc5ac6 100644
--- a/lldb/source/Plugins/Process/Utility/LinuxProcMaps.cpp
+++ b/lldb/source/Plugins/Process/Utility/LinuxProcMaps.cpp
@@ -1,4 +1,4 @@
-//===-- LinuxProcMaps.cpp ---------------------------------------*- C++ -*-===//
+//===-- LinuxProcMaps.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/LinuxProcMaps.h b/lldb/source/Plugins/Process/Utility/LinuxProcMaps.h
index e1f0e48ac5c9..363f248fd416 100644
--- a/lldb/source/Plugins/Process/Utility/LinuxProcMaps.h
+++ b/lldb/source/Plugins/Process/Utility/LinuxProcMaps.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_LinuxProcMaps_H_
-#define liblldb_LinuxProcMaps_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LINUXPROCMAPS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LINUXPROCMAPS_H
#include "lldb/lldb-forward.h"
#include "llvm/ADT/StringRef.h"
@@ -24,4 +24,4 @@ void ParseLinuxMapRegions(llvm::StringRef linux_map,
} // namespace lldb_private
-#endif // liblldb_LinuxProcMaps_H_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LINUXPROCMAPS_H
diff --git a/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp b/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
index bef47cd26307..4dd619e3bade 100644
--- a/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
+++ b/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
@@ -1,4 +1,4 @@
-//===-- LinuxSignals.cpp ----------------------------------------*- C++ -*-===//
+//===-- LinuxSignals.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/LinuxSignals.h b/lldb/source/Plugins/Process/Utility/LinuxSignals.h
index 7ad8cfcbef68..32c4744a96d0 100644
--- a/lldb/source/Plugins/Process/Utility/LinuxSignals.h
+++ b/lldb/source/Plugins/Process/Utility/LinuxSignals.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_LinuxSignals_H_
-#define liblldb_LinuxSignals_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LINUXSIGNALS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LINUXSIGNALS_H
#include "lldb/Target/UnixSignals.h"
@@ -24,4 +24,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_LinuxSignals_H_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LINUXSIGNALS_H
diff --git a/lldb/source/Plugins/Process/Utility/MipsLinuxSignals.cpp b/lldb/source/Plugins/Process/Utility/MipsLinuxSignals.cpp
index d8e5426ab5a5..8f75844277c0 100644
--- a/lldb/source/Plugins/Process/Utility/MipsLinuxSignals.cpp
+++ b/lldb/source/Plugins/Process/Utility/MipsLinuxSignals.cpp
@@ -1,5 +1,4 @@
-//===-- MipsLinuxSignals.cpp ----------------------------------------*- C++
-//-*-===//
+//===-- MipsLinuxSignals.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/MipsLinuxSignals.h b/lldb/source/Plugins/Process/Utility/MipsLinuxSignals.h
index b5e3ed86f568..6b78fc72a91c 100644
--- a/lldb/source/Plugins/Process/Utility/MipsLinuxSignals.h
+++ b/lldb/source/Plugins/Process/Utility/MipsLinuxSignals.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_MipsLinuxSignals_H_
-#define liblldb_MipsLinuxSignals_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_MIPSLINUXSIGNALS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_MIPSLINUXSIGNALS_H
#include "lldb/Target/UnixSignals.h"
@@ -25,4 +25,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_MipsLinuxSignals_H_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_MIPSLINUXSIGNALS_H
diff --git a/lldb/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp b/lldb/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp
index be61cfdd7374..3a875f7bb39b 100644
--- a/lldb/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp
+++ b/lldb/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp
@@ -1,4 +1,4 @@
-//===-- NativeRegisterContextRegisterInfo.cpp -------------------*- C++ -*-===//
+//===-- NativeRegisterContextRegisterInfo.cpp -----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h b/lldb/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h
index b285c477cd96..0e96841fd909 100644
--- a/lldb/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h
+++ b/lldb/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_PLUGINS_PROCESS_UTIILTY_NATIVE_REGISTER_CONTEXT_REGISTER_INFO
-#define LLDB_PLUGINS_PROCESS_UTIILTY_NATIVE_REGISTER_CONTEXT_REGISTER_INFO
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_NATIVEREGISTERCONTEXTREGISTERINFO_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_NATIVEREGISTERCONTEXTREGISTERINFO_H
#include <memory>
@@ -33,7 +33,7 @@ public:
const RegisterInfoInterface &GetRegisterInfoInterface() const;
-private:
+protected:
std::unique_ptr<RegisterInfoInterface> m_register_info_interface_up;
};
}
diff --git a/lldb/source/Plugins/Process/Utility/NetBSDSignals.cpp b/lldb/source/Plugins/Process/Utility/NetBSDSignals.cpp
index 29967deb7e9b..ffdfd19b4efe 100644
--- a/lldb/source/Plugins/Process/Utility/NetBSDSignals.cpp
+++ b/lldb/source/Plugins/Process/Utility/NetBSDSignals.cpp
@@ -1,4 +1,4 @@
-//===-- NetBSDSignals.cpp --------------------------------------*- C++ -*-===//
+//===-- NetBSDSignals.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/NetBSDSignals.h b/lldb/source/Plugins/Process/Utility/NetBSDSignals.h
index bf7399a89060..e6740a304a02 100644
--- a/lldb/source/Plugins/Process/Utility/NetBSDSignals.h
+++ b/lldb/source/Plugins/Process/Utility/NetBSDSignals.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_NetBSDSignals_H_
-#define liblldb_NetBSDSignals_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_NETBSDSIGNALS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_NETBSDSIGNALS_H
#include "lldb/Target/UnixSignals.h"
@@ -24,4 +24,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_NetBSDSignals_H_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_NETBSDSIGNALS_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h b/lldb/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h
index ef40162984f1..21582df91fb0 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_REGISTERCONTEXTDARWINCONSTANTS_H
-#define LLDB_REGISTERCONTEXTDARWINCONSTANTS_H
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDARWINCONSTANTS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDARWINCONSTANTS_H
namespace lldb_private {
@@ -22,4 +22,4 @@ namespace lldb_private {
} // namespace lldb_private
-#endif // LLDB_REGISTERCONTEXTDARWINCONSTANTS_H
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDARWINCONSTANTS_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
index 173e66904151..eef4541e7edd 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextDarwin_arm.cpp ---------------------------*- C++ -*-===//
+//===-- RegisterContextDarwin_arm.cpp -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h
index d7c1809a3222..1bd60f756487 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextDarwin_arm_h_
-#define liblldb_RegisterContextDarwin_arm_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDARWIN_ARM_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDARWIN_ARM_H
#include "lldb/Target/RegisterContext.h"
#include "lldb/lldb-private.h"
@@ -261,4 +261,4 @@ protected:
static const lldb_private::RegisterInfo *GetRegisterInfos();
};
-#endif // liblldb_RegisterContextDarwin_arm_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDARWIN_ARM_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
index fa5197cd6bf4..9fc275276699 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
@@ -1,5 +1,4 @@
-//===-- RegisterContextDarwin_arm64.cpp ---------------------------*- C++
-//-*-===//
+//===-- RegisterContextDarwin_arm64.cpp -----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h
index abb87e3c2348..010e566be32c 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextDarwin_arm64_h_
-#define liblldb_RegisterContextDarwin_arm64_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDARWIN_ARM64_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDARWIN_ARM64_H
#include "lldb/Target/RegisterContext.h"
#include "lldb/lldb-private.h"
@@ -228,4 +228,4 @@ protected:
static const lldb_private::RegisterInfo *GetRegisterInfos();
};
-#endif // liblldb_RegisterContextDarwin_arm64_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDARWIN_ARM64_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp
index 959b04700b17..c5ebddc56b6c 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextDarwin_i386.cpp --------------------------*- C++ -*-===//
+//===-- RegisterContextDarwin_i386.cpp ------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h
index e52f0fe63250..9c759c31caed 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextDarwin_i386_h_
-#define liblldb_RegisterContextDarwin_i386_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDARWIN_I386_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDARWIN_I386_H
#include "lldb/Target/RegisterContext.h"
#include "lldb/lldb-private.h"
@@ -205,4 +205,4 @@ protected:
static const lldb_private::RegisterInfo *GetRegisterInfos();
};
-#endif // liblldb_RegisterContextDarwin_i386_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDARWIN_I386_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
index 22088a7d6448..38cd00aea9cc 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextDarwin_x86_64.cpp ------------------------*- C++ -*-===//
+//===-- RegisterContextDarwin_x86_64.cpp ----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h
index 1a65a4f28b33..d9ba8d0b2319 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextDarwin_x86_64_h_
-#define liblldb_RegisterContextDarwin_x86_64_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDARWIN_X86_64_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDARWIN_X86_64_H
#include "lldb/Target/RegisterContext.h"
#include "lldb/lldb-private.h"
@@ -210,4 +210,4 @@ protected:
static const lldb_private::RegisterInfo *GetRegisterInfos();
};
-#endif // liblldb_RegisterContextDarwin_x86_64_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDARWIN_X86_64_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDummy.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextDummy.cpp
index 6832b6095931..4c2e291c62d6 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextDummy.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextDummy.cpp
@@ -1,5 +1,4 @@
-//===-- RegisterContextDummy.cpp ---------------------------------*- C++
-//-*-===//
+//===-- RegisterContextDummy.cpp ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDummy.h b/lldb/source/Plugins/Process/Utility/RegisterContextDummy.h
index bdaa2217d207..de98767693fe 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextDummy.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextDummy.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_RegisterContextDummy_h_
-#define lldb_RegisterContextDummy_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDUMMY_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDUMMY_H
#include <vector>
@@ -56,9 +56,10 @@ private:
lldb_private::RegisterSet m_reg_set0; // register set 0 (PC only)
lldb_private::RegisterInfo m_pc_reg_info;
- DISALLOW_COPY_AND_ASSIGN(RegisterContextDummy);
+ RegisterContextDummy(const RegisterContextDummy &) = delete;
+ const RegisterContextDummy &operator=(const RegisterContextDummy &) = delete;
};
} // namespace lldb_private
-#endif // lldb_RegisterContextDummy_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTDUMMY_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp
index b90b38108267..10d346a3cb7e 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextFreeBSD_i386.cpp ------------------------*- C++ -*-===//
+//===-- RegisterContextFreeBSD_i386.cpp -----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.h b/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.h
index 7aadf3a0a4c9..5a3e5b0551d6 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextFreeBSD_i386_H_
-#define liblldb_RegisterContextFreeBSD_i386_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTFREEBSD_I386_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTFREEBSD_I386_H
#include "RegisterInfoInterface.h"
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp
index 4331ef5ad14e..0c5d34f345db 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextFreeBSD_mips64.cpp ----------------------*- C++ -*-===//
+//===-- RegisterContextFreeBSD_mips64.cpp ---------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h b/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h
index 96f02b4440c5..39968eacf475 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextFreeBSD_mips64_H_
-#define liblldb_RegisterContextFreeBSD_mips64_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTFREEBSD_MIPS64_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTFREEBSD_MIPS64_H
#include "RegisterInfoInterface.h"
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.cpp
index 4f869eb3b177..9fe6255d698e 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextFreeBSD_powerpc.cpp ----------------------*- C++ -*-===//
+//===-- RegisterContextFreeBSD_powerpc.cpp --------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h b/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h
index ba2751194d16..7e4c43ba908a 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextFreeBSD_powerpc_h_
-#define liblldb_RegisterContextFreeBSD_powerpc_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTFREEBSD_POWERPC_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTFREEBSD_POWERPC_H
#include "RegisterInfoInterface.h"
@@ -49,4 +49,4 @@ public:
uint32_t GetRegisterCount() const override;
};
-#endif // liblldb_RegisterContextFreeBSD_powerpc_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTFREEBSD_POWERPC_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp
index bcf3951ee077..c1f390ade9b9 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextFreeBSD_x86_64.cpp ----------------------*- C++ -*-===//
+//===-- RegisterContextFreeBSD_x86_64.cpp ---------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h b/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h
index c379e1a5cd75..d0f69fde1817 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextFreeBSD_x86_64_H_
-#define liblldb_RegisterContextFreeBSD_x86_64_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTFREEBSD_X86_64_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTFREEBSD_X86_64_H
#include "RegisterInfoInterface.h"
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextHistory.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextHistory.cpp
index c19a2bfae668..577958738900 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextHistory.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextHistory.cpp
@@ -1,5 +1,4 @@
-//===-- RegisterContextHistory.cpp ---------------------------------*- C++
-//-*-===//
+//===-- RegisterContextHistory.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextHistory.h b/lldb/source/Plugins/Process/Utility/RegisterContextHistory.h
index 952e4263d955..407640d2bdb9 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextHistory.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextHistory.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_RegisterContextHistory_h_
-#define lldb_RegisterContextHistory_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTHISTORY_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTHISTORY_H
#include <vector>
@@ -58,8 +58,10 @@ private:
lldb::addr_t m_pc_value;
- DISALLOW_COPY_AND_ASSIGN(RegisterContextHistory);
+ RegisterContextHistory(const RegisterContextHistory &) = delete;
+ const RegisterContextHistory &
+ operator=(const RegisterContextHistory &) = delete;
};
} // namespace lldb_private
-#endif // lldb_RegisterContextHistory_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTHISTORY_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
index 79979639dc7e..518dc273faf4 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextLinux_i386.cpp --------------------------*- C++ -*-===//
+//===-- RegisterContextLinux_i386.cpp -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.h b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
index 5567a1ac42e5..ef731a5a7994 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextLinux_i386_H_
-#define liblldb_RegisterContextLinux_i386_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTLINUX_I386_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTLINUX_I386_H
#include "RegisterInfoInterface.h"
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp
index fc60fea79176..837549e2a495 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextLinux_mips.cpp ------------------------*- C++ -*-===//
+//===-- RegisterContextLinux_mips.cpp -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips.h b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips.h
index e637dfc15e4d..9b59ab421ff4 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextLinux_mips_H_
-#define liblldb_RegisterContextLinux_mips_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTLINUX_MIPS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTLINUX_MIPS_H
#include "RegisterInfoInterface.h"
#include "lldb/lldb-private.h"
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp
index 3927883c47a4..432a78129fde 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextLinux_mips64.cpp ------------------------*- C++ -*-===//
+//===-- RegisterContextLinux_mips64.cpp -----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h
index ca0f0140a22d..899f0a40e4ae 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextLinux_mips64_H_
-#define liblldb_RegisterContextLinux_mips64_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTLINUX_MIPS64_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTLINUX_MIPS64_H
#include "RegisterInfoInterface.h"
#include "lldb/lldb-private.h"
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_s390x.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_s390x.cpp
index d6401d788ab2..7a8989cd1225 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_s390x.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_s390x.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextLinux_s390x.cpp --------------------------*- C++ -*-===//
+//===-- RegisterContextLinux_s390x.cpp ------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_s390x.h b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_s390x.h
index 10810c97af80..f381f38ecbf9 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_s390x.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_s390x.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextLinux_s390x_h_
-#define liblldb_RegisterContextLinux_s390x_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTLINUX_S390X_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTLINUX_S390X_H
#include "RegisterInfoInterface.h"
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
index 640d5bc02256..f9d4e23fcde2 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextLinux_x86_64.cpp ------------------------*- C++ -*-===//
+//===-- RegisterContextLinux_x86_64.cpp -----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
index 02f273cb02c9..ea21b913d5c5 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextLinux_x86_64_H_
-#define liblldb_RegisterContextLinux_x86_64_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTLINUX_X86_64_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTLINUX_X86_64_H
#include "RegisterInfoInterface.h"
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp
deleted file mode 100644
index bc78c1d6160c..000000000000
--- a/lldb/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-//===-- RegisterContextMacOSXFrameBackchain.cpp -----------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "RegisterContextMacOSXFrameBackchain.h"
-
-#include "lldb/Target/Thread.h"
-#include "lldb/Utility/DataBufferHeap.h"
-#include "lldb/Utility/DataExtractor.h"
-#include "lldb/Utility/RegisterValue.h"
-#include "lldb/Utility/Scalar.h"
-#include "lldb/Utility/StreamString.h"
-#include "lldb/Utility/StringExtractorGDBRemote.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-// RegisterContextMacOSXFrameBackchain constructor
-RegisterContextMacOSXFrameBackchain::RegisterContextMacOSXFrameBackchain(
- Thread &thread, uint32_t concrete_frame_idx,
- const UnwindMacOSXFrameBackchain::Cursor &cursor)
- : RegisterContext(thread, concrete_frame_idx), m_cursor(cursor),
- m_cursor_is_valid(true) {}
-
-// Destructor
-RegisterContextMacOSXFrameBackchain::~RegisterContextMacOSXFrameBackchain() {}
-
-void RegisterContextMacOSXFrameBackchain::InvalidateAllRegisters() {
- m_cursor_is_valid = false;
-}
-
-size_t RegisterContextMacOSXFrameBackchain::GetRegisterCount() {
- return m_thread.GetRegisterContext()->GetRegisterCount();
-}
-
-const RegisterInfo *
-RegisterContextMacOSXFrameBackchain::GetRegisterInfoAtIndex(size_t reg) {
- return m_thread.GetRegisterContext()->GetRegisterInfoAtIndex(reg);
-}
-
-size_t RegisterContextMacOSXFrameBackchain::GetRegisterSetCount() {
- return m_thread.GetRegisterContext()->GetRegisterSetCount();
-}
-
-const RegisterSet *
-RegisterContextMacOSXFrameBackchain::GetRegisterSet(size_t reg_set) {
- return m_thread.GetRegisterContext()->GetRegisterSet(reg_set);
-}
-
-bool RegisterContextMacOSXFrameBackchain::ReadRegister(
- const RegisterInfo *reg_info, RegisterValue &value) {
- if (!m_cursor_is_valid)
- return false;
-
- uint64_t reg_value = LLDB_INVALID_ADDRESS;
-
- switch (reg_info->kinds[eRegisterKindGeneric]) {
- case LLDB_REGNUM_GENERIC_PC:
- if (m_cursor.pc == LLDB_INVALID_ADDRESS)
- return false;
- reg_value = m_cursor.pc;
- break;
-
- case LLDB_REGNUM_GENERIC_FP:
- if (m_cursor.fp == LLDB_INVALID_ADDRESS)
- return false;
- reg_value = m_cursor.fp;
- break;
-
- default:
- return false;
- }
-
- switch (reg_info->encoding) {
- case eEncodingInvalid:
- case eEncodingVector:
- break;
-
- case eEncodingUint:
- case eEncodingSint:
- value.SetUInt(reg_value, reg_info->byte_size);
- return true;
-
- case eEncodingIEEE754:
- switch (reg_info->byte_size) {
- case sizeof(float):
- if (sizeof(float) == sizeof(uint32_t)) {
- value.SetUInt32(reg_value, RegisterValue::eTypeFloat);
- return true;
- } else if (sizeof(float) == sizeof(uint64_t)) {
- value.SetUInt64(reg_value, RegisterValue::eTypeFloat);
- return true;
- }
- break;
-
- case sizeof(double):
- if (sizeof(double) == sizeof(uint32_t)) {
- value.SetUInt32(reg_value, RegisterValue::eTypeDouble);
- return true;
- } else if (sizeof(double) == sizeof(uint64_t)) {
- value.SetUInt64(reg_value, RegisterValue::eTypeDouble);
- return true;
- }
- break;
-
-// TOOD: need a better way to detect when "long double" types are
-// the same bytes size as "double"
-#if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__) && \
- !defined(_MSC_VER) && !defined(__mips__) && !defined(__powerpc__) && \
- !defined(__ANDROID__)
- case sizeof(long double):
- if (sizeof(long double) == sizeof(uint32_t)) {
- value.SetUInt32(reg_value, RegisterValue::eTypeLongDouble);
- return true;
- } else if (sizeof(long double) == sizeof(uint64_t)) {
- value.SetUInt64(reg_value, RegisterValue::eTypeLongDouble);
- return true;
- }
- break;
-#endif
- }
- break;
- }
- return false;
-}
-
-bool RegisterContextMacOSXFrameBackchain::WriteRegister(
- const RegisterInfo *reg_info, const RegisterValue &value) {
- // Not supported yet. We could easily add support for this by remembering the
- // address of each entry (it would need to be part of the cursor)
- return false;
-}
-
-bool RegisterContextMacOSXFrameBackchain::ReadAllRegisterValues(
- lldb::DataBufferSP &data_sp) {
- // libunwind frames can't handle this it doesn't always have all register
- // values. This call should only be called on frame zero anyway so there
- // shouldn't be any problem
- return false;
-}
-
-bool RegisterContextMacOSXFrameBackchain::WriteAllRegisterValues(
- const lldb::DataBufferSP &data_sp) {
- // Since this class doesn't respond to "ReadAllRegisterValues()", it must not
- // have been the one that saved all the register values. So we just let the
- // thread's register context (the register context for frame zero) do the
- // writing.
- return m_thread.GetRegisterContext()->WriteAllRegisterValues(data_sp);
-}
-
-uint32_t
-RegisterContextMacOSXFrameBackchain::ConvertRegisterKindToRegisterNumber(
- lldb::RegisterKind kind, uint32_t num) {
- return m_thread.GetRegisterContext()->ConvertRegisterKindToRegisterNumber(
- kind, num);
-}
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h b/lldb/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h
deleted file mode 100644
index 36e5538daa8a..000000000000
--- a/lldb/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h
+++ /dev/null
@@ -1,56 +0,0 @@
-//===-- RegisterContextMacOSXFrameBackchain.h -------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef lldb_RegisterContextMacOSXFrameBackchain_h_
-#define lldb_RegisterContextMacOSXFrameBackchain_h_
-
-#include "lldb/Target/RegisterContext.h"
-#include "lldb/lldb-private.h"
-
-#include "UnwindMacOSXFrameBackchain.h"
-
-class RegisterContextMacOSXFrameBackchain
- : public lldb_private::RegisterContext {
-public:
- RegisterContextMacOSXFrameBackchain(
- lldb_private::Thread &thread, uint32_t concrete_frame_idx,
- const UnwindMacOSXFrameBackchain::Cursor &cursor);
-
- ~RegisterContextMacOSXFrameBackchain() override;
-
- void InvalidateAllRegisters() override;
-
- size_t GetRegisterCount() override;
-
- const lldb_private::RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override;
-
- size_t GetRegisterSetCount() override;
-
- const lldb_private::RegisterSet *GetRegisterSet(size_t reg_set) override;
-
- bool ReadRegister(const lldb_private::RegisterInfo *reg_info,
- lldb_private::RegisterValue &value) override;
-
- bool WriteRegister(const lldb_private::RegisterInfo *reg_info,
- const lldb_private::RegisterValue &value) override;
-
- bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
-
- bool WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
-
- uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
- uint32_t num) override;
-
-private:
- UnwindMacOSXFrameBackchain::Cursor m_cursor;
- bool m_cursor_is_valid;
-
- DISALLOW_COPY_AND_ASSIGN(RegisterContextMacOSXFrameBackchain);
-};
-
-#endif // lldb_RegisterContextMacOSXFrameBackchain_h_
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp
index c7042ab5137a..1394cb7f00a1 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextMach_arm.cpp -----------------------------*- C++ -*-===//
+//===-- RegisterContextMach_arm.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextMach_arm.h b/lldb/source/Plugins/Process/Utility/RegisterContextMach_arm.h
index 8b2425a193be..e7c180dbdd27 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextMach_arm.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextMach_arm.h
@@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextMach_arm_h_
-#define liblldb_RegisterContextMach_arm_h_
-
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTMACH_ARM_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTMACH_ARM_H
#include "RegisterContextDarwin_arm.h"
@@ -37,4 +36,4 @@ protected:
int DoWriteDBG(lldb::tid_t tid, int flavor, const DBG &dbg);
};
-#endif // liblldb_RegisterContextMach_arm_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTMACH_ARM_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp
index e631ab9bb26c..b97166b6eebe 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextMach_i386.cpp ----------------------------*- C++ -*-===//
+//===-- RegisterContextMach_i386.cpp --------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextMach_i386.h b/lldb/source/Plugins/Process/Utility/RegisterContextMach_i386.h
index b8835561e98c..09966be60c92 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextMach_i386.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextMach_i386.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextMach_i386_h_
-#define liblldb_RegisterContextMach_i386_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTMACH_I386_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTMACH_I386_H
#include "RegisterContextDarwin_i386.h"
@@ -32,4 +32,4 @@ protected:
int DoWriteEXC(lldb::tid_t tid, int flavor, const EXC &exc);
};
-#endif // liblldb_RegisterContextMach_i386_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTMACH_I386_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp
index db17d7d88778..8933f136789f 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextMach_x86_64.cpp --------------------------*- C++ -*-===//
+//===-- RegisterContextMach_x86_64.cpp ------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextMach_x86_64.h b/lldb/source/Plugins/Process/Utility/RegisterContextMach_x86_64.h
index 688009aef8af..2a8a2cca2f8a 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextMach_x86_64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextMach_x86_64.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextMach_x86_64_h_
-#define liblldb_RegisterContextMach_x86_64_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTMACH_X86_64_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTMACH_X86_64_H
#include "RegisterContextDarwin_x86_64.h"
@@ -33,4 +33,4 @@ protected:
int DoWriteEXC(lldb::tid_t tid, int flavor, const EXC &exc);
};
-#endif // liblldb_RegisterContextMach_x86_64_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTMACH_X86_64_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextMemory.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextMemory.cpp
index 946d4fa9f8e5..f2d230b54053 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextMemory.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextMemory.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextMemory.cpp -------------------------------*- C++ -*-===//
+//===-- RegisterContextMemory.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextMemory.h b/lldb/source/Plugins/Process/Utility/RegisterContextMemory.h
index 68223eaeffd7..764ee9b97211 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextMemory.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextMemory.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_RegisterContextMemory_h_
-#define lldb_RegisterContextMemory_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTMEMORY_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTMEMORY_H
#include <vector>
@@ -67,7 +67,9 @@ protected:
// context that is stored in memmory
private:
- DISALLOW_COPY_AND_ASSIGN(RegisterContextMemory);
+ RegisterContextMemory(const RegisterContextMemory &) = delete;
+ const RegisterContextMemory &
+ operator=(const RegisterContextMemory &) = delete;
};
-#endif // lldb_RegisterContextMemory_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTMEMORY_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.cpp
new file mode 100644
index 000000000000..bd7830e42b42
--- /dev/null
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.cpp
@@ -0,0 +1,96 @@
+//===-- RegisterContextNetBSD_i386.cpp -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===---------------------------------------------------------------------===//
+
+#include "RegisterContextNetBSD_i386.h"
+#include "RegisterContextPOSIX_x86.h"
+
+using namespace lldb_private;
+using namespace lldb;
+
+// this needs to match 'struct reg'
+struct GPR {
+ uint32_t eax;
+ uint32_t ecx;
+ uint32_t edx;
+ uint32_t ebx;
+ uint32_t esp;
+ uint32_t ebp;
+ uint32_t esi;
+ uint32_t edi;
+ uint32_t eip;
+ uint32_t eflags;
+ uint32_t cs;
+ uint32_t ss;
+ uint32_t ds;
+ uint32_t es;
+ uint32_t fs;
+ uint32_t gs;
+};
+
+struct FPR_i386 {
+ uint16_t fctrl; // FPU Control Word (fcw)
+ uint16_t fstat; // FPU Status Word (fsw)
+ uint16_t ftag; // FPU Tag Word (ftw)
+ uint16_t fop; // Last Instruction Opcode (fop)
+ union {
+ struct {
+ uint64_t fip; // Instruction Pointer
+ uint64_t fdp; // Data Pointer
+ } x86_64;
+ struct {
+ uint32_t fioff; // FPU IP Offset (fip)
+ uint32_t fiseg; // FPU IP Selector (fcs)
+ uint32_t fooff; // FPU Operand Pointer Offset (foo)
+ uint32_t foseg; // FPU Operand Pointer Selector (fos)
+ } i386_; // Added _ in the end to avoid error with gcc defining i386 in some
+ // cases
+ } ptr;
+ uint32_t mxcsr; // MXCSR Register State
+ uint32_t mxcsrmask; // MXCSR Mask
+ MMSReg stmm[8]; // 8*16 bytes for each FP-reg = 128 bytes
+ XMMReg xmm[8]; // 8*16 bytes for each XMM-reg = 128 bytes
+ uint32_t padding[56];
+};
+
+struct UserArea {
+ GPR gpr;
+ FPR_i386 i387;
+ uint32_t u_debugreg[8]; // Debug registers (DR0 - DR7).
+ uint32_t tlsbase;
+};
+
+#define DR_SIZE sizeof(((UserArea *)NULL)->u_debugreg[0])
+#define DR_OFFSET(reg_index) \
+ (LLVM_EXTENSION offsetof(UserArea, u_debugreg[reg_index]))
+
+// Include RegisterInfos_i386 to declare our g_register_infos_i386 structure.
+#define DECLARE_REGISTER_INFOS_I386_STRUCT
+#include "RegisterInfos_i386.h"
+#undef DECLARE_REGISTER_INFOS_I386_STRUCT
+
+RegisterContextNetBSD_i386::RegisterContextNetBSD_i386(
+ const ArchSpec &target_arch)
+ : RegisterInfoInterface(target_arch) {}
+
+size_t RegisterContextNetBSD_i386::GetGPRSize() const { return sizeof(GPR); }
+
+const RegisterInfo *RegisterContextNetBSD_i386::GetRegisterInfo() const {
+ switch (m_target_arch.GetMachine()) {
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
+ return g_register_infos_i386;
+ default:
+ assert(false && "Unhandled target architecture.");
+ return nullptr;
+ }
+}
+
+uint32_t RegisterContextNetBSD_i386::GetRegisterCount() const {
+ return static_cast<uint32_t>(sizeof(g_register_infos_i386) /
+ sizeof(g_register_infos_i386[0]));
+}
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.h b/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.h
new file mode 100644
index 000000000000..742bb18b8306
--- /dev/null
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_i386.h
@@ -0,0 +1,25 @@
+//===-- RegisterContextNetBSD_i386.h ----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTNETBSD_I386_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTNETBSD_I386_H
+
+#include "RegisterInfoInterface.h"
+
+class RegisterContextNetBSD_i386 : public lldb_private::RegisterInfoInterface {
+public:
+ RegisterContextNetBSD_i386(const lldb_private::ArchSpec &target_arch);
+
+ size_t GetGPRSize() const override;
+
+ const lldb_private::RegisterInfo *GetRegisterInfo() const override;
+
+ uint32_t GetRegisterCount() const override;
+};
+
+#endif
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp
index e620ff66c922..21aad92ecda8 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextNetBSD_x86_64.cpp ------------------------*- C++ -*-===//
+//===-- RegisterContextNetBSD_x86_64.cpp ----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "RegisterContextNetBSD_x86_64.h"
+#include "RegisterContextNetBSD_i386.h"
#include "RegisterContextPOSIX_x86.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Support/Compiler.h"
@@ -83,9 +84,40 @@ struct UserArea {
#include "RegisterInfos_x86_64.h"
#undef DECLARE_REGISTER_INFOS_X86_64_STRUCT
+static std::vector<lldb_private::RegisterInfo> &GetPrivateRegisterInfoVector() {
+ static std::vector<lldb_private::RegisterInfo> g_register_infos;
+ return g_register_infos;
+}
+
+static const RegisterInfo *
+GetRegisterInfo_i386(const lldb_private::ArchSpec &arch) {
+ std::vector<lldb_private::RegisterInfo> &g_register_infos =
+ GetPrivateRegisterInfoVector();
+
+ // Allocate RegisterInfo only once
+ if (g_register_infos.empty()) {
+ // Copy the register information from base class
+ std::unique_ptr<RegisterContextNetBSD_i386> reg_interface(
+ new RegisterContextNetBSD_i386(arch));
+ const RegisterInfo *base_info = reg_interface->GetRegisterInfo();
+ g_register_infos.insert(g_register_infos.end(), &base_info[0],
+ &base_info[k_num_registers_i386]);
+
+// Include RegisterInfos_x86_64 to update the g_register_infos structure
+// with x86_64 offsets.
+#define UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS
+#include "RegisterInfos_x86_64.h"
+#undef UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS
+ }
+
+ return &g_register_infos[0];
+}
+
static const RegisterInfo *
PrivateGetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch) {
switch (target_arch.GetMachine()) {
+ case llvm::Triple::x86:
+ return GetRegisterInfo_i386(target_arch);
case llvm::Triple::x86_64:
return g_register_infos_x86_64;
default:
@@ -97,6 +129,11 @@ PrivateGetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch) {
static uint32_t
PrivateGetRegisterCount(const lldb_private::ArchSpec &target_arch) {
switch (target_arch.GetMachine()) {
+ case llvm::Triple::x86: {
+ assert(!GetPrivateRegisterInfoVector().empty() &&
+ "i386 register info not yet filled.");
+ return static_cast<uint32_t>(GetPrivateRegisterInfoVector().size());
+ }
case llvm::Triple::x86_64:
return static_cast<uint32_t>(sizeof(g_register_infos_x86_64) /
sizeof(g_register_infos_x86_64[0]));
@@ -106,11 +143,25 @@ PrivateGetRegisterCount(const lldb_private::ArchSpec &target_arch) {
}
}
+static uint32_t
+PrivateGetUserRegisterCount(const lldb_private::ArchSpec &target_arch) {
+ switch (target_arch.GetMachine()) {
+ case llvm::Triple::x86:
+ return static_cast<uint32_t>(k_num_user_registers_i386);
+ case llvm::Triple::x86_64:
+ return static_cast<uint32_t>(k_num_user_registers_x86_64);
+ default:
+ assert(false && "Unhandled target architecture.");
+ return 0;
+ }
+}
+
RegisterContextNetBSD_x86_64::RegisterContextNetBSD_x86_64(
const ArchSpec &target_arch)
: lldb_private::RegisterInfoInterface(target_arch),
m_register_info_p(PrivateGetRegisterInfoPtr(target_arch)),
- m_register_count(PrivateGetRegisterCount(target_arch)) {}
+ m_register_count(PrivateGetRegisterCount(target_arch)),
+ m_user_register_count(PrivateGetUserRegisterCount(target_arch)) {}
size_t RegisterContextNetBSD_x86_64::GetGPRSize() const { return sizeof(GPR); }
@@ -121,3 +172,7 @@ const RegisterInfo *RegisterContextNetBSD_x86_64::GetRegisterInfo() const {
uint32_t RegisterContextNetBSD_x86_64::GetRegisterCount() const {
return m_register_count;
}
+
+uint32_t RegisterContextNetBSD_x86_64::GetUserRegisterCount() const {
+ return m_user_register_count;
+}
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h b/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h
index 4820ef8d17ba..b7b8d33b7c37 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextNetBSD_x86_64_H_
-#define liblldb_RegisterContextNetBSD_x86_64_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTNETBSD_X86_64_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTNETBSD_X86_64_H
#include "RegisterInfoInterface.h"
@@ -22,9 +22,12 @@ public:
uint32_t GetRegisterCount() const override;
+ uint32_t GetUserRegisterCount() const override;
+
private:
const lldb_private::RegisterInfo *m_register_info_p;
const uint32_t m_register_count;
+ const uint32_t m_user_register_count;
};
#endif
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp
index 06eac6f7f991..7183ffcfd0f6 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextOpenBSD_i386.cpp ------------------------*- C++ -*-===//
+//===-- RegisterContextOpenBSD_i386.cpp -----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.h b/lldb/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.h
index 992ce0959fdf..e6e24525b7fd 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextOpenBSD_i386_H_
-#define liblldb_RegisterContextOpenBSD_i386_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTOPENBSD_I386_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTOPENBSD_I386_H
#include "RegisterInfoInterface.h"
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp
index e210196d921d..05c1f83efded 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextOpenBSD_x86_64.cpp ----------------------*- C++ -*-===//
+//===-- RegisterContextOpenBSD_x86_64.cpp ---------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h b/lldb/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h
index 9c76e7211132..b399c721546a 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextOpenBSD_x86_64_H_
-#define liblldb_RegisterContextOpenBSD_x86_64_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTOPENBSD_X86_64_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTOPENBSD_X86_64_H
#include "RegisterInfoInterface.h"
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp
index 821e2aa73b5b..617893b6b3b0 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextPOSIX_arm.cpp --------------------------*- C++ -*-===//
+//===-- RegisterContextPOSIX_arm.cpp --------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -178,35 +178,6 @@ const char *RegisterContextPOSIX_arm::GetRegisterName(unsigned reg) {
return GetRegisterInfo()[reg].name;
}
-lldb::ByteOrder RegisterContextPOSIX_arm::GetByteOrder() {
- // Get the target process whose privileged thread was used for the register
- // read.
- lldb::ByteOrder byte_order = lldb::eByteOrderInvalid;
- lldb_private::Process *process = CalculateProcess().get();
-
- if (process)
- byte_order = process->GetByteOrder();
- return byte_order;
-}
-
bool RegisterContextPOSIX_arm::IsRegisterSetAvailable(size_t set_index) {
return set_index < k_num_register_sets;
}
-
-// Used when parsing DWARF and EH frame information and any other object file
-// sections that contain register numbers in them.
-uint32_t RegisterContextPOSIX_arm::ConvertRegisterKindToRegisterNumber(
- lldb::RegisterKind kind, uint32_t num) {
- const uint32_t num_regs = GetRegisterCount();
-
- assert(kind < lldb::kNumRegisterKinds);
- for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) {
- const lldb_private::RegisterInfo *reg_info =
- GetRegisterInfoAtIndex(reg_idx);
-
- if (reg_info->kinds[kind] == num)
- return reg_idx;
- }
-
- return LLDB_INVALID_REGNUM;
-}
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h
index 603ba76430e6..d6967f05ed48 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextPOSIX_arm_h_
-#define liblldb_RegisterContextPOSIX_arm_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_ARM_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_ARM_H
#include "RegisterInfoInterface.h"
#include "lldb-arm-register-enums.h"
@@ -44,9 +44,6 @@ public:
const char *GetRegisterName(unsigned reg);
- uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
- uint32_t num) override;
-
protected:
struct RegInfo {
uint32_t num_registers;
@@ -95,12 +92,10 @@ protected:
bool IsFPR(unsigned reg);
- lldb::ByteOrder GetByteOrder();
-
virtual bool ReadGPR() = 0;
virtual bool ReadFPR() = 0;
virtual bool WriteGPR() = 0;
virtual bool WriteFPR() = 0;
};
-#endif // liblldb_RegisterContextPOSIX_arm_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_ARM_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
index db1aa1b8b093..8ef587f13e3a 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextPOSIX_arm64.cpp --------------------------*- C++ -*-===//
+//===-- RegisterContextPOSIX_arm64.cpp ------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -25,105 +25,25 @@
using namespace lldb;
using namespace lldb_private;
-// ARM64 general purpose registers.
-const uint32_t g_gpr_regnums_arm64[] = {
- gpr_x0_arm64, gpr_x1_arm64, gpr_x2_arm64, gpr_x3_arm64,
- gpr_x4_arm64, gpr_x5_arm64, gpr_x6_arm64, gpr_x7_arm64,
- gpr_x8_arm64, gpr_x9_arm64, gpr_x10_arm64, gpr_x11_arm64,
- gpr_x12_arm64, gpr_x13_arm64, gpr_x14_arm64, gpr_x15_arm64,
- gpr_x16_arm64, gpr_x17_arm64, gpr_x18_arm64, gpr_x19_arm64,
- gpr_x20_arm64, gpr_x21_arm64, gpr_x22_arm64, gpr_x23_arm64,
- gpr_x24_arm64, gpr_x25_arm64, gpr_x26_arm64, gpr_x27_arm64,
- gpr_x28_arm64, gpr_fp_arm64, gpr_lr_arm64, gpr_sp_arm64,
- gpr_pc_arm64, gpr_cpsr_arm64, gpr_w0_arm64, gpr_w1_arm64,
- gpr_w2_arm64, gpr_w3_arm64, gpr_w4_arm64, gpr_w5_arm64,
- gpr_w6_arm64, gpr_w7_arm64, gpr_w8_arm64, gpr_w9_arm64,
- gpr_w10_arm64, gpr_w11_arm64, gpr_w12_arm64, gpr_w13_arm64,
- gpr_w14_arm64, gpr_w15_arm64, gpr_w16_arm64, gpr_w17_arm64,
- gpr_w18_arm64, gpr_w19_arm64, gpr_w20_arm64, gpr_w21_arm64,
- gpr_w22_arm64, gpr_w23_arm64, gpr_w24_arm64, gpr_w25_arm64,
- gpr_w26_arm64, gpr_w27_arm64, gpr_w28_arm64,
- LLDB_INVALID_REGNUM // register sets need to end with this flag
-};
-static_assert(((sizeof g_gpr_regnums_arm64 / sizeof g_gpr_regnums_arm64[0]) -
- 1) == k_num_gpr_registers_arm64,
- "g_gpr_regnums_arm64 has wrong number of register infos");
-
-// ARM64 floating point registers.
-static const uint32_t g_fpu_regnums_arm64[] = {
- fpu_v0_arm64, fpu_v1_arm64, fpu_v2_arm64, fpu_v3_arm64,
- fpu_v4_arm64, fpu_v5_arm64, fpu_v6_arm64, fpu_v7_arm64,
- fpu_v8_arm64, fpu_v9_arm64, fpu_v10_arm64, fpu_v11_arm64,
- fpu_v12_arm64, fpu_v13_arm64, fpu_v14_arm64, fpu_v15_arm64,
- fpu_v16_arm64, fpu_v17_arm64, fpu_v18_arm64, fpu_v19_arm64,
- fpu_v20_arm64, fpu_v21_arm64, fpu_v22_arm64, fpu_v23_arm64,
- fpu_v24_arm64, fpu_v25_arm64, fpu_v26_arm64, fpu_v27_arm64,
- fpu_v28_arm64, fpu_v29_arm64, fpu_v30_arm64, fpu_v31_arm64,
- fpu_s0_arm64, fpu_s1_arm64, fpu_s2_arm64, fpu_s3_arm64,
- fpu_s4_arm64, fpu_s5_arm64, fpu_s6_arm64, fpu_s7_arm64,
- fpu_s8_arm64, fpu_s9_arm64, fpu_s10_arm64, fpu_s11_arm64,
- fpu_s12_arm64, fpu_s13_arm64, fpu_s14_arm64, fpu_s15_arm64,
- fpu_s16_arm64, fpu_s17_arm64, fpu_s18_arm64, fpu_s19_arm64,
- fpu_s20_arm64, fpu_s21_arm64, fpu_s22_arm64, fpu_s23_arm64,
- fpu_s24_arm64, fpu_s25_arm64, fpu_s26_arm64, fpu_s27_arm64,
- fpu_s28_arm64, fpu_s29_arm64, fpu_s30_arm64, fpu_s31_arm64,
-
- fpu_d0_arm64, fpu_d1_arm64, fpu_d2_arm64, fpu_d3_arm64,
- fpu_d4_arm64, fpu_d5_arm64, fpu_d6_arm64, fpu_d7_arm64,
- fpu_d8_arm64, fpu_d9_arm64, fpu_d10_arm64, fpu_d11_arm64,
- fpu_d12_arm64, fpu_d13_arm64, fpu_d14_arm64, fpu_d15_arm64,
- fpu_d16_arm64, fpu_d17_arm64, fpu_d18_arm64, fpu_d19_arm64,
- fpu_d20_arm64, fpu_d21_arm64, fpu_d22_arm64, fpu_d23_arm64,
- fpu_d24_arm64, fpu_d25_arm64, fpu_d26_arm64, fpu_d27_arm64,
- fpu_d28_arm64, fpu_d29_arm64, fpu_d30_arm64, fpu_d31_arm64,
- fpu_fpsr_arm64, fpu_fpcr_arm64,
- LLDB_INVALID_REGNUM // register sets need to end with this flag
-};
-static_assert(((sizeof g_fpu_regnums_arm64 / sizeof g_fpu_regnums_arm64[0]) -
- 1) == k_num_fpr_registers_arm64,
- "g_fpu_regnums_arm64 has wrong number of register infos");
-
-// Number of register sets provided by this context.
-enum { k_num_register_sets = 2 };
-
-// Register sets for ARM64.
-static const lldb_private::RegisterSet g_reg_sets_arm64[k_num_register_sets] = {
- {"General Purpose Registers", "gpr", k_num_gpr_registers_arm64,
- g_gpr_regnums_arm64},
- {"Floating Point Registers", "fpu", k_num_fpr_registers_arm64,
- g_fpu_regnums_arm64}};
-
bool RegisterContextPOSIX_arm64::IsGPR(unsigned reg) {
- return reg <= m_reg_info.last_gpr; // GPR's come first.
+ if (m_register_info_up->GetRegisterSetFromRegisterIndex(reg) ==
+ RegisterInfoPOSIX_arm64::GPRegSet)
+ return true;
+ return false;
}
bool RegisterContextPOSIX_arm64::IsFPR(unsigned reg) {
- return (m_reg_info.first_fpr <= reg && reg <= m_reg_info.last_fpr);
+ if (m_register_info_up->GetRegisterSetFromRegisterIndex(reg) ==
+ RegisterInfoPOSIX_arm64::FPRegSet)
+ return true;
+ return false;
}
RegisterContextPOSIX_arm64::RegisterContextPOSIX_arm64(
- lldb_private::Thread &thread, uint32_t concrete_frame_idx,
- lldb_private::RegisterInfoInterface *register_info)
- : lldb_private::RegisterContext(thread, concrete_frame_idx) {
- m_register_info_up.reset(register_info);
-
- switch (register_info->m_target_arch.GetMachine()) {
- case llvm::Triple::aarch64:
- case llvm::Triple::aarch64_32:
- m_reg_info.num_registers = k_num_registers_arm64;
- m_reg_info.num_gpr_registers = k_num_gpr_registers_arm64;
- m_reg_info.num_fpr_registers = k_num_fpr_registers_arm64;
- m_reg_info.last_gpr = k_last_gpr_arm64;
- m_reg_info.first_fpr = k_first_fpr_arm64;
- m_reg_info.last_fpr = k_last_fpr_arm64;
- m_reg_info.first_fpr_v = fpu_v0_arm64;
- m_reg_info.last_fpr_v = fpu_v31_arm64;
- m_reg_info.gpr_flags = gpr_cpsr_arm64;
- break;
- default:
- assert(false && "Unhandled target architecture.");
- break;
- }
+ lldb_private::Thread &thread,
+ std::unique_ptr<RegisterInfoPOSIX_arm64> register_info)
+ : lldb_private::RegisterContext(thread, 0),
+ m_register_info_up(std::move(register_info)) {
::memset(&m_fpr, 0, sizeof m_fpr);
}
@@ -135,19 +55,15 @@ void RegisterContextPOSIX_arm64::Invalidate() {}
void RegisterContextPOSIX_arm64::InvalidateAllRegisters() {}
unsigned RegisterContextPOSIX_arm64::GetRegisterOffset(unsigned reg) {
- assert(reg < m_reg_info.num_registers && "Invalid register number.");
- return GetRegisterInfo()[reg].byte_offset;
+ return m_register_info_up->GetRegisterInfo()[reg].byte_offset;
}
unsigned RegisterContextPOSIX_arm64::GetRegisterSize(unsigned reg) {
- assert(reg < m_reg_info.num_registers && "Invalid register number.");
- return GetRegisterInfo()[reg].byte_size;
+ return m_register_info_up->GetRegisterInfo()[reg].byte_size;
}
size_t RegisterContextPOSIX_arm64::GetRegisterCount() {
- size_t num_registers =
- m_reg_info.num_gpr_registers + m_reg_info.num_fpr_registers;
- return num_registers;
+ return m_register_info_up->GetRegisterCount();
}
size_t RegisterContextPOSIX_arm64::GetGPRSize() {
@@ -164,71 +80,23 @@ RegisterContextPOSIX_arm64::GetRegisterInfo() {
const lldb_private::RegisterInfo *
RegisterContextPOSIX_arm64::GetRegisterInfoAtIndex(size_t reg) {
- if (reg < m_reg_info.num_registers)
+ if (reg < GetRegisterCount())
return &GetRegisterInfo()[reg];
else
return nullptr;
}
size_t RegisterContextPOSIX_arm64::GetRegisterSetCount() {
- size_t sets = 0;
- for (size_t set = 0; set < k_num_register_sets; ++set) {
- if (IsRegisterSetAvailable(set))
- ++sets;
- }
-
- return sets;
+ return m_register_info_up->GetRegisterSetCount();
}
const lldb_private::RegisterSet *
RegisterContextPOSIX_arm64::GetRegisterSet(size_t set) {
- if (IsRegisterSetAvailable(set)) {
- switch (m_register_info_up->m_target_arch.GetMachine()) {
- case llvm::Triple::aarch64:
- case llvm::Triple::aarch64_32:
- return &g_reg_sets_arm64[set];
- default:
- assert(false && "Unhandled target architecture.");
- return nullptr;
- }
- }
- return nullptr;
+ return m_register_info_up->GetRegisterSet(set);
}
const char *RegisterContextPOSIX_arm64::GetRegisterName(unsigned reg) {
- assert(reg < m_reg_info.num_registers && "Invalid register offset.");
- return GetRegisterInfo()[reg].name;
-}
-
-lldb::ByteOrder RegisterContextPOSIX_arm64::GetByteOrder() {
- // Get the target process whose privileged thread was used for the register
- // read.
- lldb::ByteOrder byte_order = lldb::eByteOrderInvalid;
- lldb_private::Process *process = CalculateProcess().get();
-
- if (process)
- byte_order = process->GetByteOrder();
- return byte_order;
-}
-
-bool RegisterContextPOSIX_arm64::IsRegisterSetAvailable(size_t set_index) {
- return set_index < k_num_register_sets;
-}
-
-// Used when parsing DWARF and EH frame information and any other object file
-// sections that contain register numbers in them.
-uint32_t RegisterContextPOSIX_arm64::ConvertRegisterKindToRegisterNumber(
- lldb::RegisterKind kind, uint32_t num) {
- const uint32_t num_regs = GetRegisterCount();
-
- assert(kind < lldb::kNumRegisterKinds);
- for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) {
- const lldb_private::RegisterInfo *reg_info =
- GetRegisterInfoAtIndex(reg_idx);
-
- if (reg_info->kinds[kind] == num)
- return reg_idx;
- }
-
- return LLDB_INVALID_REGNUM;
+ if (reg < GetRegisterCount())
+ return GetRegisterInfo()[reg].name;
+ return nullptr;
}
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
index 49a49b69da6b..c2d5aee7f73c 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
@@ -6,10 +6,11 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextPOSIX_arm64_h_
-#define liblldb_RegisterContextPOSIX_arm64_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_ARM64_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_ARM64_H
#include "RegisterInfoInterface.h"
+#include "RegisterInfoPOSIX_arm64.h"
#include "lldb-arm64-register-enums.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Utility/Log.h"
@@ -19,8 +20,8 @@ class ProcessMonitor;
class RegisterContextPOSIX_arm64 : public lldb_private::RegisterContext {
public:
RegisterContextPOSIX_arm64(
- lldb_private::Thread &thread, uint32_t concrete_frame_idx,
- lldb_private::RegisterInfoInterface *register_info);
+ lldb_private::Thread &thread,
+ std::unique_ptr<RegisterInfoPOSIX_arm64> register_info);
~RegisterContextPOSIX_arm64() override;
@@ -44,50 +45,15 @@ public:
const char *GetRegisterName(unsigned reg);
- uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
- uint32_t num) override;
-
protected:
- struct RegInfo {
- uint32_t num_registers;
- uint32_t num_gpr_registers;
- uint32_t num_fpr_registers;
-
- uint32_t last_gpr;
- uint32_t first_fpr;
- uint32_t last_fpr;
-
- uint32_t first_fpr_v;
- uint32_t last_fpr_v;
-
- uint32_t gpr_flags;
- };
-
- // based on RegisterContextDarwin_arm64.h
- struct VReg {
- uint8_t bytes[16];
- };
-
- // based on RegisterContextDarwin_arm64.h
- struct FPU {
- VReg v[32];
- uint32_t fpsr;
- uint32_t fpcr;
- };
-
uint64_t m_gpr_arm64[lldb_private::k_num_gpr_registers_arm64]; // 64-bit
// general
// purpose
// registers.
- RegInfo m_reg_info;
- struct RegisterContextPOSIX_arm64::FPU
- m_fpr; // floating-point registers including extended register sets.
- std::unique_ptr<lldb_private::RegisterInfoInterface>
- m_register_info_up; // Register Info Interface (FreeBSD or Linux)
- // Determines if an extended register set is supported on the processor
- // running the inferior process.
- virtual bool IsRegisterSetAvailable(size_t set_index);
+ struct RegisterInfoPOSIX_arm64::FPU
+ m_fpr; // floating-point registers including extended register sets.
+ std::unique_ptr<RegisterInfoPOSIX_arm64> m_register_info_up;
virtual const lldb_private::RegisterInfo *GetRegisterInfo();
@@ -95,7 +61,7 @@ protected:
bool IsFPR(unsigned reg);
- lldb::ByteOrder GetByteOrder();
+ size_t GetFPUSize() { return sizeof(RegisterInfoPOSIX_arm64::FPU); }
virtual bool ReadGPR() = 0;
virtual bool ReadFPR() = 0;
@@ -103,4 +69,4 @@ protected:
virtual bool WriteFPR() = 0;
};
-#endif // liblldb_RegisterContextPOSIX_arm64_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_ARM64_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp
index f1fa3035b2ef..c41c4bd7a7ea 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextPOSIX_mips64.cpp -------------------------*- C++ -*-===//
+//===-- RegisterContextPOSIX_mips64.cpp -----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -149,17 +149,6 @@ const char *RegisterContextPOSIX_mips64::GetRegisterName(unsigned reg) {
return GetRegisterInfo()[reg].name;
}
-lldb::ByteOrder RegisterContextPOSIX_mips64::GetByteOrder() {
- // Get the target process whose privileged thread was used for the register
- // read.
- lldb::ByteOrder byte_order = eByteOrderInvalid;
- Process *process = CalculateProcess().get();
-
- if (process)
- byte_order = process->GetByteOrder();
- return byte_order;
-}
-
bool RegisterContextPOSIX_mips64::IsRegisterSetAvailable(size_t set_index) {
size_t num_sets = GetRegisterSetCount();
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h
index c507e14bd5b6..1843a2a6aff3 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextPOSIX_mips64_h_
-#define liblldb_RegisterContextPOSIX_mips64_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_MIPS64_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_MIPS64_H
#include "RegisterContext_mips.h"
#include "RegisterInfoInterface.h"
@@ -73,12 +73,10 @@ protected:
bool IsFPR(unsigned reg);
- lldb::ByteOrder GetByteOrder();
-
virtual bool ReadGPR() = 0;
virtual bool ReadFPR() = 0;
virtual bool WriteGPR() = 0;
virtual bool WriteFPR() = 0;
};
-#endif // liblldb_RegisterContextPOSIX_mips64_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_MIPS64_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp
index a78e9ed37947..cd65b96d373e 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp
@@ -1,5 +1,4 @@
-//===-- RegisterContextPOSIX_powerpc.cpp -------------------------*- C++
-//-*-===//
+//===-- RegisterContextPOSIX_powerpc.cpp ----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -158,36 +157,8 @@ const char *RegisterContextPOSIX_powerpc::GetRegisterName(unsigned reg) {
return GetRegisterInfo()[reg].name;
}
-lldb::ByteOrder RegisterContextPOSIX_powerpc::GetByteOrder() {
- // Get the target process whose privileged thread was used for the register
- // read.
- lldb::ByteOrder byte_order = eByteOrderInvalid;
- Process *process = CalculateProcess().get();
-
- if (process)
- byte_order = process->GetByteOrder();
- return byte_order;
-}
-
bool RegisterContextPOSIX_powerpc::IsRegisterSetAvailable(size_t set_index) {
size_t num_sets = k_num_register_sets;
return (set_index < num_sets);
}
-
-// Used when parsing DWARF and EH frame information and any other object file
-// sections that contain register numbers in them.
-uint32_t RegisterContextPOSIX_powerpc::ConvertRegisterKindToRegisterNumber(
- lldb::RegisterKind kind, uint32_t num) {
- const uint32_t num_regs = GetRegisterCount();
-
- assert(kind < kNumRegisterKinds);
- for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) {
- const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg_idx);
-
- if (reg_info->kinds[kind] == num)
- return reg_idx;
- }
-
- return LLDB_INVALID_REGNUM;
-}
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h
index 1a21a717b22b..e2c33461c8f1 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextPOSIX_powerpc_h_
-#define liblldb_RegisterContextPOSIX_powerpc_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_POWERPC_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_POWERPC_H
#include "RegisterContext_powerpc.h"
#include "RegisterInfoInterface.h"
@@ -165,9 +165,6 @@ public:
const char *GetRegisterName(unsigned reg);
- uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
- uint32_t num) override;
-
protected:
uint64_t
m_gpr_powerpc[k_num_gpr_registers_powerpc]; // general purpose registers.
@@ -189,8 +186,6 @@ protected:
bool IsVMX(unsigned reg);
- lldb::ByteOrder GetByteOrder();
-
virtual bool ReadGPR() = 0;
virtual bool ReadFPR() = 0;
virtual bool ReadVMX() = 0;
@@ -199,4 +194,4 @@ protected:
virtual bool WriteVMX() = 0;
};
-#endif // liblldb_RegisterContextPOSIX_powerpc_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_POWERPC_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp
index 02546c0ed16f..f670be2ef3c4 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextPOSIX_ppc64le.cpp -------------------------*- C++-*-===//
+//===-- RegisterContextPOSIX_ppc64le.cpp ----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -176,36 +176,8 @@ const char *RegisterContextPOSIX_ppc64le::GetRegisterName(unsigned reg) {
return GetRegisterInfo()[reg].name;
}
-lldb::ByteOrder RegisterContextPOSIX_ppc64le::GetByteOrder() {
- // Get the target process whose privileged thread was used for the register
- // read.
- lldb::ByteOrder byte_order = eByteOrderInvalid;
- Process *process = CalculateProcess().get();
-
- if (process)
- byte_order = process->GetByteOrder();
- return byte_order;
-}
-
bool RegisterContextPOSIX_ppc64le::IsRegisterSetAvailable(size_t set_index) {
size_t num_sets = k_num_register_sets;
return (set_index < num_sets);
}
-
-// Used when parsing DWARF and EH frame information and any other object file
-// sections that contain register numbers in them.
-uint32_t RegisterContextPOSIX_ppc64le::ConvertRegisterKindToRegisterNumber(
- lldb::RegisterKind kind, uint32_t num) {
- const uint32_t num_regs = GetRegisterCount();
-
- assert(kind < kNumRegisterKinds);
- for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) {
- const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg_idx);
-
- if (reg_info->kinds[kind] == num)
- return reg_idx;
- }
-
- return LLDB_INVALID_REGNUM;
-}
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.h b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.h
index 37079775a3c7..66794ec9e9ca 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextPOSIX_ppc64le_h_
-#define liblldb_RegisterContextPOSIX_ppc64le_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_PPC64LE_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_PPC64LE_H
#include "Plugins/Process/Utility/lldb-ppc64le-register-enums.h"
#include "RegisterInfoInterface.h"
@@ -39,9 +39,6 @@ public:
const char *GetRegisterName(unsigned reg);
- uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
- uint32_t num) override;
-
protected:
// 64-bit general purpose registers.
uint64_t m_gpr_ppc64le[k_num_gpr_registers_ppc64le];
@@ -71,7 +68,6 @@ protected:
bool IsVSX(unsigned reg);
- lldb::ByteOrder GetByteOrder();
};
-#endif // liblldb_RegisterContextPOSIX_ppc64le_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_PPC64LE_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp
index e040e5075721..e746ec642b38 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextPOSIX_s390x.cpp --------------------------*- C++ -*-===//
+//===-- RegisterContextPOSIX_s390x.cpp ------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -161,31 +161,3 @@ const RegisterSet *RegisterContextPOSIX_s390x::GetRegisterSet(size_t set) {
}
return nullptr;
}
-
-lldb::ByteOrder RegisterContextPOSIX_s390x::GetByteOrder() {
- // Get the target process whose privileged thread was used for the register
- // read.
- lldb::ByteOrder byte_order = eByteOrderInvalid;
- Process *process = CalculateProcess().get();
-
- if (process)
- byte_order = process->GetByteOrder();
- return byte_order;
-}
-
-// Used when parsing DWARF and EH frame information and any other object file
-// sections that contain register numbers in them.
-uint32_t RegisterContextPOSIX_s390x::ConvertRegisterKindToRegisterNumber(
- lldb::RegisterKind kind, uint32_t num) {
- const uint32_t num_regs = GetRegisterCount();
-
- assert(kind < kNumRegisterKinds);
- for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) {
- const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg_idx);
-
- if (reg_info->kinds[kind] == num)
- return reg_idx;
- }
-
- return LLDB_INVALID_REGNUM;
-}
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h
index 54993ce6c3ec..7df732d13ffa 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextPOSIX_s390x_h_
-#define liblldb_RegisterContextPOSIX_s390x_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_S390X_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_S390X_H
#include "RegisterContext_s390x.h"
#include "RegisterInfoInterface.h"
@@ -43,9 +43,6 @@ public:
const char *GetRegisterName(unsigned reg);
- uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
- uint32_t num) override;
-
protected:
struct RegInfo {
uint32_t num_registers;
@@ -68,12 +65,10 @@ protected:
bool IsFPR(unsigned reg);
- lldb::ByteOrder GetByteOrder();
-
virtual bool ReadGPR() = 0;
virtual bool ReadFPR() = 0;
virtual bool WriteGPR() = 0;
virtual bool WriteFPR() = 0;
};
-#endif // liblldb_RegisterContextPOSIX_s390x_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_S390X_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
index 4d5991f08f1d..ac271a90d6a1 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextPOSIX_x86.cpp ----------------------------*- C++ -*-===//
+//===-- RegisterContextPOSIX_x86.cpp --------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -456,17 +456,6 @@ const char *RegisterContextPOSIX_x86::GetRegisterName(unsigned reg) {
return GetRegisterInfo()[reg].name;
}
-lldb::ByteOrder RegisterContextPOSIX_x86::GetByteOrder() {
- // Get the target process whose privileged thread was used for the register
- // read.
- lldb::ByteOrder byte_order = eByteOrderInvalid;
- Process *process = CalculateProcess().get();
-
- if (process)
- byte_order = process->GetByteOrder();
- return byte_order;
-}
-
// Parse ymm registers and into xmm.bytes and ymmh.bytes.
bool RegisterContextPOSIX_x86::CopyYMMtoXSTATE(uint32_t reg,
lldb::ByteOrder byte_order) {
@@ -509,20 +498,3 @@ bool RegisterContextPOSIX_x86::IsRegisterSetAvailable(size_t set_index) {
++num_sets;
return (set_index < num_sets);
}
-
-// Used when parsing DWARF and EH frame information and any other object file
-// sections that contain register numbers in them.
-uint32_t RegisterContextPOSIX_x86::ConvertRegisterKindToRegisterNumber(
- lldb::RegisterKind kind, uint32_t num) {
- const uint32_t num_regs = GetRegisterCount();
-
- assert(kind < kNumRegisterKinds);
- for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) {
- const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg_idx);
-
- if (reg_info->kinds[kind] == num)
- return reg_idx;
- }
-
- return LLDB_INVALID_REGNUM;
-}
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
index 932f97bb567f..c4886ae618a2 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextPOSIX_x86_h_
-#define liblldb_RegisterContextPOSIX_x86_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_X86_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_X86_H
#include "RegisterContext_x86.h"
#include "RegisterInfoInterface.h"
@@ -47,9 +47,6 @@ public:
const char *GetRegisterName(unsigned reg);
- uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
- uint32_t num) override;
-
// Note: prefer kernel definitions over user-land
enum FPRType {
eNotValid = 0,
@@ -160,8 +157,6 @@ protected:
bool IsAVX(unsigned reg);
- lldb::ByteOrder GetByteOrder();
-
bool CopyXSTATEtoYMM(uint32_t reg, lldb::ByteOrder byte_order);
bool CopyYMMtoXSTATE(uint32_t reg, lldb::ByteOrder byte_order);
bool IsFPR(unsigned reg, FPRType fpr_type);
@@ -173,4 +168,4 @@ protected:
virtual bool WriteFPR() = 0;
};
-#endif // liblldb_RegisterContextPOSIX_x86_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_X86_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
index bcf60cc7a338..31e2944084ed 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextThreadMemory.cpp -------------------------*- C++ -*-===//
+//===-- RegisterContextThreadMemory.cpp -----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h
index 09a679ab2c9f..40688a502a66 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextThreadMemory.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_RegisterContextThreadMemory_h_
-#define lldb_RegisterContextThreadMemory_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTTHREADMEMORY_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTTHREADMEMORY_H
#include <vector>
@@ -92,9 +92,11 @@ protected:
uint32_t m_stop_id;
private:
- DISALLOW_COPY_AND_ASSIGN(RegisterContextThreadMemory);
+ RegisterContextThreadMemory(const RegisterContextThreadMemory &) = delete;
+ const RegisterContextThreadMemory &
+ operator=(const RegisterContextThreadMemory &) = delete;
};
} // namespace lldb_private
-#endif // lldb_RegisterContextThreadMemory_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTTHREADMEMORY_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextWindows_i386.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextWindows_i386.cpp
index 916d3233cde5..11556e802e33 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextWindows_i386.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextWindows_i386.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextWindows_i386.cpp -------------------------*- C++ -*-===//
+//===-- RegisterContextWindows_i386.cpp -----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextWindows_i386.h b/lldb/source/Plugins/Process/Utility/RegisterContextWindows_i386.h
index 7779cc357526..6a5d3524300d 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextWindows_i386.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextWindows_i386.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextWindows_i386_H_
-#define liblldb_RegisterContextWindows_i386_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTWINDOWS_I386_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTWINDOWS_I386_H
#include "RegisterInfoInterface.h"
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextWindows_x86_64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextWindows_x86_64.cpp
index e90584de1a44..4ffc4d25781c 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextWindows_x86_64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextWindows_x86_64.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextWindows_x86_64.cpp -----------------------*- C++ -*-===//
+//===-- RegisterContextWindows_x86_64.cpp ---------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextWindows_x86_64.h b/lldb/source/Plugins/Process/Utility/RegisterContextWindows_x86_64.h
index 18198b5b25b3..c29acf284841 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextWindows_x86_64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextWindows_x86_64.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextWindows_x86_64_H_
-#define liblldb_RegisterContextWindows_x86_64_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTWINDOWS_X86_64_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTWINDOWS_X86_64_H
#include "RegisterInfoInterface.h"
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContext_mips.h b/lldb/source/Plugins/Process/Utility/RegisterContext_mips.h
index 7780be51baad..15081f974c66 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContext_mips.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContext_mips.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContext_mips64_H_
-#define liblldb_RegisterContext_mips64_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXT_MIPS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXT_MIPS_H
#include <cstddef>
#include <cstdint>
@@ -371,4 +371,4 @@ struct UserArea {
MSA_linux_mips msa; // MSA registers.
};
-#endif // liblldb_RegisterContext_mips64_H_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXT_MIPS_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContext_powerpc.h b/lldb/source/Plugins/Process/Utility/RegisterContext_powerpc.h
index 1ffcbeb5ec48..7407e2f402e0 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContext_powerpc.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContext_powerpc.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContext_powerpc_H_
-#define liblldb_RegisterContext_powerpc_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXT_POWERPC_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXT_POWERPC_H
// eh_frame and DWARF Register numbers (eRegisterKindEHFrame &
// eRegisterKindDWARF)
@@ -120,4 +120,4 @@ enum {
dwarf_v31_powerpc,
};
-#endif // liblldb_RegisterContext_powerpc_H_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXT_POWERPC_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContext_s390x.h b/lldb/source/Plugins/Process/Utility/RegisterContext_s390x.h
index 2cf39e9eb8e2..248b3bd0beac 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContext_s390x.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContext_s390x.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContext_s390x_h_
-#define liblldb_RegisterContext_s390x_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXT_S390X_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXT_S390X_H
// SystemZ ehframe, dwarf regnums
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContext_x86.h b/lldb/source/Plugins/Process/Utility/RegisterContext_x86.h
index 2b79f778aa56..27a1bad4d53f 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContext_x86.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterContext_x86.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContext_x86_H_
-#define liblldb_RegisterContext_x86_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXT_X86_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXT_X86_H
#include <cstddef>
#include <cstdint>
diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoAndSetInterface.h b/lldb/source/Plugins/Process/Utility/RegisterInfoAndSetInterface.h
new file mode 100644
index 000000000000..7e569dc9ba78
--- /dev/null
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfoAndSetInterface.h
@@ -0,0 +1,36 @@
+//===-- RegisterInfoAndSetInterface.h ---------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERINFOANDSETINTERFACE_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERINFOANDSETINTERFACE_H
+
+#include "RegisterInfoInterface.h"
+
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/lldb-private-types.h"
+#include <vector>
+
+namespace lldb_private {
+
+class RegisterInfoAndSetInterface : public RegisterInfoInterface {
+public:
+ RegisterInfoAndSetInterface(const lldb_private::ArchSpec &target_arch)
+ : RegisterInfoInterface(target_arch) {}
+
+ virtual size_t GetFPRSize() const = 0;
+
+ virtual const lldb_private::RegisterSet *
+ GetRegisterSet(size_t reg_set) const = 0;
+
+ virtual size_t GetRegisterSetCount() const = 0;
+
+ virtual size_t GetRegisterSetFromRegisterIndex(uint32_t reg_index) const = 0;
+};
+} // namespace lldb_private
+
+#endif
diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoInterface.h b/lldb/source/Plugins/Process/Utility/RegisterInfoInterface.h
index 4b58e749adce..88c2ae7c5010 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfoInterface.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfoInterface.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_RegisterInfoInterface_h
-#define lldb_RegisterInfoInterface_h
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERINFOINTERFACE_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERINFOINTERFACE_H
#include "lldb/Utility/ArchSpec.h"
#include "lldb/lldb-private-types.h"
@@ -61,7 +61,6 @@ public:
return nullptr;
}
-public:
// FIXME make private.
lldb_private::ArchSpec m_target_arch;
};
diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.cpp b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.cpp
index d392d3be1c41..8fc4d5282b06 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterInfoPOSIX_arm.cpp ------------------------------*- C++ -*-===//
+//===-- RegisterInfoPOSIX_arm.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.h b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.h
index 39c2047600aa..1cf896e3decf 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterInfoPOSIX_arm_h_
-#define liblldb_RegisterInfoPOSIX_arm_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERINFOPOSIX_ARM_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERINFOPOSIX_ARM_H
#include "RegisterInfoInterface.h"
#include "lldb/Target/RegisterContext.h"
@@ -58,4 +58,4 @@ private:
uint32_t m_register_info_count;
};
-#endif // liblldb_RegisterInfoPOSIX_arm_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERINFOPOSIX_ARM_H
diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
index 8b367bdc6448..4537cee42ad9 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterInfoPOSIX_arm64.cpp ----------------------------*- C++ -*-===//
+//===-- RegisterInfoPOSIX_arm64.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -65,6 +65,82 @@ GetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch) {
}
}
+// Number of register sets provided by this context.
+enum {
+ k_num_gpr_registers = gpr_w28 - gpr_x0 + 1,
+ k_num_fpr_registers = fpu_fpcr - fpu_v0 + 1,
+ k_num_register_sets = 2
+};
+
+// ARM64 general purpose registers.
+static const uint32_t g_gpr_regnums_arm64[] = {
+ gpr_x0, gpr_x1, gpr_x2, gpr_x3,
+ gpr_x4, gpr_x5, gpr_x6, gpr_x7,
+ gpr_x8, gpr_x9, gpr_x10, gpr_x11,
+ gpr_x12, gpr_x13, gpr_x14, gpr_x15,
+ gpr_x16, gpr_x17, gpr_x18, gpr_x19,
+ gpr_x20, gpr_x21, gpr_x22, gpr_x23,
+ gpr_x24, gpr_x25, gpr_x26, gpr_x27,
+ gpr_x28, gpr_fp, gpr_lr, gpr_sp,
+ gpr_pc, gpr_cpsr, gpr_w0, gpr_w1,
+ gpr_w2, gpr_w3, gpr_w4, gpr_w5,
+ gpr_w6, gpr_w7, gpr_w8, gpr_w9,
+ gpr_w10, gpr_w11, gpr_w12, gpr_w13,
+ gpr_w14, gpr_w15, gpr_w16, gpr_w17,
+ gpr_w18, gpr_w19, gpr_w20, gpr_w21,
+ gpr_w22, gpr_w23, gpr_w24, gpr_w25,
+ gpr_w26, gpr_w27, gpr_w28, LLDB_INVALID_REGNUM};
+
+static_assert(((sizeof g_gpr_regnums_arm64 / sizeof g_gpr_regnums_arm64[0]) -
+ 1) == k_num_gpr_registers,
+ "g_gpr_regnums_arm64 has wrong number of register infos");
+
+// ARM64 floating point registers.
+static const uint32_t g_fpu_regnums_arm64[] = {
+ fpu_v0, fpu_v1, fpu_v2,
+ fpu_v3, fpu_v4, fpu_v5,
+ fpu_v6, fpu_v7, fpu_v8,
+ fpu_v9, fpu_v10, fpu_v11,
+ fpu_v12, fpu_v13, fpu_v14,
+ fpu_v15, fpu_v16, fpu_v17,
+ fpu_v18, fpu_v19, fpu_v20,
+ fpu_v21, fpu_v22, fpu_v23,
+ fpu_v24, fpu_v25, fpu_v26,
+ fpu_v27, fpu_v28, fpu_v29,
+ fpu_v30, fpu_v31, fpu_s0,
+ fpu_s1, fpu_s2, fpu_s3,
+ fpu_s4, fpu_s5, fpu_s6,
+ fpu_s7, fpu_s8, fpu_s9,
+ fpu_s10, fpu_s11, fpu_s12,
+ fpu_s13, fpu_s14, fpu_s15,
+ fpu_s16, fpu_s17, fpu_s18,
+ fpu_s19, fpu_s20, fpu_s21,
+ fpu_s22, fpu_s23, fpu_s24,
+ fpu_s25, fpu_s26, fpu_s27,
+ fpu_s28, fpu_s29, fpu_s30,
+ fpu_s31, 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_fpsr, fpu_fpcr, LLDB_INVALID_REGNUM};
+static_assert(((sizeof g_fpu_regnums_arm64 / sizeof g_fpu_regnums_arm64[0]) -
+ 1) == k_num_fpr_registers,
+ "g_fpu_regnums_arm64 has wrong number of register infos");
+// clang-format on
+// Register sets for ARM64.
+static const lldb_private::RegisterSet g_reg_sets_arm64[k_num_register_sets] = {
+ {"General Purpose Registers", "gpr", k_num_gpr_registers,
+ g_gpr_regnums_arm64},
+ {"Floating Point Registers", "fpu", k_num_fpr_registers,
+ g_fpu_regnums_arm64}};
+
static uint32_t
GetRegisterInfoCount(const lldb_private::ArchSpec &target_arch) {
switch (target_arch.GetMachine()) {
@@ -80,19 +156,60 @@ GetRegisterInfoCount(const lldb_private::ArchSpec &target_arch) {
RegisterInfoPOSIX_arm64::RegisterInfoPOSIX_arm64(
const lldb_private::ArchSpec &target_arch)
- : lldb_private::RegisterInfoInterface(target_arch),
+ : lldb_private::RegisterInfoAndSetInterface(target_arch),
m_register_info_p(GetRegisterInfoPtr(target_arch)),
- m_register_info_count(GetRegisterInfoCount(target_arch)) {}
+ m_register_info_count(GetRegisterInfoCount(target_arch)) {
+
+ switch (target_arch.GetMachine()) {
+ case llvm::Triple::aarch64:
+ case llvm::Triple::aarch64_32:
+ num_registers = k_num_gpr_registers + k_num_fpr_registers;
+ num_gpr_registers = k_num_gpr_registers;
+ num_fpr_registers = k_num_fpr_registers;
+ last_gpr = gpr_w28;
+ first_fpr = fpu_v0;
+ last_fpr = fpu_fpcr;
+ break;
+ default:
+ assert(false && "Unhandled target architecture.");
+ break;
+ }
+}
+
+uint32_t RegisterInfoPOSIX_arm64::GetRegisterCount() const {
+ return num_gpr_registers + num_fpr_registers;
+}
size_t RegisterInfoPOSIX_arm64::GetGPRSize() const {
return sizeof(struct RegisterInfoPOSIX_arm64::GPR);
}
+size_t RegisterInfoPOSIX_arm64::GetFPRSize() const {
+ return sizeof(struct RegisterInfoPOSIX_arm64::FPU);
+}
+
const lldb_private::RegisterInfo *
RegisterInfoPOSIX_arm64::GetRegisterInfo() const {
return m_register_info_p;
}
-uint32_t RegisterInfoPOSIX_arm64::GetRegisterCount() const {
- return m_register_info_count;
+size_t RegisterInfoPOSIX_arm64::GetRegisterSetCount() const {
+ return k_num_register_sets;
+}
+
+size_t RegisterInfoPOSIX_arm64::GetRegisterSetFromRegisterIndex(
+ uint32_t reg_index) const {
+ if (reg_index <= last_gpr)
+ return GPRegSet;
+ else if (reg_index <= last_fpr)
+ return FPRegSet;
+ return LLDB_INVALID_REGNUM;
+}
+
+const lldb_private::RegisterSet *
+RegisterInfoPOSIX_arm64::GetRegisterSet(size_t set_index) const {
+ if (set_index < k_num_register_sets)
+ return &g_reg_sets_arm64[set_index];
+
+ return nullptr;
}
diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
index ace179a81814..2da6a531a6b6 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
@@ -6,15 +6,18 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextLinux_arm64_H_
-#define liblldb_RegisterContextLinux_arm64_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERINFOPOSIX_ARM64_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERINFOPOSIX_ARM64_H
-#include "RegisterInfoInterface.h"
+#include "RegisterInfoAndSetInterface.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/lldb-private.h"
-class RegisterInfoPOSIX_arm64 : public lldb_private::RegisterInfoInterface {
+class RegisterInfoPOSIX_arm64
+ : public lldb_private::RegisterInfoAndSetInterface {
public:
+ enum { GPRegSet = 0, FPRegSet };
+
// based on RegisterContextDarwin_arm64.h
struct GPR {
uint64_t x[29]; // x0-x28
@@ -57,11 +60,28 @@ public:
size_t GetGPRSize() const override;
+ size_t GetFPRSize() const override;
+
const lldb_private::RegisterInfo *GetRegisterInfo() const override;
uint32_t GetRegisterCount() const override;
+ const lldb_private::RegisterSet *
+ GetRegisterSet(size_t reg_set) const override;
+
+ size_t GetRegisterSetCount() const override;
+
+ size_t GetRegisterSetFromRegisterIndex(uint32_t reg_index) const override;
+
private:
+ uint32_t num_registers;
+ uint32_t num_gpr_registers;
+ uint32_t num_fpr_registers;
+
+ uint32_t last_gpr;
+ uint32_t first_fpr;
+ uint32_t last_fpr;
+
const lldb_private::RegisterInfo *m_register_info_p;
uint32_t m_register_info_count;
};
diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.cpp b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.cpp
index 35051a3ce095..3461d38a3901 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterInfoPOSIX_ppc64le.cpp --------------------------*- C++ -*-===//
+//===-- RegisterInfoPOSIX_ppc64le.cpp -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.h b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.h
index c4d4d3b546e2..98549ac0dda4 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextLinux_ppc64le_H_
-#define liblldb_RegisterContextLinux_ppc64le_H_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERINFOPOSIX_PPC64LE_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERINFOPOSIX_PPC64LE_H
#include "RegisterInfoInterface.h"
#include "lldb/Target/RegisterContext.h"
diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfos_arm64.h b/lldb/source/Plugins/Process/Utility/RegisterInfos_arm64.h
index 68c12aa6e529..4aee55e7afba 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfos_arm64.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfos_arm64.h
@@ -456,37 +456,26 @@ static uint32_t g_d29_invalidates[] = {fpu_v29, fpu_s29, LLDB_INVALID_REGNUM};
static uint32_t g_d30_invalidates[] = {fpu_v30, fpu_s30, LLDB_INVALID_REGNUM};
static uint32_t g_d31_invalidates[] = {fpu_v31, fpu_s31, LLDB_INVALID_REGNUM};
-// Generates register kinds array for 64-bit general purpose registers
-#define GPR64_KIND(reg, generic_kind) \
+// Generates register kinds array with DWARF, EH frame and generic kind
+#define MISC_KIND(reg, type, generic_kind) \
{ \
arm64_ehframe::reg, arm64_dwarf::reg, generic_kind, LLDB_INVALID_REGNUM, \
- gpr_##reg \
+ type##_##reg \
}
-// Generates register kinds array for registers with lldb kind
-#define MISC_KIND(lldb_kind) \
+// Generates register kinds array for registers with only lldb kind
+#define LLDB_KIND(lldb_kind) \
{ \
LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
LLDB_INVALID_REGNUM, lldb_kind \
}
// Generates register kinds array for vector registers
-#define VREG_KIND(reg) \
- { \
- LLDB_INVALID_REGNUM, arm64_dwarf::reg, LLDB_INVALID_REGNUM, \
- LLDB_INVALID_REGNUM, fpu_##reg \
- }
-
-// Generates register kinds array for cpsr
-#define CPSR_KIND(lldb_kind) \
- { \
- arm64_ehframe::cpsr, arm64_dwarf::cpsr, LLDB_REGNUM_GENERIC_FLAGS, \
- LLDB_INVALID_REGNUM, lldb_kind \
- }
-
-#define MISC_GPR_KIND(lldb_kind) CPSR_KIND(lldb_kind)
-#define MISC_FPU_KIND(lldb_kind) MISC_KIND(lldb_kind)
-#define MISC_EXC_KIND(lldb_kind) MISC_KIND(lldb_kind)
+#define GPR64_KIND(reg, generic_kind) MISC_KIND(reg, gpr, generic_kind)
+#define VREG_KIND(reg) MISC_KIND(reg, fpu, LLDB_INVALID_REGNUM)
+#define MISC_GPR_KIND(lldb_kind) MISC_KIND(cpsr, gpr, LLDB_REGNUM_GENERIC_FLAGS)
+#define MISC_FPU_KIND(lldb_kind) LLDB_KIND(lldb_kind)
+#define MISC_EXC_KIND(lldb_kind) LLDB_KIND(lldb_kind)
// Defines a 64-bit general purpose register
#define DEFINE_GPR64(reg, generic_kind) \
@@ -509,7 +498,7 @@ static uint32_t g_d31_invalidates[] = {fpu_v31, fpu_s31, LLDB_INVALID_REGNUM};
{ \
#wreg, nullptr, 4, \
GPR_OFFSET(gpr_##xreg) + GPR_W_PSEUDO_REG_ENDIAN_OFFSET, \
- lldb::eEncodingUint, lldb::eFormatHex, MISC_KIND(gpr_##wreg), \
+ lldb::eEncodingUint, lldb::eFormatHex, LLDB_KIND(gpr_##wreg), \
g_contained_##xreg, g_##wreg##_invalidates, nullptr, 0 \
}
@@ -521,11 +510,11 @@ static uint32_t g_d31_invalidates[] = {fpu_v31, fpu_s31, LLDB_INVALID_REGNUM};
0 \
}
-// Defines S and D pseudo registers mapping over correspondig vector register
+// Defines S and D pseudo registers mapping over corresponding vector register
#define DEFINE_FPU_PSEUDO(reg, size, offset, vreg) \
{ \
#reg, nullptr, size, FPU_OFFSET(fpu_##vreg - fpu_v0) + offset, \
- lldb::eEncodingIEEE754, lldb::eFormatFloat, MISC_KIND(fpu_##reg), \
+ lldb::eEncodingIEEE754, lldb::eFormatFloat, LLDB_KIND(fpu_##reg), \
g_contained_##vreg, g_##reg##_invalidates, nullptr, 0 \
}
diff --git a/lldb/source/Plugins/Process/Utility/RegisterInfos_i386.h b/lldb/source/Plugins/Process/Utility/RegisterInfos_i386.h
index 72ff904520ad..343579cd2657 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterInfos_i386.h
+++ b/lldb/source/Plugins/Process/Utility/RegisterInfos_i386.h
@@ -145,7 +145,7 @@
DR_OFFSET(i), eEncodingUint, eFormatHex, \
{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
- LLDB_INVALID_REGNUM }, \
+ lldb_##reg##i##_i386 }, \
nullptr, nullptr, nullptr, 0 \
}
diff --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
index 6d03bd534f37..2d8e8ef21612 100644
--- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -1,4 +1,4 @@
-//===-- StopInfoMachException.cpp -------------------------------*- C++ -*-===//
+//===-- StopInfoMachException.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,6 +8,7 @@
#include "StopInfoMachException.h"
+#include "lldb/lldb-forward.h"
#if defined(__APPLE__)
// Needed for the EXC_RESOURCE interpretation macros
@@ -289,10 +290,48 @@ const char *StopInfoMachException::GetDescription() {
if (m_exc_data_count > 0)
strm.PutChar(')');
- m_description = strm.GetString();
+ m_description = std::string(strm.GetString());
return m_description.c_str();
}
+static StopInfoSP GetStopInfoForHardwareBP(Thread &thread, Target *target,
+ uint32_t exc_data_count,
+ uint64_t exc_sub_code,
+ uint64_t exc_sub_sub_code) {
+ // Try hardware watchpoint.
+ if (target) {
+ // The exc_sub_code indicates the data break address.
+ lldb::WatchpointSP wp_sp =
+ target->GetWatchpointList().FindByAddress((lldb::addr_t)exc_sub_code);
+ if (wp_sp && wp_sp->IsEnabled()) {
+ // Debugserver may piggyback the hardware index of the fired watchpoint
+ // in the exception data. Set the hardware index if that's the case.
+ if (exc_data_count >= 3)
+ wp_sp->SetHardwareIndex((uint32_t)exc_sub_sub_code);
+ return StopInfo::CreateStopReasonWithWatchpointID(thread, wp_sp->GetID());
+ }
+ }
+
+ // Try hardware breakpoint.
+ ProcessSP process_sp(thread.GetProcess());
+ if (process_sp) {
+ // The exc_sub_code indicates the data break address.
+ lldb::BreakpointSiteSP bp_sp =
+ process_sp->GetBreakpointSiteList().FindByAddress(
+ (lldb::addr_t)exc_sub_code);
+ if (bp_sp && bp_sp->IsEnabled()) {
+ // Debugserver may piggyback the hardware index of the fired breakpoint
+ // in the exception data. Set the hardware index if that's the case.
+ if (exc_data_count >= 3)
+ bp_sp->SetHardwareIndex((uint32_t)exc_sub_sub_code);
+ return StopInfo::CreateStopReasonWithBreakpointSiteID(thread,
+ bp_sp->GetID());
+ }
+ }
+
+ return nullptr;
+}
+
StopInfoSP StopInfoMachException::CreateStopReasonWithMachException(
Thread &thread, uint32_t exc_type, uint32_t exc_data_count,
uint64_t exc_code, uint64_t exc_sub_code, uint64_t exc_sub_sub_code,
@@ -350,22 +389,10 @@ StopInfoSP StopInfoMachException::CreateStopReasonWithMachException(
is_actual_breakpoint = true;
is_trace_if_actual_breakpoint_missing = true;
} else {
-
- // It's a watchpoint, then.
- // The exc_sub_code indicates the data break address.
- lldb::WatchpointSP wp_sp;
- if (target)
- wp_sp = target->GetWatchpointList().FindByAddress(
- (lldb::addr_t)exc_sub_code);
- if (wp_sp && wp_sp->IsEnabled()) {
- // Debugserver may piggyback the hardware index of the fired
- // watchpoint in the exception data. Set the hardware index if
- // that's the case.
- if (exc_data_count >= 3)
- wp_sp->SetHardwareIndex((uint32_t)exc_sub_sub_code);
- return StopInfo::CreateStopReasonWithWatchpointID(thread,
- wp_sp->GetID());
- }
+ if (StopInfoSP stop_info =
+ GetStopInfoForHardwareBP(thread, target, exc_data_count,
+ exc_sub_code, exc_sub_sub_code))
+ return stop_info;
}
} else if (exc_code == 2 || // EXC_I386_BPT
exc_code == 3) // EXC_I386_BPTFLT
diff --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.h b/lldb/source/Plugins/Process/Utility/StopInfoMachException.h
index 74c05812ab00..d9c1886d7096 100644
--- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.h
+++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_StopInfoMachException_h_
-#define liblldb_StopInfoMachException_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_STOPINFOMACHEXCEPTION_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_STOPINFOMACHEXCEPTION_H
#include <string>
@@ -48,4 +48,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_StopInfoMachException_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_STOPINFOMACHEXCEPTION_H
diff --git a/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp b/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp
index 80b04bb14f77..7469e7633e71 100644
--- a/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp
+++ b/lldb/source/Plugins/Process/Utility/ThreadMemory.cpp
@@ -1,5 +1,4 @@
-//===-- ThreadMemory.cpp ----------------------------------------------*- C++
-//-*-===//
+//===-- ThreadMemory.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -30,7 +29,8 @@ ThreadMemory::ThreadMemory(Process &process, lldb::tid_t tid,
llvm::StringRef name, llvm::StringRef queue,
lldb::addr_t register_data_addr)
: Thread(process, tid), m_backing_thread_sp(), m_thread_info_valobj_sp(),
- m_name(name), m_queue(queue), m_register_data_addr(register_data_addr) {}
+ m_name(std::string(name)), m_queue(std::string(queue)),
+ m_register_data_addr(register_data_addr) {}
ThreadMemory::~ThreadMemory() { DestroyThread(); }
@@ -54,20 +54,14 @@ RegisterContextSP ThreadMemory::GetRegisterContext() {
RegisterContextSP
ThreadMemory::CreateRegisterContextForFrame(StackFrame *frame) {
- RegisterContextSP reg_ctx_sp;
uint32_t concrete_frame_idx = 0;
if (frame)
concrete_frame_idx = frame->GetConcreteFrameIndex();
- if (concrete_frame_idx == 0) {
- reg_ctx_sp = GetRegisterContext();
- } else {
- Unwind *unwinder = GetUnwinder();
- if (unwinder != nullptr)
- reg_ctx_sp = unwinder->CreateRegisterContextForFrame(frame);
- }
- return reg_ctx_sp;
+ if (concrete_frame_idx == 0)
+ return GetRegisterContext();
+ return GetUnwinder().CreateRegisterContextForFrame(frame);
}
bool ThreadMemory::CalculateStopInfo() {
diff --git a/lldb/source/Plugins/Process/Utility/ThreadMemory.h b/lldb/source/Plugins/Process/Utility/ThreadMemory.h
index 85bc1451e4a0..d124f5780ea9 100644
--- a/lldb/source/Plugins/Process/Utility/ThreadMemory.h
+++ b/lldb/source/Plugins/Process/Utility/ThreadMemory.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadMemory_h_
-#define liblldb_ThreadMemory_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_THREADMEMORY_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_THREADMEMORY_H
#include <string>
@@ -100,7 +100,8 @@ protected:
lldb::addr_t m_register_data_addr;
private:
- DISALLOW_COPY_AND_ASSIGN(ThreadMemory);
+ ThreadMemory(const ThreadMemory &) = delete;
+ const ThreadMemory &operator=(const ThreadMemory &) = delete;
};
-#endif // liblldb_ThreadMemory_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_THREADMEMORY_H
diff --git a/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp b/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
deleted file mode 100644
index 558edeec1a37..000000000000
--- a/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
+++ /dev/null
@@ -1,247 +0,0 @@
-//===-- UnwindMacOSXFrameBackchain.cpp --------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Symbol/Function.h"
-#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Symbol/Symbol.h"
-#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/Thread.h"
-#include "lldb/Utility/ArchSpec.h"
-
-#include "RegisterContextMacOSXFrameBackchain.h"
-
-#include <memory>
-
-using namespace lldb;
-using namespace lldb_private;
-
-UnwindMacOSXFrameBackchain::UnwindMacOSXFrameBackchain(Thread &thread)
- : Unwind(thread), m_cursors() {}
-
-uint32_t UnwindMacOSXFrameBackchain::DoGetFrameCount() {
- if (m_cursors.empty()) {
- ExecutionContext exe_ctx(m_thread.shared_from_this());
- Target *target = exe_ctx.GetTargetPtr();
- if (target) {
- const ArchSpec &target_arch = target->GetArchitecture();
- // Frame zero should always be supplied by the thread...
- exe_ctx.SetFrameSP(m_thread.GetStackFrameAtIndex(0));
-
- if (target_arch.GetAddressByteSize() == 8)
- GetStackFrameData_x86_64(exe_ctx);
- else
- GetStackFrameData_i386(exe_ctx);
- }
- }
- return m_cursors.size();
-}
-
-bool UnwindMacOSXFrameBackchain::DoGetFrameInfoAtIndex(
- uint32_t idx, addr_t &cfa, addr_t &pc, bool &behaves_like_zeroth_frame) {
- const uint32_t frame_count = GetFrameCount();
- if (idx < frame_count) {
- if (m_cursors[idx].pc == LLDB_INVALID_ADDRESS)
- return false;
- if (m_cursors[idx].fp == LLDB_INVALID_ADDRESS)
- return false;
-
- pc = m_cursors[idx].pc;
- cfa = m_cursors[idx].fp;
- behaves_like_zeroth_frame = (idx == 0);
-
- return true;
- }
- return false;
-}
-
-lldb::RegisterContextSP
-UnwindMacOSXFrameBackchain::DoCreateRegisterContextForFrame(StackFrame *frame) {
- lldb::RegisterContextSP reg_ctx_sp;
- uint32_t concrete_idx = frame->GetConcreteFrameIndex();
- const uint32_t frame_count = GetFrameCount();
- if (concrete_idx < frame_count)
- reg_ctx_sp = std::make_shared<RegisterContextMacOSXFrameBackchain>(
- m_thread, concrete_idx, m_cursors[concrete_idx]);
- return reg_ctx_sp;
-}
-
-size_t UnwindMacOSXFrameBackchain::GetStackFrameData_i386(
- const ExecutionContext &exe_ctx) {
- m_cursors.clear();
-
- StackFrame *first_frame = exe_ctx.GetFramePtr();
-
- Process *process = exe_ctx.GetProcessPtr();
- if (process == nullptr)
- return 0;
-
- struct Frame_i386 {
- uint32_t fp;
- uint32_t pc;
- };
-
- RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
- assert(reg_ctx);
-
- Cursor cursor;
- cursor.pc = reg_ctx->GetPC(LLDB_INVALID_ADDRESS);
- cursor.fp = reg_ctx->GetFP(0);
-
- Frame_i386 frame = {static_cast<uint32_t>(cursor.fp),
- static_cast<uint32_t>(cursor.pc)};
-
- m_cursors.push_back(cursor);
-
- const size_t k_frame_size = sizeof(frame);
- Status error;
- while (frame.fp != 0 && frame.pc != 0 && ((frame.fp & 7) == 0)) {
- // Read both the FP and PC (8 bytes)
- if (process->ReadMemory(frame.fp, &frame.fp, k_frame_size, error) !=
- k_frame_size)
- break;
- if (frame.pc >= 0x1000) {
- cursor.pc = frame.pc;
- cursor.fp = frame.fp;
- m_cursors.push_back(cursor);
- }
- }
- if (!m_cursors.empty()) {
- lldb::addr_t first_frame_pc = m_cursors.front().pc;
- if (first_frame_pc != LLDB_INVALID_ADDRESS) {
- const SymbolContextItem resolve_scope =
- eSymbolContextModule | eSymbolContextCompUnit |
- eSymbolContextFunction | eSymbolContextSymbol;
-
- SymbolContext first_frame_sc(
- first_frame->GetSymbolContext(resolve_scope));
- const AddressRange *addr_range_ptr = nullptr;
- AddressRange range;
- if (first_frame_sc.function)
- addr_range_ptr = &first_frame_sc.function->GetAddressRange();
- else if (first_frame_sc.symbol) {
- range.GetBaseAddress() = first_frame_sc.symbol->GetAddress();
- range.SetByteSize(first_frame_sc.symbol->GetByteSize());
- addr_range_ptr = &range;
- }
-
- if (addr_range_ptr) {
- if (first_frame->GetFrameCodeAddress() ==
- addr_range_ptr->GetBaseAddress()) {
- // We are at the first instruction, so we can recover the previous PC
- // by dereferencing the SP
- lldb::addr_t first_frame_sp = reg_ctx->GetSP(0);
- // Read the real second frame return address into frame.pc
- if (first_frame_sp &&
- process->ReadMemory(first_frame_sp, &frame.pc, sizeof(frame.pc),
- error) == sizeof(frame.pc)) {
- cursor.fp = m_cursors.front().fp;
- cursor.pc = frame.pc; // Set the new second frame PC
-
- // Insert the second frame
- m_cursors.insert(m_cursors.begin() + 1, cursor);
-
- m_cursors.front().fp = first_frame_sp;
- }
- }
- }
- }
- }
- // uint32_t i=0;
- // printf(" PC FP\n");
- // printf(" ------------------ ------------------ \n");
- // for (i=0; i<m_cursors.size(); ++i)
- // {
- // printf("[%3u] 0x%16.16" PRIx64 " 0x%16.16" PRIx64 "\n", i,
- // m_cursors[i].pc, m_cursors[i].fp);
- // }
- return m_cursors.size();
-}
-
-size_t UnwindMacOSXFrameBackchain::GetStackFrameData_x86_64(
- const ExecutionContext &exe_ctx) {
- m_cursors.clear();
-
- Process *process = exe_ctx.GetProcessPtr();
- if (process == nullptr)
- return 0;
-
- StackFrame *first_frame = exe_ctx.GetFramePtr();
-
- struct Frame_x86_64 {
- uint64_t fp;
- uint64_t pc;
- };
-
- RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
- assert(reg_ctx);
-
- Cursor cursor;
- cursor.pc = reg_ctx->GetPC(LLDB_INVALID_ADDRESS);
- cursor.fp = reg_ctx->GetFP(0);
-
- Frame_x86_64 frame = {cursor.fp, cursor.pc};
-
- m_cursors.push_back(cursor);
- Status error;
- const size_t k_frame_size = sizeof(frame);
- while (frame.fp != 0 && frame.pc != 0 && ((frame.fp & 7) == 0)) {
- // Read both the FP and PC (16 bytes)
- if (process->ReadMemory(frame.fp, &frame.fp, k_frame_size, error) !=
- k_frame_size)
- break;
-
- if (frame.pc >= 0x1000) {
- cursor.pc = frame.pc;
- cursor.fp = frame.fp;
- m_cursors.push_back(cursor);
- }
- }
- if (!m_cursors.empty()) {
- lldb::addr_t first_frame_pc = m_cursors.front().pc;
- if (first_frame_pc != LLDB_INVALID_ADDRESS) {
- const SymbolContextItem resolve_scope =
- eSymbolContextModule | eSymbolContextCompUnit |
- eSymbolContextFunction | eSymbolContextSymbol;
-
- SymbolContext first_frame_sc(
- first_frame->GetSymbolContext(resolve_scope));
- const AddressRange *addr_range_ptr = nullptr;
- AddressRange range;
- if (first_frame_sc.function)
- addr_range_ptr = &first_frame_sc.function->GetAddressRange();
- else if (first_frame_sc.symbol) {
- range.GetBaseAddress() = first_frame_sc.symbol->GetAddress();
- range.SetByteSize(first_frame_sc.symbol->GetByteSize());
- addr_range_ptr = &range;
- }
-
- if (addr_range_ptr) {
- if (first_frame->GetFrameCodeAddress() ==
- addr_range_ptr->GetBaseAddress()) {
- // We are at the first instruction, so we can recover the previous PC
- // by dereferencing the SP
- lldb::addr_t first_frame_sp = reg_ctx->GetSP(0);
- // Read the real second frame return address into frame.pc
- if (process->ReadMemory(first_frame_sp, &frame.pc, sizeof(frame.pc),
- error) == sizeof(frame.pc)) {
- cursor.fp = m_cursors.front().fp;
- cursor.pc = frame.pc; // Set the new second frame PC
-
- // Insert the second frame
- m_cursors.insert(m_cursors.begin() + 1, cursor);
-
- m_cursors.front().fp = first_frame_sp;
- }
- }
- }
- }
- }
- return m_cursors.size();
-}
diff --git a/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h b/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h
deleted file mode 100644
index f0bde90a53be..000000000000
--- a/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h
+++ /dev/null
@@ -1,54 +0,0 @@
-//===-- UnwindMacOSXFrameBackchain.h ----------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef lldb_UnwindMacOSXFrameBackchain_h_
-#define lldb_UnwindMacOSXFrameBackchain_h_
-
-#include <vector>
-
-#include "lldb/Target/Unwind.h"
-#include "lldb/lldb-private.h"
-
-class UnwindMacOSXFrameBackchain : public lldb_private::Unwind {
-public:
- UnwindMacOSXFrameBackchain(lldb_private::Thread &thread);
-
- ~UnwindMacOSXFrameBackchain() override = default;
-
-protected:
- void DoClear() override { m_cursors.clear(); }
-
- uint32_t DoGetFrameCount() override;
-
- bool DoGetFrameInfoAtIndex(uint32_t frame_idx, lldb::addr_t &cfa,
- lldb::addr_t &pc,
- bool &behaves_like_zeroth_frame) override;
-
- lldb::RegisterContextSP
- DoCreateRegisterContextForFrame(lldb_private::StackFrame *frame) override;
-
- friend class RegisterContextMacOSXFrameBackchain;
-
- struct Cursor {
- lldb::addr_t pc; // Program counter
- lldb::addr_t fp; // Frame pointer for us with backchain
- };
-
-private:
- std::vector<Cursor> m_cursors;
-
- size_t GetStackFrameData_i386(const lldb_private::ExecutionContext &exe_ctx);
-
- size_t
- GetStackFrameData_x86_64(const lldb_private::ExecutionContext &exe_ctx);
-
- // For UnwindMacOSXFrameBackchain only
- DISALLOW_COPY_AND_ASSIGN(UnwindMacOSXFrameBackchain);
-};
-
-#endif // lldb_UnwindMacOSXFrameBackchain_h_
diff --git a/lldb/source/Plugins/Process/Utility/lldb-arm-register-enums.h b/lldb/source/Plugins/Process/Utility/lldb-arm-register-enums.h
index 39cbf01ea9d2..8f0eed4f02c9 100644
--- a/lldb/source/Plugins/Process/Utility/lldb-arm-register-enums.h
+++ b/lldb/source/Plugins/Process/Utility/lldb-arm-register-enums.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_arm_register_enums_h
-#define lldb_arm_register_enums_h
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_ARM_REGISTER_ENUMS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_ARM_REGISTER_ENUMS_H
namespace lldb_private {
// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
@@ -196,4 +196,4 @@ enum {
};
}
-#endif // #ifndef lldb_arm64_register_enums_h
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_ARM_REGISTER_ENUMS_H
diff --git a/lldb/source/Plugins/Process/Utility/lldb-arm64-register-enums.h b/lldb/source/Plugins/Process/Utility/lldb-arm64-register-enums.h
index cc414dcde3cf..39d47b8801cc 100644
--- a/lldb/source/Plugins/Process/Utility/lldb-arm64-register-enums.h
+++ b/lldb/source/Plugins/Process/Utility/lldb-arm64-register-enums.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_arm64_register_enums_h
-#define lldb_arm64_register_enums_h
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_ARM64_REGISTER_ENUMS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_ARM64_REGISTER_ENUMS_H
namespace lldb_private {
// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
@@ -261,4 +261,4 @@ enum {
};
}
-#endif // #ifndef lldb_arm64_register_enums_h
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_ARM64_REGISTER_ENUMS_H
diff --git a/lldb/source/Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h b/lldb/source/Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h
index d97f77122426..e6a7efd00f67 100644
--- a/lldb/source/Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h
+++ b/lldb/source/Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_mips_freebsd_register_enums_h
-#define lldb_mips_freebsd_register_enums_h
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_MIPS_FREEBSD_REGISTER_ENUMS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_MIPS_FREEBSD_REGISTER_ENUMS_H
namespace lldb_private {
// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
@@ -62,4 +62,4 @@ enum {
k_num_gpr_registers_mips64 = k_last_gpr_mips64 - k_first_gpr_mips64 + 1
};
}
-#endif // #ifndef lldb_mips_freebsd_register_enums_h
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_MIPS_FREEBSD_REGISTER_ENUMS_H
diff --git a/lldb/source/Plugins/Process/Utility/lldb-mips-linux-register-enums.h b/lldb/source/Plugins/Process/Utility/lldb-mips-linux-register-enums.h
index 2f68b8022c9a..348af27d2809 100644
--- a/lldb/source/Plugins/Process/Utility/lldb-mips-linux-register-enums.h
+++ b/lldb/source/Plugins/Process/Utility/lldb-mips-linux-register-enums.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_mips_linux_register_enums_h
-#define lldb_mips_linux_register_enums_h
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_MIPS_LINUX_REGISTER_ENUMS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_MIPS_LINUX_REGISTER_ENUMS_H
namespace lldb_private {
// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
@@ -357,4 +357,4 @@ enum {
};
}
-#endif // #ifndef lldb_mips_linux_register_enums_h
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_MIPS_LINUX_REGISTER_ENUMS_H
diff --git a/lldb/source/Plugins/Process/Utility/lldb-ppc64-register-enums.h b/lldb/source/Plugins/Process/Utility/lldb-ppc64-register-enums.h
index 6edf7ee3864d..40a75c006d84 100644
--- a/lldb/source/Plugins/Process/Utility/lldb-ppc64-register-enums.h
+++ b/lldb/source/Plugins/Process/Utility/lldb-ppc64-register-enums.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_ppc64_register_enums_h
-#define lldb_ppc64_register_enums_h
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_PPC64_REGISTER_ENUMS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_PPC64_REGISTER_ENUMS_H
// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
@@ -133,4 +133,4 @@ enum {
k_num_vmx_registers_ppc64 = k_last_vmx_ppc64 - k_first_vmx_ppc64 + 1,
};
-#endif // #ifndef lldb_ppc64_register_enums_h
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_PPC64_REGISTER_ENUMS_H
diff --git a/lldb/source/Plugins/Process/Utility/lldb-ppc64le-register-enums.h b/lldb/source/Plugins/Process/Utility/lldb-ppc64le-register-enums.h
index 0c381a5f3918..a7b5bc5ad9e3 100644
--- a/lldb/source/Plugins/Process/Utility/lldb-ppc64le-register-enums.h
+++ b/lldb/source/Plugins/Process/Utility/lldb-ppc64le-register-enums.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_ppc64le_register_enums_h
-#define lldb_ppc64le_register_enums_h
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_PPC64LE_REGISTER_ENUMS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_PPC64LE_REGISTER_ENUMS_H
// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
@@ -204,4 +204,4 @@ enum {
k_num_vsx_registers_ppc64le = k_last_vsx_ppc64le - k_first_vsx_ppc64le + 1,
};
-#endif // #ifndef lldb_ppc64le_register_enums_h
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_PPC64LE_REGISTER_ENUMS_H
diff --git a/lldb/source/Plugins/Process/Utility/lldb-s390x-register-enums.h b/lldb/source/Plugins/Process/Utility/lldb-s390x-register-enums.h
index bd6626108290..23c441e1c803 100644
--- a/lldb/source/Plugins/Process/Utility/lldb-s390x-register-enums.h
+++ b/lldb/source/Plugins/Process/Utility/lldb-s390x-register-enums.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_s390x_register_enums_h
-#define lldb_s390x_register_enums_h
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_S390X_REGISTER_ENUMS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_S390X_REGISTER_ENUMS_H
namespace lldb_private {
// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
@@ -87,4 +87,4 @@ enum {
};
}
-#endif // #ifndef lldb_s390x_register_enums_h
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_S390X_REGISTER_ENUMS_H
diff --git a/lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h b/lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h
index bfdd586d9ded..35f1a4075d09 100644
--- a/lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h
+++ b/lldb/source/Plugins/Process/Utility/lldb-x86-register-enums.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_x86_register_enums_h
-#define lldb_x86_register_enums_h
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_X86_REGISTER_ENUMS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_X86_REGISTER_ENUMS_H
namespace lldb_private {
// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
@@ -113,7 +113,8 @@ enum {
lldb_bndstatus_i386,
k_last_mpxc_i386 = lldb_bndstatus_i386,
- lldb_dr0_i386,
+ k_first_dbr_i386,
+ lldb_dr0_i386 = k_first_dbr_i386,
lldb_dr1_i386,
lldb_dr2_i386,
lldb_dr3_i386,
@@ -121,6 +122,7 @@ enum {
lldb_dr5_i386,
lldb_dr6_i386,
lldb_dr7_i386,
+ k_last_dbr_i386 = lldb_dr7_i386,
k_num_registers_i386,
k_num_gpr_registers_i386 = k_last_gpr_i386 - k_first_gpr_i386 + 1,
@@ -131,6 +133,7 @@ enum {
k_num_fpr_registers_i386 +
k_num_avx_registers_i386 +
k_num_mpx_registers_i386,
+ k_num_dbr_registers_i386 = k_last_dbr_i386 - k_first_dbr_i386 + 1,
};
// Internal codes for all x86_64 registers.
@@ -318,4 +321,4 @@ enum {
};
}
-#endif // #ifndef lldb_x86_register_enums_h
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_LLDB_X86_REGISTER_ENUMS_H
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index ab23589ae9a9..aa95e92607ad 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -1,4 +1,4 @@
-//===-- ProcessElfCore.cpp --------------------------------------*- C++ -*-===//
+//===-- ProcessElfCore.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -35,6 +35,8 @@
using namespace lldb_private;
namespace ELF = llvm::ELF;
+LLDB_PLUGIN_DEFINE(ProcessElfCore)
+
ConstString ProcessElfCore::GetPluginNameStatic() {
static ConstString g_name("elf-core");
return g_name;
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
index 829fe9ac7199..6f6309799f43 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -13,8 +13,8 @@
// space.
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ProcessElfCore_h_
-#define liblldb_ProcessElfCore_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_PROCESSELFCORE_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_PROCESSELFCORE_H
#include <list>
#include <vector>
@@ -125,7 +125,8 @@ private:
lldb::ModuleSP m_core_module_sp;
lldb_private::FileSpec m_core_file;
std::string m_dyld_plugin_name;
- DISALLOW_COPY_AND_ASSIGN(ProcessElfCore);
+ ProcessElfCore(const ProcessElfCore &) = delete;
+ const ProcessElfCore &operator=(const ProcessElfCore &) = delete;
// True if m_thread_contexts contains valid entries
bool m_thread_data_valid = false;
@@ -165,4 +166,4 @@ private:
llvm::Error parseLinuxNotes(llvm::ArrayRef<lldb_private::CoreNote> notes);
};
-#endif // liblldb_ProcessElfCore_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_PROCESSELFCORE_H
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp
index fa05c457fc61..b76f26a584c0 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextPOSIXCore_arm.cpp ------------------------*- C++ -*-===//
+//===-- RegisterContextPOSIXCore_arm.cpp ----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -44,10 +44,12 @@ bool RegisterContextCorePOSIX_arm::WriteFPR() {
bool RegisterContextCorePOSIX_arm::ReadRegister(const RegisterInfo *reg_info,
RegisterValue &value) {
lldb::offset_t offset = reg_info->byte_offset;
- uint64_t v = m_gpr.GetMaxU64(&offset, reg_info->byte_size);
- if (offset == reg_info->byte_offset + reg_info->byte_size) {
- value = v;
- return true;
+ if (offset + reg_info->byte_size <= GetGPRSize()) {
+ uint64_t v = m_gpr.GetMaxU64(&offset, reg_info->byte_size);
+ if (offset == reg_info->byte_offset + reg_info->byte_size) {
+ value = v;
+ return true;
+ }
}
return false;
}
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h
index adda43ebccbc..f9ec08ed35fc 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextCorePOSIX_arm_h_
-#define liblldb_RegisterContextCorePOSIX_arm_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_ARM_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_ARM_H
#include "Plugins/Process/Utility/RegisterContextPOSIX_arm.h"
#include "Plugins/Process/elf-core/RegisterUtilities.h"
@@ -50,4 +50,4 @@ private:
lldb_private::DataExtractor m_gpr;
};
-#endif // liblldb_RegisterContextCorePOSIX_arm_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_ARM_H
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
index e477c438ba12..685567416983 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextPOSIXCore_arm64.cpp ----------------------*- C++ -*-===//
+//===-- RegisterContextPOSIXCore_arm64.cpp --------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -17,13 +17,16 @@
using namespace lldb_private;
RegisterContextCorePOSIX_arm64::RegisterContextCorePOSIX_arm64(
- Thread &thread, RegisterInfoInterface *register_info,
+ Thread &thread, std::unique_ptr<RegisterInfoPOSIX_arm64> register_info,
const DataExtractor &gpregset, llvm::ArrayRef<CoreNote> notes)
- : RegisterContextPOSIX_arm64(thread, 0, register_info) {
+ : RegisterContextPOSIX_arm64(thread, std::move(register_info)) {
m_gpr_buffer = std::make_shared<DataBufferHeap>(gpregset.GetDataStart(),
gpregset.GetByteSize());
m_gpr.SetData(m_gpr_buffer);
m_gpr.SetByteOrder(gpregset.GetByteOrder());
+
+ m_fpregset = getRegset(
+ notes, m_register_info_up->GetTargetArchitecture().GetTriple(), FPR_Desc);
}
RegisterContextCorePOSIX_arm64::~RegisterContextCorePOSIX_arm64() {}
@@ -45,11 +48,26 @@ bool RegisterContextCorePOSIX_arm64::WriteFPR() {
bool RegisterContextCorePOSIX_arm64::ReadRegister(const RegisterInfo *reg_info,
RegisterValue &value) {
lldb::offset_t offset = reg_info->byte_offset;
- uint64_t v = m_gpr.GetMaxU64(&offset, reg_info->byte_size);
- if (offset == reg_info->byte_offset + reg_info->byte_size) {
- value = v;
- return true;
+ if (offset + reg_info->byte_size <= GetGPRSize()) {
+ uint64_t v = m_gpr.GetMaxU64(&offset, reg_info->byte_size);
+ if (offset == reg_info->byte_offset + reg_info->byte_size) {
+ value = v;
+ return true;
+ }
}
+
+ const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
+ if (reg == LLDB_INVALID_REGNUM)
+ return false;
+
+ offset -= GetGPRSize();
+ if (IsFPR(reg) && offset + reg_info->byte_size <= GetFPUSize()) {
+ Status error;
+ value.SetFromMemoryData(reg_info, m_fpregset.GetDataStart() + offset,
+ reg_info->byte_size, lldb::eByteOrderLittle, error);
+ return error.Success();
+ }
+
return false;
}
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
index de6d819c29ce..830e0ff91e4c 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextCorePOSIX_arm64_h_
-#define liblldb_RegisterContextCorePOSIX_arm64_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_ARM64_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_ARM64_H
#include "Plugins/Process/Utility/RegisterContextPOSIX_arm64.h"
#include "Plugins/Process/elf-core/RegisterUtilities.h"
@@ -18,7 +18,7 @@ class RegisterContextCorePOSIX_arm64 : public RegisterContextPOSIX_arm64 {
public:
RegisterContextCorePOSIX_arm64(
lldb_private::Thread &thread,
- lldb_private::RegisterInfoInterface *register_info,
+ std::unique_ptr<RegisterInfoPOSIX_arm64> register_info,
const lldb_private::DataExtractor &gpregset,
llvm::ArrayRef<lldb_private::CoreNote> notes);
@@ -48,6 +48,7 @@ protected:
private:
lldb::DataBufferSP m_gpr_buffer;
lldb_private::DataExtractor m_gpr;
+ lldb_private::DataExtractor m_fpregset;
};
-#endif // liblldb_RegisterContextCorePOSIX_arm64_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_ARM64_H
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp
index 3601f3b3b216..b5b83d899a44 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextPOSIXCore_mips64.cpp ---------------------*- C++ -*-===//
+//===-- RegisterContextPOSIXCore_mips64.cpp -------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h
index 999c9451573b..b42a76c082f0 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextCorePOSIX_mips64_h_
-#define liblldb_RegisterContextCorePOSIX_mips64_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_MIPS64_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_MIPS64_H
#include "Plugins/Process/Utility/RegisterContextPOSIX_mips64.h"
#include "Plugins/Process/elf-core/RegisterUtilities.h"
@@ -52,4 +52,4 @@ private:
lldb_private::DataExtractor m_fpr;
};
-#endif // liblldb_RegisterContextCorePOSIX_mips64_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_MIPS64_H
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp
index 6984bf4ee9b8..e15cd47cd7da 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextPOSIXCore_powerpc.cpp --------------------*- C++ -*-===//
+//===-- RegisterContextPOSIXCore_powerpc.cpp ------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h
index 7684c0b31837..cf50b6e0bf70 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextCorePOSIX_powerpc_h_
-#define liblldb_RegisterContextCorePOSIX_powerpc_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_POWERPC_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_POWERPC_H
#include "Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h"
#include "Plugins/Process/elf-core/RegisterUtilities.h"
@@ -57,4 +57,4 @@ private:
lldb_private::DataExtractor m_vec;
};
-#endif // liblldb_RegisterContextCorePOSIX_powerpc_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_POWERPC_H
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp
index 0eebf474f60e..d44fb399e18a 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextPOSIXCore_ppc64le.cpp --------------------*- C++ -*-===//
+//===-- RegisterContextPOSIXCore_ppc64le.cpp ------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.h b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.h
index 6e01d23dd656..8de77a7e25bf 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.h
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextCorePOSIX_ppc64le_h_
-#define liblldb_RegisterContextCorePOSIX_ppc64le_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_PPC64LE_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_PPC64LE_H
#include "Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.h"
#include "Plugins/Process/elf-core/RegisterUtilities.h"
@@ -45,4 +45,4 @@ private:
lldb_private::DataExtractor m_vsx;
};
-#endif // liblldb_RegisterContextCorePOSIX_ppc64le_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_PPC64LE_H
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp
index d84fc3e74395..c3aa92c9f86c 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextPOSIXCore_s390x.cpp ----------------------*- C++ -*-===//
+//===-- RegisterContextPOSIXCore_s390x.cpp --------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h
index 729617649c4f..4560f062e06f 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextCorePOSIX_s390x_h_
-#define liblldb_RegisterContextCorePOSIX_s390x_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_S390X_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_S390X_H
#include "Plugins/Process/Utility/RegisterContextPOSIX_s390x.h"
#include "Plugins/Process/elf-core/RegisterUtilities.h"
@@ -52,4 +52,4 @@ private:
lldb_private::DataExtractor m_fpr;
};
-#endif // liblldb_RegisterContextCorePOSIX_s390x_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_S390X_H
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
index 4454857e1799..6eaad9f381d6 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextPOSIXCore_x86_64.cpp ---------------------*- C++ -*-===//
+//===-- RegisterContextPOSIXCore_x86_64.cpp -------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
index f41991c240d2..9adfbf7e6852 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextCorePOSIX_x86_64_h_
-#define liblldb_RegisterContextCorePOSIX_x86_64_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_X86_64_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_X86_64_H
#include "Plugins/Process/Utility/RegisterContextPOSIX_x86.h"
#include "Plugins/Process/elf-core/RegisterUtilities.h"
@@ -46,4 +46,4 @@ private:
std::unique_ptr<uint8_t[]> m_fpregset;
};
-#endif // liblldb_RegisterContextCorePOSIX_x86_64_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERCONTEXTPOSIXCORE_X86_64_H
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterUtilities.cpp b/lldb/source/Plugins/Process/elf-core/RegisterUtilities.cpp
index c8829d612b31..0c21c0f50abb 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterUtilities.cpp
+++ b/lldb/source/Plugins/Process/elf-core/RegisterUtilities.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterUtilities.cpp -----------------------------------*- C++ -*-===//
+//===-- RegisterUtilities.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h b/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
index 49ad425db445..4e08aa280817 100644
--- a/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
+++ b/lldb/source/Plugins/Process/elf-core/RegisterUtilities.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_REGISTERUTILITIES_H
-#define LLDB_REGISTERUTILITIES_H
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERUTILITIES_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERUTILITIES_H
#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
#include "lldb/Utility/DataExtractor.h"
@@ -118,4 +118,4 @@ constexpr RegsetDesc PPC_VSX_Desc[] = {
} // namespace lldb_private
-#endif // #ifndef LLDB_REGISTERUTILITIES_H
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_REGISTERUTILITIES_H
diff --git a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
index 508c8a3108a6..6b5acfa4bc1b 100644
--- a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadElfCore.cpp --------------------------------------*- C++ -*-===//
+//===-- ThreadElfCore.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -82,7 +82,6 @@ ThreadElfCore::CreateRegisterContextForFrame(StackFrame *frame) {
case llvm::Triple::FreeBSD: {
switch (arch.GetMachine()) {
case llvm::Triple::aarch64:
- reg_interface = new RegisterInfoPOSIX_arm64(arch);
break;
case llvm::Triple::arm:
reg_interface = new RegisterInfoPOSIX_arm(arch);
@@ -111,7 +110,6 @@ ThreadElfCore::CreateRegisterContextForFrame(StackFrame *frame) {
case llvm::Triple::NetBSD: {
switch (arch.GetMachine()) {
case llvm::Triple::aarch64:
- reg_interface = new RegisterInfoPOSIX_arm64(arch);
break;
case llvm::Triple::x86_64:
reg_interface = new RegisterContextNetBSD_x86_64(arch);
@@ -128,7 +126,6 @@ ThreadElfCore::CreateRegisterContextForFrame(StackFrame *frame) {
reg_interface = new RegisterInfoPOSIX_arm(arch);
break;
case llvm::Triple::aarch64:
- reg_interface = new RegisterInfoPOSIX_arm64(arch);
break;
case llvm::Triple::mipsel:
case llvm::Triple::mips:
@@ -159,7 +156,6 @@ ThreadElfCore::CreateRegisterContextForFrame(StackFrame *frame) {
case llvm::Triple::OpenBSD: {
switch (arch.GetMachine()) {
case llvm::Triple::aarch64:
- reg_interface = new RegisterInfoPOSIX_arm64(arch);
break;
case llvm::Triple::arm:
reg_interface = new RegisterInfoPOSIX_arm(arch);
@@ -180,7 +176,7 @@ ThreadElfCore::CreateRegisterContextForFrame(StackFrame *frame) {
break;
}
- if (!reg_interface) {
+ if (!reg_interface && arch.GetMachine() != llvm::Triple::aarch64) {
LLDB_LOGF(log, "elf-core::%s:: Architecture(%d) or OS(%d) not supported",
__FUNCTION__, arch.GetMachine(), arch.GetTriple().getOS());
assert(false && "Architecture or OS not supported");
@@ -189,7 +185,8 @@ ThreadElfCore::CreateRegisterContextForFrame(StackFrame *frame) {
switch (arch.GetMachine()) {
case llvm::Triple::aarch64:
m_thread_reg_ctx_sp = std::make_shared<RegisterContextCorePOSIX_arm64>(
- *this, reg_interface, m_gpregset_data, m_notes);
+ *this, std::make_unique<RegisterInfoPOSIX_arm64>(arch),
+ m_gpregset_data, m_notes);
break;
case llvm::Triple::arm:
m_thread_reg_ctx_sp = std::make_shared<RegisterContextCorePOSIX_arm>(
@@ -229,9 +226,7 @@ ThreadElfCore::CreateRegisterContextForFrame(StackFrame *frame) {
reg_ctx_sp = m_thread_reg_ctx_sp;
} else {
- Unwind *unwinder = GetUnwinder();
- if (unwinder != nullptr)
- reg_ctx_sp = unwinder->CreateRegisterContextForFrame(frame);
+ reg_ctx_sp = GetUnwinder().CreateRegisterContextForFrame(frame);
}
return reg_ctx_sp;
}
@@ -296,25 +291,25 @@ Status ELFLinuxPrStatus::Parse(const DataExtractor &data,
pr_cursig = data.GetU16(&offset);
offset += 2; // pad
- pr_sigpend = data.GetPointer(&offset);
- pr_sighold = data.GetPointer(&offset);
+ pr_sigpend = data.GetAddress(&offset);
+ pr_sighold = data.GetAddress(&offset);
pr_pid = data.GetU32(&offset);
pr_ppid = data.GetU32(&offset);
pr_pgrp = data.GetU32(&offset);
pr_sid = data.GetU32(&offset);
- pr_utime.tv_sec = data.GetPointer(&offset);
- pr_utime.tv_usec = data.GetPointer(&offset);
+ pr_utime.tv_sec = data.GetAddress(&offset);
+ pr_utime.tv_usec = data.GetAddress(&offset);
- pr_stime.tv_sec = data.GetPointer(&offset);
- pr_stime.tv_usec = data.GetPointer(&offset);
+ pr_stime.tv_sec = data.GetAddress(&offset);
+ pr_stime.tv_usec = data.GetAddress(&offset);
- pr_cutime.tv_sec = data.GetPointer(&offset);
- pr_cutime.tv_usec = data.GetPointer(&offset);
+ pr_cutime.tv_sec = data.GetAddress(&offset);
+ pr_cutime.tv_usec = data.GetAddress(&offset);
- pr_cstime.tv_sec = data.GetPointer(&offset);
- pr_cstime.tv_usec = data.GetPointer(&offset);
+ pr_cstime.tv_sec = data.GetAddress(&offset);
+ pr_cstime.tv_usec = data.GetAddress(&offset);
return error;
}
@@ -367,7 +362,7 @@ Status ELFLinuxPrPsInfo::Parse(const DataExtractor &data,
offset += 4;
}
- pr_flag = data.GetPointer(&offset);
+ pr_flag = data.GetAddress(&offset);
if (arch.IsMIPS()) {
// The pr_uid and pr_gid is always 32 bit irrespective of platforms
diff --git a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.h b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.h
index ddcf35013b34..8d973bb840d2 100644
--- a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.h
+++ b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadElfCore_h_
-#define liblldb_ThreadElfCore_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_THREADELFCORE_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_THREADELFCORE_H
#include "Plugins/Process/elf-core/RegisterUtilities.h"
#include "lldb/Target/Thread.h"
@@ -173,4 +173,4 @@ protected:
bool CalculateStopInfo() override;
};
-#endif // liblldb_ThreadElfCore_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_ELF_CORE_THREADELFCORE_H
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
index 064bbde8442e..fdaa60e2df41 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
@@ -1,4 +1,4 @@
-//===-- GDBRemoteClientBase.cpp ---------------------------------*- C++ -*-===//
+//===-- GDBRemoteClientBase.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -41,7 +41,7 @@ StateType GDBRemoteClientBase::SendContinuePacketAndWaitForResponse(
{
std::lock_guard<std::mutex> lock(m_mutex);
- m_continue_packet = payload;
+ m_continue_packet = std::string(payload);
m_should_stop = false;
}
ContinueLock cont_lock(*this);
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h
index ea294ffcef26..cd9f6ebd7642 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_GDBRemoteClientBase_h_
-#define liblldb_GDBRemoteClientBase_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECLIENTBASE_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECLIENTBASE_H
#include "GDBRemoteCommunication.h"
@@ -149,4 +149,4 @@ private:
} // namespace process_gdb_remote
} // namespace lldb_private
-#endif // liblldb_GDBRemoteCommunicationClient_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECLIENTBASE_H
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 7cea013eea7f..bfacd41dc1a3 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -1,4 +1,4 @@
-//===-- GDBRemoteCommunication.cpp ------------------------------*- C++ -*-===//
+//===-- GDBRemoteCommunication.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -50,7 +50,7 @@
#include <compression.h>
#endif
-#if LLVM_ENABLE_ZLIB
+#if defined(HAVE_LIBZ)
#include <zlib.h>
#endif
@@ -125,7 +125,7 @@ GDBRemoteCommunication::SendPacketNoLock(llvm::StringRef payload) {
packet.Write(payload.data(), payload.size());
packet.PutChar('#');
packet.PutHex8(CalculcateChecksum(payload));
- std::string packet_str = packet.GetString();
+ std::string packet_str = std::string(packet.GetString());
return SendRawPacketNoLock(packet_str);
}
@@ -582,7 +582,7 @@ bool GDBRemoteCommunication::DecompressPacket() {
}
#endif
-#if LLVM_ENABLE_ZLIB
+#if defined(HAVE_LIBZ)
if (decompressed_bytes == 0 && decompressed_bufsize != ULONG_MAX &&
decompressed_buffer != nullptr &&
m_compression_type == CompressionType::ZlibDeflate) {
@@ -763,7 +763,7 @@ GDBRemoteCommunication::CheckForPacket(const uint8_t *src, size_t src_len,
if (m_bytes[0] == '$' && total_length > 4) {
for (size_t i = 0; !binary && i < total_length; ++i) {
unsigned char c = m_bytes[i];
- if (isprint(c) == 0 && isspace(c) == 0) {
+ if (!llvm::isPrint(c) && !llvm::isSpace(c)) {
binary = true;
}
}
@@ -810,31 +810,9 @@ GDBRemoteCommunication::CheckForPacket(const uint8_t *src, size_t src_len,
GDBRemotePacket::ePacketTypeRecv, total_length);
// Copy the packet from m_bytes to packet_str expanding the run-length
- // encoding in the process. Reserve enough byte for the most common case
- // (no RLE used)
- std ::string packet_str;
- packet_str.reserve(m_bytes.length());
- for (std::string::const_iterator c = m_bytes.begin() + content_start;
- c != m_bytes.begin() + content_end; ++c) {
- if (*c == '*') {
- // '*' indicates RLE. Next character will give us the repeat count
- // and previous character is what is to be repeated.
- char char_to_repeat = packet_str.back();
- // Number of time the previous character is repeated
- int repeat_count = *++c + 3 - ' ';
- // We have the char_to_repeat and repeat_count. Now push it in the
- // packet.
- for (int i = 0; i < repeat_count; ++i)
- packet_str.push_back(char_to_repeat);
- } else if (*c == 0x7d) {
- // 0x7d is the escape character. The next character is to be XOR'd
- // with 0x20.
- char escapee = *++c ^ 0x20;
- packet_str.push_back(escapee);
- } else {
- packet_str.push_back(*c);
- }
- }
+ // encoding in the process.
+ std ::string packet_str =
+ ExpandRLE(m_bytes.substr(content_start, content_end - content_start));
packet = StringExtractorGDBRemote(packet_str);
if (m_bytes[0] == '$' || m_bytes[0] == '%') {
@@ -891,7 +869,7 @@ Status GDBRemoteCommunication::StartListenThread(const char *hostname,
else
snprintf(listen_url, sizeof(listen_url), "listen://%i", port);
m_listen_url = listen_url;
- SetConnection(new ConnectionFileDescriptor());
+ SetConnection(std::make_unique<ConnectionFileDescriptor>());
llvm::Expected<HostThread> listen_thread = ThreadLauncher::LaunchThread(
listen_url, GDBRemoteCommunication::ListenThread, this);
if (!listen_thread)
@@ -1274,11 +1252,12 @@ GDBRemoteCommunication::ConnectLocally(GDBRemoteCommunication &client,
return llvm::createStringError(llvm::inconvertibleErrorCode(),
"Unable to connect: %s", status.AsCString());
- client.SetConnection(conn_up.release());
+ client.SetConnection(std::move(conn_up));
if (llvm::Error error = accept_status.get().ToError())
return error;
- server.SetConnection(new ConnectionFileDescriptor(accept_socket));
+ server.SetConnection(
+ std::make_unique<ConnectionFileDescriptor>(accept_socket));
return llvm::Error::success();
}
@@ -1382,3 +1361,30 @@ void llvm::format_provider<GDBRemoteCommunication::PacketResult>::format(
break;
}
}
+
+std::string GDBRemoteCommunication::ExpandRLE(std::string packet) {
+ // Reserve enough byte for the most common case (no RLE used).
+ std::string decoded;
+ decoded.reserve(packet.size());
+ for (std::string::const_iterator c = packet.begin(); c != packet.end(); ++c) {
+ if (*c == '*') {
+ // '*' indicates RLE. Next character will give us the repeat count and
+ // previous character is what is to be repeated.
+ char char_to_repeat = decoded.back();
+ // Number of time the previous character is repeated.
+ int repeat_count = *++c + 3 - ' ';
+ // We have the char_to_repeat and repeat_count. Now push it in the
+ // packet.
+ for (int i = 0; i < repeat_count; ++i)
+ decoded.push_back(char_to_repeat);
+ } else if (*c == 0x7d) {
+ // 0x7d is the escape character. The next character is to be XOR'd with
+ // 0x20.
+ char escapee = *++c ^ 0x20;
+ decoded.push_back(escapee);
+ } else {
+ decoded.push_back(*c);
+ }
+ }
+ return decoded;
+}
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
index 0b670018bd69..b1e2075a64fe 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_GDBRemoteCommunication_h_
-#define liblldb_GDBRemoteCommunication_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATION_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATION_H
#include "GDBRemoteCommunicationHistory.h"
@@ -142,6 +142,9 @@ public:
static llvm::Error ConnectLocally(GDBRemoteCommunication &client,
GDBRemoteCommunication &server);
+ /// Expand GDB run-length encoding.
+ static std::string ExpandRLE(std::string);
+
protected:
std::chrono::seconds m_packet_timeout;
uint32_t m_echo_number;
@@ -223,7 +226,9 @@ private:
void *m_decompression_scratch = nullptr;
#endif
- DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunication);
+ GDBRemoteCommunication(const GDBRemoteCommunication &) = delete;
+ const GDBRemoteCommunication &
+ operator=(const GDBRemoteCommunication &) = delete;
};
} // namespace process_gdb_remote
@@ -239,4 +244,4 @@ struct format_provider<
};
} // namespace llvm
-#endif // liblldb_GDBRemoteCommunication_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATION_H
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index b2f1ee527e8b..c75d5e106cd0 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1,4 +1,4 @@
-//===-- GDBRemoteCommunicationClient.cpp ------------------------*- C++ -*-===//
+//===-- GDBRemoteCommunicationClient.cpp ----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -45,6 +45,13 @@ using namespace lldb_private::process_gdb_remote;
using namespace lldb_private;
using namespace std::chrono;
+llvm::raw_ostream &process_gdb_remote::operator<<(llvm::raw_ostream &os,
+ const QOffsets &offsets) {
+ return os << llvm::formatv(
+ "QOffsets({0}, [{1:@[x]}])", offsets.segments,
+ llvm::make_range(offsets.offsets.begin(), offsets.offsets.end()));
+}
+
// GDBRemoteCommunicationClient constructor
GDBRemoteCommunicationClient::GDBRemoteCommunicationClient()
: GDBRemoteClientBase("gdb-remote.client", "gdb-remote.client.rx_packet"),
@@ -573,7 +580,8 @@ StructuredData::ObjectSP GDBRemoteCommunicationClient::GetThreadsInfo() {
if (response.IsUnsupportedResponse()) {
m_supports_jThreadsInfo = false;
} else if (!response.Empty()) {
- object_sp = StructuredData::ParseJSON(response.GetStringRef());
+ object_sp =
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
}
}
}
@@ -685,7 +693,7 @@ GDBRemoteCommunicationClient::SendPacketsAndConcatenateResponses(
if (result != PacketResult::Success)
return result;
- const std::string &this_string = this_response.GetStringRef();
+ const std::string &this_string = std::string(this_response.GetStringRef());
// Check for m or l as first character; l seems to mean this is the last
// chunk
@@ -757,7 +765,7 @@ bool GDBRemoteCommunicationClient::GetLaunchSuccess(std::string &error_str) {
return true;
if (response.GetChar() == 'E') {
// A string the describes what failed when launching...
- error_str = response.GetStringRef().substr(1);
+ error_str = std::string(response.GetStringRef().substr(1));
} else {
error_str.assign("unknown error occurred launching process");
}
@@ -833,7 +841,7 @@ int GDBRemoteCommunicationClient::SendEnvironmentPacket(
bool send_hex_encoding = false;
for (const char *p = name_equal_value; *p != '\0' && !send_hex_encoding;
++p) {
- if (isprint(*p)) {
+ if (llvm::isPrint(*p)) {
switch (*p) {
case '$':
case '#':
@@ -1000,7 +1008,7 @@ bool GDBRemoteCommunicationClient::GetGDBServerVersion() {
while (response.GetNameColonValue(name, value)) {
if (name.equals("name")) {
success = true;
- m_gdb_server_name = value;
+ m_gdb_server_name = std::string(value);
} else if (name.equals("version")) {
llvm::StringRef major, minor;
std::tie(major, minor) = value.split('.');
@@ -1045,7 +1053,7 @@ void GDBRemoteCommunicationClient::MaybeEnableCompression(
}
#endif
-#if LLVM_ENABLE_ZLIB
+#if defined(HAVE_LIBZ)
if (avail_type == CompressionType::None) {
for (auto compression : supported_compressions) {
if (compression == "zlib-deflate") {
@@ -1123,6 +1131,20 @@ bool GDBRemoteCommunicationClient::GetDefaultThreadId(lldb::tid_t &tid) {
return true;
}
+static void ParseOSType(llvm::StringRef value, std::string &os_name,
+ std::string &environment) {
+ if (value.equals("iossimulator") || value.equals("tvossimulator") ||
+ value.equals("watchossimulator")) {
+ environment = "simulator";
+ os_name = value.drop_back(environment.size()).str();
+ } else if (value.equals("maccatalyst")) {
+ os_name = "ios";
+ environment = "macabi";
+ } else {
+ os_name = value.str();
+ }
+}
+
bool GDBRemoteCommunicationClient::GetHostInfo(bool force) {
Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_PROCESS));
@@ -1158,7 +1180,7 @@ bool GDBRemoteCommunicationClient::GetHostInfo(bool force) {
if (!value.getAsInteger(0, sub))
++num_keys_decoded;
} else if (name.equals("arch")) {
- arch_name = value;
+ arch_name = std::string(value);
++num_keys_decoded;
} else if (name.equals("triple")) {
StringExtractor extractor(value);
@@ -1181,14 +1203,10 @@ bool GDBRemoteCommunicationClient::GetHostInfo(bool force) {
extractor.GetHexByteString(m_os_kernel);
++num_keys_decoded;
} else if (name.equals("ostype")) {
- if (value.equals("maccatalyst")) {
- os_name = "ios";
- environment = "macabi";
- } else
- os_name = value;
+ ParseOSType(value, os_name, environment);
++num_keys_decoded;
} else if (name.equals("vendor")) {
- vendor_name = value;
+ vendor_name = std::string(value);
++num_keys_decoded;
} else if (name.equals("endian")) {
byte_order = llvm::StringSwitch<lldb::ByteOrder>(value)
@@ -1956,9 +1974,9 @@ bool GDBRemoteCommunicationClient::DecodeProcessInfoResponse(
} else if (name.equals("cpusubtype")) {
value.getAsInteger(0, sub);
} else if (name.equals("vendor")) {
- vendor = value;
+ vendor = std::string(value);
} else if (name.equals("ostype")) {
- os_type = value;
+ os_type = std::string(value);
}
}
@@ -2045,14 +2063,10 @@ bool GDBRemoteCommunicationClient::GetCurrentProcessInfo(bool allow_lazy) {
extractor.GetHexByteString(triple);
++num_keys_decoded;
} else if (name.equals("ostype")) {
- if (value.equals("maccatalyst")) {
- os_name = "ios";
- environment = "macabi";
- } else
- os_name = value;
+ ParseOSType(value, os_name, environment);
++num_keys_decoded;
} else if (name.equals("vendor")) {
- vendor_name = value;
+ vendor_name = std::string(value);
++num_keys_decoded;
} else if (name.equals("endian")) {
byte_order = llvm::StringSwitch<lldb::ByteOrder>(value)
@@ -2069,7 +2083,7 @@ bool GDBRemoteCommunicationClient::GetCurrentProcessInfo(bool allow_lazy) {
if (!value.getAsInteger(16, pid))
++num_keys_decoded;
} else if (name.equals("elf_abi")) {
- elf_abi = value;
+ elf_abi = std::string(value);
++num_keys_decoded;
}
}
@@ -2140,7 +2154,7 @@ bool GDBRemoteCommunicationClient::GetCurrentProcessInfo(bool allow_lazy) {
uint32_t GDBRemoteCommunicationClient::FindProcesses(
const ProcessInstanceInfoMatch &match_info,
ProcessInstanceInfoList &process_infos) {
- process_infos.Clear();
+ process_infos.clear();
if (m_supports_qfProcessInfo) {
StreamString packet;
@@ -2220,7 +2234,7 @@ uint32_t GDBRemoteCommunicationClient::FindProcesses(
ProcessInstanceInfo process_info;
if (!DecodeProcessInfoResponse(response, process_info))
break;
- process_infos.Append(process_info);
+ process_infos.push_back(process_info);
response = StringExtractorGDBRemote();
} while (SendPacketAndWaitForResponse("qsProcessInfo", response, false) ==
PacketResult::Success);
@@ -2229,7 +2243,7 @@ uint32_t GDBRemoteCommunicationClient::FindProcesses(
return 0;
}
}
- return process_infos.GetSize();
+ return process_infos.size();
}
bool GDBRemoteCommunicationClient::GetUserName(uint32_t uid,
@@ -2536,7 +2550,7 @@ size_t GDBRemoteCommunicationClient::QueryGDBServer(
return 0;
StructuredData::ObjectSP data =
- StructuredData::ParseJSON(response.GetStringRef());
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
if (!data)
return 0;
@@ -2557,7 +2571,7 @@ size_t GDBRemoteCommunicationClient::QueryGDBServer(
std::string socket_name;
if (StructuredData::ObjectSP socket_name_osp =
element->GetValueForKey(llvm::StringRef("socket_name")))
- socket_name = socket_name_osp->GetStringValue();
+ socket_name = std::string(socket_name_osp->GetStringValue());
if (port != 0 || !socket_name.empty())
connection_urls.emplace_back(port, socket_name);
@@ -2783,12 +2797,10 @@ size_t GDBRemoteCommunicationClient::GetCurrentThreadIDs(
thread_ids.push_back(1);
}
} else {
-#if !defined(LLDB_CONFIGURATION_DEBUG)
Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_PROCESS |
GDBR_LOG_PACKETS));
- LLDB_LOGF(log, "error: failed to get packet sequence mutex, not sending "
- "packet 'qfThreadInfo'");
-#endif
+ LLDB_LOG(log, "error: failed to get packet sequence mutex, not sending "
+ "packet 'qfThreadInfo'");
sequence_mutex_unavailable = true;
}
return thread_ids.size();
@@ -3478,7 +3490,7 @@ GDBRemoteCommunicationClient::SendGetTraceConfigPacket(lldb::user_id_t uid,
return error;
} else
options.setTraceParams(
- static_pointer_cast<StructuredData::Dictionary>(
+ std::static_pointer_cast<StructuredData::Dictionary>(
custom_params_sp));
}
} else {
@@ -3530,6 +3542,46 @@ Status GDBRemoteCommunicationClient::SendGetTraceDataPacket(
return error;
}
+llvm::Optional<QOffsets> GDBRemoteCommunicationClient::GetQOffsets() {
+ StringExtractorGDBRemote response;
+ if (SendPacketAndWaitForResponse(
+ "qOffsets", response, /*send_async=*/false) != PacketResult::Success)
+ return llvm::None;
+ if (!response.IsNormalResponse())
+ return llvm::None;
+
+ QOffsets result;
+ llvm::StringRef ref = response.GetStringRef();
+ const auto &GetOffset = [&] {
+ addr_t offset;
+ if (ref.consumeInteger(16, offset))
+ return false;
+ result.offsets.push_back(offset);
+ return true;
+ };
+
+ if (ref.consume_front("Text=")) {
+ result.segments = false;
+ if (!GetOffset())
+ return llvm::None;
+ if (!ref.consume_front(";Data=") || !GetOffset())
+ return llvm::None;
+ if (ref.empty())
+ return result;
+ if (ref.consume_front(";Bss=") && GetOffset() && ref.empty())
+ return result;
+ } else if (ref.consume_front("TextSeg=")) {
+ result.segments = true;
+ if (!GetOffset())
+ return llvm::None;
+ if (ref.empty())
+ return result;
+ if (ref.consume_front(";DataSeg=") && GetOffset() && ref.empty())
+ return result;
+ }
+ return llvm::None;
+}
+
bool GDBRemoteCommunicationClient::GetModuleInfo(
const FileSpec &module_file_spec, const lldb_private::ArchSpec &arch_spec,
ModuleSpec &module_spec) {
@@ -3571,7 +3623,7 @@ bool GDBRemoteCommunicationClient::GetModuleInfo(
StringExtractor extractor(value);
std::string uuid;
extractor.GetHexByteString(uuid);
- module_spec.GetUUID().SetFromStringRef(uuid, uuid.size() / 2);
+ module_spec.GetUUID().SetFromStringRef(uuid);
} else if (name == "triple") {
StringExtractor extractor(value);
std::string triple;
@@ -3607,8 +3659,7 @@ ParseModuleSpec(StructuredData::Dictionary *dict) {
if (!dict->GetValueForKeyAsString("uuid", string))
return llvm::None;
- if (result.GetUUID().SetFromStringRef(string, string.size() / 2) !=
- string.size())
+ if (!result.GetUUID().SetFromStringRef(string))
return llvm::None;
if (!dict->GetValueForKeyAsInteger("file_offset", integer))
@@ -3667,7 +3718,7 @@ GDBRemoteCommunicationClient::GetModulesInfo(
}
StructuredData::ObjectSP response_object_sp =
- StructuredData::ParseJSON(response.GetStringRef());
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
if (!response_object_sp)
return llvm::None;
@@ -3722,7 +3773,7 @@ bool GDBRemoteCommunicationClient::ReadExtFeature(
return false;
}
- const std::string &str = chunk.GetStringRef();
+ const std::string &str = std::string(chunk.GetStringRef());
if (str.length() == 0) {
// should have some data in chunk
err.SetErrorString("Empty response from $qXfer packet");
@@ -3936,7 +3987,7 @@ GDBRemoteCommunicationClient::GetSupportedStructuredDataPlugins() {
if (SendPacketAndWaitForResponse("qStructuredDataPlugins", response,
send_async) == PacketResult::Success) {
m_supported_async_json_packets_sp =
- StructuredData::ParseJSON(response.GetStringRef());
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
if (m_supported_async_json_packets_sp &&
!m_supported_async_json_packets_sp->GetAsArray()) {
// We were returned something other than a JSON array. This is
@@ -4002,7 +4053,7 @@ Status GDBRemoteCommunicationClient::ConfigureRemoteStructuredData(
// Build command: Configure{type_name}: serialized config data.
StreamGDBRemote stream;
stream.PutCString("QConfigure");
- stream.PutCString(type_name.AsCString());
+ stream.PutCString(type_name.GetStringRef());
stream.PutChar(':');
if (config_sp) {
// Gather the plain-text version of the configuration data.
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
index 11fd40bce44f..8df08cbde735 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_GDBRemoteCommunicationClient_h_
-#define liblldb_GDBRemoteCommunicationClient_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONCLIENT_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONCLIENT_H
#include "GDBRemoteClientBase.h"
@@ -20,6 +20,7 @@
#include "lldb/Host/File.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/GDBRemote.h"
+#include "lldb/Utility/ProcessInfo.h"
#include "lldb/Utility/StructuredData.h"
#if defined(_WIN32)
#include "lldb/Host/windows/PosixApi.h"
@@ -31,6 +32,22 @@
namespace lldb_private {
namespace process_gdb_remote {
+/// The offsets used by the target when relocating the executable. Decoded from
+/// qOffsets packet response.
+struct QOffsets {
+ /// If true, the offsets field describes segments. Otherwise, it describes
+ /// sections.
+ bool segments;
+
+ /// The individual offsets. Section offsets have two or three members.
+ /// Segment offsets have either one of two.
+ std::vector<uint64_t> offsets;
+};
+inline bool operator==(const QOffsets &a, const QOffsets &b) {
+ return a.segments == b.segments && a.offsets == b.offsets;
+}
+llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const QOffsets &offsets);
+
class GDBRemoteCommunicationClient : public GDBRemoteClientBase {
public:
GDBRemoteCommunicationClient();
@@ -425,6 +442,11 @@ public:
bool GetSharedCacheInfoSupported();
+ /// Use qOffsets to query the offset used when relocating the target
+ /// executable. If successful, the returned structure will contain at least
+ /// one value in the offsets field.
+ llvm::Optional<QOffsets> GetQOffsets();
+
bool GetModuleInfo(const FileSpec &module_file_spec,
const ArchSpec &arch_spec, ModuleSpec &module_spec);
@@ -599,10 +621,12 @@ protected:
LazyBool GetThreadPacketSupported(lldb::tid_t tid, llvm::StringRef packetStr);
private:
- DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunicationClient);
+ GDBRemoteCommunicationClient(const GDBRemoteCommunicationClient &) = delete;
+ const GDBRemoteCommunicationClient &
+ operator=(const GDBRemoteCommunicationClient &) = delete;
};
} // namespace process_gdb_remote
} // namespace lldb_private
-#endif // liblldb_GDBRemoteCommunicationClient_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONCLIENT_H
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp
index 9e5646985f87..3984a45c3da1 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp
@@ -1,4 +1,4 @@
-//===-- GDBRemoteCommunicationHistory.cpp -----------------------*- C++ -*-===//
+//===-- GDBRemoteCommunicationHistory.cpp ---------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h
index ee265ef86dff..e783e59c3455 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_GDBRemoteCommunicationHistory_h_
-#define liblldb_GDBRemoteCommunicationHistory_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONHISTORY_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONHISTORY_H
#include <string>
#include <vector>
@@ -83,4 +83,4 @@ private:
} // namespace process_gdb_remote
} // namespace lldb_private
-#endif // liblldb_GDBRemoteCommunicationHistory_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONHISTORY_H
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
index 15c73e78bd44..920327e7d0ab 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
@@ -1,4 +1,4 @@
-//===-- GDBRemoteCommunicationReplayServer.cpp ------------------*- C++ -*-===//
+//===-- GDBRemoteCommunicationReplayServer.cpp ----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -131,22 +131,26 @@ GDBRemoteCommunicationReplayServer::GetPacketAndSendResponse(
GDBRemotePacket entry = m_packet_history.back();
m_packet_history.pop_back();
+ // Decode run-length encoding.
+ const std::string expanded_data =
+ GDBRemoteCommunication::ExpandRLE(entry.packet.data);
+
// We've handled the handshake implicitly before. Skip the packet and move
// on.
if (entry.packet.data == "+")
continue;
if (entry.type == GDBRemotePacket::ePacketTypeSend) {
- if (unexpected(entry.packet.data, packet.GetStringRef())) {
+ if (unexpected(expanded_data, packet.GetStringRef())) {
LLDB_LOG(log,
"GDBRemoteCommunicationReplayServer expected packet: '{0}'",
- entry.packet.data);
+ expanded_data);
LLDB_LOG(log, "GDBRemoteCommunicationReplayServer actual packet: '{0}'",
packet.GetStringRef());
#ifndef NDEBUG
// This behaves like a regular assert, but prints the expected and
// received packet before aborting.
- printf("Reproducer expected packet: '%s'\n", entry.packet.data.c_str());
+ printf("Reproducer expected packet: '%s'\n", expanded_data.c_str());
printf("Reproducer received packet: '%s'\n",
packet.GetStringRef().data());
llvm::report_fatal_error("Encountered unexpected packet during replay");
@@ -155,7 +159,7 @@ GDBRemoteCommunicationReplayServer::GetPacketAndSendResponse(
}
// Ignore QEnvironment packets as they're handled earlier.
- if (entry.packet.data.find("QEnvironment") == 1) {
+ if (expanded_data.find("QEnvironment") == 1) {
assert(m_packet_history.back().type ==
GDBRemotePacket::ePacketTypeRecv);
m_packet_history.pop_back();
@@ -283,3 +287,28 @@ thread_result_t GDBRemoteCommunicationReplayServer::AsyncThread(void *arg) {
return {};
}
+
+Status GDBRemoteCommunicationReplayServer::Connect(
+ process_gdb_remote::GDBRemoteCommunicationClient &client) {
+ repro::Loader *loader = repro::Reproducer::Instance().GetLoader();
+ if (!loader)
+ return Status("No loader provided.");
+
+ static std::unique_ptr<repro::MultiLoader<repro::GDBRemoteProvider>>
+ multi_loader = repro::MultiLoader<repro::GDBRemoteProvider>::Create(
+ repro::Reproducer::Instance().GetLoader());
+ if (!multi_loader)
+ return Status("No gdb remote provider found.");
+
+ llvm::Optional<std::string> history_file = multi_loader->GetNextFile();
+ if (!history_file)
+ return Status("No gdb remote packet log found.");
+
+ if (auto error = LoadReplayHistory(FileSpec(*history_file)))
+ return Status("Unable to load replay history");
+
+ if (auto error = GDBRemoteCommunication::ConnectLocally(client, *this))
+ return Status("Unable to connect to replay server");
+
+ return {};
+}
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h
index 0b5e910f7c6a..c13e5ee0bf92 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h
@@ -6,11 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_GDBRemoteCommunicationReplayServer_h_
-#define liblldb_GDBRemoteCommunicationReplayServer_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONREPLAYSERVER_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONREPLAYSERVER_H
// Other libraries and framework includes
#include "GDBRemoteCommunication.h"
+#include "GDBRemoteCommunicationClient.h"
#include "GDBRemoteCommunicationHistory.h"
// Project includes
@@ -51,6 +52,8 @@ public:
bool StartAsyncThread();
void StopAsyncThread();
+ Status Connect(process_gdb_remote::GDBRemoteCommunicationClient &client);
+
protected:
enum {
eBroadcastBitAsyncContinue = (1 << 0),
@@ -73,10 +76,13 @@ protected:
bool m_skip_acks;
private:
- DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunicationReplayServer);
+ GDBRemoteCommunicationReplayServer(
+ const GDBRemoteCommunicationReplayServer &) = delete;
+ const GDBRemoteCommunicationReplayServer &
+ operator=(const GDBRemoteCommunicationReplayServer &) = delete;
};
} // namespace process_gdb_remote
} // namespace lldb_private
-#endif // liblldb_GDBRemoteCommunicationReplayServer_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONREPLAYSERVER_H
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
index ac6ecffcf854..b78f0916b9b9 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
@@ -1,4 +1,4 @@
-//===-- GDBRemoteCommunicationServer.cpp ------------------------*- C++ -*-===//
+//===-- GDBRemoteCommunicationServer.cpp ----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
index 86f0abf45e06..a7c2ea47e3ba 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_GDBRemoteCommunicationServer_h_
-#define liblldb_GDBRemoteCommunicationServer_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVER_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVER_H
#include <functional>
#include <map>
@@ -74,7 +74,9 @@ protected:
PacketResult SendOKResponse();
private:
- DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunicationServer);
+ GDBRemoteCommunicationServer(const GDBRemoteCommunicationServer &) = delete;
+ const GDBRemoteCommunicationServer &
+ operator=(const GDBRemoteCommunicationServer &) = delete;
};
class PacketUnimplementedError
@@ -92,4 +94,4 @@ public:
} // namespace process_gdb_remote
} // namespace lldb_private
-#endif // liblldb_GDBRemoteCommunicationServer_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVER_H
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index 4b5fc0774a6d..08d489851799 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -1,4 +1,4 @@
-//===-- GDBRemoteCommunicationServerCommon.cpp ------------------*- C++ -*-===//
+//===-- GDBRemoteCommunicationServerCommon.cpp ----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -334,7 +334,7 @@ GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_qfProcessInfo(
StringExtractorGDBRemote &packet) {
m_proc_infos_index = 0;
- m_proc_infos.Clear();
+ m_proc_infos.clear();
ProcessInstanceInfoMatch match_info;
packet.SetFilePos(::strlen("qfProcessInfo"));
@@ -416,10 +416,9 @@ GDBRemoteCommunicationServerCommon::Handle_qfProcessInfo(
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_qsProcessInfo(
StringExtractorGDBRemote &packet) {
- if (m_proc_infos_index < m_proc_infos.GetSize()) {
+ if (m_proc_infos_index < m_proc_infos.size()) {
StreamString response;
- CreateProcessInfoResponse(
- m_proc_infos.GetProcessInfoAtIndex(m_proc_infos_index), response);
+ CreateProcessInfoResponse(m_proc_infos[m_proc_infos_index], response);
++m_proc_infos_index;
return SendPacketNoLock(response.GetString());
}
@@ -843,6 +842,7 @@ GDBRemoteCommunicationServerCommon::Handle_qSupported(
response.PutCString(";QThreadSuffixSupported+");
response.PutCString(";QListThreadsInStopReply+");
response.PutCString(";qEcho+");
+ response.PutCString(";qXfer:features:read+");
#if defined(__linux__) || defined(__NetBSD__)
response.PutCString(";QPassSignals+");
response.PutCString(";qXfer:auxv:read+");
@@ -1228,7 +1228,7 @@ void GDBRemoteCommunicationServerCommon::
if (cpu_subtype != 0)
response.Printf("cpusubtype:%" PRIx32 ";", cpu_subtype);
- const std::string vendor = proc_triple.getVendorName();
+ const std::string vendor = proc_triple.getVendorName().str();
if (!vendor.empty())
response.Printf("vendor:%s;", vendor.c_str());
#else
@@ -1237,7 +1237,7 @@ void GDBRemoteCommunicationServerCommon::
response.PutStringAsRawHex8(proc_triple.getTriple());
response.PutChar(';');
#endif
- std::string ostype = proc_triple.getOSName();
+ std::string ostype = std::string(proc_triple.getOSName());
// Adjust so ostype reports ios for Apple/ARM and Apple/ARM64.
if (proc_triple.getVendor() == llvm::Triple::Apple) {
switch (proc_triple.getArch()) {
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
index 525546312470..0f933c09cbd4 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_GDBRemoteCommunicationServerCommon_h_
-#define liblldb_GDBRemoteCommunicationServerCommon_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVERCOMMON_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVERCOMMON_H
#include <string>
@@ -152,4 +152,4 @@ private:
} // namespace process_gdb_remote
} // namespace lldb_private
-#endif // liblldb_GDBRemoteCommunicationServerCommon_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVERCOMMON_H
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index f33f0ee66304..ae2f4bd041c9 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -1,4 +1,4 @@
-//===-- GDBRemoteCommunicationServerLLGS.cpp --------------------*- C++ -*-===//
+//===-- GDBRemoteCommunicationServerLLGS.cpp ------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -377,6 +377,99 @@ static void AppendHexValue(StreamString &response, const uint8_t *buf,
}
}
+static llvm::StringRef GetEncodingNameOrEmpty(const RegisterInfo &reg_info) {
+ switch (reg_info.encoding) {
+ case eEncodingUint:
+ return "uint";
+ case eEncodingSint:
+ return "sint";
+ case eEncodingIEEE754:
+ return "ieee754";
+ case eEncodingVector:
+ return "vector";
+ default:
+ return "";
+ }
+}
+
+static llvm::StringRef GetFormatNameOrEmpty(const RegisterInfo &reg_info) {
+ switch (reg_info.format) {
+ case eFormatBinary:
+ return "binary";
+ case eFormatDecimal:
+ return "decimal";
+ case eFormatHex:
+ return "hex";
+ case eFormatFloat:
+ return "float";
+ case eFormatVectorOfSInt8:
+ return "vector-sint8";
+ case eFormatVectorOfUInt8:
+ return "vector-uint8";
+ case eFormatVectorOfSInt16:
+ return "vector-sint16";
+ case eFormatVectorOfUInt16:
+ return "vector-uint16";
+ case eFormatVectorOfSInt32:
+ return "vector-sint32";
+ case eFormatVectorOfUInt32:
+ return "vector-uint32";
+ case eFormatVectorOfFloat32:
+ return "vector-float32";
+ case eFormatVectorOfUInt64:
+ return "vector-uint64";
+ case eFormatVectorOfUInt128:
+ return "vector-uint128";
+ default:
+ return "";
+ };
+}
+
+static llvm::StringRef GetKindGenericOrEmpty(const RegisterInfo &reg_info) {
+ switch (reg_info.kinds[RegisterKind::eRegisterKindGeneric]) {
+ case LLDB_REGNUM_GENERIC_PC:
+ return "pc";
+ case LLDB_REGNUM_GENERIC_SP:
+ return "sp";
+ case LLDB_REGNUM_GENERIC_FP:
+ return "fp";
+ case LLDB_REGNUM_GENERIC_RA:
+ return "ra";
+ case LLDB_REGNUM_GENERIC_FLAGS:
+ return "flags";
+ case LLDB_REGNUM_GENERIC_ARG1:
+ return "arg1";
+ case LLDB_REGNUM_GENERIC_ARG2:
+ return "arg2";
+ case LLDB_REGNUM_GENERIC_ARG3:
+ return "arg3";
+ case LLDB_REGNUM_GENERIC_ARG4:
+ return "arg4";
+ case LLDB_REGNUM_GENERIC_ARG5:
+ return "arg5";
+ case LLDB_REGNUM_GENERIC_ARG6:
+ return "arg6";
+ case LLDB_REGNUM_GENERIC_ARG7:
+ return "arg7";
+ case LLDB_REGNUM_GENERIC_ARG8:
+ return "arg8";
+ default:
+ return "";
+ }
+}
+
+static void CollectRegNums(const uint32_t *reg_num, StreamString &response,
+ bool usehex) {
+ for (int i = 0; *reg_num != LLDB_INVALID_REGNUM; ++reg_num, ++i) {
+ if (i > 0)
+ response.PutChar(',');
+ if (usehex)
+ response.Printf("%" PRIx32, *reg_num);
+ else
+ response.Printf("%" PRIu32, *reg_num);
+ }
+}
+
static void WriteRegisterValueInHexFixedWidth(
StreamString &response, NativeRegisterContext &reg_ctx,
const RegisterInfo &reg_info, const RegisterValue *reg_value_p,
@@ -922,9 +1015,9 @@ void GDBRemoteCommunicationServerLLGS::DataAvailableCallback() {
}
Status GDBRemoteCommunicationServerLLGS::InitializeConnection(
- std::unique_ptr<Connection> &&connection) {
+ std::unique_ptr<Connection> connection) {
IOObjectSP read_object_sp = connection->GetReadObject();
- GDBRemoteCommunicationServer::SetConnection(connection.release());
+ GDBRemoteCommunicationServer::SetConnection(std::move(connection));
Status error;
m_network_handle_up = m_mainloop.RegisterReadObject(
@@ -960,7 +1053,7 @@ Status GDBRemoteCommunicationServerLLGS::SetSTDIOFileDescriptor(int fd) {
}
m_stdio_communication.SetCloseOnEOF(false);
- m_stdio_communication.SetConnection(conn_up.release());
+ m_stdio_communication.SetConnection(std::move(conn_up));
if (!m_stdio_communication.IsConnected()) {
error.SetErrorString(
"failed to set connection for inferior I/O communication");
@@ -1072,7 +1165,7 @@ GDBRemoteCommunicationServerLLGS::Handle_jTraceStart(
return SendIllFormedResponse(packet, "jTraceStart: Ill formed packet ");
options.setTraceParams(
- static_pointer_cast<StructuredData::Dictionary>(custom_params_sp));
+ std::static_pointer_cast<StructuredData::Dictionary>(custom_params_sp));
if (buffersize == std::numeric_limits<uint64_t>::max() ||
type != lldb::TraceType::eTraceTypeProcessorTrace) {
@@ -1699,74 +1792,18 @@ GDBRemoteCommunicationServerLLGS::Handle_qRegisterInfo(
response.Printf("bitsize:%" PRIu32 ";offset:%" PRIu32 ";",
reg_info->byte_size * 8, reg_info->byte_offset);
- switch (reg_info->encoding) {
- case eEncodingUint:
- response.PutCString("encoding:uint;");
- break;
- case eEncodingSint:
- response.PutCString("encoding:sint;");
- break;
- case eEncodingIEEE754:
- response.PutCString("encoding:ieee754;");
- break;
- case eEncodingVector:
- response.PutCString("encoding:vector;");
- break;
- default:
- break;
- }
+ llvm::StringRef encoding = GetEncodingNameOrEmpty(*reg_info);
+ if (!encoding.empty())
+ response << "encoding:" << encoding << ';';
- switch (reg_info->format) {
- case eFormatBinary:
- response.PutCString("format:binary;");
- break;
- case eFormatDecimal:
- response.PutCString("format:decimal;");
- break;
- case eFormatHex:
- response.PutCString("format:hex;");
- break;
- case eFormatFloat:
- response.PutCString("format:float;");
- break;
- case eFormatVectorOfSInt8:
- response.PutCString("format:vector-sint8;");
- break;
- case eFormatVectorOfUInt8:
- response.PutCString("format:vector-uint8;");
- break;
- case eFormatVectorOfSInt16:
- response.PutCString("format:vector-sint16;");
- break;
- case eFormatVectorOfUInt16:
- response.PutCString("format:vector-uint16;");
- break;
- case eFormatVectorOfSInt32:
- response.PutCString("format:vector-sint32;");
- break;
- case eFormatVectorOfUInt32:
- response.PutCString("format:vector-uint32;");
- break;
- case eFormatVectorOfFloat32:
- response.PutCString("format:vector-float32;");
- break;
- case eFormatVectorOfUInt64:
- response.PutCString("format:vector-uint64;");
- break;
- case eFormatVectorOfUInt128:
- response.PutCString("format:vector-uint128;");
- break;
- default:
- break;
- };
+ llvm::StringRef format = GetFormatNameOrEmpty(*reg_info);
+ if (!format.empty())
+ response << "format:" << format << ';';
const char *const register_set_name =
reg_context.GetRegisterSetNameForRegisterAtIndex(reg_index);
- if (register_set_name) {
- response.PutCString("set:");
- response.PutCString(register_set_name);
- response.PutChar(';');
- }
+ if (register_set_name)
+ response << "set:" << register_set_name << ';';
if (reg_info->kinds[RegisterKind::eRegisterKindEHFrame] !=
LLDB_INVALID_REGNUM)
@@ -1777,71 +1814,19 @@ GDBRemoteCommunicationServerLLGS::Handle_qRegisterInfo(
response.Printf("dwarf:%" PRIu32 ";",
reg_info->kinds[RegisterKind::eRegisterKindDWARF]);
- switch (reg_info->kinds[RegisterKind::eRegisterKindGeneric]) {
- case LLDB_REGNUM_GENERIC_PC:
- response.PutCString("generic:pc;");
- break;
- case LLDB_REGNUM_GENERIC_SP:
- response.PutCString("generic:sp;");
- break;
- case LLDB_REGNUM_GENERIC_FP:
- response.PutCString("generic:fp;");
- break;
- case LLDB_REGNUM_GENERIC_RA:
- response.PutCString("generic:ra;");
- break;
- case LLDB_REGNUM_GENERIC_FLAGS:
- response.PutCString("generic:flags;");
- break;
- case LLDB_REGNUM_GENERIC_ARG1:
- response.PutCString("generic:arg1;");
- break;
- case LLDB_REGNUM_GENERIC_ARG2:
- response.PutCString("generic:arg2;");
- break;
- case LLDB_REGNUM_GENERIC_ARG3:
- response.PutCString("generic:arg3;");
- break;
- case LLDB_REGNUM_GENERIC_ARG4:
- response.PutCString("generic:arg4;");
- break;
- case LLDB_REGNUM_GENERIC_ARG5:
- response.PutCString("generic:arg5;");
- break;
- case LLDB_REGNUM_GENERIC_ARG6:
- response.PutCString("generic:arg6;");
- break;
- case LLDB_REGNUM_GENERIC_ARG7:
- response.PutCString("generic:arg7;");
- break;
- case LLDB_REGNUM_GENERIC_ARG8:
- response.PutCString("generic:arg8;");
- break;
- default:
- break;
- }
+ llvm::StringRef kind_generic = GetKindGenericOrEmpty(*reg_info);
+ if (!kind_generic.empty())
+ response << "generic:" << kind_generic << ';';
if (reg_info->value_regs && reg_info->value_regs[0] != LLDB_INVALID_REGNUM) {
response.PutCString("container-regs:");
- int i = 0;
- for (const uint32_t *reg_num = reg_info->value_regs;
- *reg_num != LLDB_INVALID_REGNUM; ++reg_num, ++i) {
- if (i > 0)
- response.PutChar(',');
- response.Printf("%" PRIx32, *reg_num);
- }
+ CollectRegNums(reg_info->value_regs, response, true);
response.PutChar(';');
}
if (reg_info->invalidate_regs && reg_info->invalidate_regs[0]) {
response.PutCString("invalidate-regs:");
- int i = 0;
- for (const uint32_t *reg_num = reg_info->invalidate_regs;
- *reg_num != LLDB_INVALID_REGNUM; ++reg_num, ++i) {
- if (i > 0)
- response.PutChar(',');
- response.Printf("%" PRIx32, *reg_num);
- }
+ CollectRegNums(reg_info->invalidate_regs, response, true);
response.PutChar(';');
}
@@ -2055,7 +2040,7 @@ GDBRemoteCommunicationServerLLGS::Handle_P(StringExtractorGDBRemote &packet) {
packet, "P packet missing '=' char after register number");
// Parse out the value.
- uint8_t reg_bytes[32]; // big enough to support up to 256 bit ymmN register
+ uint8_t reg_bytes[RegisterValue::kMaxRegisterByteSize];
size_t reg_size = packet.GetHexBytesAvail(reg_bytes);
// Get the thread to use.
@@ -2510,7 +2495,7 @@ GDBRemoteCommunicationServerLLGS::Handle_qMemoryRegionInfo(
ConstString name = region_info.GetName();
if (name) {
response.PutCString("name:");
- response.PutStringAsRawHex8(name.AsCString());
+ response.PutStringAsRawHex8(name.GetStringRef());
response.PutChar(';');
}
}
@@ -2751,16 +2736,118 @@ GDBRemoteCommunicationServerLLGS::Handle_s(StringExtractorGDBRemote &packet) {
}
llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
+GDBRemoteCommunicationServerLLGS::BuildTargetXml() {
+ // Ensure we have a thread.
+ NativeThreadProtocol *thread = m_debugged_process_up->GetThreadAtIndex(0);
+ if (!thread)
+ return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "No thread available");
+
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD));
+ // Get the register context for the first thread.
+ NativeRegisterContext &reg_context = thread->GetRegisterContext();
+
+ StreamString response;
+
+ response.Printf("<?xml version=\"1.0\"?>");
+ response.Printf("<target version=\"1.0\">");
+
+ response.Printf("<architecture>%s</architecture>",
+ m_debugged_process_up->GetArchitecture()
+ .GetTriple()
+ .getArchName()
+ .str()
+ .c_str());
+
+ response.Printf("<feature>");
+
+ const int registers_count = reg_context.GetUserRegisterCount();
+ for (int reg_index = 0; reg_index < registers_count; reg_index++) {
+ const RegisterInfo *reg_info =
+ reg_context.GetRegisterInfoAtIndex(reg_index);
+
+ if (!reg_info) {
+ LLDB_LOGF(log,
+ "%s failed to get register info for register index %" PRIu32,
+ "target.xml", reg_index);
+ continue;
+ }
+
+ response.Printf("<reg name=\"%s\" bitsize=\"%" PRIu32 "\" offset=\"%" PRIu32
+ "\" regnum=\"%d\" ",
+ reg_info->name, reg_info->byte_size * 8,
+ reg_info->byte_offset, reg_index);
+
+ if (reg_info->alt_name && reg_info->alt_name[0])
+ response.Printf("altname=\"%s\" ", reg_info->alt_name);
+
+ llvm::StringRef encoding = GetEncodingNameOrEmpty(*reg_info);
+ if (!encoding.empty())
+ response << "encoding=\"" << encoding << "\" ";
+
+ llvm::StringRef format = GetFormatNameOrEmpty(*reg_info);
+ if (!format.empty())
+ response << "format=\"" << format << "\" ";
+
+ const char *const register_set_name =
+ reg_context.GetRegisterSetNameForRegisterAtIndex(reg_index);
+ if (register_set_name)
+ response << "group=\"" << register_set_name << "\" ";
+
+ if (reg_info->kinds[RegisterKind::eRegisterKindEHFrame] !=
+ LLDB_INVALID_REGNUM)
+ response.Printf("ehframe_regnum=\"%" PRIu32 "\" ",
+ reg_info->kinds[RegisterKind::eRegisterKindEHFrame]);
+
+ if (reg_info->kinds[RegisterKind::eRegisterKindDWARF] !=
+ LLDB_INVALID_REGNUM)
+ response.Printf("dwarf_regnum=\"%" PRIu32 "\" ",
+ reg_info->kinds[RegisterKind::eRegisterKindDWARF]);
+
+ llvm::StringRef kind_generic = GetKindGenericOrEmpty(*reg_info);
+ if (!kind_generic.empty())
+ response << "generic=\"" << kind_generic << "\" ";
+
+ if (reg_info->value_regs &&
+ reg_info->value_regs[0] != LLDB_INVALID_REGNUM) {
+ response.PutCString("value_regnums=\"");
+ CollectRegNums(reg_info->value_regs, response, false);
+ response.Printf("\" ");
+ }
+
+ if (reg_info->invalidate_regs && reg_info->invalidate_regs[0]) {
+ response.PutCString("invalidate_regnums=\"");
+ CollectRegNums(reg_info->invalidate_regs, response, false);
+ response.Printf("\" ");
+ }
+
+ if (reg_info->dynamic_size_dwarf_expr_bytes) {
+ const size_t dwarf_opcode_len = reg_info->dynamic_size_dwarf_len;
+ response.PutCString("dynamic_size_dwarf_expr_bytes=\"");
+ for (uint32_t i = 0; i < dwarf_opcode_len; ++i)
+ response.PutHex8(reg_info->dynamic_size_dwarf_expr_bytes[i]);
+ response.Printf("\" ");
+ }
+
+ response.Printf("/>");
+ }
+
+ response.Printf("</feature>");
+ response.Printf("</target>");
+ return MemoryBuffer::getMemBufferCopy(response.GetString(), "target.xml");
+}
+
+llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
GDBRemoteCommunicationServerLLGS::ReadXferObject(llvm::StringRef object,
llvm::StringRef annex) {
- if (object == "auxv") {
- // Make sure we have a valid process.
- if (!m_debugged_process_up ||
- (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
- return llvm::createStringError(llvm::inconvertibleErrorCode(),
- "No process available");
- }
+ // Make sure we have a valid process.
+ if (!m_debugged_process_up ||
+ (m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
+ return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "No process available");
+ }
+ if (object == "auxv") {
// Grab the auxv data.
auto buffer_or_error = m_debugged_process_up->GetAuxvData();
if (!buffer_or_error)
@@ -2786,6 +2873,9 @@ GDBRemoteCommunicationServerLLGS::ReadXferObject(llvm::StringRef object,
return MemoryBuffer::getMemBufferCopy(response.GetString(), __FUNCTION__);
}
+ if (object == "features" && annex == "target.xml")
+ return BuildTargetXml();
+
return llvm::make_error<PacketUnimplementedError>(
"Xfer object not supported");
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
index 088ba92ad11a..3ce285910c25 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_GDBRemoteCommunicationServerLLGS_h_
-#define liblldb_GDBRemoteCommunicationServerLLGS_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVERLLGS_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVERLLGS_H
#include <mutex>
#include <unordered_map>
@@ -67,7 +67,7 @@ public:
void DidExec(NativeProcessProtocol *process) override;
- Status InitializeConnection(std::unique_ptr<Connection> &&connection);
+ Status InitializeConnection(std::unique_ptr<Connection> connection);
protected:
MainLoop &m_mainloop;
@@ -199,6 +199,8 @@ protected:
static std::string XMLEncodeAttributeValue(llvm::StringRef value);
private:
+ llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>> BuildTargetXml();
+
void HandleInferiorState_Exited(NativeProcessProtocol *process);
void HandleInferiorState_Stopped(NativeProcessProtocol *process);
@@ -222,10 +224,13 @@ private:
void StopSTDIOForwarding();
// For GDBRemoteCommunicationServerLLGS only
- DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunicationServerLLGS);
+ GDBRemoteCommunicationServerLLGS(const GDBRemoteCommunicationServerLLGS &) =
+ delete;
+ const GDBRemoteCommunicationServerLLGS &
+ operator=(const GDBRemoteCommunicationServerLLGS &) = delete;
};
} // namespace process_gdb_remote
} // namespace lldb_private
-#endif // liblldb_GDBRemoteCommunicationServerLLGS_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVERLLGS_H
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
index 25cebbba8f7b..d14b79a03d17 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
@@ -1,4 +1,4 @@
-//===-- GDBRemoteCommunicationServerPlatform.cpp ----------------*- C++ -*-===//
+//===-- GDBRemoteCommunicationServerPlatform.cpp --------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -173,7 +173,7 @@ GDBRemoteCommunicationServerPlatform::Handle_qLaunchGDBServer(
uint16_t port = UINT16_MAX;
while (packet.GetNameColonValue(name, value)) {
if (name.equals("host"))
- hostname = value;
+ hostname = std::string(value);
else if (name.equals("port"))
value.getAsInteger(0, port);
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h
index eacc99a012db..a8cacea78835 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_GDBRemoteCommunicationServerPlatform_h_
-#define liblldb_GDBRemoteCommunicationServerPlatform_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVERPLATFORM_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVERPLATFORM_H
#include <map>
#include <mutex>
@@ -100,10 +100,13 @@ private:
static FileSpec GetDomainSocketPath(const char *prefix);
- DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunicationServerPlatform);
+ GDBRemoteCommunicationServerPlatform(
+ const GDBRemoteCommunicationServerPlatform &) = delete;
+ const GDBRemoteCommunicationServerPlatform &
+ operator=(const GDBRemoteCommunicationServerPlatform &) = delete;
};
} // namespace process_gdb_remote
} // namespace lldb_private
-#endif // liblldb_GDBRemoteCommunicationServerPlatform_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTECOMMUNICATIONSERVERPLATFORM_H
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index ec1a54afd727..1f31b45d0fa9 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -1,4 +1,4 @@
-//===-- GDBRemoteRegisterContext.cpp ----------------------------*- C++ -*-===//
+//===-- GDBRemoteRegisterContext.cpp --------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
index b42c87b5991b..015862587103 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_GDBRemoteRegisterContext_h_
-#define lldb_GDBRemoteRegisterContext_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTEREGISTERCONTEXT_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTEREGISTERCONTEXT_H
#include <vector>
@@ -88,9 +88,7 @@ protected:
void SetAllRegisterValid(bool b);
bool GetRegisterIsValid(uint32_t reg) const {
-#if defined(LLDB_CONFIGURATION_DEBUG)
assert(reg < m_reg_valid.size());
-#endif
if (reg < m_reg_valid.size())
return m_reg_valid[reg];
return false;
@@ -103,9 +101,7 @@ protected:
}
void SetRegisterIsValid(uint32_t reg, bool valid) {
-#if defined(LLDB_CONFIGURATION_DEBUG)
assert(reg < m_reg_valid.size());
-#endif
if (reg < m_reg_valid.size())
m_reg_valid[reg] = valid;
}
@@ -124,10 +120,12 @@ private:
bool SetPrimordialRegister(const RegisterInfo *reg_info,
GDBRemoteCommunicationClient &gdb_comm);
- DISALLOW_COPY_AND_ASSIGN(GDBRemoteRegisterContext);
+ GDBRemoteRegisterContext(const GDBRemoteRegisterContext &) = delete;
+ const GDBRemoteRegisterContext &
+ operator=(const GDBRemoteRegisterContext &) = delete;
};
} // namespace process_gdb_remote
} // namespace lldb_private
-#endif // lldb_GDBRemoteRegisterContext_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_GDBREMOTEREGISTERCONTEXT_H
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index a49db5d9a934..1fed8e064267 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1,4 +1,4 @@
-//===-- ProcessGDBRemote.cpp ------------------------------------*- C++ -*-===//
+//===-- ProcessGDBRemote.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -17,6 +17,9 @@
#include <unistd.h>
#endif
#include <sys/stat.h>
+#if defined(__APPLE__)
+#include <sys/sysctl.h>
+#endif
#include <sys/types.h>
#include <time.h>
@@ -90,6 +93,8 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::process_gdb_remote;
+LLDB_PLUGIN_DEFINE(ProcessGDBRemote)
+
namespace lldb {
// Provide a function that can easily dump the packet history if we know a
// ProcessGDBRemote * value (which we can get from logs or from debugging). We
@@ -184,21 +189,6 @@ static const ProcessKDPPropertiesSP &GetGlobalPluginProperties() {
#define HIGH_PORT (49151u)
#endif
-#if defined(__APPLE__) && \
- (defined(__arm__) || defined(__arm64__) || defined(__aarch64__))
-static bool rand_initialized = false;
-
-static inline uint16_t get_random_port() {
- if (!rand_initialized) {
- time_t seed = time(NULL);
-
- rand_initialized = true;
- srand(seed);
- }
- return (rand() % (HIGH_PORT - LOW_PORT)) + LOW_PORT;
-}
-#endif
-
ConstString ProcessGDBRemote::GetPluginNameStatic() {
static ConstString g_name("gdb-remote");
return g_name;
@@ -359,7 +349,8 @@ bool ProcessGDBRemote::ParsePythonTargetDefinition(
StructuredData::ObjectSP triple_value =
host_info_dict->GetValueForKey("triple");
if (auto triple_string_value = triple_value->GetAsString()) {
- std::string triple_string = triple_string_value->GetValue();
+ std::string triple_string =
+ std::string(triple_string_value->GetValue());
ArchSpec host_arch(triple_string.c_str());
if (!host_arch.IsCompatibleMatch(GetTarget().GetArchitecture())) {
GetTarget().SetArchitecture(host_arch);
@@ -638,15 +629,17 @@ Status ProcessGDBRemote::WillAttachToProcessWithName(const char *process_name,
return WillLaunchOrAttach();
}
-Status ProcessGDBRemote::DoConnectRemote(Stream *strm,
- llvm::StringRef remote_url) {
+Status ProcessGDBRemote::DoConnectRemote(llvm::StringRef remote_url) {
Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
Status error(WillLaunchOrAttach());
if (error.Fail())
return error;
- error = ConnectToDebugserver(remote_url);
+ if (repro::Reproducer::Instance().IsReplaying())
+ error = ConnectToReplayServer();
+ else
+ error = ConnectToDebugserver(remote_url);
if (error.Fail())
return error;
@@ -824,22 +817,23 @@ Status ProcessGDBRemote::DoLaunch(lldb_private::Module *exe_module,
// since 'O' packets can really slow down debugging if the inferior
// does a lot of output.
if ((!stdin_file_spec || !stdout_file_spec || !stderr_file_spec) &&
- pty.OpenFirstAvailableMaster(O_RDWR | O_NOCTTY, nullptr, 0)) {
- FileSpec slave_name{pty.GetSlaveName(nullptr, 0)};
+ pty.OpenFirstAvailablePrimary(O_RDWR | O_NOCTTY, nullptr, 0)) {
+ FileSpec secondary_name{pty.GetSecondaryName(nullptr, 0)};
if (!stdin_file_spec)
- stdin_file_spec = slave_name;
+ stdin_file_spec = secondary_name;
if (!stdout_file_spec)
- stdout_file_spec = slave_name;
+ stdout_file_spec = secondary_name;
if (!stderr_file_spec)
- stderr_file_spec = slave_name;
+ stderr_file_spec = secondary_name;
}
LLDB_LOGF(
log,
"ProcessGDBRemote::%s adjusted STDIO paths for local platform "
- "(IsHost() is true) using slave: stdin=%s, stdout=%s, stderr=%s",
+ "(IsHost() is true) using secondary: stdin=%s, stdout=%s, "
+ "stderr=%s",
__FUNCTION__,
stdin_file_spec ? stdin_file_spec.GetCString() : "<null>",
stdout_file_spec ? stdout_file_spec.GetCString() : "<null>",
@@ -924,8 +918,8 @@ Status ProcessGDBRemote::DoLaunch(lldb_private::Module *exe_module,
SetPrivateState(SetThreadStopInfo(response));
if (!disable_stdio) {
- if (pty.GetMasterFileDescriptor() != PseudoTerminal::invalid_fd)
- SetSTDIOFileDescriptor(pty.ReleaseMasterFileDescriptor());
+ if (pty.GetPrimaryFileDescriptor() != PseudoTerminal::invalid_fd)
+ SetSTDIOFileDescriptor(pty.ReleasePrimaryFileDescriptor());
}
}
} else {
@@ -957,7 +951,7 @@ Status ProcessGDBRemote::ConnectToDebugserver(llvm::StringRef connect_url) {
uint32_t retry_count = 0;
while (!m_gdb_comm.IsConnected()) {
if (conn_up->Connect(connect_url, &error) == eConnectionStatusSuccess) {
- m_gdb_comm.SetConnection(conn_up.release());
+ m_gdb_comm.SetConnection(std::move(conn_up));
break;
} else if (error.WasInterrupted()) {
// If we were interrupted, don't keep retrying.
@@ -1023,122 +1017,113 @@ Status ProcessGDBRemote::ConnectToDebugserver(llvm::StringRef connect_url) {
void ProcessGDBRemote::DidLaunchOrAttach(ArchSpec &process_arch) {
Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
- LLDB_LOGF(log, "ProcessGDBRemote::%s()", __FUNCTION__);
- if (GetID() != LLDB_INVALID_PROCESS_ID) {
- BuildDynamicRegisterInfo(false);
+ BuildDynamicRegisterInfo(false);
- // See if the GDB server supports the qHostInfo information
+ // See if the GDB server supports qHostInfo or qProcessInfo packets. Prefer
+ // qProcessInfo as it will be more specific to our process.
- // See if the GDB server supports the qProcessInfo packet, if so prefer
- // that over the Host information as it will be more specific to our
- // process.
+ const ArchSpec &remote_process_arch = m_gdb_comm.GetProcessArchitecture();
+ if (remote_process_arch.IsValid()) {
+ process_arch = remote_process_arch;
+ LLDB_LOG(log, "gdb-remote had process architecture, using {0} {1}",
+ process_arch.GetArchitectureName(),
+ process_arch.GetTriple().getTriple());
+ } else {
+ process_arch = m_gdb_comm.GetHostArchitecture();
+ LLDB_LOG(log,
+ "gdb-remote did not have process architecture, using gdb-remote "
+ "host architecture {0} {1}",
+ process_arch.GetArchitectureName(),
+ process_arch.GetTriple().getTriple());
+ }
- const ArchSpec &remote_process_arch = m_gdb_comm.GetProcessArchitecture();
- if (remote_process_arch.IsValid()) {
- process_arch = remote_process_arch;
- LLDB_LOGF(log,
- "ProcessGDBRemote::%s gdb-remote had process architecture, "
- "using %s %s",
- __FUNCTION__,
- process_arch.GetArchitectureName()
- ? process_arch.GetArchitectureName()
- : "<null>",
- process_arch.GetTriple().getTriple().c_str()
- ? process_arch.GetTriple().getTriple().c_str()
- : "<null>");
- } else {
- process_arch = m_gdb_comm.GetHostArchitecture();
- LLDB_LOGF(log,
- "ProcessGDBRemote::%s gdb-remote did not have process "
- "architecture, using gdb-remote host architecture %s %s",
- __FUNCTION__,
- process_arch.GetArchitectureName()
- ? process_arch.GetArchitectureName()
- : "<null>",
- process_arch.GetTriple().getTriple().c_str()
- ? process_arch.GetTriple().getTriple().c_str()
- : "<null>");
- }
+ if (process_arch.IsValid()) {
+ const ArchSpec &target_arch = GetTarget().GetArchitecture();
+ if (target_arch.IsValid()) {
+ LLDB_LOG(log, "analyzing target arch, currently {0} {1}",
+ target_arch.GetArchitectureName(),
+ target_arch.GetTriple().getTriple());
+
+ // If the remote host is ARM and we have apple as the vendor, then
+ // ARM executables and shared libraries can have mixed ARM
+ // architectures.
+ // You can have an armv6 executable, and if the host is armv7, then the
+ // system will load the best possible architecture for all shared
+ // libraries 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.GetMachine() == llvm::Triple::thumb) &&
+ process_arch.GetTriple().getVendor() == llvm::Triple::Apple) {
+ GetTarget().SetArchitecture(process_arch);
+ LLDB_LOG(log,
+ "remote process is ARM/Apple, "
+ "setting target arch to {0} {1}",
+ process_arch.GetArchitectureName(),
+ process_arch.GetTriple().getTriple());
+ } else {
+ // Fill in what is missing in the triple
+ const llvm::Triple &remote_triple = process_arch.GetTriple();
+ llvm::Triple new_target_triple = target_arch.GetTriple();
+ if (new_target_triple.getVendorName().size() == 0) {
+ new_target_triple.setVendor(remote_triple.getVendor());
- if (process_arch.IsValid()) {
- const ArchSpec &target_arch = GetTarget().GetArchitecture();
- if (target_arch.IsValid()) {
- LLDB_LOGF(log,
- "ProcessGDBRemote::%s analyzing target arch, currently %s %s",
- __FUNCTION__,
- target_arch.GetArchitectureName()
- ? target_arch.GetArchitectureName()
- : "<null>",
- target_arch.GetTriple().getTriple().c_str()
- ? target_arch.GetTriple().getTriple().c_str()
- : "<null>");
-
- // If the remote host is ARM and we have apple as the vendor, then
- // ARM executables and shared libraries can have mixed ARM
- // architectures.
- // You can have an armv6 executable, and if the host is armv7, then the
- // system will load the best possible architecture for all shared
- // libraries 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.GetMachine() == llvm::Triple::thumb) &&
- process_arch.GetTriple().getVendor() == llvm::Triple::Apple) {
- GetTarget().SetArchitecture(process_arch);
- LLDB_LOGF(log,
- "ProcessGDBRemote::%s remote process is ARM/Apple, "
- "setting target arch to %s %s",
- __FUNCTION__,
- process_arch.GetArchitectureName()
- ? process_arch.GetArchitectureName()
- : "<null>",
- process_arch.GetTriple().getTriple().c_str()
- ? process_arch.GetTriple().getTriple().c_str()
- : "<null>");
- } else {
- // Fill in what is missing in the triple
- const llvm::Triple &remote_triple = process_arch.GetTriple();
- llvm::Triple new_target_triple = target_arch.GetTriple();
- if (new_target_triple.getVendorName().size() == 0) {
- new_target_triple.setVendor(remote_triple.getVendor());
-
- if (new_target_triple.getOSName().size() == 0) {
- new_target_triple.setOS(remote_triple.getOS());
-
- if (new_target_triple.getEnvironmentName().size() == 0)
- new_target_triple.setEnvironment(
- remote_triple.getEnvironment());
- }
+ if (new_target_triple.getOSName().size() == 0) {
+ new_target_triple.setOS(remote_triple.getOS());
- ArchSpec new_target_arch = target_arch;
- new_target_arch.SetTriple(new_target_triple);
- GetTarget().SetArchitecture(new_target_arch);
+ if (new_target_triple.getEnvironmentName().size() == 0)
+ new_target_triple.setEnvironment(remote_triple.getEnvironment());
}
- }
- LLDB_LOGF(log,
- "ProcessGDBRemote::%s final target arch after "
- "adjustments for remote architecture: %s %s",
- __FUNCTION__,
- target_arch.GetArchitectureName()
- ? target_arch.GetArchitectureName()
- : "<null>",
- target_arch.GetTriple().getTriple().c_str()
- ? target_arch.GetTriple().getTriple().c_str()
- : "<null>");
- } else {
- // The target doesn't have a valid architecture yet, set it from the
- // architecture we got from the remote GDB server
- GetTarget().SetArchitecture(process_arch);
+ ArchSpec new_target_arch = target_arch;
+ new_target_arch.SetTriple(new_target_triple);
+ GetTarget().SetArchitecture(new_target_arch);
+ }
}
+
+ LLDB_LOG(log,
+ "final target arch after adjustments for remote architecture: "
+ "{0} {1}",
+ target_arch.GetArchitectureName(),
+ target_arch.GetTriple().getTriple());
+ } else {
+ // The target doesn't have a valid architecture yet, set it from the
+ // architecture we got from the remote GDB server
+ GetTarget().SetArchitecture(process_arch);
}
+ }
+
+ MaybeLoadExecutableModule();
+
+ // Find out which StructuredDataPlugins are supported by the debug monitor.
+ // These plugins transmit data over async $J packets.
+ if (StructuredData::Array *supported_packets =
+ m_gdb_comm.GetSupportedStructuredDataPlugins())
+ MapSupportedStructuredDataPlugins(*supported_packets);
+}
+
+void ProcessGDBRemote::MaybeLoadExecutableModule() {
+ ModuleSP module_sp = GetTarget().GetExecutableModule();
+ if (!module_sp)
+ return;
+
+ llvm::Optional<QOffsets> offsets = m_gdb_comm.GetQOffsets();
+ if (!offsets)
+ return;
- // Find out which StructuredDataPlugins are supported by the debug monitor.
- // These plugins transmit data over async $J packets.
- auto supported_packets_array =
- m_gdb_comm.GetSupportedStructuredDataPlugins();
- if (supported_packets_array)
- MapSupportedStructuredDataPlugins(*supported_packets_array);
+ bool is_uniform =
+ size_t(llvm::count(offsets->offsets, offsets->offsets[0])) ==
+ offsets->offsets.size();
+ if (!is_uniform)
+ return; // TODO: Handle non-uniform responses.
+
+ bool changed = false;
+ module_sp->SetLoadAddress(GetTarget(), offsets->offsets[0],
+ /*value_is_offset=*/true, changed);
+ if (changed) {
+ ModuleList list;
+ list.Append(module_sp);
+ m_process->GetTarget().ModulesDidLoad(list);
}
}
@@ -1576,7 +1561,8 @@ bool ProcessGDBRemote::UpdateThreadIDList() {
for (int i = 0; i < nItems; i++) {
// Get the thread stop info
StringExtractorGDBRemote &stop_info = m_stop_packet_stack[i];
- const std::string &stop_info_str = stop_info.GetStringRef();
+ const std::string &stop_info_str =
+ std::string(stop_info.GetStringRef());
m_thread_pcs.clear();
const size_t thread_pcs_pos = stop_info_str.find(";thread-pcs:");
@@ -2040,14 +2026,14 @@ ProcessGDBRemote::SetThreadStopInfo(StructuredData::Dictionary *thread_dict) {
});
}
} else if (key == g_key_name) {
- thread_name = object->GetStringValue();
+ thread_name = std::string(object->GetStringValue());
} else if (key == g_key_qaddr) {
thread_dispatch_qaddr = object->GetIntegerValue(LLDB_INVALID_ADDRESS);
} else if (key == g_key_queue_name) {
queue_vars_valid = true;
- queue_name = object->GetStringValue();
+ queue_name = std::string(object->GetStringValue());
} else if (key == g_key_queue_kind) {
- std::string queue_kind_str = object->GetStringValue();
+ std::string queue_kind_str = std::string(object->GetStringValue());
if (queue_kind_str == "serial") {
queue_vars_valid = true;
queue_kind = eQueueKindSerial;
@@ -2071,9 +2057,9 @@ ProcessGDBRemote::SetThreadStopInfo(StructuredData::Dictionary *thread_dict) {
else
associated_with_dispatch_queue = eLazyBoolNo;
} else if (key == g_key_reason) {
- reason = object->GetStringValue();
+ reason = std::string(object->GetStringValue());
} else if (key == g_key_description) {
- description = object->GetStringValue();
+ description = std::string(object->GetStringValue());
} else if (key == g_key_registers) {
StructuredData::Dictionary *registers_dict = object->GetAsDictionary();
@@ -2084,7 +2070,8 @@ ProcessGDBRemote::SetThreadStopInfo(StructuredData::Dictionary *thread_dict) {
const uint32_t reg =
StringConvert::ToUInt32(key.GetCString(), UINT32_MAX, 10);
if (reg != UINT32_MAX)
- expedited_register_map[reg] = object->GetStringValue();
+ expedited_register_map[reg] =
+ std::string(object->GetStringValue());
return true; // Keep iterating through all array items
});
}
@@ -2227,7 +2214,7 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) {
// Now convert the HEX bytes into a string value
name_extractor.GetHexByteString(thread_name);
} else if (key.compare("name") == 0) {
- thread_name = value;
+ thread_name = std::string(value);
} else if (key.compare("qaddr") == 0) {
value.getAsInteger(16, thread_dispatch_qaddr);
} else if (key.compare("dispatch_queue_t") == 0) {
@@ -2248,7 +2235,7 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) {
if (!value.getAsInteger(0, queue_serial_number))
queue_vars_valid = true;
} else if (key.compare("reason") == 0) {
- reason = value;
+ reason = std::string(value);
} else if (key.compare("description") == 0) {
StringExtractor desc_extractor(value);
// Now convert the HEX bytes into a string value
@@ -2297,7 +2284,7 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) {
reason = "watchpoint";
StreamString ostr;
ostr.Printf("%" PRIu64 " %" PRIu32, wp_addr, wp_index);
- description = ostr.GetString();
+ description = std::string(ostr.GetString());
} else if (key.compare("library") == 0) {
auto error = LoadModules();
if (error) {
@@ -2308,7 +2295,7 @@ StateType ProcessGDBRemote::SetThreadStopInfo(StringExtractor &stop_packet) {
} else if (key.size() == 2 && ::isxdigit(key[0]) && ::isxdigit(key[1])) {
uint32_t reg = UINT32_MAX;
if (!key.getAsInteger(16, reg))
- expedited_register_map[reg] = std::move(value);
+ expedited_register_map[reg] = std::string(std::move(value));
}
}
@@ -2585,7 +2572,7 @@ Status ProcessGDBRemote::DoDestroy() {
"to k packet: %s",
response.GetStringRef().data());
exit_string.assign("got unexpected response to k packet: ");
- exit_string.append(response.GetStringRef());
+ exit_string.append(std::string(response.GetStringRef()));
}
} else {
LLDB_LOGF(log, "ProcessGDBRemote::DoDestroy - failed to send k packet");
@@ -3127,7 +3114,7 @@ Status ProcessGDBRemote::EnableBreakpointSite(BreakpointSite *bp_site) {
if (m_gdb_comm.SupportsGDBStoppointPacket(eBreakpointSoftware)) {
if (error_no != UINT8_MAX)
error.SetErrorStringWithFormat(
- "error: %d sending the breakpoint request", errno);
+ "error: %d sending the breakpoint request", error_no);
else
error.SetErrorString("error sending the breakpoint request");
return error;
@@ -3356,30 +3343,10 @@ Status ProcessGDBRemote::DoSignal(int signo) {
return error;
}
-Status ProcessGDBRemote::ConnectToReplayServer(repro::Loader *loader) {
- if (!loader)
- return Status("No loader provided.");
-
- static std::unique_ptr<repro::MultiLoader<repro::GDBRemoteProvider>>
- multi_loader = repro::MultiLoader<repro::GDBRemoteProvider>::Create(
- repro::Reproducer::Instance().GetLoader());
-
- if (!multi_loader)
- return Status("No gdb remote provider found.");
-
- llvm::Optional<std::string> history_file = multi_loader->GetNextFile();
- if (!history_file)
- return Status("No gdb remote packet log found.");
-
- // Load replay history.
- if (auto error =
- m_gdb_replay_server.LoadReplayHistory(FileSpec(*history_file)))
- return Status("Unable to load replay history");
-
- // Make a local connection.
- if (auto error = GDBRemoteCommunication::ConnectLocally(m_gdb_comm,
- m_gdb_replay_server))
- return Status("Unable to connect to replay server");
+Status ProcessGDBRemote::ConnectToReplayServer() {
+ Status status = m_gdb_replay_server.Connect(m_gdb_comm);
+ if (status.Fail())
+ return status;
// Enable replay mode.
m_replay_mode = true;
@@ -3404,8 +3371,8 @@ ProcessGDBRemote::EstablishConnectionIfNeeded(const ProcessInfo &process_info) {
if (platform_sp && !platform_sp->IsHost())
return Status("Lost debug server connection");
- if (repro::Loader *loader = repro::Reproducer::Instance().GetLoader())
- return ConnectToReplayServer(loader);
+ if (repro::Reproducer::Instance().IsReplaying())
+ return ConnectToReplayServer();
auto error = LaunchAndConnectToDebugserver(process_info);
if (error.Fail()) {
@@ -3452,6 +3419,23 @@ Status ProcessGDBRemote::LaunchAndConnectToDebugserver(
std::bind(MonitorDebugserverProcess, this_wp, _1, _2, _3, _4), false);
debugserver_launch_info.SetUserID(process_info.GetUserID());
+#if defined(__APPLE__)
+ // On macOS 11, we need to support x86_64 applications translated to
+ // arm64. We check whether a binary is translated and spawn the correct
+ // debugserver accordingly.
+ int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID,
+ static_cast<int>(process_info.GetProcessID()) };
+ struct kinfo_proc processInfo;
+ size_t bufsize = sizeof(processInfo);
+ if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)), &processInfo,
+ &bufsize, NULL, 0) == 0 && bufsize > 0) {
+ if (processInfo.kp_proc.p_flag & P_TRANSLATED) {
+ FileSpec rosetta_debugserver("/Library/Apple/usr/libexec/oah/debugserver");
+ debugserver_launch_info.SetExecutableFile(rosetta_debugserver, false);
+ }
+ }
+#endif
+
int communication_fd = -1;
#ifdef USE_SOCKETPAIR_FOR_LOCAL_CONNECTION
// Use a socketpair on non-Windows systems for security and performance
@@ -3486,7 +3470,8 @@ Status ProcessGDBRemote::LaunchAndConnectToDebugserver(
// Our process spawned correctly, we can now set our connection to use
// our end of the socket pair
cleanup_our.release();
- m_gdb_comm.SetConnection(new ConnectionFileDescriptor(our_socket, true));
+ m_gdb_comm.SetConnection(
+ std::make_unique<ConnectionFileDescriptor>(our_socket, true));
#endif
StartAsyncThread();
}
@@ -3648,7 +3633,7 @@ void ProcessGDBRemote::StopAsyncThread() {
bool ProcessGDBRemote::HandleNotifyPacket(StringExtractorGDBRemote &packet) {
// get the packet at a string
- const std::string &pkt = packet.GetStringRef();
+ const std::string &pkt = std::string(packet.GetStringRef());
// skip %stop:
StringExtractorGDBRemote stop_info(pkt.c_str() + 5);
@@ -3794,7 +3779,7 @@ thread_result_t ProcessGDBRemote::AsyncThread(void *arg) {
} // switch(stop_state)
} // else // if in All-stop-mode
} // if (continue_packet)
- } // case eBroadcastBitAysncContinue
+ } // case eBroadcastBitAsyncContinue
break;
case eBroadcastBitAsyncThreadShouldExit:
@@ -4030,7 +4015,8 @@ ProcessGDBRemote::GetExtendedInfoForThread(lldb::tid_t tid) {
response.GetResponseType();
if (response_type == StringExtractorGDBRemote::eResponse) {
if (!response.Empty()) {
- object_sp = StructuredData::ParseJSON(response.GetStringRef());
+ object_sp =
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
}
}
}
@@ -4102,7 +4088,8 @@ ProcessGDBRemote::GetLoadedDynamicLibrariesInfos_sender(
response.GetResponseType();
if (response_type == StringExtractorGDBRemote::eResponse) {
if (!response.Empty()) {
- object_sp = StructuredData::ParseJSON(response.GetStringRef());
+ object_sp =
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
}
}
}
@@ -4135,7 +4122,8 @@ StructuredData::ObjectSP ProcessGDBRemote::GetSharedCacheInfo() {
response.GetResponseType();
if (response_type == StringExtractorGDBRemote::eResponse) {
if (!response.Empty()) {
- object_sp = StructuredData::ParseJSON(response.GetStringRef());
+ object_sp =
+ StructuredData::ParseJSON(std::string(response.GetStringRef()));
}
}
}
@@ -4419,7 +4407,7 @@ bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info,
});
if (!gdb_type.empty() && !(encoding_set || format_set)) {
- if (gdb_type.find("int") == 0) {
+ if (llvm::StringRef(gdb_type).startswith("int")) {
reg_info.format = eFormatHex;
reg_info.encoding = eEncodingUint;
} else if (gdb_type == "data_ptr" || gdb_type == "code_ptr") {
@@ -4682,7 +4670,7 @@ llvm::Expected<LoadedModuleInfoList> ProcessGDBRemote::GetLoadedModuleList() {
// value.
module.set_base_is_offset(true);
} else if (name == "l_ld") {
- // the memory address of the libraries PT_DYAMIC section.
+ // the memory address of the libraries PT_DYNAMIC section.
module.set_dynamic(StringConvert::ToUInt64(
value.data(), LLDB_INVALID_ADDRESS, 0));
}
@@ -5069,7 +5057,8 @@ ParseStructuredDataPacket(llvm::StringRef packet) {
}
// This is an asynchronous JSON packet, destined for a StructuredDataPlugin.
- StructuredData::ObjectSP json_sp = StructuredData::ParseJSON(packet);
+ StructuredData::ObjectSP json_sp =
+ StructuredData::ParseJSON(std::string(packet));
if (log) {
if (json_sp) {
StreamString json_str;
@@ -5276,7 +5265,7 @@ public:
result.SetStatus(eReturnStatusSuccessFinishResult);
Stream &output_strm = result.GetOutputStream();
output_strm.Printf(" packet: %s\n", packet_cstr);
- std::string response_str = response.GetStringRef();
+ std::string response_str = std::string(response.GetStringRef());
if (strstr(packet_cstr, "qGetProfileData") != nullptr) {
response_str = process->HarmonizeThreadIdsForProfileData(response);
@@ -5329,7 +5318,7 @@ public:
[&output_strm](llvm::StringRef output) { output_strm << output; });
result.SetStatus(eReturnStatusSuccessFinishResult);
output_strm.Printf(" packet: %s\n", packet.GetData());
- const std::string &response_str = response.GetStringRef();
+ const std::string &response_str = std::string(response.GetStringRef());
if (response_str.empty())
output_strm.PutCString("response: \nerror: UNIMPLEMENTED\n");
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index 9ea3940103b6..ba967727ae3b 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ProcessGDBRemote_h_
-#define liblldb_ProcessGDBRemote_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_PROCESSGDBREMOTE_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_PROCESSGDBREMOTE_H
#include <atomic>
#include <map>
@@ -85,7 +85,7 @@ public:
Status WillAttachToProcessWithName(const char *process_name,
bool wait_for_launch) override;
- Status DoConnectRemote(Stream *strm, llvm::StringRef remote_url) override;
+ Status DoConnectRemote(llvm::StringRef remote_url) override;
Status WillLaunchOrAttach();
@@ -312,7 +312,7 @@ protected:
bool UpdateThreadList(ThreadList &old_thread_list,
ThreadList &new_thread_list) override;
- Status ConnectToReplayServer(repro::Loader *loader);
+ Status ConnectToReplayServer();
Status EstablishConnectionIfNeeded(const ProcessInfo &process_info);
@@ -377,6 +377,7 @@ protected:
bool UpdateThreadIDList();
void DidLaunchOrAttach(ArchSpec &process_arch);
+ void MaybeLoadExecutableModule();
Status ConnectToDebugserver(llvm::StringRef host_port);
@@ -386,7 +387,7 @@ protected:
DynamicLoader *GetDynamicLoader() override;
bool GetGDBServerRegisterInfoXMLAndProcess(ArchSpec &arch_to_use,
- std::string xml_filename,
+ std::string xml_filename,
uint32_t &cur_reg_num,
uint32_t &reg_offset);
@@ -449,10 +450,11 @@ private:
llvm::DenseMap<ModuleCacheKey, ModuleSpec, ModuleCacheInfo>
m_cached_module_specs;
- DISALLOW_COPY_AND_ASSIGN(ProcessGDBRemote);
+ ProcessGDBRemote(const ProcessGDBRemote &) = delete;
+ const ProcessGDBRemote &operator=(const ProcessGDBRemote &) = delete;
};
} // namespace process_gdb_remote
} // namespace lldb_private
-#endif // liblldb_ProcessGDBRemote_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_PROCESSGDBREMOTE_H
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
index 8cadc45824b3..40990ef66494 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
@@ -1,4 +1,4 @@
-//===-- ProcessGDBRemoteLog.cpp ---------------------------------*- C++ -*-===//
+//===-- ProcessGDBRemoteLog.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h
index d9b8d4536afe..bd3e993cf72a 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h
@@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ProcessGDBRemoteLog_h_
-#define liblldb_ProcessGDBRemoteLog_h_
-
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_PROCESSGDBREMOTELOG_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_PROCESSGDBREMOTELOG_H
#include "lldb/Utility/Log.h"
@@ -43,4 +42,4 @@ public:
} // namespace process_gdb_remote
} // namespace lldb_private
-#endif // liblldb_ProcessGDBRemoteLog_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_PROCESSGDBREMOTELOG_H
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
index 9cbe3d40ca2c..d4c3c8b94b7e 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemoteProperties.td
@@ -11,8 +11,8 @@ let Definition = "processgdbremote" in {
Desc<"The file that provides the description for remote target registers.">;
def UseSVR4: Property<"use-libraries-svr4", "Boolean">,
Global,
- DefaultFalse,
- Desc<"If true, the libraries-svr4 feature will be used to get a hold of the process's loaded modules.">;
+ DefaultTrue,
+ Desc<"If true, the libraries-svr4 feature will be used to get a hold of the process's loaded modules. This setting is only effective if lldb was build with xml support.">;
def UseGPacketForReading: Property<"use-g-packet-for-reading", "Boolean">,
Global,
DefaultFalse,
diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
index 9da481979f73..6deabf8d5d71 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadGDBRemote.cpp -------------------------------------*- C++ -*-===//
+//===-- ThreadGDBRemote.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -311,9 +311,7 @@ ThreadGDBRemote::CreateRegisterContextForFrame(StackFrame *frame) {
read_all_registers_at_once, write_all_registers_at_once);
}
} else {
- Unwind *unwinder = GetUnwinder();
- if (unwinder != nullptr)
- reg_ctx_sp = unwinder->CreateRegisterContextForFrame(frame);
+ reg_ctx_sp = GetUnwinder().CreateRegisterContextForFrame(frame);
}
return reg_ctx_sp;
}
diff --git a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
index c74be169abaf..5ad11170fec4 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadGDBRemote_h_
-#define liblldb_ThreadGDBRemote_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_THREADGDBREMOTE_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_THREADGDBREMOTE_H
#include <string>
@@ -116,4 +116,4 @@ protected:
} // namespace process_gdb_remote
} // namespace lldb_private
-#endif // liblldb_ThreadGDBRemote_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_THREADGDBREMOTE_H
diff --git a/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp b/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
index 3c0e1cb49d1d..0c7f4cbbb859 100644
--- a/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
+++ b/lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
@@ -1,4 +1,4 @@
-//===-- MinidumpParser.cpp ---------------------------------------*- C++ -*-===//
+//===-- MinidumpParser.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/minidump/MinidumpParser.h b/lldb/source/Plugins/Process/minidump/MinidumpParser.h
index 4bcb2b47d45a..c4d7612b5f8d 100644
--- a/lldb/source/Plugins/Process/minidump/MinidumpParser.h
+++ b/lldb/source/Plugins/Process/minidump/MinidumpParser.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_MinidumpParser_h_
-#define liblldb_MinidumpParser_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_MINIDUMPPARSER_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_MINIDUMPPARSER_H
#include "MinidumpTypes.h"
@@ -100,7 +100,6 @@ private:
MinidumpParser(lldb::DataBufferSP data_sp,
std::unique_ptr<llvm::object::MinidumpFile> file);
-private:
lldb::DataBufferSP m_data_sp;
std::unique_ptr<llvm::object::MinidumpFile> m_file;
ArchSpec m_arch;
@@ -108,4 +107,4 @@ private:
} // end namespace minidump
} // end namespace lldb_private
-#endif // liblldb_MinidumpParser_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_MINIDUMPPARSER_H
diff --git a/lldb/source/Plugins/Process/minidump/MinidumpTypes.cpp b/lldb/source/Plugins/Process/minidump/MinidumpTypes.cpp
index ed00b1cc07db..abddd79ad7dc 100644
--- a/lldb/source/Plugins/Process/minidump/MinidumpTypes.cpp
+++ b/lldb/source/Plugins/Process/minidump/MinidumpTypes.cpp
@@ -1,4 +1,4 @@
-//===-- MinidumpTypes.cpp ---------------------------------------*- C++ -*-===//
+//===-- MinidumpTypes.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/minidump/MinidumpTypes.h b/lldb/source/Plugins/Process/minidump/MinidumpTypes.h
index a9c807930ebf..a7ac65120e2b 100644
--- a/lldb/source/Plugins/Process/minidump/MinidumpTypes.h
+++ b/lldb/source/Plugins/Process/minidump/MinidumpTypes.h
@@ -6,9 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_MinidumpTypes_h_
-#define liblldb_MinidumpTypes_h_
-
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_MINIDUMPTYPES_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_MINIDUMPTYPES_H
#include "lldb/Utility/Status.h"
@@ -120,4 +119,4 @@ private:
} // namespace minidump
} // namespace lldb_private
-#endif // liblldb_MinidumpTypes_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_MINIDUMPTYPES_H
diff --git a/lldb/source/Plugins/Process/minidump/NtStructures.h b/lldb/source/Plugins/Process/minidump/NtStructures.h
index fdb0cfb7981e..1dafbe4a4f50 100644
--- a/lldb/source/Plugins/Process/minidump/NtStructures.h
+++ b/lldb/source/Plugins/Process/minidump/NtStructures.h
@@ -1,3 +1,7 @@
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_NTSTRUCTURES_H
+
+#define LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_NTSTRUCTURES_H
+
//===-- NtStructures.h ------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
@@ -34,3 +38,5 @@ struct TEB64 {
#endif // liblldb_Plugins_Process_Minidump_NtStructures_h_
} // namespace minidump
} // namespace lldb_private
+
+#endif
diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
index 5c090dc6e12f..fc8ee346f449 100644
--- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -1,4 +1,4 @@
-//===-- ProcessMinidump.cpp -------------------------------------*- C++ -*-===//
+//===-- ProcessMinidump.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -41,6 +41,8 @@ using namespace lldb;
using namespace lldb_private;
using namespace minidump;
+LLDB_PLUGIN_DEFINE(ProcessMinidump)
+
namespace {
/// A minimal ObjectFile implementation providing a dummy object file for the
@@ -226,8 +228,10 @@ Status ProcessMinidump::DoLoadCore() {
llvm::Optional<lldb::pid_t> pid = m_minidump_parser->GetPid();
if (!pid) {
- error.SetErrorString("failed to parse PID");
- return error;
+ GetTarget().GetDebugger().GetAsyncErrorStream()->PutCString(
+ "Unable to retrieve process ID from minidump file, setting process ID "
+ "to 1.\n");
+ pid = 1;
}
SetID(pid.getValue());
@@ -253,7 +257,7 @@ void ProcessMinidump::RefreshStateAfterStop() {
// TODO: The definition and use of this "dump requested" constant
// in Breakpad are actually Linux-specific, and for similar use
- // cases on Mac/Windows it defines differnt constants, referring
+ // cases on Mac/Windows it defines different constants, referring
// to them as "simulated" exceptions; consider moving this check
// down to the OS-specific paths and checking each OS for its own
// constant.
diff --git a/lldb/source/Plugins/Process/minidump/ProcessMinidump.h b/lldb/source/Plugins/Process/minidump/ProcessMinidump.h
index 750164cf8aaf..839b0e7563f7 100644
--- a/lldb/source/Plugins/Process/minidump/ProcessMinidump.h
+++ b/lldb/source/Plugins/Process/minidump/ProcessMinidump.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ProcessMinidump_h_
-#define liblldb_ProcessMinidump_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_PROCESSMINIDUMP_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_PROCESSMINIDUMP_H
#include "MinidumpParser.h"
#include "MinidumpTypes.h"
@@ -119,4 +119,4 @@ private:
} // namespace minidump
} // namespace lldb_private
-#endif // liblldb_ProcessMinidump_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_PROCESSMINIDUMP_H
diff --git a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp
index 72dead07dcb4..eb48785263fc 100644
--- a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp
+++ b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextMinidump_ARM.cpp -------------------------*- C++ -*-===//
+//===-- RegisterContextMinidump_ARM.cpp -----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h
index 7af3b98a6fe7..857f9c0a3767 100644
--- a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h
+++ b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextMinidump_ARM_h_
-#define liblldb_RegisterContextMinidump_ARM_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_REGISTERCONTEXTMINIDUMP_ARM_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_REGISTERCONTEXTMINIDUMP_ARM_H
#include "MinidumpTypes.h"
@@ -95,4 +95,4 @@ protected:
} // end namespace minidump
} // end namespace lldb_private
-#endif // liblldb_RegisterContextMinidump_ARM_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_REGISTERCONTEXTMINIDUMP_ARM_H
diff --git a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp
index bbd0e14a3267..c7809c5f19b6 100644
--- a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp
+++ b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextMinidump_ARM64.cpp -----------------------*- C++ -*-===//
+//===-- RegisterContextMinidump_ARM64.cpp ---------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
index f9e7f39eea60..8ae751095c04 100644
--- a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
+++ b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextMinidump_ARM64_h_
-#define liblldb_RegisterContextMinidump_ARM64_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_REGISTERCONTEXTMINIDUMP_ARM64_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_REGISTERCONTEXTMINIDUMP_ARM64_H
#include "MinidumpTypes.h"
@@ -79,4 +79,4 @@ protected:
} // end namespace minidump
} // end namespace lldb_private
-#endif // liblldb_RegisterContextMinidump_ARM64_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_REGISTERCONTEXTMINIDUMP_ARM64_H
diff --git a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp
index 8ac2abb22093..38d7de77e3bf 100644
--- a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp
+++ b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextMinidump_x86_32.cpp ----------------------*- C++ -*-===//
+//===-- RegisterContextMinidump_x86_32.cpp --------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h
index d787f78ec7d3..9592d335eff7 100644
--- a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h
+++ b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextMinidump_x86_32_h_
-#define liblldb_RegisterContextMinidump_x86_32_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_REGISTERCONTEXTMINIDUMP_X86_32_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_REGISTERCONTEXTMINIDUMP_X86_32_H
#include "MinidumpTypes.h"
@@ -132,4 +132,4 @@ enum class MinidumpContext_x86_32_Flags : uint32_t {
} // end namespace minidump
} // end namespace lldb_private
-#endif // liblldb_RegisterContextMinidump_x86_32_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_REGISTERCONTEXTMINIDUMP_X86_32_H
diff --git a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
index 515ccf6b2c3c..3c593f0db6ec 100644
--- a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
+++ b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextMinidump_x86_64.cpp ----------------------*- C++ -*-===//
+//===-- RegisterContextMinidump_x86_64.cpp --------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
index 34ddd477a9d1..d920ea9d823f 100644
--- a/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
+++ b/lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextMinidump_h_
-#define liblldb_RegisterContextMinidump_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_REGISTERCONTEXTMINIDUMP_X86_64_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_REGISTERCONTEXTMINIDUMP_X86_64_H
#include "MinidumpTypes.h"
@@ -177,4 +177,4 @@ enum class MinidumpContext_x86_64_Flags : uint32_t {
} // end namespace minidump
} // end namespace lldb_private
-#endif // liblldb_RegisterContextMinidump_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_REGISTERCONTEXTMINIDUMP_X86_64_H
diff --git a/lldb/source/Plugins/Process/minidump/ThreadMinidump.cpp b/lldb/source/Plugins/Process/minidump/ThreadMinidump.cpp
index 5262de5a94c4..e146a1a1af92 100644
--- a/lldb/source/Plugins/Process/minidump/ThreadMinidump.cpp
+++ b/lldb/source/Plugins/Process/minidump/ThreadMinidump.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadMinidump.cpp --------------------------------------*- C++ -*-===//
+//===-- ThreadMinidump.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/minidump/ThreadMinidump.h b/lldb/source/Plugins/Process/minidump/ThreadMinidump.h
index 44c41bc9f50e..aed7cfbc1b16 100644
--- a/lldb/source/Plugins/Process/minidump/ThreadMinidump.h
+++ b/lldb/source/Plugins/Process/minidump/ThreadMinidump.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ThreadMinidump_h_
-#define liblldb_ThreadMinidump_h_
+#ifndef LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_THREADMINIDUMP_H
+#define LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_THREADMINIDUMP_H
#include "MinidumpTypes.h"
@@ -42,4 +42,4 @@ protected:
} // namespace minidump
} // namespace lldb_private
-#endif // liblldb_ThreadMinidump_h_
+#endif // LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_THREADMINIDUMP_H
diff --git a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
index ecee8cc674f8..acd6128d84c5 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
@@ -57,3 +57,35 @@ llvm::Error Lua::LoadModule(llvm::StringRef filename) {
lua_setglobal(m_lua_state, module_name.GetCString());
return llvm::Error::success();
}
+
+llvm::Error Lua::ChangeIO(FILE *out, FILE *err) {
+ assert(out != nullptr);
+ assert(err != nullptr);
+
+ lua_getglobal(m_lua_state, "io");
+
+ lua_getfield(m_lua_state, -1, "stdout");
+ if (luaL_Stream *s = static_cast<luaL_Stream *>(
+ luaL_testudata(m_lua_state, -1, LUA_FILEHANDLE))) {
+ s->f = out;
+ lua_pop(m_lua_state, 1);
+ } else {
+ lua_pop(m_lua_state, 2);
+ return llvm::make_error<llvm::StringError>("could not get stdout",
+ llvm::inconvertibleErrorCode());
+ }
+
+ lua_getfield(m_lua_state, -1, "stderr");
+ if (luaL_Stream *s = static_cast<luaL_Stream *>(
+ luaL_testudata(m_lua_state, -1, LUA_FILEHANDLE))) {
+ s->f = out;
+ lua_pop(m_lua_state, 1);
+ } else {
+ lua_pop(m_lua_state, 2);
+ return llvm::make_error<llvm::StringError>("could not get stderr",
+ llvm::inconvertibleErrorCode());
+ }
+
+ lua_pop(m_lua_state, 1);
+ return llvm::Error::success();
+}
diff --git a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
index f2984a925dfe..300115aac8a7 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
@@ -38,6 +38,7 @@ public:
llvm::Error Run(llvm::StringRef buffer);
llvm::Error LoadModule(llvm::StringRef filename);
+ llvm::Error ChangeIO(FILE *out, FILE *err);
private:
lua_State *m_lua_state;
diff --git a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
index 701d68d1ec08..8cbeac4563c3 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -1,4 +1,4 @@
-//===-- ScriptInterpreterLua.cpp --------------------------------*- C++ -*-===//
+//===-- ScriptInterpreterLua.cpp ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -15,10 +15,13 @@
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StringList.h"
#include "lldb/Utility/Timer.h"
+#include "llvm/Support/FormatAdapters.h"
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(ScriptInterpreterLua)
+
class IOHandlerLuaInterpreter : public IOHandlerDelegate,
public IOHandlerEditline {
public:
@@ -28,15 +31,23 @@ public:
">>> ", "..> ", true, debugger.GetUseColor(), 0,
*this, nullptr),
m_script_interpreter(script_interpreter) {
+ llvm::cantFail(m_script_interpreter.GetLua().ChangeIO(
+ debugger.GetOutputFile().GetStream(),
+ debugger.GetErrorFile().GetStream()));
llvm::cantFail(m_script_interpreter.EnterSession(debugger.GetID()));
}
- ~IOHandlerLuaInterpreter() {
+ ~IOHandlerLuaInterpreter() override {
llvm::cantFail(m_script_interpreter.LeaveSession());
}
void IOHandlerInputComplete(IOHandler &io_handler,
std::string &data) override {
+ if (llvm::StringRef(data).rtrim() == "quit") {
+ io_handler.SetIsDone(true);
+ return;
+ }
+
if (llvm::Error error = m_script_interpreter.GetLua().Run(data)) {
*GetOutputStreamFileSP() << llvm::toString(std::move(error));
}
@@ -55,12 +66,43 @@ ScriptInterpreterLua::~ScriptInterpreterLua() {}
bool ScriptInterpreterLua::ExecuteOneLine(llvm::StringRef command,
CommandReturnObject *result,
const ExecuteScriptOptions &options) {
+ if (command.empty()) {
+ if (result)
+ result->AppendError("empty command passed to lua\n");
+ return false;
+ }
+
+ llvm::Expected<std::unique_ptr<ScriptInterpreterIORedirect>>
+ io_redirect_or_error = ScriptInterpreterIORedirect::Create(
+ options.GetEnableIO(), m_debugger, result);
+ if (!io_redirect_or_error) {
+ if (result)
+ result->AppendErrorWithFormatv(
+ "failed to redirect I/O: {0}\n",
+ llvm::fmt_consume(io_redirect_or_error.takeError()));
+ else
+ llvm::consumeError(io_redirect_or_error.takeError());
+ return false;
+ }
+
+ ScriptInterpreterIORedirect &io_redirect = **io_redirect_or_error;
+
+ if (llvm::Error e =
+ m_lua->ChangeIO(io_redirect.GetOutputFile()->GetStream(),
+ io_redirect.GetErrorFile()->GetStream())) {
+ result->AppendErrorWithFormatv("lua failed to redirect I/O: {0}\n",
+ llvm::toString(std::move(e)));
+ return false;
+ }
+
if (llvm::Error e = m_lua->Run(command)) {
result->AppendErrorWithFormatv(
"lua failed attempting to evaluate '{0}': {1}\n", command,
llvm::toString(std::move(e)));
return false;
}
+
+ io_redirect.Flush();
return true;
}
@@ -68,25 +110,23 @@ void ScriptInterpreterLua::ExecuteInterpreterLoop() {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
- Debugger &debugger = m_debugger;
-
// At the moment, the only time the debugger does not have an input file
// handle is when this is called directly from lua, in which case it is
// both dangerous and unnecessary (not to mention confusing) to try to embed
// a running interpreter loop inside the already running lua interpreter
// loop, so we won't do it.
-
- if (!debugger.GetInputFile().IsValid())
+ if (!m_debugger.GetInputFile().IsValid())
return;
- IOHandlerSP io_handler_sp(new IOHandlerLuaInterpreter(debugger, *this));
- debugger.PushIOHandler(io_handler_sp);
+ IOHandlerSP io_handler_sp(new IOHandlerLuaInterpreter(m_debugger, *this));
+ m_debugger.RunIOHandlerAsync(io_handler_sp);
}
bool ScriptInterpreterLua::LoadScriptingModule(
const char *filename, bool init_session, lldb_private::Status &error,
StructuredData::ObjectSP *module_sp) {
+ FileSystem::Instance().Collect(filename);
if (llvm::Error e = m_lua->LoadModule(filename)) {
error.SetErrorStringWithFormatv("lua failed to import '{0}': {1}\n",
filename, llvm::toString(std::move(e)));
diff --git a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
index 4e922151385b..bcc6ab24f6d0 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
@@ -25,7 +25,7 @@ public:
void ExecuteInterpreterLoop() override;
- virtual bool
+ bool
LoadScriptingModule(const char *filename, bool init_session,
lldb_private::Status &error,
StructuredData::ObjectSP *module_sp = nullptr) override;
diff --git a/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp b/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
index 3517f831970d..d9c32cc132d4 100644
--- a/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
@@ -1,4 +1,4 @@
-//===-- ScriptInterpreterNone.cpp -------------------------------*- C++ -*-===//
+//===-- ScriptInterpreterNone.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -20,6 +20,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(ScriptInterpreterNone)
+
ScriptInterpreterNone::ScriptInterpreterNone(Debugger &debugger)
: ScriptInterpreter(debugger, eScriptLanguageNone) {}
diff --git a/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h b/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h
index 242065cc23e8..c438b6315c5d 100644
--- a/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h
+++ b/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ScriptInterpreterNone_h_
-#define liblldb_ScriptInterpreterNone_h_
+#ifndef LLDB_SOURCE_PLUGINS_SCRIPTINTERPRETER_NONE_SCRIPTINTERPRETERNONE_H
+#define LLDB_SOURCE_PLUGINS_SCRIPTINTERPRETER_NONE_SCRIPTINTERPRETERNONE_H
#include "lldb/Interpreter/ScriptInterpreter.h"
@@ -44,4 +44,4 @@ public:
} // namespace lldb_private
-#endif // liblldb_ScriptInterpreterNone_h_
+#endif // LLDB_SOURCE_PLUGINS_SCRIPTINTERPRETER_NONE_SCRIPTINTERPRETERNONE_H
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
index e5a67653e334..6f040fdef09b 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -1,4 +1,4 @@
-//===-- PythonDataObjects.cpp -----------------------------------*- C++ -*-===//
+//===-- PythonDataObjects.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -44,7 +44,15 @@ template <>
Expected<long long> python::As<long long>(Expected<PythonObject> &&obj) {
if (!obj)
return obj.takeError();
- return obj.get().AsLongLong();
+ return obj->AsLongLong();
+}
+
+template <>
+Expected<unsigned long long>
+python::As<unsigned long long>(Expected<PythonObject> &&obj) {
+ if (!obj)
+ return obj.takeError();
+ return obj->AsUnsignedLongLong();
}
template <>
@@ -58,7 +66,56 @@ Expected<std::string> python::As<std::string>(Expected<PythonObject> &&obj) {
auto utf8 = str.AsUTF8();
if (!utf8)
return utf8.takeError();
- return utf8.get();
+ return std::string(utf8.get());
+}
+
+Expected<long long> PythonObject::AsLongLong() const {
+ if (!m_py_obj)
+ return nullDeref();
+#if PY_MAJOR_VERSION < 3
+ if (!PyLong_Check(m_py_obj)) {
+ PythonInteger i(PyRefType::Borrowed, m_py_obj);
+ return i.AsLongLong();
+ }
+#endif
+ assert(!PyErr_Occurred());
+ long long r = PyLong_AsLongLong(m_py_obj);
+ if (PyErr_Occurred())
+ return exception();
+ return r;
+}
+
+Expected<long long> PythonObject::AsUnsignedLongLong() const {
+ if (!m_py_obj)
+ return nullDeref();
+#if PY_MAJOR_VERSION < 3
+ if (!PyLong_Check(m_py_obj)) {
+ PythonInteger i(PyRefType::Borrowed, m_py_obj);
+ return i.AsUnsignedLongLong();
+ }
+#endif
+ assert(!PyErr_Occurred());
+ long long r = PyLong_AsUnsignedLongLong(m_py_obj);
+ if (PyErr_Occurred())
+ return exception();
+ return r;
+}
+
+// wraps on overflow, instead of raising an error.
+Expected<unsigned long long> PythonObject::AsModuloUnsignedLongLong() const {
+ if (!m_py_obj)
+ return nullDeref();
+#if PY_MAJOR_VERSION < 3
+ if (!PyLong_Check(m_py_obj)) {
+ PythonInteger i(PyRefType::Borrowed, m_py_obj);
+ return i.AsModuloUnsignedLongLong();
+ }
+#endif
+ assert(!PyErr_Occurred());
+ unsigned long long r = PyLong_AsUnsignedLongLongMask(m_py_obj);
+ if (PyErr_Occurred())
+ return exception();
+ return r;
}
void StructuredPythonObject::Serialize(llvm::json::OStream &s) const {
@@ -463,32 +520,22 @@ void PythonInteger::Convert(PyRefType &type, PyObject *&py_obj) {
#endif
}
-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");
-
- int overflow = 0;
- int64_t result = PyLong_AsLongLongAndOverflow(m_py_obj, &overflow);
- if (overflow != 0) {
- // We got an integer that overflows, like 18446744072853913392L we can't
- // use PyLong_AsLongLong() as it will return 0xffffffffffffffff. If we
- // use the unsigned long long it will work as expected.
- const uint64_t uval = PyLong_AsUnsignedLongLong(m_py_obj);
- result = static_cast<int64_t>(uval);
- }
- return result;
- }
- return UINT64_MAX;
-}
-
void PythonInteger::SetInteger(int64_t value) {
*this = Take<PythonInteger>(PyLong_FromLongLong(value));
}
StructuredData::IntegerSP PythonInteger::CreateStructuredInteger() const {
StructuredData::IntegerSP result(new StructuredData::Integer);
- result->SetValue(GetInteger());
+ // FIXME this is really not ideal. Errors are silently converted to 0
+ // and overflows are silently wrapped. But we'd need larger changes
+ // to StructuredData to fix it, so that's how it is for now.
+ llvm::Expected<unsigned long long> value = AsModuloUnsignedLongLong();
+ if (!value) {
+ llvm::consumeError(value.takeError());
+ result->SetValue(0);
+ } else {
+ result->SetValue(value.get());
+ }
return result;
}
@@ -1044,7 +1091,7 @@ std::string PythonException::ReadBacktrace() const {
if (!backtrace) {
std::string message =
std::string(toCString()) + "\n" +
- "Traceback unavailble, an error occurred while reading it:\n";
+ "Traceback unavailable, an error occurred while reading it:\n";
return (message + llvm::toString(backtrace.takeError()));
}
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
index b75045b239a8..22f6c67eb7a5 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
@@ -36,7 +36,7 @@
// can never fail to assert instead, such as the creation of
// PythonString from a string literal.
//
-// * Elimintate Reset(), and make all non-default constructors private.
+// * Eliminate Reset(), and make all non-default constructors private.
// Python objects should be created with Retain<> or Take<>, and they
// should be assigned with operator=
//
@@ -90,7 +90,9 @@ public:
void Serialize(llvm::json::OStream &s) const override;
private:
- DISALLOW_COPY_AND_ASSIGN(StructuredPythonObject);
+ StructuredPythonObject(const StructuredPythonObject &) = delete;
+ const StructuredPythonObject &
+ operator=(const StructuredPythonObject &) = delete;
};
enum class PyObjectType {
@@ -319,7 +321,6 @@ public:
StructuredData::ObjectSP CreateStructuredObject() const;
-public:
template <typename... T>
llvm::Expected<PythonObject> CallMethod(const char *name,
const T &... t) const {
@@ -360,15 +361,12 @@ public:
return !!r;
}
- llvm::Expected<long long> AsLongLong() {
- if (!m_py_obj)
- return nullDeref();
- assert(!PyErr_Occurred());
- long long r = PyLong_AsLongLong(m_py_obj);
- if (PyErr_Occurred())
- return exception();
- return r;
- }
+ llvm::Expected<long long> AsLongLong() const;
+
+ llvm::Expected<long long> AsUnsignedLongLong() const;
+
+ // wraps on overflow, instead of raising an error.
+ llvm::Expected<unsigned long long> AsModuloUnsignedLongLong() const;
llvm::Expected<bool> IsInstance(const PythonObject &cls) {
if (!m_py_obj || !cls.IsValid())
@@ -400,6 +398,10 @@ template <>
llvm::Expected<long long> As<long long>(llvm::Expected<PythonObject> &&obj);
template <>
+llvm::Expected<unsigned long long>
+As<unsigned long long>(llvm::Expected<PythonObject> &&obj);
+
+template <>
llvm::Expected<std::string> As<std::string>(llvm::Expected<PythonObject> &&obj);
@@ -491,8 +493,6 @@ public:
static bool Check(PyObject *py_obj);
static void Convert(PyRefType &type, PyObject *&py_obj);
- int64_t GetInteger() const;
-
void SetInteger(int64_t value);
StructuredData::IntegerSP CreateStructuredInteger() const;
@@ -595,7 +595,7 @@ public:
// safe, returns invalid on error;
static PythonModule ImportModule(llvm::StringRef name) {
- std::string s = name;
+ std::string s = std::string(name);
auto mod = Import(s.c_str());
if (!mod) {
llvm::consumeError(mod.takeError());
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index 06e0d5bfa63f..9f56b4fa60a5 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -1,4 +1,4 @@
-//===-- ScriptInterpreterPython.cpp -----------------------------*- C++ -*-===//
+//===-- ScriptInterpreterPython.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -16,7 +16,6 @@
#include "PythonDataObjects.h"
#include "PythonReadline.h"
#include "ScriptInterpreterPythonImpl.h"
-
#include "lldb/API/SBFrame.h"
#include "lldb/API/SBValue.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
@@ -26,7 +25,6 @@
#include "lldb/Core/PluginManager.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"
@@ -35,13 +33,9 @@
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Utility/Timer.h"
-
-#if defined(_WIN32)
-#include "lldb/Host/windows/ConnectionGenericFileWindows.h"
-#endif
-
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormatAdapters.h"
@@ -56,6 +50,8 @@ using namespace lldb_private;
using namespace lldb_private::python;
using llvm::Expected;
+LLDB_PLUGIN_DEFINE(ScriptInterpreterPython)
+
// Defined in the SWIG source file
#if PY_MAJOR_VERSION >= 3
extern "C" PyObject *PyInit__lldb(void);
@@ -222,10 +218,6 @@ 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();
#ifdef LLDB_USE_LIBEDIT_READLINE_COMPAT_MODULE
@@ -269,20 +261,40 @@ public:
// 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 LLDB_EMBED_PYTHON_HOME
#if PY_MAJOR_VERSION >= 3
- size_t size = 0;
- static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+ typedef wchar_t* str_type;
#else
- static char g_python_home[] = LLDB_PYTHON_HOME;
+ typedef char* str_type;
#endif
- Py_SetPythonHome(g_python_home);
+ static str_type g_python_home = []() -> str_type {
+ const char *lldb_python_home = LLDB_PYTHON_HOME;
+ const char *absolute_python_home = nullptr;
+ llvm::SmallString<64> path;
+ if (llvm::sys::path::is_absolute(lldb_python_home)) {
+ absolute_python_home = lldb_python_home;
+ } else {
+ FileSpec spec = HostInfo::GetShlibDir();
+ if (!spec)
+ return nullptr;
+ spec.GetPath(path);
+ llvm::sys::path::append(path, lldb_python_home);
+ absolute_python_home = path.c_str();
+ }
+#if PY_MAJOR_VERSION >= 3
+ size_t size = 0;
+ return Py_DecodeLocale(absolute_python_home, &size);
+#else
+ return strdup(absolute_python_home);
+#endif
+ }();
+ if (g_python_home != nullptr) {
+ Py_SetPythonHome(g_python_home);
+ }
#else
#if defined(__APPLE__) && PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 7
// For Darwin, the only Python version supported is the one shipped in the
@@ -471,7 +483,7 @@ ScriptInterpreterPythonImpl::ScriptInterpreterPythonImpl(Debugger &debugger)
m_run_one_line_str_global(),
m_dictionary_name(m_debugger.GetInstanceName().AsCString()),
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_pty_secondary_is_open(false), m_valid_session(true), m_lock_count(0),
m_command_thread_state(nullptr) {
InitializePrivate();
@@ -853,7 +865,7 @@ static std::string GenerateUniqueName(const char *base_name_wanted,
else
sstr.Printf("%s_%p", base_name_wanted, name_token);
- return sstr.GetString();
+ return std::string(sstr.GetString());
}
bool ScriptInterpreterPythonImpl::GetEmbeddedInterpreterModuleObjects() {
@@ -877,15 +889,6 @@ bool ScriptInterpreterPythonImpl::GetEmbeddedInterpreterModuleObjects() {
return m_run_one_line_function.IsValid();
}
-static void ReadThreadBytesReceived(void *baton, const void *src,
- size_t src_len) {
- if (src && src_len) {
- Stream *strm = (Stream *)baton;
- strm->Write(src, src_len);
- strm->Flush();
- }
-}
-
bool ScriptInterpreterPythonImpl::ExecuteOneLine(
llvm::StringRef command, CommandReturnObject *result,
const ExecuteScriptOptions &options) {
@@ -901,77 +904,21 @@ bool ScriptInterpreterPythonImpl::ExecuteOneLine(
// another string to pass to PyRun_SimpleString messes up the escaping. So
// we use the following more complicated method to pass the command string
// directly down to Python.
- Debugger &debugger = m_debugger;
-
- FileSP input_file_sp;
- StreamFileSP output_file_sp;
- StreamFileSP error_file_sp;
- Communication output_comm(
- "lldb.ScriptInterpreterPythonImpl.ExecuteOneLine.comm");
- bool join_read_thread = false;
- if (options.GetEnableIO()) {
- if (result) {
- input_file_sp = debugger.GetInputFileSP();
- // Set output to a temporary file so we can forward the results on to
- // the result object
-
- Pipe pipe;
- Status pipe_result = pipe.CreateNew(false);
- if (pipe_result.Success()) {
-#if defined(_WIN32)
- lldb::file_t read_file = pipe.GetReadNativeHandle();
- pipe.ReleaseReadFileDescriptor();
- std::unique_ptr<ConnectionGenericFile> conn_up(
- new ConnectionGenericFile(read_file, true));
-#else
- std::unique_ptr<ConnectionFileDescriptor> conn_up(
- new ConnectionFileDescriptor(pipe.ReleaseReadFileDescriptor(),
- true));
-#endif
- if (conn_up->IsConnected()) {
- output_comm.SetConnection(conn_up.release());
- output_comm.SetReadThreadBytesReceivedCallback(
- ReadThreadBytesReceived, &result->GetOutputStream());
- output_comm.StartReadThread();
- join_read_thread = true;
- FILE *outfile_handle =
- fdopen(pipe.ReleaseWriteFileDescriptor(), "w");
- output_file_sp = std::make_shared<StreamFile>(outfile_handle, true);
- error_file_sp = output_file_sp;
- if (outfile_handle)
- ::setbuf(outfile_handle, nullptr);
-
- result->SetImmediateOutputFile(
- debugger.GetOutputStream().GetFileSP());
- result->SetImmediateErrorFile(
- debugger.GetErrorStream().GetFileSP());
- }
- }
- }
- if (!input_file_sp || !output_file_sp || !error_file_sp)
- debugger.AdoptTopIOHandlerFilesIfInvalid(input_file_sp, output_file_sp,
- error_file_sp);
- } else {
- auto nullin = FileSystem::Instance().Open(
- FileSpec(FileSystem::DEV_NULL),
- File::eOpenOptionRead);
- auto nullout = FileSystem::Instance().Open(
- FileSpec(FileSystem::DEV_NULL),
- File::eOpenOptionWrite);
- if (!nullin) {
- result->AppendErrorWithFormatv("failed to open /dev/null: {0}\n",
- llvm::fmt_consume(nullin.takeError()));
- return false;
- }
- if (!nullout) {
- result->AppendErrorWithFormatv("failed to open /dev/null: {0}\n",
- llvm::fmt_consume(nullout.takeError()));
- return false;
- }
- input_file_sp = std::move(nullin.get());
- error_file_sp = output_file_sp = std::make_shared<StreamFile>(std::move(nullout.get()));
+ llvm::Expected<std::unique_ptr<ScriptInterpreterIORedirect>>
+ io_redirect_or_error = ScriptInterpreterIORedirect::Create(
+ options.GetEnableIO(), m_debugger, result);
+ if (!io_redirect_or_error) {
+ if (result)
+ result->AppendErrorWithFormatv(
+ "failed to redirect I/O: {0}\n",
+ llvm::fmt_consume(io_redirect_or_error.takeError()));
+ else
+ llvm::consumeError(io_redirect_or_error.takeError());
+ return false;
}
+ ScriptInterpreterIORedirect &io_redirect = **io_redirect_or_error;
+
bool success = false;
{
// WARNING! It's imperative that this RAII scope be as tight as
@@ -987,8 +934,9 @@ bool ScriptInterpreterPythonImpl::ExecuteOneLine(
Locker::AcquireLock | Locker::InitSession |
(options.GetSetLLDBGlobals() ? Locker::InitGlobals : 0) |
((result && result->GetInteractive()) ? 0 : Locker::NoSTDIN),
- Locker::FreeAcquiredLock | Locker::TearDownSession, input_file_sp,
- output_file_sp->GetFileSP(), error_file_sp->GetFileSP());
+ Locker::FreeAcquiredLock | Locker::TearDownSession,
+ io_redirect.GetInputFile(), io_redirect.GetOutputFile(),
+ io_redirect.GetErrorFile());
// Find the correct script interpreter dictionary in the main module.
PythonDictionary &session_dict = GetSessionDictionary();
@@ -1014,21 +962,7 @@ bool ScriptInterpreterPythonImpl::ExecuteOneLine(
}
}
- // Flush our output and error file handles
- output_file_sp->Flush();
- error_file_sp->Flush();
- }
-
- if (join_read_thread) {
- // Close the write end of the pipe since we are done with our one line
- // script. This should cause the read thread that output_comm is using to
- // exit
- output_file_sp->GetFile().Close();
- // The close above should cause this thread to exit when it gets to the
- // end of file, so let it get all its data
- output_comm.JoinReadThread();
- // Now we can close the read end of the pipe
- output_comm.Disconnect();
+ io_redirect.Flush();
}
if (success)
@@ -1064,7 +998,7 @@ void ScriptInterpreterPythonImpl::ExecuteInterpreterLoop() {
IOHandlerSP io_handler_sp(new IOHandlerPythonInterpreter(debugger, this));
if (io_handler_sp) {
- debugger.PushIOHandler(io_handler_sp);
+ debugger.RunIOHandlerAsync(io_handler_sp);
}
}
@@ -1343,8 +1277,8 @@ Status ScriptInterpreterPythonImpl::SetBreakpointCommandCallback(
bp_options->SetCallback(
ScriptInterpreterPythonImpl::BreakpointCallbackFunction, baton_sp);
return error;
- } else
- return error;
+ }
+ return error;
}
// Set a Python one-liner as the callback for the watchpoint.
@@ -1970,8 +1904,7 @@ lldb::StateType ScriptInterpreterPythonImpl::ScriptedThreadPlanGetRunState(
}
if (should_step)
return lldb::eStateStepping;
- else
- return lldb::eStateRunning;
+ return lldb::eStateRunning;
}
StructuredData::GenericSP
@@ -2043,8 +1976,7 @@ ScriptInterpreterPythonImpl::ScriptedBreakpointResolverSearchDepth(
if (depth_as_int <= lldb::kLastSearchDepthKind)
return (lldb::SearchDepth)depth_as_int;
- else
- return lldb::eSearchDepthModule;
+ return lldb::eSearchDepthModule;
}
StructuredData::ObjectSP
@@ -2748,6 +2680,7 @@ bool ScriptInterpreterPythonImpl::LoadScriptingModule(
{
FileSpec target_file(pathname);
FileSystem::Instance().Resolve(target_file);
+ FileSystem::Instance().Collect(target_file);
std::string basename(target_file.GetFilename().GetCString());
StreamString command_stream;
@@ -3010,39 +2943,42 @@ bool ScriptInterpreterPythonImpl::RunScriptBasedCommand(
return ret_val;
}
-// in Python, a special attribute __doc__ contains the docstring for an object
-// (function, method, class, ...) if any is defined Otherwise, the attribute's
-// value is None
+/// In Python, a special attribute __doc__ contains the docstring for an object
+/// (function, method, class, ...) if any is defined Otherwise, the attribute's
+/// value is None.
bool ScriptInterpreterPythonImpl::GetDocumentationForItem(const char *item,
std::string &dest) {
dest.clear();
+
if (!item || !*item)
return false;
+
std::string command(item);
command += ".__doc__";
- char *result_ptr = nullptr; // Python is going to point this to valid data if
- // ExecuteOneLineWithReturn returns successfully
+ // Python is going to point this to valid data if ExecuteOneLineWithReturn
+ // returns successfully.
+ char *result_ptr = nullptr;
if (ExecuteOneLineWithReturn(
- command.c_str(), ScriptInterpreter::eScriptReturnTypeCharStrOrNone,
+ command, ScriptInterpreter::eScriptReturnTypeCharStrOrNone,
&result_ptr,
ScriptInterpreter::ExecuteScriptOptions().SetEnableIO(false))) {
if (result_ptr)
dest.assign(result_ptr);
return true;
- } else {
- StreamString str_stream;
- str_stream.Printf(
- "Function %s was not found. Containing module might be missing.", item);
- dest = str_stream.GetString();
- return false;
}
+
+ StreamString str_stream;
+ str_stream << "Function " << item
+ << " was not found. Containing module might be missing.";
+ dest = std::string(str_stream.GetString());
+
+ return false;
}
bool ScriptInterpreterPythonImpl::GetShortHelpForCommandObject(
StructuredData::GenericSP cmd_obj_sp, std::string &dest) {
- bool got_string = false;
dest.clear();
Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock);
@@ -3076,12 +3012,12 @@ bool ScriptInterpreterPythonImpl::GetShortHelpForCommandObject(
if (PyErr_Occurred())
PyErr_Clear();
- // right now we know this function exists and is callable..
+ // Right now we know this function exists and is callable.
PythonObject py_return(
PyRefType::Owned,
PyObject_CallMethod(implementor.get(), callee_name, nullptr));
- // if it fails, print the error but otherwise go on
+ // If it fails, print the error but otherwise go on.
if (PyErr_Occurred()) {
PyErr_Print();
PyErr_Clear();
@@ -3091,9 +3027,10 @@ bool ScriptInterpreterPythonImpl::GetShortHelpForCommandObject(
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;
+ return true;
}
- return got_string;
+
+ return false;
}
uint32_t ScriptInterpreterPythonImpl::GetFlagsForCommandObject(
@@ -3131,20 +3068,15 @@ uint32_t ScriptInterpreterPythonImpl::GetFlagsForCommandObject(
if (PyErr_Occurred())
PyErr_Clear();
- // right now we know this function exists and is callable..
- PythonObject py_return(
- PyRefType::Owned,
- PyObject_CallMethod(implementor.get(), callee_name, nullptr));
+ long long py_return = unwrapOrSetPythonException(
+ As<long long>(implementor.CallMethod(callee_name)));
// if it fails, print the error but otherwise go on
if (PyErr_Occurred()) {
PyErr_Print();
PyErr_Clear();
- }
-
- if (py_return.IsAllocated() && PythonInteger::Check(py_return.get())) {
- PythonInteger int_value(PyRefType::Borrowed, py_return.get());
- result = int_value.GetInteger();
+ } else {
+ result = py_return;
}
return result;
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
index 1fa198b07e54..22b2c8152eac 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -395,7 +395,7 @@ public:
std::string m_dictionary_name;
ActiveIOHandler m_active_io_handler;
bool m_session_is_active;
- bool m_pty_slave_is_open;
+ bool m_pty_secondary_is_open;
bool m_valid_session;
uint32_t m_lock_count;
PyThreadState *m_command_thread_state;
diff --git a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
index c6b234baa8c8..5ceaf886b812 100644
--- a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
+++ b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
@@ -1,4 +1,4 @@
-//===-- StructuredDataDarwinLog.cpp -----------------------------*- C++ -*-===//
+//===-- StructuredDataDarwinLog.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -36,6 +36,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(StructuredDataDarwinLog)
+
#pragma mark -
#pragma mark Anonymous Namespace
@@ -706,9 +708,9 @@ private:
attribute_end_pos + 1, operation_end_pos - (attribute_end_pos + 1));
// add filter spec
- auto rule_sp =
- FilterRule::CreateRule(accept, attribute_index, ConstString(operation),
- rule_text.substr(operation_end_pos + 1), error);
+ auto rule_sp = FilterRule::CreateRule(
+ accept, attribute_index, ConstString(operation),
+ std::string(rule_text.substr(operation_end_pos + 1)), error);
if (rule_sp && error.Success())
m_filter_rules.push_back(rule_sp);
@@ -979,7 +981,7 @@ EnableOptionsSP ParseAutoEnableOptions(Status &error, Debugger &debugger) {
EnableOptionsSP options_sp(new EnableOptions());
options_sp->NotifyOptionParsingStarting(&exe_ctx);
- CommandReturnObject result;
+ CommandReturnObject result(debugger.GetUseColor());
// Parse the arguments.
auto options_property_sp =
@@ -1034,7 +1036,7 @@ bool RunEnableCommand(CommandInterpreter &interpreter) {
}
// Run the command.
- CommandReturnObject return_object;
+ CommandReturnObject return_object(interpreter.GetDebugger().GetUseColor());
interpreter.HandleCommand(command_stream.GetData(), eLazyBoolNo,
return_object);
return return_object.Succeeded();
diff --git a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h
index 8fa1eed66efb..caa94af1f30e 100644
--- a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h
+++ b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef StructuredDataDarwinLog_h
-#define StructuredDataDarwinLog_h
+#ifndef LLDB_SOURCE_PLUGINS_STRUCTUREDDATA_DARWINLOG_STRUCTUREDDATADARWINLOG_H
+#define LLDB_SOURCE_PLUGINS_STRUCTUREDDATA_DARWINLOG_STRUCTUREDDATADARWINLOG_H
#include "lldb/Target/StructuredDataPlugin.h"
@@ -34,7 +34,7 @@ public:
/// Return whether the DarwinLog functionality is enabled.
///
- /// The DarwinLog functionality is enabled if the user expicitly enabled
+ /// The DarwinLog functionality is enabled if the user explicitly enabled
/// it with the enable command, or if the user has the setting set
/// that controls if we always enable it for newly created/attached
/// processes.
@@ -115,4 +115,4 @@ private:
};
}
-#endif /* StructuredDataPluginDarwinLog_hpp */
+#endif // LLDB_SOURCE_PLUGINS_STRUCTUREDDATA_DARWINLOG_STRUCTUREDDATADARWINLOG_H
diff --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
index b2c4d0883341..eeec7296747e 100644
--- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -1,4 +1,4 @@
-//===-- SymbolFileBreakpad.cpp ----------------------------------*- C++ -*-===//
+//===-- SymbolFileBreakpad.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -25,6 +25,8 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::breakpad;
+LLDB_PLUGIN_DEFINE(SymbolFileBreakpad)
+
char SymbolFileBreakpad::ID;
class SymbolFileBreakpad::LineIterator {
@@ -292,7 +294,7 @@ uint32_t SymbolFileBreakpad::ResolveSymbolContext(
}
void SymbolFileBreakpad::FindFunctions(
- ConstString name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext &parent_decl_ctx,
FunctionNameType name_type_mask, bool include_inlines,
SymbolContextList &sc_list) {
// TODO
@@ -305,7 +307,7 @@ void SymbolFileBreakpad::FindFunctions(const RegularExpression &regex,
}
void SymbolFileBreakpad::FindTypes(
- ConstString name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files,
TypeMap &types) {}
@@ -406,20 +408,25 @@ GetRule(llvm::StringRef &unwind_rules) {
}
static const RegisterInfo *
-ResolveRegister(const SymbolFile::RegisterInfoResolver &resolver,
+ResolveRegister(const llvm::Triple &triple,
+ const SymbolFile::RegisterInfoResolver &resolver,
llvm::StringRef name) {
- if (name.consume_front("$"))
- return resolver.ResolveName(name);
-
- return nullptr;
+ if (triple.isX86() || triple.isMIPS()) {
+ // X86 and MIPS registers have '$' in front of their register names. Arm and
+ // AArch64 don't.
+ if (!name.consume_front("$"))
+ return nullptr;
+ }
+ return resolver.ResolveName(name);
}
static const RegisterInfo *
-ResolveRegisterOrRA(const SymbolFile::RegisterInfoResolver &resolver,
+ResolveRegisterOrRA(const llvm::Triple &triple,
+ const SymbolFile::RegisterInfoResolver &resolver,
llvm::StringRef name) {
if (name == ".ra")
return resolver.ResolveNumber(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
- return ResolveRegister(resolver, name);
+ return ResolveRegister(triple, resolver, name);
}
llvm::ArrayRef<uint8_t> SymbolFileBreakpad::SaveAsDWARF(postfix::Node &node) {
@@ -438,6 +445,7 @@ bool SymbolFileBreakpad::ParseCFIUnwindRow(llvm::StringRef unwind_rules,
Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS);
llvm::BumpPtrAllocator node_alloc;
+ llvm::Triple triple = m_objfile_sp->GetArchitecture().GetTriple();
while (auto rule = GetRule(unwind_rules)) {
node_alloc.Reset();
llvm::StringRef lhs = rule->first;
@@ -453,7 +461,8 @@ bool SymbolFileBreakpad::ParseCFIUnwindRow(llvm::StringRef unwind_rules,
if (name == ".cfa" && lhs != ".cfa")
return postfix::MakeNode<postfix::InitialValueNode>(node_alloc);
- if (const RegisterInfo *info = ResolveRegister(resolver, name)) {
+ if (const RegisterInfo *info =
+ ResolveRegister(triple, resolver, name)) {
return postfix::MakeNode<postfix::RegisterNode>(
node_alloc, info->kinds[eRegisterKindLLDB]);
}
@@ -468,7 +477,8 @@ bool SymbolFileBreakpad::ParseCFIUnwindRow(llvm::StringRef unwind_rules,
llvm::ArrayRef<uint8_t> saved = SaveAsDWARF(*rhs);
if (lhs == ".cfa") {
row.GetCFAValue().SetIsDWARFExpression(saved.data(), saved.size());
- } else if (const RegisterInfo *info = ResolveRegisterOrRA(resolver, lhs)) {
+ } else if (const RegisterInfo *info =
+ ResolveRegisterOrRA(triple, resolver, lhs)) {
UnwindPlan::Row::RegisterLocation loc;
loc.SetIsDWARFExpression(saved.data(), saved.size());
row.SetRegisterInfo(info->kinds[eRegisterKindLLDB], loc);
@@ -572,6 +582,7 @@ SymbolFileBreakpad::ParseWinUnwindPlan(const Bookmark &bookmark,
return nullptr;
}
auto it = program.begin();
+ llvm::Triple triple = m_objfile_sp->GetArchitecture().GetTriple();
const auto &symbol_resolver =
[&](postfix::SymbolNode &symbol) -> postfix::Node * {
llvm::StringRef name = symbol.GetName();
@@ -579,7 +590,7 @@ SymbolFileBreakpad::ParseWinUnwindPlan(const Bookmark &bookmark,
if (rule.first == name)
return rule.second;
}
- if (const RegisterInfo *info = ResolveRegister(resolver, name))
+ if (const RegisterInfo *info = ResolveRegister(triple, resolver, name))
return postfix::MakeNode<postfix::RegisterNode>(
node_alloc, info->kinds[eRegisterKindLLDB]);
return nullptr;
@@ -609,7 +620,7 @@ SymbolFileBreakpad::ParseWinUnwindPlan(const Bookmark &bookmark,
// Now process the rest of the assignments.
for (++it; it != program.end(); ++it) {
- const RegisterInfo *info = ResolveRegister(resolver, it->first);
+ const RegisterInfo *info = ResolveRegister(triple, resolver, it->first);
// It is not an error if the resolution fails because the program may
// contain temporary variables.
if (!info)
@@ -694,18 +705,18 @@ void SymbolFileBreakpad::ParseLineTableAndSupportFiles(CompileUnit &cu,
"How did we create compile units without a base address?");
SupportFileMap map;
- data.line_table_up = std::make_unique<LineTable>(&cu);
- std::unique_ptr<LineSequence> line_seq_up(
- data.line_table_up->CreateLineSequenceContainer());
+ std::vector<std::unique_ptr<LineSequence>> sequences;
+ std::unique_ptr<LineSequence> line_seq_up =
+ LineTable::CreateLineSequenceContainer();
llvm::Optional<addr_t> next_addr;
auto finish_sequence = [&]() {
- data.line_table_up->AppendLineEntryToSequence(
+ LineTable::AppendLineEntryToSequence(
line_seq_up.get(), *next_addr, /*line*/ 0, /*column*/ 0,
/*file_idx*/ 0, /*is_start_of_statement*/ false,
/*is_start_of_basic_block*/ false, /*is_prologue_end*/ false,
/*is_epilogue_begin*/ false, /*is_terminal_entry*/ true);
- data.line_table_up->InsertSequence(line_seq_up.get());
- line_seq_up->Clear();
+ sequences.push_back(std::move(line_seq_up));
+ line_seq_up = LineTable::CreateLineSequenceContainer();
};
LineIterator It(*m_objfile_sp, Record::Func, data.bookmark),
@@ -722,7 +733,7 @@ void SymbolFileBreakpad::ParseLineTableAndSupportFiles(CompileUnit &cu,
// Discontiguous entries. Finish off the previous sequence and reset.
finish_sequence();
}
- data.line_table_up->AppendLineEntryToSequence(
+ LineTable::AppendLineEntryToSequence(
line_seq_up.get(), record->Address, record->LineNum, /*column*/ 0,
map[record->FileNum], /*is_start_of_statement*/ true,
/*is_start_of_basic_block*/ false, /*is_prologue_end*/ false,
@@ -731,6 +742,7 @@ void SymbolFileBreakpad::ParseLineTableAndSupportFiles(CompileUnit &cu,
}
if (next_addr)
finish_sequence();
+ data.line_table_up = std::make_unique<LineTable>(&cu, std::move(sequences));
data.support_files = map.translate(cu.GetPrimaryFile(), *m_files);
}
diff --git a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
index de271224a65d..90dbcc77627a 100644
--- a/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
+++ b/lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_PLUGINS_SYMBOLFILE_BREAKPAD_SYMBOLFILEBREAKPAD_H
-#define LLDB_PLUGINS_SYMBOLFILE_BREAKPAD_SYMBOLFILEBREAKPAD_H
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_BREAKPAD_SYMBOLFILEBREAKPAD_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_BREAKPAD_SYMBOLFILEBREAKPAD_H
#include "Plugins/ObjectFile/Breakpad/BreakpadRecords.h"
#include "lldb/Core/FileSpecList.h"
@@ -82,7 +82,7 @@ public:
size_t ParseBlocksRecursive(Function &func) override { return 0; }
void FindGlobalVariables(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
+ const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
VariableList &variables) override {}
@@ -110,14 +110,14 @@ public:
TypeList &type_list) override {}
void FindFunctions(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
+ const CompilerDeclContext &parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines, SymbolContextList &sc_list) override;
void FindFunctions(const RegularExpression &regex, bool include_inlines,
SymbolContextList &sc_list) override;
- void FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx,
+ void FindTypes(ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<SymbolFile *> &searched_symbol_files,
TypeMap &types) override;
@@ -135,7 +135,7 @@ public:
CompilerDeclContext
FindNamespace(ConstString name,
- const CompilerDeclContext *parent_decl_ctx) override {
+ const CompilerDeclContext &parent_decl_ctx) override {
return CompilerDeclContext();
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
index 0a5073b8cd9e..33ab11a3ca40 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -1,4 +1,4 @@
-//===-- AppleDWARFIndex.cpp ------------------------------------*- C++ -*-===//
+//===-- AppleDWARFIndex.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -52,54 +52,70 @@ std::unique_ptr<AppleDWARFIndex> AppleDWARFIndex::Create(
return nullptr;
}
-void AppleDWARFIndex::GetGlobalVariables(ConstString basename, DIEArray &offsets) {
- if (m_apple_names_up)
- m_apple_names_up->FindByName(basename.GetStringRef(), offsets);
+void AppleDWARFIndex::GetGlobalVariables(
+ ConstString basename, llvm::function_ref<bool(DWARFDIE die)> callback) {
+ if (!m_apple_names_up)
+ return;
+ m_apple_names_up->FindByName(
+ basename.GetStringRef(),
+ DIERefCallback(callback, basename.GetStringRef()));
}
-void AppleDWARFIndex::GetGlobalVariables(const RegularExpression &regex,
- DIEArray &offsets) {
+void AppleDWARFIndex::GetGlobalVariables(
+ const RegularExpression &regex,
+ llvm::function_ref<bool(DWARFDIE die)> callback) {
if (!m_apple_names_up)
return;
DWARFMappedHash::DIEInfoArray hash_data;
- if (m_apple_names_up->AppendAllDIEsThatMatchingRegex(regex, hash_data))
- DWARFMappedHash::ExtractDIEArray(hash_data, offsets);
+ m_apple_names_up->AppendAllDIEsThatMatchingRegex(regex, hash_data);
+ // This is not really the DIE name.
+ DWARFMappedHash::ExtractDIEArray(hash_data,
+ DIERefCallback(callback, regex.GetText()));
}
-void AppleDWARFIndex::GetGlobalVariables(const DWARFUnit &cu,
- DIEArray &offsets) {
+void AppleDWARFIndex::GetGlobalVariables(
+ const DWARFUnit &cu, llvm::function_ref<bool(DWARFDIE die)> callback) {
if (!m_apple_names_up)
return;
DWARFMappedHash::DIEInfoArray hash_data;
- if (m_apple_names_up->AppendAllDIEsInRange(cu.GetOffset(),
- cu.GetNextUnitOffset(), hash_data))
- DWARFMappedHash::ExtractDIEArray(hash_data, offsets);
+ m_apple_names_up->AppendAllDIEsInRange(cu.GetOffset(), cu.GetNextUnitOffset(),
+ hash_data);
+ DWARFMappedHash::ExtractDIEArray(hash_data, DIERefCallback(callback));
}
-void AppleDWARFIndex::GetObjCMethods(ConstString class_name,
- DIEArray &offsets) {
- if (m_apple_objc_up)
- m_apple_objc_up->FindByName(class_name.GetStringRef(), offsets);
+void AppleDWARFIndex::GetObjCMethods(
+ ConstString class_name, llvm::function_ref<bool(DWARFDIE die)> callback) {
+ if (!m_apple_objc_up)
+ return;
+ m_apple_objc_up->FindByName(
+ class_name.GetStringRef(),
+ DIERefCallback(callback, class_name.GetStringRef()));
}
-void AppleDWARFIndex::GetCompleteObjCClass(ConstString class_name,
- bool must_be_implementation,
- DIEArray &offsets) {
- if (m_apple_types_up) {
- m_apple_types_up->FindCompleteObjCClassByName(
- class_name.GetStringRef(), offsets, must_be_implementation);
- }
+void AppleDWARFIndex::GetCompleteObjCClass(
+ ConstString class_name, bool must_be_implementation,
+ llvm::function_ref<bool(DWARFDIE die)> callback) {
+ if (!m_apple_types_up)
+ return;
+ m_apple_types_up->FindCompleteObjCClassByName(
+ class_name.GetStringRef(),
+ DIERefCallback(callback, class_name.GetStringRef()),
+ must_be_implementation);
}
-void AppleDWARFIndex::GetTypes(ConstString name, DIEArray &offsets) {
- if (m_apple_types_up)
- m_apple_types_up->FindByName(name.GetStringRef(), offsets);
+void AppleDWARFIndex::GetTypes(
+ ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) {
+ if (!m_apple_types_up)
+ return;
+ m_apple_types_up->FindByName(name.GetStringRef(),
+ DIERefCallback(callback, name.GetStringRef()));
}
-void AppleDWARFIndex::GetTypes(const DWARFDeclContext &context,
- DIEArray &offsets) {
+void AppleDWARFIndex::GetTypes(
+ const DWARFDeclContext &context,
+ llvm::function_ref<bool(DWARFDIE die)> callback) {
if (!m_apple_types_up)
return;
@@ -119,7 +135,8 @@ void AppleDWARFIndex::GetTypes(const DWARFDeclContext &context,
if (log)
m_module.LogMessage(log, "FindByNameAndTagAndQualifiedNameHash()");
m_apple_types_up->FindByNameAndTagAndQualifiedNameHash(
- type_name.GetStringRef(), tag, qualified_name_hash, offsets);
+ type_name.GetStringRef(), tag, qualified_name_hash,
+ DIERefCallback(callback, type_name.GetStringRef()));
return;
}
@@ -133,54 +150,52 @@ void AppleDWARFIndex::GetTypes(const DWARFDeclContext &context,
if (!has_qualified_name_hash && (context.GetSize() > 1) &&
(context[1].tag == DW_TAG_class_type ||
context[1].tag == DW_TAG_structure_type)) {
- DIEArray class_matches;
- m_apple_types_up->FindByName(context[1].name, class_matches);
- if (class_matches.empty())
+ if (m_apple_types_up->FindByName(context[1].name,
+ [&](DIERef ref) { return false; }))
return;
}
if (log)
m_module.LogMessage(log, "FindByNameAndTag()");
- m_apple_types_up->FindByNameAndTag(type_name.GetStringRef(), tag, offsets);
+ m_apple_types_up->FindByNameAndTag(
+ type_name.GetStringRef(), tag,
+ DIERefCallback(callback, type_name.GetStringRef()));
return;
}
- m_apple_types_up->FindByName(type_name.GetStringRef(), offsets);
+ m_apple_types_up->FindByName(
+ type_name.GetStringRef(),
+ DIERefCallback(callback, type_name.GetStringRef()));
}
-void AppleDWARFIndex::GetNamespaces(ConstString name, DIEArray &offsets) {
- if (m_apple_namespaces_up)
- m_apple_namespaces_up->FindByName(name.GetStringRef(), offsets);
+void AppleDWARFIndex::GetNamespaces(
+ ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) {
+ if (!m_apple_namespaces_up)
+ return;
+ m_apple_namespaces_up->FindByName(
+ name.GetStringRef(), DIERefCallback(callback, name.GetStringRef()));
}
-void AppleDWARFIndex::GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
- const CompilerDeclContext &parent_decl_ctx,
- uint32_t name_type_mask,
- std::vector<DWARFDIE> &dies) {
- DIEArray offsets;
- m_apple_names_up->FindByName(name.GetStringRef(), offsets);
- for (const DIERef &die_ref : offsets) {
- ProcessFunctionDIE(name.GetStringRef(), die_ref, dwarf, parent_decl_ctx,
- name_type_mask, dies);
- }
+void AppleDWARFIndex::GetFunctions(
+ ConstString name, SymbolFileDWARF &dwarf,
+ const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask,
+ llvm::function_ref<bool(DWARFDIE die)> callback) {
+ m_apple_names_up->FindByName(name.GetStringRef(), [&](DIERef die_ref) {
+ return ProcessFunctionDIE(name.GetStringRef(), die_ref, dwarf,
+ parent_decl_ctx, name_type_mask, callback);
+ });
}
-void AppleDWARFIndex::GetFunctions(const RegularExpression &regex,
- DIEArray &offsets) {
+void AppleDWARFIndex::GetFunctions(
+ const RegularExpression &regex,
+ llvm::function_ref<bool(DWARFDIE die)> callback) {
if (!m_apple_names_up)
return;
DWARFMappedHash::DIEInfoArray hash_data;
- if (m_apple_names_up->AppendAllDIEsThatMatchingRegex(regex, hash_data))
- DWARFMappedHash::ExtractDIEArray(hash_data, offsets);
-}
-
-void AppleDWARFIndex::ReportInvalidDIERef(const DIERef &ref,
- llvm::StringRef name) {
- m_module.ReportErrorIfModifyDetected(
- "the DWARF debug information has been modified (accelerator table had "
- "bad die 0x%8.8x for '%s')\n",
- ref.die_offset(), name.str().c_str());
+ m_apple_names_up->AppendAllDIEsThatMatchingRegex(regex, hash_data);
+ DWARFMappedHash::ExtractDIEArray(hash_data,
+ DIERefCallback(callback, regex.GetText()));
}
void AppleDWARFIndex::Dump(Stream &s) {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
index d15d61e270b3..a7032f50e590 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_APPLEDWARFINDEX_H
-#define LLDB_APPLEDWARFINDEX_H
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_APPLEDWARFINDEX_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_APPLEDWARFINDEX_H
#include "Plugins/SymbolFile/DWARF/DWARFIndex.h"
#include "Plugins/SymbolFile/DWARF/HashedNameToDIE.h"
@@ -32,23 +32,33 @@ public:
void Preload() override {}
- void GetGlobalVariables(ConstString basename, DIEArray &offsets) override;
- void GetGlobalVariables(const RegularExpression &regex,
- DIEArray &offsets) override;
- void GetGlobalVariables(const DWARFUnit &cu, DIEArray &offsets) override;
- void GetObjCMethods(ConstString class_name, DIEArray &offsets) override;
- void GetCompleteObjCClass(ConstString class_name, bool must_be_implementation,
- DIEArray &offsets) override;
- void GetTypes(ConstString name, DIEArray &offsets) override;
- void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override;
- void GetNamespaces(ConstString name, DIEArray &offsets) override;
+ void
+ GetGlobalVariables(ConstString basename,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void
+ GetGlobalVariables(const RegularExpression &regex,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void
+ GetGlobalVariables(const DWARFUnit &cu,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetObjCMethods(ConstString class_name,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetCompleteObjCClass(
+ ConstString class_name, bool must_be_implementation,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetTypes(ConstString name,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetTypes(const DWARFDeclContext &context,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetNamespaces(ConstString name,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
void GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
uint32_t name_type_mask,
- std::vector<DWARFDIE> &dies) override;
- void GetFunctions(const RegularExpression &regex, DIEArray &offsets) override;
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetFunctions(const RegularExpression &regex,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
- void ReportInvalidDIERef(const DIERef &ref, llvm::StringRef name) override;
void Dump(Stream &s) override;
private:
@@ -59,4 +69,4 @@ private:
};
} // namespace lldb_private
-#endif // LLDB_APPLEDWARFINDEX_H
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_APPLEDWARFINDEX_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp
index f7f2a5bf006b..7a8ab9c9bcfd 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp
@@ -1,4 +1,4 @@
-//===-- DIERef.cpp ----------------------------------------------*- C++ -*-===//
+//===-- DIERef.cpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
index 5546bb7e8b86..f7e09ee17283 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_DIERef_h_
-#define SymbolFileDWARF_DIERef_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DIEREF_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DIEREF_H
#include "lldb/Core/dwarf.h"
#include "llvm/ADT/Optional.h"
@@ -44,6 +44,16 @@ public:
dw_offset_t die_offset() const { return m_die_offset; }
+ bool operator<(DIERef other) const {
+ if (m_dwo_num_valid != other.m_dwo_num_valid)
+ return m_dwo_num_valid < other.m_dwo_num_valid;
+ if (m_dwo_num_valid && (m_dwo_num != other.m_dwo_num))
+ return m_dwo_num < other.m_dwo_num;
+ if (m_section != other.m_section)
+ return m_section < other.m_section;
+ return m_die_offset < other.m_die_offset;
+ }
+
private:
uint32_t m_dwo_num : 30;
uint32_t m_dwo_num_valid : 1;
@@ -60,4 +70,4 @@ template<> struct format_provider<DIERef> {
};
} // namespace llvm
-#endif // SymbolFileDWARF_DIERef_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DIEREF_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
index 7ee4727cde91..2e0a7fd3ecd3 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_DWARFASTParser_h_
-#define SymbolFileDWARF_DWARFASTParser_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSER_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSER_H
#include "DWARFDefines.h"
#include "lldb/Core/PluginInterface.h"
@@ -55,4 +55,4 @@ public:
const lldb_private::ExecutionContext *exe_ctx = nullptr);
};
-#endif // SymbolFileDWARF_DWARFASTParser_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSER_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 232063a6f339..2d1db66e7fd9 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFASTParserClang.cpp ---------------------------------*- C++ -*-===//
+//===-- DWARFASTParserClang.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -13,17 +13,17 @@
#include "DWARFDeclContext.h"
#include "DWARFDefines.h"
#include "SymbolFileDWARF.h"
-#include "SymbolFileDWARFDwo.h"
#include "SymbolFileDWARFDebugMap.h"
+#include "SymbolFileDWARFDwo.h"
#include "UniqueDWARFASTType.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
#include "Plugins/Language/ObjC/ObjCLanguage.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Value.h"
#include "lldb/Host/Host.h"
-#include "lldb/Symbol/ClangASTImporter.h"
-#include "lldb/Symbol/ClangASTMetadata.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -35,6 +35,8 @@
#include "lldb/Utility/Log.h"
#include "lldb/Utility/StreamString.h"
+#include "llvm/Demangle/Demangle.h"
+
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
@@ -55,7 +57,7 @@
using namespace lldb;
using namespace lldb_private;
-DWARFASTParserClang::DWARFASTParserClang(ClangASTContext &ast)
+DWARFASTParserClang::DWARFASTParserClang(TypeSystemClang &ast)
: m_ast(ast), m_die_to_decl_ctx(), m_decl_ctx_to_die() {}
DWARFASTParserClang::~DWARFASTParserClang() {}
@@ -85,39 +87,10 @@ static bool DeclKindIsCXXClass(clang::Decl::Kind decl_kind) {
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() const {
- return (bit_size != LLDB_INVALID_ADDRESS) &&
- (bit_offset != LLDB_INVALID_ADDRESS);
- }
-
- bool NextBitfieldOffsetIsValid(const uint64_t next_bit_offset) const {
- if (IsValid()) {
- // This bitfield info is valid, so any subsequent bitfields must not
- // overlap and must be at a higher bit offset than any previous bitfield
- // + size.
- return (bit_size + bit_offset) <= next_bit_offset;
- } else {
- // If the this BitfieldInfo is not valid, then any offset isOK
- return true;
- }
- }
-};
ClangASTImporter &DWARFASTParserClang::GetClangASTImporter() {
if (!m_clang_ast_importer_up) {
- m_clang_ast_importer_up.reset(new ClangASTImporter);
+ m_clang_ast_importer_up = std::make_unique<ClangASTImporter>();
}
return *m_clang_ast_importer_up;
}
@@ -184,7 +157,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc,
// The type in the Clang module must have the same language as the current CU.
LanguageSet languages;
- languages.Insert(die.GetCU()->GetLanguageType());
+ languages.Insert(SymbolFileDWARF::GetLanguage(*die.GetCU()));
llvm::DenseSet<SymbolFile *> searched_symbol_files;
clang_module_sp->GetSymbolFile()->FindTypes(decl_context, languages,
searched_symbol_files, pcm_types);
@@ -239,14 +212,15 @@ TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc,
TypeSP type_sp(new Type(
die.GetID(), dwarf, pcm_type_sp->GetName(), pcm_type_sp->GetByteSize(),
nullptr, LLDB_INVALID_UID, Type::eEncodingInvalid,
- &pcm_type_sp->GetDeclaration(), type, Type::ResolveState::Forward));
+ &pcm_type_sp->GetDeclaration(), type, Type::ResolveState::Forward,
+ TypePayloadClang(GetOwningClangModule(die))));
dwarf->GetTypeList().Insert(type_sp);
dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
- clang::TagDecl *tag_decl = ClangASTContext::GetAsTagDecl(type);
- if (tag_decl)
+ clang::TagDecl *tag_decl = TypeSystemClang::GetAsTagDecl(type);
+ if (tag_decl) {
LinkDeclContextToDIE(tag_decl, die);
- else {
+ } else {
clang::DeclContext *defn_decl_ctx = GetCachedClangDeclContextForDIE(die);
if (defn_decl_ctx)
LinkDeclContextToDIE(defn_decl_ctx, die);
@@ -255,7 +229,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const SymbolContext &sc,
return type_sp;
}
-static void CompleteExternalTagDeclType(ClangASTContext &ast,
+static void CompleteExternalTagDeclType(TypeSystemClang &ast,
ClangASTImporter &ast_importer,
clang::DeclContext *decl_ctx,
DWARFDIE die,
@@ -277,8 +251,8 @@ static void CompleteExternalTagDeclType(ClangASTContext &ast,
type_name_cstr ? type_name_cstr : "", die.GetOffset());
// We need to make the type look complete otherwise, we might crash in
// Clang when adding children.
- if (ClangASTContext::StartTagDeclarationDefinition(type))
- ClangASTContext::CompleteTagDeclarationDefinition(type);
+ if (TypeSystemClang::StartTagDeclarationDefinition(type))
+ TypeSystemClang::CompleteTagDeclarationDefinition(type);
}
}
@@ -533,7 +507,7 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext &sc,
DWARF_LOG_LOOKUPS));
SymbolFileDWARF *dwarf = die.GetDWARF();
const dw_tag_t tag = die.Tag();
- LanguageType cu_language = die.GetLanguage();
+ LanguageType cu_language = SymbolFileDWARF::GetLanguage(*die.GetCU());
Type::ResolveState resolve_state = Type::ResolveState::Unresolved;
Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID;
TypeSP type_sp;
@@ -735,7 +709,7 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext &sc,
type_sp = std::make_shared<Type>(
die.GetID(), dwarf, attrs.name, attrs.byte_size, nullptr,
dwarf->GetUID(attrs.type.Reference()), encoding_data_type, &attrs.decl,
- clang_type, resolve_state);
+ clang_type, resolve_state, TypePayloadClang(GetOwningClangModule(die)));
dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
return type_sp;
@@ -755,8 +729,7 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc,
if (type_sp)
return type_sp;
- DWARFDeclContext die_decl_ctx;
- die.GetDWARFDeclContext(die_decl_ctx);
+ DWARFDeclContext die_decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
@@ -818,27 +791,28 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc,
clang_type = m_ast.CreateEnumerationType(
attrs.name.GetCString(), GetClangDeclContextContainingDIE(die, nullptr),
- attrs.decl, enumerator_clang_type, attrs.is_scoped_enum);
+ GetOwningClangModule(die), attrs.decl, enumerator_clang_type,
+ attrs.is_scoped_enum);
} else {
- enumerator_clang_type =
- m_ast.GetEnumerationIntegerType(clang_type.GetOpaqueQualType());
+ enumerator_clang_type = m_ast.GetEnumerationIntegerType(clang_type);
}
- LinkDeclContextToDIE(ClangASTContext::GetDeclContextForType(clang_type), die);
+ LinkDeclContextToDIE(TypeSystemClang::GetDeclContextForType(clang_type), die);
type_sp = std::make_shared<Type>(
die.GetID(), dwarf, attrs.name, attrs.byte_size, nullptr,
dwarf->GetUID(attrs.type.Reference()), Type::eEncodingIsUID, &attrs.decl,
- clang_type, Type::ResolveState::Forward);
+ clang_type, Type::ResolveState::Forward,
+ TypePayloadClang(GetOwningClangModule(die)));
- if (ClangASTContext::StartTagDeclarationDefinition(clang_type)) {
+ if (TypeSystemClang::StartTagDeclarationDefinition(clang_type)) {
if (die.HasChildren()) {
bool is_signed = false;
enumerator_clang_type.IsIntegerType(is_signed);
ParseChildEnumerators(clang_type, is_signed,
type_sp->GetByteSize().getValueOr(0), die);
}
- ClangASTContext::CompleteTagDeclarationDefinition(clang_type);
+ TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
} else {
dwarf->GetObjectFile()->GetModule()->ReportError(
"DWARF DIE at 0x%8.8x named \"%s\" was not able to start its "
@@ -948,7 +922,7 @@ TypeSP DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die,
if (complete_objc_class_type_sp) {
CompilerType type_clang_forward_type =
complete_objc_class_type_sp->GetForwardCompilerType();
- if (ClangASTContext::IsObjCObjectOrInterfaceType(
+ if (TypeSystemClang::IsObjCObjectOrInterfaceType(
type_clang_forward_type))
class_opaque_type = type_clang_forward_type;
}
@@ -1053,7 +1027,7 @@ TypeSP DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die,
} else {
CompilerType class_opaque_type =
class_type->GetForwardCompilerType();
- if (ClangASTContext::IsCXXClassType(class_opaque_type)) {
+ if (TypeSystemClang::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
@@ -1198,27 +1172,38 @@ TypeSP DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die,
}
if (!function_decl) {
+ const char *name = attrs.name.GetCString();
+
+ // We currently generate function templates with template parameters in
+ // their name. In order to get closer to the AST that clang generates
+ // we want to strip these from the name when creating the AST.
+ if (attrs.mangled_name) {
+ llvm::ItaniumPartialDemangler D;
+ if (!D.partialDemangle(attrs.mangled_name))
+ name = D.getFunctionBaseName(nullptr, nullptr);
+ }
+
// We just have a function that isn't part of a class
function_decl = m_ast.CreateFunctionDeclaration(
ignore_containing_context ? m_ast.GetTranslationUnitDecl()
: containing_decl_ctx,
- attrs.name.GetCString(), clang_type, attrs.storage,
+ GetOwningClangModule(die), name, clang_type, attrs.storage,
attrs.is_inline);
if (has_template_params) {
- ClangASTContext::TemplateParameterInfos template_param_infos;
+ TypeSystemClang::TemplateParameterInfos template_param_infos;
ParseTemplateParameterInfos(die, template_param_infos);
template_function_decl = m_ast.CreateFunctionDeclaration(
ignore_containing_context ? m_ast.GetTranslationUnitDecl()
: containing_decl_ctx,
- attrs.name.GetCString(), clang_type, attrs.storage,
- attrs.is_inline);
+ GetOwningClangModule(die), attrs.name.GetCString(), clang_type,
+ attrs.storage, attrs.is_inline);
clang::FunctionTemplateDecl *func_template_decl =
m_ast.CreateFunctionTemplateDecl(
- containing_decl_ctx, template_function_decl,
- attrs.name.GetCString(), template_param_infos);
+ containing_decl_ctx, GetOwningClangModule(die),
+ template_function_decl, name, template_param_infos);
m_ast.CreateFunctionTemplateSpecializationInfo(
- function_decl, func_template_decl, template_param_infos);
+ template_function_decl, func_template_decl, template_param_infos);
}
lldbassert(function_decl);
@@ -1278,44 +1263,7 @@ TypeSP DWARFASTParserClang::ParseArrayType(const DWARFDIE &die,
if (attrs.byte_stride == 0 && attrs.bit_stride == 0)
attrs.byte_stride = element_type->GetByteSize().getValueOr(0);
CompilerType array_element_type = element_type->GetForwardCompilerType();
-
- if (ClangASTContext::IsCXXClassType(array_element_type) &&
- !array_element_type.GetCompleteType()) {
- ModuleSP module_sp = die.GetModule();
- if (module_sp) {
- if (die.GetCU()->GetProducer() == eProducerClang)
- module_sp->ReportError(
- "DWARF DW_TAG_array_type DIE at 0x%8.8x has a "
- "class/union/struct element type DIE 0x%8.8x that is a "
- "forward declaration, not a complete definition.\nTry "
- "compiling the source file with -fstandalone-debug or "
- "disable -gmodules",
- die.GetOffset(), type_die.GetOffset());
- else
- module_sp->ReportError(
- "DWARF DW_TAG_array_type DIE at 0x%8.8x has a "
- "class/union/struct element type DIE 0x%8.8x that is a "
- "forward declaration, not a complete definition.\nPlease "
- "file a bug against the compiler and include the "
- "preprocessed output for %s",
- die.GetOffset(), type_die.GetOffset(), GetUnitName(die).c_str());
- }
-
- // We have no choice other than to pretend that the element class
- // type is complete. If we don't do this, clang will crash when
- // trying to layout the class. Since we provide layout
- // assistance, all ivars in this class and other classes will be
- // fine, this is the best we can do short of crashing.
- if (ClangASTContext::StartTagDeclarationDefinition(array_element_type)) {
- ClangASTContext::CompleteTagDeclarationDefinition(array_element_type);
- } else {
- module_sp->ReportError("DWARF DIE at 0x%8.8x was not able to "
- "start its definition.\nPlease file a "
- "bug and attach the file at the start "
- "of this error message",
- type_die.GetOffset());
- }
- }
+ CompleteType(array_element_type);
uint64_t array_element_bit_stride =
attrs.byte_stride * 8 + attrs.bit_stride;
@@ -1357,7 +1305,7 @@ TypeSP DWARFASTParserClang::ParsePointerToMemberType(
CompilerType pointee_clang_type = pointee_type->GetForwardCompilerType();
CompilerType class_clang_type = class_type->GetLayoutCompilerType();
- CompilerType clang_type = ClangASTContext::CreateMemberPointerType(
+ CompilerType clang_type = TypeSystemClang::CreateMemberPointerType(
class_clang_type, pointee_clang_type);
if (llvm::Optional<uint64_t> clang_type_size =
@@ -1370,6 +1318,28 @@ TypeSP DWARFASTParserClang::ParsePointerToMemberType(
return nullptr;
}
+void DWARFASTParserClang::CompleteType(CompilerType type) {
+ // Technically, enums can be incomplete too, but we don't handle those as they
+ // are emitted even under -flimit-debug-info.
+ if (!TypeSystemClang::IsCXXClassType(type))
+ return;
+
+ if (type.GetCompleteType())
+ return;
+
+ // No complete definition in this module. Mark the class as complete to
+ // satisfy local ast invariants, but make a note of the fact that
+ // it is not _really_ complete so we can later search for a definition in a
+ // different module.
+ // Since we provide layout assistance, layouts of types containing this class
+ // will be correct even if we are not able to find the definition elsewhere.
+ bool started = TypeSystemClang::StartTagDeclarationDefinition(type);
+ lldbassert(started && "Unable to start a class type definition.");
+ TypeSystemClang::CompleteTagDeclarationDefinition(type);
+ const clang::TagDecl *td = ClangUtil::GetAsTagDecl(type);
+ m_ast.GetMetadata(td)->SetIsForcefullyCompleted();
+}
+
TypeSP DWARFASTParserClang::UpdateSymbolContextScopeForType(
const SymbolContext &sc, const DWARFDIE &die, TypeSP type_sp) {
if (!type_sp)
@@ -1412,7 +1382,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
CompilerType clang_type;
const dw_tag_t tag = die.Tag();
SymbolFileDWARF *dwarf = die.GetDWARF();
- LanguageType cu_language = die.GetLanguage();
+ LanguageType cu_language = SymbolFileDWARF::GetLanguage(*die.GetCU());
Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_TYPE_COMPLETION |
DWARF_LOG_LOOKUPS);
@@ -1544,8 +1514,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
if (type_sp)
return type_sp;
- DWARFDeclContext die_decl_ctx;
- die.GetDWARFDeclContext(die_decl_ctx);
+ DWARFDeclContext die_decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
// type_sp = FindDefinitionTypeForDIE (dwarf_cu, die,
// type_name_const_str);
@@ -1611,12 +1580,12 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
metadata.SetIsDynamicCXXType(dwarf->ClassOrStructIsVirtual(die));
if (attrs.name.GetStringRef().contains('<')) {
- ClangASTContext::TemplateParameterInfos template_param_infos;
+ TypeSystemClang::TemplateParameterInfos template_param_infos;
if (ParseTemplateParameterInfos(die, template_param_infos)) {
clang::ClassTemplateDecl *class_template_decl =
- m_ast.ParseClassTemplateDecl(decl_ctx, attrs.accessibility,
- attrs.name.GetCString(), tag_decl_kind,
- template_param_infos);
+ m_ast.ParseClassTemplateDecl(
+ decl_ctx, GetOwningClangModule(die), attrs.accessibility,
+ attrs.name.GetCString(), tag_decl_kind, template_param_infos);
if (!class_template_decl) {
if (log) {
dwarf->GetObjectFile()->GetModule()->LogMessage(
@@ -1631,8 +1600,8 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
clang::ClassTemplateSpecializationDecl *class_specialization_decl =
m_ast.CreateClassTemplateSpecializationDecl(
- decl_ctx, class_template_decl, tag_decl_kind,
- template_param_infos);
+ decl_ctx, GetOwningClangModule(die), class_template_decl,
+ tag_decl_kind, template_param_infos);
clang_type = m_ast.CreateClassTemplateSpecializationType(
class_specialization_decl);
clang_type_was_created = true;
@@ -1645,8 +1614,9 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
if (!clang_type_was_created) {
clang_type_was_created = true;
clang_type = m_ast.CreateRecordType(
- decl_ctx, attrs.accessibility, attrs.name.GetCString(), tag_decl_kind,
- attrs.class_language, &metadata, attrs.exports_symbols);
+ decl_ctx, GetOwningClangModule(die), attrs.accessibility,
+ attrs.name.GetCString(), tag_decl_kind, attrs.class_language,
+ &metadata, attrs.exports_symbols);
}
}
@@ -1654,12 +1624,11 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
// parameters in any class methods need it for the clang types for
// function prototypes.
LinkDeclContextToDIE(m_ast.GetDeclContextForType(clang_type), die);
- type_sp = std::make_shared<Type>(die.GetID(), dwarf, attrs.name,
- attrs.byte_size, nullptr, LLDB_INVALID_UID,
- Type::eEncodingIsUID, &attrs.decl,
- clang_type, Type::ResolveState::Forward);
-
- type_sp->SetIsCompleteObjCClass(attrs.is_complete_objc_class);
+ type_sp = std::make_shared<Type>(
+ die.GetID(), dwarf, attrs.name, attrs.byte_size, nullptr,
+ LLDB_INVALID_UID, Type::eEncodingIsUID, &attrs.decl, clang_type,
+ Type::ResolveState::Forward,
+ TypePayloadClang(OptionalClangModuleID(), attrs.is_complete_objc_class));
// Add our type to the unique type map so we don't end up creating many
// copies of the same type over and over in the ASTContext for our
@@ -1705,8 +1674,8 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
// these child definitions.
if (!die.HasChildren()) {
// No children for this struct/union/class, lets finish it
- if (ClangASTContext::StartTagDeclarationDefinition(clang_type)) {
- ClangASTContext::CompleteTagDeclarationDefinition(clang_type);
+ if (TypeSystemClang::StartTagDeclarationDefinition(clang_type)) {
+ TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
} else {
dwarf->GetObjectFile()->GetModule()->ReportError(
"DWARF DIE at 0x%8.8x named \"%s\" was not able to start its "
@@ -1718,7 +1687,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
if (tag == DW_TAG_structure_type) // this only applies in C
{
clang::RecordDecl *record_decl =
- ClangASTContext::GetAsRecordDecl(clang_type);
+ TypeSystemClang::GetAsRecordDecl(clang_type);
if (record_decl) {
GetClangASTImporter().SetRecordLayout(
@@ -1736,7 +1705,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
if (attrs.class_language != eLanguageTypeObjC &&
attrs.class_language != eLanguageTypeObjC_plus_plus)
- ClangASTContext::StartTagDeclarationDefinition(clang_type);
+ TypeSystemClang::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
@@ -1752,9 +1721,9 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,
// binaries.
dwarf->GetForwardDeclDieToClangType()[die.GetDIE()] =
clang_type.GetOpaqueQualType();
- dwarf->GetForwardDeclClangTypeToDie()
- [ClangUtil::RemoveFastQualifiers(clang_type).GetOpaqueQualType()] =
- die.GetID();
+ dwarf->GetForwardDeclClangTypeToDie().try_emplace(
+ ClangUtil::RemoveFastQualifiers(clang_type).GetOpaqueQualType(),
+ *die.GetDIERef());
m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), true);
}
}
@@ -1799,7 +1768,7 @@ public:
m_property_getter_name(property_getter_name),
m_property_attributes(property_attributes) {
if (metadata != nullptr) {
- m_metadata_up.reset(new ClangASTMetadata());
+ m_metadata_up = std::make_unique<ClangASTMetadata>();
*m_metadata_up = *metadata;
}
}
@@ -1819,14 +1788,14 @@ public:
m_property_attributes = rhs.m_property_attributes;
if (rhs.m_metadata_up) {
- m_metadata_up.reset(new ClangASTMetadata());
+ m_metadata_up = std::make_unique<ClangASTMetadata>();
*m_metadata_up = *rhs.m_metadata_up;
}
return *this;
}
bool Finalize() {
- return ClangASTContext::AddObjCClassProperty(
+ return TypeSystemClang::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_up.get());
@@ -1845,14 +1814,14 @@ private:
bool DWARFASTParserClang::ParseTemplateDIE(
const DWARFDIE &die,
- ClangASTContext::TemplateParameterInfos &template_param_infos) {
+ TypeSystemClang::TemplateParameterInfos &template_param_infos) {
const dw_tag_t tag = die.Tag();
bool is_template_template_argument = false;
switch (tag) {
case DW_TAG_GNU_template_parameter_pack: {
- template_param_infos.packed_args.reset(
- new ClangASTContext::TemplateParameterInfos);
+ template_param_infos.packed_args =
+ std::make_unique<TypeSystemClang::TemplateParameterInfos>();
for (DWARFDIE child_die = die.GetFirstChild(); child_die.IsValid();
child_die = child_die.GetSibling()) {
if (!ParseTemplateDIE(child_die, *template_param_infos.packed_args))
@@ -1954,7 +1923,7 @@ bool DWARFASTParserClang::ParseTemplateDIE(
bool DWARFASTParserClang::ParseTemplateParameterInfos(
const DWARFDIE &parent_die,
- ClangASTContext::TemplateParameterInfos &template_param_infos) {
+ TypeSystemClang::TemplateParameterInfos &template_param_infos) {
if (!parent_die)
return false;
@@ -1988,141 +1957,102 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
ClangASTImporter::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;
- }
-
- std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases;
- std::vector<int> member_accessibilities;
- bool is_a_class = false;
- // Parse members and base classes first
- std::vector<DWARFDIE> member_function_dies;
-
- DelayedPropertyList delayed_properties;
- ParseChildMembers(die, clang_type, class_language, bases,
- member_accessibilities, member_function_dies,
- delayed_properties, default_accessibility, is_a_class,
- layout_info);
-
- // Now parse any methods if there were any...
- for (const DWARFDIE &die : member_function_dies)
- dwarf->ResolveType(die);
-
- 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 (die.HasChildren()) {
+ const bool type_is_objc_object_or_interface =
+ TypeSystemClang::IsObjCObjectOrInterfaceType(clang_type);
+ if (type_is_objc_object_or_interface) {
+ // For objective C we don't start the definition when the class is
+ // created.
+ TypeSystemClang::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;
+ }
+
+ std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases;
+ std::vector<int> member_accessibilities;
+ bool is_a_class = false;
+ // Parse members and base classes first
+ std::vector<DWARFDIE> member_function_dies;
+
+ DelayedPropertyList delayed_properties;
+ ParseChildMembers(die, clang_type, bases, member_accessibilities,
+ member_function_dies, delayed_properties,
+ default_accessibility, is_a_class, layout_info);
+
+ // Now parse any methods if there were any...
+ for (const DWARFDIE &die : member_function_dies)
+ dwarf->ResolveType(die);
+
+ if (type_is_objc_object_or_interface) {
+ ConstString class_name(clang_type.GetTypeName());
+ if (class_name) {
+ dwarf->GetObjCMethods(class_name, [&](DWARFDIE method_die) {
+ method_die.ResolveType();
+ return true;
+ });
- // 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(ClangUtil::GetQualType(clang_type),
- clang::TTK_Class);
+ for (DelayedPropertyList::iterator pi = delayed_properties.begin(),
+ pe = delayed_properties.end();
+ pi != pe; ++pi)
+ pi->Finalize();
}
+ }
- // 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 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 (!type_is_objc_object_or_interface) {
+ if (is_a_class && tag_decl_kind != clang::TTK_Class)
+ m_ast.SetTagTypeKind(ClangUtil::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 (!bases.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.TransferBaseClasses()
+ for (const auto &base_class : bases) {
+ clang::TypeSourceInfo *type_source_info =
+ base_class->getTypeSourceInfo();
+ if (type_source_info)
+ CompleteType(m_ast.GetType(type_source_info->getType()));
}
- if (!bases.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.TransferBaseClasses()
- for (const auto &base_class : bases) {
- clang::TypeSourceInfo *type_source_info =
- base_class->getTypeSourceInfo();
- if (type_source_info) {
- CompilerType base_class_type =
- m_ast.GetType(type_source_info->getType());
- if (!base_class_type.GetCompleteType()) {
- 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() == eProducerClang)
- module->ReportError(":: Try compiling the source file with "
- "-fstandalone-debug.");
-
- // 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.TransferBaseClasses()" 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.
- if (ClangASTContext::StartTagDeclarationDefinition(
- base_class_type)) {
- ClangASTContext::CompleteTagDeclarationDefinition(
- base_class_type);
- }
- }
- }
- }
-
- m_ast.TransferBaseClasses(clang_type.GetOpaqueQualType(),
- std::move(bases));
- }
+ m_ast.TransferBaseClasses(clang_type.GetOpaqueQualType(),
+ std::move(bases));
}
}
m_ast.AddMethodOverridesForCXXRecordType(clang_type.GetOpaqueQualType());
- ClangASTContext::BuildIndirectFields(clang_type);
- ClangASTContext::CompleteTagDeclarationDefinition(clang_type);
+ TypeSystemClang::BuildIndirectFields(clang_type);
+ TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
if (!layout_info.field_offsets.empty() || !layout_info.base_offsets.empty() ||
!layout_info.vbase_offsets.empty()) {
@@ -2144,14 +2074,14 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
bool DWARFASTParserClang::CompleteEnumType(const DWARFDIE &die,
lldb_private::Type *type,
CompilerType &clang_type) {
- if (ClangASTContext::StartTagDeclarationDefinition(clang_type)) {
+ if (TypeSystemClang::StartTagDeclarationDefinition(clang_type)) {
if (die.HasChildren()) {
bool is_signed = false;
clang_type.IsIntegerType(is_signed);
ParseChildEnumerators(clang_type, is_signed,
type->GetByteSize().getValueOr(0), die);
}
- ClangASTContext::CompleteTagDeclarationDefinition(clang_type);
+ TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
}
return (bool)clang_type;
}
@@ -2211,7 +2141,7 @@ void DWARFASTParserClang::EnsureAllDIEsInDeclContextHaveBeenParsed(
CompilerDecl DWARFASTParserClang::GetDeclForUIDFromDWARF(const DWARFDIE &die) {
clang::Decl *clang_decl = GetClangDeclForDIE(die);
if (clang_decl != nullptr)
- return CompilerDecl(&m_ast, clang_decl);
+ return m_ast.GetCompilerDecl(clang_decl);
return CompilerDecl();
}
@@ -2340,9 +2270,11 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
func_name.SetValue(ConstString(mangled), true);
else if ((die.GetParent().Tag() == DW_TAG_compile_unit ||
die.GetParent().Tag() == DW_TAG_partial_unit) &&
- Language::LanguageIsCPlusPlus(die.GetLanguage()) &&
- !Language::LanguageIsObjC(die.GetLanguage()) && name &&
- strcmp(name, "main") != 0) {
+ Language::LanguageIsCPlusPlus(
+ SymbolFileDWARF::GetLanguage(*die.GetCU())) &&
+ !Language::LanguageIsObjC(
+ SymbolFileDWARF::GetLanguage(*die.GetCU())) &&
+ 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.
@@ -2352,10 +2284,9 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
unsigned type_quals = 0;
std::vector<CompilerType> param_types;
std::vector<clang::ParmVarDecl *> param_decls;
- DWARFDeclContext decl_ctx;
StreamString sstr;
- die.GetDWARFDeclContext(decl_ctx);
+ DWARFDeclContext decl_ctx = SymbolFileDWARF::GetDWARFDeclContext(die);
sstr << decl_ctx.GetQualifiedName();
clang::DeclContext *containing_decl_ctx =
@@ -2382,8 +2313,8 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
FunctionSP func_sp;
std::unique_ptr<Declaration> decl_up;
if (decl_file != 0 || decl_line != 0 || decl_column != 0)
- decl_up.reset(new Declaration(die.GetCU()->GetFile(decl_file),
- decl_line, decl_column));
+ decl_up = std::make_unique<Declaration>(die.GetCU()->GetFile(decl_file),
+ decl_line, decl_column);
SymbolFileDWARF *dwarf = die.GetDWARF();
// Supply the type _only_ if it has already been parsed
@@ -2413,13 +2344,12 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
void DWARFASTParserClang::ParseSingleMember(
const DWARFDIE &die, const DWARFDIE &parent_die,
- lldb_private::CompilerType &class_clang_type,
- const lldb::LanguageType class_language,
+ const lldb_private::CompilerType &class_clang_type,
std::vector<int> &member_accessibilities,
- lldb::AccessType &default_accessibility,
+ lldb::AccessType default_accessibility,
DelayedPropertyList &delayed_properties,
lldb_private::ClangASTImporter::LayoutInfo &layout_info,
- BitfieldInfo &last_field_info) {
+ FieldInfo &last_field_info) {
ModuleSP module_sp = parent_die.GetDWARF()->GetObjectFile()->GetModule();
const dw_tag_t tag = die.Tag();
// Get the parent byte size so we can verify any members will fit
@@ -2430,453 +2360,400 @@ void DWARFASTParserClang::ParseSingleMember(
DWARFAttributes attributes;
const size_t num_attributes = die.GetAttributes(attributes);
- if (num_attributes > 0) {
- const char *name = nullptr;
- const char *prop_name = nullptr;
- const char *prop_getter_name = nullptr;
- const char *prop_setter_name = nullptr;
- uint32_t prop_attributes = 0;
-
- bool is_artificial = false;
- DWARFFormValue encoding_form;
- AccessType accessibility = eAccessNone;
- uint32_t member_byte_offset =
- (parent_die.Tag() == DW_TAG_union_type) ? 0 : UINT32_MAX;
- llvm::Optional<uint64_t> byte_size;
- int64_t bit_offset = 0;
- uint64_t data_bit_offset = UINT64_MAX;
- 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_name:
- name = form_value.AsCString();
- break;
- case DW_AT_type:
- encoding_form = form_value;
- break;
- case DW_AT_bit_offset:
- bit_offset = form_value.Signed();
- 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_bit_offset:
- data_bit_offset = 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.GetData();
- uint32_t block_length = form_value.Unsigned();
- uint32_t block_offset =
- form_value.BlockData() - debug_info_data.GetDataStart();
- if (DWARFExpression::Evaluate(
- nullptr, // ExecutionContext *
- nullptr, // RegisterContext *
- module_sp,
- DataExtractor(debug_info_data, block_offset, block_length),
- die.GetCU(), eRegisterKindDWARF, &initialValue, nullptr,
- memberOffset, nullptr)) {
- member_byte_offset = memberOffset.ResolveValue(nullptr).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();
+ if (num_attributes == 0)
+ return;
+
+ const char *name = nullptr;
+ const char *prop_name = nullptr;
+ const char *prop_getter_name = nullptr;
+ const char *prop_setter_name = nullptr;
+ uint32_t prop_attributes = 0;
+
+ bool is_artificial = false;
+ DWARFFormValue encoding_form;
+ AccessType accessibility = eAccessNone;
+ uint32_t member_byte_offset =
+ (parent_die.Tag() == DW_TAG_union_type) ? 0 : UINT32_MAX;
+ llvm::Optional<uint64_t> byte_size;
+ int64_t bit_offset = 0;
+ uint64_t data_bit_offset = UINT64_MAX;
+ 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)) {
+ // DW_AT_data_member_location indicates the byte offset of the
+ // word from the base address of the structure.
+ //
+ // DW_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.
+ //
+ // DW_AT_bit_size indicates the size of the field in bits.
+ switch (attr) {
+ 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.Signed();
+ 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_bit_offset:
+ data_bit_offset = 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.GetData();
+ uint32_t block_length = form_value.Unsigned();
+ uint32_t block_offset =
+ form_value.BlockData() - debug_info_data.GetDataStart();
+ if (DWARFExpression::Evaluate(
+ nullptr, // ExecutionContext *
+ nullptr, // RegisterContext *
+ module_sp,
+ DataExtractor(debug_info_data, block_offset, block_length),
+ die.GetCU(), eRegisterKindDWARF, &initialValue, nullptr,
+ memberOffset, nullptr)) {
+ member_byte_offset = memberOffset.ResolveValue(nullptr).UInt();
}
- break;
+ } 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;
+ 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;
- }
+ 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_setter;
+ if (prop_name) {
+ ConstString fixed_setter;
- // Check if the property getter/setter were provided as full names.
- // We want basenames, so we extract them.
+ // 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_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 (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 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;
+ 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]);
+ ss.Printf("set%c%s:", toupper(prop_name[0]), &prop_name[1]);
- fixed_setter.SetString(ss.GetString());
- prop_setter_name = fixed_setter.GetCString();
- }
+ fixed_setter.SetString(ss.GetString());
+ 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.
+ // 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 (byte_size.getValueOr(0) == 0 && bit_offset < 0) {
+ bit_size = 0;
+ bit_offset = 0;
+ }
+
+ const bool class_is_objc_object_or_interface =
+ TypeSystemClang::IsObjCObjectOrInterfaceType(class_clang_type);
+
+ // FIXME: Make Clang ignore Objective-C accessibility for expressions
+ if (class_is_objc_object_or_interface)
+ accessibility = eAccessNone;
- if (byte_size.getValueOr(0) == 0 && bit_offset < 0) {
- bit_size = 0;
- bit_offset = 0;
+ // Handle static members
+ if (is_external && member_byte_offset == UINT32_MAX) {
+ Type *var_type = die.ResolveTypeUID(encoding_form.Reference());
+
+ if (var_type) {
+ if (accessibility == eAccessNone)
+ accessibility = eAccessPublic;
+ TypeSystemClang::AddVariableToRecordType(
+ class_clang_type, name, var_type->GetLayoutCompilerType(),
+ accessibility);
}
+ return;
+ }
- // FIXME: Make Clang ignore Objective-C accessibility for expressions
- if (class_language == eLanguageTypeObjC ||
- class_language == eLanguageTypeObjC_plus_plus)
- accessibility = eAccessNone;
+ if (!is_artificial) {
+ Type *member_type = die.ResolveTypeUID(encoding_form.Reference());
- // Handle static members
- if (is_external && member_byte_offset == UINT32_MAX) {
- Type *var_type = die.ResolveTypeUID(encoding_form.Reference());
+ clang::FieldDecl *field_decl = nullptr;
+ const uint64_t character_width = 8;
+ const uint64_t word_width = 32;
+ if (tag == DW_TAG_member) {
+ if (member_type) {
+ CompilerType member_clang_type = member_type->GetLayoutCompilerType();
- if (var_type) {
if (accessibility == eAccessNone)
- accessibility = eAccessPublic;
- ClangASTContext::AddVariableToRecordType(
- class_clang_type, name, var_type->GetLayoutCompilerType(),
- accessibility);
- }
- return;
- }
-
- if (!is_artificial) {
- Type *member_type = die.ResolveTypeUID(encoding_form.Reference());
-
- clang::FieldDecl *field_decl = nullptr;
- 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 (data_bit_offset != UINT64_MAX) {
- this_field_info.bit_offset = data_bit_offset;
- } else {
- if (!byte_size)
- byte_size = member_type->GetByteSize();
+ accessibility = default_accessibility;
+ member_accessibilities.push_back(accessibility);
- ObjectFile *objfile = die.GetDWARF()->GetObjectFile();
- if (objfile->GetByteOrder() == eByteOrderLittle) {
- this_field_info.bit_offset += byte_size.getValueOr(0) * 8;
- this_field_info.bit_offset -= (bit_offset + bit_size);
- } else {
- this_field_info.bit_offset += bit_offset;
- }
+ uint64_t field_bit_offset =
+ (member_byte_offset == UINT32_MAX ? 0 : (member_byte_offset * 8));
+
+ if (bit_size > 0) {
+ FieldInfo this_field_info;
+ this_field_info.bit_offset = field_bit_offset;
+ this_field_info.bit_size = bit_size;
+
+ if (data_bit_offset != UINT64_MAX) {
+ this_field_info.bit_offset = data_bit_offset;
+ } else {
+ if (!byte_size)
+ byte_size = member_type->GetByteSize();
+
+ ObjectFile *objfile = die.GetDWARF()->GetObjectFile();
+ if (objfile->GetByteOrder() == eByteOrderLittle) {
+ this_field_info.bit_offset += byte_size.getValueOr(0) * 8;
+ this_field_info.bit_offset -= (bit_offset + bit_size);
+ } else {
+ this_field_info.bit_offset += bit_offset;
}
+ }
+
+ if ((this_field_info.bit_offset >= parent_bit_size) ||
+ (last_field_info.IsBitfield() &&
+ !last_field_info.NextBitfieldOffsetIsValid(
+ this_field_info.bit_offset))) {
+ ObjectFile *objfile = die.GetDWARF()->GetObjectFile();
+ objfile->GetModule()->ReportWarning(
+ "0x%8.8" PRIx64 ": %s bitfield named \"%s\" has invalid "
+ "bit offset (0x%8.8" PRIx64
+ ") member will be ignored. Please file a bug against the "
+ "compiler and include the preprocessed output for %s\n",
+ die.GetID(), DW_TAG_value_to_name(tag), name,
+ this_field_info.bit_offset, GetUnitName(parent_die).c_str());
+ return;
+ }
+
+ // Update the field bit offset we will report for layout
+ field_bit_offset = this_field_info.bit_offset;
+
+ // 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_is_objc_object_or_interface)
+ detect_unnamed_bitfields =
+ die.GetCU()->Supports_unnamed_objc_bitfields();
- if ((this_field_info.bit_offset >= parent_bit_size) ||
- !last_field_info.NextBitfieldOffsetIsValid(
- this_field_info.bit_offset)) {
- ObjectFile *objfile = die.GetDWARF()->GetObjectFile();
- objfile->GetModule()->ReportWarning(
- "0x%8.8" PRIx64 ": %s bitfield named \"%s\" has invalid "
- "bit offset (0x%8.8" PRIx64
- ") member will be ignored. Please file a bug against the "
- "compiler and include the preprocessed output for %s\n",
- die.GetID(), DW_TAG_value_to_name(tag), name,
- this_field_info.bit_offset, GetUnitName(parent_die).c_str());
- this_field_info.Clear();
- return;
+ if (detect_unnamed_bitfields) {
+ clang::Optional<FieldInfo> unnamed_field_info;
+ uint64_t last_field_end = 0;
+
+ last_field_end =
+ last_field_info.bit_offset + last_field_info.bit_size;
+
+ if (!last_field_info.IsBitfield()) {
+ // The last field was not a bit-field...
+ // but if it did take up the entire word then we need to extend
+ // last_field_end so the bit-field does not step into the last
+ // fields padding.
+ if (last_field_end != 0 && ((last_field_end % word_width) != 0))
+ last_field_end += word_width - (last_field_end % word_width);
}
- // 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 we have a gap between the last_field_end and the current
+ // field we have an unnamed bit-field.
+ // If we have a base class, we assume there is no unnamed
+ // bit-field if this is the first field since the gap can be
+ // attributed to the members from the base class. This assumption
+ // is not correct if the first field of the derived class is
+ // indeed an unnamed bit-field. We currently do not have the
+ // machinary to track the offset of the last field of classes we
+ // have seen before, so we are not handling this case.
+ if (this_field_info.bit_offset != last_field_end &&
+ this_field_info.bit_offset > last_field_end &&
+ !(last_field_info.bit_offset == 0 &&
+ last_field_info.bit_size == 0 &&
+ layout_info.base_offsets.size() != 0)) {
+ unnamed_field_info = FieldInfo{};
+ unnamed_field_info->bit_size =
+ this_field_info.bit_offset - last_field_end;
+ unnamed_field_info->bit_offset = last_field_end;
+ }
- if (anon_field_info.IsValid()) {
- clang::FieldDecl *unnamed_bitfield_decl =
- ClangASTContext::AddFieldToRecordType(
- class_clang_type, llvm::StringRef(),
- m_ast.GetBuiltinTypeForEncodingAndBitSize(eEncodingSint,
- word_width),
- accessibility, anon_field_info.bit_size);
+ if (unnamed_field_info) {
+ clang::FieldDecl *unnamed_bitfield_decl =
+ TypeSystemClang::AddFieldToRecordType(
+ class_clang_type, llvm::StringRef(),
+ m_ast.GetBuiltinTypeForEncodingAndBitSize(eEncodingSint,
+ word_width),
+ accessibility, unnamed_field_info->bit_size);
- layout_info.field_offsets.insert(std::make_pair(
- unnamed_bitfield_decl, anon_field_info.bit_offset));
- }
+ layout_info.field_offsets.insert(std::make_pair(
+ unnamed_bitfield_decl, unnamed_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 &&
- (member_array_size != 0 ||
- member_byte_offset > parent_byte_size)) {
- module_sp->ReportError(
- "0x%8.8" PRIx64
- ": DW_TAG_member '%s' refers to type 0x%8.8x"
- " which extends beyond the bounds of 0x%8.8" PRIx64,
- die.GetID(), name, encoding_form.Reference().GetOffset(),
- parent_die.GetID());
- }
+ last_field_info = this_field_info;
+ last_field_info.SetIsBitfield(true);
+ } else {
+ last_field_info.bit_offset = field_bit_offset;
- member_clang_type =
- m_ast.CreateArrayType(member_array_element_type, 0, false);
- }
- }
+ if (llvm::Optional<uint64_t> clang_type_size =
+ member_clang_type.GetByteSize(nullptr)) {
+ last_field_info.bit_size = *clang_type_size * character_width;
}
- if (ClangASTContext::IsCXXClassType(member_clang_type) &&
- !member_clang_type.GetCompleteType()) {
- if (die.GetCU()->GetProducer() == 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 -fstandalone-debug",
- 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, GetUnitName(parent_die).c_str());
- // We have no choice other than to pretend that the member
- // class is complete. If we don't do this, clang will crash
- // when trying to layout the class. Since we provide layout
- // assistance, all ivars in this class and other classes will
- // be fine, this is the best we can do short of crashing.
- if (ClangASTContext::StartTagDeclarationDefinition(
- member_clang_type)) {
- ClangASTContext::CompleteTagDeclarationDefinition(
- member_clang_type);
- } else {
- module_sp->ReportError(
- "DWARF DIE at 0x%8.8x (class %s) has a member variable "
- "0x%8.8x (%s) whose type claims to be a C++ class but we "
- "were not able to start its definition.\nPlease file a "
- "bug and attach the file at the start of this error "
- "message",
- parent_die.GetOffset(), parent_die.GetName(), die.GetOffset(),
- name);
+ last_field_info.SetIsBitfield(false);
+ }
+
+ 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 &&
+ (member_array_size != 0 ||
+ member_byte_offset > parent_byte_size)) {
+ module_sp->ReportError(
+ "0x%8.8" PRIx64
+ ": DW_TAG_member '%s' refers to type 0x%8.8x"
+ " which extends beyond the bounds of 0x%8.8" PRIx64,
+ die.GetID(), name, encoding_form.Reference().GetOffset(),
+ parent_die.GetID());
+ }
+
+ member_clang_type =
+ m_ast.CreateArrayType(member_array_element_type, 0, false);
}
}
+ }
- field_decl = ClangASTContext::AddFieldToRecordType(
- class_clang_type, name, member_clang_type, accessibility,
- bit_size);
+ CompleteType(member_clang_type);
- m_ast.SetMetadataAsUserID(field_decl, die.GetID());
+ field_decl = TypeSystemClang::AddFieldToRecordType(
+ class_clang_type, name, member_clang_type, accessibility,
+ bit_size);
- 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.8x"
- " which was unable to be parsed",
- die.GetID(), name, encoding_form.Reference().GetOffset());
- else
- module_sp->ReportError(
- "0x%8.8" PRIx64 ": DW_TAG_member refers to type 0x%8.8x"
- " which was unable to be parsed",
- die.GetID(), encoding_form.Reference().GetOffset());
- }
+ 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.8x"
+ " which was unable to be parsed",
+ die.GetID(), name, encoding_form.Reference().GetOffset());
+ else
+ module_sp->ReportError(
+ "0x%8.8" PRIx64 ": DW_TAG_member refers to type 0x%8.8x"
+ " which was unable to be parsed",
+ die.GetID(), encoding_form.Reference().GetOffset());
}
+ }
- if (prop_name != nullptr && member_type) {
- clang::ObjCIvarDecl *ivar_decl = nullptr;
+ if (prop_name != nullptr && member_type) {
+ clang::ObjCIvarDecl *ivar_decl = nullptr;
- if (field_decl) {
- ivar_decl = clang::dyn_cast<clang::ObjCIvarDecl>(field_decl);
- assert(ivar_decl != nullptr);
- }
+ if (field_decl) {
+ ivar_decl = clang::dyn_cast<clang::ObjCIvarDecl>(field_decl);
+ assert(ivar_decl != nullptr);
+ }
- 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));
+ 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());
- }
+ if (ivar_decl)
+ m_ast.SetMetadataAsUserID(ivar_decl, die.GetID());
}
}
}
bool DWARFASTParserClang::ParseChildMembers(
const DWARFDIE &parent_die, CompilerType &class_clang_type,
- const LanguageType class_language,
std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
std::vector<int> &member_accessibilities,
std::vector<DWARFDIE> &member_function_dies,
@@ -2885,11 +2762,11 @@ bool DWARFASTParserClang::ParseChildMembers(
if (!parent_die)
return false;
- BitfieldInfo last_field_info;
+ FieldInfo last_field_info;
ModuleSP module_sp = parent_die.GetDWARF()->GetObjectFile()->GetModule();
- ClangASTContext *ast =
- llvm::dyn_cast_or_null<ClangASTContext>(class_clang_type.GetTypeSystem());
+ TypeSystemClang *ast =
+ llvm::dyn_cast_or_null<TypeSystemClang>(class_clang_type.GetTypeSystem());
if (ast == nullptr)
return false;
@@ -2900,7 +2777,7 @@ bool DWARFASTParserClang::ParseChildMembers(
switch (tag) {
case DW_TAG_member:
case DW_TAG_APPLE_property:
- ParseSingleMember(die, parent_die, class_clang_type, class_language,
+ ParseSingleMember(die, parent_die, class_clang_type,
member_accessibilities, default_accessibility,
delayed_properties, layout_info, last_field_info);
break;
@@ -2990,7 +2867,7 @@ bool DWARFASTParserClang::ParseChildMembers(
CompilerType base_class_clang_type =
base_class_type->GetFullCompilerType();
assert(base_class_clang_type);
- if (class_language == eLanguageTypeObjC) {
+ if (TypeSystemClang::IsObjCObjectOrInterfaceType(class_clang_type)) {
ast->SetObjCSuperClass(class_clang_type, base_class_clang_type);
} else {
std::unique_ptr<clang::CXXBaseSpecifier> result =
@@ -3121,9 +2998,9 @@ size_t DWARFASTParserClang::ParseChildParameters(
function_param_types.push_back(type->GetForwardCompilerType());
clang::ParmVarDecl *param_var_decl =
- m_ast.CreateParameterDeclaration(containing_decl_ctx, name,
- type->GetForwardCompilerType(),
- storage);
+ m_ast.CreateParameterDeclaration(
+ containing_decl_ctx, GetOwningClangModule(die), name,
+ type->GetForwardCompilerType(), storage);
assert(param_var_decl);
function_param_decls.push_back(param_var_decl);
@@ -3318,10 +3195,10 @@ clang::Decl *DWARFASTParserClang::GetClangDeclForDIE(const DWARFDIE &die) {
if (dwarf && type) {
const char *name = die.GetName();
clang::DeclContext *decl_context =
- ClangASTContext::DeclContextGetAsDeclContext(
+ TypeSystemClang::DeclContextGetAsDeclContext(
dwarf->GetDeclContextContainingUID(die.GetID()));
decl = m_ast.CreateVariableDeclaration(
- decl_context, name,
+ decl_context, GetOwningClangModule(die), name,
ClangUtil::GetQualType(type->GetForwardCompilerType()));
}
break;
@@ -3330,16 +3207,16 @@ clang::Decl *DWARFASTParserClang::GetClangDeclForDIE(const DWARFDIE &die) {
SymbolFileDWARF *dwarf = die.GetDWARF();
DWARFDIE imported_uid = die.GetAttributeValueAsReferenceDIE(DW_AT_import);
if (imported_uid) {
- CompilerDecl imported_decl = imported_uid.GetDecl();
+ CompilerDecl imported_decl = SymbolFileDWARF::GetDecl(imported_uid);
if (imported_decl) {
clang::DeclContext *decl_context =
- ClangASTContext::DeclContextGetAsDeclContext(
+ TypeSystemClang::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);
+ decl = m_ast.CreateUsingDeclaration(
+ decl_context, OptionalClangModuleID(), clang_imported_decl);
}
}
break;
@@ -3349,15 +3226,17 @@ clang::Decl *DWARFASTParserClang::GetClangDeclForDIE(const DWARFDIE &die) {
DWARFDIE imported_uid = die.GetAttributeValueAsReferenceDIE(DW_AT_import);
if (imported_uid) {
- CompilerDeclContext imported_decl_ctx = imported_uid.GetDeclContext();
+ CompilerDeclContext imported_decl_ctx =
+ SymbolFileDWARF::GetDeclContext(imported_uid);
if (imported_decl_ctx) {
clang::DeclContext *decl_context =
- ClangASTContext::DeclContextGetAsDeclContext(
+ TypeSystemClang::DeclContextGetAsDeclContext(
dwarf->GetDeclContextContainingUID(die.GetID()));
if (clang::NamespaceDecl *ns_decl =
- ClangASTContext::DeclContextGetAsNamespaceDecl(
+ TypeSystemClang::DeclContextGetAsNamespaceDecl(
imported_decl_ctx))
- decl = m_ast.CreateUsingDirectiveDeclaration(decl_context, ns_decl);
+ decl = m_ast.CreateUsingDirectiveDeclaration(
+ decl_context, OptionalClangModuleID(), ns_decl);
}
}
break;
@@ -3415,6 +3294,32 @@ DWARFASTParserClang::GetClangDeclContextForDIE(const DWARFDIE &die) {
return nullptr;
}
+OptionalClangModuleID
+DWARFASTParserClang::GetOwningClangModule(const DWARFDIE &die) {
+ if (!die.IsValid())
+ return {};
+
+ for (DWARFDIE parent = die.GetParent(); parent.IsValid();
+ parent = parent.GetParent()) {
+ const dw_tag_t tag = parent.Tag();
+ if (tag == DW_TAG_module) {
+ DWARFDIE module_die = parent;
+ auto it = m_die_to_module.find(module_die.GetDIE());
+ if (it != m_die_to_module.end())
+ return it->second;
+ const char *name = module_die.GetAttributeValueAsString(DW_AT_name, 0);
+ if (!name)
+ return {};
+
+ OptionalClangModuleID id =
+ m_ast.GetOrCreateClangModule(name, GetOwningClangModule(module_die));
+ m_die_to_module.insert({module_die.GetDIE(), id});
+ return id;
+ }
+ }
+ return {};
+}
+
static bool IsSubroutine(const DWARFDIE &die) {
switch (die.Tag()) {
case DW_TAG_subprogram:
@@ -3487,7 +3392,8 @@ clang::BlockDecl *DWARFASTParserClang::ResolveBlockDIE(const DWARFDIE &die) {
DWARFDIE decl_context_die;
clang::DeclContext *decl_context =
GetClangDeclContextContainingDIE(die, &decl_context_die);
- decl = m_ast.CreateBlockDeclaration(decl_context);
+ decl =
+ m_ast.CreateBlockDeclaration(decl_context, GetOwningClangModule(die));
if (decl)
LinkDeclContextToDIE((clang::DeclContext *)decl, die);
@@ -3515,7 +3421,8 @@ DWARFASTParserClang::ResolveNamespaceDIE(const DWARFDIE &die) {
die.GetAttributeValueAsUnsigned(DW_AT_export_symbols, 0) != 0;
namespace_decl = m_ast.GetUniqueNamespaceDeclaration(
- namespace_name, containing_decl_ctx, is_inline);
+ namespace_name, containing_decl_ctx, GetOwningClangModule(die),
+ is_inline);
Log *log =
nullptr; // (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
if (log) {
@@ -3697,9 +3604,11 @@ bool DWARFASTParserClang::CopyUniqueClassMethodTypes(
}
DWARFASTParserClang *src_dwarf_ast_parser =
- (DWARFASTParserClang *)src_die.GetDWARFParser();
+ static_cast<DWARFASTParserClang *>(
+ SymbolFileDWARF::GetDWARFParser(*src_die.GetCU()));
DWARFASTParserClang *dst_dwarf_ast_parser =
- (DWARFASTParserClang *)dst_die.GetDWARFParser();
+ static_cast<DWARFASTParserClang *>(
+ SymbolFileDWARF::GetDWARFParser(*dst_die.GetCU()));
// Now do the work of linking the DeclContexts and Types.
if (fast_path) {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
index 4ad757247c3e..2ef49abc1da1 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_DWARFASTParserClang_h_
-#define SymbolFileDWARF_DWARFASTParserClang_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSERCLANG_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSERCLANG_H
#include "clang/AST/CharUnits.h"
#include "llvm/ADT/DenseMap.h"
@@ -19,10 +19,10 @@
#include "DWARFDefines.h"
#include "DWARFFormValue.h"
#include "LogChannelDWARF.h"
-#include "lldb/Core/ClangForward.h"
#include "lldb/Core/PluginInterface.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangASTImporter.h"
+
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include <vector>
@@ -36,7 +36,7 @@ struct ParsedDWARFTypeAttributes;
class DWARFASTParserClang : public DWARFASTParser {
public:
- DWARFASTParserClang(lldb_private::ClangASTContext &ast);
+ DWARFASTParserClang(lldb_private::TypeSystemClang &ast);
~DWARFASTParserClang() override;
@@ -78,15 +78,19 @@ protected:
DIEToDeclContextMap;
typedef std::multimap<const clang::DeclContext *, const DWARFDIE>
DeclContextToDIEMap;
+ typedef llvm::DenseMap<const DWARFDebugInfoEntry *,
+ lldb_private::OptionalClangModuleID>
+ DIEToModuleMap;
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::Decl *>
DIEToDeclMap;
typedef llvm::DenseMap<const clang::Decl *, DIEPointerSet> DeclToDIEMap;
- lldb_private::ClangASTContext &m_ast;
+ lldb_private::TypeSystemClang &m_ast;
DIEToDeclMap m_die_to_decl;
DeclToDIEMap m_decl_to_die;
DIEToDeclContextMap m_die_to_decl_ctx;
DeclContextToDIEMap m_decl_ctx_to_die;
+ DIEToModuleMap m_die_to_module;
std::unique_ptr<lldb_private::ClangASTImporter> m_clang_ast_importer_up;
/// @}
@@ -97,16 +101,15 @@ protected:
clang::NamespaceDecl *ResolveNamespaceDIE(const DWARFDIE &die);
bool ParseTemplateDIE(const DWARFDIE &die,
- lldb_private::ClangASTContext::TemplateParameterInfos
+ lldb_private::TypeSystemClang::TemplateParameterInfos
&template_param_infos);
bool ParseTemplateParameterInfos(
const DWARFDIE &parent_die,
- lldb_private::ClangASTContext::TemplateParameterInfos
+ lldb_private::TypeSystemClang::TemplateParameterInfos
&template_param_infos);
bool ParseChildMembers(
const DWARFDIE &die, lldb_private::CompilerType &class_compiler_type,
- const lldb::LanguageType class_language,
std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
std::vector<int> &member_accessibilities,
std::vector<DWARFDIE> &member_function_dies,
@@ -140,6 +143,7 @@ protected:
clang::DeclContext *GetClangDeclContextContainingDIE(const DWARFDIE &die,
DWARFDIE *decl_ctx_die);
+ lldb_private::OptionalClangModuleID GetOwningClangModule(const DWARFDIE &die);
bool CopyUniqueClassMethodTypes(const DWARFDIE &src_class_die,
const DWARFDIE &dst_class_die,
@@ -170,45 +174,31 @@ protected:
lldb::ModuleSP GetModuleForType(const DWARFDIE &die);
private:
- struct BitfieldInfo {
- uint64_t bit_size;
- uint64_t bit_offset;
+ struct FieldInfo {
+ uint64_t bit_size = 0;
+ uint64_t bit_offset = 0;
+ bool is_bitfield = false;
- BitfieldInfo()
- : bit_size(LLDB_INVALID_ADDRESS), bit_offset(LLDB_INVALID_ADDRESS) {}
+ FieldInfo() = default;
- void Clear() {
- bit_size = LLDB_INVALID_ADDRESS;
- bit_offset = LLDB_INVALID_ADDRESS;
- }
-
- bool IsValid() const {
- return (bit_size != LLDB_INVALID_ADDRESS) &&
- (bit_offset != LLDB_INVALID_ADDRESS);
- }
+ void SetIsBitfield(bool flag) { is_bitfield = flag; }
+ bool IsBitfield() { return is_bitfield; }
bool NextBitfieldOffsetIsValid(const uint64_t next_bit_offset) const {
- if (IsValid()) {
- // This bitfield info is valid, so any subsequent bitfields must not
- // overlap and must be at a higher bit offset than any previous bitfield
- // + size.
- return (bit_size + bit_offset) <= next_bit_offset;
- } else {
- // If the this BitfieldInfo is not valid, then any offset isOK
- return true;
- }
+ // Any subsequent bitfields must not overlap and must be at a higher
+ // bit offset than any previous bitfield + size.
+ return (bit_size + bit_offset) <= next_bit_offset;
}
};
void
ParseSingleMember(const DWARFDIE &die, const DWARFDIE &parent_die,
- lldb_private::CompilerType &class_clang_type,
- const lldb::LanguageType class_language,
+ const lldb_private::CompilerType &class_clang_type,
std::vector<int> &member_accessibilities,
- lldb::AccessType &default_accessibility,
+ lldb::AccessType default_accessibility,
DelayedPropertyList &delayed_properties,
lldb_private::ClangASTImporter::LayoutInfo &layout_info,
- BitfieldInfo &last_field_info);
+ FieldInfo &last_field_info);
bool CompleteRecordType(const DWARFDIE &die, lldb_private::Type *type,
lldb_private::CompilerType &clang_type);
@@ -227,6 +217,12 @@ private:
ParsedDWARFTypeAttributes &attrs);
lldb::TypeSP ParsePointerToMemberType(const DWARFDIE &die,
const ParsedDWARFTypeAttributes &attrs);
+
+ /// Complete a type from debug info, or mark it as forcefully completed if
+ /// there is no of the type in the current Module. Call this function in
+ /// contexts where the usual C++ rules require a type to be complete (base
+ /// class, member, etc.).
+ void CompleteType(lldb_private::CompilerType type);
};
/// Parsed form of all attributes that are relevant for type reconstruction.
@@ -264,4 +260,4 @@ struct ParsedDWARFTypeAttributes {
uint32_t encoding = 0;
};
-#endif // SymbolFileDWARF_DWARFASTParserClang_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSERCLANG_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
index 741669b05754..0e9370be15fb 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFAbbreviationDeclaration.cpp ------------------------*- C++ -*-===//
+//===-- DWARFAbbreviationDeclaration.cpp ----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h
index c0cf8823a368..f70aa71a5958 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DWARFAbbreviationDeclaration_h_
-#define liblldb_DWARFAbbreviationDeclaration_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFABBREVIATIONDECLARATION_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFABBREVIATIONDECLARATION_H
#include "DWARFAttribute.h"
#include "DWARFDefines.h"
@@ -62,4 +62,4 @@ protected:
DWARFAttribute::collection m_attributes;
};
-#endif // liblldb_DWARFAbbreviationDeclaration_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFABBREVIATIONDECLARATION_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
index b3594a455680..6c72d9e26221 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFAttribute.cpp --------------------------------------*- C++ -*-===//
+//===-- DWARFAttribute.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
index 58427b19100a..9948969f108f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_DWARFAttribute_h_
-#define SymbolFileDWARF_DWARFAttribute_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFATTRIBUTE_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFATTRIBUTE_H
#include "DWARFDefines.h"
#include "DWARFFormValue.h"
@@ -82,4 +82,4 @@ protected:
collection m_infos;
};
-#endif // SymbolFileDWARF_DWARFAttribute_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFATTRIBUTE_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
index 033105efdc53..fcb424029f5a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFBaseDIE.cpp ---------------------------------------*- C++ -*-===//
+//===-- DWARFBaseDIE.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -74,13 +74,6 @@ const char *DWARFBaseDIE::GetName() const {
return nullptr;
}
-lldb::LanguageType DWARFBaseDIE::GetLanguage() const {
- if (IsValid())
- return m_cu->GetLanguageType();
- else
- return lldb::eLanguageTypeUnknown;
-}
-
lldb::ModuleSP DWARFBaseDIE::GetModule() const {
SymbolFileDWARF *dwarf = GetDWARF();
if (dwarf)
@@ -103,24 +96,6 @@ SymbolFileDWARF *DWARFBaseDIE::GetDWARF() const {
return nullptr;
}
-llvm::Expected<lldb_private::TypeSystem &> DWARFBaseDIE::GetTypeSystem() const {
- if (!m_cu)
- return llvm::make_error<llvm::StringError>(
- "Unable to get TypeSystem, no compilation unit available",
- llvm::inconvertibleErrorCode());
- return m_cu->GetTypeSystem();
-}
-
-DWARFASTParser *DWARFBaseDIE::GetDWARFParser() const {
- auto type_system_or_err = GetTypeSystem();
- if (auto err = type_system_or_err.takeError()) {
- LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_SYMBOLS),
- std::move(err), "Unable to get DWARFASTParser");
- return nullptr;
- }
- return type_system_or_err->GetDWARFParser();
-}
-
bool DWARFBaseDIE::HasChildren() const {
return m_die && m_die->HasChildren();
}
@@ -130,11 +105,10 @@ bool DWARFBaseDIE::Supports_DW_AT_APPLE_objc_complete_type() const {
}
size_t DWARFBaseDIE::GetAttributes(DWARFAttributes &attributes,
- uint32_t depth) const {
+ Recurse recurse) const {
if (IsValid())
- return m_die->GetAttributes(m_cu, attributes, depth);
- if (depth == 0)
- attributes.Clear();
+ return m_die->GetAttributes(m_cu, attributes, recurse);
+ attributes.Clear();
return 0;
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
index 9652d7946e87..059b84864be7 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_DWARFBaseDIE_h_
-#define SymbolFileDWARF_DWARFBaseDIE_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFBASEDIE_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFBASEDIE_H
#include "lldb/Core/dwarf.h"
#include "lldb/lldb-types.h"
@@ -57,10 +57,6 @@ public:
llvm::Optional<DIERef> GetDIERef() const;
- llvm::Expected<lldb_private::TypeSystem &> GetTypeSystem() const;
-
- DWARFASTParser *GetDWARFParser() const;
-
void Set(DWARFUnit *cu, DWARFDebugInfoEntry *die) {
if (cu && die) {
m_cu = cu;
@@ -98,8 +94,6 @@ public:
const char *GetName() const;
- lldb::LanguageType GetLanguage() const;
-
lldb::ModuleSP GetModule() const;
// Getting attribute values from the DIE.
@@ -116,7 +110,9 @@ public:
uint64_t GetAttributeValueAsAddress(const dw_attr_t attr,
uint64_t fail_value) const;
- size_t GetAttributes(DWARFAttributes &attributes, uint32_t depth = 0) const;
+ enum class Recurse : bool { no, yes };
+ size_t GetAttributes(DWARFAttributes &attributes,
+ Recurse recurse = Recurse::yes) const;
protected:
DWARFUnit *m_cu;
@@ -126,4 +122,4 @@ protected:
bool operator==(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs);
bool operator!=(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs);
-#endif // SymbolFileDWARF_DWARFBaseDIE_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFBASEDIE_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
index 718f0537d6ed..f54fe0662aa2 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFCompileUnit.cpp ------------------------------------*- C++ -*-===//
+//===-- DWARFCompileUnit.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -33,41 +33,27 @@ void DWARFCompileUnit::BuildAddressRangeTable(
size_t num_debug_aranges = debug_aranges->GetNumRanges();
- // First get the compile unit DIE only and check if it has a DW_AT_ranges
+ // First get the compile unit DIE only and check contains ranges information.
const DWARFDebugInfoEntry *die = GetUnitDIEPtrOnly();
const dw_offset_t cu_offset = GetOffset();
if (die) {
DWARFRangeList ranges;
const size_t num_ranges =
- die->GetAttributeAddressRanges(this, ranges, false);
+ die->GetAttributeAddressRanges(this, ranges, /*check_hi_lo_pc=*/true);
if (num_ranges > 0) {
- // This compile unit has DW_AT_ranges, assume this is correct if it is
- // present since clang no longer makes .debug_aranges by default and it
- // emits DW_AT_ranges for DW_TAG_compile_units. GCC also does this with
- // recent GCC builds.
for (size_t i = 0; i < num_ranges; ++i) {
const DWARFRangeList::Entry &range = ranges.GetEntryRef(i);
debug_aranges->AppendRange(cu_offset, range.GetRangeBase(),
range.GetRangeEnd());
}
- return; // We got all of our ranges from the DW_AT_ranges attribute
+ return;
}
}
- // We don't have a DW_AT_ranges attribute, so we need to parse the DWARF
-
- // If the DIEs weren't parsed, then we don't want all dies for all compile
- // units to stay loaded when they weren't needed. So we can end up parsing
- // the DWARF and then throwing them all away to keep memory usage down.
- ScopedExtractDIEs clear_dies(ExtractDIEsScoped());
-
- die = DIEPtr();
- if (die)
- die->BuildAddressRangeTable(this, debug_aranges);
if (debug_aranges->GetNumRanges() == num_debug_aranges) {
- // We got nothing from the functions, maybe we have a line tables only
+ // We got nothing from the debug info, maybe we have a line tables only
// situation. Check the line tables and build the arange table from this.
SymbolContext sc;
sc.comp_unit = m_dwarf.GetCompUnitForDWARFCompUnit(*this);
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
index 454637ef981c..3ec161f7dd51 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_DWARFCompileUnit_h_
-#define SymbolFileDWARF_DWARFCompileUnit_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFCOMPILEUNIT_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFCOMPILEUNIT_H
#include "DWARFUnit.h"
#include "llvm/Support/Error.h"
@@ -27,9 +27,10 @@ private:
DIERef::Section section, bool is_dwo)
: DWARFUnit(dwarf, uid, header, abbrevs, section, is_dwo) {}
- DISALLOW_COPY_AND_ASSIGN(DWARFCompileUnit);
+ DWARFCompileUnit(const DWARFCompileUnit &) = delete;
+ const DWARFCompileUnit &operator=(const DWARFCompileUnit &) = delete;
friend class DWARFUnit;
};
-#endif // SymbolFileDWARF_DWARFCompileUnit_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFCOMPILEUNIT_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
index 5052b825fea6..37e28a09f3c4 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFContext.cpp ----------------------------------------*- C++ -*-===//
+//===-- DWARFContext.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -28,18 +28,28 @@ static DWARFDataExtractor LoadSection(SectionList *section_list,
}
const DWARFDataExtractor &
-DWARFContext::LoadOrGetSection(SectionType main_section_type,
+DWARFContext::LoadOrGetSection(llvm::Optional<SectionType> main_section_type,
llvm::Optional<SectionType> dwo_section_type,
SectionData &data) {
llvm::call_once(data.flag, [&] {
if (dwo_section_type && isDwo())
data.data = LoadSection(m_dwo_section_list, *dwo_section_type);
- else
- data.data = LoadSection(m_main_section_list, main_section_type);
+ else if (main_section_type)
+ data.data = LoadSection(m_main_section_list, *main_section_type);
});
return data.data;
}
+const DWARFDataExtractor &DWARFContext::getOrLoadCuIndexData() {
+ return LoadOrGetSection(llvm::None, eSectionTypeDWARFDebugCuIndex,
+ m_data_debug_cu_index);
+}
+
+const DWARFDataExtractor &DWARFContext::getOrLoadTuIndexData() {
+ return LoadOrGetSection(llvm::None, eSectionTypeDWARFDebugTuIndex,
+ m_data_debug_tu_index);
+}
+
const DWARFDataExtractor &DWARFContext::getOrLoadAbbrevData() {
return LoadOrGetSection(eSectionTypeDWARFDebugAbbrev,
eSectionTypeDWARFDebugAbbrevDwo, m_data_debug_abbrev);
@@ -117,32 +127,19 @@ llvm::DWARFContext &DWARFContext::GetAsLLVM() {
if (!m_llvm_context) {
llvm::StringMap<std::unique_ptr<llvm::MemoryBuffer>> section_map;
uint8_t addr_size = 0;
-
- auto AddSection = [&](Section &section) {
- DataExtractor section_data;
- section.GetSectionData(section_data);
-
+ auto AddSection = [&](llvm::StringRef name, DWARFDataExtractor data) {
// Set the address size the first time we see it.
if (addr_size == 0)
- addr_size = section_data.GetByteSize();
+ addr_size = data.GetAddressByteSize();
- llvm::StringRef data = llvm::toStringRef(section_data.GetData());
- llvm::StringRef name = section.GetName().GetStringRef();
- if (name.startswith("."))
- name = name.drop_front();
section_map.try_emplace(
- name, llvm::MemoryBuffer::getMemBuffer(data, name, false));
+ name, llvm::MemoryBuffer::getMemBuffer(toStringRef(data.GetData()),
+ name, false));
};
- if (m_main_section_list) {
- for (auto &section : *m_main_section_list)
- AddSection(*section);
- }
-
- if (m_dwo_section_list) {
- for (auto &section : *m_dwo_section_list)
- AddSection(*section);
- }
+ AddSection("debug_line_str", getOrLoadLineStrData());
+ AddSection("debug_cu_index", getOrLoadCuIndexData());
+ AddSection("debug_tu_index", getOrLoadTuIndexData());
m_llvm_context = llvm::DWARFContext::create(section_map, addr_size);
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
index 8691001b1b76..92161a21d167 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_PLUGINS_SYMBOLFILE_DWARF_DWARFCONTEXT_H
-#define LLDB_PLUGINS_SYMBOLFILE_DWARF_DWARFCONTEXT_H
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFCONTEXT_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFCONTEXT_H
#include "DWARFDataExtractor.h"
#include "lldb/Core/Section.h"
@@ -31,6 +31,7 @@ private:
SectionData m_data_debug_abbrev;
SectionData m_data_debug_addr;
SectionData m_data_debug_aranges;
+ SectionData m_data_debug_cu_index;
SectionData m_data_debug_info;
SectionData m_data_debug_line;
SectionData m_data_debug_line_str;
@@ -41,13 +42,17 @@ private:
SectionData m_data_debug_rnglists;
SectionData m_data_debug_str;
SectionData m_data_debug_str_offsets;
+ SectionData m_data_debug_tu_index;
SectionData m_data_debug_types;
const DWARFDataExtractor &
- LoadOrGetSection(lldb::SectionType main_section_type,
+ LoadOrGetSection(llvm::Optional<lldb::SectionType> main_section_type,
llvm::Optional<lldb::SectionType> dwo_section_type,
SectionData &data);
+ const DWARFDataExtractor &getOrLoadCuIndexData();
+ const DWARFDataExtractor &getOrLoadTuIndexData();
+
public:
explicit DWARFContext(SectionList *main_section_list,
SectionList *dwo_section_list)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
index c5411a17f274..8e995e627978 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFDIE.cpp --------------------------------------------*- C++ -*-===//
+//===-- DWARFDIE.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -32,7 +32,7 @@ class ElaboratingDIEIterator
// Container sizes are optimized for the case of following DW_AT_specification
// and DW_AT_abstract_origin just once.
llvm::SmallVector<DWARFDIE, 2> m_worklist;
- llvm::SmallSet<lldb::user_id_t, 3> m_seen;
+ llvm::SmallSet<DWARFDebugInfoEntry *, 3> m_seen;
void Next() {
assert(!m_worklist.empty() && "Incrementing end iterator?");
@@ -44,7 +44,7 @@ class ElaboratingDIEIterator
// And add back any items that elaborate it.
for (dw_attr_t attr : {DW_AT_specification, DW_AT_abstract_origin}) {
if (DWARFDIE d = die.GetReferencedDIE(attr))
- if (m_seen.insert(die.GetID()).second)
+ if (m_seen.insert(die.GetDIE()).second)
m_worklist.push_back(d);
}
}
@@ -140,25 +140,64 @@ DWARFDIE::GetAttributeValueAsReferenceDIE(const dw_attr_t attr) const {
}
DWARFDIE
-DWARFDIE::LookupDeepestBlock(lldb::addr_t file_addr) const {
- if (IsValid()) {
- SymbolFileDWARF *dwarf = GetDWARF();
- DWARFUnit *cu = GetCU();
- DWARFDebugInfoEntry *function_die = nullptr;
- DWARFDebugInfoEntry *block_die = nullptr;
- if (m_die->LookupAddress(file_addr, cu, &function_die, &block_die)) {
- if (block_die && block_die != function_die) {
- if (cu->ContainsDIEOffset(block_die->GetOffset()))
- return DWARFDIE(cu, block_die);
- else
- return DWARFDIE(dwarf->DebugInfo()->GetUnit(DIERef(
- cu->GetSymbolFileDWARF().GetDwoNum(),
- cu->GetDebugSection(), block_die->GetOffset())),
- block_die);
+DWARFDIE::LookupDeepestBlock(lldb::addr_t address) const {
+ if (!IsValid())
+ return DWARFDIE();
+
+ DWARFDIE result;
+ bool check_children = false;
+ bool match_addr_range = false;
+ switch (Tag()) {
+ case DW_TAG_class_type:
+ case DW_TAG_namespace:
+ case DW_TAG_structure_type:
+ case DW_TAG_common_block:
+ check_children = true;
+ break;
+ case DW_TAG_compile_unit:
+ case DW_TAG_module:
+ case DW_TAG_catch_block:
+ case DW_TAG_subprogram:
+ case DW_TAG_try_block:
+ case DW_TAG_partial_unit:
+ match_addr_range = true;
+ break;
+ case DW_TAG_lexical_block:
+ case DW_TAG_inlined_subroutine:
+ check_children = true;
+ match_addr_range = true;
+ break;
+ default:
+ break;
+ }
+
+ if (match_addr_range) {
+ DWARFRangeList ranges;
+ if (m_die->GetAttributeAddressRanges(m_cu, ranges,
+ /*check_hi_lo_pc=*/true) &&
+ ranges.FindEntryThatContains(address)) {
+ check_children = true;
+ switch (Tag()) {
+ default:
+ break;
+
+ case DW_TAG_inlined_subroutine: // Inlined Function
+ case DW_TAG_lexical_block: // Block { } in code
+ result = *this;
+ break;
}
+ } else {
+ check_children = false;
}
}
- return DWARFDIE();
+
+ if (check_children) {
+ for (DWARFDIE child = GetFirstChild(); child; child = child.GetSibling()) {
+ if (DWARFDIE child_result = child.LookupDeepestBlock(address))
+ return child_result;
+ }
+ }
+ return result;
}
const char *DWARFDIE::GetMangledName() const {
@@ -333,15 +372,6 @@ std::vector<DWARFDIE> DWARFDIE::GetDeclContextDIEs() const {
return result;
}
-void DWARFDIE::GetDWARFDeclContext(DWARFDeclContext &dwarf_decl_ctx) const {
- if (IsValid()) {
- dwarf_decl_ctx.SetLanguage(GetLanguage());
- m_die->GetDWARFDeclContext(GetCU(), dwarf_decl_ctx);
- } else {
- dwarf_decl_ctx.Clear();
- }
-}
-
void DWARFDIE::GetDeclContext(
llvm::SmallVectorImpl<lldb_private::CompilerContext> &context) const {
const dw_tag_t tag = Tag();
@@ -418,27 +448,3 @@ bool DWARFDIE::GetDIENamesAndRanges(
} else
return false;
}
-
-CompilerDecl DWARFDIE::GetDecl() const {
- DWARFASTParser *dwarf_ast = GetDWARFParser();
- if (dwarf_ast)
- return dwarf_ast->GetDeclForUIDFromDWARF(*this);
- else
- return CompilerDecl();
-}
-
-CompilerDeclContext DWARFDIE::GetDeclContext() const {
- DWARFASTParser *dwarf_ast = GetDWARFParser();
- if (dwarf_ast)
- return dwarf_ast->GetDeclContextForUIDFromDWARF(*this);
- else
- return CompilerDeclContext();
-}
-
-CompilerDeclContext DWARFDIE::GetContainingDeclContext() const {
- DWARFASTParser *dwarf_ast = GetDWARFParser();
- if (dwarf_ast)
- return dwarf_ast->GetDeclContextContainingUIDFromDWARF(*this);
- else
- return CompilerDeclContext();
-}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
index 87d52eee9dd9..13737280926c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_DWARFDIE_h_
-#define SymbolFileDWARF_DWARFDIE_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDIE_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDIE_H
#include "DWARFBaseDIE.h"
#include "llvm/ADT/SmallSet.h"
@@ -70,8 +70,6 @@ public:
// DeclContext related functions
std::vector<DWARFDIE> GetDeclContextDIEs() const;
- void GetDWARFDeclContext(DWARFDeclContext &dwarf_decl_ctx) const;
-
/// Return this DIE's decl context as it is needed to look up types
/// in Clang's -gmodules debug info format.
void GetDeclContext(
@@ -90,14 +88,6 @@ public:
int &decl_line, int &decl_column, int &call_file,
int &call_line, int &call_column,
lldb_private::DWARFExpression *frame_base) const;
-
- // CompilerDecl related functions
-
- lldb_private::CompilerDecl GetDecl() const;
-
- lldb_private::CompilerDeclContext GetDeclContext() const;
-
- lldb_private::CompilerDeclContext GetContainingDeclContext() const;
};
-#endif // SymbolFileDWARF_DWARFDIE_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDIE_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
index 1678b228137f..cf483286a66d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFDataExtractor.cpp ----------------------------------*- C++ -*-===//
+//===-- DWARFDataExtractor.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -23,8 +23,7 @@ DWARFDataExtractor::GetDWARFOffset(lldb::offset_t *offset_ptr) const {
llvm::DWARFDataExtractor DWARFDataExtractor::GetAsLLVM() const {
return llvm::DWARFDataExtractor(
- llvm::StringRef(reinterpret_cast<const char *>(GetDataStart()),
- GetByteSize()),
+ llvm::makeArrayRef(GetDataStart(), GetByteSize()),
GetByteOrder() == lldb::eByteOrderLittle, GetAddressByteSize());
}
} // namespace lldb_private
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
index 22db5e8c0b79..df92bd45d5cc 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_DWARFDataExtractor_h_
-#define liblldb_DWARFDataExtractor_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDATAEXTRACTOR_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDATAEXTRACTOR_H
#include "lldb/Core/dwarf.h"
#include "lldb/Utility/DataExtractor.h"
@@ -34,4 +34,4 @@ public:
};
}
-#endif // liblldb_DWARFDataExtractor_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDATAEXTRACTOR_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
index 26301566a8e1..0f0f50a645db 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFDebugAbbrev.cpp ------------------------------------*- C++ -*-===//
+//===-- DWARFDebugAbbrev.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h
index 9c4729326081..555864f44967 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_DWARFDebugAbbrev_h_
-#define SymbolFileDWARF_DWARFDebugAbbrev_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGABBREV_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGABBREV_H
#include <list>
#include <map>
@@ -78,4 +78,4 @@ protected:
mutable DWARFAbbreviationDeclarationCollMapConstIter m_prev_abbr_offset_pos;
};
-#endif // SymbolFileDWARF_DWARFDebugAbbrev_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGABBREV_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
index 86ce3b329b25..728cefe620a5 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFDebugArangeSet.cpp ---------------------------------*- C++ -*-===//
+//===-- DWARFDebugArangeSet.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -63,7 +63,8 @@ llvm::Error DWARFDebugArangeSet::extract(const DWARFDataExtractor &data,
// 1 - the version looks good
// 2 - the address byte size looks plausible
// 3 - the length seems to make sense
- // size looks plausible
+ // 4 - size looks plausible
+ // 5 - the arange tuples do not contain a segment field
if (m_header.version < 2 || m_header.version > 5)
return llvm::make_error<llvm::object::GenericBinaryError>(
"Invalid arange header version");
@@ -81,6 +82,10 @@ llvm::Error DWARFDebugArangeSet::extract(const DWARFDataExtractor &data,
return llvm::make_error<llvm::object::GenericBinaryError>(
"Invalid arange header length");
+ if (m_header.seg_size)
+ return llvm::make_error<llvm::object::GenericBinaryError>(
+ "segmented arange entries are not supported");
+
// The first tuple following the header in each set begins at an offset
// that is a multiple of the size of a single tuple (that is, twice the
// size of an address). The header is padded, if necessary, to the
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h
index db0cf22a3f45..6b5b69a70a80 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_DWARFDebugArangeSet_h_
-#define SymbolFileDWARF_DWARFDebugArangeSet_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGARANGESET_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGARANGESET_H
#include "lldb/Core/dwarf.h"
#include <cstdint>
@@ -59,4 +59,4 @@ protected:
DescriptorColl m_arange_descriptors;
};
-#endif // SymbolFileDWARF_DWARFDebugArangeSet_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGARANGESET_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
index c8da2381353e..7dc52c1e2df0 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFDebugAranges.cpp -----------------------------------*- C++ -*-===//
+//===-- DWARFDebugAranges.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
index 74ba011b27af..96e82619f985 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_DWARFDebugAranges_h_
-#define SymbolFileDWARF_DWARFDebugAranges_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGARANGES_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGARANGES_H
#include "lldb/Core/dwarf.h"
#include "lldb/Utility/RangeMap.h"
@@ -52,4 +52,4 @@ protected:
RangeToDIE m_aranges;
};
-#endif // SymbolFileDWARF_DWARFDebugAranges_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGARANGES_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
index 1e04baca2c58..874978bf1398 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFDebugInfo.cpp --------------------------------------*- C++ -*-===//
+//===-- DWARFDebugInfo.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -72,10 +72,16 @@ void DWARFDebugInfo::ParseUnitsFor(DIERef::Section section) {
DWARFDataExtractor data = section == DIERef::Section::DebugTypes
? m_context.getOrLoadDebugTypesData()
: m_context.getOrLoadDebugInfoData();
+ const llvm::DWARFUnitIndex *index = nullptr;
+ if (m_context.isDwo())
+ index = &llvm::getDWARFUnitIndex(m_context.GetAsLLVM(),
+ section == DIERef::Section::DebugTypes
+ ? llvm::DW_SECT_EXT_TYPES
+ : llvm::DW_SECT_INFO);
lldb::offset_t offset = 0;
while (data.ValidOffset(offset)) {
- llvm::Expected<DWARFUnitSP> unit_sp =
- DWARFUnit::extract(m_dwarf, m_units.size(), data, section, &offset);
+ llvm::Expected<DWARFUnitSP> unit_sp = DWARFUnit::extract(
+ m_dwarf, m_units.size(), data, section, &offset, index);
if (!unit_sp) {
// FIXME: Propagate this error up.
@@ -96,12 +102,11 @@ void DWARFDebugInfo::ParseUnitsFor(DIERef::Section section) {
}
void DWARFDebugInfo::ParseUnitHeadersIfNeeded() {
- if (!m_units.empty())
- return;
-
- ParseUnitsFor(DIERef::Section::DebugInfo);
- ParseUnitsFor(DIERef::Section::DebugTypes);
- llvm::sort(m_type_hash_to_unit_index, llvm::less_first());
+ llvm::call_once(m_units_once_flag, [&] {
+ ParseUnitsFor(DIERef::Section::DebugInfo);
+ ParseUnitsFor(DIERef::Section::DebugTypes);
+ llvm::sort(m_type_hash_to_unit_index, llvm::less_first());
+ });
}
size_t DWARFDebugInfo::GetNumUnits() {
@@ -109,7 +114,7 @@ size_t DWARFDebugInfo::GetNumUnits() {
return m_units.size();
}
-DWARFUnit *DWARFDebugInfo::GetUnitAtIndex(user_id_t idx) {
+DWARFUnit *DWARFDebugInfo::GetUnitAtIndex(size_t idx) {
DWARFUnit *cu = nullptr;
if (idx < GetNumUnits())
cu = m_units[idx].get();
@@ -191,7 +196,7 @@ DWARFDIE
DWARFDebugInfo::GetDIE(const DIERef &die_ref) {
DWARFUnit *cu = GetUnit(die_ref);
if (cu)
- return cu->GetDIE(die_ref.die_offset());
+ return cu->GetNonSkeletonUnit().GetDIE(die_ref.die_offset());
return DWARFDIE(); // Not found
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
index 056cf33a202f..bdc718a5c2fa 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_DWARFDebugInfo_h_
-#define SymbolFileDWARF_DWARFDebugInfo_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGINFO_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGINFO_H
#include <map>
#include <vector>
@@ -35,7 +35,7 @@ public:
lldb_private::DWARFContext &context);
size_t GetNumUnits();
- DWARFUnit *GetUnitAtIndex(lldb::user_id_t idx);
+ DWARFUnit *GetUnitAtIndex(size_t idx);
DWARFUnit *GetUnitAtOffset(DIERef::Section section, dw_offset_t cu_offset,
uint32_t *idx_ptr = nullptr);
DWARFUnit *GetUnitContainingDIEOffset(DIERef::Section section,
@@ -61,7 +61,10 @@ protected:
SymbolFileDWARF &m_dwarf;
lldb_private::DWARFContext &m_context;
+
+ llvm::once_flag m_units_once_flag;
UnitColl m_units;
+
std::unique_ptr<DWARFDebugAranges>
m_cu_aranges_up; // A quick address to compile unit table
@@ -76,7 +79,8 @@ private:
uint32_t FindUnitIndex(DIERef::Section section, dw_offset_t offset);
- DISALLOW_COPY_AND_ASSIGN(DWARFDebugInfo);
+ DWARFDebugInfo(const DWARFDebugInfo &) = delete;
+ const DWARFDebugInfo &operator=(const DWARFDebugInfo &) = delete;
};
-#endif // SymbolFileDWARF_DWARFDebugInfo_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGINFO_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 320500fe608d..f6425a889da8 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFDebugInfoEntry.cpp ---------------------------------*- C++ -*-===//
+//===-- DWARFDebugInfoEntry.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -395,152 +395,14 @@ bool DWARFDebugInfoEntry::GetDIENamesAndRanges(
return !ranges.IsEmpty();
}
-// Dump
-//
-// Dumps a debug information entry and all of it's attributes to the specified
-// stream.
-void DWARFDebugInfoEntry::Dump(const DWARFUnit *cu, Stream &s,
- uint32_t recurse_depth) const {
- const DWARFDataExtractor &data = cu->GetData();
- lldb::offset_t offset = m_offset;
-
- if (data.ValidOffset(offset)) {
- dw_uleb128_t abbrCode = data.GetULEB128(&offset);
-
- s.Printf("\n0x%8.8x: ", m_offset);
- s.Indent();
- if (abbrCode != m_abbr_idx) {
- s.Printf("error: DWARF has been modified\n");
- } else if (abbrCode) {
- const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu);
- if (abbrevDecl) {
- s.PutCString(DW_TAG_value_to_name(abbrevDecl->Tag()));
- s.Printf(" [%u] %c\n", abbrCode, abbrevDecl->HasChildren() ? '*' : ' ');
-
- // Dump all data in the .debug_info/.debug_types for the attributes
- const uint32_t numAttributes = abbrevDecl->NumAttributes();
- for (uint32_t i = 0; i < numAttributes; ++i) {
- DWARFFormValue form_value(cu);
- dw_attr_t attr;
- abbrevDecl->GetAttrAndFormValueByIndex(i, attr, form_value);
-
- DumpAttribute(cu, data, &offset, s, attr, form_value);
- }
-
- const DWARFDebugInfoEntry *child = GetFirstChild();
- if (recurse_depth > 0 && child) {
- s.IndentMore();
-
- while (child) {
- child->Dump(cu, s, recurse_depth - 1);
- child = child->GetSibling();
- }
- s.IndentLess();
- }
- } else
- s.Printf("Abbreviation code note found in 'debug_abbrev' class for "
- "code: %u\n",
- abbrCode);
- } else {
- s.Printf("NULL\n");
- }
- }
-}
-
-// DumpAttribute
-//
-// Dumps a debug information entry attribute along with it's form. Any special
-// display of attributes is done (disassemble location lists, show enumeration
-// values for attributes, etc).
-void DWARFDebugInfoEntry::DumpAttribute(
- const DWARFUnit *cu, const DWARFDataExtractor &data,
- lldb::offset_t *offset_ptr, Stream &s, dw_attr_t attr,
- DWARFFormValue &form_value) {
- bool show_form = s.GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowForm);
-
- s.Printf(" ");
- s.Indent(DW_AT_value_to_name(attr));
-
- if (show_form) {
- s.Printf("[%s", DW_FORM_value_to_name(form_value.Form()));
- }
-
- if (!form_value.ExtractValue(data, offset_ptr))
- return;
-
- if (show_form) {
- if (form_value.Form() == DW_FORM_indirect) {
- s.Printf(" [%s]", DW_FORM_value_to_name(form_value.Form()));
- }
-
- s.PutCString("] ");
- }
-
- s.PutCString("( ");
-
- // Check to see if we have any special attribute formatters
- switch (attr) {
- case DW_AT_stmt_list:
- s.Printf("0x%8.8" PRIx64, form_value.Unsigned());
- break;
-
- case DW_AT_language:
- s.PutCString(DW_LANG_value_to_name(form_value.Unsigned()));
- break;
-
- case DW_AT_encoding:
- s.PutCString(DW_ATE_value_to_name(form_value.Unsigned()));
- break;
-
- case DW_AT_frame_base:
- case DW_AT_location:
- case DW_AT_data_member_location: {
- const uint8_t *blockData = form_value.BlockData();
- if (blockData) {
- // Location description is inlined in data in the form value
- DWARFDataExtractor locationData(data,
- (*offset_ptr) - form_value.Unsigned(),
- form_value.Unsigned());
- DWARFExpression::PrintDWARFExpression(
- s, locationData, DWARFUnit::GetAddressByteSize(cu), 4, false);
- } 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
- uint64_t debug_loc_offset = form_value.Unsigned();
- DWARFExpression::PrintDWARFLocationList(s, cu, cu->GetLocationData(),
- debug_loc_offset);
- }
- } break;
-
- case DW_AT_abstract_origin:
- case DW_AT_specification: {
- DWARFDIE abstract_die = form_value.Reference();
- form_value.Dump(s);
- // *ostrm_ptr << HEX32 << abstract_die.GetOffset() << " ( ";
- abstract_die.GetName(s);
- } break;
-
- case DW_AT_type: {
- DWARFDIE type_die = form_value.Reference();
- s.PutCString(" ( ");
- type_die.AppendTypeName(s);
- s.PutCString(" )");
- } break;
-
- default:
- break;
- }
-
- s.PutCString(" )\n");
-}
-
// Get all attribute values for a given DIE, including following any
// specification or abstract origin attributes and including those in the
// results. Any duplicate attributes will have the first instance take
// precedence (this can happen for declaration attributes).
-size_t DWARFDebugInfoEntry::GetAttributes(
- const DWARFUnit *cu, DWARFAttributes &attributes,
- uint32_t curr_depth) const {
+size_t DWARFDebugInfoEntry::GetAttributes(const DWARFUnit *cu,
+ DWARFAttributes &attributes,
+ Recurse recurse,
+ uint32_t curr_depth) const {
const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu);
if (abbrevDecl) {
const DWARFDataExtractor &data = cu->GetData();
@@ -571,11 +433,13 @@ size_t DWARFDebugInfoEntry::GetAttributes(
break;
}
- if ((attr == DW_AT_specification) || (attr == DW_AT_abstract_origin)) {
+ if (recurse == Recurse::yes &&
+ ((attr == DW_AT_specification) || (attr == DW_AT_abstract_origin))) {
if (form_value.ExtractValue(data, &offset)) {
DWARFDIE spec_die = form_value.Reference();
if (spec_die)
- spec_die.GetAttributes(attributes, curr_depth + 1);
+ spec_die.GetDIE()->GetAttributes(spec_die.GetCU(), attributes,
+ recurse, curr_depth + 1);
}
} else {
llvm::Optional<uint8_t> fixed_skip_size = DWARFFormValue::GetFixedSize(form, cu);
@@ -819,34 +683,9 @@ const char *DWARFDebugInfoEntry::GetPubname(const DWARFUnit *cu) const {
return name;
}
-// BuildAddressRangeTable
-void DWARFDebugInfoEntry::BuildAddressRangeTable(
- const DWARFUnit *cu, DWARFDebugAranges *debug_aranges) const {
- if (m_tag) {
- if (m_tag == DW_TAG_subprogram) {
- dw_addr_t lo_pc = LLDB_INVALID_ADDRESS;
- dw_addr_t hi_pc = LLDB_INVALID_ADDRESS;
- if (GetAttributeAddressRange(cu, lo_pc, hi_pc, LLDB_INVALID_ADDRESS)) {
- /// printf("BuildAddressRangeTable() 0x%8.8x: %30s: [0x%8.8x -
- /// 0x%8.8x)\n", m_offset, DW_TAG_value_to_name(tag), lo_pc, hi_pc);
- debug_aranges->AppendRange(cu->GetOffset(), lo_pc, hi_pc);
- }
- }
-
- const DWARFDebugInfoEntry *child = GetFirstChild();
- while (child) {
- child->BuildAddressRangeTable(cu, debug_aranges);
- child = child->GetSibling();
- }
- }
-}
-
-// BuildFunctionAddressRangeTable
-//
-// This function is very similar to the BuildAddressRangeTable function except
-// that the actual DIE offset for the function is placed in the table instead
-// of the compile unit offset (which is the way the standard .debug_aranges
-// section does it).
+/// This function is builds a table very similar to the standard .debug_aranges
+/// table, except that the actual DIE offset for the function is placed in the
+/// table instead of the compile unit offset.
void DWARFDebugInfoEntry::BuildFunctionAddressRangeTable(
const DWARFUnit *cu, DWARFDebugAranges *debug_aranges) const {
if (m_tag) {
@@ -854,8 +693,6 @@ void DWARFDebugInfoEntry::BuildFunctionAddressRangeTable(
dw_addr_t lo_pc = LLDB_INVALID_ADDRESS;
dw_addr_t hi_pc = LLDB_INVALID_ADDRESS;
if (GetAttributeAddressRange(cu, lo_pc, hi_pc, LLDB_INVALID_ADDRESS)) {
- // printf("BuildAddressRangeTable() 0x%8.8x: [0x%16.16" PRIx64 " -
- // 0x%16.16" PRIx64 ")\n", m_offset, lo_pc, hi_pc); // DEBUG ONLY
debug_aranges->AppendRange(GetOffset(), lo_pc, hi_pc);
}
}
@@ -868,25 +705,34 @@ void DWARFDebugInfoEntry::BuildFunctionAddressRangeTable(
}
}
-void DWARFDebugInfoEntry::GetDWARFDeclContext(
- DWARFUnit *cu, DWARFDeclContext &dwarf_decl_ctx) const {
- const dw_tag_t tag = Tag();
- if (tag != DW_TAG_compile_unit && tag != DW_TAG_partial_unit) {
- dwarf_decl_ctx.AppendDeclContext(tag, GetName(cu));
- DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE(cu);
- if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != this) {
- if (parent_decl_ctx_die.Tag() != DW_TAG_compile_unit &&
- parent_decl_ctx_die.Tag() != DW_TAG_partial_unit)
- parent_decl_ctx_die.GetDIE()->GetDWARFDeclContext(
- parent_decl_ctx_die.GetCU(), dwarf_decl_ctx);
- }
+DWARFDeclContext
+DWARFDebugInfoEntry::GetDWARFDeclContextStatic(const DWARFDebugInfoEntry *die,
+ DWARFUnit *cu) {
+ DWARFDeclContext dwarf_decl_ctx;
+ for (;;) {
+ const dw_tag_t tag = die->Tag();
+ if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit)
+ return dwarf_decl_ctx;
+ dwarf_decl_ctx.AppendDeclContext(tag, die->GetName(cu));
+ DWARFDIE parent_decl_ctx_die = die->GetParentDeclContextDIE(cu);
+ if (!parent_decl_ctx_die || parent_decl_ctx_die.GetDIE() == die)
+ return dwarf_decl_ctx;
+ if (parent_decl_ctx_die.Tag() == DW_TAG_compile_unit ||
+ parent_decl_ctx_die.Tag() == DW_TAG_partial_unit)
+ return dwarf_decl_ctx;
+ die = parent_decl_ctx_die.GetDIE();
+ cu = parent_decl_ctx_die.GetCU();
}
}
+DWARFDeclContext DWARFDebugInfoEntry::GetDWARFDeclContext(DWARFUnit *cu) const {
+ return GetDWARFDeclContextStatic(this, cu);
+}
+
DWARFDIE
DWARFDebugInfoEntry::GetParentDeclContextDIE(DWARFUnit *cu) const {
DWARFAttributes attributes;
- GetAttributes(cu, attributes);
+ GetAttributes(cu, attributes, Recurse::yes);
return GetParentDeclContextDIE(cu, attributes);
}
@@ -936,7 +782,7 @@ DWARFDebugInfoEntry::GetParentDeclContextDIE(
const char *DWARFDebugInfoEntry::GetQualifiedName(DWARFUnit *cu,
std::string &storage) const {
DWARFAttributes attributes;
- GetAttributes(cu, attributes);
+ GetAttributes(cu, attributes, Recurse::yes);
return GetQualifiedName(cu, attributes, storage);
}
@@ -993,209 +839,6 @@ DWARFDebugInfoEntry::GetQualifiedName(DWARFUnit *cu,
return storage.c_str();
}
-bool DWARFDebugInfoEntry::LookupAddress(const dw_addr_t address, DWARFUnit *cu,
- DWARFDebugInfoEntry **function_die,
- DWARFDebugInfoEntry **block_die) {
- bool found_address = false;
- if (m_tag) {
- bool check_children = false;
- bool match_addr_range = false;
- // printf("0x%8.8x: %30s: address = 0x%8.8x - ", m_offset,
- // DW_TAG_value_to_name(tag), address);
- switch (m_tag) {
- case DW_TAG_array_type:
- break;
- case DW_TAG_class_type:
- check_children = true;
- break;
- case DW_TAG_entry_point:
- case DW_TAG_enumeration_type:
- case DW_TAG_formal_parameter:
- case DW_TAG_imported_declaration:
- case DW_TAG_label:
- break;
- case DW_TAG_lexical_block:
- check_children = true;
- match_addr_range = true;
- break;
- case DW_TAG_member:
- case DW_TAG_pointer_type:
- case DW_TAG_reference_type:
- break;
- case DW_TAG_compile_unit:
- match_addr_range = true;
- break;
- case DW_TAG_string_type:
- break;
- case DW_TAG_structure_type:
- check_children = true;
- break;
- case DW_TAG_subroutine_type:
- case DW_TAG_typedef:
- case DW_TAG_union_type:
- case DW_TAG_unspecified_parameters:
- case DW_TAG_variant:
- break;
- case DW_TAG_common_block:
- check_children = true;
- break;
- case DW_TAG_common_inclusion:
- case DW_TAG_inheritance:
- break;
- case DW_TAG_inlined_subroutine:
- check_children = true;
- match_addr_range = true;
- break;
- case DW_TAG_module:
- match_addr_range = true;
- break;
- case DW_TAG_ptr_to_member_type:
- case DW_TAG_set_type:
- case DW_TAG_subrange_type:
- case DW_TAG_with_stmt:
- case DW_TAG_access_declaration:
- case DW_TAG_base_type:
- break;
- case DW_TAG_catch_block:
- match_addr_range = true;
- break;
- case DW_TAG_const_type:
- case DW_TAG_constant:
- case DW_TAG_enumerator:
- case DW_TAG_file_type:
- case DW_TAG_friend:
- case DW_TAG_namelist:
- case DW_TAG_namelist_item:
- case DW_TAG_packed_type:
- break;
- case DW_TAG_subprogram:
- match_addr_range = true;
- break;
- case DW_TAG_template_type_parameter:
- case DW_TAG_template_value_parameter:
- case DW_TAG_GNU_template_parameter_pack:
- case DW_TAG_thrown_type:
- break;
- case DW_TAG_try_block:
- match_addr_range = true;
- break;
- case DW_TAG_variant_part:
- case DW_TAG_variable:
- case DW_TAG_volatile_type:
- case DW_TAG_dwarf_procedure:
- case DW_TAG_restrict_type:
- case DW_TAG_interface_type:
- break;
- case DW_TAG_namespace:
- check_children = true;
- break;
- case DW_TAG_imported_module:
- case DW_TAG_unspecified_type:
- break;
- case DW_TAG_partial_unit:
- match_addr_range = true;
- break;
- case DW_TAG_imported_unit:
- case DW_TAG_shared_type:
- default:
- break;
- }
-
- if (match_addr_range) {
- dw_addr_t lo_pc =
- GetAttributeValueAsAddress(cu, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
- if (lo_pc != LLDB_INVALID_ADDRESS) {
- dw_addr_t hi_pc = GetAttributeHighPC(cu, lo_pc, LLDB_INVALID_ADDRESS);
- if (hi_pc != LLDB_INVALID_ADDRESS) {
- // printf("\n0x%8.8x: %30s: address = 0x%8.8x [0x%8.8x - 0x%8.8x) ",
- // m_offset, DW_TAG_value_to_name(tag), address, lo_pc, hi_pc);
- if ((lo_pc <= address) && (address < hi_pc)) {
- found_address = true;
- // puts("***MATCH***");
- switch (m_tag) {
- case DW_TAG_compile_unit: // File
- case DW_TAG_partial_unit: // File
- check_children =
- ((function_die != nullptr) || (block_die != nullptr));
- break;
-
- case DW_TAG_subprogram: // Function
- if (function_die)
- *function_die = this;
- check_children = (block_die != nullptr);
- break;
-
- case DW_TAG_inlined_subroutine: // Inlined Function
- case DW_TAG_lexical_block: // Block { } in code
- if (block_die) {
- *block_die = this;
- check_children = true;
- }
- break;
-
- default:
- check_children = true;
- break;
- }
- }
- } else {
- // Compile units may not have a valid high/low pc when there
- // are address gaps in subroutines so we must always search
- // if there is no valid high and low PC.
- check_children =
- (m_tag == DW_TAG_compile_unit || m_tag == DW_TAG_partial_unit) &&
- ((function_die != nullptr) || (block_die != nullptr));
- }
- } else {
- DWARFRangeList ranges;
- if (GetAttributeAddressRanges(cu, ranges, /*check_hi_lo_pc*/ false) &&
- ranges.FindEntryThatContains(address)) {
- found_address = true;
- // puts("***MATCH***");
- switch (m_tag) {
- case DW_TAG_compile_unit: // File
- case DW_TAG_partial_unit: // File
- check_children =
- ((function_die != nullptr) || (block_die != nullptr));
- break;
-
- case DW_TAG_subprogram: // Function
- if (function_die)
- *function_die = this;
- check_children = (block_die != nullptr);
- break;
-
- case DW_TAG_inlined_subroutine: // Inlined Function
- case DW_TAG_lexical_block: // Block { } in code
- if (block_die) {
- *block_die = this;
- check_children = true;
- }
- break;
-
- default:
- check_children = true;
- break;
- }
- } else {
- check_children = false;
- }
- }
- }
-
- if (check_children) {
- // printf("checking children\n");
- DWARFDebugInfoEntry *child = GetFirstChild();
- while (child) {
- if (child->LookupAddress(address, cu, function_die, block_die))
- return true;
- child = child->GetSibling();
- }
- }
- }
- return found_address;
-}
-
lldb::offset_t DWARFDebugInfoEntry::GetFirstAttributeOffset() const {
return GetOffset() + llvm::getULEB128Size(m_abbr_idx);
}
@@ -1210,6 +853,29 @@ DWARFDebugInfoEntry::GetAbbreviationDeclarationPtr(const DWARFUnit *cu) const {
return nullptr;
}
+bool DWARFDebugInfoEntry::IsGlobalOrStaticScopeVariable() const {
+ if (Tag() != DW_TAG_variable)
+ return false;
+ const DWARFDebugInfoEntry *parent_die = GetParent();
+ while (parent_die != nullptr) {
+ switch (parent_die->Tag()) {
+ case DW_TAG_subprogram:
+ case DW_TAG_lexical_block:
+ case DW_TAG_inlined_subroutine:
+ return false;
+
+ case DW_TAG_compile_unit:
+ case DW_TAG_partial_unit:
+ return true;
+
+ default:
+ break;
+ }
+ parent_die = parent_die->GetParent();
+ }
+ return false;
+}
+
bool DWARFDebugInfoEntry::operator==(const DWARFDebugInfoEntry &rhs) const {
return m_offset == rhs.m_offset && m_parent_idx == rhs.m_parent_idx &&
m_sibling_idx == rhs.m_sibling_idx &&
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
index f35af6e7d498..3019e1767f18 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -6,13 +6,14 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_DWARFDebugInfoEntry_h_
-#define SymbolFileDWARF_DWARFDebugInfoEntry_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGINFOENTRY_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGINFOENTRY_H
#include "SymbolFileDWARF.h"
#include "llvm/ADT/SmallVector.h"
#include "DWARFAbbreviationDeclaration.h"
+#include "DWARFBaseDIE.h"
#include "DWARFDebugAbbrev.h"
#include "DWARFDebugRanges.h"
#include <map>
@@ -41,23 +42,17 @@ public:
bool operator==(const DWARFDebugInfoEntry &rhs) const;
bool operator!=(const DWARFDebugInfoEntry &rhs) const;
- void BuildAddressRangeTable(const DWARFUnit *cu,
- DWARFDebugAranges *debug_aranges) const;
-
void BuildFunctionAddressRangeTable(const DWARFUnit *cu,
DWARFDebugAranges *debug_aranges) const;
bool Extract(const lldb_private::DWARFDataExtractor &data,
const DWARFUnit *cu, lldb::offset_t *offset_ptr);
- bool LookupAddress(const dw_addr_t address, DWARFUnit *cu,
- DWARFDebugInfoEntry **function_die,
- DWARFDebugInfoEntry **block_die);
-
- size_t GetAttributes(const DWARFUnit *cu,
- DWARFAttributes &attrs,
- uint32_t curr_depth = 0)
- const; // "curr_depth" for internal use only, don't set this yourself!!!
+ using Recurse = DWARFBaseDIE::Recurse;
+ size_t GetAttributes(const DWARFUnit *cu, DWARFAttributes &attrs,
+ Recurse recurse = Recurse::yes) const {
+ return GetAttributes(cu, attrs, recurse, 0 /* curr_depth */);
+ }
dw_offset_t
GetAttributeValue(const DWARFUnit *cu, const dw_attr_t attr,
@@ -106,15 +101,6 @@ public:
const char *GetQualifiedName(DWARFUnit *cu, const DWARFAttributes &attributes,
std::string &storage) const;
- void Dump(const DWARFUnit *cu, lldb_private::Stream &s,
- uint32_t recurse_depth) const;
-
- static void
- DumpAttribute(const DWARFUnit *cu,
- const lldb_private::DWARFDataExtractor &data,
- lldb::offset_t *offset_ptr, lldb_private::Stream &s,
- dw_attr_t attr, DWARFFormValue &form_value);
-
bool GetDIENamesAndRanges(
DWARFUnit *cu, const char *&name, const char *&mangled,
DWARFRangeList &rangeList, int &decl_file, int &decl_line,
@@ -162,8 +148,7 @@ public:
return HasChildren() ? this + 1 : nullptr;
}
- void GetDWARFDeclContext(DWARFUnit *cu,
- DWARFDeclContext &dwarf_decl_ctx) const;
+ DWARFDeclContext GetDWARFDeclContext(DWARFUnit *cu) const;
DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu) const;
DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu,
@@ -172,7 +157,15 @@ public:
void SetSiblingIndex(uint32_t idx) { m_sibling_idx = idx; }
void SetParentIndex(uint32_t idx) { m_parent_idx = idx; }
+ // This function returns true if the variable scope is either
+ // global or (file-static). It will return false for static variables
+ // that are local to a function, as they have local scope.
+ bool IsGlobalOrStaticScopeVariable() const;
+
protected:
+ static DWARFDeclContext
+ GetDWARFDeclContextStatic(const DWARFDebugInfoEntry *die, DWARFUnit *cu);
+
dw_offset_t m_offset; // Offset within the .debug_info/.debug_types
uint32_t m_parent_idx; // How many to subtract from "this" to get the parent.
// If zero this die has no parent
@@ -185,6 +178,10 @@ protected:
/// A copy of the DW_TAG value so we don't have to go through the compile
/// unit abbrev table
dw_tag_t m_tag = llvm::dwarf::DW_TAG_null;
+
+private:
+ size_t GetAttributes(const DWARFUnit *cu, DWARFAttributes &attrs,
+ Recurse recurse, uint32_t curr_depth) const;
};
-#endif // SymbolFileDWARF_DWARFDebugInfoEntry_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGINFOENTRY_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp
index 4238be7ec1c3..278950a9f336 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFDebugMacro.cpp -------------------------------------*- C++ -*-===//
+//===-- DWARFDebugMacro.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h
index c3a93a9f4d14..5c0338e950eb 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_DWARFDebugMacro_h_
-#define SymbolFileDWARF_DWARFDebugMacro_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGMACRO_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGMACRO_H
#include <map>
@@ -58,4 +58,4 @@ public:
lldb_private::DebugMacrosSP &debug_macros_sp);
};
-#endif // SymbolFileDWARF_DWARFDebugMacro_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGMACRO_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
index 6c074002cb20..6a0f11d2a1c4 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFDebugRanges.cpp ------------------------------------*- C++ -*-===//
+//===-- DWARFDebugRanges.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
index 1888a7760f27..b587845a67d9 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_DWARFDebugRanges_h_
-#define SymbolFileDWARF_DWARFDebugRanges_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGRANGES_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGRANGES_H
#include "lldb/Core/dwarf.h"
#include <map>
@@ -39,4 +39,4 @@ protected:
range_map m_range_map;
};
-#endif // SymbolFileDWARF_DWARFDebugRanges_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGRANGES_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
index a664314035e4..f4c8c14cc8af 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFDeclContext.cpp ------------------------------------*- C++ -*-===//
+//===-- DWARFDeclContext.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
index 348b33464a54..9072b2dc0115 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_DWARFDeclContext_h_
-#define SymbolFileDWARF_DWARFDeclContext_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDECLCONTEXT_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDECLCONTEXT_H
#include <string>
#include <vector>
@@ -48,6 +48,7 @@ public:
}
bool operator==(const DWARFDeclContext &rhs) const;
+ bool operator!=(const DWARFDeclContext &rhs) const { return !(*this == rhs); }
uint32_t GetSize() const { return m_entries.size(); }
@@ -85,4 +86,4 @@ protected:
lldb::LanguageType m_language;
};
-#endif // SymbolFileDWARF_DWARFDeclContext_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDECLCONTEXT_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp
index 2ae1bbc9f507..4e99a295ce50 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFDefines.cpp ----------------------------------------*- C++ -*-===//
+//===-- DWARFDefines.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -58,321 +58,6 @@ const char *DW_OP_value_to_name(uint32_t val) {
return llvmstr.data();
}
-DRC_class DW_OP_value_to_class(uint32_t val) {
- // FIXME: If we just used llvm's DWARFExpression printer, we could delete
- // all this code (and more in lldb's DWARFExpression.cpp).
- switch (val) {
- case 0x03:
- return DRC_ONEOPERAND;
- case 0x06:
- return DRC_ZEROOPERANDS;
- case 0x08:
- return DRC_ONEOPERAND;
- case 0x09:
- return DRC_ONEOPERAND;
- case 0x0a:
- return DRC_ONEOPERAND;
- case 0x0b:
- return DRC_ONEOPERAND;
- case 0x0c:
- return DRC_ONEOPERAND;
- case 0x0d:
- return DRC_ONEOPERAND;
- case 0x0e:
- return DRC_ONEOPERAND;
- case 0x0f:
- return DRC_ONEOPERAND;
- case 0x10:
- return DRC_ONEOPERAND;
- case 0x11:
- return DRC_ONEOPERAND;
- case 0x12:
- return DRC_ZEROOPERANDS;
- case 0x13:
- return DRC_ZEROOPERANDS;
- case 0x14:
- return DRC_ZEROOPERANDS;
- case 0x15:
- return DRC_ONEOPERAND;
- case 0x16:
- return DRC_ZEROOPERANDS;
- case 0x17:
- return DRC_ZEROOPERANDS;
- case 0x18:
- return DRC_ZEROOPERANDS;
- case 0x19:
- return DRC_ZEROOPERANDS;
- case 0x1a:
- return DRC_ZEROOPERANDS;
- case 0x1b:
- return DRC_ZEROOPERANDS;
- case 0x1c:
- return DRC_ZEROOPERANDS;
- case 0x1d:
- return DRC_ZEROOPERANDS;
- case 0x1e:
- return DRC_ZEROOPERANDS;
- case 0x1f:
- return DRC_ZEROOPERANDS;
- case 0x20:
- return DRC_ZEROOPERANDS;
- case 0x21:
- return DRC_ZEROOPERANDS;
- case 0x22:
- return DRC_ZEROOPERANDS;
- case 0x23:
- return DRC_ONEOPERAND;
- case 0x24:
- return DRC_ZEROOPERANDS;
- case 0x25:
- return DRC_ZEROOPERANDS;
- case 0x26:
- return DRC_ZEROOPERANDS;
- case 0x27:
- return DRC_ZEROOPERANDS;
- case 0x2f:
- return DRC_ONEOPERAND;
- case 0x28:
- return DRC_ONEOPERAND;
- case 0x29:
- return DRC_ZEROOPERANDS;
- case 0x2a:
- return DRC_ZEROOPERANDS;
- case 0x2b:
- return DRC_ZEROOPERANDS;
- case 0x2c:
- return DRC_ZEROOPERANDS;
- case 0x2d:
- return DRC_ZEROOPERANDS;
- case 0x2e:
- return DRC_ZEROOPERANDS;
- case 0x30:
- return DRC_ZEROOPERANDS;
- case 0x31:
- return DRC_ZEROOPERANDS;
- case 0x32:
- return DRC_ZEROOPERANDS;
- case 0x33:
- return DRC_ZEROOPERANDS;
- case 0x34:
- return DRC_ZEROOPERANDS;
- case 0x35:
- return DRC_ZEROOPERANDS;
- case 0x36:
- return DRC_ZEROOPERANDS;
- case 0x37:
- return DRC_ZEROOPERANDS;
- case 0x38:
- return DRC_ZEROOPERANDS;
- case 0x39:
- return DRC_ZEROOPERANDS;
- case 0x3a:
- return DRC_ZEROOPERANDS;
- case 0x3b:
- return DRC_ZEROOPERANDS;
- case 0x3c:
- return DRC_ZEROOPERANDS;
- case 0x3d:
- return DRC_ZEROOPERANDS;
- case 0x3e:
- return DRC_ZEROOPERANDS;
- case 0x3f:
- return DRC_ZEROOPERANDS;
- case 0x40:
- return DRC_ZEROOPERANDS;
- case 0x41:
- return DRC_ZEROOPERANDS;
- case 0x42:
- return DRC_ZEROOPERANDS;
- case 0x43:
- return DRC_ZEROOPERANDS;
- case 0x44:
- return DRC_ZEROOPERANDS;
- case 0x45:
- return DRC_ZEROOPERANDS;
- case 0x46:
- return DRC_ZEROOPERANDS;
- case 0x47:
- return DRC_ZEROOPERANDS;
- case 0x48:
- return DRC_ZEROOPERANDS;
- case 0x49:
- return DRC_ZEROOPERANDS;
- case 0x4a:
- return DRC_ZEROOPERANDS;
- case 0x4b:
- return DRC_ZEROOPERANDS;
- case 0x4c:
- return DRC_ZEROOPERANDS;
- case 0x4d:
- return DRC_ZEROOPERANDS;
- case 0x4e:
- return DRC_ZEROOPERANDS;
- case 0x4f:
- return DRC_ZEROOPERANDS;
- case 0x50:
- return DRC_ZEROOPERANDS;
- case 0x51:
- return DRC_ZEROOPERANDS;
- case 0x52:
- return DRC_ZEROOPERANDS;
- case 0x53:
- return DRC_ZEROOPERANDS;
- case 0x54:
- return DRC_ZEROOPERANDS;
- case 0x55:
- return DRC_ZEROOPERANDS;
- case 0x56:
- return DRC_ZEROOPERANDS;
- case 0x57:
- return DRC_ZEROOPERANDS;
- case 0x58:
- return DRC_ZEROOPERANDS;
- case 0x59:
- return DRC_ZEROOPERANDS;
- case 0x5a:
- return DRC_ZEROOPERANDS;
- case 0x5b:
- return DRC_ZEROOPERANDS;
- case 0x5c:
- return DRC_ZEROOPERANDS;
- case 0x5d:
- return DRC_ZEROOPERANDS;
- case 0x5e:
- return DRC_ZEROOPERANDS;
- case 0x5f:
- return DRC_ZEROOPERANDS;
- case 0x60:
- return DRC_ZEROOPERANDS;
- case 0x61:
- return DRC_ZEROOPERANDS;
- case 0x62:
- return DRC_ZEROOPERANDS;
- case 0x63:
- return DRC_ZEROOPERANDS;
- case 0x64:
- return DRC_ZEROOPERANDS;
- case 0x65:
- return DRC_ZEROOPERANDS;
- case 0x66:
- return DRC_ZEROOPERANDS;
- case 0x67:
- return DRC_ZEROOPERANDS;
- case 0x68:
- return DRC_ZEROOPERANDS;
- case 0x69:
- return DRC_ZEROOPERANDS;
- case 0x6a:
- return DRC_ZEROOPERANDS;
- case 0x6b:
- return DRC_ZEROOPERANDS;
- case 0x6c:
- return DRC_ZEROOPERANDS;
- case 0x6d:
- return DRC_ZEROOPERANDS;
- case 0x6e:
- return DRC_ZEROOPERANDS;
- case 0x6f:
- return DRC_ZEROOPERANDS;
- case 0x70:
- return DRC_ONEOPERAND;
- case 0x71:
- return DRC_ONEOPERAND;
- case 0x72:
- return DRC_ONEOPERAND;
- case 0x73:
- return DRC_ONEOPERAND;
- case 0x74:
- return DRC_ONEOPERAND;
- case 0x75:
- return DRC_ONEOPERAND;
- case 0x76:
- return DRC_ONEOPERAND;
- case 0x77:
- return DRC_ONEOPERAND;
- case 0x78:
- return DRC_ONEOPERAND;
- case 0x79:
- return DRC_ONEOPERAND;
- case 0x7a:
- return DRC_ONEOPERAND;
- case 0x7b:
- return DRC_ONEOPERAND;
- case 0x7c:
- return DRC_ONEOPERAND;
- case 0x7d:
- return DRC_ONEOPERAND;
- case 0x7e:
- return DRC_ONEOPERAND;
- case 0x7f:
- return DRC_ONEOPERAND;
- case 0x80:
- return DRC_ONEOPERAND;
- case 0x81:
- return DRC_ONEOPERAND;
- case 0x82:
- return DRC_ONEOPERAND;
- case 0x83:
- return DRC_ONEOPERAND;
- case 0x84:
- return DRC_ONEOPERAND;
- case 0x85:
- return DRC_ONEOPERAND;
- case 0x86:
- return DRC_ONEOPERAND;
- case 0x87:
- return DRC_ONEOPERAND;
- case 0x88:
- return DRC_ONEOPERAND;
- case 0x89:
- return DRC_ONEOPERAND;
- case 0x8a:
- return DRC_ONEOPERAND;
- case 0x8b:
- return DRC_ONEOPERAND;
- case 0x8c:
- return DRC_ONEOPERAND;
- case 0x8d:
- return DRC_ONEOPERAND;
- case 0x8e:
- return DRC_ONEOPERAND;
- case 0x8f:
- return DRC_ONEOPERAND;
- case 0x90:
- return DRC_ONEOPERAND;
- case 0x91:
- return DRC_ONEOPERAND;
- case 0x92:
- return DRC_TWOOPERANDS;
- case 0x93:
- return DRC_ONEOPERAND;
- case 0x94:
- return DRC_ONEOPERAND;
- case 0x95:
- return DRC_ONEOPERAND;
- case 0x96:
- return DRC_ZEROOPERANDS;
- case 0x97:
- return DRC_DWARFv3 | DRC_ZEROOPERANDS;
- case 0x98:
- return DRC_DWARFv3 | DRC_ONEOPERAND;
- case 0x99:
- return DRC_DWARFv3 | DRC_ONEOPERAND;
- case 0x9a:
- return DRC_DWARFv3 | DRC_ONEOPERAND;
- case 0xa3: /* DW_OP_entry_value */
- return DRC_TWOOPERANDS;
- case 0xf0:
- return DRC_ZEROOPERANDS; /* DW_OP_APPLE_uninit */
- case 0xe0:
- return 0;
- case 0xff:
- return 0;
- default:
- return 0;
- }
-}
-
const char *DW_ATE_value_to_name(uint32_t val) {
static char invalid[100];
llvm::StringRef llvmstr = llvm::dwarf::AttributeEncodingString(val);
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.h
index d16cb07baf88..1b7102cd7e31 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_DWARFDefines_h_
-#define SymbolFileDWARF_DWARFDefines_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEFINES_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEFINES_H
#include "lldb/Core/dwarf.h"
#include <stdint.h>
@@ -26,52 +26,12 @@ const char *DW_FORM_value_to_name(uint32_t val);
const char *DW_OP_value_to_name(uint32_t val);
-DRC_class DW_OP_value_to_class(uint32_t val);
-
const char *DW_ATE_value_to_name(uint32_t val);
const char *DW_LANG_value_to_name(uint32_t val);
const char *DW_LNS_value_to_name(uint32_t val);
-/* These DRC are entirely our own construction,
- although they are derived from various comments in the DWARF standard.
- Most of these are not useful to the parser, but the DW_AT and DW_FORM
- classes should prove to be usable in some fashion. */
-
-#define DRC_0x65 0x1
-#define DRC_ADDRESS 0x2
-#define DRC_BLOCK 0x4
-#define DRC_CONSTANT 0x8
-#define DRC_DWARFv3 0x10
-#define DRC_FLAG 0x20
-#define DRC_INDIRECT_SPECIAL 0x40
-#define DRC_LINEPTR 0x80
-#define DRC_LOCEXPR 0x100
-#define DRC_LOCLISTPTR 0x200
-#define DRC_MACPTR 0x400
-#define DRC_ONEOPERAND 0x800
-#define DRC_OPERANDONE_1BYTE_DELTA 0x1000
-#define DRC_OPERANDONE_2BYTE_DELTA 0x2000
-#define DRC_OPERANDONE_4BYTE_DELTA 0x4000
-#define DRC_OPERANDONE_ADDRESS 0x8000
-#define DRC_OPERANDONE_BLOCK 0x10000
-#define DRC_OPERANDONE_SLEB128_OFFSET 0x20000
-#define DRC_OPERANDONE_ULEB128_OFFSET 0x40000
-#define DRC_OPERANDONE_ULEB128_REGISTER 0x80000
-#define DRC_OPERANDTWO_BLOCK 0x100000
-#define DRC_OPERANDTWO_SLEB128_OFFSET 0x200000
-#define DRC_OPERANDTWO_ULEB128_OFFSET 0x400000
-#define DRC_OPERANDTWO_ULEB128_REGISTER 0x800000
-#define DRC_OPERNADONE_ULEB128_REGISTER 0x1000000
-#define DRC_RANGELISTPTR 0x2000000
-#define DRC_REFERENCE 0x4000000
-#define DRC_STRING 0x8000000
-#define DRC_TWOOPERANDS 0x10000000
-#define DRC_VENDOR_GNU 0x20000000
-#define DRC_VENDOR_MIPS 0x40000000
-#define DRC_ZEROOPERANDS 0x80000000
-
} // namespace lldb_private
-#endif // SymbolFileDWARF_DWARFDefines_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEFINES_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
index f660cc32b3f8..305f1cbd2826 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFFormValue.cpp --------------------------------------*- C++ -*-===//
+//===-- DWARFFormValue.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -454,40 +454,26 @@ void DWARFFormValue::Dump(Stream &s) const {
}
const char *DWARFFormValue::AsCString() const {
- SymbolFileDWARF &symbol_file = m_unit->GetSymbolFileDWARF();
+ DWARFContext &context = m_unit->GetSymbolFileDWARF().GetDWARFContext();
- if (m_form == DW_FORM_string) {
+ if (m_form == DW_FORM_string)
return m_value.value.cstr;
- } else if (m_form == DW_FORM_strp) {
- return symbol_file.GetDWARFContext().getOrLoadStrData().PeekCStr(
- m_value.value.uval);
- } else if (m_form == DW_FORM_GNU_str_index) {
- uint32_t index_size = 4;
- lldb::offset_t offset = m_value.value.uval * index_size;
- dw_offset_t str_offset =
- symbol_file.GetDWARFContext().getOrLoadStrOffsetsData().GetMaxU64(
- &offset, index_size);
- return symbol_file.GetDWARFContext().getOrLoadStrData().PeekCStr(
- str_offset);
- }
-
- if (m_form == DW_FORM_strx || m_form == DW_FORM_strx1 ||
- m_form == DW_FORM_strx2 || m_form == DW_FORM_strx3 ||
- m_form == DW_FORM_strx4) {
-
- // The same code as above.
- uint32_t indexSize = 4;
- lldb::offset_t offset =
- m_unit->GetStrOffsetsBase() + m_value.value.uval * indexSize;
- dw_offset_t strOffset =
- symbol_file.GetDWARFContext().getOrLoadStrOffsetsData().GetMaxU64(
- &offset, indexSize);
- return symbol_file.GetDWARFContext().getOrLoadStrData().PeekCStr(strOffset);
+ if (m_form == DW_FORM_strp)
+ return context.getOrLoadStrData().PeekCStr(m_value.value.uval);
+
+ if (m_form == DW_FORM_GNU_str_index || m_form == DW_FORM_strx ||
+ m_form == DW_FORM_strx1 || m_form == DW_FORM_strx2 ||
+ m_form == DW_FORM_strx3 || m_form == DW_FORM_strx4) {
+
+ llvm::Optional<uint64_t> offset =
+ m_unit->GetStringOffsetSectionItem(m_value.value.uval);
+ if (!offset)
+ return nullptr;
+ return context.getOrLoadStrData().PeekCStr(*offset);
}
if (m_form == DW_FORM_line_strp)
- return symbol_file.GetDWARFContext().getOrLoadLineStrData().PeekCStr(
- m_value.value.uval);
+ return context.getOrLoadLineStrData().PeekCStr(m_value.value.uval);
return nullptr;
}
@@ -531,7 +517,7 @@ DWARFDIE DWARFFormValue::Reference() const {
case DW_FORM_ref_addr: {
DWARFUnit *ref_cu =
- m_unit->GetSymbolFileDWARF().DebugInfo()->GetUnitContainingDIEOffset(
+ m_unit->GetSymbolFileDWARF().DebugInfo().GetUnitContainingDIEOffset(
DIERef::Section::DebugInfo, value);
if (!ref_cu) {
m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
@@ -544,7 +530,7 @@ DWARFDIE DWARFFormValue::Reference() const {
case DW_FORM_ref_sig8: {
DWARFTypeUnit *tu =
- m_unit->GetSymbolFileDWARF().DebugInfo()->GetTypeUnitForHash(value);
+ m_unit->GetSymbolFileDWARF().DebugInfo().GetTypeUnitForHash(value);
if (!tu)
return {};
return tu->GetDIE(tu->GetTypeOffset());
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
index 848db2990ded..b401352c693d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_DWARFFormValue_h_
-#define SymbolFileDWARF_DWARFFormValue_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFFORMVALUE_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFFORMVALUE_H
#include "DWARFDataExtractor.h"
#include <stddef.h>
@@ -86,4 +86,4 @@ protected:
ValueType m_value; // Contains all data for the form
};
-#endif // SymbolFileDWARF_DWARFFormValue_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFFORMVALUE_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
index c122f756e81a..683033d0ee4c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFIndex.cpp -----------------------------------------*- C++ -*-===//
+//===-- DWARFIndex.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -11,20 +11,21 @@
#include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
+#include "lldb/Core/Module.h"
+
using namespace lldb_private;
using namespace lldb;
DWARFIndex::~DWARFIndex() = default;
-void DWARFIndex::ProcessFunctionDIE(llvm::StringRef name, DIERef ref,
- SymbolFileDWARF &dwarf,
- const CompilerDeclContext &parent_decl_ctx,
- uint32_t name_type_mask,
- std::vector<DWARFDIE> &dies) {
+bool DWARFIndex::ProcessFunctionDIE(
+ llvm::StringRef name, DIERef ref, SymbolFileDWARF &dwarf,
+ const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask,
+ llvm::function_ref<bool(DWARFDIE die)> callback) {
DWARFDIE die = dwarf.GetDIE(ref);
if (!die) {
ReportInvalidDIERef(ref, name);
- return;
+ return true;
}
// Exit early if we're searching exclusively for methods or selectors and
@@ -32,26 +33,22 @@ void DWARFIndex::ProcessFunctionDIE(llvm::StringRef name, DIERef ref,
uint32_t looking_for_nonmethods =
name_type_mask & ~(eFunctionNameTypeMethod | eFunctionNameTypeSelector);
if (!looking_for_nonmethods && parent_decl_ctx.IsValid())
- return;
+ return true;
// Otherwise, we need to also check that the context matches. If it does not
// match, we do nothing.
- if (!SymbolFileDWARF::DIEInDeclContext(&parent_decl_ctx, die))
- return;
+ if (!SymbolFileDWARF::DIEInDeclContext(parent_decl_ctx, die))
+ return true;
// In case of a full match, we just insert everything we find.
- if (name_type_mask & eFunctionNameTypeFull) {
- dies.push_back(die);
- return;
- }
+ if (name_type_mask & eFunctionNameTypeFull)
+ return callback(die);
// If looking for ObjC selectors, we need to also check if the name is a
// possible selector.
if (name_type_mask & eFunctionNameTypeSelector &&
- ObjCLanguage::IsPossibleObjCMethodName(die.GetName())) {
- dies.push_back(die);
- return;
- }
+ ObjCLanguage::IsPossibleObjCMethodName(die.GetName()))
+ return callback(die);
bool looking_for_methods = name_type_mask & lldb::eFunctionNameTypeMethod;
bool looking_for_functions = name_type_mask & lldb::eFunctionNameTypeBase;
@@ -61,6 +58,29 @@ void DWARFIndex::ProcessFunctionDIE(llvm::StringRef name, DIERef ref,
// searching for.
if ((looking_for_methods && looking_for_functions) ||
looking_for_methods == die.IsMethod())
- dies.push_back(die);
+ return callback(die);
}
+
+ return true;
+}
+
+DWARFIndex::DIERefCallbackImpl::DIERefCallbackImpl(
+ const DWARFIndex &index, llvm::function_ref<bool(DWARFDIE die)> callback,
+ llvm::StringRef name)
+ : m_index(index),
+ m_dwarf(*llvm::cast<SymbolFileDWARF>(index.m_module.GetSymbolFile())),
+ m_callback(callback), m_name(name) {}
+
+bool DWARFIndex::DIERefCallbackImpl::operator()(DIERef ref) const {
+ if (DWARFDIE die = m_dwarf.GetDIE(ref))
+ return m_callback(die);
+ m_index.ReportInvalidDIERef(ref, m_name);
+ return true;
+}
+
+void DWARFIndex::ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const {
+ m_module.ReportErrorIfModifyDetected(
+ "the DWARF debug information has been modified (accelerator table had "
+ "bad die 0x%8.8x for '%s')\n",
+ ref.die_offset(), name.str().c_str());
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
index e3c7c5e63ac8..ecf82a910b66 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_DWARFINDEX_H
-#define LLDB_DWARFINDEX_H
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFINDEX_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFINDEX_H
#include "Plugins/SymbolFile/DWARF/DIERef.h"
#include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
@@ -27,26 +27,38 @@ public:
/// Finds global variables with the given base name. Any additional filtering
/// (e.g., to only retrieve variables from a given context) should be done by
/// the consumer.
- virtual void GetGlobalVariables(ConstString basename, DIEArray &offsets) = 0;
+ virtual void
+ GetGlobalVariables(ConstString basename,
+ llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
- virtual void GetGlobalVariables(const RegularExpression &regex,
- DIEArray &offsets) = 0;
- virtual void GetGlobalVariables(const DWARFUnit &cu, DIEArray &offsets) = 0;
- virtual void GetObjCMethods(ConstString class_name, DIEArray &offsets) = 0;
- virtual void GetCompleteObjCClass(ConstString class_name,
- bool must_be_implementation,
- DIEArray &offsets) = 0;
- virtual void GetTypes(ConstString name, DIEArray &offsets) = 0;
- virtual void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) = 0;
- virtual void GetNamespaces(ConstString name, DIEArray &offsets) = 0;
- virtual void GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
- const CompilerDeclContext &parent_decl_ctx,
- uint32_t name_type_mask,
- std::vector<DWARFDIE> &dies) = 0;
- virtual void GetFunctions(const RegularExpression &regex,
- DIEArray &offsets) = 0;
+ virtual void
+ GetGlobalVariables(const RegularExpression &regex,
+ llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
+ virtual void
+ GetGlobalVariables(const DWARFUnit &cu,
+ llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
+ virtual void
+ GetObjCMethods(ConstString class_name,
+ llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
+ virtual void
+ GetCompleteObjCClass(ConstString class_name, bool must_be_implementation,
+ llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
+ virtual void GetTypes(ConstString name,
+ llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
+ virtual void GetTypes(const DWARFDeclContext &context,
+ llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
+ virtual void
+ GetNamespaces(ConstString name,
+ llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
+ virtual void
+ GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
+ const CompilerDeclContext &parent_decl_ctx,
+ uint32_t name_type_mask,
+ llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
+ virtual void
+ GetFunctions(const RegularExpression &regex,
+ llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
- virtual void ReportInvalidDIERef(const DIERef &ref, llvm::StringRef name) = 0;
virtual void Dump(Stream &s) = 0;
protected:
@@ -56,11 +68,33 @@ protected:
/// the function given by "ref" matches search criteria given by
/// "parent_decl_ctx" and "name_type_mask", it is inserted into the "dies"
/// vector.
- void ProcessFunctionDIE(llvm::StringRef name, DIERef ref,
+ bool ProcessFunctionDIE(llvm::StringRef name, DIERef ref,
SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
- uint32_t name_type_mask, std::vector<DWARFDIE> &dies);
+ uint32_t name_type_mask,
+ llvm::function_ref<bool(DWARFDIE die)> callback);
+
+ class DIERefCallbackImpl {
+ public:
+ DIERefCallbackImpl(const DWARFIndex &index,
+ llvm::function_ref<bool(DWARFDIE die)> callback,
+ llvm::StringRef name);
+ bool operator()(DIERef ref) const;
+
+ private:
+ const DWARFIndex &m_index;
+ SymbolFileDWARF &m_dwarf;
+ const llvm::function_ref<bool(DWARFDIE die)> m_callback;
+ const llvm::StringRef m_name;
+ };
+ DIERefCallbackImpl
+ DIERefCallback(llvm::function_ref<bool(DWARFDIE die)> callback,
+ llvm::StringRef name = {}) const {
+ return DIERefCallbackImpl(*this, callback, name);
+ }
+
+ void ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const;
};
} // namespace lldb_private
-#endif // LLDB_DWARFINDEX_H
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFINDEX_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
index fcc031bf1ea0..48d578977c57 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFTypeUnit.cpp ---------------------------------------*- C++ -*-===//
+//===-- DWARFTypeUnit.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
index 8967509c081a..5e4d48ab285a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_DWARFTypeUnit_h_
-#define SymbolFileDWARF_DWARFTypeUnit_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFTYPEUNIT_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFTYPEUNIT_H
#include "DWARFUnit.h"
#include "llvm/Support/Error.h"
@@ -34,4 +34,4 @@ private:
friend class DWARFUnit;
};
-#endif // SymbolFileDWARF_DWARFTypeUnit_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFTYPEUNIT_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 22e3e40dac93..dfa40759a7ff 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFUnit.cpp -------------------------------------------*- C++ -*-===//
+//===-- DWARFUnit.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -188,7 +188,7 @@ void DWARFUnit::ExtractDIEsRWLocked() {
// simultaneously. We also don't need to do that as the dwo file will
// contain a superset of information. So, we don't even attempt to parse
// any remaining DIEs.
- if (m_dwo_symbol_file) {
+ if (m_dwo) {
m_die_array.front().SetHasChildren(false);
break;
}
@@ -249,10 +249,8 @@ void DWARFUnit::ExtractDIEsRWLocked() {
m_die_array.shrink_to_fit();
- if (m_dwo_symbol_file) {
- DWARFUnit *dwo_cu = m_dwo_symbol_file->GetCompileUnit();
- dwo_cu->ExtractDIEsIfNeeded();
- }
+ if (m_dwo)
+ m_dwo->ExtractDIEsIfNeeded();
}
// This is used when a split dwarf is enabled.
@@ -261,23 +259,33 @@ void DWARFUnit::ExtractDIEsRWLocked() {
// .debug_str_offsets. At the same time, the corresponding split debug unit also
// may use DW_FORM_strx* forms pointing to its own .debug_str_offsets.dwo and
// for that case, we should find the offset (skip the section header).
-static void SetDwoStrOffsetsBase(DWARFUnit *dwo_cu) {
+void DWARFUnit::SetDwoStrOffsetsBase() {
lldb::offset_t baseOffset = 0;
- const DWARFDataExtractor &strOffsets =
- dwo_cu->GetSymbolFileDWARF().GetDWARFContext().getOrLoadStrOffsetsData();
- uint64_t length = strOffsets.GetU32(&baseOffset);
- if (length == 0xffffffff)
- length = strOffsets.GetU64(&baseOffset);
+ if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) {
+ if (const auto *contribution =
+ entry->getContribution(llvm::DW_SECT_STR_OFFSETS))
+ baseOffset = contribution->Offset;
+ else
+ return;
+ }
- // Check version.
- if (strOffsets.GetU16(&baseOffset) < 5)
- return;
+ if (GetVersion() >= 5) {
+ const DWARFDataExtractor &strOffsets =
+ GetSymbolFileDWARF().GetDWARFContext().getOrLoadStrOffsetsData();
+ uint64_t length = strOffsets.GetU32(&baseOffset);
+ if (length == 0xffffffff)
+ length = strOffsets.GetU64(&baseOffset);
- // Skip padding.
- baseOffset += 2;
+ // Check version.
+ if (strOffsets.GetU16(&baseOffset) < 5)
+ return;
+
+ // Skip padding.
+ baseOffset += 2;
+ }
- dwo_cu->SetStrOffsetsBase(baseOffset);
+ SetStrOffsetsBase(baseOffset);
}
// m_die_array_mutex must be already held as read/write.
@@ -336,32 +344,27 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
}
}
- if (m_is_dwo)
+ if (m_is_dwo) {
+ SetDwoStrOffsetsBase();
return;
+ }
- std::unique_ptr<SymbolFileDWARFDwo> dwo_symbol_file =
+ std::shared_ptr<SymbolFileDWARFDwo> dwo_symbol_file =
m_dwarf.GetDwoSymbolFileForCompileUnit(*this, cu_die);
if (!dwo_symbol_file)
return;
- DWARFUnit *dwo_cu = dwo_symbol_file->GetCompileUnit();
+ uint64_t main_dwo_id =
+ cu_die.GetAttributeValueAsUnsigned(this, DW_AT_GNU_dwo_id, 0);
+ DWARFUnit *dwo_cu = dwo_symbol_file->GetDWOCompileUnitForHash(main_dwo_id);
if (!dwo_cu)
return; // Can't fetch the compile unit from the dwo file.
+ dwo_cu->SetUserData(this);
DWARFBaseDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
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(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);
-
// Here for DWO CU we want to use the address base set in the skeleton unit
// (DW_AT_addr_base) if it is available and use the DW_AT_GNU_addr_base
// otherwise. We do that because pre-DWARF v5 could use the DW_AT_GNU_*
@@ -375,21 +378,18 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
if (GetVersion() <= 4 && gnu_ranges_base)
dwo_cu->SetRangesBase(*gnu_ranges_base);
- else if (m_dwo_symbol_file->GetDWARFContext()
+ else if (dwo_symbol_file->GetDWARFContext()
.getOrLoadRngListsData()
.GetByteSize() > 0)
dwo_cu->SetRangesBase(llvm::DWARFListTableHeader::getHeaderSize(DWARF32));
- if (GetVersion() >= 5 && m_dwo_symbol_file->GetDWARFContext()
- .getOrLoadLocListsData()
- .GetByteSize() > 0)
+ if (GetVersion() >= 5 &&
+ dwo_symbol_file->GetDWARFContext().getOrLoadLocListsData().GetByteSize() >
+ 0)
dwo_cu->SetLoclistsBase(llvm::DWARFListTableHeader::getHeaderSize(DWARF32));
dwo_cu->SetBaseAddress(GetBaseAddress());
- for (size_t i = 0; i < m_dwo_symbol_file->DebugInfo()->GetNumUnits(); ++i) {
- DWARFUnit *unit = m_dwo_symbol_file->DebugInfo()->GetUnitAtIndex(i);
- SetDwoStrOffsetsBase(unit);
- }
+ m_dwo = std::shared_ptr<DWARFUnit>(std::move(dwo_symbol_file), dwo_cu);
}
DWARFDIE DWARFUnit::LookupAddress(const dw_addr_t address) {
@@ -467,18 +467,25 @@ void DWARFUnit::SetLoclistsBase(dw_addr_t loclists_base) {
std::unique_ptr<llvm::DWARFLocationTable>
DWARFUnit::GetLocationTable(const DataExtractor &data) const {
llvm::DWARFDataExtractor llvm_data(
- toStringRef(data.GetData()),
- data.GetByteOrder() == lldb::eByteOrderLittle, data.GetAddressByteSize());
+ data.GetData(), data.GetByteOrder() == lldb::eByteOrderLittle,
+ data.GetAddressByteSize());
if (m_is_dwo || GetVersion() >= 5)
return std::make_unique<llvm::DWARFDebugLoclists>(llvm_data, GetVersion());
return std::make_unique<llvm::DWARFDebugLoc>(llvm_data);
}
-const DWARFDataExtractor &DWARFUnit::GetLocationData() const {
+DWARFDataExtractor DWARFUnit::GetLocationData() const {
DWARFContext &Ctx = GetSymbolFileDWARF().GetDWARFContext();
- return GetVersion() >= 5 ? Ctx.getOrLoadLocListsData()
- : Ctx.getOrLoadLocData();
+ const DWARFDataExtractor &data =
+ GetVersion() >= 5 ? Ctx.getOrLoadLocListsData() : Ctx.getOrLoadLocData();
+ if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) {
+ if (const auto *contribution = entry->getContribution(llvm::DW_SECT_EXT_LOC))
+ return DWARFDataExtractor(data, contribution->Offset,
+ contribution->Length);
+ return DWARFDataExtractor();
+ }
+ return data;
}
void DWARFUnit::SetRangesBase(dw_addr_t ranges_base) {
@@ -506,18 +513,14 @@ void DWARFUnit::ClearDIEsRWLocked() {
m_die_array.clear();
m_die_array.shrink_to_fit();
- if (m_dwo_symbol_file)
- m_dwo_symbol_file->GetCompileUnit()->ClearDIEsRWLocked();
+ if (m_dwo)
+ m_dwo->ClearDIEsRWLocked();
}
lldb::ByteOrder DWARFUnit::GetByteOrder() const {
return m_dwarf.GetObjectFile()->GetByteOrder();
}
-llvm::Expected<TypeSystem &> DWARFUnit::GetTypeSystem() {
- return m_dwarf.GetTypeSystemForLanguage(GetLanguageType());
-}
-
void DWARFUnit::SetBaseAddress(dw_addr_t base_addr) { m_base_addr = base_addr; }
// Compare function DWARFDebugAranges::Range structures
@@ -534,9 +537,6 @@ static bool CompareDIEOffset(const DWARFDebugInfoEntry &die,
DWARFDIE
DWARFUnit::GetDIE(dw_offset_t die_offset) {
if (die_offset != DW_INVALID_OFFSET) {
- if (GetDwoSymbolFile())
- return GetDwoSymbolFile()->GetCompileUnit()->GetDIE(die_offset);
-
if (ContainsDIEOffset(die_offset)) {
ExtractDIEsIfNeeded();
DWARFDebugInfoEntry::const_iterator end = m_die_array.cend();
@@ -555,8 +555,9 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
}
DWARFUnit &DWARFUnit::GetNonSkeletonUnit() {
- if (SymbolFileDWARFDwo *dwo = GetDwoSymbolFile())
- return *dwo->GetCompileUnit();
+ ExtractUnitDIEIfNeeded();
+ if (m_dwo)
+ return *m_dwo;
return *this;
}
@@ -570,11 +571,7 @@ uint8_t DWARFUnit::GetDefaultAddressSize() { return 4; }
void *DWARFUnit::GetUserData() const { return m_user_data; }
-void DWARFUnit::SetUserData(void *d) {
- m_user_data = d;
- if (m_dwo_symbol_file)
- m_dwo_symbol_file->GetCompileUnit()->SetUserData(d);
-}
+void DWARFUnit::SetUserData(void *d) { m_user_data = d; }
bool DWARFUnit::Supports_DW_AT_APPLE_objc_complete_type() {
return GetProducer() != eProducerLLVMGCC;
@@ -658,28 +655,17 @@ uint32_t DWARFUnit::GetProducerVersionUpdate() {
ParseProducerInfo();
return m_producer_version_update;
}
-LanguageType DWARFUnit::LanguageTypeFromDWARF(uint64_t val) {
- // Note: user languages between lo_user and hi_user must be handled
- // explicitly here.
- switch (val) {
- case DW_LANG_Mips_Assembler:
- return eLanguageTypeMipsAssembler;
- case DW_LANG_GOOGLE_RenderScript:
- return eLanguageTypeExtRenderScript;
- default:
- return static_cast<LanguageType>(val);
- }
-}
-LanguageType DWARFUnit::GetLanguageType() {
- if (m_language_type != eLanguageTypeUnknown)
- return m_language_type;
+uint64_t DWARFUnit::GetDWARFLanguageType() {
+ if (m_language_type)
+ return *m_language_type;
const DWARFDebugInfoEntry *die = GetUnitDIEPtrOnly();
- if (die)
- m_language_type = LanguageTypeFromDWARF(
- die->GetAttributeValueAsUnsigned(this, DW_AT_language, 0));
- return m_language_type;
+ if (!die)
+ m_language_type = 0;
+ else
+ m_language_type = die->GetAttributeValueAsUnsigned(this, DW_AT_language, 0);
+ return *m_language_type;
}
bool DWARFUnit::GetIsOptimized() {
@@ -738,25 +724,6 @@ removeHostnameFromPathname(llvm::StringRef path_from_dwarf) {
return path;
}
-static FileSpec resolveCompDir(const FileSpec &path) {
- bool is_symlink = SymbolFileDWARF::GetSymlinkPaths().FindFileIndex(
- 0, path, /*full*/ true) != UINT32_MAX;
-
- if (!is_symlink)
- return path;
-
- namespace fs = llvm::sys::fs;
- if (fs::get_file_type(path.GetPath(), false) != fs::file_type::symlink_file)
- return path;
-
- FileSpec resolved_symlink;
- const auto error = FileSystem::Instance().Readlink(path, resolved_symlink);
- if (error.Success())
- return resolved_symlink;
-
- return path;
-}
-
void DWARFUnit::ComputeCompDirAndGuessPathStyle() {
m_comp_dir = FileSpec();
const DWARFDebugInfoEntry *die = GetUnitDIEPtrOnly();
@@ -768,7 +735,7 @@ void DWARFUnit::ComputeCompDirAndGuessPathStyle() {
if (!comp_dir.empty()) {
FileSpec::Style comp_dir_style =
FileSpec::GuessPathStyle(comp_dir).getValueOr(FileSpec::Style::native);
- m_comp_dir = resolveCompDir(FileSpec(comp_dir, comp_dir_style));
+ m_comp_dir = FileSpec(comp_dir, comp_dir_style);
} else {
// Try to detect the style based on the DW_AT_name attribute, but just store
// the detected style in the m_comp_dir field.
@@ -795,21 +762,22 @@ void DWARFUnit::ComputeAbsolutePath() {
SymbolFileDWARFDwo *DWARFUnit::GetDwoSymbolFile() {
ExtractUnitDIEIfNeeded();
- return m_dwo_symbol_file.get();
+ if (m_dwo)
+ return &llvm::cast<SymbolFileDWARFDwo>(m_dwo->GetSymbolFileDWARF());
+ return nullptr;
}
const DWARFDebugAranges &DWARFUnit::GetFunctionAranges() {
if (m_func_aranges_up == nullptr) {
- m_func_aranges_up.reset(new DWARFDebugAranges());
+ m_func_aranges_up = std::make_unique<DWARFDebugAranges>();
const DWARFDebugInfoEntry *die = DIEPtr();
if (die)
die->BuildFunctionAddressRangeTable(this, m_func_aranges_up.get());
- if (m_dwo_symbol_file) {
- DWARFUnit *dwo_cu = m_dwo_symbol_file->GetCompileUnit();
- const DWARFDebugInfoEntry *dwo_die = dwo_cu->DIEPtr();
+ if (m_dwo) {
+ const DWARFDebugInfoEntry *dwo_die = m_dwo->DIEPtr();
if (dwo_die)
- dwo_die->BuildFunctionAddressRangeTable(dwo_cu,
+ dwo_die->BuildFunctionAddressRangeTable(m_dwo.get(),
m_func_aranges_up.get());
}
@@ -820,10 +788,13 @@ const DWARFDebugAranges &DWARFUnit::GetFunctionAranges() {
}
llvm::Expected<DWARFUnitHeader>
-DWARFUnitHeader::extract(const DWARFDataExtractor &data, DIERef::Section section,
- lldb::offset_t *offset_ptr) {
+DWARFUnitHeader::extract(const DWARFDataExtractor &data,
+ DIERef::Section section, lldb::offset_t *offset_ptr,
+ const llvm::DWARFUnitIndex *index) {
DWARFUnitHeader header;
header.m_offset = *offset_ptr;
+ if (index)
+ header.m_index_entry = index->getFromOffset(*offset_ptr);
header.m_length = data.GetDWARFInitialLength(offset_ptr);
header.m_version = data.GetU16(offset_ptr);
if (header.m_version == 5) {
@@ -839,6 +810,26 @@ DWARFUnitHeader::extract(const DWARFDataExtractor &data, DIERef::Section section
section == DIERef::Section::DebugTypes ? DW_UT_type : DW_UT_compile;
}
+ if (header.m_index_entry) {
+ if (header.m_abbr_offset) {
+ return llvm::createStringError(
+ llvm::inconvertibleErrorCode(),
+ "Package unit with a non-zero abbreviation offset");
+ }
+ auto *unit_contrib = header.m_index_entry->getContribution();
+ if (!unit_contrib || unit_contrib->Length != header.m_length + 4) {
+ return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Inconsistent DWARF package unit index");
+ }
+ auto *abbr_entry =
+ header.m_index_entry->getContribution(llvm::DW_SECT_ABBREV);
+ if (!abbr_entry) {
+ return llvm::createStringError(
+ llvm::inconvertibleErrorCode(),
+ "DWARF package index missing abbreviation column");
+ }
+ header.m_abbr_offset = abbr_entry->Offset;
+ }
if (header.IsTypeUnit()) {
header.m_type_hash = data.GetU64(offset_ptr);
header.m_type_offset = data.GetDWARFOffset(offset_ptr);
@@ -869,11 +860,12 @@ DWARFUnitHeader::extract(const DWARFDataExtractor &data, DIERef::Section section
llvm::Expected<DWARFUnitSP>
DWARFUnit::extract(SymbolFileDWARF &dwarf, user_id_t uid,
const DWARFDataExtractor &debug_info,
- DIERef::Section section, lldb::offset_t *offset_ptr) {
+ DIERef::Section section, lldb::offset_t *offset_ptr,
+ const llvm::DWARFUnitIndex *index) {
assert(debug_info.ValidOffset(*offset_ptr));
auto expected_header =
- DWARFUnitHeader::extract(debug_info, section, offset_ptr);
+ DWARFUnitHeader::extract(debug_info, section, offset_ptr, index);
if (!expected_header)
return expected_header.takeError();
@@ -924,6 +916,12 @@ uint32_t DWARFUnit::GetHeaderByteSize() const {
llvm_unreachable("invalid UnitType.");
}
+llvm::Optional<uint64_t>
+DWARFUnit::GetStringOffsetSectionItem(uint32_t index) const {
+ offset_t offset = GetStrOffsetsBase() + index * 4;
+ return m_dwarf.GetDWARFContext().getOrLoadStrOffsetsData().GetU32(&offset);
+}
+
llvm::Expected<DWARFRangeList>
DWARFUnit::FindRnglistFromOffset(dw_offset_t offset) {
if (GetVersion() <= 4) {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
index 217f9bb89ace..affad286a490 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -6,12 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_DWARFUnit_h_
-#define SymbolFileDWARF_DWARFUnit_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFUNIT_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFUNIT_H
#include "DWARFDIE.h"
#include "DWARFDebugInfoEntry.h"
#include "lldb/lldb-enumerations.h"
+#include "lldb/Utility/XcodeSDK.h"
#include "llvm/Support/RWMutex.h"
#include <atomic>
@@ -39,6 +40,9 @@ class DWARFUnitHeader {
dw_offset_t m_length = 0;
uint16_t m_version = 0;
dw_offset_t m_abbr_offset = 0;
+
+ const llvm::DWARFUnitIndex::Entry *m_index_entry = nullptr;
+
uint8_t m_unit_type = 0;
uint8_t m_addr_size = 0;
@@ -56,6 +60,9 @@ public:
dw_offset_t GetLength() const { return m_length; }
dw_offset_t GetAbbrOffset() const { return m_abbr_offset; }
uint8_t GetUnitType() const { return m_unit_type; }
+ const llvm::DWARFUnitIndex::Entry *GetIndexEntry() const {
+ return m_index_entry;
+ }
uint64_t GetTypeHash() const { return m_type_hash; }
dw_offset_t GetTypeOffset() const { return m_type_offset; }
bool IsTypeUnit() const {
@@ -65,7 +72,7 @@ public:
static llvm::Expected<DWARFUnitHeader>
extract(const lldb_private::DWARFDataExtractor &data, DIERef::Section section,
- lldb::offset_t *offset_ptr);
+ lldb::offset_t *offset_ptr, const llvm::DWARFUnitIndex *index);
};
class DWARFUnit : public lldb_private::UserID {
@@ -76,9 +83,12 @@ public:
static llvm::Expected<DWARFUnitSP>
extract(SymbolFileDWARF &dwarf2Data, lldb::user_id_t uid,
const lldb_private::DWARFDataExtractor &debug_info,
- DIERef::Section section, lldb::offset_t *offset_ptr);
+ DIERef::Section section, lldb::offset_t *offset_ptr,
+ const llvm::DWARFUnitIndex *index);
virtual ~DWARFUnit();
+ bool IsDWOUnit() { return m_is_dwo; }
+
void ExtractUnitDIEIfNeeded();
void ExtractDIEsIfNeeded();
@@ -88,7 +98,8 @@ public:
bool m_clear_dies = false;
ScopedExtractDIEs(DWARFUnit &cu);
~ScopedExtractDIEs();
- DISALLOW_COPY_AND_ASSIGN(ScopedExtractDIEs);
+ ScopedExtractDIEs(const ScopedExtractDIEs &) = delete;
+ const ScopedExtractDIEs &operator=(const ScopedExtractDIEs &) = delete;
ScopedExtractDIEs(ScopedExtractDIEs &&rhs);
ScopedExtractDIEs &operator=(ScopedExtractDIEs &&rhs);
};
@@ -152,8 +163,6 @@ public:
lldb::ByteOrder GetByteOrder() const;
- llvm::Expected<lldb_private::TypeSystem &> GetTypeSystem();
-
const DWARFDebugAranges &GetFunctionAranges();
void SetBaseAddress(dw_addr_t base_addr);
@@ -190,9 +199,7 @@ public:
uint32_t GetProducerVersionUpdate();
- static lldb::LanguageType LanguageTypeFromDWARF(uint64_t val);
-
- lldb::LanguageType GetLanguageType();
+ uint64_t GetDWARFLanguageType();
bool GetIsOptimized();
@@ -213,6 +220,8 @@ public:
uint8_t GetUnitType() const { return m_header.GetUnitType(); }
bool IsTypeUnit() const { return m_header.IsTypeUnit(); }
+ llvm::Optional<uint64_t> GetStringOffsetSectionItem(uint32_t index) const;
+
/// Return a list of address ranges resulting from a (possibly encoded)
/// range list starting at a given offset in the appropriate ranges section.
llvm::Expected<DWARFRangeList> FindRnglistFromOffset(dw_offset_t offset);
@@ -248,7 +257,7 @@ public:
std::unique_ptr<llvm::DWARFLocationTable>
GetLocationTable(const lldb_private::DataExtractor &data) const;
- const lldb_private::DWARFDataExtractor &GetLocationData() const;
+ lldb_private::DWARFDataExtractor GetLocationData() const;
protected:
DWARFUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
@@ -279,7 +288,7 @@ protected:
}
SymbolFileDWARF &m_dwarf;
- std::unique_ptr<SymbolFileDWARFDwo> m_dwo_symbol_file;
+ std::shared_ptr<DWARFUnit> m_dwo;
DWARFUnitHeader m_header;
const DWARFAbbreviationDeclarationSet *m_abbrevs = nullptr;
void *m_user_data = nullptr;
@@ -304,7 +313,7 @@ protected:
uint32_t m_producer_version_major = 0;
uint32_t m_producer_version_minor = 0;
uint32_t m_producer_version_update = 0;
- lldb::LanguageType m_language_type = lldb::eLanguageTypeUnknown;
+ llvm::Optional<uint64_t> m_language_type;
lldb_private::LazyBool m_is_optimized = lldb_private::eLazyBoolCalculate;
llvm::Optional<lldb_private::FileSpec> m_comp_dir;
llvm::Optional<lldb_private::FileSpec> m_file_spec;
@@ -329,11 +338,13 @@ private:
void ClearDIEsRWLocked();
void AddUnitDIE(const DWARFDebugInfoEntry &cu_die);
+ void SetDwoStrOffsetsBase();
void ComputeCompDirAndGuessPathStyle();
void ComputeAbsolutePath();
- DISALLOW_COPY_AND_ASSIGN(DWARFUnit);
+ DWARFUnit(const DWARFUnit &) = delete;
+ const DWARFUnit &operator=(const DWARFUnit &) = delete;
};
-#endif // SymbolFileDWARF_DWARFUnit_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFUNIT_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 007ef2e05e59..cb3e662a6cdf 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -1,4 +1,4 @@
-//===-- DebugNamesDWARFIndex.cpp -------------------------------*- C++ -*-===//
+//===-- DebugNamesDWARFIndex.cpp ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -10,6 +10,7 @@
#include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h"
#include "Plugins/SymbolFile/DWARF/DWARFDeclContext.h"
#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h"
+#include "lldb/Core/Module.h"
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Stream.h"
@@ -19,18 +20,14 @@ using namespace lldb;
llvm::Expected<std::unique_ptr<DebugNamesDWARFIndex>>
DebugNamesDWARFIndex::Create(Module &module, DWARFDataExtractor debug_names,
DWARFDataExtractor debug_str,
- DWARFDebugInfo *debug_info) {
- if (!debug_info) {
- return llvm::make_error<llvm::StringError>("debug info null",
- llvm::inconvertibleErrorCode());
- }
+ SymbolFileDWARF &dwarf) {
auto index_up = std::make_unique<DebugNames>(debug_names.GetAsLLVM(),
debug_str.GetAsLLVM());
if (llvm::Error E = index_up->extract())
return std::move(E);
return std::unique_ptr<DebugNamesDWARFIndex>(new DebugNamesDWARFIndex(
- module, std::move(index_up), debug_names, debug_str, *debug_info));
+ module, std::move(index_up), debug_names, debug_str, dwarf));
}
llvm::DenseSet<dw_offset_t>
@@ -53,12 +50,7 @@ DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) {
if (!cu)
return llvm::None;
- // This initializes the DWO symbol file. It's not possible for
- // GetDwoSymbolFile to call this automatically because of mutual recursion
- // between this and DWARFDebugInfoEntry::GetAttributeValue.
- cu->ExtractUnitDIEIfNeeded();
cu = &cu->GetNonSkeletonUnit();
-
if (llvm::Optional<uint64_t> die_offset = entry.getDIEUnitOffset())
return DIERef(cu->GetSymbolFileDWARF().GetDwoNum(),
DIERef::Section::DebugInfo, cu->GetOffset() + *die_offset);
@@ -66,10 +58,18 @@ DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) {
return llvm::None;
}
-void DebugNamesDWARFIndex::Append(const DebugNames::Entry &entry,
- DIEArray &offsets) {
- if (llvm::Optional<DIERef> ref = ToDIERef(entry))
- offsets.push_back(*ref);
+bool DebugNamesDWARFIndex::ProcessEntry(
+ const DebugNames::Entry &entry,
+ llvm::function_ref<bool(DWARFDIE die)> callback, llvm::StringRef name) {
+ llvm::Optional<DIERef> ref = ToDIERef(entry);
+ if (!ref)
+ return true;
+ SymbolFileDWARF &dwarf =
+ *llvm::cast<SymbolFileDWARF>(m_module.GetSymbolFile());
+ DWARFDIE die = dwarf.GetDIE(*ref);
+ if (!die)
+ return true;
+ return callback(die);
}
void DebugNamesDWARFIndex::MaybeLogLookupError(llvm::Error error,
@@ -83,23 +83,23 @@ void DebugNamesDWARFIndex::MaybeLogLookupError(llvm::Error error,
ni.getUnitOffset(), name);
}
-void DebugNamesDWARFIndex::GetGlobalVariables(ConstString basename,
- DIEArray &offsets) {
- m_fallback.GetGlobalVariables(basename, offsets);
-
+void DebugNamesDWARFIndex::GetGlobalVariables(
+ ConstString basename, llvm::function_ref<bool(DWARFDIE die)> callback) {
for (const DebugNames::Entry &entry :
m_debug_names_up->equal_range(basename.GetStringRef())) {
if (entry.tag() != DW_TAG_variable)
continue;
- Append(entry, offsets);
+ if (!ProcessEntry(entry, callback, basename.GetStringRef()))
+ return;
}
-}
-void DebugNamesDWARFIndex::GetGlobalVariables(const RegularExpression &regex,
- DIEArray &offsets) {
- m_fallback.GetGlobalVariables(regex, offsets);
+ m_fallback.GetGlobalVariables(basename, callback);
+}
+void DebugNamesDWARFIndex::GetGlobalVariables(
+ const RegularExpression &regex,
+ llvm::function_ref<bool(DWARFDIE die)> callback) {
for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
for (DebugNames::NameTableEntry nte: ni) {
if (!regex.Execute(nte.getString()))
@@ -111,17 +111,19 @@ void DebugNamesDWARFIndex::GetGlobalVariables(const RegularExpression &regex,
if (entry_or->tag() != DW_TAG_variable)
continue;
- Append(*entry_or, offsets);
+ if (!ProcessEntry(*entry_or, callback,
+ llvm::StringRef(nte.getString())))
+ return;
}
MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
}
}
-}
-void DebugNamesDWARFIndex::GetGlobalVariables(const DWARFUnit &cu,
- DIEArray &offsets) {
- m_fallback.GetGlobalVariables(cu, offsets);
+ m_fallback.GetGlobalVariables(regex, callback);
+}
+void DebugNamesDWARFIndex::GetGlobalVariables(
+ const DWARFUnit &cu, llvm::function_ref<bool(DWARFDIE die)> callback) {
uint64_t cu_offset = cu.GetOffset();
for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
for (DebugNames::NameTableEntry nte: ni) {
@@ -133,18 +135,20 @@ void DebugNamesDWARFIndex::GetGlobalVariables(const DWARFUnit &cu,
if (entry_or->getCUOffset() != cu_offset)
continue;
- Append(*entry_or, offsets);
+ if (!ProcessEntry(*entry_or, callback,
+ llvm::StringRef(nte.getString())))
+ return;
}
MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
}
}
-}
-void DebugNamesDWARFIndex::GetCompleteObjCClass(ConstString class_name,
- bool must_be_implementation,
- DIEArray &offsets) {
- m_fallback.GetCompleteObjCClass(class_name, must_be_implementation, offsets);
+ m_fallback.GetGlobalVariables(cu, callback);
+}
+void DebugNamesDWARFIndex::GetCompleteObjCClass(
+ ConstString class_name, bool must_be_implementation,
+ llvm::function_ref<bool(DWARFDIE die)> callback) {
// Keep a list of incomplete types as fallback for when we don't find the
// complete type.
DIEArray incomplete_types;
@@ -165,84 +169,98 @@ void DebugNamesDWARFIndex::GetCompleteObjCClass(ConstString class_name,
continue;
}
- // FIXME: We should return DWARFDIEs so we don't have to resolve it twice.
DWARFDIE die = m_debug_info.GetDIE(*ref);
- if (!die)
+ if (!die) {
+ ReportInvalidDIERef(*ref, class_name.GetStringRef());
continue;
+ }
if (die.GetAttributeValueAsUnsigned(DW_AT_APPLE_objc_complete_type, 0)) {
// If we find the complete version we're done.
- offsets.push_back(*ref);
+ callback(die);
return;
- } else {
- incomplete_types.push_back(*ref);
}
+ incomplete_types.push_back(*ref);
}
- offsets.insert(offsets.end(), incomplete_types.begin(),
- incomplete_types.end());
-}
+ auto dierefcallback = DIERefCallback(callback, class_name.GetStringRef());
+ for (DIERef ref : incomplete_types)
+ if (!dierefcallback(ref))
+ return;
-void DebugNamesDWARFIndex::GetTypes(ConstString name, DIEArray &offsets) {
- m_fallback.GetTypes(name, offsets);
+ m_fallback.GetCompleteObjCClass(class_name, must_be_implementation, callback);
+}
+void DebugNamesDWARFIndex::GetTypes(
+ ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) {
for (const DebugNames::Entry &entry :
m_debug_names_up->equal_range(name.GetStringRef())) {
- if (isType(entry.tag()))
- Append(entry, offsets);
+ if (isType(entry.tag())) {
+ if (!ProcessEntry(entry, callback, name.GetStringRef()))
+ return;
+ }
}
-}
-void DebugNamesDWARFIndex::GetTypes(const DWARFDeclContext &context,
- DIEArray &offsets) {
- m_fallback.GetTypes(context, offsets);
+ m_fallback.GetTypes(name, callback);
+}
- for (const DebugNames::Entry &entry :
- m_debug_names_up->equal_range(context[0].name)) {
- if (entry.tag() == context[0].tag)
- Append(entry, offsets);
+void DebugNamesDWARFIndex::GetTypes(
+ const DWARFDeclContext &context,
+ llvm::function_ref<bool(DWARFDIE die)> callback) {
+ auto name = context[0].name;
+ for (const DebugNames::Entry &entry : m_debug_names_up->equal_range(name)) {
+ if (entry.tag() == context[0].tag) {
+ if (!ProcessEntry(entry, callback, name))
+ return;
+ }
}
-}
-void DebugNamesDWARFIndex::GetNamespaces(ConstString name, DIEArray &offsets) {
- m_fallback.GetNamespaces(name, offsets);
+ m_fallback.GetTypes(context, callback);
+}
+void DebugNamesDWARFIndex::GetNamespaces(
+ ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) {
for (const DebugNames::Entry &entry :
m_debug_names_up->equal_range(name.GetStringRef())) {
- if (entry.tag() == DW_TAG_namespace)
- Append(entry, offsets);
+ if (entry.tag() == DW_TAG_namespace) {
+ if (!ProcessEntry(entry, callback, name.GetStringRef()))
+ return;
+ }
}
+
+ m_fallback.GetNamespaces(name, callback);
}
void DebugNamesDWARFIndex::GetFunctions(
ConstString name, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask,
- std::vector<DWARFDIE> &dies) {
-
- std::vector<DWARFDIE> v;
- m_fallback.GetFunctions(name, dwarf, parent_decl_ctx, name_type_mask, v);
+ llvm::function_ref<bool(DWARFDIE die)> callback) {
+ std::set<DWARFDebugInfoEntry *> seen;
for (const DebugNames::Entry &entry :
m_debug_names_up->equal_range(name.GetStringRef())) {
Tag tag = entry.tag();
if (tag != DW_TAG_subprogram && tag != DW_TAG_inlined_subroutine)
continue;
- if (llvm::Optional<DIERef> ref = ToDIERef(entry))
- ProcessFunctionDIE(name.GetStringRef(), *ref, dwarf, parent_decl_ctx,
- name_type_mask, v);
+ if (llvm::Optional<DIERef> ref = ToDIERef(entry)) {
+ if (!ProcessFunctionDIE(name.GetStringRef(), *ref, dwarf, parent_decl_ctx,
+ name_type_mask, [&](DWARFDIE die) {
+ if (!seen.insert(die.GetDIE()).second)
+ return true;
+ return callback(die);
+ }))
+ return;
+ }
}
- std::set<DWARFDebugInfoEntry *> seen;
- for (DWARFDIE die : v)
- if (seen.insert(die.GetDIE()).second)
- dies.push_back(die);
+ m_fallback.GetFunctions(name, dwarf, parent_decl_ctx, name_type_mask,
+ callback);
}
-void DebugNamesDWARFIndex::GetFunctions(const RegularExpression &regex,
- DIEArray &offsets) {
- m_fallback.GetFunctions(regex, offsets);
-
+void DebugNamesDWARFIndex::GetFunctions(
+ const RegularExpression &regex,
+ llvm::function_ref<bool(DWARFDIE die)> callback) {
for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
for (DebugNames::NameTableEntry nte: ni) {
if (!regex.Execute(nte.getString()))
@@ -255,11 +273,15 @@ void DebugNamesDWARFIndex::GetFunctions(const RegularExpression &regex,
if (tag != DW_TAG_subprogram && tag != DW_TAG_inlined_subroutine)
continue;
- Append(*entry_or, offsets);
+ if (!ProcessEntry(*entry_or, callback,
+ llvm::StringRef(nte.getString())))
+ return;
}
MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
}
}
+
+ m_fallback.GetFunctions(regex, callback);
}
void DebugNamesDWARFIndex::Dump(Stream &s) {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
index dca25496373f..5d041c36c8f2 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
@@ -6,12 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_DEBUGNAMESDWARFINDEX_H
-#define LLDB_DEBUGNAMESDWARFINDEX_H
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DEBUGNAMESDWARFINDEX_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DEBUGNAMESDWARFINDEX_H
#include "Plugins/SymbolFile/DWARF/DWARFIndex.h"
#include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h"
#include "Plugins/SymbolFile/DWARF/ManualDWARFIndex.h"
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
#include "lldb/Utility/ConstString.h"
#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
@@ -20,28 +21,38 @@ class DebugNamesDWARFIndex : public DWARFIndex {
public:
static llvm::Expected<std::unique_ptr<DebugNamesDWARFIndex>>
Create(Module &module, DWARFDataExtractor debug_names,
- DWARFDataExtractor debug_str, DWARFDebugInfo *debug_info);
+ DWARFDataExtractor debug_str, SymbolFileDWARF &dwarf);
void Preload() override { m_fallback.Preload(); }
- void GetGlobalVariables(ConstString basename, DIEArray &offsets) override;
- void GetGlobalVariables(const RegularExpression &regex,
- DIEArray &offsets) override;
- void GetGlobalVariables(const DWARFUnit &cu, DIEArray &offsets) override;
- void GetObjCMethods(ConstString class_name, DIEArray &offsets) override {}
- void GetCompleteObjCClass(ConstString class_name, bool must_be_implementation,
- DIEArray &offsets) override;
- void GetTypes(ConstString name, DIEArray &offsets) override;
- void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override;
- void GetNamespaces(ConstString name, DIEArray &offsets) override;
+ void
+ GetGlobalVariables(ConstString basename,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void
+ GetGlobalVariables(const RegularExpression &regex,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void
+ GetGlobalVariables(const DWARFUnit &cu,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void
+ GetObjCMethods(ConstString class_name,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override {}
+ void GetCompleteObjCClass(
+ ConstString class_name, bool must_be_implementation,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetTypes(ConstString name,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetTypes(const DWARFDeclContext &context,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetNamespaces(ConstString name,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
void GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
uint32_t name_type_mask,
- std::vector<DWARFDIE> &dies) override;
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
void GetFunctions(const RegularExpression &regex,
- DIEArray &offsets) override;
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
- void ReportInvalidDIERef(const DIERef &ref, llvm::StringRef name) override {}
void Dump(Stream &s) override;
private:
@@ -49,11 +60,11 @@ private:
std::unique_ptr<llvm::DWARFDebugNames> debug_names_up,
DWARFDataExtractor debug_names_data,
DWARFDataExtractor debug_str_data,
- DWARFDebugInfo &debug_info)
- : DWARFIndex(module), m_debug_info(debug_info),
+ SymbolFileDWARF &dwarf)
+ : DWARFIndex(module), m_debug_info(dwarf.DebugInfo()),
m_debug_names_data(debug_names_data), m_debug_str_data(debug_str_data),
m_debug_names_up(std::move(debug_names_up)),
- m_fallback(module, &debug_info, GetUnits(*m_debug_names_up)) {}
+ m_fallback(module, dwarf, GetUnits(*m_debug_names_up)) {}
DWARFDebugInfo &m_debug_info;
@@ -67,7 +78,9 @@ private:
ManualDWARFIndex m_fallback;
llvm::Optional<DIERef> ToDIERef(const DebugNames::Entry &entry);
- void Append(const DebugNames::Entry &entry, DIEArray &offsets);
+ bool ProcessEntry(const DebugNames::Entry &entry,
+ llvm::function_ref<bool(DWARFDIE die)> callback,
+ llvm::StringRef name);
static void MaybeLogLookupError(llvm::Error error,
const DebugNames::NameIndex &ni,
@@ -78,4 +91,4 @@ private:
} // namespace lldb_private
-#endif // LLDB_DEBUGNAMESDWARFINDEX_H
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DEBUGNAMESDWARFINDEX_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
index 88a29f4a2672..d36f2a8bccf7 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
@@ -1,4 +1,4 @@
-//===-- HashedNameToDIE.cpp -------------------------------------*- C++ -*-===//
+//===-- HashedNameToDIE.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,91 +9,99 @@
#include "HashedNameToDIE.h"
#include "llvm/ADT/StringRef.h"
-void DWARFMappedHash::ExtractDIEArray(const DIEInfoArray &die_info_array,
- DIEArray &die_offsets) {
+bool DWARFMappedHash::ExtractDIEArray(
+ const DIEInfoArray &die_info_array,
+ llvm::function_ref<bool(DIERef ref)> callback) {
const size_t count = die_info_array.size();
for (size_t i = 0; i < count; ++i)
- die_offsets.emplace_back(die_info_array[i]);
+ if (!callback(DIERef(die_info_array[i])))
+ return false;
+ return true;
}
-void DWARFMappedHash::ExtractDIEArray(const DIEInfoArray &die_info_array,
- const dw_tag_t tag,
- DIEArray &die_offsets) {
+void DWARFMappedHash::ExtractDIEArray(
+ const DIEInfoArray &die_info_array, const dw_tag_t tag,
+ llvm::function_ref<bool(DIERef ref)> callback) {
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]);
+ ExtractDIEArray(die_info_array, callback);
+ return;
+ }
+
+ 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) {
+ if (!callback(DIERef(die_info_array[i])))
+ return;
}
}
}
-void DWARFMappedHash::ExtractDIEArray(const DIEInfoArray &die_info_array,
- const dw_tag_t tag,
- const uint32_t qualified_name_hash,
- DIEArray &die_offsets) {
+void DWARFMappedHash::ExtractDIEArray(
+ const DIEInfoArray &die_info_array, const dw_tag_t tag,
+ const uint32_t qualified_name_hash,
+ llvm::function_ref<bool(DIERef ref)> callback) {
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]);
+ ExtractDIEArray(die_info_array, callback);
+ return;
+ }
+
+ 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) {
+ if (!callback(DIERef(die_info_array[i])))
+ return;
}
}
}
void DWARFMappedHash::ExtractClassOrStructDIEArray(
const DIEInfoArray &die_info_array,
- bool return_implementation_only_if_available, DIEArray &die_offsets) {
+ bool return_implementation_only_if_available,
+ llvm::function_ref<bool(DIERef ref)> callback) {
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]);
- 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]);
- }
- } else {
- die_offsets.emplace_back(die_info_array[i]);
- }
+ if (!(die_tag == 0 || die_tag == DW_TAG_class_type ||
+ die_tag == DW_TAG_structure_type))
+ continue;
+ bool is_implementation =
+ (die_info_array[i].type_flags & eTypeFlagClassIsImplementation) != 0;
+ if (is_implementation != return_implementation_only_if_available)
+ continue;
+ if (return_implementation_only_if_available) {
+ // We found the one true definition for this class, so only return
+ // that
+ callback(DIERef(die_info_array[i]));
+ return;
}
+ if (!callback(DIERef(die_info_array[i])))
+ return;
}
}
void DWARFMappedHash::ExtractTypesFromDIEArray(
const DIEInfoArray &die_info_array, uint32_t type_flag_mask,
- uint32_t type_flag_value, DIEArray &die_offsets) {
+ uint32_t type_flag_value, llvm::function_ref<bool(DIERef ref)> callback) {
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]);
+ if ((die_info_array[i].type_flags & type_flag_mask) == type_flag_value) {
+ if (!callback(DIERef(die_info_array[i])))
+ return;
+ }
}
}
@@ -453,7 +461,7 @@ DWARFMappedHash::MemoryTable::AppendHashDataForRegularExpression(
}
}
-size_t DWARFMappedHash::MemoryTable::AppendAllDIEsThatMatchingRegex(
+void DWARFMappedHash::MemoryTable::AppendAllDIEsThatMatchingRegex(
const lldb_private::RegularExpression &regex,
DIEInfoArray &die_info_array) const {
const uint32_t hash_count = m_header.hashes_count;
@@ -482,10 +490,9 @@ size_t DWARFMappedHash::MemoryTable::AppendAllDIEsThatMatchingRegex(
}
}
die_info_array.swap(pair.value);
- return die_info_array.size();
}
-size_t DWARFMappedHash::MemoryTable::AppendAllDIEsInRange(
+void 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;
@@ -512,73 +519,74 @@ size_t DWARFMappedHash::MemoryTable::AppendAllDIEsInRange(
}
}
}
- return die_info_array.size();
}
-size_t DWARFMappedHash::MemoryTable::FindByName(llvm::StringRef name,
- DIEArray &die_offsets) {
+bool DWARFMappedHash::MemoryTable::FindByName(
+ llvm::StringRef name, llvm::function_ref<bool(DIERef ref)> callback) {
if (name.empty())
- return 0;
+ return true;
DIEInfoArray die_info_array;
- if (FindByName(name, die_info_array))
- DWARFMappedHash::ExtractDIEArray(die_info_array, die_offsets);
- return die_info_array.size();
+ FindByName(name, die_info_array);
+ return DWARFMappedHash::ExtractDIEArray(die_info_array, callback);
}
-size_t DWARFMappedHash::MemoryTable::FindByNameAndTag(llvm::StringRef name,
- const dw_tag_t tag,
- DIEArray &die_offsets) {
+void DWARFMappedHash::MemoryTable::FindByNameAndTag(
+ llvm::StringRef name, const dw_tag_t tag,
+ llvm::function_ref<bool(DIERef ref)> callback) {
DIEInfoArray die_info_array;
- if (FindByName(name, die_info_array))
- DWARFMappedHash::ExtractDIEArray(die_info_array, tag, die_offsets);
- return die_info_array.size();
+ FindByName(name, die_info_array);
+ DWARFMappedHash::ExtractDIEArray(die_info_array, tag, callback);
}
-size_t DWARFMappedHash::MemoryTable::FindByNameAndTagAndQualifiedNameHash(
+void DWARFMappedHash::MemoryTable::FindByNameAndTagAndQualifiedNameHash(
llvm::StringRef name, const dw_tag_t tag,
- const uint32_t qualified_name_hash, DIEArray &die_offsets) {
+ const uint32_t qualified_name_hash,
+ llvm::function_ref<bool(DIERef ref)> callback) {
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();
+ FindByName(name, die_info_array);
+ DWARFMappedHash::ExtractDIEArray(die_info_array, tag, qualified_name_hash,
+ callback);
}
-size_t DWARFMappedHash::MemoryTable::FindCompleteObjCClassByName(
- llvm::StringRef name, DIEArray &die_offsets, bool must_be_implementation) {
+void DWARFMappedHash::MemoryTable::FindCompleteObjCClassByName(
+ llvm::StringRef name, llvm::function_ref<bool(DIERef ref)> callback,
+ 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);
- }
+ 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, callback);
+ return;
}
- return die_offsets.size();
+ // 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.
+ bool found_implementation = false;
+ DWARFMappedHash::ExtractClassOrStructDIEArray(
+ die_info_array, true /*return_implementation_only_if_available*/,
+ [&](DIERef ref) {
+ found_implementation = true;
+ // Here the return value does not matter as we are called at most once.
+ return callback(ref);
+ });
+ if (found_implementation)
+ return;
+ DWARFMappedHash::ExtractClassOrStructDIEArray(
+ die_info_array, false /*return_implementation_only_if_available*/,
+ callback);
}
-size_t DWARFMappedHash::MemoryTable::FindByName(llvm::StringRef name,
- DIEInfoArray &die_info_array) {
+void DWARFMappedHash::MemoryTable::FindByName(llvm::StringRef name,
+ DIEInfoArray &die_info_array) {
if (name.empty())
- return 0;
+ return;
Pair kv_pair;
- size_t old_size = die_info_array.size();
- if (Find(name, kv_pair)) {
+ if (Find(name, kv_pair))
die_info_array.swap(kv_pair.value);
- return die_info_array.size() - old_size;
- }
- return 0;
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
index 56d9bc548877..ad178fc6a987 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_HashedNameToDIE_h_
-#define SymbolFileDWARF_HashedNameToDIE_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_HASHEDNAMETODIE_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_HASHEDNAMETODIE_H
#include <vector>
@@ -132,33 +132,36 @@ public:
bool ReadHashData(uint32_t hash_data_offset,
HashData &hash_data) const override;
- size_t
+ void
AppendAllDIEsThatMatchingRegex(const lldb_private::RegularExpression &regex,
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;
+ void AppendAllDIEsInRange(const uint32_t die_offset_start,
+ const uint32_t die_offset_end,
+ DIEInfoArray &die_info_array) const;
- size_t FindByName(llvm::StringRef name, DIEArray &die_offsets);
+ bool FindByName(llvm::StringRef name,
+ llvm::function_ref<bool(DIERef ref)> callback);
- size_t FindByNameAndTag(llvm::StringRef name, const dw_tag_t tag,
- DIEArray &die_offsets);
+ void FindByNameAndTag(llvm::StringRef name, const dw_tag_t tag,
+ llvm::function_ref<bool(DIERef ref)> callback);
- size_t FindByNameAndTagAndQualifiedNameHash(
+ void FindByNameAndTagAndQualifiedNameHash(
llvm::StringRef name, const dw_tag_t tag,
- const uint32_t qualified_name_hash, DIEArray &die_offsets);
+ const uint32_t qualified_name_hash,
+ llvm::function_ref<bool(DIERef ref)> callback);
- size_t FindCompleteObjCClassByName(llvm::StringRef name,
- DIEArray &die_offsets,
- bool must_be_implementation);
+ void
+ FindCompleteObjCClassByName(llvm::StringRef name,
+ llvm::function_ref<bool(DIERef ref)> callback,
+ bool must_be_implementation);
protected:
Result AppendHashDataForRegularExpression(
const lldb_private::RegularExpression &regex,
lldb::offset_t *hash_data_offset_ptr, Pair &pair) const;
- size_t FindByName(llvm::StringRef name, DIEInfoArray &die_info_array);
+ void FindByName(llvm::StringRef name, DIEInfoArray &die_info_array);
Result GetHashDataForName(llvm::StringRef name,
lldb::offset_t *hash_data_offset_ptr,
@@ -169,29 +172,30 @@ public:
std::string m_name;
};
- static void ExtractDIEArray(const DIEInfoArray &die_info_array,
- DIEArray &die_offsets);
+ static bool ExtractDIEArray(const DIEInfoArray &die_info_array,
+ llvm::function_ref<bool(DIERef ref)> callback);
protected:
static void ExtractDIEArray(const DIEInfoArray &die_info_array,
- const dw_tag_t tag, DIEArray &die_offsets);
+ const dw_tag_t tag,
+ llvm::function_ref<bool(DIERef ref)> callback);
static void ExtractDIEArray(const DIEInfoArray &die_info_array,
const dw_tag_t tag,
const uint32_t qualified_name_hash,
- DIEArray &die_offsets);
+ llvm::function_ref<bool(DIERef ref)> callback);
static void
ExtractClassOrStructDIEArray(const DIEInfoArray &die_info_array,
bool return_implementation_only_if_available,
- DIEArray &die_offsets);
+ llvm::function_ref<bool(DIERef ref)> callback);
- static void ExtractTypesFromDIEArray(const DIEInfoArray &die_info_array,
- uint32_t type_flag_mask,
- uint32_t type_flag_value,
- DIEArray &die_offsets);
+ static void
+ ExtractTypesFromDIEArray(const DIEInfoArray &die_info_array,
+ uint32_t type_flag_mask, uint32_t type_flag_value,
+ llvm::function_ref<bool(DIERef ref)> callback);
static const char *GetAtomTypeName(uint16_t atom);
};
-#endif // SymbolFileDWARF_HashedNameToDIE_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_HASHEDNAMETODIE_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
index 8495016d4280..3f1d6677bacf 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
@@ -1,4 +1,4 @@
-//===-- LogChannelDWARF.cpp ------------------------------------*- C++ -*-===//
+//===-- LogChannelDWARF.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h
index a89c686735d2..2fc23563ef93 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_LogChannelDWARF_h_
-#define SymbolFileDWARF_LogChannelDWARF_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_LOGCHANNELDWARF_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_LOGCHANNELDWARF_H
#include "lldb/Utility/Log.h"
@@ -32,4 +32,4 @@ public:
};
}
-#endif // SymbolFileDWARF_LogChannelDWARF_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_LOGCHANNELDWARF_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 1e5927bd14f0..7bf4b52bc783 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -1,4 +1,4 @@
-//===-- ManualDWARFIndex.cpp -----------------------------------*- C++ -*-===//
+//===-- ManualDWARFIndex.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -13,31 +13,47 @@
#include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h"
#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h"
#include "lldb/Core/Module.h"
-#include "lldb/Host/TaskPool.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/Timer.h"
+#include "llvm/Support/ThreadPool.h"
using namespace lldb_private;
using namespace lldb;
void ManualDWARFIndex::Index() {
- if (!m_debug_info)
+ if (!m_dwarf)
return;
- DWARFDebugInfo &debug_info = *m_debug_info;
- m_debug_info = nullptr;
+ SymbolFileDWARF &main_dwarf = *m_dwarf;
+ m_dwarf = nullptr;
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
- Timer scoped_timer(func_cat, "%p", static_cast<void *>(&debug_info));
+ Timer scoped_timer(func_cat, "%p", static_cast<void *>(&main_dwarf));
+
+ DWARFDebugInfo &main_info = main_dwarf.DebugInfo();
+ SymbolFileDWARFDwo *dwp_dwarf = main_dwarf.GetDwpSymbolFile().get();
+ DWARFDebugInfo *dwp_info = dwp_dwarf ? &dwp_dwarf->DebugInfo() : nullptr;
std::vector<DWARFUnit *> units_to_index;
- units_to_index.reserve(debug_info.GetNumUnits());
- for (size_t U = 0; U < debug_info.GetNumUnits(); ++U) {
- DWARFUnit *unit = debug_info.GetUnitAtIndex(U);
+ units_to_index.reserve(main_info.GetNumUnits() +
+ (dwp_info ? dwp_info->GetNumUnits() : 0));
+
+ // Process all units in the main file, as well as any type units in the dwp
+ // file. Type units in dwo files are handled when we reach the dwo file in
+ // IndexUnit.
+ for (size_t U = 0; U < main_info.GetNumUnits(); ++U) {
+ DWARFUnit *unit = main_info.GetUnitAtIndex(U);
if (unit && m_units_to_avoid.count(unit->GetOffset()) == 0)
units_to_index.push_back(unit);
}
+ if (dwp_info && dwp_info->ContainsTypeUnits()) {
+ for (size_t U = 0; U < dwp_info->GetNumUnits(); ++U) {
+ if (auto *tu = llvm::dyn_cast<DWARFTypeUnit>(dwp_info->GetUnitAtIndex(U)))
+ units_to_index.push_back(tu);
+ }
+ }
+
if (units_to_index.empty())
return;
@@ -48,27 +64,34 @@ void ManualDWARFIndex::Index() {
std::vector<llvm::Optional<DWARFUnit::ScopedExtractDIEs>> clear_cu_dies(
units_to_index.size());
auto parser_fn = [&](size_t cu_idx) {
- IndexUnit(*units_to_index[cu_idx], sets[cu_idx]);
+ IndexUnit(*units_to_index[cu_idx], dwp_dwarf, sets[cu_idx]);
};
auto extract_fn = [&units_to_index, &clear_cu_dies](size_t cu_idx) {
clear_cu_dies[cu_idx] = units_to_index[cu_idx]->ExtractDIEsScoped();
};
+ // Share one thread pool across operations to avoid the overhead of
+ // recreating the threads.
+ llvm::ThreadPool pool;
+
// Create a task runner that extracts dies for each DWARF unit in a
- // separate thread
+ // separate thread.
// First figure out which units didn't have their DIEs already
// parsed and remember this. If no DIEs were parsed prior to this index
// function call, we are going to want to clear the CU dies after we are
// done indexing to make sure we don't pull in all DWARF dies, but we need
// to wait until all units have been indexed in case a DIE in one
// unit refers to another and the indexes accesses those DIEs.
- TaskMapOverInt(0, units_to_index.size(), extract_fn);
+ for (size_t i = 0; i < units_to_index.size(); ++i)
+ pool.async(extract_fn, i);
+ pool.wait();
// Now create a task runner that can index each DWARF unit in a
// separate thread so we can index quickly.
-
- TaskMapOverInt(0, units_to_index.size(), parser_fn);
+ for (size_t i = 0; i < units_to_index.size(); ++i)
+ pool.async(parser_fn, i);
+ pool.wait();
auto finalize_fn = [this, &sets](NameToDIE(IndexSet::*index)) {
NameToDIE &result = m_set.*index;
@@ -77,21 +100,19 @@ void ManualDWARFIndex::Index() {
result.Finalize();
};
- TaskPool::RunTasks([&]() { finalize_fn(&IndexSet::function_basenames); },
- [&]() { finalize_fn(&IndexSet::function_fullnames); },
- [&]() { finalize_fn(&IndexSet::function_methods); },
- [&]() { finalize_fn(&IndexSet::function_selectors); },
- [&]() { finalize_fn(&IndexSet::objc_class_selectors); },
- [&]() { finalize_fn(&IndexSet::globals); },
- [&]() { finalize_fn(&IndexSet::types); },
- [&]() { finalize_fn(&IndexSet::namespaces); });
+ pool.async(finalize_fn, &IndexSet::function_basenames);
+ pool.async(finalize_fn, &IndexSet::function_fullnames);
+ pool.async(finalize_fn, &IndexSet::function_methods);
+ pool.async(finalize_fn, &IndexSet::function_selectors);
+ pool.async(finalize_fn, &IndexSet::objc_class_selectors);
+ pool.async(finalize_fn, &IndexSet::globals);
+ pool.async(finalize_fn, &IndexSet::types);
+ pool.async(finalize_fn, &IndexSet::namespaces);
+ pool.wait();
}
-void ManualDWARFIndex::IndexUnit(DWARFUnit &unit, IndexSet &set) {
- assert(
- !unit.GetSymbolFileDWARF().GetBaseCompileUnit() &&
- "DWARFUnit associated with .dwo or .dwp should not be indexed directly");
-
+void ManualDWARFIndex::IndexUnit(DWARFUnit &unit, SymbolFileDWARFDwo *dwp,
+ IndexSet &set) {
Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS);
if (log) {
@@ -100,14 +121,21 @@ void ManualDWARFIndex::IndexUnit(DWARFUnit &unit, IndexSet &set) {
unit.GetOffset());
}
- const LanguageType cu_language = unit.GetLanguageType();
+ const LanguageType cu_language = SymbolFileDWARF::GetLanguage(unit);
IndexUnitImpl(unit, cu_language, set);
if (SymbolFileDWARFDwo *dwo_symbol_file = unit.GetDwoSymbolFile()) {
- DWARFDebugInfo &dwo_info = *dwo_symbol_file->DebugInfo();
- for (size_t i = 0; i < dwo_info.GetNumUnits(); ++i)
- IndexUnitImpl(*dwo_info.GetUnitAtIndex(i), cu_language, set);
+ // Type units in a dwp file are indexed separately, so we just need to
+ // process the split unit here. However, if the split unit is in a dwo file,
+ // then we need to process type units here.
+ if (dwo_symbol_file == dwp) {
+ IndexUnitImpl(unit.GetNonSkeletonUnit(), cu_language, set);
+ } else {
+ DWARFDebugInfo &dwo_info = dwo_symbol_file->DebugInfo();
+ for (size_t i = 0; i < dwo_info.GetNumUnits(); ++i)
+ IndexUnitImpl(*dwo_info.GetUnitAtIndex(i), cu_language, set);
+ }
}
}
@@ -165,12 +193,6 @@ void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit,
is_declaration = form_value.Unsigned() != 0;
break;
- // case DW_AT_artificial:
- // 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(i, form_value))
@@ -190,49 +212,8 @@ void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit,
case DW_AT_location:
case DW_AT_const_value:
has_location_or_const_value = true;
- if (tag == DW_TAG_variable) {
- const DWARFDebugInfoEntry *parent_die = die.GetParent();
- while (parent_die != nullptr) {
- switch (parent_die->Tag()) {
- case DW_TAG_subprogram:
- case DW_TAG_lexical_block:
- case DW_TAG_inlined_subroutine:
- // Even if this is a function level static, we don't add it. We
- // could theoretically add these if we wanted to by
- // introspecting into the DW_AT_location and seeing if the
- // location describes a hard coded address, but we don't want
- // the performance penalty of that right now.
- is_global_or_static_variable = false;
- // if (attributes.ExtractFormValueAtIndex(dwarf, i,
- // form_value)) {
- // // If we have valid block data, then we have location
- // // expression bytesthat 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.UnitAtIndex(i)->GetAddressByteSize()) {
- // if (block_data[0] == DW_OP_addr)
- // add_die = true;
- // }
- // }
- // }
- parent_die = nullptr; // Terminate the while loop.
- break;
-
- case DW_TAG_compile_unit:
- case DW_TAG_partial_unit:
- is_global_or_static_variable = true;
- parent_die = nullptr; // Terminate the while loop.
- break;
-
- default:
- parent_die =
- parent_die->GetParent(); // Keep going in the while loop.
- break;
- }
- }
- }
+ is_global_or_static_variable = die.IsGlobalOrStaticScopeVariable();
+
break;
case DW_AT_specification:
@@ -347,108 +328,118 @@ void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit,
}
}
-void ManualDWARFIndex::GetGlobalVariables(ConstString basename, DIEArray &offsets) {
+void ManualDWARFIndex::GetGlobalVariables(
+ ConstString basename, llvm::function_ref<bool(DWARFDIE die)> callback) {
Index();
- m_set.globals.Find(basename, offsets);
+ m_set.globals.Find(basename,
+ DIERefCallback(callback, basename.GetStringRef()));
}
-void ManualDWARFIndex::GetGlobalVariables(const RegularExpression &regex,
- DIEArray &offsets) {
+void ManualDWARFIndex::GetGlobalVariables(
+ const RegularExpression &regex,
+ llvm::function_ref<bool(DWARFDIE die)> callback) {
Index();
- m_set.globals.Find(regex, offsets);
+ m_set.globals.Find(regex, DIERefCallback(callback, regex.GetText()));
}
-void ManualDWARFIndex::GetGlobalVariables(const DWARFUnit &unit,
- DIEArray &offsets) {
+void ManualDWARFIndex::GetGlobalVariables(
+ const DWARFUnit &unit, llvm::function_ref<bool(DWARFDIE die)> callback) {
Index();
- m_set.globals.FindAllEntriesForUnit(unit, offsets);
+ m_set.globals.FindAllEntriesForUnit(unit, DIERefCallback(callback));
}
-void ManualDWARFIndex::GetObjCMethods(ConstString class_name,
- DIEArray &offsets) {
+void ManualDWARFIndex::GetObjCMethods(
+ ConstString class_name, llvm::function_ref<bool(DWARFDIE die)> callback) {
Index();
- m_set.objc_class_selectors.Find(class_name, offsets);
+ m_set.objc_class_selectors.Find(
+ class_name, DIERefCallback(callback, class_name.GetStringRef()));
}
-void ManualDWARFIndex::GetCompleteObjCClass(ConstString class_name,
- bool must_be_implementation,
- DIEArray &offsets) {
+void ManualDWARFIndex::GetCompleteObjCClass(
+ ConstString class_name, bool must_be_implementation,
+ llvm::function_ref<bool(DWARFDIE die)> callback) {
Index();
- m_set.types.Find(class_name, offsets);
+ m_set.types.Find(class_name,
+ DIERefCallback(callback, class_name.GetStringRef()));
}
-void ManualDWARFIndex::GetTypes(ConstString name, DIEArray &offsets) {
+void ManualDWARFIndex::GetTypes(
+ ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) {
Index();
- m_set.types.Find(name, offsets);
+ m_set.types.Find(name, DIERefCallback(callback, name.GetStringRef()));
}
-void ManualDWARFIndex::GetTypes(const DWARFDeclContext &context,
- DIEArray &offsets) {
+void ManualDWARFIndex::GetTypes(
+ const DWARFDeclContext &context,
+ llvm::function_ref<bool(DWARFDIE die)> callback) {
Index();
- m_set.types.Find(ConstString(context[0].name), offsets);
+ auto name = context[0].name;
+ m_set.types.Find(ConstString(name),
+ DIERefCallback(callback, llvm::StringRef(name)));
}
-void ManualDWARFIndex::GetNamespaces(ConstString name, DIEArray &offsets) {
+void ManualDWARFIndex::GetNamespaces(
+ ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) {
Index();
- m_set.namespaces.Find(name, offsets);
+ m_set.namespaces.Find(name, DIERefCallback(callback, name.GetStringRef()));
}
-void ManualDWARFIndex::GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
- const CompilerDeclContext &parent_decl_ctx,
- uint32_t name_type_mask,
- std::vector<DWARFDIE> &dies) {
+void ManualDWARFIndex::GetFunctions(
+ ConstString name, SymbolFileDWARF &dwarf,
+ const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask,
+ llvm::function_ref<bool(DWARFDIE die)> callback) {
Index();
if (name_type_mask & eFunctionNameTypeFull) {
- DIEArray offsets;
- m_set.function_fullnames.Find(name, offsets);
- for (const DIERef &die_ref: offsets) {
- DWARFDIE die = dwarf.GetDIE(die_ref);
- if (!die)
- continue;
- if (SymbolFileDWARF::DIEInDeclContext(&parent_decl_ctx, die))
- dies.push_back(die);
- }
+ if (!m_set.function_fullnames.Find(
+ name, DIERefCallback(
+ [&](DWARFDIE die) {
+ if (!SymbolFileDWARF::DIEInDeclContext(parent_decl_ctx,
+ die))
+ return true;
+ return callback(die);
+ },
+ name.GetStringRef())))
+ return;
}
if (name_type_mask & eFunctionNameTypeBase) {
- DIEArray offsets;
- m_set.function_basenames.Find(name, offsets);
- for (const DIERef &die_ref: offsets) {
- DWARFDIE die = dwarf.GetDIE(die_ref);
- if (!die)
- continue;
- if (SymbolFileDWARF::DIEInDeclContext(&parent_decl_ctx, die))
- dies.push_back(die);
- }
- offsets.clear();
+ if (!m_set.function_basenames.Find(
+ name, DIERefCallback(
+ [&](DWARFDIE die) {
+ if (!SymbolFileDWARF::DIEInDeclContext(parent_decl_ctx,
+ die))
+ return true;
+ return callback(die);
+ },
+ name.GetStringRef())))
+ return;
}
if (name_type_mask & eFunctionNameTypeMethod && !parent_decl_ctx.IsValid()) {
- DIEArray offsets;
- m_set.function_methods.Find(name, offsets);
- for (const DIERef &die_ref: offsets) {
- if (DWARFDIE die = dwarf.GetDIE(die_ref))
- dies.push_back(die);
- }
+ if (!m_set.function_methods.Find(
+ name, DIERefCallback(callback, name.GetStringRef())))
+ return;
}
if (name_type_mask & eFunctionNameTypeSelector &&
!parent_decl_ctx.IsValid()) {
- DIEArray offsets;
- m_set.function_selectors.Find(name, offsets);
- for (const DIERef &die_ref: offsets) {
- if (DWARFDIE die = dwarf.GetDIE(die_ref))
- dies.push_back(die);
- }
+ if (!m_set.function_selectors.Find(
+ name, DIERefCallback(callback, name.GetStringRef())))
+ return;
}
}
-void ManualDWARFIndex::GetFunctions(const RegularExpression &regex,
- DIEArray &offsets) {
+void ManualDWARFIndex::GetFunctions(
+ const RegularExpression &regex,
+ llvm::function_ref<bool(DWARFDIE die)> callback) {
Index();
- m_set.function_basenames.Find(regex, offsets);
- m_set.function_fullnames.Find(regex, offsets);
+ if (!m_set.function_basenames.Find(regex,
+ DIERefCallback(callback, regex.GetText())))
+ return;
+ if (!m_set.function_fullnames.Find(regex,
+ DIERefCallback(callback, regex.GetText())))
+ return;
}
void ManualDWARFIndex::Dump(Stream &s) {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
index dd03b103c936..baff989eecca 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
@@ -6,42 +6,53 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_MANUALDWARFINDEX_H
-#define LLDB_MANUALDWARFINDEX_H
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_MANUALDWARFINDEX_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_MANUALDWARFINDEX_H
#include "Plugins/SymbolFile/DWARF/DWARFIndex.h"
#include "Plugins/SymbolFile/DWARF/NameToDIE.h"
#include "llvm/ADT/DenseSet.h"
class DWARFDebugInfo;
+class SymbolFileDWARFDwo;
namespace lldb_private {
class ManualDWARFIndex : public DWARFIndex {
public:
- ManualDWARFIndex(Module &module, DWARFDebugInfo *debug_info,
+ ManualDWARFIndex(Module &module, SymbolFileDWARF &dwarf,
llvm::DenseSet<dw_offset_t> units_to_avoid = {})
- : DWARFIndex(module), m_debug_info(debug_info),
+ : DWARFIndex(module), m_dwarf(&dwarf),
m_units_to_avoid(std::move(units_to_avoid)) {}
void Preload() override { Index(); }
- void GetGlobalVariables(ConstString basename, DIEArray &offsets) override;
- void GetGlobalVariables(const RegularExpression &regex,
- DIEArray &offsets) override;
- void GetGlobalVariables(const DWARFUnit &unit, DIEArray &offsets) override;
- void GetObjCMethods(ConstString class_name, DIEArray &offsets) override;
- void GetCompleteObjCClass(ConstString class_name, bool must_be_implementation,
- DIEArray &offsets) override;
- void GetTypes(ConstString name, DIEArray &offsets) override;
- void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override;
- void GetNamespaces(ConstString name, DIEArray &offsets) override;
+ void
+ GetGlobalVariables(ConstString basename,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void
+ GetGlobalVariables(const RegularExpression &regex,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void
+ GetGlobalVariables(const DWARFUnit &unit,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetObjCMethods(ConstString class_name,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetCompleteObjCClass(
+ ConstString class_name, bool must_be_implementation,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetTypes(ConstString name,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetTypes(const DWARFDeclContext &context,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetNamespaces(ConstString name,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
void GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
uint32_t name_type_mask,
- std::vector<DWARFDIE> &dies) override;
- void GetFunctions(const RegularExpression &regex, DIEArray &offsets) override;
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetFunctions(const RegularExpression &regex,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
- void ReportInvalidDIERef(const DIERef &ref, llvm::StringRef name) override {}
void Dump(Stream &s) override;
private:
@@ -56,14 +67,15 @@ private:
NameToDIE namespaces;
};
void Index();
- void IndexUnit(DWARFUnit &unit, IndexSet &set);
+ void IndexUnit(DWARFUnit &unit, SymbolFileDWARFDwo *dwp, IndexSet &set);
static void IndexUnitImpl(DWARFUnit &unit,
const lldb::LanguageType cu_language,
IndexSet &set);
- /// Non-null value means we haven't built the index yet.
- DWARFDebugInfo *m_debug_info;
+ /// The DWARF file which we are indexing. Set to nullptr after the index is
+ /// built.
+ SymbolFileDWARF *m_dwarf;
/// Which dwarf units should we skip while building the index.
llvm::DenseSet<dw_offset_t> m_units_to_avoid;
@@ -71,4 +83,4 @@ private:
};
} // namespace lldb_private
-#endif // LLDB_MANUALDWARFINDEX_H
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_MANUALDWARFINDEX_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
index 7d81afb1b226..42e96af84a96 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
@@ -1,4 +1,4 @@
-//===-- NameToDIE.cpp -------------------------------------------*- C++ -*-===//
+//===-- NameToDIE.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -26,28 +26,38 @@ void NameToDIE::Insert(ConstString name, const DIERef &die_ref) {
m_map.Append(name, die_ref);
}
-size_t NameToDIE::Find(ConstString name, DIEArray &info_array) const {
- return m_map.GetValues(name, info_array);
+bool NameToDIE::Find(ConstString name,
+ llvm::function_ref<bool(DIERef ref)> callback) const {
+ for (const auto &entry : m_map.equal_range(name))
+ if (!callback(entry.value))
+ return false;
+ return true;
}
-size_t NameToDIE::Find(const RegularExpression &regex,
- DIEArray &info_array) const {
- return m_map.GetValues(regex, info_array);
+bool NameToDIE::Find(const RegularExpression &regex,
+ llvm::function_ref<bool(DIERef ref)> callback) const {
+ for (const auto &entry : m_map)
+ if (regex.Execute(entry.cstring.GetCString())) {
+ if (!callback(entry.value))
+ return false;
+ }
+ return true;
}
-size_t NameToDIE::FindAllEntriesForUnit(const DWARFUnit &unit,
- DIEArray &info_array) const {
- const size_t initial_size = info_array.size();
+void NameToDIE::FindAllEntriesForUnit(
+ const DWARFUnit &unit,
+ llvm::function_ref<bool(DIERef ref)> callback) const {
const uint32_t size = m_map.GetSize();
for (uint32_t i = 0; i < size; ++i) {
const DIERef &die_ref = m_map.GetValueAtIndexUnchecked(i);
if (unit.GetSymbolFileDWARF().GetDwoNum() == die_ref.dwo_num() &&
unit.GetDebugSection() == die_ref.section() &&
unit.GetOffset() <= die_ref.die_offset() &&
- die_ref.die_offset() < unit.GetNextUnitOffset())
- info_array.push_back(die_ref);
+ die_ref.die_offset() < unit.GetNextUnitOffset()) {
+ if (!callback(die_ref))
+ return;
+ }
}
- return info_array.size() - initial_size;
}
void NameToDIE::Dump(Stream *s) {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h
index b504f45e81b5..5aa841cf3d10 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_NameToDIE_h_
-#define SymbolFileDWARF_NameToDIE_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_NAMETODIE_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_NAMETODIE_H
#include <functional>
@@ -32,14 +32,15 @@ public:
void Finalize();
- size_t Find(lldb_private::ConstString name,
- DIEArray &info_array) const;
+ bool Find(lldb_private::ConstString name,
+ llvm::function_ref<bool(DIERef ref)> callback) const;
- size_t Find(const lldb_private::RegularExpression &regex,
- DIEArray &info_array) const;
+ bool Find(const lldb_private::RegularExpression &regex,
+ llvm::function_ref<bool(DIERef ref)> callback) const;
- size_t FindAllEntriesForUnit(const DWARFUnit &unit,
- DIEArray &info_array) const;
+ void
+ FindAllEntriesForUnit(const DWARFUnit &unit,
+ llvm::function_ref<bool(DIERef ref)> callback) const;
void
ForEach(std::function<bool(lldb_private::ConstString name,
@@ -50,4 +51,4 @@ protected:
lldb_private::UniqueCStringMap<DIERef> m_map;
};
-#endif // SymbolFileDWARF_NameToDIE_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_NAMETODIE_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index d45a8b56efe4..9f64e5255fd5 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1,4 +1,4 @@
-//===-- SymbolFileDWARF.cpp ------------------------------------*- C++ -*-===//
+//===-- SymbolFileDWARF.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -34,9 +34,9 @@
#include "lldb/Interpreter/OptionValueFileSpecList.h"
#include "lldb/Interpreter/OptionValueProperties.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Symbol/Block.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/CompilerDecl.h"
#include "lldb/Symbol/CompilerDeclContext.h"
@@ -70,7 +70,6 @@
#include "ManualDWARFIndex.h"
#include "SymbolFileDWARFDebugMap.h"
#include "SymbolFileDWARFDwo.h"
-#include "SymbolFileDWARFDwp.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/Support/FileSystem.h"
@@ -94,6 +93,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(SymbolFileDWARF)
+
char SymbolFileDWARF::ID;
// static inline bool
@@ -135,14 +136,6 @@ public:
m_collection_sp->Initialize(g_symbolfiledwarf_properties);
}
- FileSpecList GetSymLinkPaths() {
- const OptionValueFileSpecList *option_value =
- m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(
- nullptr, true, ePropertySymLinkPaths);
- assert(option_value);
- return option_value->GetCurrentValue();
- }
-
bool IgnoreFileIndexes() const {
return m_collection_sp->GetPropertyAtIndexAsBoolean(
nullptr, ePropertyIgnoreIndexes, false);
@@ -169,18 +162,46 @@ ParseLLVMLineTable(lldb_private::DWARFContext &context,
llvm::Expected<const llvm::DWARFDebugLine::LineTable *> line_table =
line.getOrParseLineTable(
data, line_offset, ctx, nullptr, [&](llvm::Error e) {
- LLDB_LOG_ERROR(log, std::move(e),
- "SymbolFileDWARF::ParseLineTable failed to parse");
+ LLDB_LOG_ERROR(
+ log, std::move(e),
+ "SymbolFileDWARF::ParseLineTable failed to parse: {0}");
});
if (!line_table) {
LLDB_LOG_ERROR(log, line_table.takeError(),
- "SymbolFileDWARF::ParseLineTable failed to parse");
+ "SymbolFileDWARF::ParseLineTable failed to parse: {0}");
return nullptr;
}
return *line_table;
}
+static bool ParseLLVMLineTablePrologue(lldb_private::DWARFContext &context,
+ llvm::DWARFDebugLine::Prologue &prologue,
+ dw_offset_t line_offset,
+ dw_offset_t unit_offset) {
+ Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
+ bool success = true;
+ llvm::DWARFDataExtractor data = context.getOrLoadLineData().GetAsLLVM();
+ llvm::DWARFContext &ctx = context.GetAsLLVM();
+ uint64_t offset = line_offset;
+ llvm::Error error = prologue.parse(
+ data, &offset,
+ [&](llvm::Error e) {
+ success = false;
+ LLDB_LOG_ERROR(log, std::move(e),
+ "SymbolFileDWARF::ParseSupportFiles failed to parse "
+ "line table prologue: {0}");
+ },
+ ctx, nullptr);
+ if (error) {
+ LLDB_LOG_ERROR(log, std::move(error),
+ "SymbolFileDWARF::ParseSupportFiles failed to parse line "
+ "table prologue: {0}");
+ return false;
+ }
+ return success;
+}
+
static llvm::Optional<std::string>
GetFileByIndex(const llvm::DWARFDebugLine::Prologue &prologue, size_t idx,
llvm::StringRef compile_dir, FileSpec::Style style) {
@@ -192,7 +213,7 @@ GetFileByIndex(const llvm::DWARFDebugLine::Prologue &prologue, size_t idx,
// Otherwise ask for a relative path.
std::string rel_path;
- auto relative = llvm::DILineInfoSpecifier::FileLineInfoKind::Default;
+ auto relative = llvm::DILineInfoSpecifier::FileLineInfoKind::RawValue;
if (!prologue.getFileNameByIndex(idx, compile_dir, relative, rel_path, style))
return {};
return std::move(rel_path);
@@ -227,15 +248,12 @@ ParseSupportFilesFromPrologue(const lldb::ModuleSP &module,
return support_files;
}
-FileSpecList SymbolFileDWARF::GetSymlinkPaths() {
- return GetGlobalPluginProperties()->GetSymLinkPaths();
-}
-
void SymbolFileDWARF::Initialize() {
LogChannelDWARF::Initialize();
PluginManager::RegisterPlugin(GetPluginNameStatic(),
GetPluginDescriptionStatic(), CreateInstance,
DebuggerInitialize);
+ SymbolFileDWARFDebugMap::Initialize();
}
void SymbolFileDWARF::DebuggerInitialize(Debugger &debugger) {
@@ -250,6 +268,7 @@ void SymbolFileDWARF::DebuggerInitialize(Debugger &debugger) {
}
void SymbolFileDWARF::Terminate() {
+ SymbolFileDWARFDebugMap::Terminate();
PluginManager::UnregisterPlugin(CreateInstance);
LogChannelDWARF::Terminate();
}
@@ -333,10 +352,8 @@ void SymbolFileDWARF::GetTypes(const DWARFDIE &die, dw_offset_t min_die_offset,
if (add_type) {
const bool assert_not_being_parsed = true;
Type *type = ResolveTypeUID(die, assert_not_being_parsed);
- if (type) {
- if (type_set.find(type) == type_set.end())
- type_set.insert(type);
- }
+ if (type)
+ type_set.insert(type);
}
}
@@ -366,15 +383,12 @@ void SymbolFileDWARF::GetTypes(SymbolContextScope *sc_scope,
GetTypes(dwarf_cu->DIE(), dwarf_cu->GetOffset(),
dwarf_cu->GetNextUnitOffset(), type_mask, type_set);
} else {
- DWARFDebugInfo *info = DebugInfo();
- if (info) {
- const size_t num_cus = info->GetNumUnits();
- for (size_t cu_idx = 0; cu_idx < num_cus; ++cu_idx) {
- dwarf_cu = info->GetUnitAtIndex(cu_idx);
- if (dwarf_cu) {
- GetTypes(dwarf_cu->DIE(), 0, UINT32_MAX, type_mask, type_set);
- }
- }
+ DWARFDebugInfo &info = DebugInfo();
+ const size_t num_cus = info.GetNumUnits();
+ for (size_t cu_idx = 0; cu_idx < num_cus; ++cu_idx) {
+ dwarf_cu = info.GetUnitAtIndex(cu_idx);
+ if (dwarf_cu)
+ GetTypes(dwarf_cu->DIE(), 0, UINT32_MAX, type_mask, type_set);
}
}
@@ -418,9 +432,8 @@ SymbolFileDWARF::SymbolFileDWARF(ObjectFileSP objfile_sp,
// contain the .o file index/ID
m_debug_map_module_wp(), m_debug_map_symfile(nullptr),
m_context(m_objfile_sp->GetModule()->GetSectionList(), dwo_section_list),
- m_data_debug_loc(), m_abbr(), m_info(), m_fetched_external_modules(false),
- m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate),
- m_unique_ast_type_map() {}
+ m_fetched_external_modules(false),
+ m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate) {}
SymbolFileDWARF::~SymbolFileDWARF() {}
@@ -471,9 +484,9 @@ void SymbolFileDWARF::InitializeObject() {
LoadSectionData(eSectionTypeDWARFDebugNames, debug_names);
if (debug_names.GetByteSize() > 0) {
llvm::Expected<std::unique_ptr<DebugNamesDWARFIndex>> index_or =
- DebugNamesDWARFIndex::Create(
- *GetObjectFile()->GetModule(), debug_names,
- m_context.getOrLoadStrData(), DebugInfo());
+ DebugNamesDWARFIndex::Create(*GetObjectFile()->GetModule(),
+ debug_names,
+ m_context.getOrLoadStrData(), *this);
if (index_or) {
m_index = std::move(*index_or);
return;
@@ -483,8 +496,8 @@ void SymbolFileDWARF::InitializeObject() {
}
}
- m_index = std::make_unique<ManualDWARFIndex>(*GetObjectFile()->GetModule(),
- DebugInfo());
+ m_index =
+ std::make_unique<ManualDWARFIndex>(*GetObjectFile()->GetModule(), *this);
}
bool SymbolFileDWARF::SupportedVersion(uint16_t version) {
@@ -573,15 +586,6 @@ uint32_t SymbolFileDWARF::CalculateAbilities() {
return abilities;
}
-const DWARFDataExtractor &
-SymbolFileDWARF::GetCachedSectionData(lldb::SectionType sect_type,
- DWARFDataSegment &data_segment) {
- llvm::call_once(data_segment.m_flag, [this, sect_type, &data_segment] {
- this->LoadSectionData(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_objfile_sp->GetModule());
@@ -618,23 +622,14 @@ DWARFDebugAbbrev *SymbolFileDWARF::DebugAbbrev() {
return m_abbr.get();
}
-const DWARFDebugAbbrev *SymbolFileDWARF::DebugAbbrev() const {
- return m_abbr.get();
-}
-
-DWARFDebugInfo *SymbolFileDWARF::DebugInfo() {
- if (m_info == nullptr) {
+DWARFDebugInfo &SymbolFileDWARF::DebugInfo() {
+ llvm::call_once(m_info_once_flag, [&] {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, "%s this = %p", LLVM_PRETTY_FUNCTION,
static_cast<void *>(this));
- if (m_context.getOrLoadDebugInfoData().GetByteSize() > 0)
- m_info = std::make_unique<DWARFDebugInfo>(*this, m_context);
- }
- return m_info.get();
-}
-
-const DWARFDebugInfo *SymbolFileDWARF::DebugInfo() const {
- return m_info.get();
+ m_info = std::make_unique<DWARFDebugInfo>(*this, m_context);
+ });
+ return *m_info;
}
DWARFUnit *
@@ -642,15 +637,11 @@ SymbolFileDWARF::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) {
if (!comp_unit)
return nullptr;
- DWARFDebugInfo *info = DebugInfo();
- if (info) {
- // The compile unit ID is the index of the DWARF unit.
- DWARFUnit *dwarf_cu = info->GetUnitAtIndex(comp_unit->GetID());
- if (dwarf_cu && dwarf_cu->GetUserData() == nullptr)
- dwarf_cu->SetUserData(comp_unit);
- return dwarf_cu;
- }
- return nullptr;
+ // The compile unit ID is the index of the DWARF unit.
+ DWARFUnit *dwarf_cu = DebugInfo().GetUnitAtIndex(comp_unit->GetID());
+ if (dwarf_cu && dwarf_cu->GetUserData() == nullptr)
+ dwarf_cu->SetUserData(comp_unit);
+ return dwarf_cu;
}
DWARFDebugRanges *SymbolFileDWARF::GetDebugRanges() {
@@ -660,7 +651,7 @@ DWARFDebugRanges *SymbolFileDWARF::GetDebugRanges() {
static_cast<void *>(this));
if (m_context.getOrLoadRangesData().GetByteSize() > 0)
- m_ranges.reset(new DWARFDebugRanges());
+ m_ranges = std::make_unique<DWARFDebugRanges>();
if (m_ranges)
m_ranges->Extract(m_context);
@@ -668,6 +659,22 @@ DWARFDebugRanges *SymbolFileDWARF::GetDebugRanges() {
return m_ranges.get();
}
+/// Make an absolute path out of \p file_spec and remap it using the
+/// module's source remapping dictionary.
+static void MakeAbsoluteAndRemap(FileSpec &file_spec, DWARFUnit &dwarf_cu,
+ const ModuleSP &module_sp) {
+ if (!file_spec)
+ return;
+ // 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.
+ file_spec.MakeAbsolute(dwarf_cu.GetCompilationDirectory());
+
+ std::string remapped_file;
+ if (module_sp->RemapSourceFile(file_spec.GetPath(), remapped_file))
+ file_spec.SetFile(remapped_file, FileSpec::Style::native);
+}
+
lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) {
CompUnitSP cu_sp;
CompileUnit *comp_unit = (CompileUnit *)dwarf_cu.GetUserData();
@@ -675,9 +682,7 @@ lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) {
// We already parsed this compile unit, had out a shared pointer to it
cu_sp = comp_unit->shared_from_this();
} else {
- if (&dwarf_cu.GetSymbolFileDWARF() != this) {
- return dwarf_cu.GetSymbolFileDWARF().ParseCompileUnit(dwarf_cu);
- } else if (dwarf_cu.GetOffset() == 0 && GetDebugMapSymfile()) {
+ if (dwarf_cu.GetOffset() == 0 && GetDebugMapSymfile()) {
// Let the debug map create the compile unit
cu_sp = m_debug_map_symfile->GetCompileUnit(this);
dwarf_cu.SetUserData(cu_sp.get());
@@ -688,19 +693,9 @@ lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) {
dwarf_cu.GetNonSkeletonUnit().GetUnitDIEOnly();
if (cu_die) {
FileSpec cu_file_spec(cu_die.GetName(), dwarf_cu.GetPathStyle());
- if (cu_file_spec) {
- // If we have a full path to the compile unit, we don't need to
- // resolve the file. This can be expensive e.g. when the source
- // files are NFS mounted.
- cu_file_spec.MakeAbsolute(dwarf_cu.GetCompilationDirectory());
-
- std::string remapped_file;
- if (module_sp->RemapSourceFile(cu_file_spec.GetPath(),
- remapped_file))
- cu_file_spec.SetFile(remapped_file, FileSpec::Style::native);
- }
+ MakeAbsoluteAndRemap(cu_file_spec, dwarf_cu, module_sp);
- LanguageType cu_language = DWARFUnit::LanguageTypeFromDWARF(
+ LanguageType cu_language = SymbolFileDWARF::LanguageTypeFromDWARF(
cu_die.GetAttributeValueAsUnsigned(DW_AT_language, 0));
bool is_optimized = dwarf_cu.GetNonSkeletonUnit().GetIsOptimized();
@@ -724,16 +719,13 @@ void SymbolFileDWARF::BuildCuTranslationTable() {
if (!m_lldb_cu_to_dwarf_unit.empty())
return;
- DWARFDebugInfo *info = DebugInfo();
- if (!info)
- return;
-
- if (!info->ContainsTypeUnits()) {
+ DWARFDebugInfo &info = DebugInfo();
+ if (!info.ContainsTypeUnits()) {
// We can use a 1-to-1 mapping. No need to build a translation table.
return;
}
- for (uint32_t i = 0, num = info->GetNumUnits(); i < num; ++i) {
- if (auto *cu = llvm::dyn_cast<DWARFCompileUnit>(info->GetUnitAtIndex(i))) {
+ for (uint32_t i = 0, num = info.GetNumUnits(); i < num; ++i) {
+ if (auto *cu = llvm::dyn_cast<DWARFCompileUnit>(info.GetUnitAtIndex(i))) {
cu->SetID(m_lldb_cu_to_dwarf_unit.size());
m_lldb_cu_to_dwarf_unit.push_back(i);
}
@@ -750,23 +742,16 @@ llvm::Optional<uint32_t> SymbolFileDWARF::GetDWARFUnitIndex(uint32_t cu_idx) {
}
uint32_t SymbolFileDWARF::CalculateNumCompileUnits() {
- DWARFDebugInfo *info = DebugInfo();
- if (!info)
- return 0;
BuildCuTranslationTable();
- return m_lldb_cu_to_dwarf_unit.empty() ? info->GetNumUnits()
+ return m_lldb_cu_to_dwarf_unit.empty() ? DebugInfo().GetNumUnits()
: m_lldb_cu_to_dwarf_unit.size();
}
CompUnitSP SymbolFileDWARF::ParseCompileUnitAtIndex(uint32_t cu_idx) {
ASSERT_MODULE_LOCK(this);
- DWARFDebugInfo *info = DebugInfo();
- if (!info)
- return {};
-
if (llvm::Optional<uint32_t> dwarf_idx = GetDWARFUnitIndex(cu_idx)) {
if (auto *dwarf_cu = llvm::cast_or_null<DWARFCompileUnit>(
- info->GetUnitAtIndex(*dwarf_idx)))
+ DebugInfo().GetUnitAtIndex(*dwarf_idx)))
return ParseCompileUnit(*dwarf_cu);
}
return {};
@@ -778,8 +763,7 @@ Function *SymbolFileDWARF::ParseFunction(CompileUnit &comp_unit,
if (!die.IsValid())
return nullptr;
- auto type_system_or_err =
- GetTypeSystemForLanguage(die.GetCU()->GetLanguageType());
+ auto type_system_or_err = GetTypeSystemForLanguage(GetLanguage(*die.GetCU()));
if (auto err = type_system_or_err.takeError()) {
LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_SYMBOLS),
std::move(err), "Unable to parse function");
@@ -792,6 +776,13 @@ Function *SymbolFileDWARF::ParseFunction(CompileUnit &comp_unit,
return dwarf_ast->ParseFunctionFromDWARF(comp_unit, die);
}
+lldb::addr_t SymbolFileDWARF::FixupAddress(lldb::addr_t file_addr) {
+ SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile();
+ if (debug_map_symfile)
+ return debug_map_symfile->LinkOSOFileAddress(this, file_addr);
+ return file_addr;
+}
+
bool SymbolFileDWARF::FixupAddress(Address &addr) {
SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile();
if (debug_map_symfile) {
@@ -804,11 +795,39 @@ lldb::LanguageType SymbolFileDWARF::ParseLanguage(CompileUnit &comp_unit) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
if (dwarf_cu)
- return dwarf_cu->GetLanguageType();
+ return GetLanguage(*dwarf_cu);
else
return eLanguageTypeUnknown;
}
+XcodeSDK SymbolFileDWARF::ParseXcodeSDK(CompileUnit &comp_unit) {
+ std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
+ DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
+ if (!dwarf_cu)
+ return {};
+ const DWARFBaseDIE cu_die = dwarf_cu->GetNonSkeletonUnit().GetUnitDIEOnly();
+ if (!cu_die)
+ return {};
+ const char *sdk = cu_die.GetAttributeValueAsString(DW_AT_APPLE_sdk, nullptr);
+ if (!sdk)
+ return {};
+ const char *sysroot =
+ cu_die.GetAttributeValueAsString(DW_AT_LLVM_sysroot, "");
+ // Register the sysroot path remapping with the module belonging to
+ // the CU as well as the one belonging to the symbol file. The two
+ // would be different if this is an OSO object and module is the
+ // corresponding debug map, in which case both should be updated.
+ ModuleSP module_sp = comp_unit.GetModule();
+ if (module_sp)
+ module_sp->RegisterXcodeSDK(sdk, sysroot);
+
+ ModuleSP local_module_sp = m_objfile_sp->GetModule();
+ if (local_module_sp && local_module_sp != module_sp)
+ local_module_sp->RegisterXcodeSDK(sdk, sysroot);
+
+ return {sdk};
+}
+
size_t SymbolFileDWARF::ParseFunctions(CompileUnit &comp_unit) {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, "SymbolFileDWARF::ParseFunctions");
@@ -863,8 +882,24 @@ bool SymbolFileDWARF::ForEachExternalModule(
bool SymbolFileDWARF::ParseSupportFiles(CompileUnit &comp_unit,
FileSpecList &support_files) {
- if (!comp_unit.GetLineTable())
- ParseLineTable(comp_unit);
+ std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
+ DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
+ if (!dwarf_cu)
+ return false;
+
+ dw_offset_t offset = dwarf_cu->GetLineTableOffset();
+ if (offset == DW_INVALID_OFFSET)
+ return false;
+
+ llvm::DWARFDebugLine::Prologue prologue;
+ if (!ParseLLVMLineTablePrologue(m_context, prologue, offset,
+ dwarf_cu->GetOffset()))
+ return false;
+
+ comp_unit.SetSupportFiles(ParseSupportFilesFromPrologue(
+ comp_unit.GetModule(), prologue, dwarf_cu->GetPathStyle(),
+ dwarf_cu->GetCompilationDirectory().GetCString()));
+
return true;
}
@@ -898,12 +933,15 @@ SymbolFileDWARF::GetTypeUnitSupportFiles(DWARFTypeUnit &tu) {
llvm::DWARFDataExtractor data = m_context.getOrLoadLineData().GetAsLLVM();
llvm::DWARFContext &ctx = m_context.GetAsLLVM();
llvm::DWARFDebugLine::Prologue prologue;
- llvm::Error error = prologue.parse(data, &line_table_offset, ctx);
- if (error) {
+ auto report = [](llvm::Error error) {
Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
LLDB_LOG_ERROR(log, std::move(error),
"SymbolFileDWARF::GetTypeUnitSupportFiles failed to parse "
"the line table prologue");
+ };
+ llvm::Error error = prologue.parse(data, &line_table_offset, report, ctx);
+ if (error) {
+ report(std::move(error));
} else {
list = ParseSupportFilesFromPrologue(GetObjectFile()->GetModule(),
prologue, tu.GetPathStyle());
@@ -961,9 +999,12 @@ bool SymbolFileDWARF::ParseImportedModules(
}
std::reverse(module.path.begin(), module.path.end());
if (const char *include_path = module_die.GetAttributeValueAsString(
- DW_AT_LLVM_include_path, nullptr))
- module.search_path = ConstString(include_path);
- if (const char *sysroot = module_die.GetAttributeValueAsString(
+ DW_AT_LLVM_include_path, nullptr)) {
+ FileSpec include_spec(include_path, dwarf_cu->GetPathStyle());
+ MakeAbsoluteAndRemap(include_spec, *dwarf_cu, m_objfile_sp->GetModule());
+ module.search_path = ConstString(include_spec.GetPath());
+ }
+ if (const char *sysroot = dwarf_cu->DIE().GetAttributeValueAsString(
DW_AT_LLVM_sysroot, nullptr))
module.sysroot = ConstString(sysroot);
imported_modules.push_back(module);
@@ -981,18 +1022,13 @@ bool SymbolFileDWARF::ParseLineTable(CompileUnit &comp_unit) {
if (!dwarf_cu)
return false;
- const DWARFBaseDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
- if (!dwarf_cu_die)
- return false;
-
- 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)
+ dw_offset_t offset = dwarf_cu->GetLineTableOffset();
+ if (offset == DW_INVALID_OFFSET)
return false;
llvm::DWARFDebugLine line;
- const llvm::DWARFDebugLine::LineTable *line_table = ParseLLVMLineTable(
- m_context, line, cu_line_offset, dwarf_cu->GetOffset());
+ const llvm::DWARFDebugLine::LineTable *line_table =
+ ParseLLVMLineTable(m_context, line, offset, dwarf_cu->GetOffset());
if (!line_table)
return false;
@@ -1000,20 +1036,23 @@ bool SymbolFileDWARF::ParseLineTable(CompileUnit &comp_unit) {
// FIXME: Rather than parsing the whole line table and then copying it over
// into LLDB, we should explore using a callback to populate the line table
// while we parse to reduce memory usage.
- std::unique_ptr<LineTable> line_table_up =
- std::make_unique<LineTable>(&comp_unit);
- LineSequence *sequence = line_table_up->CreateLineSequenceContainer();
+ std::unique_ptr<LineSequence> sequence =
+ LineTable::CreateLineSequenceContainer();
+ std::vector<std::unique_ptr<LineSequence>> sequences;
for (auto &row : line_table->Rows) {
- line_table_up->AppendLineEntryToSequence(
- sequence, row.Address.Address, row.Line, row.Column, row.File,
+ LineTable::AppendLineEntryToSequence(
+ sequence.get(), row.Address.Address, row.Line, row.Column, row.File,
row.IsStmt, row.BasicBlock, row.PrologueEnd, row.EpilogueBegin,
row.EndSequence);
if (row.EndSequence) {
- line_table_up->InsertSequence(sequence);
- sequence = line_table_up->CreateLineSequenceContainer();
+ sequences.push_back(std::move(sequence));
+ sequence = LineTable::CreateLineSequenceContainer();
}
}
+ std::unique_ptr<LineTable> line_table_up =
+ std::make_unique<LineTable>(&comp_unit, std::move(sequences));
+
if (SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile()) {
// We have an object file that has a line table with addresses that are not
// linked. We need to link the line table and convert the addresses that
@@ -1024,10 +1063,6 @@ bool SymbolFileDWARF::ParseLineTable(CompileUnit &comp_unit) {
comp_unit.SetLineTable(line_table_up.release());
}
- comp_unit.SetSupportFiles(ParseSupportFilesFromPrologue(
- comp_unit.GetModule(), line_table->Prologue, dwarf_cu->GetPathStyle(),
- dwarf_cu->GetCompilationDirectory().GetCString()));
-
return true;
}
@@ -1157,15 +1192,15 @@ size_t SymbolFileDWARF::ParseBlocksRecursive(
(name != nullptr || mangled_name != nullptr)) {
std::unique_ptr<Declaration> decl_up;
if (decl_file != 0 || decl_line != 0 || decl_column != 0)
- decl_up.reset(new Declaration(
+ decl_up = std::make_unique<Declaration>(
comp_unit.GetSupportFiles().GetFileSpecAtIndex(decl_file),
- decl_line, decl_column));
+ decl_line, decl_column);
std::unique_ptr<Declaration> call_up;
if (call_file != 0 || call_line != 0 || call_column != 0)
- call_up.reset(new Declaration(
+ call_up = std::make_unique<Declaration>(
comp_unit.GetSupportFiles().GetFileSpecAtIndex(call_file),
- call_line, call_column));
+ call_line, call_column);
block->SetInlinedFunctionInfo(name, mangled_name, decl_up.get(),
call_up.get());
@@ -1289,7 +1324,7 @@ CompilerDecl SymbolFileDWARF::GetDeclForUID(lldb::user_id_t type_uid) {
// SymbolFileDWARF::GetDIE(). See comments inside the
// SymbolFileDWARF::GetDIE() for details.
if (DWARFDIE die = GetDIE(type_uid))
- return die.GetDecl();
+ return GetDecl(die);
return CompilerDecl();
}
@@ -1302,7 +1337,7 @@ SymbolFileDWARF::GetDeclContextForUID(lldb::user_id_t type_uid) {
// SymbolFileDWARF::GetDIE(). See comments inside the
// SymbolFileDWARF::GetDIE() for details.
if (DWARFDIE die = GetDIE(type_uid))
- return die.GetDeclContext();
+ return GetDeclContext(die);
return CompilerDeclContext();
}
@@ -1313,7 +1348,7 @@ SymbolFileDWARF::GetDeclContextContainingUID(lldb::user_id_t type_uid) {
// SymbolFileDWARF::GetDIE(). See comments inside the
// SymbolFileDWARF::GetDIE() for details.
if (DWARFDIE die = GetDIE(type_uid))
- return die.GetContainingDeclContext();
+ return GetContainingDeclContext(die);
return CompilerDeclContext();
}
@@ -1394,8 +1429,8 @@ bool SymbolFileDWARF::HasForwardDeclForClangType(
}
TypeSystem *type_system = compiler_type.GetTypeSystem();
- ClangASTContext *clang_type_system =
- llvm::dyn_cast_or_null<ClangASTContext>(type_system);
+ TypeSystemClang *clang_type_system =
+ llvm::dyn_cast_or_null<TypeSystemClang>(type_system);
if (!clang_type_system)
return false;
DWARFASTParserClang *ast_parser =
@@ -1406,8 +1441,8 @@ bool SymbolFileDWARF::HasForwardDeclForClangType(
bool SymbolFileDWARF::CompleteType(CompilerType &compiler_type) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
- ClangASTContext *clang_type_system =
- llvm::dyn_cast_or_null<ClangASTContext>(compiler_type.GetTypeSystem());
+ TypeSystemClang *clang_type_system =
+ llvm::dyn_cast_or_null<TypeSystemClang>(compiler_type.GetTypeSystem());
if (clang_type_system) {
DWARFASTParserClang *ast_parser =
static_cast<DWARFASTParserClang *>(clang_type_system->GetDWARFParser());
@@ -1444,8 +1479,7 @@ bool SymbolFileDWARF::CompleteType(CompilerType &compiler_type) {
dwarf_die.GetID(), dwarf_die.GetTagAsCString(),
type->GetName().AsCString());
assert(compiler_type);
- DWARFASTParser *dwarf_ast = dwarf_die.GetDWARFParser();
- if (dwarf_ast)
+ if (DWARFASTParser *dwarf_ast = GetDWARFParser(*dwarf_die.GetCU()))
return dwarf_ast->CompleteTypeFromDWARF(dwarf_die, type, compiler_type);
}
return false;
@@ -1473,20 +1507,25 @@ Type *SymbolFileDWARF::ResolveType(const DWARFDIE &die,
CompileUnit *
SymbolFileDWARF::GetCompUnitForDWARFCompUnit(DWARFCompileUnit &dwarf_cu) {
+ if (dwarf_cu.IsDWOUnit()) {
+ DWARFCompileUnit *non_dwo_cu =
+ static_cast<DWARFCompileUnit *>(dwarf_cu.GetUserData());
+ assert(non_dwo_cu);
+ return non_dwo_cu->GetSymbolFileDWARF().GetCompUnitForDWARFCompUnit(
+ *non_dwo_cu);
+ }
// Check if the symbol vendor already knows about this compile unit?
if (dwarf_cu.GetUserData() == nullptr) {
// The symbol vendor doesn't know about this compile unit, we need to parse
// and add it to the symbol vendor object.
return ParseCompileUnit(dwarf_cu).get();
}
- return (CompileUnit *)dwarf_cu.GetUserData();
+ return static_cast<CompileUnit *>(dwarf_cu.GetUserData());
}
-size_t SymbolFileDWARF::GetObjCMethodDIEOffsets(ConstString class_name,
- DIEArray &method_die_offsets) {
- method_die_offsets.clear();
- m_index->GetObjCMethods(class_name, method_die_offsets);
- return method_die_offsets.size();
+void SymbolFileDWARF::GetObjCMethods(
+ ConstString class_name, llvm::function_ref<bool(DWARFDIE die)> callback) {
+ m_index->GetObjCMethods(class_name, callback);
}
bool SymbolFileDWARF::GetFunction(const DWARFDIE &die, SymbolContext &sc) {
@@ -1522,17 +1561,15 @@ lldb::ModuleSP SymbolFileDWARF::GetExternalModule(ConstString name) {
DWARFDIE
SymbolFileDWARF::GetDIE(const DIERef &die_ref) {
if (die_ref.dwo_num()) {
- return DebugInfo()
- ->GetUnitAtIndex(*die_ref.dwo_num())
- ->GetDwoSymbolFile()
- ->GetDIE(die_ref);
+ SymbolFileDWARF *dwarf = *die_ref.dwo_num() == 0x3fffffff
+ ? m_dwp_symfile.get()
+ : this->DebugInfo()
+ .GetUnitAtIndex(*die_ref.dwo_num())
+ ->GetDwoSymbolFile();
+ return dwarf->DebugInfo().GetDIE(die_ref);
}
- DWARFDebugInfo *debug_info = DebugInfo();
- if (debug_info)
- return debug_info->GetDIE(die_ref);
- else
- return DWARFDIE();
+ return DebugInfo().GetDIE(die_ref);
}
/// Return the DW_AT_(GNU_)dwo_name.
@@ -1569,7 +1606,7 @@ llvm::Optional<uint64_t> SymbolFileDWARF::GetDWOId() {
return {};
}
-std::unique_ptr<SymbolFileDWARFDwo>
+std::shared_ptr<SymbolFileDWARFDwo>
SymbolFileDWARF::GetDwoSymbolFileForCompileUnit(
DWARFUnit &unit, const DWARFDebugInfoEntry &cu_die) {
// If this is a Darwin-style debug map (non-.dSYM) symbol file,
@@ -1589,14 +1626,8 @@ SymbolFileDWARF::GetDwoSymbolFileForCompileUnit(
if (!dwo_name)
return nullptr;
- SymbolFileDWARFDwp *dwp_symfile = GetDwpSymbolFile();
- if (dwp_symfile) {
- uint64_t dwo_id = ::GetDWOId(*dwarf_cu, cu_die);
- std::unique_ptr<SymbolFileDWARFDwo> dwo_symfile =
- dwp_symfile->GetSymbolFileForDwoId(*dwarf_cu, dwo_id);
- if (dwo_symfile)
- return dwo_symfile;
- }
+ if (std::shared_ptr<SymbolFileDWARFDwo> dwp_sp = GetDwpSymbolFile())
+ return dwp_sp;
FileSpec dwo_file(dwo_name);
FileSystem::Instance().Resolve(dwo_file);
@@ -1624,20 +1655,21 @@ SymbolFileDWARF::GetDwoSymbolFileForCompileUnit(
if (dwo_obj_file == nullptr)
return nullptr;
- return std::make_unique<SymbolFileDWARFDwo>(dwo_obj_file, *dwarf_cu);
+ return std::make_shared<SymbolFileDWARFDwo>(*this, dwo_obj_file,
+ dwarf_cu->GetID());
}
void SymbolFileDWARF::UpdateExternalModuleListIfNeeded() {
if (m_fetched_external_modules)
return;
m_fetched_external_modules = true;
- DWARFDebugInfo *debug_info = DebugInfo();
+ DWARFDebugInfo &debug_info = DebugInfo();
// Follow DWO skeleton unit breadcrumbs.
const uint32_t num_compile_units = GetNumCompileUnits();
for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
auto *dwarf_cu =
- llvm::dyn_cast<DWARFCompileUnit>(debug_info->GetUnitAtIndex(cu_idx));
+ llvm::dyn_cast<DWARFCompileUnit>(debug_info.GetUnitAtIndex(cu_idx));
if (!dwarf_cu)
continue;
@@ -1731,7 +1763,7 @@ void SymbolFileDWARF::UpdateExternalModuleListIfNeeded() {
SymbolFileDWARF::GlobalVariableMap &SymbolFileDWARF::GetGlobalAranges() {
if (!m_global_aranges_up) {
- m_global_aranges_up.reset(new GlobalVariableMap());
+ m_global_aranges_up = std::make_unique<GlobalVariableMap>();
ModuleSP module_sp = GetObjectFile()->GetModule();
if (module_sp) {
@@ -1773,6 +1805,32 @@ SymbolFileDWARF::GlobalVariableMap &SymbolFileDWARF::GetGlobalAranges() {
return *m_global_aranges_up;
}
+void SymbolFileDWARF::ResolveFunctionAndBlock(lldb::addr_t file_vm_addr,
+ bool lookup_block,
+ SymbolContext &sc) {
+ assert(sc.comp_unit);
+ DWARFUnit &cu = GetDWARFCompileUnit(sc.comp_unit)->GetNonSkeletonUnit();
+ DWARFDIE function_die = cu.LookupAddress(file_vm_addr);
+ DWARFDIE block_die;
+ if (function_die) {
+ sc.function = sc.comp_unit->FindFunctionByUID(function_die.GetID()).get();
+ if (sc.function == nullptr)
+ sc.function = ParseFunction(*sc.comp_unit, function_die);
+
+ if (sc.function && lookup_block)
+ block_die = function_die.LookupDeepestBlock(file_vm_addr);
+ }
+
+ if (!sc.function || ! lookup_block)
+ return;
+
+ Block &block = sc.function->GetBlock(true);
+ if (block_die)
+ sc.block = block.FindBlockByID(block_die.GetID());
+ else
+ sc.block = block.FindBlockByID(function_die.GetID());
+}
+
uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr,
SymbolContextItem resolve_scope,
SymbolContext &sc) {
@@ -1791,123 +1849,99 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr,
eSymbolContextLineEntry | eSymbolContextVariable)) {
lldb::addr_t file_vm_addr = so_addr.GetFileAddress();
- DWARFDebugInfo *debug_info = DebugInfo();
- if (debug_info) {
- llvm::Expected<DWARFDebugAranges &> aranges =
- debug_info->GetCompileUnitAranges();
- if (!aranges) {
- Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
- LLDB_LOG_ERROR(log, aranges.takeError(),
- "SymbolFileDWARF::ResolveSymbolContext failed to get cu "
- "aranges. {0}");
- return 0;
- }
+ DWARFDebugInfo &debug_info = DebugInfo();
+ llvm::Expected<DWARFDebugAranges &> aranges =
+ debug_info.GetCompileUnitAranges();
+ if (!aranges) {
+ Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
+ LLDB_LOG_ERROR(log, aranges.takeError(),
+ "SymbolFileDWARF::ResolveSymbolContext failed to get cu "
+ "aranges. {0}");
+ return 0;
+ }
- const dw_offset_t cu_offset = aranges->FindAddress(file_vm_addr);
- if (cu_offset == DW_INVALID_OFFSET) {
- // Global variables are not in the compile unit address ranges. The
- // only way to currently find global variables is to iterate over the
- // .debug_pubnames or the __apple_names table and find all items in
- // there that point to DW_TAG_variable DIEs and then find the address
- // that matches.
- if (resolve_scope & eSymbolContextVariable) {
- GlobalVariableMap &map = GetGlobalAranges();
- const GlobalVariableMap::Entry *entry =
- map.FindEntryThatContains(file_vm_addr);
- if (entry && entry->data) {
- Variable *variable = entry->data;
- SymbolContextScope *scc = variable->GetSymbolContextScope();
- if (scc) {
- scc->CalculateSymbolContext(&sc);
- sc.variable = variable;
- }
- return sc.GetResolvedMask();
+ const dw_offset_t cu_offset = aranges->FindAddress(file_vm_addr);
+ if (cu_offset == DW_INVALID_OFFSET) {
+ // Global variables are not in the compile unit address ranges. The only
+ // way to currently find global variables is to iterate over the
+ // .debug_pubnames or the __apple_names table and find all items in there
+ // that point to DW_TAG_variable DIEs and then find the address that
+ // matches.
+ if (resolve_scope & eSymbolContextVariable) {
+ GlobalVariableMap &map = GetGlobalAranges();
+ const GlobalVariableMap::Entry *entry =
+ map.FindEntryThatContains(file_vm_addr);
+ if (entry && entry->data) {
+ Variable *variable = entry->data;
+ SymbolContextScope *scc = variable->GetSymbolContextScope();
+ if (scc) {
+ scc->CalculateSymbolContext(&sc);
+ sc.variable = variable;
}
+ return sc.GetResolvedMask();
}
- } else {
- uint32_t cu_idx = DW_INVALID_INDEX;
- if (auto *dwarf_cu = llvm::dyn_cast_or_null<DWARFCompileUnit>(
- debug_info->GetUnitAtOffset(DIERef::Section::DebugInfo,
- cu_offset, &cu_idx))) {
- sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
- if (sc.comp_unit) {
- resolved |= eSymbolContextCompUnit;
-
- bool force_check_line_table = false;
- if (resolve_scope &
- (eSymbolContextFunction | eSymbolContextBlock)) {
- DWARFDIE function_die = dwarf_cu->LookupAddress(file_vm_addr);
- DWARFDIE block_die;
- if (function_die) {
- sc.function =
- sc.comp_unit->FindFunctionByUID(function_die.GetID()).get();
- if (sc.function == nullptr)
- sc.function = ParseFunction(*sc.comp_unit, function_die);
-
- if (sc.function && (resolve_scope & eSymbolContextBlock))
- block_die = function_die.LookupDeepestBlock(file_vm_addr);
- } else {
- // We might have had a compile unit that had discontiguous
- // address ranges where the gaps are symbols that don't have
- // any debug info. Discontiguous compile unit address ranges
- // should only happen when there aren't other functions from
- // other compile units in these gaps. This helps keep the size
- // of the aranges down.
- force_check_line_table = true;
- }
-
- if (sc.function != nullptr) {
- resolved |= eSymbolContextFunction;
-
- if (resolve_scope & eSymbolContextBlock) {
- Block &block = sc.function->GetBlock(true);
-
- if (block_die)
- sc.block = block.FindBlockByID(block_die.GetID());
- else
- sc.block = block.FindBlockByID(function_die.GetID());
- if (sc.block)
- resolved |= eSymbolContextBlock;
- }
- }
+ }
+ } else {
+ uint32_t cu_idx = DW_INVALID_INDEX;
+ if (auto *dwarf_cu = llvm::dyn_cast_or_null<DWARFCompileUnit>(
+ debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo, cu_offset,
+ &cu_idx))) {
+ sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
+ if (sc.comp_unit) {
+ resolved |= eSymbolContextCompUnit;
+
+ bool force_check_line_table = false;
+ if (resolve_scope & (eSymbolContextFunction | eSymbolContextBlock)) {
+ ResolveFunctionAndBlock(file_vm_addr,
+ resolve_scope & eSymbolContextBlock, sc);
+ if (sc.function)
+ resolved |= eSymbolContextFunction;
+ else {
+ // We might have had a compile unit that had discontiguous address
+ // ranges where the gaps are symbols that don't have any debug
+ // info. Discontiguous compile unit address ranges should only
+ // happen when there aren't other functions from other compile
+ // units in these gaps. This helps keep the size of the aranges
+ // down.
+ force_check_line_table = true;
}
+ if (sc.block)
+ resolved |= eSymbolContextBlock;
+ }
- if ((resolve_scope & eSymbolContextLineEntry) ||
- force_check_line_table) {
- LineTable *line_table = sc.comp_unit->GetLineTable();
- if (line_table != nullptr) {
- // And address that makes it into this function should be in
- // terms of this debug file if there is no debug map, or it
- // will be an address in the .o file which needs to be fixed up
- // to be in terms of the debug map executable. Either way,
- // calling FixupAddress() will work for us.
- Address exe_so_addr(so_addr);
- if (FixupAddress(exe_so_addr)) {
- if (line_table->FindLineEntryByAddress(exe_so_addr,
- sc.line_entry)) {
- resolved |= eSymbolContextLineEntry;
- }
+ if ((resolve_scope & eSymbolContextLineEntry) ||
+ force_check_line_table) {
+ LineTable *line_table = sc.comp_unit->GetLineTable();
+ if (line_table != nullptr) {
+ // And address that makes it into this function should be in terms
+ // of this debug file if there is no debug map, or it will be an
+ // address in the .o file which needs to be fixed up to be in
+ // terms of the debug map executable. Either way, calling
+ // FixupAddress() will work for us.
+ Address exe_so_addr(so_addr);
+ if (FixupAddress(exe_so_addr)) {
+ if (line_table->FindLineEntryByAddress(exe_so_addr,
+ sc.line_entry)) {
+ resolved |= eSymbolContextLineEntry;
}
}
}
+ }
- if (force_check_line_table &&
- !(resolved & eSymbolContextLineEntry)) {
- // We might have had a compile unit that had discontiguous
- // address ranges where the gaps are symbols that don't have any
- // debug info. Discontiguous compile unit address ranges should
- // only happen when there aren't other functions from other
- // compile units in these gaps. This helps keep the size of the
- // aranges down.
- sc.comp_unit = nullptr;
- resolved &= ~eSymbolContextCompUnit;
- }
- } else {
- GetObjectFile()->GetModule()->ReportWarning(
- "0x%8.8x: compile unit %u failed to create a valid "
- "lldb_private::CompileUnit class.",
- cu_offset, cu_idx);
+ if (force_check_line_table && !(resolved & eSymbolContextLineEntry)) {
+ // We might have had a compile unit that had discontiguous address
+ // ranges where the gaps are symbols that don't have any debug info.
+ // Discontiguous compile unit address ranges should only happen when
+ // there aren't other functions from other compile units in these
+ // gaps. This helps keep the size of the aranges down.
+ sc.comp_unit = nullptr;
+ resolved &= ~eSymbolContextCompUnit;
}
+ } else {
+ GetObjectFile()->GetModule()->ReportWarning(
+ "0x%8.8x: compile unit %u failed to create a valid "
+ "lldb_private::CompileUnit class.",
+ cu_offset, cu_idx);
}
}
}
@@ -1969,30 +2003,8 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const FileSpec &file_spec,
const lldb::addr_t file_vm_addr =
sc.line_entry.range.GetBaseAddress().GetFileAddress();
if (file_vm_addr != LLDB_INVALID_ADDRESS) {
- DWARFDIE function_die =
- GetDWARFCompileUnit(dc_cu)->LookupAddress(file_vm_addr);
- DWARFDIE block_die;
- if (function_die) {
- sc.function =
- sc.comp_unit->FindFunctionByUID(function_die.GetID())
- .get();
- if (sc.function == nullptr)
- sc.function =
- ParseFunction(*sc.comp_unit, function_die);
-
- if (sc.function && (resolve_scope & eSymbolContextBlock))
- block_die =
- function_die.LookupDeepestBlock(file_vm_addr);
- }
-
- if (sc.function != nullptr) {
- Block &block = sc.function->GetBlock(true);
-
- if (block_die)
- sc.block = block.FindBlockByID(block_die.GetID());
- else if (function_die)
- sc.block = block.FindBlockByID(function_die.GetID());
- }
+ ResolveFunctionAndBlock(
+ file_vm_addr, resolve_scope & eSymbolContextBlock, sc);
}
}
@@ -2035,15 +2047,15 @@ std::recursive_mutex &SymbolFileDWARF::GetModuleMutex() const {
}
bool SymbolFileDWARF::DeclContextMatchesThisSymbolFile(
- const lldb_private::CompilerDeclContext *decl_ctx) {
- if (decl_ctx == nullptr || !decl_ctx->IsValid()) {
+ const lldb_private::CompilerDeclContext &decl_ctx) {
+ if (!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;
}
- TypeSystem *decl_ctx_type_system = decl_ctx->GetTypeSystem();
+ TypeSystem *decl_ctx_type_system = decl_ctx.GetTypeSystem();
auto type_system_or_err = GetTypeSystemForLanguage(
decl_ctx_type_system->GetMinimumLanguage(nullptr));
if (auto err = type_system_or_err.takeError()) {
@@ -2067,7 +2079,7 @@ bool SymbolFileDWARF::DeclContextMatchesThisSymbolFile(
}
void SymbolFileDWARF::FindGlobalVariables(
- ConstString name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches, VariableList &variables) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
@@ -2077,16 +2089,12 @@ void SymbolFileDWARF::FindGlobalVariables(
log,
"SymbolFileDWARF::FindGlobalVariables (name=\"%s\", "
"parent_decl_ctx=%p, max_matches=%u, variables)",
- name.GetCString(), static_cast<const void *>(parent_decl_ctx),
+ name.GetCString(), static_cast<const void *>(&parent_decl_ctx),
max_matches);
if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
return;
- DWARFDebugInfo *info = DebugInfo();
- if (!info)
- return;
-
// Remember how many variables are in the list before we search.
const uint32_t original_size = variables.GetSize();
@@ -2098,69 +2106,46 @@ void SymbolFileDWARF::FindGlobalVariables(
context, basename))
basename = name.GetStringRef();
- DIEArray die_offsets;
- m_index->GetGlobalVariables(ConstString(basename), die_offsets);
- const size_t num_die_matches = die_offsets.size();
- if (num_die_matches) {
- SymbolContext sc;
- sc.module_sp = m_objfile_sp->GetModule();
- assert(sc.module_sp);
-
- // Loop invariant: Variables up to this index have been checked for context
- // matches.
- uint32_t pruned_idx = original_size;
+ // Loop invariant: Variables up to this index have been checked for context
+ // matches.
+ uint32_t pruned_idx = original_size;
- bool done = false;
- for (size_t i = 0; i < num_die_matches && !done; ++i) {
- const DIERef &die_ref = die_offsets[i];
- DWARFDIE die = GetDIE(die_ref);
-
- if (die) {
- switch (die.Tag()) {
- default:
- case DW_TAG_subprogram:
- case DW_TAG_inlined_subroutine:
- case DW_TAG_try_block:
- case DW_TAG_catch_block:
- break;
+ SymbolContext sc;
+ m_index->GetGlobalVariables(ConstString(basename), [&](DWARFDIE die) {
+ if (!sc.module_sp)
+ sc.module_sp = m_objfile_sp->GetModule();
+ assert(sc.module_sp);
- case DW_TAG_variable: {
- auto *dwarf_cu = llvm::dyn_cast<DWARFCompileUnit>(die.GetCU());
- if (!dwarf_cu)
- continue;
- sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
-
- if (parent_decl_ctx) {
- DWARFASTParser *dwarf_ast = die.GetDWARFParser();
- 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;
- }
- }
+ if (die.Tag() != DW_TAG_variable)
+ return true;
- ParseVariables(sc, die, LLDB_INVALID_ADDRESS, false, false,
- &variables);
- while (pruned_idx < variables.GetSize()) {
- VariableSP var_sp = variables.GetVariableAtIndex(pruned_idx);
- if (name_is_mangled ||
- var_sp->GetName().GetStringRef().contains(name.GetStringRef()))
- ++pruned_idx;
- else
- variables.RemoveVariableAtIndex(pruned_idx);
- }
+ auto *dwarf_cu = llvm::dyn_cast<DWARFCompileUnit>(die.GetCU());
+ if (!dwarf_cu)
+ return true;
+ sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
- if (variables.GetSize() - original_size >= max_matches)
- done = true;
- } break;
- }
- } else {
- m_index->ReportInvalidDIERef(die_ref, name.GetStringRef());
+ if (parent_decl_ctx) {
+ if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU())) {
+ CompilerDeclContext actual_parent_decl_ctx =
+ dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
+ if (!actual_parent_decl_ctx ||
+ actual_parent_decl_ctx != parent_decl_ctx)
+ return true;
}
}
- }
+
+ ParseVariables(sc, die, LLDB_INVALID_ADDRESS, false, false, &variables);
+ while (pruned_idx < variables.GetSize()) {
+ VariableSP var_sp = variables.GetVariableAtIndex(pruned_idx);
+ if (name_is_mangled ||
+ var_sp->GetName().GetStringRef().contains(name.GetStringRef()))
+ ++pruned_idx;
+ else
+ variables.RemoveVariableAtIndex(pruned_idx);
+ }
+
+ return variables.GetSize() - original_size < max_matches;
+ });
// Return the number of variable that were appended to the list
const uint32_t num_matches = variables.GetSize() - original_size;
@@ -2169,7 +2154,7 @@ void SymbolFileDWARF::FindGlobalVariables(
log,
"SymbolFileDWARF::FindGlobalVariables (name=\"%s\", "
"parent_decl_ctx=%p, max_matches=%u, variables) => %u",
- name.GetCString(), static_cast<const void *>(parent_decl_ctx),
+ name.GetCString(), static_cast<const void *>(&parent_decl_ctx),
max_matches, num_matches);
}
}
@@ -2188,41 +2173,24 @@ void SymbolFileDWARF::FindGlobalVariables(const RegularExpression &regex,
regex.GetText().str().c_str(), max_matches);
}
- DWARFDebugInfo *info = DebugInfo();
- if (!info)
- return;
-
// Remember how many variables are in the list before we search.
const uint32_t original_size = variables.GetSize();
- DIEArray die_offsets;
- m_index->GetGlobalVariables(regex, die_offsets);
-
SymbolContext sc;
- sc.module_sp = m_objfile_sp->GetModule();
- assert(sc.module_sp);
-
- const size_t num_matches = die_offsets.size();
- if (num_matches) {
- for (size_t i = 0; i < num_matches; ++i) {
- const DIERef &die_ref = die_offsets[i];
- DWARFDIE die = GetDIE(die_ref);
+ m_index->GetGlobalVariables(regex, [&](DWARFDIE die) {
+ if (!sc.module_sp)
+ sc.module_sp = m_objfile_sp->GetModule();
+ assert(sc.module_sp);
- if (die) {
- DWARFCompileUnit *dwarf_cu =
- llvm::dyn_cast<DWARFCompileUnit>(die.GetCU());
- if (!dwarf_cu)
- continue;
- sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
+ DWARFCompileUnit *dwarf_cu = llvm::dyn_cast<DWARFCompileUnit>(die.GetCU());
+ if (!dwarf_cu)
+ return true;
+ sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
- ParseVariables(sc, die, LLDB_INVALID_ADDRESS, false, false, &variables);
+ ParseVariables(sc, die, LLDB_INVALID_ADDRESS, false, false, &variables);
- if (variables.GetSize() - original_size >= max_matches)
- break;
- } else
- m_index->ReportInvalidDIERef(die_ref, regex.GetText());
- }
- }
+ return variables.GetSize() - original_size < max_matches;
+ });
}
bool SymbolFileDWARF::ResolveFunction(const DWARFDIE &orig_die,
@@ -2281,28 +2249,26 @@ bool SymbolFileDWARF::ResolveFunction(const DWARFDIE &orig_die,
return false;
}
-bool SymbolFileDWARF::DIEInDeclContext(const CompilerDeclContext *decl_ctx,
+bool SymbolFileDWARF::DIEInDeclContext(const CompilerDeclContext &decl_ctx,
const DWARFDIE &die) {
// 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())
+ if (!decl_ctx.IsValid())
return true;
if (die) {
- DWARFASTParser *dwarf_ast = die.GetDWARFParser();
- if (dwarf_ast) {
- CompilerDeclContext actual_decl_ctx =
- dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
- if (actual_decl_ctx)
- return decl_ctx->IsContainedInLookup(actual_decl_ctx);
+ if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU())) {
+ if (CompilerDeclContext actual_decl_ctx =
+ dwarf_ast->GetDeclContextContainingUIDFromDWARF(die))
+ return decl_ctx.IsContainedInLookup(actual_decl_ctx);
}
}
return false;
}
void SymbolFileDWARF::FindFunctions(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
+ const CompilerDeclContext &parent_decl_ctx,
FunctionNameType name_type_mask,
bool include_inlines,
SymbolContextList &sc_list) {
@@ -2337,17 +2303,13 @@ void SymbolFileDWARF::FindFunctions(ConstString name,
const uint32_t original_size = sc_list.GetSize();
llvm::DenseSet<const DWARFDebugInfoEntry *> resolved_dies;
- DIEArray offsets;
- CompilerDeclContext empty_decl_ctx;
- if (!parent_decl_ctx)
- parent_decl_ctx = &empty_decl_ctx;
-
- std::vector<DWARFDIE> dies;
- m_index->GetFunctions(name, *this, *parent_decl_ctx, name_type_mask, dies);
- for (const DWARFDIE &die : dies) {
- if (resolved_dies.insert(die.GetDIE()).second)
- ResolveFunction(die, include_inlines, sc_list);
- }
+
+ m_index->GetFunctions(name, *this, parent_decl_ctx, name_type_mask,
+ [&](DWARFDIE die) {
+ if (resolved_dies.insert(die.GetDIE()).second)
+ ResolveFunction(die, include_inlines, sc_list);
+ return true;
+ });
// Return the number of variable that were appended to the list
const uint32_t num_matches = sc_list.GetSize() - original_size;
@@ -2378,35 +2340,21 @@ void SymbolFileDWARF::FindFunctions(const RegularExpression &regex,
regex.GetText().str().c_str());
}
- DWARFDebugInfo *info = DebugInfo();
- if (!info)
- return;
-
- DIEArray offsets;
- m_index->GetFunctions(regex, offsets);
-
llvm::DenseSet<const DWARFDebugInfoEntry *> resolved_dies;
- for (DIERef ref : offsets) {
- DWARFDIE die = info->GetDIE(ref);
- if (!die) {
- m_index->ReportInvalidDIERef(ref, regex.GetText());
- continue;
- }
+ m_index->GetFunctions(regex, [&](DWARFDIE die) {
if (resolved_dies.insert(die.GetDIE()).second)
ResolveFunction(die, include_inlines, sc_list);
- }
+ return true;
+ });
}
void SymbolFileDWARF::GetMangledNamesForFunction(
const std::string &scope_qualified_name,
std::vector<ConstString> &mangled_names) {
- DWARFDebugInfo *info = DebugInfo();
- uint32_t num_comp_units = 0;
- if (info)
- num_comp_units = info->GetNumUnits();
-
+ DWARFDebugInfo &info = DebugInfo();
+ uint32_t num_comp_units = info.GetNumUnits();
for (uint32_t i = 0; i < num_comp_units; i++) {
- DWARFUnit *cu = info->GetUnitAtIndex(i);
+ DWARFUnit *cu = info.GetUnitAtIndex(i);
if (cu == nullptr)
continue;
@@ -2415,15 +2363,15 @@ void SymbolFileDWARF::GetMangledNamesForFunction(
dwo->GetMangledNamesForFunction(scope_qualified_name, mangled_names);
}
- for (lldb::user_id_t uid :
+ for (DIERef die_ref :
m_function_scope_qualified_name_map.lookup(scope_qualified_name)) {
- DWARFDIE die = GetDIE(uid);
+ DWARFDIE die = GetDIE(die_ref);
mangled_names.push_back(ConstString(die.GetMangledName()));
}
}
void SymbolFileDWARF::FindTypes(
- ConstString name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {
@@ -2432,10 +2380,6 @@ void SymbolFileDWARF::FindTypes(
if (!searched_symbol_files.insert(this).second)
return;
- DWARFDebugInfo *info = DebugInfo();
- if (!info)
- return;
-
Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
if (log) {
@@ -2444,8 +2388,8 @@ void SymbolFileDWARF::FindTypes(
log,
"SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx = "
"%p (\"%s\"), max_matches=%u, type_list)",
- name.GetCString(), static_cast<const void *>(parent_decl_ctx),
- parent_decl_ctx->GetName().AsCString("<NULL>"), max_matches);
+ name.GetCString(), static_cast<const void *>(&parent_decl_ctx),
+ parent_decl_ctx.GetName().AsCString("<NULL>"), max_matches);
else
GetObjectFile()->GetModule()->LogMessage(
log,
@@ -2457,38 +2401,28 @@ void SymbolFileDWARF::FindTypes(
if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
return;
- DIEArray die_offsets;
- m_index->GetTypes(name, die_offsets);
- const size_t num_die_matches = die_offsets.size();
+ m_index->GetTypes(name, [&](DWARFDIE die) {
+ if (!DIEInDeclContext(parent_decl_ctx, die))
+ return true; // The containing decl contexts don't match
- for (size_t i = 0; i < num_die_matches; ++i) {
- const DIERef &die_ref = die_offsets[i];
- DWARFDIE die = GetDIE(die_ref);
- if (die) {
- if (!DIEInDeclContext(parent_decl_ctx, die))
- continue; // The containing decl contexts don't match
-
- 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());
- if (types.GetSize() >= max_matches)
- break;
- }
- } else {
- m_index->ReportInvalidDIERef(die_ref, name.GetStringRef());
- }
- }
+ Type *matching_type = ResolveType(die, true, true);
+ if (!matching_type)
+ return true;
+
+ // We found a type pointer, now find the shared pointer form our type
+ // list
+ types.InsertUnique(matching_type->shared_from_this());
+ return types.GetSize() < max_matches;
+ });
// Next search through the reachable Clang modules. This only applies for
// DWARF objects compiled with -gmodules that haven't been processed by
// dsymutil.
- if (num_die_matches < max_matches) {
+ if (types.GetSize() < max_matches) {
UpdateExternalModuleListIfNeeded();
for (const auto &pair : m_external_type_modules)
- if (ModuleSP external_module_sp = pair.second)
+ if (ModuleSP external_module_sp = pair.second)
if (SymbolFile *sym_file = external_module_sp->GetSymbolFile())
sym_file->FindTypes(name, parent_decl_ctx, max_matches,
searched_symbol_files, types);
@@ -2500,8 +2434,8 @@ void SymbolFileDWARF::FindTypes(
log,
"SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx "
"= %p (\"%s\"), max_matches=%u, type_list) => %u",
- name.GetCString(), static_cast<const void *>(parent_decl_ctx),
- parent_decl_ctx->GetName().AsCString("<NULL>"), max_matches,
+ name.GetCString(), static_cast<const void *>(&parent_decl_ctx),
+ parent_decl_ctx.GetName().AsCString("<NULL>"), max_matches,
types.GetSize());
} else {
GetObjectFile()->GetModule()->LogMessage(
@@ -2529,32 +2463,22 @@ void SymbolFileDWARF::FindTypes(
if (!name)
return;
- DIEArray die_offsets;
- m_index->GetTypes(name, die_offsets);
- const size_t num_die_matches = die_offsets.size();
-
- for (size_t i = 0; i < num_die_matches; ++i) {
- const DIERef &die_ref = die_offsets[i];
- DWARFDIE die = GetDIE(die_ref);
-
- if (!die) {
- m_index->ReportInvalidDIERef(die_ref, name.GetStringRef());
- continue;
- }
- if (!languages[die.GetCU()->GetLanguageType()])
- continue;
+ m_index->GetTypes(name, [&](DWARFDIE die) {
+ if (!languages[GetLanguage(*die.GetCU())])
+ return true;
llvm::SmallVector<CompilerContext, 4> die_context;
die.GetDeclContext(die_context);
if (!contextMatches(die_context, pattern))
- continue;
+ return true;
if (Type *matching_type = ResolveType(die, true, true)) {
// We found a type pointer, now find the shared pointer form our type
// list.
types.InsertUnique(matching_type->shared_from_this());
}
- }
+ return true;
+ });
// Next search through the reachable Clang modules. This only applies for
// DWARF objects compiled with -gmodules that haven't been processed by
@@ -2569,7 +2493,7 @@ void SymbolFileDWARF::FindTypes(
CompilerDeclContext
SymbolFileDWARF::FindNamespace(ConstString name,
- const CompilerDeclContext *parent_decl_ctx) {
+ const CompilerDeclContext &parent_decl_ctx) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
@@ -2584,32 +2508,18 @@ SymbolFileDWARF::FindNamespace(ConstString name,
if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
return namespace_decl_ctx;
- DWARFDebugInfo *info = DebugInfo();
- if (info) {
- DIEArray die_offsets;
- m_index->GetNamespaces(name, die_offsets);
- const size_t num_matches = die_offsets.size();
- if (num_matches) {
- for (size_t i = 0; i < num_matches; ++i) {
- const DIERef &die_ref = die_offsets[i];
- DWARFDIE die = GetDIE(die_ref);
-
- if (die) {
- if (!DIEInDeclContext(parent_decl_ctx, die))
- continue; // The containing decl contexts don't match
-
- DWARFASTParser *dwarf_ast = die.GetDWARFParser();
- if (dwarf_ast) {
- namespace_decl_ctx = dwarf_ast->GetDeclContextForUIDFromDWARF(die);
- if (namespace_decl_ctx)
- break;
- }
- } else {
- m_index->ReportInvalidDIERef(die_ref, name.GetStringRef());
- }
- }
- }
- }
+ m_index->GetNamespaces(name, [&](DWARFDIE die) {
+ if (!DIEInDeclContext(parent_decl_ctx, die))
+ return true; // The containing decl contexts don't match
+
+ DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU());
+ if (!dwarf_ast)
+ return true;
+
+ namespace_decl_ctx = dwarf_ast->GetDeclContextForUIDFromDWARF(die);
+ return !namespace_decl_ctx.IsValid();
+ });
+
if (log && namespace_decl_ctx) {
GetObjectFile()->GetModule()->LogMessage(
log,
@@ -2735,10 +2645,10 @@ bool SymbolFileDWARF::Supports_DW_AT_APPLE_objc_complete_type(DWARFUnit *cu) {
if (cu && cu->Supports_DW_AT_APPLE_objc_complete_type())
m_supports_DW_AT_APPLE_objc_complete_type = eLazyBoolYes;
else {
- DWARFDebugInfo *debug_info = DebugInfo();
+ DWARFDebugInfo &debug_info = DebugInfo();
const uint32_t num_compile_units = GetNumCompileUnits();
for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
- DWARFUnit *dwarf_cu = debug_info->GetUnitAtIndex(cu_idx);
+ DWARFUnit *dwarf_cu = debug_info.GetUnitAtIndex(cu_idx);
if (dwarf_cu != cu &&
dwarf_cu->Supports_DW_AT_APPLE_objc_complete_type()) {
m_supports_DW_AT_APPLE_objc_complete_type = eLazyBoolYes;
@@ -2763,17 +2673,8 @@ TypeSP SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(
if (!type_name || (must_be_implementation && !GetObjCClassSymbol(type_name)))
return type_sp;
- DIEArray die_offsets;
- m_index->GetCompleteObjCClass(type_name, must_be_implementation, die_offsets);
-
- const size_t num_matches = die_offsets.size();
-
- if (num_matches) {
- for (size_t i = 0; i < num_matches; ++i) {
- const DIERef &die_ref = die_offsets[i];
- DWARFDIE type_die = GetDIE(die_ref);
-
- if (type_die) {
+ m_index->GetCompleteObjCClass(
+ type_name, must_be_implementation, [&](DWARFDIE type_die) {
bool try_resolving_type = false;
// Don't try and resolve the DIE we are looking for with the DIE
@@ -2788,35 +2689,32 @@ TypeSP SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(
break;
}
}
+ if (!try_resolving_type)
+ return true;
- if (try_resolving_type) {
- 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_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",
- die.GetID(),
- m_objfile_sp->GetFileSpec().GetFilename().AsCString(
- "<Unknown>"),
- type_die.GetID(), type_cu->GetID());
-
- if (die)
- GetDIEToType()[die.GetDIE()] = resolved_type;
- type_sp = resolved_type->shared_from_this();
- break;
- }
- }
- }
- } else {
- m_index->ReportInvalidDIERef(die_ref, type_name.GetStringRef());
- }
- }
- }
+ 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)
+ return true;
+
+ Type *resolved_type = ResolveType(type_die, false, true);
+ if (!resolved_type || resolved_type == DIE_IS_BEING_PARSED)
+ return true;
+
+ DEBUG_PRINTF(
+ "resolved 0x%8.8" PRIx64 " from %s to 0x%8.8" PRIx64
+ " (cu 0x%8.8" PRIx64 ")\n",
+ die.GetID(),
+ m_objfile_sp->GetFileSpec().GetFilename().AsCString("<Unknown>"),
+ type_die.GetID(), type_cu->GetID());
+
+ if (die)
+ GetDIEToType()[die.GetDIE()] = resolved_type;
+ type_sp = resolved_type->shared_from_this();
+ return false;
+ });
return type_sp;
}
@@ -2930,10 +2828,6 @@ TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
dwarf_decl_ctx.GetQualifiedName());
}
- DIEArray die_offsets;
- m_index->GetTypes(dwarf_decl_ctx, die_offsets);
- const size_t num_matches = die_offsets.size();
-
// Get the type system that we are looking to find a type for. We will
// use this to ensure any matches we find are in a language that this
// type system supports
@@ -2950,91 +2844,85 @@ TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
type_system = &type_system_or_err.get();
}
}
- if (num_matches) {
- for (size_t i = 0; i < num_matches; ++i) {
- const DIERef &die_ref = die_offsets[i];
- DWARFDIE type_die = GetDIE(die_ref);
-
- if (type_die) {
- // Make sure type_die's langauge matches the type system we are
- // looking for. We don't want to find a "Foo" type from Java if we
- // are looking for a "Foo" type for C, C++, ObjC, or ObjC++.
- if (type_system &&
- !type_system->SupportsLanguage(type_die.GetLanguage()))
- continue;
- 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();
- // Make sure the tags match
- if (type_tag == tag) {
- // The tags match, lets try resolving this type
- try_resolving_type = true;
- } else {
- // The tags don't match, but we need to watch our for a forward
- // declaration for a struct and ("struct foo") ends up being a
- // class ("class foo { ... };") or vice versa.
- switch (type_tag) {
- case DW_TAG_class_type:
- // We had a "class foo", see if we ended up with a "struct foo
- // { ... };"
- try_resolving_type = (tag == DW_TAG_structure_type);
- break;
- case DW_TAG_structure_type:
- // We had a "struct foo", see if we ended up with a "class foo
- // { ... };"
- try_resolving_type = (tag == DW_TAG_class_type);
- break;
- default:
- // Tags don't match, don't event try to resolve using this type
- // whose name matches....
- break;
- }
- }
- if (try_resolving_type) {
- DWARFDeclContext type_dwarf_decl_ctx;
- type_die.GetDWARFDeclContext(type_dwarf_decl_ctx);
-
- if (log) {
- GetObjectFile()->GetModule()->LogMessage(
- log,
- "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_dwarf_decl_ctx.GetQualifiedName());
- }
+ m_index->GetTypes(dwarf_decl_ctx, [&](DWARFDIE type_die) {
+ // Make sure type_die's langauge matches the type system we are
+ // looking for. We don't want to find a "Foo" type from Java if we
+ // are looking for a "Foo" type for C, C++, ObjC, or ObjC++.
+ if (type_system &&
+ !type_system->SupportsLanguage(GetLanguage(*type_die.GetCU())))
+ return true;
+ bool try_resolving_type = false;
- // Make sure the decl contexts match all the way up
- if (dwarf_decl_ctx == type_dwarf_decl_ctx) {
- Type *resolved_type = ResolveType(type_die, false);
- if (resolved_type && resolved_type != DIE_IS_BEING_PARSED) {
- type_sp = resolved_type->shared_from_this();
- break;
- }
- }
- } else {
- if (log) {
- std::string 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(),
- qualified_name.c_str());
- }
- }
- } else {
- m_index->ReportInvalidDIERef(die_ref, type_name.GetStringRef());
+ // Don't try and resolve the DIE we are looking for with the DIE
+ // itself!
+ const dw_tag_t type_tag = type_die.Tag();
+ // Make sure the tags match
+ if (type_tag == tag) {
+ // The tags match, lets try resolving this type
+ try_resolving_type = true;
+ } else {
+ // The tags don't match, but we need to watch our for a forward
+ // declaration for a struct and ("struct foo") ends up being a
+ // class ("class foo { ... };") or vice versa.
+ switch (type_tag) {
+ case DW_TAG_class_type:
+ // We had a "class foo", see if we ended up with a "struct foo
+ // { ... };"
+ try_resolving_type = (tag == DW_TAG_structure_type);
+ break;
+ case DW_TAG_structure_type:
+ // We had a "struct foo", see if we ended up with a "class foo
+ // { ... };"
+ try_resolving_type = (tag == DW_TAG_class_type);
+ break;
+ default:
+ // Tags don't match, don't event try to resolve using this type
+ // whose name matches....
+ break;
}
}
- }
+
+ if (!try_resolving_type) {
+ if (log) {
+ std::string 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(),
+ qualified_name.c_str());
+ }
+ return true;
+ }
+
+ DWARFDeclContext type_dwarf_decl_ctx = GetDWARFDeclContext(type_die);
+
+ if (log) {
+ GetObjectFile()->GetModule()->LogMessage(
+ log,
+ "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_dwarf_decl_ctx.GetQualifiedName());
+ }
+
+ // Make sure the decl contexts match all the way up
+ if (dwarf_decl_ctx != type_dwarf_decl_ctx)
+ return true;
+
+ Type *resolved_type = ResolveType(type_die, false);
+ if (!resolved_type || resolved_type == DIE_IS_BEING_PARSED)
+ return true;
+
+ type_sp = resolved_type->shared_from_this();
+ return false;
+ });
}
}
return type_sp;
@@ -3045,8 +2933,7 @@ TypeSP SymbolFileDWARF::ParseType(const SymbolContext &sc, const DWARFDIE &die,
if (!die)
return {};
- auto type_system_or_err =
- GetTypeSystemForLanguage(die.GetCU()->GetLanguageType());
+ auto type_system_or_err = GetTypeSystemForLanguage(GetLanguage(*die.GetCU()));
if (auto err = type_system_or_err.takeError()) {
LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_SYMBOLS),
std::move(err), "Unable to parse type");
@@ -3067,7 +2954,7 @@ TypeSP SymbolFileDWARF::ParseType(const SymbolContext &sc, const DWARFDIE &die,
.AsCString(""));
if (scope_qualified_name.size()) {
m_function_scope_qualified_name_map[scope_qualified_name].insert(
- die.GetID());
+ *die.GetDIERef());
}
}
}
@@ -3124,7 +3011,8 @@ size_t SymbolFileDWARF::ParseBlocksRecursive(Function &func) {
size_t functions_added = 0;
const dw_offset_t function_die_offset = func.GetID();
- DWARFDIE function_die = dwarf_cu->GetDIE(function_die_offset);
+ DWARFDIE function_die =
+ dwarf_cu->GetNonSkeletonUnit().GetDIE(function_die_offset);
if (function_die) {
ParseBlocksRecursive(*comp_unit, &func.GetBlock(false), function_die,
LLDB_INVALID_ADDRESS, 0);
@@ -3152,10 +3040,6 @@ size_t SymbolFileDWARF::ParseTypes(CompileUnit &comp_unit) {
size_t SymbolFileDWARF::ParseVariablesForContext(const SymbolContext &sc) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
if (sc.comp_unit != nullptr) {
- DWARFDebugInfo *info = DebugInfo();
- if (info == nullptr)
- return 0;
-
if (sc.function) {
DWARFDIE function_die = GetDIE(sc.function->GetID());
@@ -3170,7 +3054,7 @@ size_t SymbolFileDWARF::ParseVariablesForContext(const SymbolContext &sc) {
return num_variables;
}
} else if (sc.comp_unit) {
- DWARFUnit *dwarf_cu = info->GetUnitAtIndex(sc.comp_unit->GetID());
+ DWARFUnit *dwarf_cu = DebugInfo().GetUnitAtIndex(sc.comp_unit->GetID());
if (dwarf_cu == nullptr)
return 0;
@@ -3182,25 +3066,16 @@ size_t SymbolFileDWARF::ParseVariablesForContext(const SymbolContext &sc) {
variables = std::make_shared<VariableList>();
sc.comp_unit->SetVariableList(variables);
- DIEArray die_offsets;
- m_index->GetGlobalVariables(dwarf_cu->GetNonSkeletonUnit(),
- die_offsets);
- const size_t num_matches = die_offsets.size();
- if (num_matches) {
- for (size_t i = 0; i < num_matches; ++i) {
- const DIERef &die_ref = die_offsets[i];
- DWARFDIE die = GetDIE(die_ref);
- if (die) {
+ m_index->GetGlobalVariables(
+ dwarf_cu->GetNonSkeletonUnit(), [&](DWARFDIE die) {
VariableSP var_sp(
ParseVariableDIE(sc, die, LLDB_INVALID_ADDRESS));
if (var_sp) {
variables->AddVariableIfUnique(var_sp);
++vars_added;
}
- } else
- m_index->ReportInvalidDIERef(die_ref, "");
- }
- }
+ return true;
+ });
}
return vars_added;
}
@@ -3412,12 +3287,10 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
// declaration context.
if ((parent_tag == DW_TAG_compile_unit ||
parent_tag == DW_TAG_partial_unit) &&
- Language::LanguageIsCPlusPlus(die.GetLanguage())) {
- DWARFDeclContext decl_ctx;
-
- die.GetDWARFDeclContext(decl_ctx);
- mangled = decl_ctx.GetQualifiedNameAsConstString().GetCString();
- }
+ Language::LanguageIsCPlusPlus(GetLanguage(*die.GetCU())))
+ mangled = GetDWARFDeclContext(die)
+ .GetQualifiedNameAsConstString()
+ .GetCString();
}
if (tag == DW_TAG_formal_parameter)
@@ -3524,7 +3397,8 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
}
}
} else {
- if (location_is_const_value_data)
+ if (location_is_const_value_data &&
+ die.GetDIE()->IsGlobalOrStaticScopeVariable())
scope = eValueTypeVariableStatic;
else {
scope = eValueTypeVariableLocal;
@@ -3603,7 +3477,7 @@ SymbolFileDWARF::FindBlockContainingSpecification(
// 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"
- return FindBlockContainingSpecification(DebugInfo()->GetDIE(func_die_ref),
+ return FindBlockContainingSpecification(DebugInfo().GetDIE(func_die_ref),
spec_block_die_offset);
}
@@ -3762,7 +3636,8 @@ CollectCallSiteParameters(ModuleSP module, DWARFDIE call_site_die) {
CallSiteParameterArray parameters;
for (DWARFDIE child = call_site_die.GetFirstChild(); child.IsValid();
child = child.GetSibling()) {
- if (child.Tag() != DW_TAG_call_site_parameter)
+ if (child.Tag() != DW_TAG_call_site_parameter &&
+ child.Tag() != DW_TAG_GNU_call_site_parameter)
continue;
llvm::Optional<DWARFExpression> LocationInCallee;
@@ -3792,7 +3667,7 @@ CollectCallSiteParameters(ModuleSP module, DWARFDIE call_site_die) {
dw_attr_t attr = attributes.AttributeAtIndex(i);
if (attr == DW_AT_location)
LocationInCallee = parse_simple_location(i);
- if (attr == DW_AT_call_value)
+ if (attr == DW_AT_call_value || attr == DW_AT_GNU_call_site_value)
LocationInCaller = parse_simple_location(i);
}
@@ -3805,12 +3680,13 @@ CollectCallSiteParameters(ModuleSP module, DWARFDIE call_site_die) {
}
/// Collect call graph edges present in a function DIE.
-static std::vector<std::unique_ptr<lldb_private::CallEdge>>
-CollectCallEdges(ModuleSP module, DWARFDIE function_die) {
+std::vector<std::unique_ptr<lldb_private::CallEdge>>
+SymbolFileDWARF::CollectCallEdges(ModuleSP module, DWARFDIE function_die) {
// Check if the function has a supported call site-related attribute.
// TODO: In the future it may be worthwhile to support call_all_source_calls.
- uint64_t has_call_edges =
- function_die.GetAttributeValueAsUnsigned(DW_AT_call_all_calls, 0);
+ bool has_call_edges =
+ function_die.GetAttributeValueAsUnsigned(DW_AT_call_all_calls, 0) ||
+ function_die.GetAttributeValueAsUnsigned(DW_AT_GNU_all_call_sites, 0);
if (!has_call_edges)
return {};
@@ -3826,15 +3702,22 @@ CollectCallEdges(ModuleSP module, DWARFDIE function_die) {
std::vector<std::unique_ptr<CallEdge>> call_edges;
for (DWARFDIE child = function_die.GetFirstChild(); child.IsValid();
child = child.GetSibling()) {
- if (child.Tag() != DW_TAG_call_site)
+ if (child.Tag() != DW_TAG_call_site && child.Tag() != DW_TAG_GNU_call_site)
continue;
llvm::Optional<DWARFDIE> call_origin;
llvm::Optional<DWARFExpression> call_target;
addr_t return_pc = LLDB_INVALID_ADDRESS;
+ addr_t call_inst_pc = LLDB_INVALID_ADDRESS;
+ addr_t low_pc = LLDB_INVALID_ADDRESS;
+ bool tail_call = false;
+ // Second DW_AT_low_pc may come from DW_TAG_subprogram referenced by
+ // DW_TAG_GNU_call_site's DW_AT_abstract_origin overwriting our 'low_pc'.
+ // So do not inherit attributes from DW_AT_abstract_origin.
DWARFAttributes attributes;
- const size_t num_attributes = child.GetAttributes(attributes);
+ const size_t num_attributes =
+ child.GetAttributes(attributes, DWARFDIE::Recurse::no);
for (size_t i = 0; i < num_attributes; ++i) {
DWARFFormValue form_value;
if (!attributes.ExtractFormValueAtIndex(i, form_value)) {
@@ -3844,8 +3727,11 @@ CollectCallEdges(ModuleSP module, DWARFDIE function_die) {
dw_attr_t attr = attributes.AttributeAtIndex(i);
+ if (attr == DW_AT_call_tail_call || attr == DW_AT_GNU_tail_call)
+ tail_call = form_value.Boolean();
+
// Extract DW_AT_call_origin (the call target's DIE).
- if (attr == DW_AT_call_origin) {
+ if (attr == DW_AT_call_origin || attr == DW_AT_abstract_origin) {
call_origin = form_value.Reference();
if (!call_origin->IsValid()) {
LLDB_LOG(log, "CollectCallEdges: Invalid call origin in {0}",
@@ -3854,15 +3740,24 @@ CollectCallEdges(ModuleSP module, DWARFDIE function_die) {
}
}
+ if (attr == DW_AT_low_pc)
+ low_pc = form_value.Address();
+
// Extract DW_AT_call_return_pc (the PC the call returns to) if it's
// available. It should only ever be unavailable for tail call edges, in
// which case use LLDB_INVALID_ADDRESS.
if (attr == DW_AT_call_return_pc)
return_pc = form_value.Address();
+ // Extract DW_AT_call_pc (the PC at the call/branch instruction). It
+ // should only ever be unavailable for non-tail calls, in which case use
+ // LLDB_INVALID_ADDRESS.
+ if (attr == DW_AT_call_pc)
+ call_inst_pc = form_value.Address();
+
// Extract DW_AT_call_target (the location of the address of the indirect
// call).
- if (attr == DW_AT_call_target) {
+ if (attr == DW_AT_call_target || attr == DW_AT_GNU_call_site_target) {
if (!DWARFFormValue::IsBlockForm(form_value.Form())) {
LLDB_LOG(log,
"CollectCallEdges: AT_call_target does not have block form");
@@ -3882,16 +3777,39 @@ CollectCallEdges(ModuleSP module, DWARFDIE function_die) {
continue;
}
+ addr_t caller_address;
+ CallEdge::AddrType caller_address_type;
+ if (return_pc != LLDB_INVALID_ADDRESS) {
+ caller_address = return_pc;
+ caller_address_type = CallEdge::AddrType::AfterCall;
+ } else if (low_pc != LLDB_INVALID_ADDRESS) {
+ caller_address = low_pc;
+ caller_address_type = CallEdge::AddrType::AfterCall;
+ } else if (call_inst_pc != LLDB_INVALID_ADDRESS) {
+ caller_address = call_inst_pc;
+ caller_address_type = CallEdge::AddrType::Call;
+ } else {
+ LLDB_LOG(log, "CollectCallEdges: No caller address");
+ continue;
+ }
+ // Adjust any PC forms. It needs to be fixed up if the main executable
+ // contains a debug map (i.e. pointers to object files), because we need a
+ // file address relative to the executable's text section.
+ caller_address = FixupAddress(caller_address);
+
// Extract call site parameters.
CallSiteParameterArray parameters =
CollectCallSiteParameters(module, child);
std::unique_ptr<CallEdge> edge;
if (call_origin) {
- LLDB_LOG(log, "CollectCallEdges: Found call origin: {0} (retn-PC: {1:x})",
- call_origin->GetPubname(), return_pc);
- edge = std::make_unique<DirectCallEdge>(call_origin->GetMangledName(),
- return_pc, std::move(parameters));
+ LLDB_LOG(log,
+ "CollectCallEdges: Found call origin: {0} (retn-PC: {1:x}) "
+ "(call-PC: {2:x})",
+ call_origin->GetPubname(), return_pc, call_inst_pc);
+ edge = std::make_unique<DirectCallEdge>(
+ call_origin->GetMangledName(), caller_address_type, caller_address,
+ tail_call, std::move(parameters));
} else {
if (log) {
StreamString call_target_desc;
@@ -3900,8 +3818,9 @@ CollectCallEdges(ModuleSP module, DWARFDIE function_die) {
LLDB_LOG(log, "CollectCallEdges: Found indirect call target: {0}",
call_target_desc.GetString());
}
- edge = std::make_unique<IndirectCallEdge>(*call_target, return_pc,
- std::move(parameters));
+ edge = std::make_unique<IndirectCallEdge>(
+ *call_target, caller_address_type, caller_address, tail_call,
+ std::move(parameters));
}
if (log && parameters.size()) {
@@ -3925,6 +3844,11 @@ CollectCallEdges(ModuleSP module, DWARFDIE function_die) {
std::vector<std::unique_ptr<lldb_private::CallEdge>>
SymbolFileDWARF::ParseCallEdgesInFunction(UserID func_id) {
+ // ParseCallEdgesInFunction must be called at the behest of an exclusively
+ // locked lldb::Function instance. Storage for parsed call edges is owned by
+ // the lldb::Function instance: locking at the SymbolFile level would be too
+ // late, because the act of storing results from ParseCallEdgesInFunction
+ // would be racy.
DWARFDIE func_die = GetDIE(func_id.GetID());
if (func_die.IsValid())
return CollectCallEdges(GetObjectFile()->GetModule(), func_die);
@@ -3945,8 +3869,8 @@ void SymbolFileDWARF::DumpClangAST(Stream &s) {
auto ts_or_err = GetTypeSystemForLanguage(eLanguageTypeC_plus_plus);
if (!ts_or_err)
return;
- ClangASTContext *clang =
- llvm::dyn_cast_or_null<ClangASTContext>(&ts_or_err.get());
+ TypeSystemClang *clang =
+ llvm::dyn_cast_or_null<TypeSystemClang>(&ts_or_err.get());
if (!clang)
return;
clang->Dump(s);
@@ -3957,26 +3881,93 @@ SymbolFileDWARFDebugMap *SymbolFileDWARF::GetDebugMapSymfile() {
lldb::ModuleSP module_sp(m_debug_map_module_wp.lock());
if (module_sp) {
m_debug_map_symfile =
- (SymbolFileDWARFDebugMap *)module_sp->GetSymbolFile();
+ static_cast<SymbolFileDWARFDebugMap *>(module_sp->GetSymbolFile());
}
}
return m_debug_map_symfile;
}
-SymbolFileDWARFDwp *SymbolFileDWARF::GetDwpSymbolFile() {
+const std::shared_ptr<SymbolFileDWARFDwo> &SymbolFileDWARF::GetDwpSymbolFile() {
llvm::call_once(m_dwp_symfile_once_flag, [this]() {
ModuleSpec module_spec;
module_spec.GetFileSpec() = m_objfile_sp->GetFileSpec();
module_spec.GetSymbolFileSpec() =
- FileSpec(m_objfile_sp->GetFileSpec().GetPath() + ".dwp");
+ FileSpec(m_objfile_sp->GetModule()->GetFileSpec().GetPath() + ".dwp");
FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
FileSpec dwp_filespec =
Symbols::LocateExecutableSymbolFile(module_spec, search_paths);
if (FileSystem::Instance().Exists(dwp_filespec)) {
- m_dwp_symfile = SymbolFileDWARFDwp::Create(GetObjectFile()->GetModule(),
- dwp_filespec);
+ DataBufferSP dwp_file_data_sp;
+ lldb::offset_t dwp_file_data_offset = 0;
+ ObjectFileSP dwp_obj_file = ObjectFile::FindPlugin(
+ GetObjectFile()->GetModule(), &dwp_filespec, 0,
+ FileSystem::Instance().GetByteSize(dwp_filespec), dwp_file_data_sp,
+ dwp_file_data_offset);
+ if (!dwp_obj_file)
+ return;
+ m_dwp_symfile =
+ std::make_shared<SymbolFileDWARFDwo>(*this, dwp_obj_file, 0x3fffffff);
}
});
- return m_dwp_symfile.get();
+ return m_dwp_symfile;
+}
+
+llvm::Expected<TypeSystem &> SymbolFileDWARF::GetTypeSystem(DWARFUnit &unit) {
+ return unit.GetSymbolFileDWARF().GetTypeSystemForLanguage(GetLanguage(unit));
+}
+
+DWARFASTParser *SymbolFileDWARF::GetDWARFParser(DWARFUnit &unit) {
+ auto type_system_or_err = GetTypeSystem(unit);
+ if (auto err = type_system_or_err.takeError()) {
+ LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_SYMBOLS),
+ std::move(err), "Unable to get DWARFASTParser");
+ return nullptr;
+ }
+ return type_system_or_err->GetDWARFParser();
+}
+
+CompilerDecl SymbolFileDWARF::GetDecl(const DWARFDIE &die) {
+ if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU()))
+ return dwarf_ast->GetDeclForUIDFromDWARF(die);
+ return CompilerDecl();
+}
+
+CompilerDeclContext SymbolFileDWARF::GetDeclContext(const DWARFDIE &die) {
+ if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU()))
+ return dwarf_ast->GetDeclContextForUIDFromDWARF(die);
+ return CompilerDeclContext();
+}
+
+CompilerDeclContext
+SymbolFileDWARF::GetContainingDeclContext(const DWARFDIE &die) {
+ if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU()))
+ return dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
+ return CompilerDeclContext();
+}
+
+DWARFDeclContext SymbolFileDWARF::GetDWARFDeclContext(const DWARFDIE &die) {
+ if (!die.IsValid())
+ return {};
+ DWARFDeclContext dwarf_decl_ctx =
+ die.GetDIE()->GetDWARFDeclContext(die.GetCU());
+ dwarf_decl_ctx.SetLanguage(GetLanguage(*die.GetCU()));
+ return dwarf_decl_ctx;
+}
+
+LanguageType SymbolFileDWARF::LanguageTypeFromDWARF(uint64_t val) {
+ // Note: user languages between lo_user and hi_user must be handled
+ // explicitly here.
+ switch (val) {
+ case DW_LANG_Mips_Assembler:
+ return eLanguageTypeMipsAssembler;
+ case DW_LANG_GOOGLE_RenderScript:
+ return eLanguageTypeExtRenderScript;
+ default:
+ return static_cast<LanguageType>(val);
+ }
+}
+
+LanguageType SymbolFileDWARF::GetLanguage(DWARFUnit &unit) {
+ return LanguageTypeFromDWARF(unit.GetDWARFLanguageType());
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 23e26732453f..76ceb279c718 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -6,17 +6,17 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_SymbolFileDWARF_h_
-#define SymbolFileDWARF_SymbolFileDWARF_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARF_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARF_H
#include <list>
#include <map>
#include <mutex>
-#include <set>
#include <unordered_map>
#include <vector>
#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SetVector.h"
#include "llvm/Support/Threading.h"
#include "lldb/Core/UniqueCStringMap.h"
@@ -90,8 +90,6 @@ public:
static lldb_private::SymbolFile *
CreateInstance(lldb::ObjectFileSP objfile_sp);
- static lldb_private::FileSpecList GetSymlinkPaths();
-
// Constructors and Destructors
SymbolFileDWARF(lldb::ObjectFileSP objfile_sp,
@@ -108,6 +106,9 @@ public:
lldb::LanguageType
ParseLanguage(lldb_private::CompileUnit &comp_unit) override;
+ lldb_private::XcodeSDK
+ ParseXcodeSDK(lldb_private::CompileUnit &comp_unit) override;
+
size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override;
bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override;
@@ -168,7 +169,7 @@ public:
void
FindGlobalVariables(lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ const lldb_private::CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
lldb_private::VariableList &variables) override;
@@ -177,7 +178,7 @@ public:
lldb_private::VariableList &variables) override;
void FindFunctions(lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ const lldb_private::CompilerDeclContext &parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines,
lldb_private::SymbolContextList &sc_list) override;
@@ -192,7 +193,7 @@ public:
void
FindTypes(lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ const lldb_private::CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
lldb_private::TypeMap &types) override;
@@ -211,7 +212,7 @@ public:
lldb_private::CompilerDeclContext FindNamespace(
lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx) override;
+ const lldb_private::CompilerDeclContext &parent_decl_ctx) override;
void PreloadSymbols() override;
@@ -224,11 +225,7 @@ public:
DWARFDebugAbbrev *DebugAbbrev();
- const DWARFDebugAbbrev *DebugAbbrev() const;
-
- DWARFDebugInfo *DebugInfo();
-
- const DWARFDebugInfo *DebugInfo() const;
+ DWARFDebugInfo &DebugInfo();
DWARFDebugRanges *GetDebugRanges();
@@ -243,8 +240,8 @@ public:
lldb_private::CompileUnit *
GetCompUnitForDWARFCompUnit(DWARFCompileUnit &dwarf_cu);
- virtual size_t GetObjCMethodDIEOffsets(lldb_private::ConstString class_name,
- DIEArray &method_die_offsets);
+ virtual void GetObjCMethods(lldb_private::ConstString class_name,
+ llvm::function_ref<bool(DWARFDIE die)> callback);
bool Supports_DW_AT_APPLE_objc_complete_type(DWARFUnit *cu);
@@ -252,8 +249,6 @@ public:
static DWARFDIE GetParentSymbolContextDIE(const DWARFDIE &die);
- virtual lldb::CompUnitSP ParseCompileUnit(DWARFCompileUnit &dwarf_cu);
-
lldb::ModuleSP GetExternalModule(lldb_private::ConstString name);
typedef std::map<lldb_private::ConstString, lldb::ModuleSP>
@@ -278,22 +273,17 @@ public:
lldb::user_id_t GetUID(DIERef ref);
- std::unique_ptr<SymbolFileDWARFDwo>
+ std::shared_ptr<SymbolFileDWARFDwo>
GetDwoSymbolFileForCompileUnit(DWARFUnit &dwarf_cu,
const DWARFDebugInfoEntry &cu_die);
- // For regular SymbolFileDWARF instances the method returns nullptr,
- // for the instances of the subclass SymbolFileDWARFDwo
- // the method returns a pointer to the base compile unit.
- virtual DWARFCompileUnit *GetBaseCompileUnit() { return nullptr; }
-
virtual llvm::Optional<uint32_t> GetDwoNum() { return llvm::None; }
/// If this is a DWARF object with a single CU, return its DW_AT_dwo_id.
llvm::Optional<uint64_t> GetDWOId();
static bool
- DIEInDeclContext(const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ DIEInDeclContext(const lldb_private::CompilerDeclContext &parent_decl_ctx,
const DWARFDIE &die);
std::vector<std::unique_ptr<lldb_private::CallEdge>>
@@ -305,8 +295,30 @@ public:
lldb_private::DWARFContext &GetDWARFContext() { return m_context; }
+ const std::shared_ptr<SymbolFileDWARFDwo> &GetDwpSymbolFile();
+
lldb_private::FileSpec GetFile(DWARFUnit &unit, size_t file_idx);
+ static llvm::Expected<lldb_private::TypeSystem &>
+ GetTypeSystem(DWARFUnit &unit);
+
+ static DWARFASTParser *GetDWARFParser(DWARFUnit &unit);
+
+ // CompilerDecl related functions
+
+ static lldb_private::CompilerDecl GetDecl(const DWARFDIE &die);
+
+ static lldb_private::CompilerDeclContext GetDeclContext(const DWARFDIE &die);
+
+ static lldb_private::CompilerDeclContext
+ GetContainingDeclContext(const DWARFDIE &die);
+
+ static DWARFDeclContext GetDWARFDeclContext(const DWARFDIE &die);
+
+ static lldb::LanguageType LanguageTypeFromDWARF(uint64_t val);
+
+ static lldb::LanguageType GetLanguage(DWARFUnit &unit);
+
protected:
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *>
DIEToTypePtr;
@@ -315,25 +327,16 @@ protected:
typedef llvm::DenseMap<const DWARFDebugInfoEntry *,
lldb::opaque_compiler_type_t>
DIEToClangType;
- typedef llvm::DenseMap<lldb::opaque_compiler_type_t, lldb::user_id_t>
- ClangTypeToDIE;
+ typedef llvm::DenseMap<lldb::opaque_compiler_type_t, DIERef> ClangTypeToDIE;
- struct DWARFDataSegment {
- llvm::once_flag m_flag;
- lldb_private::DWARFDataExtractor m_data;
- };
-
- DISALLOW_COPY_AND_ASSIGN(SymbolFileDWARF);
-
- const lldb_private::DWARFDataExtractor &
- GetCachedSectionData(lldb::SectionType sect_type,
- DWARFDataSegment &data_segment);
+ SymbolFileDWARF(const SymbolFileDWARF &) = delete;
+ const SymbolFileDWARF &operator=(const SymbolFileDWARF &) = delete;
virtual void LoadSectionData(lldb::SectionType sect_type,
lldb_private::DWARFDataExtractor &data);
bool DeclContextMatchesThisSymbolFile(
- const lldb_private::CompilerDeclContext *decl_ctx);
+ const lldb_private::CompilerDeclContext &decl_ctx);
uint32_t CalculateNumCompileUnits() override;
@@ -341,6 +344,8 @@ protected:
lldb_private::TypeList &GetTypeList() override;
+ lldb::CompUnitSP ParseCompileUnit(DWARFCompileUnit &dwarf_cu);
+
virtual DWARFUnit *
GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit);
@@ -383,6 +388,13 @@ protected:
bool ResolveFunction(const DWARFDIE &die, bool include_inlines,
lldb_private::SymbolContextList &sc_list);
+ /// Resolve functions and (possibly) blocks for the given file address and a
+ /// compile unit. The compile unit comes from the sc argument and it must be
+ /// set. The results of the lookup (if any) are written back to the symbol
+ /// context.
+ void ResolveFunctionAndBlock(lldb::addr_t file_vm_addr, bool lookup_block,
+ lldb_private::SymbolContext &sc);
+
virtual lldb::TypeSP
FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext &die_decl_ctx);
@@ -417,9 +429,21 @@ protected:
bool ClassContainsSelector(const DWARFDIE &class_die,
lldb_private::ConstString selector);
+ /// Parse call site entries (DW_TAG_call_site), including any nested call site
+ /// parameters (DW_TAG_call_site_parameter).
+ std::vector<std::unique_ptr<lldb_private::CallEdge>>
+ CollectCallEdges(lldb::ModuleSP module, DWARFDIE function_die);
+
+ /// If this symbol file is linked to by a debug map (see
+ /// SymbolFileDWARFDebugMap), and \p file_addr is a file address relative to
+ /// an object file, adjust \p file_addr so that it is relative to the main
+ /// binary. Returns the adjusted address, or \p file_addr if no adjustment is
+ /// needed, on success and LLDB_INVALID_ADDRESS otherwise.
+ lldb::addr_t FixupAddress(lldb::addr_t file_addr);
+
bool FixupAddress(lldb_private::Address &addr);
- typedef std::set<lldb_private::Type *> TypeSet;
+ typedef llvm::SetVector<lldb_private::Type *> TypeSet;
void GetTypes(const DWARFDIE &die, dw_offset_t min_die_offset,
dw_offset_t max_die_offset, uint32_t type_mask,
@@ -454,7 +478,7 @@ protected:
};
llvm::Optional<DecodedUID> DecodeUID(lldb::user_id_t uid);
- SymbolFileDWARFDwp *GetDwpSymbolFile();
+ void FindDwpSymbolFile();
const lldb_private::FileSpecList &GetTypeUnitSupportFiles(DWARFTypeUnit &tu);
@@ -462,17 +486,14 @@ protected:
SymbolFileDWARFDebugMap *m_debug_map_symfile;
llvm::once_flag m_dwp_symfile_once_flag;
- std::unique_ptr<SymbolFileDWARFDwp> m_dwp_symfile;
+ std::shared_ptr<SymbolFileDWARFDwo> m_dwp_symfile;
lldb_private::DWARFContext m_context;
- DWARFDataSegment m_data_debug_loc;
- DWARFDataSegment m_data_debug_loclists;
+ llvm::once_flag m_info_once_flag;
+ std::unique_ptr<DWARFDebugInfo> m_info;
- // The unique pointer items below are generated on demand if and when someone
- // accesses them through a non const version of this class.
std::unique_ptr<DWARFDebugAbbrev> m_abbr;
- std::unique_ptr<DWARFDebugInfo> m_info;
std::unique_ptr<GlobalVariableMap> m_global_aranges_up;
typedef std::unordered_map<lldb::offset_t, lldb_private::DebugMacrosSP>
@@ -484,7 +505,7 @@ protected:
bool m_fetched_external_modules : 1;
lldb_private::LazyBool m_supports_DW_AT_APPLE_objc_complete_type;
- typedef std::set<lldb::user_id_t> DIERefSet;
+ typedef std::set<DIERef> DIERefSet;
typedef llvm::StringMap<DIERefSet> NameToOffsetMap;
NameToOffsetMap m_function_scope_qualified_name_map;
std::unique_ptr<DWARFDebugRanges> m_ranges;
@@ -498,4 +519,4 @@ protected:
std::vector<uint32_t> m_lldb_cu_to_dwarf_unit;
};
-#endif // SymbolFileDWARF_SymbolFileDWARF_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARF_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index cce666a222d0..6515d78b8f23 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -1,4 +1,4 @@
-//===-- SymbolFileDWARFDebugMap.cpp -----------------------------*- C++ -*-===//
+//===-- SymbolFileDWARFDebugMap.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -108,8 +108,7 @@ SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap(
// First we find the original symbol in the .o file's symbol table
Symbol *oso_fun_symbol = oso_symtab->FindFirstSymbolWithNameAndType(
- exe_symbol->GetMangled().GetName(lldb::eLanguageTypeUnknown,
- Mangled::ePreferMangled),
+ exe_symbol->GetMangled().GetName(Mangled::ePreferMangled),
eSymbolTypeCode, Symtab::eDebugNo, Symtab::eVisibilityAny);
if (oso_fun_symbol) {
// Add the inverse OSO file address to debug map entry mapping
@@ -139,8 +138,7 @@ SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap(
// in the .o file
Symbol *oso_gsym_symbol =
oso_symtab->FindFirstSymbolWithNameAndType(
- exe_symbol->GetMangled().GetName(lldb::eLanguageTypeUnknown,
- Mangled::ePreferMangled),
+ exe_symbol->GetMangled().GetName(Mangled::ePreferMangled),
eSymbolTypeData, Symtab::eDebugNo, Symtab::eVisibilityAny);
if (exe_symbol && oso_gsym_symbol && exe_symbol->ValueIsAddress() &&
oso_gsym_symbol->ValueIsAddress()) {
@@ -416,6 +414,7 @@ Module *SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo(
FileSpec oso_file(oso_path);
ConstString oso_object;
if (FileSystem::Instance().Exists(oso_file)) {
+ FileSystem::Instance().Collect(oso_file);
// The modification time returned by the FS can have a higher precision
// than the one from the CU.
auto oso_mod_time = std::chrono::time_point_cast<std::chrono::seconds>(
@@ -531,7 +530,7 @@ SymbolFileDWARF *
SymbolFileDWARFDebugMap::GetSymbolFileAsSymbolFileDWARF(SymbolFile *sym_file) {
if (sym_file &&
sym_file->GetPluginName() == SymbolFileDWARF::GetPluginNameStatic())
- return (SymbolFileDWARF *)sym_file;
+ return static_cast<SymbolFileDWARF *>(sym_file);
return nullptr;
}
@@ -630,6 +629,14 @@ SymbolFileDWARFDebugMap::ParseLanguage(CompileUnit &comp_unit) {
return eLanguageTypeUnknown;
}
+XcodeSDK SymbolFileDWARFDebugMap::ParseXcodeSDK(CompileUnit &comp_unit) {
+ std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
+ SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
+ if (oso_dwarf)
+ return oso_dwarf->ParseXcodeSDK(comp_unit);
+ return {};
+}
+
size_t SymbolFileDWARFDebugMap::ParseFunctions(CompileUnit &comp_unit) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
@@ -826,7 +833,7 @@ uint32_t SymbolFileDWARFDebugMap::ResolveSymbolContext(
}
void SymbolFileDWARFDebugMap::PrivateFindGlobalVariables(
- ConstString name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext &parent_decl_ctx,
const std::vector<uint32_t>
&indexes, // Indexes into the symbol table that match "name"
uint32_t max_matches, VariableList &variables) {
@@ -848,7 +855,7 @@ void SymbolFileDWARFDebugMap::PrivateFindGlobalVariables(
}
void SymbolFileDWARFDebugMap::FindGlobalVariables(
- ConstString name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches, VariableList &variables) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
uint32_t total_matches = 0;
@@ -1002,7 +1009,7 @@ static void RemoveFunctionsWithModuleNotEqualTo(const ModuleSP &module_sp,
}
void SymbolFileDWARFDebugMap::FindFunctions(
- ConstString name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext &parent_decl_ctx,
FunctionNameType name_type_mask, bool include_inlines,
SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
@@ -1172,7 +1179,7 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
}
void SymbolFileDWARFDebugMap::FindTypes(
- ConstString name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {
@@ -1209,7 +1216,7 @@ void SymbolFileDWARFDebugMap::FindTypes(
CompilerDeclContext SymbolFileDWARFDebugMap::FindNamespace(
lldb_private::ConstString name,
- const CompilerDeclContext *parent_decl_ctx) {
+ const CompilerDeclContext &parent_decl_ctx) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
CompilerDeclContext matching_namespace;
@@ -1225,6 +1232,9 @@ CompilerDeclContext SymbolFileDWARFDebugMap::FindNamespace(
void SymbolFileDWARFDebugMap::DumpClangAST(Stream &s) {
ForEachSymbolFile([&s](SymbolFileDWARF *oso_dwarf) -> bool {
oso_dwarf->DumpClangAST(s);
+ // The underlying assumption is that DumpClangAST(...) will obtain the
+ // AST from the underlying TypeSystem and therefore we only need to do
+ // this once and can stop after the first iteration hence we return true.
return true;
});
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
index 035a902498be..06f0d48c04ca 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARF_SymbolFileDWARFDebugMap_h_
-#define SymbolFileDWARF_SymbolFileDWARFDebugMap_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARFDEBUGMAP_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARFDEBUGMAP_H
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Utility/RangeMap.h"
@@ -57,11 +57,10 @@ public:
// Compile Unit function calls
lldb::LanguageType
ParseLanguage(lldb_private::CompileUnit &comp_unit) override;
-
+ lldb_private::XcodeSDK
+ ParseXcodeSDK(lldb_private::CompileUnit &comp_unit) override;
size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override;
-
bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override;
-
bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override;
bool ForEachExternalModule(
@@ -105,14 +104,14 @@ public:
lldb_private::SymbolContextList &sc_list) override;
void
FindGlobalVariables(lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ const lldb_private::CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
lldb_private::VariableList &variables) override;
void FindGlobalVariables(const lldb_private::RegularExpression &regex,
uint32_t max_matches,
lldb_private::VariableList &variables) override;
void FindFunctions(lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ const lldb_private::CompilerDeclContext &parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines,
lldb_private::SymbolContextList &sc_list) override;
@@ -121,7 +120,7 @@ public:
lldb_private::SymbolContextList &sc_list) override;
void
FindTypes(lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ const lldb_private::CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
lldb_private::TypeMap &types) override;
@@ -132,7 +131,7 @@ public:
lldb_private::TypeMap &types) override;
lldb_private::CompilerDeclContext FindNamespace(
lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx) override;
+ const lldb_private::CompilerDeclContext &parent_decl_ctx) override;
void GetTypes(lldb_private::SymbolContextScope *sc_scope,
lldb::TypeClass type_mask,
lldb_private::TypeList &type_list) override;
@@ -254,7 +253,7 @@ protected:
void PrivateFindGlobalVariables(
lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ const lldb_private::CompilerDeclContext &parent_decl_ctx,
const std::vector<uint32_t> &name_symbol_indexes, uint32_t max_matches,
lldb_private::VariableList &variables);
@@ -379,4 +378,4 @@ protected:
DWARFDebugAranges *debug_aranges);
};
-#endif // #ifndef SymbolFileDWARF_SymbolFileDWARFDebugMap_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARFDEBUGMAP_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
index f75f06f31e2d..3aaa7d330b84 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -1,4 +1,4 @@
-//===-- SymbolFileDWARFDwo.cpp ----------------------------------*- C++ -*-===//
+//===-- SymbolFileDWARFDwo.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -23,62 +23,52 @@ using namespace lldb_private;
char SymbolFileDWARFDwo::ID;
-SymbolFileDWARFDwo::SymbolFileDWARFDwo(ObjectFileSP objfile,
- DWARFCompileUnit &dwarf_cu)
+SymbolFileDWARFDwo::SymbolFileDWARFDwo(SymbolFileDWARF &base_symbol_file,
+ ObjectFileSP objfile, uint32_t id)
: SymbolFileDWARF(objfile, objfile->GetSectionList(
/*update_module_section_list*/ false)),
- m_base_dwarf_cu(dwarf_cu) {
- SetID(((lldb::user_id_t)dwarf_cu.GetID()) << 32);
-}
-
-void SymbolFileDWARFDwo::LoadSectionData(lldb::SectionType sect_type,
- DWARFDataExtractor &data) {
- const SectionList *section_list =
- m_objfile_sp->GetSectionList(false /* update_module_section_list */);
- if (section_list) {
- SectionSP section_sp(section_list->FindSectionByType(sect_type, true));
- if (section_sp) {
+ m_base_symbol_file(base_symbol_file) {
+ SetID(user_id_t(id) << 32);
- if (m_objfile_sp->ReadSectionData(section_sp.get(), data) != 0)
- return;
+ // Parsing of the dwarf unit index is not thread-safe, so we need to prime it
+ // to enable subsequent concurrent lookups.
+ m_context.GetAsLLVM().getCUIndex();
+}
- data.Clear();
+DWARFCompileUnit *SymbolFileDWARFDwo::GetDWOCompileUnitForHash(uint64_t hash) {
+ if (const llvm::DWARFUnitIndex &index = m_context.GetAsLLVM().getCUIndex()) {
+ if (const llvm::DWARFUnitIndex::Entry *entry = index.getFromHash(hash)) {
+ if (auto *unit_contrib = entry->getContribution())
+ return llvm::dyn_cast_or_null<DWARFCompileUnit>(
+ DebugInfo().GetUnitAtOffset(DIERef::Section::DebugInfo,
+ unit_contrib->Offset));
}
+ return nullptr;
}
- SymbolFileDWARF::LoadSectionData(sect_type, data);
-}
-
-lldb::CompUnitSP
-SymbolFileDWARFDwo::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) {
- assert(GetCompileUnit() == &dwarf_cu &&
- "SymbolFileDWARFDwo::ParseCompileUnit called with incompatible "
- "compile unit");
- return GetBaseSymbolFile().ParseCompileUnit(m_base_dwarf_cu);
-}
-
-DWARFCompileUnit *SymbolFileDWARFDwo::GetCompileUnit() {
- if (!m_cu)
- m_cu = ComputeCompileUnit();
- return m_cu;
+ DWARFCompileUnit *cu = FindSingleCompileUnit();
+ if (!cu)
+ return nullptr;
+ if (hash !=
+ cu->GetUnitDIEOnly().GetAttributeValueAsUnsigned(DW_AT_GNU_dwo_id, 0))
+ return nullptr;
+ return cu;
}
-DWARFCompileUnit *SymbolFileDWARFDwo::ComputeCompileUnit() {
- DWARFDebugInfo *debug_info = DebugInfo();
- if (!debug_info)
- return nullptr;
+DWARFCompileUnit *SymbolFileDWARFDwo::FindSingleCompileUnit() {
+ DWARFDebugInfo &debug_info = DebugInfo();
// Right now we only support dwo files with one compile unit. If we don't have
// type units, we can just check for the unit count.
- if (!debug_info->ContainsTypeUnits() && debug_info->GetNumUnits() == 1)
- return llvm::cast<DWARFCompileUnit>(debug_info->GetUnitAtIndex(0));
+ if (!debug_info.ContainsTypeUnits() && debug_info.GetNumUnits() == 1)
+ return llvm::cast<DWARFCompileUnit>(debug_info.GetUnitAtIndex(0));
// Otherwise, we have to run through all units, and find the compile unit that
// way.
DWARFCompileUnit *cu = nullptr;
- for (size_t i = 0; i < debug_info->GetNumUnits(); ++i) {
+ for (size_t i = 0; i < debug_info.GetNumUnits(); ++i) {
if (auto *candidate =
- llvm::dyn_cast<DWARFCompileUnit>(debug_info->GetUnitAtIndex(i))) {
+ llvm::dyn_cast<DWARFCompileUnit>(debug_info.GetUnitAtIndex(i))) {
if (cu)
return nullptr; // More that one CU found.
cu = candidate;
@@ -87,11 +77,6 @@ DWARFCompileUnit *SymbolFileDWARFDwo::ComputeCompileUnit() {
return cu;
}
-DWARFUnit *
-SymbolFileDWARFDwo::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) {
- return GetCompileUnit();
-}
-
SymbolFileDWARF::DIEToTypePtr &SymbolFileDWARFDwo::GetDIEToType() {
return GetBaseSymbolFile().GetDIEToType();
}
@@ -110,10 +95,10 @@ SymbolFileDWARFDwo::GetForwardDeclClangTypeToDie() {
return GetBaseSymbolFile().GetForwardDeclClangTypeToDie();
}
-size_t SymbolFileDWARFDwo::GetObjCMethodDIEOffsets(
- lldb_private::ConstString class_name, DIEArray &method_die_offsets) {
- return GetBaseSymbolFile().GetObjCMethodDIEOffsets(class_name,
- method_die_offsets);
+void SymbolFileDWARFDwo::GetObjCMethods(
+ lldb_private::ConstString class_name,
+ llvm::function_ref<bool(DWARFDIE die)> callback) {
+ GetBaseSymbolFile().GetObjCMethods(class_name, callback);
}
UniqueDWARFASTTypeMap &SymbolFileDWARFDwo::GetUniqueDWARFASTTypeMap() {
@@ -133,10 +118,6 @@ lldb::TypeSP SymbolFileDWARFDwo::FindCompleteObjCDefinitionTypeForDIE(
die, type_name, must_be_implementation);
}
-SymbolFileDWARF &SymbolFileDWARFDwo::GetBaseSymbolFile() {
- return m_base_dwarf_cu.GetSymbolFileDWARF();
-}
-
llvm::Expected<TypeSystem &>
SymbolFileDWARFDwo::GetTypeSystemForLanguage(LanguageType language) {
return GetBaseSymbolFile().GetTypeSystemForLanguage(language);
@@ -144,7 +125,7 @@ SymbolFileDWARFDwo::GetTypeSystemForLanguage(LanguageType language) {
DWARFDIE
SymbolFileDWARFDwo::GetDIE(const DIERef &die_ref) {
- if (*die_ref.dwo_num() == GetDwoNum())
- return DebugInfo()->GetDIE(die_ref);
+ if (die_ref.dwo_num() == GetDwoNum())
+ return DebugInfo().GetDIE(die_ref);
return GetBaseSymbolFile().GetDIE(die_ref);
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
index 0855dba044e4..93538aac3c54 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef SymbolFileDWARFDwo_SymbolFileDWARFDwo_h_
-#define SymbolFileDWARFDwo_SymbolFileDWARFDwo_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARFDWO_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARFDWO_H
#include "SymbolFileDWARF.h"
@@ -24,19 +24,15 @@ public:
static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
/// \}
- SymbolFileDWARFDwo(lldb::ObjectFileSP objfile, DWARFCompileUnit &dwarf_cu);
+ SymbolFileDWARFDwo(SymbolFileDWARF &m_base_symbol_file,
+ lldb::ObjectFileSP objfile, uint32_t id);
~SymbolFileDWARFDwo() override = default;
- lldb::CompUnitSP ParseCompileUnit(DWARFCompileUnit &dwarf_cu) override;
+ DWARFCompileUnit *GetDWOCompileUnitForHash(uint64_t hash);
- DWARFCompileUnit *GetCompileUnit();
-
- DWARFUnit *
- GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) override;
-
- size_t GetObjCMethodDIEOffsets(lldb_private::ConstString class_name,
- DIEArray &method_die_offsets) override;
+ void GetObjCMethods(lldb_private::ConstString class_name,
+ llvm::function_ref<bool(DWARFDIE die)> callback) override;
llvm::Expected<lldb_private::TypeSystem &>
GetTypeSystemForLanguage(lldb::LanguageType language) override;
@@ -44,14 +40,9 @@ public:
DWARFDIE
GetDIE(const DIERef &die_ref) override;
- DWARFCompileUnit *GetBaseCompileUnit() override { return &m_base_dwarf_cu; }
-
llvm::Optional<uint32_t> GetDwoNum() override { return GetID() >> 32; }
protected:
- void LoadSectionData(lldb::SectionType sect_type,
- lldb_private::DWARFDataExtractor &data) override;
-
DIEToTypePtr &GetDIEToType() override;
DIEToVariableSP &GetDIEToVariable() override;
@@ -69,12 +60,13 @@ protected:
const DWARFDIE &die, lldb_private::ConstString type_name,
bool must_be_implementation) override;
- SymbolFileDWARF &GetBaseSymbolFile();
+ SymbolFileDWARF &GetBaseSymbolFile() { return m_base_symbol_file; }
- DWARFCompileUnit *ComputeCompileUnit();
+ /// If this file contains exactly one compile unit, this function will return
+ /// it. Otherwise it returns nullptr.
+ DWARFCompileUnit *FindSingleCompileUnit();
- DWARFCompileUnit &m_base_dwarf_cu;
- DWARFCompileUnit *m_cu = nullptr;
+ SymbolFileDWARF &m_base_symbol_file;
};
-#endif // SymbolFileDWARFDwo_SymbolFileDWARFDwo_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARFDWO_H
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
deleted file mode 100644
index 4288dcb5c9bd..000000000000
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-//===-- SymbolFileDWARFDwoDwp.cpp -------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "SymbolFileDWARFDwoDwp.h"
-
-#include "lldb/Core/Section.h"
-#include "lldb/Expression/DWARFExpression.h"
-#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Utility/LLDBAssert.h"
-
-#include "DWARFUnit.h"
-#include "DWARFDebugInfo.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-char SymbolFileDWARFDwoDwp::ID;
-
-SymbolFileDWARFDwoDwp::SymbolFileDWARFDwoDwp(SymbolFileDWARFDwp *dwp_symfile,
- ObjectFileSP objfile,
- DWARFCompileUnit &dwarf_cu,
- uint64_t dwo_id)
- : SymbolFileDWARFDwo(objfile, dwarf_cu), m_dwp_symfile(dwp_symfile),
- m_dwo_id(dwo_id) {}
-
-void SymbolFileDWARFDwoDwp::LoadSectionData(lldb::SectionType sect_type,
- DWARFDataExtractor &data) {
- if (m_dwp_symfile->LoadSectionData(m_dwo_id, sect_type, data))
- return;
-
- SymbolFileDWARF::LoadSectionData(sect_type, data);
-}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h
deleted file mode 100644
index a55795ba5950..000000000000
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h
+++ /dev/null
@@ -1,39 +0,0 @@
-//===-- SymbolFileDWARFDwoDwp.h ---------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef SymbolFileDWARFDwoDwp_SymbolFileDWARFDwoDwp_h_
-#define SymbolFileDWARFDwoDwp_SymbolFileDWARFDwoDwp_h_
-
-#include "SymbolFileDWARFDwo.h"
-#include "SymbolFileDWARFDwp.h"
-
-class SymbolFileDWARFDwoDwp : public SymbolFileDWARFDwo {
- /// LLVM RTTI support.
- static char ID;
-
-public:
- /// LLVM RTTI support.
- /// \{
- bool isA(const void *ClassID) const override {
- return ClassID == &ID || SymbolFileDWARFDwo::isA(ClassID);
- }
- static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
- /// \}
- SymbolFileDWARFDwoDwp(SymbolFileDWARFDwp *dwp_symfile,
- lldb::ObjectFileSP objfile, DWARFCompileUnit &dwarf_cu,
- uint64_t dwo_id);
-
-protected:
- void LoadSectionData(lldb::SectionType sect_type,
- lldb_private::DWARFDataExtractor &data) override;
-
- SymbolFileDWARFDwp *m_dwp_symfile;
- uint64_t m_dwo_id;
-};
-
-#endif // SymbolFileDWARFDwoDwp_SymbolFileDWARFDwoDwp_h_
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
deleted file mode 100644
index 08e6e1c8c2f3..000000000000
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-//===-- SymbolFileDWARFDwp.cpp ----------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "SymbolFileDWARFDwp.h"
-
-#include "lldb/Core/Section.h"
-#include "lldb/Symbol/ObjectFile.h"
-
-#include "SymbolFileDWARFDwoDwp.h"
-
-static llvm::DWARFSectionKind
-lldbSectTypeToLlvmSectionKind(lldb::SectionType type) {
- switch (type) {
- case lldb::eSectionTypeDWARFDebugInfo:
- return llvm::DW_SECT_INFO;
- // case lldb::eSectionTypeDWARFDebugTypes:
- // return llvm::DW_SECT_TYPES;
- case lldb::eSectionTypeDWARFDebugAbbrev:
- return llvm::DW_SECT_ABBREV;
- case lldb::eSectionTypeDWARFDebugLine:
- return llvm::DW_SECT_LINE;
- case lldb::eSectionTypeDWARFDebugLoc:
- return llvm::DW_SECT_LOC;
- case lldb::eSectionTypeDWARFDebugStrOffsets:
- return llvm::DW_SECT_STR_OFFSETS;
- // case lldb::eSectionTypeDWARFDebugMacinfo:
- // return llvm::DW_SECT_MACINFO;
- case lldb::eSectionTypeDWARFDebugMacro:
- return llvm::DW_SECT_MACRO;
- default:
- // Note: 0 is an invalid dwarf section kind.
- return llvm::DWARFSectionKind(0);
- }
-}
-
-std::unique_ptr<SymbolFileDWARFDwp>
-SymbolFileDWARFDwp::Create(lldb::ModuleSP module_sp,
- const lldb_private::FileSpec &file_spec) {
- const lldb::offset_t file_offset = 0;
- lldb::DataBufferSP file_data_sp;
- lldb::offset_t file_data_offset = 0;
- lldb::ObjectFileSP obj_file = lldb_private::ObjectFile::FindPlugin(
- module_sp, &file_spec, file_offset,
- lldb_private::FileSystem::Instance().GetByteSize(file_spec), file_data_sp,
- file_data_offset);
- if (obj_file == nullptr)
- return nullptr;
-
- std::unique_ptr<SymbolFileDWARFDwp> dwp_symfile(
- new SymbolFileDWARFDwp(module_sp, obj_file));
-
- lldb_private::DWARFDataExtractor debug_cu_index;
- if (!dwp_symfile->LoadRawSectionData(lldb::eSectionTypeDWARFDebugCuIndex,
- debug_cu_index))
- return nullptr;
-
- llvm::DataExtractor llvm_debug_cu_index(
- llvm::StringRef(debug_cu_index.PeekCStr(0), debug_cu_index.GetByteSize()),
- debug_cu_index.GetByteOrder() == lldb::eByteOrderLittle,
- debug_cu_index.GetAddressByteSize());
- if (!dwp_symfile->m_debug_cu_index.parse(llvm_debug_cu_index))
- return nullptr;
- dwp_symfile->InitDebugCUIndexMap();
- return dwp_symfile;
-}
-
-void SymbolFileDWARFDwp::InitDebugCUIndexMap() {
- m_debug_cu_index_map.clear();
- for (const auto &entry : m_debug_cu_index.getRows())
- m_debug_cu_index_map.emplace(entry.getSignature(), &entry);
-}
-
-SymbolFileDWARFDwp::SymbolFileDWARFDwp(lldb::ModuleSP module_sp,
- lldb::ObjectFileSP obj_file)
- : m_obj_file(std::move(obj_file)), m_debug_cu_index(llvm::DW_SECT_INFO)
-{}
-
-std::unique_ptr<SymbolFileDWARFDwo>
-SymbolFileDWARFDwp::GetSymbolFileForDwoId(DWARFCompileUnit &dwarf_cu,
- uint64_t dwo_id) {
- return std::unique_ptr<SymbolFileDWARFDwo>(
- new SymbolFileDWARFDwoDwp(this, m_obj_file, dwarf_cu, dwo_id));
-}
-
-bool SymbolFileDWARFDwp::LoadSectionData(
- uint64_t dwo_id, lldb::SectionType sect_type,
- lldb_private::DWARFDataExtractor &data) {
- lldb_private::DWARFDataExtractor section_data;
- if (!LoadRawSectionData(sect_type, section_data))
- return false;
-
- auto it = m_debug_cu_index_map.find(dwo_id);
- if (it == m_debug_cu_index_map.end())
- return false;
-
- auto *offsets =
- it->second->getOffset(lldbSectTypeToLlvmSectionKind(sect_type));
- if (offsets) {
- data.SetData(section_data, offsets->Offset, offsets->Length);
- } else {
- data.SetData(section_data, 0, section_data.GetByteSize());
- }
- return true;
-}
-
-bool SymbolFileDWARFDwp::LoadRawSectionData(
- lldb::SectionType sect_type, lldb_private::DWARFDataExtractor &data) {
- std::lock_guard<std::mutex> lock(m_sections_mutex);
-
- auto it = m_sections.find(sect_type);
- if (it != m_sections.end()) {
- if (it->second.GetByteSize() == 0)
- return false;
-
- data = it->second;
- return true;
- }
-
- const lldb_private::SectionList *section_list =
- m_obj_file->GetSectionList(false /* update_module_section_list */);
- if (section_list) {
- lldb::SectionSP section_sp(
- section_list->FindSectionByType(sect_type, true));
- if (section_sp) {
- if (m_obj_file->ReadSectionData(section_sp.get(), data) != 0) {
- m_sections[sect_type] = data;
- return true;
- }
- }
- }
- m_sections[sect_type].Clear();
- return false;
-}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h
deleted file mode 100644
index ef06b9dca8bb..000000000000
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h
+++ /dev/null
@@ -1,50 +0,0 @@
-//===-- SymbolFileDWARFDwp.h ------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef SymbolFileDWARFDwp_SymbolFileDWARFDwp_h_
-#define SymbolFileDWARFDwp_SymbolFileDWARFDwp_h_
-
-#include <memory>
-
-#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
-
-#include "lldb/Core/Module.h"
-
-#include "DWARFDataExtractor.h"
-#include "SymbolFileDWARFDwo.h"
-
-class SymbolFileDWARFDwp {
-public:
- static std::unique_ptr<SymbolFileDWARFDwp>
- Create(lldb::ModuleSP module_sp, const lldb_private::FileSpec &file_spec);
-
- std::unique_ptr<SymbolFileDWARFDwo>
- GetSymbolFileForDwoId(DWARFCompileUnit &dwarf_cu, uint64_t dwo_id);
-
- bool LoadSectionData(uint64_t dwo_id, lldb::SectionType sect_type,
- lldb_private::DWARFDataExtractor &data);
-
-private:
- explicit SymbolFileDWARFDwp(lldb::ModuleSP module_sp,
- lldb::ObjectFileSP obj_file);
-
- bool LoadRawSectionData(lldb::SectionType sect_type,
- lldb_private::DWARFDataExtractor &data);
-
- void InitDebugCUIndexMap();
-
- lldb::ObjectFileSP m_obj_file;
-
- std::mutex m_sections_mutex;
- std::map<lldb::SectionType, lldb_private::DWARFDataExtractor> m_sections;
-
- llvm::DWARFUnitIndex m_debug_cu_index;
- std::map<uint64_t, const llvm::DWARFUnitIndex::Entry *> m_debug_cu_index_map;
-};
-
-#endif // SymbolFileDWARFDwp_SymbolFileDWARFDwp_h_
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td
index ef6ae3498588..2f1ce88808b7 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFProperties.td
@@ -1,10 +1,6 @@
include "../../../../include/lldb/Core/PropertiesBase.td"
let Definition = "symbolfiledwarf" in {
- def SymLinkPaths: Property<"comp-dir-symlink-paths", "FileSpecList">,
- Global,
- DefaultStringValue<"">,
- Desc<"If the DW_AT_comp_dir matches any of these paths the symbolic links will be resolved at DWARF parse time.">;
def IgnoreIndexes: Property<"ignore-file-indexes", "Boolean">,
Global,
DefaultFalse,
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp b/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
index 4862fea8d079..2181989cd37a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
@@ -1,4 +1,4 @@
-//===-- UniqueDWARFASTType.cpp ----------------------------------*- C++ -*-===//
+//===-- UniqueDWARFASTType.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h b/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h
index 1269dbac7126..a1b1a3009787 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_UniqueDWARFASTType_h_
-#define lldb_UniqueDWARFASTType_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_UNIQUEDWARFASTTYPE_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_UNIQUEDWARFASTTYPE_H
#include <vector>
@@ -100,4 +100,4 @@ protected:
collection m_collection;
};
-#endif // lldb_UniqueDWARFASTType_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_UNIQUEDWARFASTTYPE_H
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.cpp
index 3834165c71c0..ca9ddcec287f 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.cpp
@@ -1,4 +1,4 @@
-//===-- CodeViewRegisterMapping.cpp -----------------------------*- C++ -*-===//
+//===-- CodeViewRegisterMapping.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.h b/lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.h
index b1c31e0c1785..02c7495565b8 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.h
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Plugins_SymbolFile_PDB_CodeViewRegisterMapping_h_
-#define lldb_Plugins_SymbolFile_PDB_CodeViewRegisterMapping_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_CODEVIEWREGISTERMAPPING_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_CODEVIEWREGISTERMAPPING_H
#include "llvm/ADT/Triple.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp
index 830d78f81679..f25dc84fb342 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp
@@ -1,4 +1,4 @@
-//===-- CompileUnitIndex.cpp ------------------------------------*- C++ -*-===//
+//===-- CompileUnitIndex.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -154,7 +154,7 @@ CompilandIndexItem &CompileUnitIndex::GetOrCreateCompiland(uint16_t modi) {
// name until we find it, and we can cache that one since the memory is backed
// by a contiguous chunk inside the mapped PDB.
llvm::SmallString<64> main_file = GetMainSourceFile(*cci);
- std::string s = main_file.str();
+ std::string s = std::string(main_file.str());
llvm::sys::path::native(main_file);
uint32_t file_count = modules.getSourceFileCount(modi);
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h b/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h
index 44a1c8cdd9c2..088de970cbf3 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_PLUGINS_SYMBOLFILENATIVEPDB_COMPILEUNITINDEX_H
-#define LLDB_PLUGINS_SYMBOLFILENATIVEPDB_COMPILEUNITINDEX_H
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_COMPILEUNITINDEX_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_COMPILEUNITINDEX_H
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp
index 6aaff06cc134..d0672352a58f 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFLocationExpression.cpp -----------------------------*- C++ -*-===//
+//===-- DWARFLocationExpression.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.h b/lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.h
index c37d715babdc..99da09b70fe1 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.h
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.h
@@ -6,14 +6,15 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_DWARFLOCATIONEXPRESSION_H
-#define LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_DWARFLOCATIONEXPRESSION_H
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_DWARFLOCATIONEXPRESSION_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_DWARFLOCATIONEXPRESSION_H
#include "lldb/lldb-forward.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
namespace llvm {
class APSInt;
+class StringRef;
namespace codeview {
class TypeIndex;
}
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
index 4588c80aa1b1..0acc77d7c67f 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -14,11 +14,11 @@
#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
#include "llvm/Demangle/MicrosoftDemangle.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
#include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Module.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangASTMetadata.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Utility/LLDBAssert.h"
@@ -178,7 +178,7 @@ GetNestedTagDefinition(const NestedTypeRecord &Record,
// single component of a mangled name. So we can inject it into the parent's
// mangled name to see if it matches.
CVTagRecord child = CVTagRecord::create(cvt);
- std::string qname = parent.asTag().getUniqueName();
+ std::string qname = std::string(parent.asTag().getUniqueName());
if (qname.size() < 4 || child.asTag().getUniqueName().size() < 4)
return llvm::None;
@@ -202,7 +202,7 @@ static bool IsAnonymousNamespaceName(llvm::StringRef name) {
return name == "`anonymous namespace'" || name == "`anonymous-namespace'";
}
-PdbAstBuilder::PdbAstBuilder(ObjectFile &obj, PdbIndex &index, ClangASTContext &clang)
+PdbAstBuilder::PdbAstBuilder(ObjectFile &obj, PdbIndex &index, TypeSystemClang &clang)
: m_index(index), m_clang(clang) {
BuildParentMap();
}
@@ -221,7 +221,7 @@ PdbAstBuilder::CreateDeclInfoForType(const TagRecord &record, TypeIndex ti) {
StringView sv(record.UniqueName.begin(), record.UniqueName.size());
llvm::ms_demangle::TagTypeNode *ttn = demangler.parseTagUniqueName(sv);
if (demangler.Error)
- return {m_clang.GetTranslationUnitDecl(), record.UniqueName};
+ return {m_clang.GetTranslationUnitDecl(), std::string(record.UniqueName)};
llvm::ms_demangle::IdentifierNode *idn =
ttn->QualifiedName->getUnqualifiedIdentifier();
@@ -248,7 +248,7 @@ PdbAstBuilder::CreateDeclInfoForType(const TagRecord &record, TypeIndex ti) {
// a NamespaceDecl and a CXXRecordDecl, so instead we create a class at
// global scope with the fully qualified name.
if (AnyScopesHaveTemplateParams(scopes))
- return {context, record.Name};
+ return {context, std::string(record.Name)};
for (llvm::ms_demangle::Node *scope : scopes) {
auto *nii = static_cast<llvm::ms_demangle::NamedIdentifierNode *>(scope);
@@ -507,7 +507,7 @@ PdbAstBuilder::CreateDeclInfoForUndecoratedName(llvm::StringRef name) {
llvm::StringRef uname = specs.back().GetBaseName();
specs = specs.drop_back();
if (specs.empty())
- return {context, name};
+ return {context, std::string(name)};
llvm::StringRef scope_name = specs.back().GetFullName();
@@ -517,7 +517,7 @@ PdbAstBuilder::CreateDeclInfoForUndecoratedName(llvm::StringRef name) {
clang::QualType qt = GetOrCreateType(types.back());
clang::TagDecl *tag = qt->getAsTagDecl();
if (tag)
- return {clang::TagDecl::castToDeclContext(tag), uname};
+ return {clang::TagDecl::castToDeclContext(tag), std::string(uname)};
types.pop_back();
}
@@ -526,7 +526,7 @@ PdbAstBuilder::CreateDeclInfoForUndecoratedName(llvm::StringRef name) {
std::string ns_name = spec.GetBaseName().str();
context = GetOrCreateNamespaceDecl(ns_name.c_str(), *context);
}
- return {context, uname};
+ return {context, std::string(uname)};
}
clang::DeclContext *
@@ -656,7 +656,7 @@ bool PdbAstBuilder::CompleteTagDecl(clang::TagDecl &tag) {
lldbassert(IsTagRecord(type_id, m_index.tpi()));
clang::QualType tag_qt = m_clang.getASTContext().getTypeDeclType(&tag);
- ClangASTContext::SetHasExternalStorage(tag_qt.getAsOpaquePtr(), false);
+ TypeSystemClang::SetHasExternalStorage(tag_qt.getAsOpaquePtr(), false);
TypeIndex tag_ti = type_id.index;
CVType cvt = m_index.tpi().getType(tag_ti);
@@ -681,7 +681,7 @@ bool PdbAstBuilder::CompleteTagDecl(clang::TagDecl &tag) {
// Visit all members of this class, then perform any finalization necessary
// to complete the class.
CompilerType ct = ToCompilerType(tag_qt);
- UdtRecordCompleter completer(best_ti, ct, tag, *this, m_index.tpi());
+ UdtRecordCompleter completer(best_ti, ct, tag, *this, m_index);
auto error =
llvm::codeview::visitMemberRecordStream(field_list_cvt.data(), completer);
completer.complete();
@@ -776,12 +776,13 @@ clang::QualType PdbAstBuilder::CreateRecordType(PdbTypeSymId id,
metadata.SetUserID(toOpaqueUid(id));
metadata.SetIsDynamicCXXType(false);
- CompilerType ct = m_clang.CreateRecordType(
- context, access, uname, ttk, lldb::eLanguageTypeC_plus_plus, &metadata);
+ CompilerType ct =
+ m_clang.CreateRecordType(context, OptionalClangModuleID(), access, uname,
+ ttk, lldb::eLanguageTypeC_plus_plus, &metadata);
lldbassert(ct.IsValid());
- ClangASTContext::StartTagDeclarationDefinition(ct);
+ TypeSystemClang::StartTagDeclarationDefinition(ct);
// Even if it's possible, don't complete it at this point. Just mark it
// forward resolved, and if/when LLDB needs the full definition, it can
@@ -789,7 +790,7 @@ clang::QualType PdbAstBuilder::CreateRecordType(PdbTypeSymId id,
clang::QualType result =
clang::QualType::getFromOpaquePtr(ct.GetOpaqueQualType());
- ClangASTContext::SetHasExternalStorage(result.getAsOpaquePtr(), true);
+ TypeSystemClang::SetHasExternalStorage(result.getAsOpaquePtr(), true);
return result;
}
@@ -804,7 +805,8 @@ clang::NamespaceDecl *
PdbAstBuilder::GetOrCreateNamespaceDecl(const char *name,
clang::DeclContext &context) {
return m_clang.GetUniqueNamespaceDeclaration(
- IsAnonymousNamespaceName(name) ? nullptr : name, &context);
+ IsAnonymousNamespaceName(name) ? nullptr : name, &context,
+ OptionalClangModuleID());
}
clang::BlockDecl *
@@ -814,7 +816,8 @@ PdbAstBuilder::GetOrCreateBlockDecl(PdbCompilandSymId block_id) {
clang::DeclContext *scope = GetParentDeclContext(block_id);
- clang::BlockDecl *block_decl = m_clang.CreateBlockDeclaration(scope);
+ clang::BlockDecl *block_decl =
+ m_clang.CreateBlockDeclaration(scope, OptionalClangModuleID());
m_uid_to_decl.insert({toOpaqueUid(block_id), block_decl});
DeclStatus status;
@@ -831,7 +834,7 @@ clang::VarDecl *PdbAstBuilder::CreateVariableDecl(PdbSymUid uid, CVSymbol sym,
clang::QualType qt = GetOrCreateType(var_info.type);
clang::VarDecl *var_decl = m_clang.CreateVariableDeclaration(
- &scope, var_info.name.str().c_str(), qt);
+ &scope, OptionalClangModuleID(), var_info.name.str().c_str(), qt);
m_uid_to_decl[toOpaqueUid(uid)] = var_decl;
DeclStatus status;
@@ -876,10 +879,10 @@ PdbAstBuilder::GetOrCreateTypedefDecl(PdbGlobalSymId id) {
PdbTypeSymId real_type_id{udt.Type, false};
clang::QualType qt = GetOrCreateType(real_type_id);
- std::string uname = DropNameScope(udt.Name);
+ std::string uname = std::string(DropNameScope(udt.Name));
CompilerType ct = m_clang.CreateTypedefType(ToCompilerType(qt), uname.c_str(),
- ToCompilerDeclContext(*scope));
+ ToCompilerDeclContext(*scope), 0);
clang::TypedefNameDecl *tnd = m_clang.GetAsTypedefDecl(ct);
DeclStatus status;
status.resolved = true;
@@ -1012,7 +1015,8 @@ PdbAstBuilder::GetOrCreateFunctionDecl(PdbCompilandSymId func_id) {
proc_name.consume_front("::");
clang::FunctionDecl *function_decl = m_clang.CreateFunctionDeclaration(
- parent, proc_name.str().c_str(), func_ct, storage, false);
+ parent, OptionalClangModuleID(), proc_name.str().c_str(), func_ct,
+ storage, false);
lldbassert(m_uid_to_decl.count(toOpaqueUid(func_id)) == 0);
m_uid_to_decl[toOpaqueUid(func_id)] = function_decl;
@@ -1080,8 +1084,8 @@ void PdbAstBuilder::CreateFunctionParameters(PdbCompilandSymId func_id,
CompilerType param_type_ct = m_clang.GetType(qt);
clang::ParmVarDecl *param = m_clang.CreateParameterDeclaration(
- &function_decl, param_name.str().c_str(), param_type_ct,
- clang::SC_None, true);
+ &function_decl, OptionalClangModuleID(), param_name.str().c_str(),
+ param_type_ct, clang::SC_None, true);
lldbassert(m_uid_to_decl.count(toOpaqueUid(param_uid)) == 0);
m_uid_to_decl[toOpaqueUid(param_uid)] = param;
@@ -1102,11 +1106,11 @@ clang::QualType PdbAstBuilder::CreateEnumType(PdbTypeSymId id,
Declaration declaration;
CompilerType enum_ct = m_clang.CreateEnumerationType(
- uname.c_str(), decl_context, declaration, ToCompilerType(underlying_type),
- er.isScoped());
+ uname.c_str(), decl_context, OptionalClangModuleID(), declaration,
+ ToCompilerType(underlying_type), er.isScoped());
- ClangASTContext::StartTagDeclarationDefinition(enum_ct);
- ClangASTContext::SetHasExternalStorage(enum_ct.GetOpaqueQualType(), true);
+ TypeSystemClang::StartTagDeclarationDefinition(enum_ct);
+ TypeSystemClang::SetHasExternalStorage(enum_ct.GetOpaqueQualType(), true);
return clang::QualType::getFromOpaquePtr(enum_ct.GetOpaqueQualType());
}
@@ -1334,7 +1338,7 @@ void PdbAstBuilder::ParseDeclsForContext(clang::DeclContext &context) {
}
CompilerDecl PdbAstBuilder::ToCompilerDecl(clang::Decl &decl) {
- return {&m_clang, &decl};
+ return m_clang.GetCompilerDecl(&decl);
}
CompilerType PdbAstBuilder::ToCompilerType(clang::QualType qt) {
@@ -1347,7 +1351,7 @@ PdbAstBuilder::ToCompilerDeclContext(clang::DeclContext &context) {
}
clang::Decl * PdbAstBuilder::FromCompilerDecl(CompilerDecl decl) {
- return static_cast<clang::Decl *>(decl.GetOpaqueDecl());
+ return ClangUtil::GetDecl(decl);
}
clang::DeclContext *
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
index a4242e90810d..7bb2584d19a3 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
@@ -6,13 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBASTBUILDER_H
-#define LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBASTBUILDER_H
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBASTBUILDER_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBASTBUILDER_H
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringRef.h"
-#include "lldb/Symbol/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
#include "PdbIndex.h"
#include "PdbSymUid.h"
@@ -51,7 +51,7 @@ struct DeclStatus {
class PdbAstBuilder {
public:
// Constructors and Destructors
- PdbAstBuilder(ObjectFile &obj, PdbIndex &index, ClangASTContext &clang);
+ PdbAstBuilder(ObjectFile &obj, PdbIndex &index, TypeSystemClang &clang);
lldb_private::CompilerDeclContext GetTranslationUnitDecl();
@@ -80,7 +80,7 @@ public:
clang::Decl *FromCompilerDecl(CompilerDecl decl);
clang::DeclContext *FromCompilerDeclContext(CompilerDeclContext context);
- ClangASTContext &clang() { return m_clang; }
+ TypeSystemClang &clang() { return m_clang; }
ClangASTImporter &importer() { return m_importer; }
void Dump(Stream &stream);
@@ -129,7 +129,7 @@ private:
clang::QualType CreateSimpleType(TypeIndex ti);
PdbIndex &m_index;
- ClangASTContext &m_clang;
+ TypeSystemClang &m_clang;
ClangASTImporter m_importer;
@@ -142,4 +142,4 @@ private:
} // namespace npdb
} // namespace lldb_private
-#endif // lldb_Plugins_SymbolFile_PDB_SymbolFilePDB_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBASTBUILDER_H
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp
index a7bc23519710..ecae767e4469 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp
@@ -1,4 +1,4 @@
-//===-- PdbFPOProgramToDWARFExpression.cpp ----------------------*- C++ -*-===//
+//===-- PdbFPOProgramToDWARFExpression.cpp --------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.h b/lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.h
index 107e26fb04cb..fb979b877143 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.h
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Plugins_SymbolFile_PDB_PDBFPOProgramToDWARFExpression_h_
-#define lldb_Plugins_SymbolFile_PDB_PDBFPOProgramToDWARFExpression_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBFPOPROGRAMTODWARFEXPRESSION_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBFPOPROGRAMTODWARFEXPRESSION_H
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp
index ba9a95b16e18..6ac6cc2da29b 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp
@@ -1,4 +1,4 @@
-//===-- PdbIndex.cpp --------------------------------------------*- C++ -*-===//
+//===-- PdbIndex.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.h b/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.h
index b30e7870bbdb..ccc3cc2f4538 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.h
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_PLUGINS_SYMBOLFILENATIVEPDB_PDBINDEX_H
-#define LLDB_PLUGINS_SYMBOLFILENATIVEPDB_PDBINDEX_H
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBINDEX_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBINDEX_H
#include "lldb/lldb-types.h"
#include "llvm/ADT/IntervalMap.h"
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbSymUid.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbSymUid.cpp
index e5ad23f813eb..67397d707110 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbSymUid.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbSymUid.cpp
@@ -1,4 +1,4 @@
-//===-- PdbSymUid.cpp -------------------------------------------*- C++ -*-===//
+//===-- PdbSymUid.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h b/lldb/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h
index 7252d63c1ab4..3accd38d710e 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h
@@ -14,8 +14,8 @@
// access to the compile unit's information.
//===----------------------------------------------------------------------===//
-#ifndef LLDB_PLUGINS_SYMBOLFILENATIVEPDB_PDBSYMUID_H
-#define LLDB_PLUGINS_SYMBOLFILENATIVEPDB_PDBSYMUID_H
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBSYMUID_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBSYMUID_H
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
#include "llvm/DebugInfo/PDB/PDBTypes.h"
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
index fc047e25a2f4..b5a16447d9cf 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
@@ -1,4 +1,4 @@
-//===-- PdbUtil.cpp ---------------------------------------------*- C++ -*-===//
+//===-- PdbUtil.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
index 6f675b56dca4..c309c5c8ea1c 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_PLUGINS_SYMBOLFILENATIVEPDB_PDBUTIL_H
-#define LLDB_PLUGINS_SYMBOLFILENATIVEPDB_PDBUTIL_H
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBUTIL_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_PDBUTIL_H
#include "lldb/Expression/DWARFExpression.h"
#include "lldb/Symbol/Variable.h"
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index 370c339fb74b..cce06473d92f 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -1,4 +1,4 @@
-//===-- SymbolFileNativePDB.cpp ---------------------------------*- C++ -*-===//
+//===-- SymbolFileNativePDB.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -14,13 +14,13 @@
#include "clang/AST/DeclCXX.h"
#include "clang/AST/Type.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
#include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/StreamBuffer.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -129,17 +129,18 @@ loadMatchingPDBFile(std::string exe_path, llvm::BumpPtrAllocator &allocator) {
// If it doesn't have a debug directory, fail.
llvm::StringRef pdb_file;
- auto ec = obj->getDebugPDBInfo(pdb_info, pdb_file);
- if (ec)
+ if (llvm::Error e = obj->getDebugPDBInfo(pdb_info, pdb_file)) {
+ consumeError(std::move(e));
return nullptr;
+ }
// if the file doesn't exist, is not a pdb, or doesn't have a matching guid,
// fail.
llvm::file_magic magic;
- ec = llvm::identify_magic(pdb_file, magic);
+ auto ec = llvm::identify_magic(pdb_file, magic);
if (ec || magic != llvm::file_magic::pdb)
return nullptr;
- std::unique_ptr<PDBFile> pdb = loadPDBFile(pdb_file, allocator);
+ std::unique_ptr<PDBFile> pdb = loadPDBFile(std::string(pdb_file), allocator);
if (!pdb)
return nullptr;
@@ -331,7 +332,7 @@ void SymbolFileNativePDB::InitializeObject() {
std::move(err), "Failed to initialize");
} else {
ts_or_err->SetSymbolFile(this);
- auto *clang = llvm::cast_or_null<ClangASTContext>(&ts_or_err.get());
+ auto *clang = llvm::cast_or_null<TypeSystemClang>(&ts_or_err.get());
lldbassert(clang);
m_ast = std::make_unique<PdbAstBuilder>(*m_objfile_sp, *m_index, *clang);
}
@@ -452,7 +453,7 @@ lldb::TypeSP SymbolFileNativePDB::CreateModifierType(PdbTypeSymId type_id,
std::string name;
if (mr.ModifiedType.isSimple())
- name = GetSimpleTypeName(mr.ModifiedType.getSimpleKind());
+ name = std::string(GetSimpleTypeName(mr.ModifiedType.getSimpleKind()));
else
name = computeTypeName(stream.typeCollection(), mr.ModifiedType);
Declaration decl;
@@ -532,14 +533,14 @@ static std::string GetUnqualifiedTypeName(const TagRecord &record) {
MSVCUndecoratedNameParser parser(record.Name);
llvm::ArrayRef<MSVCUndecoratedNameSpecifier> specs = parser.GetSpecifiers();
- return specs.back().GetBaseName();
+ return std::string(specs.back().GetBaseName());
}
llvm::ms_demangle::Demangler demangler;
StringView sv(record.UniqueName.begin(), record.UniqueName.size());
llvm::ms_demangle::TagTypeNode *ttn = demangler.parseTagUniqueName(sv);
if (demangler.Error)
- return record.Name;
+ return std::string(record.Name);
llvm::ms_demangle::IdentifierNode *idn =
ttn->QualifiedName->getUnqualifiedIdentifier();
@@ -1171,7 +1172,7 @@ size_t SymbolFileNativePDB::ParseBlocksRecursive(Function &func) {
void SymbolFileNativePDB::DumpClangAST(Stream &s) { m_ast->Dump(s); }
void SymbolFileNativePDB::FindGlobalVariables(
- ConstString name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches, VariableList &variables) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>;
@@ -1198,7 +1199,7 @@ void SymbolFileNativePDB::FindGlobalVariables(
}
void SymbolFileNativePDB::FindFunctions(
- ConstString name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext &parent_decl_ctx,
FunctionNameType name_type_mask, bool include_inlines,
SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
@@ -1236,7 +1237,7 @@ void SymbolFileNativePDB::FindFunctions(const RegularExpression &regex,
SymbolContextList &sc_list) {}
void SymbolFileNativePDB::FindTypes(
- ConstString name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files,
TypeMap &types) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
@@ -1563,7 +1564,7 @@ void SymbolFileNativePDB::GetTypes(lldb_private::SymbolContextScope *sc_scope,
CompilerDeclContext
SymbolFileNativePDB::FindNamespace(ConstString name,
- const CompilerDeclContext *parent_decl_ctx) {
+ const CompilerDeclContext &parent_decl_ctx) {
return {};
}
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
index a37de0f58ef3..bf5718e11a19 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_SYMBOLFILENATIVEPDB_H
-#define LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_SYMBOLFILENATIVEPDB_H
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_SYMBOLFILENATIVEPDB_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_SYMBOLFILENATIVEPDB_H
#include "lldb/Symbol/SymbolFile.h"
@@ -100,7 +100,7 @@ public:
size_t ParseBlocksRecursive(Function &func) override;
void FindGlobalVariables(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
+ const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
VariableList &variables) override;
@@ -129,14 +129,14 @@ public:
TypeList &type_list) override;
void FindFunctions(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
+ const CompilerDeclContext &parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines, SymbolContextList &sc_list) override;
void FindFunctions(const RegularExpression &regex, bool include_inlines,
SymbolContextList &sc_list) override;
- void FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx,
+ void FindTypes(ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<SymbolFile *> &searched_symbol_files,
TypeMap &types) override;
@@ -150,7 +150,7 @@ public:
CompilerDeclContext
FindNamespace(ConstString name,
- const CompilerDeclContext *parent_decl_ctx) override;
+ const CompilerDeclContext &parent_decl_ctx) override;
ConstString GetPluginName() override;
@@ -246,4 +246,4 @@ private:
} // namespace npdb
} // namespace lldb_private
-#endif // lldb_Plugins_SymbolFile_PDB_SymbolFilePDB_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_SYMBOLFILENATIVEPDB_H
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
index 7221144407c1..c8fb46c75034 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
@@ -5,15 +5,18 @@
#include "PdbSymUid.h"
#include "PdbUtil.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-forward.h"
+#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
+#include "llvm/DebugInfo/PDB/Native/GlobalsStream.h"
#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
#include "llvm/DebugInfo/PDB/PDBTypes.h"
@@ -29,10 +32,10 @@ UdtRecordCompleter::UdtRecordCompleter(PdbTypeSymId id,
CompilerType &derived_ct,
clang::TagDecl &tag_decl,
PdbAstBuilder &ast_builder,
- TpiStream &tpi)
+ PdbIndex &index)
: m_id(id), m_derived_ct(derived_ct), m_tag_decl(tag_decl),
- m_ast_builder(ast_builder), m_tpi(tpi) {
- CVType cvt = m_tpi.getType(m_id.index);
+ m_ast_builder(ast_builder), m_index(index) {
+ CVType cvt = m_index.tpi().getType(m_id.index);
switch (cvt.kind()) {
case LF_ENUM:
llvm::cantFail(TypeDeserializer::deserializeAs<EnumRecord>(cvt, m_cvr.er));
@@ -55,7 +58,7 @@ clang::QualType UdtRecordCompleter::AddBaseClassForTypeIndex(
PdbTypeSymId type_id(ti);
clang::QualType qt = m_ast_builder.GetOrCreateType(type_id);
- CVType udt_cvt = m_tpi.getType(ti);
+ CVType udt_cvt = m_index.tpi().getType(ti);
std::unique_ptr<clang::CXXBaseSpecifier> base_spec =
m_ast_builder.clang().CreateBaseClassSpecifier(
@@ -128,9 +131,70 @@ Error UdtRecordCompleter::visitKnownMember(
lldb::AccessType access =
TranslateMemberAccess(static_data_member.getAccess());
- ClangASTContext::AddVariableToRecordType(
+ auto decl = TypeSystemClang::AddVariableToRecordType(
m_derived_ct, static_data_member.Name, member_ct, access);
+ // Static constant members may be a const[expr] declaration.
+ // Query the symbol's value as the variable initializer if valid.
+ if (member_ct.IsConst()) {
+ std::string qual_name = decl->getQualifiedNameAsString();
+
+ auto results =
+ m_index.globals().findRecordsByName(qual_name, m_index.symrecords());
+
+ for (const auto &result : results) {
+ if (result.second.kind() == SymbolKind::S_CONSTANT) {
+ ConstantSym constant(SymbolRecordKind::ConstantSym);
+ cantFail(SymbolDeserializer::deserializeAs<ConstantSym>(result.second,
+ constant));
+
+ clang::QualType qual_type = decl->getType();
+ unsigned type_width = decl->getASTContext().getIntWidth(qual_type);
+ unsigned constant_width = constant.Value.getBitWidth();
+
+ if (qual_type->isIntegralOrEnumerationType()) {
+ if (type_width >= constant_width) {
+ TypeSystemClang::SetIntegerInitializerForVariable(
+ decl, constant.Value.extOrTrunc(type_width));
+ } else {
+ LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_AST),
+ "Class '{0}' has a member '{1}' of type '{2}' ({3} bits) "
+ "which resolves to a wider constant value ({4} bits). "
+ "Ignoring constant.",
+ m_derived_ct.GetTypeName(), static_data_member.Name,
+ member_ct.GetTypeName(), type_width, constant_width);
+ }
+ } else {
+ lldb::BasicType basic_type_enum = member_ct.GetBasicTypeEnumeration();
+ switch (basic_type_enum) {
+ case lldb::eBasicTypeFloat:
+ case lldb::eBasicTypeDouble:
+ case lldb::eBasicTypeLongDouble:
+ if (type_width == constant_width) {
+ TypeSystemClang::SetFloatingInitializerForVariable(
+ decl, basic_type_enum == lldb::eBasicTypeFloat
+ ? llvm::APFloat(constant.Value.bitsToFloat())
+ : llvm::APFloat(constant.Value.bitsToDouble()));
+ decl->setConstexpr(true);
+ } else {
+ LLDB_LOG(
+ GetLogIfAllCategoriesSet(LIBLLDB_LOG_AST),
+ "Class '{0}' has a member '{1}' of type '{2}' ({3} bits) "
+ "which resolves to a constant value of mismatched width "
+ "({4} bits). Ignoring constant.",
+ m_derived_ct.GetTypeName(), static_data_member.Name,
+ member_ct.GetTypeName(), type_width, constant_width);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+
// FIXME: Add a PdbSymUid namespace for field list members and update
// the m_uid_to_decl map with this decl.
return Error::success();
@@ -149,7 +213,7 @@ Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr,
TypeIndex ti(data_member.Type);
if (!ti.isSimple()) {
- CVType cvt = m_tpi.getType(ti);
+ CVType cvt = m_index.tpi().getType(ti);
if (cvt.kind() == LF_BITFIELD) {
BitFieldRecord bfr;
llvm::cantFail(TypeDeserializer::deserializeAs<BitFieldRecord>(cvt, bfr));
@@ -164,7 +228,7 @@ Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr,
lldb::AccessType access = TranslateMemberAccess(data_member.getAccess());
- clang::FieldDecl *decl = ClangASTContext::AddFieldToRecordType(
+ clang::FieldDecl *decl = TypeSystemClang::AddFieldToRecordType(
m_derived_ct, data_member.Name, m_ast_builder.ToCompilerType(member_qt),
access, bitfield_width);
// FIXME: Add a PdbSymUid namespace for field list members and update
@@ -187,7 +251,7 @@ Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr,
OverloadedMethodRecord &overloaded) {
TypeIndex method_list_idx = overloaded.MethodList;
- CVType method_list_type = m_tpi.getType(method_list_idx);
+ CVType method_list_type = m_index.tpi().getType(method_list_idx);
assert(method_list_type.kind() == LF_METHODLIST);
MethodOverloadListRecord method_list;
@@ -223,12 +287,12 @@ void UdtRecordCompleter::complete() {
for (auto &ib : m_bases)
bases.push_back(std::move(ib.second));
- ClangASTContext &clang = m_ast_builder.clang();
+ TypeSystemClang &clang = m_ast_builder.clang();
clang.TransferBaseClasses(m_derived_ct.GetOpaqueQualType(), std::move(bases));
clang.AddMethodOverridesForCXXRecordType(m_derived_ct.GetOpaqueQualType());
- ClangASTContext::BuildIndirectFields(m_derived_ct);
- ClangASTContext::CompleteTagDeclarationDefinition(m_derived_ct);
+ TypeSystemClang::BuildIndirectFields(m_derived_ct);
+ TypeSystemClang::CompleteTagDeclarationDefinition(m_derived_ct);
if (auto *record_decl = llvm::dyn_cast<clang::CXXRecordDecl>(&m_tag_decl)) {
m_ast_builder.importer().SetRecordLayout(record_decl, m_layout);
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h
index 55397582209b..ae7e47c82fe5 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h
@@ -6,10 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_UDTRECORDCOMPLETER_H
-#define LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_UDTRECORDCOMPLETER_H
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_UDTRECORDCOMPLETER_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_UDTRECORDCOMPLETER_H
-#include "lldb/Symbol/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
#include "llvm/DebugInfo/CodeView/CVRecord.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
@@ -25,6 +25,7 @@ class TagDecl;
namespace llvm {
namespace pdb {
class TpiStream;
+class GlobalsStream;
}
} // namespace llvm
@@ -33,6 +34,7 @@ class Type;
class CompilerType;
namespace npdb {
class PdbAstBuilder;
+class PdbIndex;
class UdtRecordCompleter : public llvm::codeview::TypeVisitorCallbacks {
using IndexedBase =
@@ -49,14 +51,14 @@ class UdtRecordCompleter : public llvm::codeview::TypeVisitorCallbacks {
CompilerType &m_derived_ct;
clang::TagDecl &m_tag_decl;
PdbAstBuilder &m_ast_builder;
- llvm::pdb::TpiStream &m_tpi;
+ PdbIndex &m_index;
std::vector<IndexedBase> m_bases;
ClangASTImporter::LayoutInfo m_layout;
public:
UdtRecordCompleter(PdbTypeSymId id, CompilerType &derived_ct,
clang::TagDecl &tag_decl, PdbAstBuilder &ast_builder,
- llvm::pdb::TpiStream &tpi);
+ PdbIndex &index);
#define MEMBER_RECORD(EnumName, EnumVal, Name) \
llvm::Error visitKnownMember(llvm::codeview::CVMemberRecord &CVR, \
@@ -79,4 +81,4 @@ private:
} // namespace npdb
} // namespace lldb_private
-#endif // LLDB_PLUGINS_SYMBOLFILE_NATIVEPDB_UDTRECORDCOMPLETER_H
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_NATIVEPDB_UDTRECORDCOMPLETER_H
diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
index 6b2dbd9e1e5a..d87926a6588f 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -1,4 +1,4 @@
-//===-- PDBASTParser.cpp ----------------------------------------*- C++ -*-===//
+//===-- PDBASTParser.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -14,10 +14,10 @@
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Module.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangASTMetadata.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/Declaration.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/TypeMap.h"
@@ -100,7 +100,7 @@ static lldb::Encoding TranslateEnumEncoding(PDB_VariantType type) {
}
static CompilerType
-GetBuiltinTypeForPDBEncodingAndBitSize(ClangASTContext &clang_ast,
+GetBuiltinTypeForPDBEncodingAndBitSize(TypeSystemClang &clang_ast,
const PDBSymbolTypeBuiltin &pdb_type,
Encoding encoding, uint32_t width) {
clang::ASTContext &ast = clang_ast.getASTContext();
@@ -353,7 +353,7 @@ static clang::CallingConv TranslateCallingConvention(PDB_CallingConv pdb_cc) {
}
}
-PDBASTParser::PDBASTParser(lldb_private::ClangASTContext &ast) : m_ast(ast) {}
+PDBASTParser::PDBASTParser(lldb_private::TypeSystemClang &ast) : m_ast(ast) {}
PDBASTParser::~PDBASTParser() {}
@@ -386,7 +386,8 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
return nullptr;
// Ignore unnamed-tag UDTs.
- std::string name = MSVCUndecoratedNameParser::DropScope(udt->getName());
+ std::string name =
+ std::string(MSVCUndecoratedNameParser::DropScope(udt->getName()));
if (name.empty())
return nullptr;
@@ -408,9 +409,9 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
metadata.SetUserID(type.getSymIndexId());
metadata.SetIsDynamicCXXType(false);
- clang_type =
- m_ast.CreateRecordType(decl_context, access, name, tag_type_kind,
- lldb::eLanguageTypeC_plus_plus, &metadata);
+ clang_type = m_ast.CreateRecordType(
+ decl_context, OptionalClangModuleID(), access, name, tag_type_kind,
+ lldb::eLanguageTypeC_plus_plus, &metadata);
assert(clang_type.IsValid());
auto record_decl =
@@ -422,15 +423,15 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
m_ast.getASTContext(), GetMSInheritance(*udt));
record_decl->addAttr(inheritance_attr);
- ClangASTContext::StartTagDeclarationDefinition(clang_type);
+ TypeSystemClang::StartTagDeclarationDefinition(clang_type);
auto children = udt->findAllChildren();
if (!children || children->getChildCount() == 0) {
// PDB does not have symbol of forwarder. We assume we get an udt w/o
// any fields. Just complete it at this point.
- ClangASTContext::CompleteTagDeclarationDefinition(clang_type);
+ TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
- ClangASTContext::SetHasExternalStorage(clang_type.GetOpaqueQualType(),
+ TypeSystemClang::SetHasExternalStorage(clang_type.GetOpaqueQualType(),
false);
type_resolve_state = Type::ResolveState::Full;
@@ -439,7 +440,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
// an endless recursion in CompleteTypeFromUdt function.
m_forward_decl_to_uid[record_decl] = type.getSymIndexId();
- ClangASTContext::SetHasExternalStorage(clang_type.GetOpaqueQualType(),
+ TypeSystemClang::SetHasExternalStorage(clang_type.GetOpaqueQualType(),
true);
type_resolve_state = Type::ResolveState::Forward;
@@ -465,7 +466,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
assert(enum_type);
std::string name =
- MSVCUndecoratedNameParser::DropScope(enum_type->getName());
+ std::string(MSVCUndecoratedNameParser::DropScope(enum_type->getName()));
auto decl_context = GetDeclContextContainingSymbol(type);
uint64_t bytes = enum_type->getLength();
@@ -496,10 +497,11 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
// Class). Set it false for now.
bool isScoped = false;
- ast_enum = m_ast.CreateEnumerationType(name.c_str(), decl_context, decl,
+ ast_enum = m_ast.CreateEnumerationType(name.c_str(), decl_context,
+ OptionalClangModuleID(), decl,
builtin_type, isScoped);
- auto enum_decl = ClangASTContext::GetAsEnumDecl(ast_enum);
+ auto enum_decl = TypeSystemClang::GetAsEnumDecl(ast_enum);
assert(enum_decl);
m_uid_to_decl[type.getSymIndexId()] = enum_decl;
@@ -512,8 +514,8 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
}
}
- if (ClangASTContext::StartTagDeclarationDefinition(ast_enum))
- ClangASTContext::CompleteTagDeclarationDefinition(ast_enum);
+ if (TypeSystemClang::StartTagDeclarationDefinition(ast_enum))
+ TypeSystemClang::CompleteTagDeclarationDefinition(ast_enum);
}
if (enum_type->isConstType())
@@ -538,7 +540,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
return nullptr;
std::string name =
- MSVCUndecoratedNameParser::DropScope(type_def->getName());
+ std::string(MSVCUndecoratedNameParser::DropScope(type_def->getName()));
auto decl_ctx = GetDeclContextContainingSymbol(type);
// Check if such a typedef already exists in the current context
@@ -549,11 +551,11 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
CompilerType target_ast_type = target_type->GetFullCompilerType();
ast_typedef = m_ast.CreateTypedefType(
- target_ast_type, name.c_str(), m_ast.CreateDeclContext(decl_ctx));
+ target_ast_type, name.c_str(), m_ast.CreateDeclContext(decl_ctx), 0);
if (!ast_typedef)
return nullptr;
- auto typedef_decl = ClangASTContext::GetAsTypedefDecl(ast_typedef);
+ auto typedef_decl = TypeSystemClang::GetAsTypedefDecl(ast_typedef);
assert(typedef_decl);
m_uid_to_decl[type.getSymIndexId()] = typedef_decl;
}
@@ -587,7 +589,8 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
return nullptr;
func_sig = sig.release();
// Function type is named.
- name = MSVCUndecoratedNameParser::DropScope(pdb_func->getName());
+ name = std::string(
+ MSVCUndecoratedNameParser::DropScope(pdb_func->getName()));
} else if (auto pdb_func_sig =
llvm::dyn_cast<PDBSymbolTypeFunctionSig>(&type)) {
func_sig = const_cast<PDBSymbolTypeFunctionSig *>(pdb_func_sig);
@@ -660,10 +663,10 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
CompilerType element_ast_type = element_type->GetForwardCompilerType();
// If element type is UDT, it needs to be complete.
- if (ClangASTContext::IsCXXClassType(element_ast_type) &&
+ if (TypeSystemClang::IsCXXClassType(element_ast_type) &&
!element_ast_type.GetCompleteType()) {
- if (ClangASTContext::StartTagDeclarationDefinition(element_ast_type)) {
- ClangASTContext::CompleteTagDeclarationDefinition(element_ast_type);
+ if (TypeSystemClang::StartTagDeclarationDefinition(element_ast_type)) {
+ TypeSystemClang::CompleteTagDeclarationDefinition(element_ast_type);
} else {
// We are not able to start defintion.
return nullptr;
@@ -721,7 +724,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
assert(class_parent_type);
CompilerType pointer_ast_type;
- pointer_ast_type = ClangASTContext::CreateMemberPointerType(
+ pointer_ast_type = TypeSystemClang::CreateMemberPointerType(
class_parent_type->GetLayoutCompilerType(),
pointee_type->GetForwardCompilerType());
assert(pointer_ast_type);
@@ -787,7 +790,7 @@ bool PDBASTParser::CompleteTypeFromPDB(
m_forward_decl_to_uid.erase(uid_it);
- ClangASTContext::SetHasExternalStorage(compiler_type.GetOpaqueQualType(),
+ TypeSystemClang::SetHasExternalStorage(compiler_type.GetOpaqueQualType(),
false);
switch (symbol->getSymTag()) {
@@ -887,7 +890,8 @@ PDBASTParser::GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol) {
if (auto parent_decl = llvm::dyn_cast_or_null<clang::TagDecl>(decl_context))
m_ast.GetCompleteDecl(parent_decl);
- std::string name = MSVCUndecoratedNameParser::DropScope(data->getName());
+ std::string name =
+ std::string(MSVCUndecoratedNameParser::DropScope(data->getName()));
// Check if the current context already contains the symbol with the name.
clang::Decl *decl =
@@ -898,7 +902,7 @@ PDBASTParser::GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol) {
return nullptr;
decl = m_ast.CreateVariableDeclaration(
- decl_context, name.c_str(),
+ decl_context, OptionalClangModuleID(), name.c_str(),
ClangUtil::GetQualType(type->GetLayoutCompilerType()));
}
@@ -913,7 +917,8 @@ PDBASTParser::GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol) {
auto decl_context = GetDeclContextContainingSymbol(symbol);
assert(decl_context);
- std::string name = MSVCUndecoratedNameParser::DropScope(func->getName());
+ std::string name =
+ std::string(MSVCUndecoratedNameParser::DropScope(func->getName()));
Type *type = symbol_file->ResolveTypeUID(sym_id);
if (!type)
@@ -923,8 +928,8 @@ PDBASTParser::GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol) {
: clang::StorageClass::SC_None;
auto decl = m_ast.CreateFunctionDeclaration(
- decl_context, name.c_str(), type->GetForwardCompilerType(), storage,
- func->hasInlineAttribute());
+ decl_context, OptionalClangModuleID(), name.c_str(),
+ type->GetForwardCompilerType(), storage, func->hasInlineAttribute());
std::vector<clang::ParmVarDecl *> params;
if (std::unique_ptr<PDBSymbolTypeFunctionSig> sig = func->getSignature()) {
@@ -937,8 +942,8 @@ PDBASTParser::GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol) {
continue;
clang::ParmVarDecl *param = m_ast.CreateParameterDeclaration(
- decl, nullptr, arg_type->GetForwardCompilerType(),
- clang::SC_None, true);
+ decl, OptionalClangModuleID(), nullptr,
+ arg_type->GetForwardCompilerType(), clang::SC_None, true);
if (param)
params.push_back(param);
}
@@ -1047,13 +1052,13 @@ clang::DeclContext *PDBASTParser::GetDeclContextContainingSymbol(
// or a type. We check it to avoid fake namespaces such as `__l2':
// `N0::N1::CClass::PrivateFunc::__l2::InnerFuncStruct'
if (!has_type_or_function_parent) {
- std::string namespace_name = specs[i].GetBaseName();
+ std::string namespace_name = std::string(specs[i].GetBaseName());
const char *namespace_name_c_str =
IsAnonymousNamespaceName(namespace_name) ? nullptr
: namespace_name.data();
clang::NamespaceDecl *namespace_decl =
- m_ast.GetUniqueNamespaceDeclaration(namespace_name_c_str,
- curr_context);
+ m_ast.GetUniqueNamespaceDeclaration(
+ namespace_name_c_str, curr_context, OptionalClangModuleID());
m_parent_to_namespaces[curr_context].insert(namespace_decl);
m_namespaces.insert(namespace_decl);
@@ -1119,7 +1124,8 @@ bool PDBASTParser::AddEnumValue(CompilerType enum_type,
const PDBSymbolData &enum_value) {
Declaration decl;
Variant v = enum_value.getValue();
- std::string name = MSVCUndecoratedNameParser::DropScope(enum_value.getName());
+ std::string name =
+ std::string(MSVCUndecoratedNameParser::DropScope(enum_value.getName()));
int64_t raw_value;
switch (v.Type) {
case PDB_VariantType::Int8:
@@ -1149,8 +1155,7 @@ bool PDBASTParser::AddEnumValue(CompilerType enum_type,
default:
return false;
}
- CompilerType underlying_type =
- m_ast.GetEnumerationIntegerType(enum_type.GetOpaqueQualType());
+ CompilerType underlying_type = m_ast.GetEnumerationIntegerType(enum_type);
uint32_t byte_size = m_ast.getASTContext().getTypeSize(
ClangUtil::GetQualType(underlying_type));
auto enum_constant_decl = m_ast.AddEnumerationValueToEnumerationType(
@@ -1190,8 +1195,8 @@ bool PDBASTParser::CompleteTypeFromUDT(
AddRecordMethods(symbol_file, compiler_type, *methods_enum);
m_ast.AddMethodOverridesForCXXRecordType(compiler_type.GetOpaqueQualType());
- ClangASTContext::BuildIndirectFields(compiler_type);
- ClangASTContext::CompleteTagDeclarationDefinition(compiler_type);
+ TypeSystemClang::BuildIndirectFields(compiler_type);
+ TypeSystemClang::CompleteTagDeclarationDefinition(compiler_type);
clang::CXXRecordDecl *record_decl =
m_ast.GetAsCXXRecordDecl(compiler_type.GetOpaqueQualType());
@@ -1225,8 +1230,8 @@ void PDBASTParser::AddRecordMembers(
"which does not have a complete definition.",
record_type.GetTypeName().GetCString(), member_name.c_str(),
member_comp_type.GetTypeName().GetCString());
- if (ClangASTContext::StartTagDeclarationDefinition(member_comp_type))
- ClangASTContext::CompleteTagDeclarationDefinition(member_comp_type);
+ if (TypeSystemClang::StartTagDeclarationDefinition(member_comp_type))
+ TypeSystemClang::CompleteTagDeclarationDefinition(member_comp_type);
}
auto access = TranslateMemberAccess(member->getAccess());
@@ -1239,7 +1244,7 @@ void PDBASTParser::AddRecordMembers(
if (location_type == PDB_LocType::ThisRel)
bit_size *= 8;
- auto decl = ClangASTContext::AddFieldToRecordType(
+ auto decl = TypeSystemClang::AddFieldToRecordType(
record_type, member_name.c_str(), member_comp_type, access, bit_size);
if (!decl)
continue;
@@ -1255,11 +1260,57 @@ void PDBASTParser::AddRecordMembers(
break;
}
case PDB_DataKind::StaticMember: {
- auto decl = ClangASTContext::AddVariableToRecordType(
+ auto decl = TypeSystemClang::AddVariableToRecordType(
record_type, member_name.c_str(), member_comp_type, access);
if (!decl)
continue;
+ // Static constant members may be a const[expr] declaration.
+ // Query the symbol's value as the variable initializer if valid.
+ if (member_comp_type.IsConst()) {
+ auto value = member->getValue();
+ clang::QualType qual_type = decl->getType();
+ unsigned type_width = m_ast.getASTContext().getIntWidth(qual_type);
+ unsigned constant_width = value.getBitWidth();
+
+ if (qual_type->isIntegralOrEnumerationType()) {
+ if (type_width >= constant_width) {
+ TypeSystemClang::SetIntegerInitializerForVariable(
+ decl, value.toAPSInt().extOrTrunc(type_width));
+ } else {
+ LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_AST),
+ "Class '{0}' has a member '{1}' of type '{2}' ({3} bits) "
+ "which resolves to a wider constant value ({4} bits). "
+ "Ignoring constant.",
+ record_type.GetTypeName(), member_name,
+ member_comp_type.GetTypeName(), type_width,
+ constant_width);
+ }
+ } else {
+ switch (member_comp_type.GetBasicTypeEnumeration()) {
+ case lldb::eBasicTypeFloat:
+ case lldb::eBasicTypeDouble:
+ case lldb::eBasicTypeLongDouble:
+ if (type_width == constant_width) {
+ TypeSystemClang::SetFloatingInitializerForVariable(
+ decl, value.toAPFloat());
+ decl->setConstexpr(true);
+ } else {
+ LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_AST),
+ "Class '{0}' has a member '{1}' of type '{2}' ({3} "
+ "bits) which resolves to a constant value of mismatched "
+ "width ({4} bits). Ignoring constant.",
+ record_type.GetTypeName(), member_name,
+ member_comp_type.GetTypeName(), type_width,
+ constant_width);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
m_uid_to_decl[member->getSymIndexId()] = decl;
break;
@@ -1289,8 +1340,8 @@ void PDBASTParser::AddRecordBases(
"which does not have a complete definition.",
record_type.GetTypeName().GetCString(),
base_comp_type.GetTypeName().GetCString());
- if (ClangASTContext::StartTagDeclarationDefinition(base_comp_type))
- ClangASTContext::CompleteTagDeclarationDefinition(base_comp_type);
+ if (TypeSystemClang::StartTagDeclarationDefinition(base_comp_type))
+ TypeSystemClang::CompleteTagDeclarationDefinition(base_comp_type);
}
auto access = TranslateMemberAccess(base->getAccess());
@@ -1333,7 +1384,8 @@ clang::CXXMethodDecl *
PDBASTParser::AddRecordMethod(lldb_private::SymbolFile &symbol_file,
lldb_private::CompilerType &record_type,
const llvm::pdb::PDBSymbolFunc &method) const {
- std::string name = MSVCUndecoratedNameParser::DropScope(method.getName());
+ std::string name =
+ std::string(MSVCUndecoratedNameParser::DropScope(method.getName()));
Type *method_type = symbol_file.ResolveTypeUID(method.getSymIndexId());
// MSVC specific __vecDelDtor.
@@ -1346,8 +1398,8 @@ PDBASTParser::AddRecordMethod(lldb_private::SymbolFile &symbol_file,
":: Class '%s' has a method '%s' whose type cannot be completed.",
record_type.GetTypeName().GetCString(),
method_comp_type.GetTypeName().GetCString());
- if (ClangASTContext::StartTagDeclarationDefinition(method_comp_type))
- ClangASTContext::CompleteTagDeclarationDefinition(method_comp_type);
+ if (TypeSystemClang::StartTagDeclarationDefinition(method_comp_type))
+ TypeSystemClang::CompleteTagDeclarationDefinition(method_comp_type);
}
AccessType access = TranslateMemberAccess(method.getAccess());
diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.h b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.h
index 9221d42b2020..06f317f4c4d9 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.h
+++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.h
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_PLUGINS_SYMBOLFILE_PDB_PDBASTPARSER_H
-#define LLDB_PLUGINS_SYMBOLFILE_PDB_PDBASTPARSER_H
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_PDBASTPARSER_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_PDBASTPARSER_H
#include "lldb/lldb-forward.h"
-#include "lldb/Symbol/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
class SymbolFilePDB;
@@ -23,7 +23,7 @@ class RecordDecl;
} // namespace clang
namespace lldb_private {
-class ClangASTContext;
+class TypeSystemClang;
class CompilerType;
} // namespace lldb_private
@@ -42,7 +42,7 @@ class PDBSymbolTypeUDT;
class PDBASTParser {
public:
- PDBASTParser(lldb_private::ClangASTContext &ast);
+ PDBASTParser(lldb_private::TypeSystemClang &ast);
~PDBASTParser();
lldb::TypeSP CreateLLDBTypeFromPDBType(const llvm::pdb::PDBSymbol &type);
@@ -103,7 +103,7 @@ private:
lldb_private::CompilerType &record_type,
const llvm::pdb::PDBSymbolFunc &method) const;
- lldb_private::ClangASTContext &m_ast;
+ lldb_private::TypeSystemClang &m_ast;
lldb_private::ClangASTImporter m_ast_importer;
CXXRecordDeclToUidMap m_forward_decl_to_uid;
@@ -113,4 +113,4 @@ private:
DeclContextToUidMap m_decl_context_to_uid;
};
-#endif // LLDB_PLUGINS_SYMBOLFILE_PDB_PDBASTPARSER_H
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_PDBASTPARSER_H
diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
index 42bf1b34c956..330188e29f00 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
@@ -1,4 +1,4 @@
-//===-- PDBLocationToDWARFExpression.cpp ------------------------*- C++ -*-===//
+//===-- PDBLocationToDWARFExpression.cpp ----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h b/lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h
index 2e9d1386d537..fd0fef03e2c8 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h
+++ b/lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Plugins_SymbolFile_PDB_PDBLocationToDWARFExpression_h_
-#define lldb_Plugins_SymbolFile_PDB_PDBLocationToDWARFExpression_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_PDBLOCATIONTODWARFEXPRESSION_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_PDBLOCATIONTODWARFEXPRESSION_H
#include "lldb/Core/Module.h"
#include "lldb/Symbol/Variable.h"
diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index 917ab68af418..1001514edede 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -1,4 +1,4 @@
-//===-- SymbolFilePDB.cpp ---------------------------------------*- C++ -*-===//
+//===-- SymbolFilePDB.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -13,9 +13,9 @@
#include "clang/Lex/Lexer.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -58,6 +58,8 @@ using namespace lldb;
using namespace lldb_private;
using namespace llvm::pdb;
+LLDB_PLUGIN_DEFINE(SymbolFilePDB)
+
char SymbolFilePDB::ID;
namespace {
@@ -310,8 +312,8 @@ SymbolFilePDB::ParseCompileUnitFunctionForPDBFunc(const PDBSymbolFunc &pdb_func,
return nullptr;
}
- ClangASTContext *clang_type_system =
- llvm::dyn_cast_or_null<ClangASTContext>(&type_system_or_err.get());
+ TypeSystemClang *clang_type_system =
+ llvm::dyn_cast_or_null<TypeSystemClang>(&type_system_or_err.get());
if (!clang_type_system)
return nullptr;
clang_type_system->GetPDBParser()->GetDeclForSymbol(pdb_func);
@@ -560,8 +562,8 @@ lldb_private::Type *SymbolFilePDB::ResolveTypeUID(lldb::user_id_t type_uid) {
return nullptr;
}
- ClangASTContext *clang_type_system =
- llvm::dyn_cast_or_null<ClangASTContext>(&type_system_or_err.get());
+ TypeSystemClang *clang_type_system =
+ llvm::dyn_cast_or_null<TypeSystemClang>(&type_system_or_err.get());
if (!clang_type_system)
return nullptr;
PDBASTParser *pdb = clang_type_system->GetPDBParser();
@@ -597,8 +599,8 @@ bool SymbolFilePDB::CompleteType(lldb_private::CompilerType &compiler_type) {
return false;
}
- ClangASTContext *clang_ast_ctx =
- llvm::dyn_cast_or_null<ClangASTContext>(&type_system_or_err.get());
+ TypeSystemClang *clang_ast_ctx =
+ llvm::dyn_cast_or_null<TypeSystemClang>(&type_system_or_err.get());
if (!clang_ast_ctx)
return false;
@@ -619,8 +621,8 @@ lldb_private::CompilerDecl SymbolFilePDB::GetDeclForUID(lldb::user_id_t uid) {
return CompilerDecl();
}
- ClangASTContext *clang_ast_ctx =
- llvm::dyn_cast_or_null<ClangASTContext>(&type_system_or_err.get());
+ TypeSystemClang *clang_ast_ctx =
+ llvm::dyn_cast_or_null<TypeSystemClang>(&type_system_or_err.get());
if (!clang_ast_ctx)
return CompilerDecl();
@@ -636,7 +638,7 @@ lldb_private::CompilerDecl SymbolFilePDB::GetDeclForUID(lldb::user_id_t uid) {
if (!decl)
return CompilerDecl();
- return CompilerDecl(clang_ast_ctx, decl);
+ return clang_ast_ctx->GetCompilerDecl(decl);
}
lldb_private::CompilerDeclContext
@@ -649,8 +651,8 @@ SymbolFilePDB::GetDeclContextForUID(lldb::user_id_t uid) {
return CompilerDeclContext();
}
- ClangASTContext *clang_ast_ctx =
- llvm::dyn_cast_or_null<ClangASTContext>(&type_system_or_err.get());
+ TypeSystemClang *clang_ast_ctx =
+ llvm::dyn_cast_or_null<TypeSystemClang>(&type_system_or_err.get());
if (!clang_ast_ctx)
return CompilerDeclContext();
@@ -679,8 +681,8 @@ SymbolFilePDB::GetDeclContextContainingUID(lldb::user_id_t uid) {
return CompilerDeclContext();
}
- ClangASTContext *clang_ast_ctx =
- llvm::dyn_cast_or_null<ClangASTContext>(&type_system_or_err.get());
+ TypeSystemClang *clang_ast_ctx =
+ llvm::dyn_cast_or_null<TypeSystemClang>(&type_system_or_err.get());
if (!clang_ast_ctx)
return CompilerDeclContext();
@@ -708,8 +710,8 @@ void SymbolFilePDB::ParseDeclsForContext(
return;
}
- ClangASTContext *clang_ast_ctx =
- llvm::dyn_cast_or_null<ClangASTContext>(&type_system_or_err.get());
+ TypeSystemClang *clang_ast_ctx =
+ llvm::dyn_cast_or_null<TypeSystemClang>(&type_system_or_err.get());
if (!clang_ast_ctx)
return;
@@ -1096,8 +1098,7 @@ SymbolFilePDB::ParseVariables(const lldb_private::SymbolContext &sc,
}
void SymbolFilePDB::FindGlobalVariables(
- lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ lldb_private::ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches, lldb_private::VariableList &variables) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
@@ -1129,8 +1130,8 @@ void SymbolFilePDB::FindGlobalVariables(
if (sc.comp_unit == nullptr)
continue;
- if (parent_decl_ctx && GetDeclContextContainingUID(
- result->getSymIndexId()) != *parent_decl_ctx)
+ if (parent_decl_ctx.IsValid() &&
+ GetDeclContextContainingUID(result->getSymIndexId()) != parent_decl_ctx)
continue;
ParseVariables(sc, *pdb_data, &variables);
@@ -1225,7 +1226,7 @@ void SymbolFilePDB::CacheFunctionNames() {
// To search a method name, like NS::Class:MemberFunc, LLDB searches
// its base name, i.e. MemberFunc by default. Since PDBSymbolFunc does
- // not have inforamtion of this, we extract base names and cache them
+ // not have information of this, we extract base names and cache them
// by our own effort.
llvm::StringRef basename = MSVCUndecoratedNameParser::DropScope(name);
if (!basename.empty())
@@ -1294,7 +1295,7 @@ void SymbolFilePDB::CacheFunctionNames() {
void SymbolFilePDB::FindFunctions(
lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ const lldb_private::CompilerDeclContext &parent_decl_ctx,
FunctionNameType name_type_mask, bool include_inlines,
lldb_private::SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
@@ -1323,8 +1324,8 @@ void SymbolFilePDB::FindFunctions(
if (resolved_ids.find(id) != resolved_ids.end())
continue;
- if (parent_decl_ctx &&
- GetDeclContextContainingUID(id) != *parent_decl_ctx)
+ if (parent_decl_ctx.IsValid() &&
+ GetDeclContextContainingUID(id) != parent_decl_ctx)
continue;
if (ResolveFunction(id, include_inlines, sc_list))
@@ -1422,8 +1423,7 @@ void SymbolFilePDB::AddSymbols(lldb_private::Symtab &symtab) {
}
void SymbolFilePDB::FindTypes(
- lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ lldb_private::ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
lldb_private::TypeMap &types) {
@@ -1450,7 +1450,7 @@ void SymbolFilePDB::DumpClangAST(Stream &s) {
}
auto *clang_type_system =
- llvm::dyn_cast_or_null<ClangASTContext>(&type_system_or_err.get());
+ llvm::dyn_cast_or_null<TypeSystemClang>(&type_system_or_err.get());
if (!clang_type_system)
return;
clang_type_system->Dump(s);
@@ -1513,7 +1513,7 @@ void SymbolFilePDB::FindTypesByRegex(
void SymbolFilePDB::FindTypesByName(
llvm::StringRef name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ const lldb_private::CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches, lldb_private::TypeMap &types) {
std::unique_ptr<IPDBEnumSymbols> results;
if (name.empty())
@@ -1548,8 +1548,8 @@ void SymbolFilePDB::FindTypesByName(
if (!ResolveTypeUID(result->getSymIndexId()))
continue;
- if (parent_decl_ctx && GetDeclContextContainingUID(
- result->getSymIndexId()) != *parent_decl_ctx)
+ if (parent_decl_ctx.IsValid() &&
+ GetDeclContextContainingUID(result->getSymIndexId()) != parent_decl_ctx)
continue;
auto iter = m_types.find(result->getSymIndexId());
@@ -1663,17 +1663,16 @@ PDBASTParser *SymbolFilePDB::GetPDBAstParser() {
}
auto *clang_type_system =
- llvm::dyn_cast_or_null<ClangASTContext>(&type_system_or_err.get());
+ llvm::dyn_cast_or_null<TypeSystemClang>(&type_system_or_err.get());
if (!clang_type_system)
return nullptr;
return clang_type_system->GetPDBParser();
}
-
-lldb_private::CompilerDeclContext SymbolFilePDB::FindNamespace(
- lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx) {
+lldb_private::CompilerDeclContext
+SymbolFilePDB::FindNamespace(lldb_private::ConstString name,
+ const CompilerDeclContext &parent_decl_ctx) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
auto type_system_or_err =
GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus);
@@ -1685,7 +1684,7 @@ lldb_private::CompilerDeclContext SymbolFilePDB::FindNamespace(
}
auto *clang_type_system =
- llvm::dyn_cast_or_null<ClangASTContext>(&type_system_or_err.get());
+ llvm::dyn_cast_or_null<TypeSystemClang>(&type_system_or_err.get());
if (!clang_type_system)
return CompilerDeclContext();
@@ -1696,7 +1695,7 @@ lldb_private::CompilerDeclContext SymbolFilePDB::FindNamespace(
clang::DeclContext *decl_context = nullptr;
if (parent_decl_ctx)
decl_context = static_cast<clang::DeclContext *>(
- parent_decl_ctx->GetOpaqueDeclContext());
+ parent_decl_ctx.GetOpaqueDeclContext());
auto namespace_decl =
pdb->FindNamespaceDecl(decl_context, name.GetStringRef());
@@ -1817,7 +1816,7 @@ bool SymbolFilePDB::ParseCompileUnitLineTable(CompileUnit &comp_unit,
prev_source_idx, false, false, false, false, true);
line_table->InsertSequence(sequence.release());
- sequence.reset(line_table->CreateLineSequenceContainer());
+ sequence = line_table->CreateLineSequenceContainer();
}
if (ShouldAddLine(match_line, lno, length)) {
@@ -1854,7 +1853,7 @@ bool SymbolFilePDB::ParseCompileUnitLineTable(CompileUnit &comp_unit,
prev_source_idx, false, false, false, false, true);
}
- line_table->InsertSequence(sequence.release());
+ line_table->InsertSequence(sequence.get());
}
if (line_table->GetSize()) {
@@ -1940,18 +1939,17 @@ SymbolFilePDB::GetMangledForPDBFunc(const llvm::pdb::PDBSymbolFunc &pdb_func) {
mangled.SetMangledName(ConstString(func_decorated_name));
// For MSVC, format of C funciton's decorated name depends on calling
- // conventon. Unfortunately none of the format is recognized by current
+ // convention. Unfortunately none of the format is recognized by current
// LLDB. For example, `_purecall` is a __cdecl C function. From PDB,
// `__purecall` is retrieved as both its decorated and undecorated name
// (using PDBSymbolFunc::getUndecoratedName method). However `__purecall`
// string is not treated as mangled in LLDB (neither `?` nor `_Z` prefix).
// Mangled::GetDemangledName method will fail internally and caches an
- // empty string as its undecorated name. So we will face a contradition
+ // empty string as its undecorated name. So we will face a contradiction
// here for the same symbol:
// non-empty undecorated name from PDB
// empty undecorated name from LLDB
- if (!func_undecorated_name.empty() &&
- mangled.GetDemangledName(mangled.GuessLanguage()).IsEmpty())
+ if (!func_undecorated_name.empty() && mangled.GetDemangledName().IsEmpty())
mangled.SetDemangledName(ConstString(func_undecorated_name));
// LLDB uses several flags to control how a C++ decorated name is
@@ -1960,8 +1958,7 @@ SymbolFilePDB::GetMangledForPDBFunc(const llvm::pdb::PDBSymbolFunc &pdb_func) {
// PDB source unless we also apply same flags in getting undecorated
// name through PDBSymbolFunc::getUndecoratedNameEx method.
if (!func_undecorated_name.empty() &&
- mangled.GetDemangledName(mangled.GuessLanguage()) !=
- ConstString(func_undecorated_name))
+ mangled.GetDemangledName() != ConstString(func_undecorated_name))
mangled.SetDemangledName(ConstString(func_undecorated_name));
} else if (!func_undecorated_name.empty()) {
mangled.SetDemangledName(ConstString(func_undecorated_name));
@@ -1972,11 +1969,11 @@ SymbolFilePDB::GetMangledForPDBFunc(const llvm::pdb::PDBSymbolFunc &pdb_func) {
}
bool SymbolFilePDB::DeclContextMatchesThisSymbolFile(
- const lldb_private::CompilerDeclContext *decl_ctx) {
- if (decl_ctx == nullptr || !decl_ctx->IsValid())
+ const lldb_private::CompilerDeclContext &decl_ctx) {
+ if (!decl_ctx.IsValid())
return true;
- TypeSystem *decl_ctx_type_system = decl_ctx->GetTypeSystem();
+ TypeSystem *decl_ctx_type_system = decl_ctx.GetTypeSystem();
if (!decl_ctx_type_system)
return false;
auto type_system_or_err = GetTypeSystemForLanguage(
diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
index 7a4eee48771a..928cbffc5f63 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Plugins_SymbolFile_PDB_SymbolFilePDB_h_
-#define lldb_Plugins_SymbolFile_PDB_SymbolFilePDB_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_SYMBOLFILEPDB_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_SYMBOLFILEPDB_H
#include "lldb/Core/UniqueCStringMap.h"
#include "lldb/Symbol/SymbolFile.h"
@@ -112,7 +112,7 @@ public:
void
FindGlobalVariables(lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ const lldb_private::CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
lldb_private::VariableList &variables) override;
@@ -121,7 +121,7 @@ public:
lldb_private::VariableList &variables) override;
void FindFunctions(lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ const lldb_private::CompilerDeclContext &parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines,
lldb_private::SymbolContextList &sc_list) override;
@@ -138,7 +138,7 @@ public:
void
FindTypes(lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ const lldb_private::CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
lldb_private::TypeMap &types) override;
@@ -160,7 +160,7 @@ public:
lldb_private::CompilerDeclContext FindNamespace(
lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx) override;
+ const lldb_private::CompilerDeclContext &parent_decl_ctx) override;
lldb_private::ConstString GetPluginName() override;
@@ -195,7 +195,7 @@ private:
llvm::DenseMap<uint32_t, uint32_t> &index_map) const;
void FindTypesByName(llvm::StringRef name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ const lldb_private::CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches, lldb_private::TypeMap &types);
std::string GetMangledForPDBData(const llvm::pdb::PDBSymbolData &pdb_data);
@@ -242,7 +242,7 @@ private:
void CacheFunctionNames();
bool DeclContextMatchesThisSymbolFile(
- const lldb_private::CompilerDeclContext *decl_ctx);
+ const lldb_private::CompilerDeclContext &decl_ctx);
uint32_t GetCompilandId(const llvm::pdb::PDBSymbolData &data);
@@ -262,4 +262,4 @@ private:
lldb_private::UniqueCStringMap<uint32_t> m_func_method_names;
};
-#endif // lldb_Plugins_SymbolFile_PDB_SymbolFilePDB_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_SYMBOLFILEPDB_H
diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
index 305efea1afab..c4a0e609aa22 100644
--- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
+++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
@@ -1,4 +1,4 @@
-//===-- SymbolFileSymtab.cpp ------------------------------------*- C++ -*-===//
+//===-- SymbolFileSymtab.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -25,6 +25,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(SymbolFileSymtab)
+
char SymbolFileSymtab::ID;
void SymbolFileSymtab::Initialize() {
diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
index 1fff8188433e..9557ebbcb272 100644
--- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
+++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_SymbolFileSymtab_h_
-#define liblldb_SymbolFileSymtab_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_SYMTAB_SYMBOLFILESYMTAB_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_SYMTAB_SYMBOLFILESYMTAB_H
#include <map>
#include <vector>
@@ -106,7 +106,8 @@ protected:
TypeMap m_objc_class_types;
private:
- DISALLOW_COPY_AND_ASSIGN(SymbolFileSymtab);
+ SymbolFileSymtab(const SymbolFileSymtab &) = delete;
+ const SymbolFileSymtab &operator=(const SymbolFileSymtab &) = delete;
};
-#endif // liblldb_SymbolFileSymtab_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_SYMTAB_SYMBOLFILESYMTAB_H
diff --git a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
index d4d7a8937c12..2e6fd4365021 100644
--- a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
+++ b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
@@ -1,4 +1,4 @@
-//===-- SymbolVendorELF.cpp ----------------------------------*- C++ -*-===//
+//===-- SymbolVendorELF.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -25,6 +25,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(SymbolVendorELF)
+
// SymbolVendorELF constructor
SymbolVendorELF::SymbolVendorELF(const lldb::ModuleSP &module_sp)
: SymbolVendor(module_sp) {}
diff --git a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h
index 0cd740da5ce3..824906c04955 100644
--- a/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h
+++ b/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_SymbolVendorELF_h_
-#define liblldb_SymbolVendorELF_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLVENDOR_ELF_SYMBOLVENDORELF_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLVENDOR_ELF_SYMBOLVENDORELF_H
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/lldb-private.h"
@@ -38,7 +38,8 @@ public:
uint32_t GetPluginVersion() override;
private:
- DISALLOW_COPY_AND_ASSIGN(SymbolVendorELF);
+ SymbolVendorELF(const SymbolVendorELF &) = delete;
+ const SymbolVendorELF &operator=(const SymbolVendorELF &) = delete;
};
-#endif // liblldb_SymbolVendorELF_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLVENDOR_ELF_SYMBOLVENDORELF_H
diff --git a/lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.cpp b/lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.cpp
new file mode 100644
index 000000000000..1c09dabc5622
--- /dev/null
+++ b/lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.cpp
@@ -0,0 +1,147 @@
+//===-- SymbolVendorWasm.cpp ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "SymbolVendorWasm.h"
+
+#include <string.h>
+
+#include "Plugins/ObjectFile/wasm/ObjectFileWasm.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Section.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Symbol/LocateSymbolFile.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/Timer.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::wasm;
+
+LLDB_PLUGIN_DEFINE(SymbolVendorWasm)
+
+// SymbolVendorWasm constructor
+SymbolVendorWasm::SymbolVendorWasm(const lldb::ModuleSP &module_sp)
+ : SymbolVendor(module_sp) {}
+
+void SymbolVendorWasm::Initialize() {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(),
+ GetPluginDescriptionStatic(), CreateInstance);
+}
+
+void SymbolVendorWasm::Terminate() {
+ PluginManager::UnregisterPlugin(CreateInstance);
+}
+
+lldb_private::ConstString SymbolVendorWasm::GetPluginNameStatic() {
+ static ConstString g_name("WASM");
+ return g_name;
+}
+
+const char *SymbolVendorWasm::GetPluginDescriptionStatic() {
+ return "Symbol vendor for WASM that looks for dwo files that match "
+ "executables.";
+}
+
+// CreateInstance
+//
+// Platforms can register a callback to use when creating symbol vendors to
+// allow for complex debug information file setups, and to also allow for
+// finding separate debug information files.
+SymbolVendor *
+SymbolVendorWasm::CreateInstance(const lldb::ModuleSP &module_sp,
+ lldb_private::Stream *feedback_strm) {
+ if (!module_sp)
+ return nullptr;
+
+ ObjectFileWasm *obj_file =
+ llvm::dyn_cast_or_null<ObjectFileWasm>(module_sp->GetObjectFile());
+ if (!obj_file)
+ return nullptr;
+
+ // If the main object file already contains debug info, then we are done.
+ if (obj_file->GetSectionList()->FindSectionByType(
+ lldb::eSectionTypeDWARFDebugInfo, true))
+ return nullptr;
+
+ static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
+ Timer scoped_timer(func_cat, "SymbolVendorWasm::CreateInstance (module = %s)",
+ module_sp->GetFileSpec().GetPath().c_str());
+
+ ModuleSpec module_spec;
+ module_spec.GetFileSpec() = obj_file->GetFileSpec();
+ FileSystem::Instance().Resolve(module_spec.GetFileSpec());
+ module_spec.GetUUID() = obj_file->GetUUID();
+
+ // A Wasm module may have a custom section named "external_debug_info" whose
+ // content is the absolute or relative path of the Wasm module that contains
+ // debug symbols for this module.
+ llvm::Optional<FileSpec> symbol_file_spec =
+ obj_file->GetExternalDebugInfoFileSpec();
+ if (!symbol_file_spec)
+ return nullptr;
+ module_spec.GetSymbolFileSpec() = *symbol_file_spec;
+
+ FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
+ FileSpec sym_fspec =
+ Symbols::LocateExecutableSymbolFile(module_spec, search_paths);
+ if (!sym_fspec)
+ return nullptr;
+
+ DataBufferSP sym_file_data_sp;
+ lldb::offset_t sym_file_data_offset = 0;
+ ObjectFileSP sym_objfile_sp = ObjectFile::FindPlugin(
+ module_sp, &sym_fspec, 0, FileSystem::Instance().GetByteSize(sym_fspec),
+ sym_file_data_sp, sym_file_data_offset);
+ if (!sym_objfile_sp)
+ return nullptr;
+
+ // This objfile is for debugging purposes.
+ sym_objfile_sp->SetType(ObjectFile::eTypeDebugInfo);
+
+ SymbolVendorWasm *symbol_vendor = new SymbolVendorWasm(module_sp);
+
+ // Get the module unified section list and add our debug sections to
+ // that.
+ SectionList *module_section_list = module_sp->GetSectionList();
+ SectionList *objfile_section_list = sym_objfile_sp->GetSectionList();
+
+ static const SectionType g_sections[] = {
+ eSectionTypeDWARFDebugAbbrev, eSectionTypeDWARFDebugAddr,
+ eSectionTypeDWARFDebugAranges, eSectionTypeDWARFDebugCuIndex,
+ eSectionTypeDWARFDebugFrame, eSectionTypeDWARFDebugInfo,
+ eSectionTypeDWARFDebugLine, eSectionTypeDWARFDebugLineStr,
+ eSectionTypeDWARFDebugLoc, eSectionTypeDWARFDebugLocLists,
+ eSectionTypeDWARFDebugMacInfo, eSectionTypeDWARFDebugMacro,
+ eSectionTypeDWARFDebugPubNames, eSectionTypeDWARFDebugPubTypes,
+ eSectionTypeDWARFDebugRanges, eSectionTypeDWARFDebugRngLists,
+ eSectionTypeDWARFDebugStr, eSectionTypeDWARFDebugStrOffsets,
+ eSectionTypeDWARFDebugTypes};
+ for (SectionType section_type : g_sections) {
+ if (SectionSP section_sp =
+ objfile_section_list->FindSectionByType(section_type, true)) {
+ if (SectionSP module_section_sp =
+ module_section_list->FindSectionByType(section_type, true))
+ module_section_list->ReplaceSection(module_section_sp->GetID(),
+ section_sp);
+ else
+ module_section_list->AddSection(section_sp);
+ }
+ }
+
+ symbol_vendor->AddSymbolFileRepresentation(sym_objfile_sp);
+ return symbol_vendor;
+}
+
+// PluginInterface protocol
+ConstString SymbolVendorWasm::GetPluginName() { return GetPluginNameStatic(); }
+
+uint32_t SymbolVendorWasm::GetPluginVersion() { return 1; }
diff --git a/lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.h b/lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.h
new file mode 100644
index 000000000000..96e737b1be96
--- /dev/null
+++ b/lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.h
@@ -0,0 +1,45 @@
+//===-- SymbolVendorWasm.h --------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLVENDOR_WASM_SYMBOLVENDORWASM_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLVENDOR_WASM_SYMBOLVENDORWASM_H
+
+#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/lldb-private.h"
+
+namespace lldb_private {
+namespace wasm {
+
+class SymbolVendorWasm : public lldb_private::SymbolVendor {
+public:
+ SymbolVendorWasm(const lldb::ModuleSP &module_sp);
+
+ static void Initialize();
+ static void Terminate();
+ static lldb_private::ConstString GetPluginNameStatic();
+ static const char *GetPluginDescriptionStatic();
+
+ static lldb_private::SymbolVendor *
+ CreateInstance(const lldb::ModuleSP &module_sp,
+ lldb_private::Stream *feedback_strm);
+
+ /// PluginInterface protocol.
+ /// \{
+ lldb_private::ConstString GetPluginName() override;
+ uint32_t GetPluginVersion() override;
+ /// \}
+
+private:
+ SymbolVendorWasm(const SymbolVendorWasm &) = delete;
+ const SymbolVendorWasm &operator=(const SymbolVendorWasm &) = delete;
+};
+
+} // namespace wasm
+} // namespace lldb_private
+
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLVENDOR_WASM_SYMBOLVENDORWASM_H
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index ac3bce179d9e..bc06ea8164d4 100644
--- a/lldb/source/Symbol/ClangASTContext.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -1,4 +1,4 @@
-//===-- ClangASTContext.cpp -------------------------------------*- C++ -*-===//
+//===-- TypeSystemClang.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Symbol/ClangASTContext.h"
+#include "TypeSystemClang.h"
#include "llvm/Support/FormatAdapters.h"
#include "llvm/Support/FormatVariadic.h"
@@ -34,14 +34,21 @@
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/TargetOptions.h"
#include "clang/Frontend/FrontendOptions.h"
+#include "clang/Lex/HeaderSearch.h"
+#include "clang/Lex/HeaderSearchOptions.h"
+#include "clang/Lex/ModuleMap.h"
#include "clang/Sema/Sema.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/Threading.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h"
+#include "Plugins/ExpressionParser/Clang/ClangExternalASTSourceCallbacks.h"
#include "Plugins/ExpressionParser/Clang/ClangFunctionCaller.h"
#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
#include "Plugins/ExpressionParser/Clang/ClangUserExpression.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
#include "Plugins/ExpressionParser/Clang/ClangUtilityFunction.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/Flags.h"
@@ -52,10 +59,6 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/ThreadSafeDenseMap.h"
#include "lldb/Core/UniqueCStringMap.h"
-#include "lldb/Symbol/ClangASTImporter.h"
-#include "lldb/Symbol/ClangASTMetadata.h"
-#include "lldb/Symbol/ClangExternalASTSourceCallbacks.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Target/ExecutionContext.h"
@@ -81,16 +84,20 @@ using namespace lldb_private;
using namespace clang;
using llvm::StringSwitch;
+LLDB_PLUGIN_DEFINE(TypeSystemClang)
+
namespace {
-#ifdef LLDB_CONFIGURATION_DEBUG
static void VerifyDecl(clang::Decl *decl) {
assert(decl && "VerifyDecl called with nullptr?");
+#ifndef NDEBUG
+ // We don't care about the actual access value here but only want to trigger
+ // that Clang calls its internal Decl::AccessDeclContextSanity check.
decl->getAccess();
-}
#endif
+}
static inline bool
-ClangASTContextSupportsLanguage(lldb::LanguageType language) {
+TypeSystemClangSupportsLanguage(lldb::LanguageType language) {
return language == eLanguageTypeUnknown || // Clang is the default type system
lldb_private::Language::LanguageIsC(language) ||
lldb_private::Language::LanguageIsCPlusPlus(language) ||
@@ -238,7 +245,7 @@ static lldb::addr_t GetVTableAddress(Process &process,
if (err.Fail() || vbtable_ptr_offset + data.GetAddressByteSize() > size)
return LLDB_INVALID_ADDRESS;
- return data.GetPointer(&vbtable_ptr_offset);
+ return data.GetAddress(&vbtable_ptr_offset);
}
static int64_t ReadVBaseOffsetFromVTable(Process &process,
@@ -300,7 +307,7 @@ static bool GetVBaseBitOffset(VTableContextBase &vtable_ctx,
return true;
}
-typedef lldb_private::ThreadSafeDenseMap<clang::ASTContext *, ClangASTContext *>
+typedef lldb_private::ThreadSafeDenseMap<clang::ASTContext *, TypeSystemClang *>
ClangASTMap;
static ClangASTMap &GetASTMap() {
@@ -312,9 +319,43 @@ static ClangASTMap &GetASTMap() {
return *g_map_ptr;
}
-char ClangASTContext::ID;
+TypePayloadClang::TypePayloadClang(OptionalClangModuleID owning_module,
+ bool is_complete_objc_class)
+ : m_payload(owning_module.GetValue()) {
+ SetIsCompleteObjCClass(is_complete_objc_class);
+}
+
+void TypePayloadClang::SetOwningModule(OptionalClangModuleID id) {
+ assert(id.GetValue() < ObjCClassBit);
+ bool is_complete = IsCompleteObjCClass();
+ m_payload = id.GetValue();
+ SetIsCompleteObjCClass(is_complete);
+}
+
+static void SetMemberOwningModule(clang::Decl *member,
+ const clang::Decl *parent) {
+ if (!member || !parent)
+ return;
+
+ OptionalClangModuleID id(parent->getOwningModuleID());
+ if (!id.HasValue())
+ return;
+
+ member->setFromASTFile();
+ member->setOwningModuleID(id.GetValue());
+ member->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible);
+ if (llvm::isa<clang::NamedDecl>(member))
+ if (auto *dc = llvm::dyn_cast<clang::DeclContext>(parent)) {
+ dc->setHasExternalVisibleStorage(true);
+ // This triggers ExternalASTSource::FindExternalVisibleDeclsByName() to be
+ // called when searching for members.
+ dc->setHasExternalLexicalStorage(true);
+ }
+}
+
+char TypeSystemClang::ID;
-bool ClangASTContext::IsOperator(llvm::StringRef name,
+bool TypeSystemClang::IsOperator(llvm::StringRef name,
clang::OverloadedOperatorKind &op_kind) {
// All operators have to start with "operator".
if (!name.consume_front("operator"))
@@ -395,7 +436,7 @@ bool ClangASTContext::IsOperator(llvm::StringRef name,
}
clang::AccessSpecifier
-ClangASTContext::ConvertAccessTypeToAccessSpecifier(AccessType access) {
+TypeSystemClang::ConvertAccessTypeToAccessSpecifier(AccessType access) {
switch (access) {
default:
break;
@@ -497,17 +538,25 @@ static void ParseLangArgs(LangOptions &Opts, InputKind IK, const char *triple) {
//
// FIXME: This is affected by other options (-fno-inline).
Opts.NoInlineDefine = !Opt;
+
+ // This is needed to allocate the extra space for the owning module
+ // on each decl.
+ Opts.ModulesLocalVisibility = 1;
}
-ClangASTContext::ClangASTContext(llvm::Triple target_triple) {
+TypeSystemClang::TypeSystemClang(llvm::StringRef name,
+ llvm::Triple target_triple) {
+ m_display_name = name.str();
if (!target_triple.str().empty())
SetTargetTriple(target_triple.str());
// The caller didn't pass an ASTContext so create a new one for this
- // ClangASTContext.
+ // TypeSystemClang.
CreateASTContext();
}
-ClangASTContext::ClangASTContext(ASTContext &existing_ctxt) {
+TypeSystemClang::TypeSystemClang(llvm::StringRef name,
+ ASTContext &existing_ctxt) {
+ m_display_name = name.str();
SetTargetTriple(existing_ctxt.getTargetInfo().getTriple().str());
m_ast_up.reset(&existing_ctxt);
@@ -515,22 +564,22 @@ ClangASTContext::ClangASTContext(ASTContext &existing_ctxt) {
}
// Destructor
-ClangASTContext::~ClangASTContext() { Finalize(); }
+TypeSystemClang::~TypeSystemClang() { Finalize(); }
-ConstString ClangASTContext::GetPluginNameStatic() {
+ConstString TypeSystemClang::GetPluginNameStatic() {
return ConstString("clang");
}
-ConstString ClangASTContext::GetPluginName() {
- return ClangASTContext::GetPluginNameStatic();
+ConstString TypeSystemClang::GetPluginName() {
+ return TypeSystemClang::GetPluginNameStatic();
}
-uint32_t ClangASTContext::GetPluginVersion() { return 1; }
+uint32_t TypeSystemClang::GetPluginVersion() { return 1; }
-lldb::TypeSystemSP ClangASTContext::CreateInstance(lldb::LanguageType language,
+lldb::TypeSystemSP TypeSystemClang::CreateInstance(lldb::LanguageType language,
lldb_private::Module *module,
Target *target) {
- if (!ClangASTContextSupportsLanguage(language))
+ if (!TypeSystemClangSupportsLanguage(language))
return lldb::TypeSystemSP();
ArchSpec arch;
if (module)
@@ -556,14 +605,16 @@ lldb::TypeSystemSP ClangASTContext::CreateInstance(lldb::LanguageType language,
}
}
- if (module)
- return std::make_shared<ClangASTContext>(triple);
- else if (target && target->IsValid())
- return std::make_shared<ClangASTContextForExpressions>(*target, triple);
+ if (module) {
+ std::string ast_name =
+ "ASTContext for '" + module->GetFileSpec().GetPath() + "'";
+ return std::make_shared<TypeSystemClang>(ast_name, triple);
+ } else if (target && target->IsValid())
+ return std::make_shared<TypeSystemClangForExpressions>(*target, triple);
return lldb::TypeSystemSP();
}
-LanguageSet ClangASTContext::GetSupportedLanguagesForTypes() {
+LanguageSet TypeSystemClang::GetSupportedLanguagesForTypes() {
LanguageSet languages;
languages.Insert(lldb::eLanguageTypeC89);
languages.Insert(lldb::eLanguageTypeC);
@@ -579,7 +630,7 @@ LanguageSet ClangASTContext::GetSupportedLanguagesForTypes() {
return languages;
}
-LanguageSet ClangASTContext::GetSupportedLanguagesForExpressions() {
+LanguageSet TypeSystemClang::GetSupportedLanguagesForExpressions() {
LanguageSet languages;
languages.Insert(lldb::eLanguageTypeC_plus_plus);
languages.Insert(lldb::eLanguageTypeObjC_plus_plus);
@@ -589,17 +640,17 @@ LanguageSet ClangASTContext::GetSupportedLanguagesForExpressions() {
return languages;
}
-void ClangASTContext::Initialize() {
+void TypeSystemClang::Initialize() {
PluginManager::RegisterPlugin(
GetPluginNameStatic(), "clang base AST context plug-in", CreateInstance,
GetSupportedLanguagesForTypes(), GetSupportedLanguagesForExpressions());
}
-void ClangASTContext::Terminate() {
+void TypeSystemClang::Terminate() {
PluginManager::UnregisterPlugin(CreateInstance);
}
-void ClangASTContext::Finalize() {
+void TypeSystemClang::Finalize() {
assert(m_ast_up);
GetASTMap().Erase(m_ast_up.get());
if (!m_ast_owned)
@@ -615,28 +666,28 @@ void ClangASTContext::Finalize() {
m_language_options_up.reset();
}
-void ClangASTContext::setSema(Sema *s) {
+void TypeSystemClang::setSema(Sema *s) {
// Ensure that the new sema actually belongs to our ASTContext.
assert(s == nullptr || &s->getASTContext() == m_ast_up.get());
m_sema = s;
}
-const char *ClangASTContext::GetTargetTriple() {
+const char *TypeSystemClang::GetTargetTriple() {
return m_target_triple.c_str();
}
-void ClangASTContext::SetTargetTriple(llvm::StringRef target_triple) {
+void TypeSystemClang::SetTargetTriple(llvm::StringRef target_triple) {
m_target_triple = target_triple.str();
}
-void ClangASTContext::SetExternalSource(
+void TypeSystemClang::SetExternalSource(
llvm::IntrusiveRefCntPtr<ExternalASTSource> &ast_source_up) {
ASTContext &ast = getASTContext();
ast.setExternalSource(ast_source_up);
ast.getTranslationUnitDecl()->setHasExternalLexicalStorage(true);
}
-ASTContext &ClangASTContext::getASTContext() {
+ASTContext &TypeSystemClang::getASTContext() {
assert(m_ast_up);
return *m_ast_up;
}
@@ -665,35 +716,35 @@ private:
Log *m_log;
};
-void ClangASTContext::CreateASTContext() {
+void TypeSystemClang::CreateASTContext() {
assert(!m_ast_up);
m_ast_owned = true;
- m_language_options_up.reset(new LangOptions());
+ m_language_options_up = std::make_unique<LangOptions>();
ParseLangArgs(*m_language_options_up, clang::Language::ObjCXX,
GetTargetTriple());
- m_identifier_table_up.reset(
- new IdentifierTable(*m_language_options_up, nullptr));
- m_builtins_up.reset(new Builtin::Context());
+ m_identifier_table_up =
+ std::make_unique<IdentifierTable>(*m_language_options_up, nullptr);
+ m_builtins_up = std::make_unique<Builtin::Context>();
- m_selector_table_up.reset(new SelectorTable());
+ m_selector_table_up = std::make_unique<SelectorTable>();
clang::FileSystemOptions file_system_options;
- m_file_manager_up.reset(new clang::FileManager(
- file_system_options, FileSystem::Instance().GetVirtualFileSystem()));
+ m_file_manager_up = std::make_unique<clang::FileManager>(
+ file_system_options, FileSystem::Instance().GetVirtualFileSystem());
llvm::IntrusiveRefCntPtr<DiagnosticIDs> diag_id_sp(new DiagnosticIDs());
- m_diagnostics_engine_up.reset(
- new DiagnosticsEngine(diag_id_sp, new DiagnosticOptions()));
+ m_diagnostics_engine_up =
+ std::make_unique<DiagnosticsEngine>(diag_id_sp, new DiagnosticOptions());
- m_source_manager_up.reset(
- new clang::SourceManager(*m_diagnostics_engine_up, *m_file_manager_up));
- m_ast_up.reset(new ASTContext(*m_language_options_up, *m_source_manager_up,
- *m_identifier_table_up, *m_selector_table_up,
- *m_builtins_up));
+ m_source_manager_up = std::make_unique<clang::SourceManager>(
+ *m_diagnostics_engine_up, *m_file_manager_up);
+ m_ast_up = std::make_unique<ASTContext>(
+ *m_language_options_up, *m_source_manager_up, *m_identifier_table_up,
+ *m_selector_table_up, *m_builtins_up);
- m_diagnostic_consumer_up.reset(new NullDiagnosticConsumer);
+ m_diagnostic_consumer_up = std::make_unique<NullDiagnosticConsumer>();
m_ast_up->getDiagnostics().setClient(m_diagnostic_consumer_up.get(), false);
// This can be NULL if we don't know anything about the architecture or if
@@ -710,18 +761,18 @@ void ClangASTContext::CreateASTContext() {
SetExternalSource(ast_source_up);
}
-ClangASTContext *ClangASTContext::GetASTContext(clang::ASTContext *ast) {
- ClangASTContext *clang_ast = GetASTMap().Lookup(ast);
+TypeSystemClang *TypeSystemClang::GetASTContext(clang::ASTContext *ast) {
+ TypeSystemClang *clang_ast = GetASTMap().Lookup(ast);
return clang_ast;
}
-clang::MangleContext *ClangASTContext::getMangleContext() {
+clang::MangleContext *TypeSystemClang::getMangleContext() {
if (m_mangle_ctx_up == nullptr)
m_mangle_ctx_up.reset(getASTContext().createMangleContext());
return m_mangle_ctx_up.get();
}
-std::shared_ptr<clang::TargetOptions> &ClangASTContext::getTargetOptions() {
+std::shared_ptr<clang::TargetOptions> &TypeSystemClang::getTargetOptions() {
if (m_target_options_rp == nullptr && !m_target_triple.empty()) {
m_target_options_rp = std::make_shared<clang::TargetOptions>();
if (m_target_options_rp != nullptr)
@@ -730,7 +781,7 @@ std::shared_ptr<clang::TargetOptions> &ClangASTContext::getTargetOptions() {
return m_target_options_rp;
}
-TargetInfo *ClangASTContext::getTargetInfo() {
+TargetInfo *TypeSystemClang::getTargetInfo() {
// target_triple should be something like "x86_64-apple-macosx"
if (m_target_info_up == nullptr && !m_target_triple.empty())
m_target_info_up.reset(TargetInfo::CreateTargetInfo(
@@ -747,7 +798,7 @@ static inline bool QualTypeMatchesBitSize(const uint64_t bit_size,
}
CompilerType
-ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(Encoding encoding,
+TypeSystemClang::GetBuiltinTypeForEncodingAndBitSize(Encoding encoding,
size_t bit_size) {
ASTContext &ast = getASTContext();
switch (encoding) {
@@ -808,7 +859,7 @@ ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(Encoding encoding,
}
lldb::BasicType
-ClangASTContext::GetBasicTypeEnumeration(ConstString name) {
+TypeSystemClang::GetBasicTypeEnumeration(ConstString name) {
if (name) {
typedef UniqueCStringMap<lldb::BasicType> TypeNameToBasicTypeMap;
static TypeNameToBasicTypeMap g_type_map;
@@ -873,7 +924,7 @@ ClangASTContext::GetBasicTypeEnumeration(ConstString name) {
return eBasicTypeInvalid;
}
-uint32_t ClangASTContext::GetPointerByteSize() {
+uint32_t TypeSystemClang::GetPointerByteSize() {
if (m_pointer_byte_size == 0)
if (auto size = GetBasicType(lldb::eBasicTypeVoid)
.GetPointerType()
@@ -882,7 +933,7 @@ uint32_t ClangASTContext::GetPointerByteSize() {
return m_pointer_byte_size;
}
-CompilerType ClangASTContext::GetBasicType(lldb::BasicType basic_type) {
+CompilerType TypeSystemClang::GetBasicType(lldb::BasicType basic_type) {
clang::ASTContext &ast = getASTContext();
lldb::opaque_compiler_type_t clang_type =
@@ -893,7 +944,7 @@ CompilerType ClangASTContext::GetBasicType(lldb::BasicType basic_type) {
return CompilerType();
}
-CompilerType ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize(
+CompilerType TypeSystemClang::GetBuiltinTypeForDWARFEncodingAndBitSize(
llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size) {
ASTContext &ast = getASTContext();
@@ -1079,13 +1130,22 @@ CompilerType ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize(
break;
case DW_ATE_UTF:
- if (!type_name.empty()) {
- if (type_name == "char16_t")
- return GetType(ast.Char16Ty);
- if (type_name == "char32_t")
- return GetType(ast.Char32Ty);
- if (type_name == "char8_t")
- return GetType(ast.Char8Ty);
+ switch (bit_size) {
+ case 8:
+ return GetType(ast.Char8Ty);
+ case 16:
+ return GetType(ast.Char16Ty);
+ case 32:
+ return GetType(ast.Char32Ty);
+ default:
+ if (!type_name.empty()) {
+ if (type_name == "char16_t")
+ return GetType(ast.Char16Ty);
+ if (type_name == "char32_t")
+ return GetType(ast.Char32Ty);
+ if (type_name == "char8_t")
+ return GetType(ast.Char8Ty);
+ }
}
break;
}
@@ -1106,7 +1166,7 @@ CompilerType ClangASTContext::GetBuiltinTypeForDWARFEncodingAndBitSize(
return CompilerType();
}
-CompilerType ClangASTContext::GetCStringType(bool is_const) {
+CompilerType TypeSystemClang::GetCStringType(bool is_const) {
ASTContext &ast = getASTContext();
QualType char_type(ast.CharTy);
@@ -1116,10 +1176,10 @@ CompilerType ClangASTContext::GetCStringType(bool is_const) {
return GetType(ast.getPointerType(char_type));
}
-bool ClangASTContext::AreTypesSame(CompilerType type1, CompilerType type2,
+bool TypeSystemClang::AreTypesSame(CompilerType type1, CompilerType type2,
bool ignore_qualifiers) {
- ClangASTContext *ast =
- llvm::dyn_cast_or_null<ClangASTContext>(type1.GetTypeSystem());
+ TypeSystemClang *ast =
+ llvm::dyn_cast_or_null<TypeSystemClang>(type1.GetTypeSystem());
if (!ast || ast != type2.GetTypeSystem())
return false;
@@ -1137,7 +1197,7 @@ bool ClangASTContext::AreTypesSame(CompilerType type1, CompilerType type2,
return ast->getASTContext().hasSameType(type1_qual, type2_qual);
}
-CompilerType ClangASTContext::GetTypeForDecl(void *opaque_decl) {
+CompilerType TypeSystemClang::GetTypeForDecl(void *opaque_decl) {
if (!opaque_decl)
return CompilerType();
@@ -1147,13 +1207,13 @@ CompilerType ClangASTContext::GetTypeForDecl(void *opaque_decl) {
return CompilerType();
}
-CompilerDeclContext ClangASTContext::CreateDeclContext(DeclContext *ctx) {
+CompilerDeclContext TypeSystemClang::CreateDeclContext(DeclContext *ctx) {
// Check that the DeclContext actually belongs to this ASTContext.
assert(&ctx->getParentASTContext() == &getASTContext());
return CompilerDeclContext(this, ctx);
}
-CompilerType ClangASTContext::GetTypeForDecl(clang::NamedDecl *decl) {
+CompilerType TypeSystemClang::GetTypeForDecl(clang::NamedDecl *decl) {
if (clang::ObjCInterfaceDecl *interface_decl =
llvm::dyn_cast<clang::ObjCInterfaceDecl>(decl))
return GetTypeForDecl(interface_decl);
@@ -1162,22 +1222,65 @@ CompilerType ClangASTContext::GetTypeForDecl(clang::NamedDecl *decl) {
return CompilerType();
}
-CompilerType ClangASTContext::GetTypeForDecl(TagDecl *decl) {
+CompilerType TypeSystemClang::GetTypeForDecl(TagDecl *decl) {
return GetType(getASTContext().getTagDeclType(decl));
}
-CompilerType ClangASTContext::GetTypeForDecl(ObjCInterfaceDecl *decl) {
+CompilerType TypeSystemClang::GetTypeForDecl(ObjCInterfaceDecl *decl) {
return GetType(getASTContext().getObjCInterfaceType(decl));
}
#pragma mark Structure, Unions, Classes
-CompilerType ClangASTContext::CreateRecordType(DeclContext *decl_ctx,
- AccessType access_type,
- llvm::StringRef name, int kind,
- LanguageType language,
- ClangASTMetadata *metadata,
- bool exports_symbols) {
+void TypeSystemClang::SetOwningModule(clang::Decl *decl,
+ OptionalClangModuleID owning_module) {
+ if (!decl || !owning_module.HasValue())
+ return;
+
+ decl->setFromASTFile();
+ decl->setOwningModuleID(owning_module.GetValue());
+ decl->setModuleOwnershipKind(clang::Decl::ModuleOwnershipKind::Visible);
+}
+
+OptionalClangModuleID
+TypeSystemClang::GetOrCreateClangModule(llvm::StringRef name,
+ OptionalClangModuleID parent,
+ bool is_framework, bool is_explicit) {
+ // Get the external AST source which holds the modules.
+ auto *ast_source = llvm::dyn_cast_or_null<ClangExternalASTSourceCallbacks>(
+ getASTContext().getExternalSource());
+ assert(ast_source && "external ast source was lost");
+ if (!ast_source)
+ return {};
+
+ // Lazily initialize the module map.
+ if (!m_header_search_up) {
+ auto HSOpts = std::make_shared<clang::HeaderSearchOptions>();
+ m_header_search_up = std::make_unique<clang::HeaderSearch>(
+ HSOpts, *m_source_manager_up, *m_diagnostics_engine_up,
+ *m_language_options_up, m_target_info_up.get());
+ m_module_map_up = std::make_unique<clang::ModuleMap>(
+ *m_source_manager_up, *m_diagnostics_engine_up, *m_language_options_up,
+ m_target_info_up.get(), *m_header_search_up);
+ }
+
+ // Get or create the module context.
+ bool created;
+ clang::Module *module;
+ auto parent_desc = ast_source->getSourceDescriptor(parent.GetValue());
+ std::tie(module, created) = m_module_map_up->findOrCreateModule(
+ name, parent_desc ? parent_desc->getModuleOrNull() : nullptr,
+ is_framework, is_explicit);
+ if (!created)
+ return ast_source->GetIDForModule(module);
+
+ return ast_source->RegisterModule(module);
+}
+
+CompilerType TypeSystemClang::CreateRecordType(
+ clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
+ AccessType access_type, llvm::StringRef name, int kind,
+ LanguageType language, ClangASTMetadata *metadata, bool exports_symbols) {
ASTContext &ast = getASTContext();
if (decl_ctx == nullptr)
@@ -1187,7 +1290,8 @@ CompilerType ClangASTContext::CreateRecordType(DeclContext *decl_ctx,
language == eLanguageTypeObjC_plus_plus) {
bool isForwardDecl = true;
bool isInternal = false;
- return CreateObjCClass(name, decl_ctx, isForwardDecl, isInternal, metadata);
+ return CreateObjCClass(name, decl_ctx, owning_module, isForwardDecl,
+ isInternal, metadata);
}
// NOTE: Eventually CXXRecordDecl will be merged back into RecordDecl and
@@ -1197,10 +1301,12 @@ CompilerType ClangASTContext::CreateRecordType(DeclContext *decl_ctx,
// complete definition just in case.
bool has_name = !name.empty();
-
- CXXRecordDecl *decl = CXXRecordDecl::Create(
- ast, (TagDecl::TagKind)kind, decl_ctx, SourceLocation(), SourceLocation(),
- has_name ? &ast.Idents.get(name) : nullptr);
+ CXXRecordDecl *decl = CXXRecordDecl::CreateDeserialized(ast, 0);
+ decl->setTagKind(static_cast<TagDecl::TagKind>(kind));
+ decl->setDeclContext(decl_ctx);
+ if (has_name)
+ decl->setDeclName(&ast.Idents.get(name));
+ SetOwningModule(decl, owning_module);
if (!has_name) {
// In C++ a lambda is also represented as an unnamed class. This is
@@ -1253,76 +1359,81 @@ namespace {
}
static TemplateParameterList *CreateTemplateParameterList(
- ASTContext *ast,
- const ClangASTContext::TemplateParameterInfos &template_param_infos,
+ ASTContext &ast,
+ const TypeSystemClang::TemplateParameterInfos &template_param_infos,
llvm::SmallVector<NamedDecl *, 8> &template_param_decls) {
const bool parameter_pack = false;
const bool is_typename = false;
const unsigned depth = 0;
const size_t num_template_params = template_param_infos.args.size();
DeclContext *const decl_context =
- ast->getTranslationUnitDecl(); // Is this the right decl context?,
+ ast.getTranslationUnitDecl(); // Is this the right decl context?,
for (size_t i = 0; i < num_template_params; ++i) {
const char *name = template_param_infos.names[i];
IdentifierInfo *identifier_info = nullptr;
if (name && name[0])
- identifier_info = &ast->Idents.get(name);
+ identifier_info = &ast.Idents.get(name);
if (IsValueParam(template_param_infos.args[i])) {
+ QualType template_param_type =
+ template_param_infos.args[i].getIntegralType();
template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
- *ast, decl_context,
- SourceLocation(), SourceLocation(), depth, i, identifier_info,
- template_param_infos.args[i].getIntegralType(), parameter_pack,
- nullptr));
-
+ ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
+ identifier_info, template_param_type, parameter_pack,
+ ast.getTrivialTypeSourceInfo(template_param_type)));
} else {
template_param_decls.push_back(TemplateTypeParmDecl::Create(
- *ast, decl_context,
- SourceLocation(), SourceLocation(), depth, i, identifier_info,
- is_typename, parameter_pack));
+ ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
+ identifier_info, is_typename, parameter_pack));
}
}
if (template_param_infos.packed_args) {
IdentifierInfo *identifier_info = nullptr;
if (template_param_infos.pack_name && template_param_infos.pack_name[0])
- identifier_info = &ast->Idents.get(template_param_infos.pack_name);
+ identifier_info = &ast.Idents.get(template_param_infos.pack_name);
const bool parameter_pack_true = true;
if (!template_param_infos.packed_args->args.empty() &&
IsValueParam(template_param_infos.packed_args->args[0])) {
+ QualType template_param_type =
+ template_param_infos.packed_args->args[0].getIntegralType();
template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
- *ast, decl_context, SourceLocation(), SourceLocation(), depth,
- num_template_params, identifier_info,
- template_param_infos.packed_args->args[0].getIntegralType(),
- parameter_pack_true, nullptr));
+ ast, decl_context, SourceLocation(), SourceLocation(), depth,
+ num_template_params, identifier_info, template_param_type,
+ parameter_pack_true,
+ ast.getTrivialTypeSourceInfo(template_param_type)));
} else {
template_param_decls.push_back(TemplateTypeParmDecl::Create(
- *ast, decl_context, SourceLocation(), SourceLocation(), depth,
+ ast, decl_context, SourceLocation(), SourceLocation(), depth,
num_template_params, identifier_info, is_typename,
parameter_pack_true));
}
}
clang::Expr *const requires_clause = nullptr; // TODO: Concepts
TemplateParameterList *template_param_list = TemplateParameterList::Create(
- *ast, SourceLocation(), SourceLocation(), template_param_decls,
+ ast, SourceLocation(), SourceLocation(), template_param_decls,
SourceLocation(), requires_clause);
return template_param_list;
}
-clang::FunctionTemplateDecl *ClangASTContext::CreateFunctionTemplateDecl(
- clang::DeclContext *decl_ctx, clang::FunctionDecl *func_decl,
- const char *name, const TemplateParameterInfos &template_param_infos) {
+clang::FunctionTemplateDecl *TypeSystemClang::CreateFunctionTemplateDecl(
+ clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
+ clang::FunctionDecl *func_decl, const char *name,
+ const TemplateParameterInfos &template_param_infos) {
// /// Create a function template node.
ASTContext &ast = getASTContext();
llvm::SmallVector<NamedDecl *, 8> template_param_decls;
-
TemplateParameterList *template_param_list = CreateTemplateParameterList(
- &ast, template_param_infos, template_param_decls);
- FunctionTemplateDecl *func_tmpl_decl = FunctionTemplateDecl::Create(
- ast, decl_ctx, func_decl->getLocation(), func_decl->getDeclName(),
- template_param_list, func_decl);
+ ast, template_param_infos, template_param_decls);
+ FunctionTemplateDecl *func_tmpl_decl =
+ FunctionTemplateDecl::CreateDeserialized(ast, 0);
+ func_tmpl_decl->setDeclContext(decl_ctx);
+ func_tmpl_decl->setLocation(func_decl->getLocation());
+ func_tmpl_decl->setDeclName(func_decl->getDeclName());
+ func_tmpl_decl->init(func_decl, template_param_list);
+ SetOwningModule(func_tmpl_decl, owning_module);
for (size_t i = 0, template_param_decl_count = template_param_decls.size();
i < template_param_decl_count; ++i) {
@@ -1338,7 +1449,7 @@ clang::FunctionTemplateDecl *ClangASTContext::CreateFunctionTemplateDecl(
return func_tmpl_decl;
}
-void ClangASTContext::CreateFunctionTemplateSpecializationInfo(
+void TypeSystemClang::CreateFunctionTemplateSpecializationInfo(
FunctionDecl *func_decl, clang::FunctionTemplateDecl *func_tmpl_decl,
const TemplateParameterInfos &infos) {
TemplateArgumentList *template_args_ptr =
@@ -1348,9 +1459,10 @@ void ClangASTContext::CreateFunctionTemplateSpecializationInfo(
template_args_ptr, nullptr);
}
-ClassTemplateDecl *ClangASTContext::CreateClassTemplateDecl(
- DeclContext *decl_ctx, lldb::AccessType access_type, const char *class_name,
- int kind, const TemplateParameterInfos &template_param_infos) {
+ClassTemplateDecl *TypeSystemClang::CreateClassTemplateDecl(
+ DeclContext *decl_ctx, OptionalClangModuleID owning_module,
+ lldb::AccessType access_type, const char *class_name, int kind,
+ const TemplateParameterInfos &template_param_infos) {
ASTContext &ast = getASTContext();
ClassTemplateDecl *class_template_decl = nullptr;
@@ -1371,13 +1483,14 @@ ClassTemplateDecl *ClangASTContext::CreateClassTemplateDecl(
llvm::SmallVector<NamedDecl *, 8> template_param_decls;
TemplateParameterList *template_param_list = CreateTemplateParameterList(
- &ast, template_param_infos, template_param_decls);
+ ast, template_param_infos, template_param_decls);
- CXXRecordDecl *template_cxx_decl = CXXRecordDecl::Create(
- ast, (TagDecl::TagKind)kind,
- decl_ctx, // What decl context do we use here? TU? The actual decl
- // context?
- SourceLocation(), SourceLocation(), &identifier_info);
+ CXXRecordDecl *template_cxx_decl = CXXRecordDecl::CreateDeserialized(ast, 0);
+ template_cxx_decl->setTagKind(static_cast<TagDecl::TagKind>(kind));
+ // What decl context do we use here? TU? The actual decl context?
+ template_cxx_decl->setDeclContext(decl_ctx);
+ template_cxx_decl->setDeclName(decl_name);
+ SetOwningModule(template_cxx_decl, owning_module);
for (size_t i = 0, template_param_decl_count = template_param_decls.size();
i < template_param_decl_count; ++i) {
@@ -1389,33 +1502,29 @@ ClassTemplateDecl *ClangASTContext::CreateClassTemplateDecl(
// template_cxx_decl->startDefinition();
// template_cxx_decl->completeDefinition();
- class_template_decl = ClassTemplateDecl::Create(
- ast,
- decl_ctx, // What decl context do we use here? TU? The actual decl
- // context?
- SourceLocation(), decl_name, template_param_list, template_cxx_decl);
+ class_template_decl = ClassTemplateDecl::CreateDeserialized(ast, 0);
+ // What decl context do we use here? TU? The actual decl context?
+ class_template_decl->setDeclContext(decl_ctx);
+ class_template_decl->setDeclName(decl_name);
+ class_template_decl->init(template_cxx_decl, template_param_list);
template_cxx_decl->setDescribedClassTemplate(class_template_decl);
+ SetOwningModule(class_template_decl, owning_module);
if (class_template_decl) {
if (access_type != eAccessNone)
class_template_decl->setAccess(
ConvertAccessTypeToAccessSpecifier(access_type));
- // if (TagDecl *ctx_tag_decl = dyn_cast<TagDecl>(decl_ctx))
- // CompleteTagDeclarationDefinition(GetTypeForDecl(ctx_tag_decl));
-
decl_ctx->addDecl(class_template_decl);
-#ifdef LLDB_CONFIGURATION_DEBUG
VerifyDecl(class_template_decl);
-#endif
}
return class_template_decl;
}
TemplateTemplateParmDecl *
-ClangASTContext::CreateTemplateTemplateParmDecl(const char *template_name) {
+TypeSystemClang::CreateTemplateTemplateParmDecl(const char *template_name) {
ASTContext &ast = getASTContext();
auto *decl_ctx = ast.getTranslationUnitDecl();
@@ -1423,13 +1532,13 @@ ClangASTContext::CreateTemplateTemplateParmDecl(const char *template_name) {
IdentifierInfo &identifier_info = ast.Idents.get(template_name);
llvm::SmallVector<NamedDecl *, 8> template_param_decls;
- ClangASTContext::TemplateParameterInfos template_param_infos;
+ TypeSystemClang::TemplateParameterInfos template_param_infos;
TemplateParameterList *template_param_list = CreateTemplateParameterList(
- &ast, template_param_infos, template_param_decls);
+ ast, template_param_infos, template_param_decls);
// LLDB needs to create those decls only to be able to display a
// type that includes a template template argument. Only the name matters for
- // this purpose, so we use dummy values for the other characterisitcs of the
+ // this purpose, so we use dummy values for the other characteristics of the
// type.
return TemplateTemplateParmDecl::Create(
ast, decl_ctx, SourceLocation(),
@@ -1438,8 +1547,9 @@ ClangASTContext::CreateTemplateTemplateParmDecl(const char *template_name) {
}
ClassTemplateSpecializationDecl *
-ClangASTContext::CreateClassTemplateSpecializationDecl(
- DeclContext *decl_ctx, ClassTemplateDecl *class_template_decl, int kind,
+TypeSystemClang::CreateClassTemplateSpecializationDecl(
+ DeclContext *decl_ctx, OptionalClangModuleID owning_module,
+ ClassTemplateDecl *class_template_decl, int kind,
const TemplateParameterInfos &template_param_infos) {
ASTContext &ast = getASTContext();
llvm::SmallVector<clang::TemplateArgument, 2> args(
@@ -1452,9 +1562,18 @@ ClangASTContext::CreateClassTemplateSpecializationDecl(
ast, template_param_infos.packed_args->args);
}
ClassTemplateSpecializationDecl *class_template_specialization_decl =
- ClassTemplateSpecializationDecl::Create(
- ast, (TagDecl::TagKind)kind, decl_ctx, SourceLocation(),
- SourceLocation(), class_template_decl, args, nullptr);
+ ClassTemplateSpecializationDecl::CreateDeserialized(ast, 0);
+ class_template_specialization_decl->setTagKind(
+ static_cast<TagDecl::TagKind>(kind));
+ class_template_specialization_decl->setDeclContext(decl_ctx);
+ class_template_specialization_decl->setInstantiationOf(class_template_decl);
+ class_template_specialization_decl->setTemplateArgs(
+ TemplateArgumentList::CreateCopy(ast, args));
+ ast.getTypeDeclType(class_template_specialization_decl, nullptr);
+ class_template_specialization_decl->setDeclName(
+ class_template_decl->getDeclName());
+ SetOwningModule(class_template_specialization_decl, owning_module);
+ decl_ctx->addDecl(class_template_specialization_decl);
class_template_specialization_decl->setSpecializationKind(
TSK_ExplicitSpecialization);
@@ -1462,7 +1581,7 @@ ClangASTContext::CreateClassTemplateSpecializationDecl(
return class_template_specialization_decl;
}
-CompilerType ClangASTContext::CreateClassTemplateSpecializationType(
+CompilerType TypeSystemClang::CreateClassTemplateSpecializationType(
ClassTemplateSpecializationDecl *class_template_specialization_decl) {
if (class_template_specialization_decl) {
ASTContext &ast = getASTContext();
@@ -1490,7 +1609,7 @@ static inline bool check_op_param(bool is_method,
return false;
}
-bool ClangASTContext::CheckOverloadedOperatorKindParameterCount(
+bool TypeSystemClang::CheckOverloadedOperatorKindParameterCount(
bool is_method, clang::OverloadedOperatorKind op_kind,
uint32_t num_params) {
switch (op_kind) {
@@ -1516,7 +1635,7 @@ bool ClangASTContext::CheckOverloadedOperatorKindParameterCount(
}
clang::AccessSpecifier
-ClangASTContext::UnifyAccessSpecifiers(clang::AccessSpecifier lhs,
+TypeSystemClang::UnifyAccessSpecifiers(clang::AccessSpecifier lhs,
clang::AccessSpecifier rhs) {
// Make the access equal to the stricter of the field and the nested field's
// access
@@ -1529,7 +1648,7 @@ ClangASTContext::UnifyAccessSpecifiers(clang::AccessSpecifier lhs,
return AS_public;
}
-bool ClangASTContext::FieldIsBitfield(FieldDecl *field,
+bool TypeSystemClang::FieldIsBitfield(FieldDecl *field,
uint32_t &bitfield_bit_size) {
ASTContext &ast = getASTContext();
if (field == nullptr)
@@ -1548,7 +1667,7 @@ bool ClangASTContext::FieldIsBitfield(FieldDecl *field,
return false;
}
-bool ClangASTContext::RecordHasFields(const RecordDecl *record_decl) {
+bool TypeSystemClang::RecordHasFields(const RecordDecl *record_decl) {
if (record_decl == nullptr)
return false;
@@ -1573,21 +1692,21 @@ bool ClangASTContext::RecordHasFields(const RecordDecl *record_decl) {
#pragma mark Objective-C Classes
-CompilerType ClangASTContext::CreateObjCClass(llvm::StringRef name,
- DeclContext *decl_ctx,
- bool isForwardDecl,
- bool isInternal,
- ClangASTMetadata *metadata) {
+CompilerType TypeSystemClang::CreateObjCClass(
+ llvm::StringRef name, clang::DeclContext *decl_ctx,
+ OptionalClangModuleID owning_module, bool isForwardDecl, bool isInternal,
+ ClangASTMetadata *metadata) {
ASTContext &ast = getASTContext();
assert(!name.empty());
- if (decl_ctx == nullptr)
+ if (!decl_ctx)
decl_ctx = ast.getTranslationUnitDecl();
- ObjCInterfaceDecl *decl = ObjCInterfaceDecl::Create(
- ast, decl_ctx, SourceLocation(), &ast.Idents.get(name), nullptr, nullptr,
- SourceLocation(),
- /*isForwardDecl,*/
- isInternal);
+ ObjCInterfaceDecl *decl = ObjCInterfaceDecl::CreateDeserialized(ast, 0);
+ decl->setDeclContext(decl_ctx);
+ decl->setDeclName(&ast.Idents.get(name));
+ /*isForwardDecl,*/
+ decl->setImplicit(isInternal);
+ SetOwningModule(decl, owning_module);
if (decl && metadata)
SetMetadata(decl, *metadata);
@@ -1596,11 +1715,11 @@ CompilerType ClangASTContext::CreateObjCClass(llvm::StringRef name,
}
static inline bool BaseSpecifierIsEmpty(const CXXBaseSpecifier *b) {
- return !ClangASTContext::RecordHasFields(b->getType()->getAsCXXRecordDecl());
+ return !TypeSystemClang::RecordHasFields(b->getType()->getAsCXXRecordDecl());
}
uint32_t
-ClangASTContext::GetNumBaseClasses(const CXXRecordDecl *cxx_record_decl,
+TypeSystemClang::GetNumBaseClasses(const CXXRecordDecl *cxx_record_decl,
bool omit_empty_base_classes) {
uint32_t num_bases = 0;
if (cxx_record_decl) {
@@ -1610,10 +1729,8 @@ ClangASTContext::GetNumBaseClasses(const CXXRecordDecl *cxx_record_decl,
base_class_end = cxx_record_decl->bases_end();
base_class != base_class_end; ++base_class) {
// Skip empty base classes
- if (omit_empty_base_classes) {
- if (BaseSpecifierIsEmpty(base_class))
- continue;
- }
+ if (BaseSpecifierIsEmpty(base_class))
+ continue;
++num_bases;
}
} else
@@ -1624,12 +1741,13 @@ ClangASTContext::GetNumBaseClasses(const CXXRecordDecl *cxx_record_decl,
#pragma mark Namespace Declarations
-NamespaceDecl *ClangASTContext::GetUniqueNamespaceDeclaration(
- const char *name, DeclContext *decl_ctx, bool is_inline) {
+NamespaceDecl *TypeSystemClang::GetUniqueNamespaceDeclaration(
+ const char *name, clang::DeclContext *decl_ctx,
+ OptionalClangModuleID owning_module, bool is_inline) {
NamespaceDecl *namespace_decl = nullptr;
ASTContext &ast = getASTContext();
TranslationUnitDecl *translation_unit_decl = ast.getTranslationUnitDecl();
- if (decl_ctx == nullptr)
+ if (!decl_ctx)
decl_ctx = translation_unit_decl;
if (name) {
@@ -1678,18 +1796,23 @@ NamespaceDecl *ClangASTContext::GetUniqueNamespaceDeclaration(
}
}
}
-#ifdef LLDB_CONFIGURATION_DEBUG
+ // Note: namespaces can span multiple modules, so perhaps this isn't a good
+ // idea.
+ SetOwningModule(namespace_decl, owning_module);
+
VerifyDecl(namespace_decl);
-#endif
return namespace_decl;
}
clang::BlockDecl *
-ClangASTContext::CreateBlockDeclaration(clang::DeclContext *ctx) {
- if (ctx != nullptr) {
+TypeSystemClang::CreateBlockDeclaration(clang::DeclContext *ctx,
+ OptionalClangModuleID owning_module) {
+ if (ctx) {
clang::BlockDecl *decl =
- clang::BlockDecl::Create(getASTContext(), ctx, clang::SourceLocation());
+ clang::BlockDecl::CreateDeserialized(getASTContext(), 0);
+ decl->setDeclContext(ctx);
ctx->addDecl(decl);
+ SetOwningModule(decl, owning_module);
return decl;
}
return nullptr;
@@ -1712,31 +1835,37 @@ clang::DeclContext *FindLCABetweenDecls(clang::DeclContext *left,
return nullptr;
}
-clang::UsingDirectiveDecl *ClangASTContext::CreateUsingDirectiveDeclaration(
- clang::DeclContext *decl_ctx, clang::NamespaceDecl *ns_decl) {
- if (decl_ctx != nullptr && ns_decl != nullptr) {
+clang::UsingDirectiveDecl *TypeSystemClang::CreateUsingDirectiveDeclaration(
+ clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
+ clang::NamespaceDecl *ns_decl) {
+ if (decl_ctx && ns_decl) {
auto *translation_unit = getASTContext().getTranslationUnitDecl();
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;
+ 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);
+ SetOwningModule(using_decl, owning_module);
+ return using_decl;
}
return nullptr;
}
clang::UsingDecl *
-ClangASTContext::CreateUsingDeclaration(clang::DeclContext *current_decl_ctx,
+TypeSystemClang::CreateUsingDeclaration(clang::DeclContext *current_decl_ctx,
+ OptionalClangModuleID owning_module,
clang::NamedDecl *target) {
- if (current_decl_ctx != nullptr && target != nullptr) {
+ if (current_decl_ctx && target) {
clang::UsingDecl *using_decl = clang::UsingDecl::Create(
getASTContext(), current_decl_ctx, clang::SourceLocation(),
clang::NestedNameSpecifierLoc(), clang::DeclarationNameInfo(), false);
+ SetOwningModule(using_decl, owning_module);
clang::UsingShadowDecl *shadow_decl = clang::UsingShadowDecl::Create(
getASTContext(), current_decl_ctx, clang::SourceLocation(), using_decl,
target);
+ SetOwningModule(shadow_decl, owning_module);
using_decl->addShadowDecl(shadow_decl);
current_decl_ctx->addDecl(using_decl);
return using_decl;
@@ -1744,14 +1873,17 @@ ClangASTContext::CreateUsingDeclaration(clang::DeclContext *current_decl_ctx,
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);
+clang::VarDecl *TypeSystemClang::CreateVariableDeclaration(
+ clang::DeclContext *decl_context, OptionalClangModuleID owning_module,
+ const char *name, clang::QualType type) {
+ if (decl_context) {
+ clang::VarDecl *var_decl =
+ clang::VarDecl::CreateDeserialized(getASTContext(), 0);
+ var_decl->setDeclContext(decl_context);
+ if (name && name[0])
+ var_decl->setDeclName(&getASTContext().Idents.getOwn(name));
+ var_decl->setType(type);
+ SetOwningModule(var_decl, owning_module);
var_decl->setAccess(clang::AS_public);
decl_context->addDecl(var_decl);
return var_decl;
@@ -1760,7 +1892,7 @@ clang::VarDecl *ClangASTContext::CreateVariableDeclaration(
}
lldb::opaque_compiler_type_t
-ClangASTContext::GetOpaqueCompilerType(clang::ASTContext *ast,
+TypeSystemClang::GetOpaqueCompilerType(clang::ASTContext *ast,
lldb::BasicType basic_type) {
switch (basic_type) {
case eBasicTypeVoid:
@@ -1833,7 +1965,7 @@ ClangASTContext::GetOpaqueCompilerType(clang::ASTContext *ast,
#pragma mark Function Types
clang::DeclarationName
-ClangASTContext::GetDeclarationName(const char *name,
+TypeSystemClang::GetDeclarationName(const char *name,
const CompilerType &function_clang_type) {
if (!name || !name[0])
return clang::DeclarationName();
@@ -1855,19 +1987,20 @@ ClangASTContext::GetDeclarationName(const char *name,
const bool is_method = false;
const unsigned int num_params = function_type->getNumParams();
- if (!ClangASTContext::CheckOverloadedOperatorKindParameterCount(
+ if (!TypeSystemClang::CheckOverloadedOperatorKindParameterCount(
is_method, op_kind, num_params))
return clang::DeclarationName();
return getASTContext().DeclarationNames.getCXXOperatorName(op_kind);
}
-FunctionDecl *ClangASTContext::CreateFunctionDeclaration(
- DeclContext *decl_ctx, const char *name,
- const CompilerType &function_clang_type, int storage, bool is_inline) {
+FunctionDecl *TypeSystemClang::CreateFunctionDeclaration(
+ clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
+ const char *name, const CompilerType &function_clang_type, int storage,
+ bool is_inline) {
FunctionDecl *func_decl = nullptr;
ASTContext &ast = getASTContext();
- if (decl_ctx == nullptr)
+ if (!decl_ctx)
decl_ctx = ast.getTranslationUnitDecl();
const bool hasWrittenPrototype = true;
@@ -1875,23 +2008,26 @@ FunctionDecl *ClangASTContext::CreateFunctionDeclaration(
clang::DeclarationName declarationName =
GetDeclarationName(name, function_clang_type);
- func_decl = FunctionDecl::Create(
- ast, decl_ctx, SourceLocation(), SourceLocation(), declarationName,
- ClangUtil::GetQualType(function_clang_type), nullptr,
- (clang::StorageClass)storage, is_inline, hasWrittenPrototype,
- isConstexprSpecified ? CSK_constexpr : CSK_unspecified);
+ func_decl = FunctionDecl::CreateDeserialized(ast, 0);
+ func_decl->setDeclContext(decl_ctx);
+ func_decl->setDeclName(declarationName);
+ func_decl->setType(ClangUtil::GetQualType(function_clang_type));
+ func_decl->setStorageClass(static_cast<clang::StorageClass>(storage));
+ func_decl->setInlineSpecified(is_inline);
+ func_decl->setHasWrittenPrototype(hasWrittenPrototype);
+ func_decl->setConstexprKind(isConstexprSpecified ? CSK_constexpr
+ : CSK_unspecified);
+ SetOwningModule(func_decl, owning_module);
if (func_decl)
decl_ctx->addDecl(func_decl);
-#ifdef LLDB_CONFIGURATION_DEBUG
VerifyDecl(func_decl);
-#endif
return func_decl;
}
CompilerType
-ClangASTContext::CreateFunctionType(const CompilerType &result_type,
+TypeSystemClang::CreateFunctionType(const CompilerType &result_type,
const CompilerType *args, unsigned num_args,
bool is_variadic, unsigned type_quals,
clang::CallingConv cc) {
@@ -1929,22 +2065,25 @@ ClangASTContext::CreateFunctionType(const CompilerType &result_type,
ClangUtil::GetQualType(result_type), qual_type_args, proto_info));
}
-ParmVarDecl *ClangASTContext::CreateParameterDeclaration(
- clang::DeclContext *decl_ctx, const char *name,
- const CompilerType &param_type, int storage, bool add_decl) {
+ParmVarDecl *TypeSystemClang::CreateParameterDeclaration(
+ clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
+ const char *name, const CompilerType &param_type, int storage,
+ bool add_decl) {
ASTContext &ast = getASTContext();
- auto *decl =
- ParmVarDecl::Create(ast, decl_ctx, SourceLocation(), SourceLocation(),
- name && name[0] ? &ast.Idents.get(name) : nullptr,
- ClangUtil::GetQualType(param_type), nullptr,
- (clang::StorageClass)storage, nullptr);
+ auto *decl = ParmVarDecl::CreateDeserialized(ast, 0);
+ decl->setDeclContext(decl_ctx);
+ if (name && name[0])
+ decl->setDeclName(&ast.Idents.get(name));
+ decl->setType(ClangUtil::GetQualType(param_type));
+ decl->setStorageClass(static_cast<clang::StorageClass>(storage));
+ SetOwningModule(decl, owning_module);
if (add_decl)
decl_ctx->addDecl(decl);
return decl;
}
-void ClangASTContext::SetFunctionParameters(FunctionDecl *function_decl,
+void TypeSystemClang::SetFunctionParameters(FunctionDecl *function_decl,
ParmVarDecl **params,
unsigned num_params) {
if (function_decl)
@@ -1952,7 +2091,7 @@ void ClangASTContext::SetFunctionParameters(FunctionDecl *function_decl,
}
CompilerType
-ClangASTContext::CreateBlockPointerType(const CompilerType &function_type) {
+TypeSystemClang::CreateBlockPointerType(const CompilerType &function_type) {
QualType block_type = m_ast_up->getBlockPointerType(
clang::QualType::getFromOpaquePtr(function_type.GetOpaqueQualType()));
@@ -1961,7 +2100,7 @@ ClangASTContext::CreateBlockPointerType(const CompilerType &function_type) {
#pragma mark Array Types
-CompilerType ClangASTContext::CreateArrayType(const CompilerType &element_type,
+CompilerType TypeSystemClang::CreateArrayType(const CompilerType &element_type,
size_t element_count,
bool is_vector) {
if (element_type.IsValid()) {
@@ -1986,7 +2125,7 @@ CompilerType ClangASTContext::CreateArrayType(const CompilerType &element_type,
return CompilerType();
}
-CompilerType ClangASTContext::CreateStructForIdentifier(
+CompilerType TypeSystemClang::CreateStructForIdentifier(
ConstString type_name,
const std::initializer_list<std::pair<const char *, CompilerType>>
&type_fields,
@@ -1999,8 +2138,9 @@ CompilerType ClangASTContext::CreateStructForIdentifier(
return type;
}
- type = CreateRecordType(nullptr, lldb::eAccessPublic, type_name.GetCString(),
- clang::TTK_Struct, lldb::eLanguageTypeC);
+ type = CreateRecordType(nullptr, OptionalClangModuleID(), lldb::eAccessPublic,
+ type_name.GetCString(), clang::TTK_Struct,
+ lldb::eLanguageTypeC);
StartTagDeclarationDefinition(type);
for (const auto &field : type_fields)
AddFieldToRecordType(type, field.first, field.second, lldb::eAccessPublic,
@@ -2011,7 +2151,7 @@ CompilerType ClangASTContext::CreateStructForIdentifier(
return type;
}
-CompilerType ClangASTContext::GetOrCreateStructForIdentifier(
+CompilerType TypeSystemClang::GetOrCreateStructForIdentifier(
ConstString type_name,
const std::initializer_list<std::pair<const char *, CompilerType>>
&type_fields,
@@ -2025,25 +2165,24 @@ CompilerType ClangASTContext::GetOrCreateStructForIdentifier(
#pragma mark Enumeration Types
-CompilerType
-ClangASTContext::CreateEnumerationType(const char *name, DeclContext *decl_ctx,
- const Declaration &decl,
- const CompilerType &integer_clang_type,
- bool is_scoped) {
+CompilerType TypeSystemClang::CreateEnumerationType(
+ const char *name, clang::DeclContext *decl_ctx,
+ OptionalClangModuleID owning_module, const Declaration &decl,
+ const CompilerType &integer_clang_type, bool is_scoped) {
// 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 IsFixed = false;
-
- EnumDecl *enum_decl = EnumDecl::Create(
- ast, decl_ctx, SourceLocation(), SourceLocation(),
- name && name[0] ? &ast.Idents.get(name) : nullptr, nullptr,
- is_scoped, // IsScoped
- is_scoped, // IsScopedUsingClassTag
- false); // IsFixed
-
+ EnumDecl *enum_decl = EnumDecl::CreateDeserialized(ast, 0);
+ enum_decl->setDeclContext(decl_ctx);
+ if (name && name[0])
+ enum_decl->setDeclName(&ast.Idents.get(name));
+ enum_decl->setScoped(is_scoped);
+ enum_decl->setScopedUsingClassTag(is_scoped);
+ enum_decl->setFixed(false);
+ SetOwningModule(enum_decl, owning_module);
if (enum_decl) {
if (decl_ctx)
decl_ctx->addDecl(enum_decl);
@@ -2058,7 +2197,7 @@ ClangASTContext::CreateEnumerationType(const char *name, DeclContext *decl_ctx,
return CompilerType();
}
-CompilerType ClangASTContext::GetIntTypeFromBitSize(size_t bit_size,
+CompilerType TypeSystemClang::GetIntTypeFromBitSize(size_t bit_size,
bool is_signed) {
clang::ASTContext &ast = getASTContext();
@@ -2102,12 +2241,12 @@ CompilerType ClangASTContext::GetIntTypeFromBitSize(size_t bit_size,
return CompilerType();
}
-CompilerType ClangASTContext::GetPointerSizedIntType(bool is_signed) {
+CompilerType TypeSystemClang::GetPointerSizedIntType(bool is_signed) {
return GetIntTypeFromBitSize(
getASTContext().getTypeSize(getASTContext().VoidPtrTy), is_signed);
}
-void ClangASTContext::DumpDeclContextHiearchy(clang::DeclContext *decl_ctx) {
+void TypeSystemClang::DumpDeclContextHiearchy(clang::DeclContext *decl_ctx) {
if (decl_ctx) {
DumpDeclContextHiearchy(decl_ctx->getParent());
@@ -2121,7 +2260,7 @@ void ClangASTContext::DumpDeclContextHiearchy(clang::DeclContext *decl_ctx) {
}
}
-void ClangASTContext::DumpDeclHiearchy(clang::Decl *decl) {
+void TypeSystemClang::DumpDeclHiearchy(clang::Decl *decl) {
if (decl == nullptr)
return;
DumpDeclContextHiearchy(decl->getDeclContext());
@@ -2143,7 +2282,7 @@ void ClangASTContext::DumpDeclHiearchy(clang::Decl *decl) {
}
}
-bool ClangASTContext::DeclsAreEquivalent(clang::Decl *lhs_decl,
+bool TypeSystemClang::DeclsAreEquivalent(clang::Decl *lhs_decl,
clang::Decl *rhs_decl) {
if (lhs_decl && rhs_decl) {
// Make sure the decl kinds match first
@@ -2226,7 +2365,7 @@ bool ClangASTContext::DeclsAreEquivalent(clang::Decl *lhs_decl,
}
return false;
}
-bool ClangASTContext::GetCompleteDecl(clang::ASTContext *ast,
+bool TypeSystemClang::GetCompleteDecl(clang::ASTContext *ast,
clang::Decl *decl) {
if (!decl)
return false;
@@ -2262,45 +2401,45 @@ bool ClangASTContext::GetCompleteDecl(clang::ASTContext *ast,
}
}
-void ClangASTContext::SetMetadataAsUserID(const clang::Decl *decl,
+void TypeSystemClang::SetMetadataAsUserID(const clang::Decl *decl,
user_id_t user_id) {
ClangASTMetadata meta_data;
meta_data.SetUserID(user_id);
SetMetadata(decl, meta_data);
}
-void ClangASTContext::SetMetadataAsUserID(const clang::Type *type,
+void TypeSystemClang::SetMetadataAsUserID(const clang::Type *type,
user_id_t user_id) {
ClangASTMetadata meta_data;
meta_data.SetUserID(user_id);
SetMetadata(type, meta_data);
}
-void ClangASTContext::SetMetadata(const clang::Decl *object,
+void TypeSystemClang::SetMetadata(const clang::Decl *object,
ClangASTMetadata &metadata) {
m_decl_metadata[object] = metadata;
}
-void ClangASTContext::SetMetadata(const clang::Type *object,
+void TypeSystemClang::SetMetadata(const clang::Type *object,
ClangASTMetadata &metadata) {
m_type_metadata[object] = metadata;
}
-ClangASTMetadata *ClangASTContext::GetMetadata(const clang::Decl *object) {
+ClangASTMetadata *TypeSystemClang::GetMetadata(const clang::Decl *object) {
auto It = m_decl_metadata.find(object);
if (It != m_decl_metadata.end())
return &It->second;
return nullptr;
}
-ClangASTMetadata *ClangASTContext::GetMetadata(const clang::Type *object) {
+ClangASTMetadata *TypeSystemClang::GetMetadata(const clang::Type *object) {
auto It = m_type_metadata.find(object);
if (It != m_type_metadata.end())
return &It->second;
return nullptr;
}
-bool ClangASTContext::SetTagTypeKind(clang::QualType tag_qual_type,
+bool TypeSystemClang::SetTagTypeKind(clang::QualType tag_qual_type,
int kind) const {
const clang::Type *clang_type = tag_qual_type.getTypePtr();
if (clang_type) {
@@ -2317,7 +2456,7 @@ bool ClangASTContext::SetTagTypeKind(clang::QualType tag_qual_type,
return false;
}
-bool ClangASTContext::SetDefaultAccessForRecordFields(
+bool TypeSystemClang::SetDefaultAccessForRecordFields(
clang::RecordDecl *record_decl, int default_accessibility,
int *assigned_accessibilities, size_t num_assigned_accessibilities) {
if (record_decl) {
@@ -2337,7 +2476,7 @@ bool ClangASTContext::SetDefaultAccessForRecordFields(
}
clang::DeclContext *
-ClangASTContext::GetDeclContextForType(const CompilerType &type) {
+TypeSystemClang::GetDeclContextForType(const CompilerType &type) {
return GetDeclContextForType(ClangUtil::GetQualType(type));
}
@@ -2372,7 +2511,7 @@ RemoveWrappingTypes(QualType type, ArrayRef<clang::Type::TypeClass> mask = {}) {
}
clang::DeclContext *
-ClangASTContext::GetDeclContextForType(clang::QualType type) {
+TypeSystemClang::GetDeclContextForType(clang::QualType type) {
if (type.isNull())
return nullptr;
@@ -2533,7 +2672,13 @@ ConvertAccessTypeToObjCIvarAccessControl(AccessType access) {
// Tests
-bool ClangASTContext::IsAggregateType(lldb::opaque_compiler_type_t type) {
+#ifndef NDEBUG
+bool TypeSystemClang::Verify(lldb::opaque_compiler_type_t type) {
+ return !type || llvm::isa<clang::Type>(GetQualType(type).getTypePtr());
+}
+#endif
+
+bool TypeSystemClang::IsAggregateType(lldb::opaque_compiler_type_t type) {
clang::QualType qual_type(RemoveWrappingTypes(GetCanonicalQualType(type)));
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
@@ -2554,7 +2699,7 @@ bool ClangASTContext::IsAggregateType(lldb::opaque_compiler_type_t type) {
return false;
}
-bool ClangASTContext::IsAnonymousType(lldb::opaque_compiler_type_t type) {
+bool TypeSystemClang::IsAnonymousType(lldb::opaque_compiler_type_t type) {
clang::QualType qual_type(RemoveWrappingTypes(GetCanonicalQualType(type)));
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
@@ -2576,7 +2721,7 @@ bool ClangASTContext::IsAnonymousType(lldb::opaque_compiler_type_t type) {
return false;
}
-bool ClangASTContext::IsArrayType(lldb::opaque_compiler_type_t type,
+bool TypeSystemClang::IsArrayType(lldb::opaque_compiler_type_t type,
CompilerType *element_type_ptr,
uint64_t *size, bool *is_incomplete) {
clang::QualType qual_type(RemoveWrappingTypes(GetCanonicalQualType(type)));
@@ -2645,7 +2790,7 @@ bool ClangASTContext::IsArrayType(lldb::opaque_compiler_type_t type,
return false;
}
-bool ClangASTContext::IsVectorType(lldb::opaque_compiler_type_t type,
+bool TypeSystemClang::IsVectorType(lldb::opaque_compiler_type_t type,
CompilerType *element_type, uint64_t *size) {
clang::QualType qual_type(GetCanonicalQualType(type));
@@ -2680,7 +2825,7 @@ bool ClangASTContext::IsVectorType(lldb::opaque_compiler_type_t type,
return false;
}
-bool ClangASTContext::IsRuntimeGeneratedType(
+bool TypeSystemClang::IsRuntimeGeneratedType(
lldb::opaque_compiler_type_t type) {
clang::DeclContext *decl_ctx = GetDeclContextForType(GetQualType(type));
if (!decl_ctx)
@@ -2698,21 +2843,21 @@ bool ClangASTContext::IsRuntimeGeneratedType(
return (ast_metadata->GetISAPtr() != 0);
}
-bool ClangASTContext::IsCharType(lldb::opaque_compiler_type_t type) {
+bool TypeSystemClang::IsCharType(lldb::opaque_compiler_type_t type) {
return GetQualType(type).getUnqualifiedType()->isCharType();
}
-bool ClangASTContext::IsCompleteType(lldb::opaque_compiler_type_t type) {
+bool TypeSystemClang::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) {
+bool TypeSystemClang::IsConst(lldb::opaque_compiler_type_t type) {
return GetQualType(type).isConstQualified();
}
-bool ClangASTContext::IsCStringType(lldb::opaque_compiler_type_t type,
+bool TypeSystemClang::IsCStringType(lldb::opaque_compiler_type_t type,
uint32_t &length) {
CompilerType pointee_or_element_clang_type;
length = 0;
@@ -2737,7 +2882,7 @@ bool ClangASTContext::IsCStringType(lldb::opaque_compiler_type_t type,
return false;
}
-bool ClangASTContext::IsFunctionType(lldb::opaque_compiler_type_t type,
+bool TypeSystemClang::IsFunctionType(lldb::opaque_compiler_type_t type,
bool *is_variadic_ptr) {
if (type) {
clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type));
@@ -2773,7 +2918,7 @@ bool ClangASTContext::IsFunctionType(lldb::opaque_compiler_type_t type,
// Used to detect "Homogeneous Floating-point Aggregates"
uint32_t
-ClangASTContext::IsHomogeneousAggregate(lldb::opaque_compiler_type_t type,
+TypeSystemClang::IsHomogeneousAggregate(lldb::opaque_compiler_type_t type,
CompilerType *base_type_ptr) {
if (!type)
return 0;
@@ -2854,7 +2999,7 @@ ClangASTContext::IsHomogeneousAggregate(lldb::opaque_compiler_type_t type,
return 0;
}
-size_t ClangASTContext::GetNumberOfFunctionArguments(
+size_t TypeSystemClang::GetNumberOfFunctionArguments(
lldb::opaque_compiler_type_t type) {
if (type) {
clang::QualType qual_type(GetCanonicalQualType(type));
@@ -2867,7 +3012,7 @@ size_t ClangASTContext::GetNumberOfFunctionArguments(
}
CompilerType
-ClangASTContext::GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type,
+TypeSystemClang::GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type,
const size_t index) {
if (type) {
clang::QualType qual_type(GetQualType(type));
@@ -2881,7 +3026,7 @@ ClangASTContext::GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type,
return CompilerType();
}
-bool ClangASTContext::IsFunctionPointerType(lldb::opaque_compiler_type_t type) {
+bool TypeSystemClang::IsFunctionPointerType(lldb::opaque_compiler_type_t type) {
if (type) {
clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type));
@@ -2906,7 +3051,7 @@ bool ClangASTContext::IsFunctionPointerType(lldb::opaque_compiler_type_t type) {
return false;
}
-bool ClangASTContext::IsBlockPointerType(
+bool TypeSystemClang::IsBlockPointerType(
lldb::opaque_compiler_type_t type,
CompilerType *function_pointer_type_ptr) {
if (type) {
@@ -2943,7 +3088,7 @@ bool ClangASTContext::IsBlockPointerType(
return false;
}
-bool ClangASTContext::IsIntegerType(lldb::opaque_compiler_type_t type,
+bool TypeSystemClang::IsIntegerType(lldb::opaque_compiler_type_t type,
bool &is_signed) {
if (!type)
return false;
@@ -2962,7 +3107,7 @@ bool ClangASTContext::IsIntegerType(lldb::opaque_compiler_type_t type,
return false;
}
-bool ClangASTContext::IsEnumerationType(lldb::opaque_compiler_type_t type,
+bool TypeSystemClang::IsEnumerationType(lldb::opaque_compiler_type_t type,
bool &is_signed) {
if (type) {
const clang::EnumType *enum_type = llvm::dyn_cast<clang::EnumType>(
@@ -2978,7 +3123,7 @@ bool ClangASTContext::IsEnumerationType(lldb::opaque_compiler_type_t type,
return false;
}
-bool ClangASTContext::IsPointerType(lldb::opaque_compiler_type_t type,
+bool TypeSystemClang::IsPointerType(lldb::opaque_compiler_type_t type,
CompilerType *pointee_type) {
if (type) {
clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type));
@@ -3030,7 +3175,7 @@ bool ClangASTContext::IsPointerType(lldb::opaque_compiler_type_t type,
return false;
}
-bool ClangASTContext::IsPointerOrReferenceType(
+bool TypeSystemClang::IsPointerOrReferenceType(
lldb::opaque_compiler_type_t type, CompilerType *pointee_type) {
if (type) {
clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type));
@@ -3095,7 +3240,7 @@ bool ClangASTContext::IsPointerOrReferenceType(
return false;
}
-bool ClangASTContext::IsReferenceType(lldb::opaque_compiler_type_t type,
+bool TypeSystemClang::IsReferenceType(lldb::opaque_compiler_type_t type,
CompilerType *pointee_type,
bool *is_rvalue) {
if (type) {
@@ -3131,7 +3276,7 @@ bool ClangASTContext::IsReferenceType(lldb::opaque_compiler_type_t type,
return false;
}
-bool ClangASTContext::IsFloatingPointType(lldb::opaque_compiler_type_t type,
+bool TypeSystemClang::IsFloatingPointType(lldb::opaque_compiler_type_t type,
uint32_t &count, bool &is_complex) {
if (type) {
clang::QualType qual_type(GetCanonicalQualType(type));
@@ -3169,7 +3314,7 @@ bool ClangASTContext::IsFloatingPointType(lldb::opaque_compiler_type_t type,
return false;
}
-bool ClangASTContext::IsDefined(lldb::opaque_compiler_type_t type) {
+bool TypeSystemClang::IsDefined(lldb::opaque_compiler_type_t type) {
if (!type)
return false;
@@ -3195,7 +3340,7 @@ bool ClangASTContext::IsDefined(lldb::opaque_compiler_type_t type) {
return true;
}
-bool ClangASTContext::IsObjCClassType(const CompilerType &type) {
+bool TypeSystemClang::IsObjCClassType(const CompilerType &type) {
if (ClangUtil::IsClangType(type)) {
clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type));
@@ -3208,13 +3353,13 @@ bool ClangASTContext::IsObjCClassType(const CompilerType &type) {
return false;
}
-bool ClangASTContext::IsObjCObjectOrInterfaceType(const CompilerType &type) {
+bool TypeSystemClang::IsObjCObjectOrInterfaceType(const CompilerType &type) {
if (ClangUtil::IsClangType(type))
return ClangUtil::GetCanonicalQualType(type)->isObjCObjectOrInterfaceType();
return false;
}
-bool ClangASTContext::IsClassType(lldb::opaque_compiler_type_t type) {
+bool TypeSystemClang::IsClassType(lldb::opaque_compiler_type_t type) {
if (!type)
return false;
clang::QualType qual_type(GetCanonicalQualType(type));
@@ -3222,7 +3367,7 @@ bool ClangASTContext::IsClassType(lldb::opaque_compiler_type_t type) {
return (type_class == clang::Type::Record);
}
-bool ClangASTContext::IsEnumType(lldb::opaque_compiler_type_t type) {
+bool TypeSystemClang::IsEnumType(lldb::opaque_compiler_type_t type) {
if (!type)
return false;
clang::QualType qual_type(GetCanonicalQualType(type));
@@ -3230,7 +3375,7 @@ bool ClangASTContext::IsEnumType(lldb::opaque_compiler_type_t type) {
return (type_class == clang::Type::Enum);
}
-bool ClangASTContext::IsPolymorphicClass(lldb::opaque_compiler_type_t type) {
+bool TypeSystemClang::IsPolymorphicClass(lldb::opaque_compiler_type_t type) {
if (type) {
clang::QualType qual_type(GetCanonicalQualType(type));
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
@@ -3256,7 +3401,7 @@ bool ClangASTContext::IsPolymorphicClass(lldb::opaque_compiler_type_t type) {
return false;
}
-bool ClangASTContext::IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
+bool TypeSystemClang::IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
CompilerType *dynamic_pointee_type,
bool check_cplusplus,
bool check_objc) {
@@ -3278,9 +3423,9 @@ bool ClangASTContext::IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
case clang::Type::ObjCObjectPointer:
if (check_objc) {
- if (auto objc_pointee_type =
+ if (const auto *objc_pointee_type =
qual_type->getPointeeType().getTypePtrOrNull()) {
- if (auto objc_object_type =
+ if (const auto *objc_object_type =
llvm::dyn_cast_or_null<clang::ObjCObjectType>(
objc_pointee_type)) {
if (objc_object_type->isObjCClass())
@@ -3385,39 +3530,40 @@ bool ClangASTContext::IsPossibleDynamicType(lldb::opaque_compiler_type_t type,
return false;
}
-bool ClangASTContext::IsScalarType(lldb::opaque_compiler_type_t type) {
+bool TypeSystemClang::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) {
+bool TypeSystemClang::IsTypedefType(lldb::opaque_compiler_type_t type) {
if (!type)
return false;
- return GetQualType(type)->getTypeClass() == clang::Type::Typedef;
+ return RemoveWrappingTypes(GetQualType(type), {clang::Type::Typedef})
+ ->getTypeClass() == clang::Type::Typedef;
}
-bool ClangASTContext::IsVoidType(lldb::opaque_compiler_type_t type) {
+bool TypeSystemClang::IsVoidType(lldb::opaque_compiler_type_t type) {
if (!type)
return false;
return GetCanonicalQualType(type)->isVoidType();
}
-bool ClangASTContext::CanPassInRegisters(const CompilerType &type) {
+bool TypeSystemClang::CanPassInRegisters(const CompilerType &type) {
if (auto *record_decl =
- ClangASTContext::GetAsRecordDecl(type)) {
+ TypeSystemClang::GetAsRecordDecl(type)) {
return record_decl->canPassInRegisters();
}
return false;
}
-bool ClangASTContext::SupportsLanguage(lldb::LanguageType language) {
- return ClangASTContextSupportsLanguage(language);
+bool TypeSystemClang::SupportsLanguage(lldb::LanguageType language) {
+ return TypeSystemClangSupportsLanguage(language);
}
Optional<std::string>
-ClangASTContext::GetCXXClassName(const CompilerType &type) {
+TypeSystemClang::GetCXXClassName(const CompilerType &type) {
if (!type)
return llvm::None;
@@ -3432,7 +3578,7 @@ ClangASTContext::GetCXXClassName(const CompilerType &type) {
return std::string(cxx_record_decl->getIdentifier()->getNameStart());
}
-bool ClangASTContext::IsCXXClassType(const CompilerType &type) {
+bool TypeSystemClang::IsCXXClassType(const CompilerType &type) {
if (!type)
return false;
@@ -3440,7 +3586,7 @@ bool ClangASTContext::IsCXXClassType(const CompilerType &type) {
return !qual_type.isNull() && qual_type->getAsCXXRecordDecl() != nullptr;
}
-bool ClangASTContext::IsBeingDefined(lldb::opaque_compiler_type_t type) {
+bool TypeSystemClang::IsBeingDefined(lldb::opaque_compiler_type_t type) {
if (!type)
return false;
clang::QualType qual_type(GetCanonicalQualType(type));
@@ -3450,7 +3596,7 @@ bool ClangASTContext::IsBeingDefined(lldb::opaque_compiler_type_t type) {
return false;
}
-bool ClangASTContext::IsObjCObjectPointerType(const CompilerType &type,
+bool TypeSystemClang::IsObjCObjectPointerType(const CompilerType &type,
CompilerType *class_type_ptr) {
if (!ClangUtil::IsClangType(type))
return false;
@@ -3480,7 +3626,7 @@ bool ClangASTContext::IsObjCObjectPointerType(const CompilerType &type,
// Type Completion
-bool ClangASTContext::GetCompleteType(lldb::opaque_compiler_type_t type) {
+bool TypeSystemClang::GetCompleteType(lldb::opaque_compiler_type_t type) {
if (!type)
return false;
const bool allow_completion = true;
@@ -3488,26 +3634,38 @@ bool ClangASTContext::GetCompleteType(lldb::opaque_compiler_type_t 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;
- 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);
- }
+ConstString TypeSystemClang::GetTypeName(lldb::opaque_compiler_type_t type) {
+ if (!type)
+ return ConstString();
+
+ clang::QualType qual_type(GetQualType(type));
+
+ // For a typedef just return the qualified name.
+ if (const auto *typedef_type = qual_type->getAs<clang::TypedefType>()) {
+ const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
+ return ConstString(typedef_decl->getQualifiedNameAsString());
}
- return ConstString(type_name);
+
+ clang::PrintingPolicy printing_policy(getASTContext().getPrintingPolicy());
+ printing_policy.SuppressTagKeyword = true;
+ return ConstString(qual_type.getAsString(printing_policy));
+}
+
+ConstString
+TypeSystemClang::GetDisplayTypeName(lldb::opaque_compiler_type_t type) {
+ if (!type)
+ return ConstString();
+
+ clang::QualType qual_type(GetQualType(type));
+ clang::PrintingPolicy printing_policy(getASTContext().getPrintingPolicy());
+ printing_policy.SuppressTagKeyword = true;
+ printing_policy.SuppressScope = false;
+ printing_policy.SuppressUnwrittenScope = true;
+ return ConstString(qual_type.getAsString(printing_policy));
}
uint32_t
-ClangASTContext::GetTypeInfo(lldb::opaque_compiler_type_t type,
+TypeSystemClang::GetTypeInfo(lldb::opaque_compiler_type_t type,
CompilerType *pointee_or_element_clang_type) {
if (!type)
return 0;
@@ -3708,7 +3866,7 @@ ClangASTContext::GetTypeInfo(lldb::opaque_compiler_type_t type,
}
lldb::LanguageType
-ClangASTContext::GetMinimumLanguage(lldb::opaque_compiler_type_t type) {
+TypeSystemClang::GetMinimumLanguage(lldb::opaque_compiler_type_t type) {
if (!type)
return lldb::eLanguageTypeC;
@@ -3792,7 +3950,7 @@ ClangASTContext::GetMinimumLanguage(lldb::opaque_compiler_type_t type) {
}
lldb::TypeClass
-ClangASTContext::GetTypeClass(lldb::opaque_compiler_type_t type) {
+TypeSystemClang::GetTypeClass(lldb::opaque_compiler_type_t type) {
if (!type)
return lldb::eTypeClassInvalid;
@@ -3831,6 +3989,9 @@ ClangASTContext::GetTypeClass(lldb::opaque_compiler_type_t type) {
case clang::Type::Vector:
return lldb::eTypeClassVector;
case clang::Type::Builtin:
+ // Ext-Int is just an integer type.
+ case clang::Type::ExtInt:
+ case clang::Type::DependentExtInt:
return lldb::eTypeClassBuiltin;
case clang::Type::ObjCObjectPointer:
return lldb::eTypeClassObjCObjectPointer;
@@ -3907,12 +4068,17 @@ ClangASTContext::GetTypeClass(lldb::opaque_compiler_type_t type) {
break;
case clang::Type::MacroQualified:
break;
+
+ // Matrix types that we're not sure how to display at the moment.
+ case clang::Type::ConstantMatrix:
+ case clang::Type::DependentSizedMatrix:
+ break;
}
// We don't know hot to display this type...
return lldb::eTypeClassOther;
}
-unsigned ClangASTContext::GetTypeQualifiers(lldb::opaque_compiler_type_t type) {
+unsigned TypeSystemClang::GetTypeQualifiers(lldb::opaque_compiler_type_t type) {
if (type)
return GetQualType(type).getQualifiers().getCVRQualifiers();
return 0;
@@ -3921,7 +4087,7 @@ unsigned ClangASTContext::GetTypeQualifiers(lldb::opaque_compiler_type_t type) {
// Creating related types
CompilerType
-ClangASTContext::GetArrayElementType(lldb::opaque_compiler_type_t type,
+TypeSystemClang::GetArrayElementType(lldb::opaque_compiler_type_t type,
uint64_t *stride) {
if (type) {
clang::QualType qual_type(GetQualType(type));
@@ -3944,7 +4110,7 @@ ClangASTContext::GetArrayElementType(lldb::opaque_compiler_type_t type,
return CompilerType();
}
-CompilerType ClangASTContext::GetArrayType(lldb::opaque_compiler_type_t type,
+CompilerType TypeSystemClang::GetArrayType(lldb::opaque_compiler_type_t type,
uint64_t size) {
if (type) {
clang::QualType qual_type(GetCanonicalQualType(type));
@@ -3962,7 +4128,7 @@ CompilerType ClangASTContext::GetArrayType(lldb::opaque_compiler_type_t type,
}
CompilerType
-ClangASTContext::GetCanonicalType(lldb::opaque_compiler_type_t type) {
+TypeSystemClang::GetCanonicalType(lldb::opaque_compiler_type_t type) {
if (type)
return GetType(GetCanonicalQualType(type));
return CompilerType();
@@ -3982,14 +4148,14 @@ static clang::QualType GetFullyUnqualifiedType_Impl(clang::ASTContext *ast,
}
CompilerType
-ClangASTContext::GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) {
+TypeSystemClang::GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) {
if (type)
return GetType(
GetFullyUnqualifiedType_Impl(&getASTContext(), GetQualType(type)));
return CompilerType();
}
-int ClangASTContext::GetFunctionArgumentCount(
+int TypeSystemClang::GetFunctionArgumentCount(
lldb::opaque_compiler_type_t type) {
if (type) {
const clang::FunctionProtoType *func =
@@ -4000,7 +4166,7 @@ int ClangASTContext::GetFunctionArgumentCount(
return -1;
}
-CompilerType ClangASTContext::GetFunctionArgumentTypeAtIndex(
+CompilerType TypeSystemClang::GetFunctionArgumentTypeAtIndex(
lldb::opaque_compiler_type_t type, size_t idx) {
if (type) {
const clang::FunctionProtoType *func =
@@ -4015,7 +4181,7 @@ CompilerType ClangASTContext::GetFunctionArgumentTypeAtIndex(
}
CompilerType
-ClangASTContext::GetFunctionReturnType(lldb::opaque_compiler_type_t type) {
+TypeSystemClang::GetFunctionReturnType(lldb::opaque_compiler_type_t type) {
if (type) {
clang::QualType qual_type(GetQualType(type));
const clang::FunctionProtoType *func =
@@ -4027,7 +4193,7 @@ ClangASTContext::GetFunctionReturnType(lldb::opaque_compiler_type_t type) {
}
size_t
-ClangASTContext::GetNumMemberFunctions(lldb::opaque_compiler_type_t type) {
+TypeSystemClang::GetNumMemberFunctions(lldb::opaque_compiler_type_t type) {
size_t num_functions = 0;
if (type) {
clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type));
@@ -4087,7 +4253,7 @@ ClangASTContext::GetNumMemberFunctions(lldb::opaque_compiler_type_t type) {
}
TypeMemberFunctionImpl
-ClangASTContext::GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type,
+TypeSystemClang::GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type,
size_t idx) {
std::string name;
MemberFunctionKind kind(MemberFunctionKind::eMemberFunctionKindUnknown);
@@ -4123,7 +4289,7 @@ ClangASTContext::GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type,
else
kind = lldb::eMemberFunctionKindInstanceMethod;
clang_type = GetType(cxx_method_decl->getType());
- clang_decl = CompilerDecl(this, cxx_method_decl);
+ clang_decl = GetCompilerDecl(cxx_method_decl);
}
}
}
@@ -4149,7 +4315,7 @@ ClangASTContext::GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type,
clang::ObjCMethodDecl *objc_method_decl =
method_iter->getCanonicalDecl();
if (objc_method_decl) {
- clang_decl = CompilerDecl(this, objc_method_decl);
+ clang_decl = GetCompilerDecl(objc_method_decl);
name = objc_method_decl->getSelector().getAsString();
if (objc_method_decl->isClassMethod())
kind = lldb::eMemberFunctionKindStaticMethod;
@@ -4179,7 +4345,7 @@ ClangASTContext::GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type,
clang::ObjCMethodDecl *objc_method_decl =
method_iter->getCanonicalDecl();
if (objc_method_decl) {
- clang_decl = CompilerDecl(this, objc_method_decl);
+ clang_decl = GetCompilerDecl(objc_method_decl);
name = objc_method_decl->getSelector().getAsString();
if (objc_method_decl->isClassMethod())
kind = lldb::eMemberFunctionKindStaticMethod;
@@ -4204,33 +4370,35 @@ ClangASTContext::GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type,
}
CompilerType
-ClangASTContext::GetNonReferenceType(lldb::opaque_compiler_type_t type) {
+TypeSystemClang::GetNonReferenceType(lldb::opaque_compiler_type_t type) {
if (type)
return GetType(GetQualType(type).getNonReferenceType());
return CompilerType();
}
-CompilerType ClangASTContext::CreateTypedefType(
+CompilerType TypeSystemClang::CreateTypedefType(
const CompilerType &type, const char *typedef_name,
- const CompilerDeclContext &compiler_decl_ctx) {
+ const CompilerDeclContext &compiler_decl_ctx, uint32_t payload) {
if (type && typedef_name && typedef_name[0]) {
- ClangASTContext *ast =
- llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
+ TypeSystemClang *ast =
+ llvm::dyn_cast<TypeSystemClang>(type.GetTypeSystem());
if (!ast)
return CompilerType();
clang::ASTContext &clang_ast = ast->getASTContext();
clang::QualType qual_type(ClangUtil::GetQualType(type));
clang::DeclContext *decl_ctx =
- ClangASTContext::DeclContextGetAsDeclContext(compiler_decl_ctx);
- if (decl_ctx == nullptr)
+ TypeSystemClang::DeclContextGetAsDeclContext(compiler_decl_ctx);
+ if (!decl_ctx)
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));
+ clang::TypedefDecl *decl =
+ clang::TypedefDecl::CreateDeserialized(clang_ast, 0);
+ decl->setDeclContext(decl_ctx);
+ decl->setDeclName(&clang_ast.Idents.get(typedef_name));
+ decl->setTypeSourceInfo(clang_ast.getTrivialTypeSourceInfo(qual_type));
+ SetOwningModule(decl, TypePayloadClang(payload).GetOwningModule());
decl->setAccess(clang::AS_public); // TODO respect proper access specifier
decl_ctx->addDecl(decl);
@@ -4242,7 +4410,7 @@ CompilerType ClangASTContext::CreateTypedefType(
}
CompilerType
-ClangASTContext::GetPointeeType(lldb::opaque_compiler_type_t type) {
+TypeSystemClang::GetPointeeType(lldb::opaque_compiler_type_t type) {
if (type) {
clang::QualType qual_type(GetQualType(type));
return GetType(qual_type.getTypePtr()->getPointeeType());
@@ -4251,12 +4419,11 @@ ClangASTContext::GetPointeeType(lldb::opaque_compiler_type_t type) {
}
CompilerType
-ClangASTContext::GetPointerType(lldb::opaque_compiler_type_t type) {
+TypeSystemClang::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) {
+ switch (qual_type.getDesugaredType(getASTContext())->getTypeClass()) {
case clang::Type::ObjCObject:
case clang::Type::ObjCInterface:
return GetType(getASTContext().getObjCObjectPointerType(qual_type));
@@ -4269,7 +4436,7 @@ ClangASTContext::GetPointerType(lldb::opaque_compiler_type_t type) {
}
CompilerType
-ClangASTContext::GetLValueReferenceType(lldb::opaque_compiler_type_t type) {
+TypeSystemClang::GetLValueReferenceType(lldb::opaque_compiler_type_t type) {
if (type)
return GetType(getASTContext().getLValueReferenceType(GetQualType(type)));
else
@@ -4277,21 +4444,21 @@ ClangASTContext::GetLValueReferenceType(lldb::opaque_compiler_type_t type) {
}
CompilerType
-ClangASTContext::GetRValueReferenceType(lldb::opaque_compiler_type_t type) {
+TypeSystemClang::GetRValueReferenceType(lldb::opaque_compiler_type_t type) {
if (type)
return GetType(getASTContext().getRValueReferenceType(GetQualType(type)));
else
return CompilerType();
}
-CompilerType ClangASTContext::GetAtomicType(lldb::opaque_compiler_type_t type) {
+CompilerType TypeSystemClang::GetAtomicType(lldb::opaque_compiler_type_t type) {
if (!type)
return CompilerType();
return GetType(getASTContext().getAtomicType(GetQualType(type)));
}
CompilerType
-ClangASTContext::AddConstModifier(lldb::opaque_compiler_type_t type) {
+TypeSystemClang::AddConstModifier(lldb::opaque_compiler_type_t type) {
if (type) {
clang::QualType result(GetQualType(type));
result.addConst();
@@ -4301,7 +4468,7 @@ ClangASTContext::AddConstModifier(lldb::opaque_compiler_type_t type) {
}
CompilerType
-ClangASTContext::AddVolatileModifier(lldb::opaque_compiler_type_t type) {
+TypeSystemClang::AddVolatileModifier(lldb::opaque_compiler_type_t type) {
if (type) {
clang::QualType result(GetQualType(type));
result.addVolatile();
@@ -4311,7 +4478,7 @@ ClangASTContext::AddVolatileModifier(lldb::opaque_compiler_type_t type) {
}
CompilerType
-ClangASTContext::AddRestrictModifier(lldb::opaque_compiler_type_t type) {
+TypeSystemClang::AddRestrictModifier(lldb::opaque_compiler_type_t type) {
if (type) {
clang::QualType result(GetQualType(type));
result.addRestrict();
@@ -4320,23 +4487,23 @@ ClangASTContext::AddRestrictModifier(lldb::opaque_compiler_type_t type) {
return CompilerType();
}
-CompilerType
-ClangASTContext::CreateTypedef(lldb::opaque_compiler_type_t type,
- const char *typedef_name,
- const CompilerDeclContext &compiler_decl_ctx) {
+CompilerType TypeSystemClang::CreateTypedef(
+ lldb::opaque_compiler_type_t type, const char *typedef_name,
+ const CompilerDeclContext &compiler_decl_ctx, uint32_t payload) {
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)
+ TypeSystemClang::DeclContextGetAsDeclContext(compiler_decl_ctx);
+ if (!decl_ctx)
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));
+ SetOwningModule(decl, TypePayloadClang(payload).GetOwningModule());
clang::TagDecl *tdecl = nullptr;
if (!qual_type.isNull()) {
@@ -4361,10 +4528,10 @@ ClangASTContext::CreateTypedef(lldb::opaque_compiler_type_t type,
}
CompilerType
-ClangASTContext::GetTypedefedType(lldb::opaque_compiler_type_t type) {
+TypeSystemClang::GetTypedefedType(lldb::opaque_compiler_type_t type) {
if (type) {
- const clang::TypedefType *typedef_type =
- llvm::dyn_cast<clang::TypedefType>(GetQualType(type));
+ const clang::TypedefType *typedef_type = llvm::dyn_cast<clang::TypedefType>(
+ RemoveWrappingTypes(GetQualType(type), {clang::Type::Typedef}));
if (typedef_type)
return GetType(typedef_type->getDecl()->getUnderlyingType());
}
@@ -4373,13 +4540,13 @@ ClangASTContext::GetTypedefedType(lldb::opaque_compiler_type_t type) {
// Create related types using the current type's AST
-CompilerType ClangASTContext::GetBasicTypeFromAST(lldb::BasicType basic_type) {
- return ClangASTContext::GetBasicType(basic_type);
+CompilerType TypeSystemClang::GetBasicTypeFromAST(lldb::BasicType basic_type) {
+ return TypeSystemClang::GetBasicType(basic_type);
}
// Exploring the type
const llvm::fltSemantics &
-ClangASTContext::GetFloatTypeSemantics(size_t byte_size) {
+TypeSystemClang::GetFloatTypeSemantics(size_t byte_size) {
clang::ASTContext &ast = getASTContext();
const size_t bit_size = byte_size * 8;
if (bit_size == ast.getTypeSize(ast.FloatTy))
@@ -4394,7 +4561,7 @@ ClangASTContext::GetFloatTypeSemantics(size_t byte_size) {
}
Optional<uint64_t>
-ClangASTContext::GetBitSize(lldb::opaque_compiler_type_t type,
+TypeSystemClang::GetBitSize(lldb::opaque_compiler_type_t type,
ExecutionContextScope *exe_scope) {
if (GetCompleteType(type)) {
clang::QualType qual_type(GetCanonicalQualType(type));
@@ -4458,14 +4625,14 @@ ClangASTContext::GetBitSize(lldb::opaque_compiler_type_t type,
}
llvm::Optional<size_t>
-ClangASTContext::GetTypeBitAlign(lldb::opaque_compiler_type_t type,
+TypeSystemClang::GetTypeBitAlign(lldb::opaque_compiler_type_t type,
ExecutionContextScope *exe_scope) {
if (GetCompleteType(type))
return getASTContext().getTypeAlign(GetQualType(type));
return {};
}
-lldb::Encoding ClangASTContext::GetEncoding(lldb::opaque_compiler_type_t type,
+lldb::Encoding TypeSystemClang::GetEncoding(lldb::opaque_compiler_type_t type,
uint64_t &count) {
if (!type)
return lldb::eEncodingInvalid;
@@ -4504,6 +4671,11 @@ lldb::Encoding ClangASTContext::GetEncoding(lldb::opaque_compiler_type_t type,
// TODO: Set this to more than one???
break;
+ case clang::Type::ExtInt:
+ case clang::Type::DependentExtInt:
+ return qual_type->isUnsignedIntegerType() ? lldb::eEncodingUint
+ : lldb::eEncodingSint;
+
case clang::Type::Builtin:
switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) {
case clang::BuiltinType::Void:
@@ -4566,6 +4738,7 @@ lldb::Encoding ClangASTContext::GetEncoding(lldb::opaque_compiler_type_t type,
case clang::BuiltinType::Float128:
case clang::BuiltinType::Double:
case clang::BuiltinType::LongDouble:
+ case clang::BuiltinType::BFloat16:
return lldb::eEncodingIEEE754;
case clang::BuiltinType::ObjCClass:
@@ -4622,6 +4795,8 @@ lldb::Encoding ClangASTContext::GetEncoding(lldb::opaque_compiler_type_t type,
case clang::BuiltinType::Kind::OCLReserveID:
case clang::BuiltinType::Kind::OCLSampler:
case clang::BuiltinType::Kind::OMPArraySection:
+ case clang::BuiltinType::Kind::OMPArrayShaping:
+ case clang::BuiltinType::Kind::OMPIterator:
case clang::BuiltinType::Kind::Overload:
case clang::BuiltinType::Kind::PseudoObject:
case clang::BuiltinType::Kind::UnknownAny:
@@ -4643,16 +4818,56 @@ lldb::Encoding ClangASTContext::GetEncoding(lldb::opaque_compiler_type_t type,
case clang::BuiltinType::SveBool:
case clang::BuiltinType::SveInt8:
+ case clang::BuiltinType::SveInt8x2:
+ case clang::BuiltinType::SveInt8x3:
+ case clang::BuiltinType::SveInt8x4:
case clang::BuiltinType::SveInt16:
+ case clang::BuiltinType::SveInt16x2:
+ case clang::BuiltinType::SveInt16x3:
+ case clang::BuiltinType::SveInt16x4:
case clang::BuiltinType::SveInt32:
+ case clang::BuiltinType::SveInt32x2:
+ case clang::BuiltinType::SveInt32x3:
+ case clang::BuiltinType::SveInt32x4:
case clang::BuiltinType::SveInt64:
+ case clang::BuiltinType::SveInt64x2:
+ case clang::BuiltinType::SveInt64x3:
+ case clang::BuiltinType::SveInt64x4:
case clang::BuiltinType::SveUint8:
+ case clang::BuiltinType::SveUint8x2:
+ case clang::BuiltinType::SveUint8x3:
+ case clang::BuiltinType::SveUint8x4:
case clang::BuiltinType::SveUint16:
+ case clang::BuiltinType::SveUint16x2:
+ case clang::BuiltinType::SveUint16x3:
+ case clang::BuiltinType::SveUint16x4:
case clang::BuiltinType::SveUint32:
+ case clang::BuiltinType::SveUint32x2:
+ case clang::BuiltinType::SveUint32x3:
+ case clang::BuiltinType::SveUint32x4:
case clang::BuiltinType::SveUint64:
+ case clang::BuiltinType::SveUint64x2:
+ case clang::BuiltinType::SveUint64x3:
+ case clang::BuiltinType::SveUint64x4:
case clang::BuiltinType::SveFloat16:
+ case clang::BuiltinType::SveBFloat16:
+ case clang::BuiltinType::SveBFloat16x2:
+ case clang::BuiltinType::SveBFloat16x3:
+ case clang::BuiltinType::SveBFloat16x4:
+ case clang::BuiltinType::SveFloat16x2:
+ case clang::BuiltinType::SveFloat16x3:
+ case clang::BuiltinType::SveFloat16x4:
case clang::BuiltinType::SveFloat32:
+ case clang::BuiltinType::SveFloat32x2:
+ case clang::BuiltinType::SveFloat32x3:
+ case clang::BuiltinType::SveFloat32x4:
case clang::BuiltinType::SveFloat64:
+ case clang::BuiltinType::SveFloat64x2:
+ case clang::BuiltinType::SveFloat64x3:
+ case clang::BuiltinType::SveFloat64x4:
+ break;
+
+ case clang::BuiltinType::IncompleteMatrixIdx:
break;
}
break;
@@ -4716,12 +4931,16 @@ lldb::Encoding ClangASTContext::GetEncoding(lldb::opaque_compiler_type_t type,
break;
case clang::Type::MacroQualified:
break;
+
+ case clang::Type::ConstantMatrix:
+ case clang::Type::DependentSizedMatrix:
+ break;
}
count = 0;
return lldb::eEncodingInvalid;
}
-lldb::Format ClangASTContext::GetFormat(lldb::opaque_compiler_type_t type) {
+lldb::Format TypeSystemClang::GetFormat(lldb::opaque_compiler_type_t type) {
if (!type)
return lldb::eFormatDefault;
@@ -4756,9 +4975,13 @@ lldb::Format ClangASTContext::GetFormat(lldb::opaque_compiler_type_t type) {
case clang::Type::Vector:
break;
+ case clang::Type::ExtInt:
+ case clang::Type::DependentExtInt:
+ return qual_type->isUnsignedIntegerType() ? lldb::eFormatUnsigned
+ : lldb::eFormatDecimal;
+
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:
@@ -4858,6 +5081,11 @@ lldb::Format ClangASTContext::GetFormat(lldb::opaque_compiler_type_t type) {
break;
case clang::Type::MacroQualified:
break;
+
+ // Matrix types we're not sure how to display yet.
+ case clang::Type::ConstantMatrix:
+ case clang::Type::DependentSizedMatrix:
+ break;
}
// We don't know hot to display this type...
return lldb::eFormatBytes;
@@ -4878,7 +5106,7 @@ static bool ObjCDeclHasIVars(clang::ObjCInterfaceDecl *class_interface_decl,
}
static Optional<SymbolFile::ArrayInfo>
-GetDynamicArrayInfo(ClangASTContext &ast, SymbolFile *sym_file,
+GetDynamicArrayInfo(TypeSystemClang &ast, SymbolFile *sym_file,
clang::QualType qual_type,
const ExecutionContext *exe_ctx) {
if (qual_type->isIncompleteArrayType())
@@ -4888,7 +5116,7 @@ GetDynamicArrayInfo(ClangASTContext &ast, SymbolFile *sym_file,
return llvm::None;
}
-uint32_t ClangASTContext::GetNumChildren(lldb::opaque_compiler_type_t type,
+uint32_t TypeSystemClang::GetNumChildren(lldb::opaque_compiler_type_t type,
bool omit_empty_base_classes,
const ExecutionContext *exe_ctx) {
if (!type)
@@ -4937,7 +5165,7 @@ uint32_t ClangASTContext::GetNumChildren(lldb::opaque_compiler_type_t type,
->getDecl());
// Skip empty base classes
- if (!ClangASTContext::RecordHasFields(base_class_decl))
+ if (!TypeSystemClang::RecordHasFields(base_class_decl))
continue;
num_children++;
@@ -4983,12 +5211,15 @@ uint32_t ClangASTContext::GetNumChildren(lldb::opaque_compiler_type_t type,
}
break;
+ case clang::Type::LValueReference:
+ case clang::Type::RValueReference:
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 =
- GetType(pointee_type).GetNumChildren(omit_empty_base_classes, exe_ctx);
+ CompilerType pointee_clang_type(GetPointeeType(type));
+
+ uint32_t num_pointee_children = 0;
+ if (pointee_clang_type.IsAggregateType())
+ num_pointee_children =
+ pointee_clang_type.GetNumChildren(omit_empty_base_classes, exe_ctx);
// If this type points to a simple type, then it has 1 child
if (num_pointee_children == 0)
num_children = 1;
@@ -5020,8 +5251,11 @@ uint32_t ClangASTContext::GetNumChildren(lldb::opaque_compiler_type_t type,
const clang::PointerType *pointer_type =
llvm::cast<clang::PointerType>(qual_type.getTypePtr());
clang::QualType pointee_type(pointer_type->getPointeeType());
- uint32_t num_pointee_children =
- GetType(pointee_type).GetNumChildren(omit_empty_base_classes, exe_ctx);
+ CompilerType pointee_clang_type(GetType(pointee_type));
+ uint32_t num_pointee_children = 0;
+ if (pointee_clang_type.IsAggregateType())
+ num_pointee_children =
+ pointee_clang_type.GetNumChildren(omit_empty_base_classes, exe_ctx);
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
@@ -5030,32 +5264,18 @@ uint32_t ClangASTContext::GetNumChildren(lldb::opaque_compiler_type_t type,
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 =
- GetType(pointee_type).GetNumChildren(omit_empty_base_classes, exe_ctx);
- // 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;
-
default:
break;
}
return num_children;
}
-CompilerType ClangASTContext::GetBuiltinTypeByName(ConstString name) {
+CompilerType TypeSystemClang::GetBuiltinTypeByName(ConstString name) {
return GetBasicType(GetBasicTypeEnumeration(name));
}
lldb::BasicType
-ClangASTContext::GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) {
+TypeSystemClang::GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) {
if (type) {
clang::QualType qual_type(GetQualType(type));
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
@@ -5127,7 +5347,7 @@ ClangASTContext::GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) {
return eBasicTypeInvalid;
}
-void ClangASTContext::ForEachEnumerator(
+void TypeSystemClang::ForEachEnumerator(
lldb::opaque_compiler_type_t type,
std::function<bool(const CompilerType &integer_type,
ConstString name,
@@ -5153,7 +5373,7 @@ void ClangASTContext::ForEachEnumerator(
#pragma mark Aggregate Types
-uint32_t ClangASTContext::GetNumFields(lldb::opaque_compiler_type_t type) {
+uint32_t TypeSystemClang::GetNumFields(lldb::opaque_compiler_type_t type) {
if (!type)
return 0;
@@ -5270,7 +5490,7 @@ GetObjCFieldAtIndex(clang::ASTContext *ast,
return nullptr;
}
-CompilerType ClangASTContext::GetFieldAtIndex(lldb::opaque_compiler_type_t type,
+CompilerType TypeSystemClang::GetFieldAtIndex(lldb::opaque_compiler_type_t type,
size_t idx, std::string &name,
uint64_t *bit_offset_ptr,
uint32_t *bitfield_bit_size_ptr,
@@ -5373,7 +5593,7 @@ CompilerType ClangASTContext::GetFieldAtIndex(lldb::opaque_compiler_type_t type,
}
uint32_t
-ClangASTContext::GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) {
+TypeSystemClang::GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) {
uint32_t count = 0;
clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type));
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
@@ -5425,7 +5645,7 @@ ClangASTContext::GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) {
}
uint32_t
-ClangASTContext::GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) {
+TypeSystemClang::GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) {
uint32_t count = 0;
clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type));
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
@@ -5445,7 +5665,7 @@ ClangASTContext::GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) {
return count;
}
-CompilerType ClangASTContext::GetDirectBaseClassAtIndex(
+CompilerType TypeSystemClang::GetDirectBaseClassAtIndex(
lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) {
clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type));
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
@@ -5540,7 +5760,7 @@ CompilerType ClangASTContext::GetDirectBaseClassAtIndex(
return CompilerType();
}
-CompilerType ClangASTContext::GetVirtualBaseClassAtIndex(
+CompilerType TypeSystemClang::GetVirtualBaseClassAtIndex(
lldb::opaque_compiler_type_t type, size_t idx, uint32_t *bit_offset_ptr) {
clang::QualType qual_type = RemoveWrappingTypes(GetCanonicalQualType(type));
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
@@ -5588,7 +5808,7 @@ CompilerType ClangASTContext::GetVirtualBaseClassAtIndex(
// 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) {
+uint32_t TypeSystemClang::GetNumPointeeChildren(clang::QualType type) {
if (type.isNull())
return 0;
@@ -5721,7 +5941,7 @@ uint32_t ClangASTContext::GetNumPointeeChildren(clang::QualType type) {
return 0;
}
-CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
+CompilerType TypeSystemClang::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,
@@ -5791,7 +6011,7 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
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))
+ if (!TypeSystemClang::RecordHasFields(base_class_decl))
continue;
}
@@ -6068,7 +6288,7 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
if (array) {
CompilerType element_type = GetType(array->getElementType());
if (element_type.GetCompleteType()) {
- child_name = llvm::formatv("[{0}]", idx);
+ child_name = std::string(llvm::formatv("[{0}]", idx));
if (Optional<uint64_t> size =
element_type.GetByteSize(get_exe_scope())) {
child_byte_size = *size;
@@ -6170,11 +6390,6 @@ static uint32_t GetIndexForRecordBase(const clang::RecordDecl *record_decl,
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(),
@@ -6185,12 +6400,6 @@ static uint32_t GetIndexForRecordBase(const clang::RecordDecl *record_decl,
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;
@@ -6203,7 +6412,7 @@ static uint32_t GetIndexForRecordBase(const clang::RecordDecl *record_decl,
static uint32_t GetIndexForRecordChild(const clang::RecordDecl *record_decl,
clang::NamedDecl *canonical_decl,
bool omit_empty_base_classes) {
- uint32_t child_idx = ClangASTContext::GetNumBaseClasses(
+ uint32_t child_idx = TypeSystemClang::GetNumBaseClasses(
llvm::dyn_cast<clang::CXXRecordDecl>(record_decl),
omit_empty_base_classes);
@@ -6250,7 +6459,7 @@ static uint32_t GetIndexForRecordChild(const clang::RecordDecl *record_decl,
// 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(
+size_t TypeSystemClang::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]) {
@@ -6287,7 +6496,7 @@ size_t ClangASTContext::GetIndexOfChildMemberWithName(
} 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(
+ child_idx + TypeSystemClang::GetNumBaseClasses(
cxx_record_decl, omit_empty_base_classes));
return child_indexes.size();
}
@@ -6296,9 +6505,6 @@ size_t ClangASTContext::GetIndexOfChildMemberWithName(
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);
@@ -6445,7 +6651,7 @@ size_t ClangASTContext::GetIndexOfChildMemberWithName(
// clang::QualType pointee_type =
// mem_ptr_type->getPointeeType();
//
- // if (ClangASTContext::IsAggregateType
+ // if (TypeSystemClang::IsAggregateType
// (pointee_type.getAsOpaquePtr()))
// {
// return GetIndexOfChildWithName (ast,
@@ -6489,7 +6695,7 @@ size_t ClangASTContext::GetIndexOfChildMemberWithName(
// matches can include base class names.
uint32_t
-ClangASTContext::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
+TypeSystemClang::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
const char *name,
bool omit_empty_base_classes) {
if (type && name && name[0]) {
@@ -6523,7 +6729,7 @@ ClangASTContext::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
->getAs<clang::RecordType>()
->getDecl());
if (omit_empty_base_classes &&
- !ClangASTContext::RecordHasFields(base_class_decl))
+ !TypeSystemClang::RecordHasFields(base_class_decl))
continue;
CompilerType base_class_clang_type = GetType(base_class->getType());
@@ -6626,7 +6832,7 @@ ClangASTContext::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
// clang::QualType pointee_type =
// mem_ptr_type->getPointeeType();
//
- // if (ClangASTContext::IsAggregateType
+ // if (TypeSystemClang::IsAggregateType
// (pointee_type.getAsOpaquePtr()))
// {
// return GetIndexOfChildWithName (ast,
@@ -6684,7 +6890,7 @@ ClangASTContext::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
}
size_t
-ClangASTContext::GetNumTemplateArguments(lldb::opaque_compiler_type_t type) {
+TypeSystemClang::GetNumTemplateArguments(lldb::opaque_compiler_type_t type) {
if (!type)
return 0;
@@ -6713,7 +6919,7 @@ ClangASTContext::GetNumTemplateArguments(lldb::opaque_compiler_type_t type) {
}
const clang::ClassTemplateSpecializationDecl *
-ClangASTContext::GetAsTemplateSpecialization(
+TypeSystemClang::GetAsTemplateSpecialization(
lldb::opaque_compiler_type_t type) {
if (!type)
return nullptr;
@@ -6738,7 +6944,7 @@ ClangASTContext::GetAsTemplateSpecialization(
}
lldb::TemplateArgumentKind
-ClangASTContext::GetTemplateArgumentKind(lldb::opaque_compiler_type_t type,
+TypeSystemClang::GetTemplateArgumentKind(lldb::opaque_compiler_type_t type,
size_t arg_idx) {
const clang::ClassTemplateSpecializationDecl *template_decl =
GetAsTemplateSpecialization(type);
@@ -6777,7 +6983,7 @@ ClangASTContext::GetTemplateArgumentKind(lldb::opaque_compiler_type_t type,
}
CompilerType
-ClangASTContext::GetTypeTemplateArgument(lldb::opaque_compiler_type_t type,
+TypeSystemClang::GetTypeTemplateArgument(lldb::opaque_compiler_type_t type,
size_t idx) {
const clang::ClassTemplateSpecializationDecl *template_decl =
GetAsTemplateSpecialization(type);
@@ -6793,7 +6999,7 @@ ClangASTContext::GetTypeTemplateArgument(lldb::opaque_compiler_type_t type,
}
Optional<CompilerType::IntegralTemplateArgument>
-ClangASTContext::GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type,
+TypeSystemClang::GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type,
size_t idx) {
const clang::ClassTemplateSpecializationDecl *template_decl =
GetAsTemplateSpecialization(type);
@@ -6809,13 +7015,13 @@ ClangASTContext::GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type,
{template_arg.getAsIntegral(), GetType(template_arg.getIntegralType())}};
}
-CompilerType ClangASTContext::GetTypeForFormatters(void *type) {
+CompilerType TypeSystemClang::GetTypeForFormatters(void *type) {
if (type)
return ClangUtil::RemoveFastQualifiers(CompilerType(this, type));
return CompilerType();
}
-clang::EnumDecl *ClangASTContext::GetAsEnumDecl(const CompilerType &type) {
+clang::EnumDecl *TypeSystemClang::GetAsEnumDecl(const CompilerType &type) {
const clang::EnumType *enutype =
llvm::dyn_cast<clang::EnumType>(ClangUtil::GetCanonicalQualType(type));
if (enutype)
@@ -6823,7 +7029,7 @@ clang::EnumDecl *ClangASTContext::GetAsEnumDecl(const CompilerType &type) {
return nullptr;
}
-clang::RecordDecl *ClangASTContext::GetAsRecordDecl(const CompilerType &type) {
+clang::RecordDecl *TypeSystemClang::GetAsRecordDecl(const CompilerType &type) {
const clang::RecordType *record_type =
llvm::dyn_cast<clang::RecordType>(ClangUtil::GetCanonicalQualType(type));
if (record_type)
@@ -6831,12 +7037,12 @@ clang::RecordDecl *ClangASTContext::GetAsRecordDecl(const CompilerType &type) {
return nullptr;
}
-clang::TagDecl *ClangASTContext::GetAsTagDecl(const CompilerType &type) {
+clang::TagDecl *TypeSystemClang::GetAsTagDecl(const CompilerType &type) {
return ClangUtil::GetAsTagDecl(type);
}
clang::TypedefNameDecl *
-ClangASTContext::GetAsTypedefDecl(const CompilerType &type) {
+TypeSystemClang::GetAsTypedefDecl(const CompilerType &type) {
const clang::TypedefType *typedef_type =
llvm::dyn_cast<clang::TypedefType>(ClangUtil::GetQualType(type));
if (typedef_type)
@@ -6845,12 +7051,12 @@ ClangASTContext::GetAsTypedefDecl(const CompilerType &type) {
}
clang::CXXRecordDecl *
-ClangASTContext::GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type) {
+TypeSystemClang::GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type) {
return GetCanonicalQualType(type)->getAsCXXRecordDecl();
}
clang::ObjCInterfaceDecl *
-ClangASTContext::GetAsObjCInterfaceDecl(const CompilerType &type) {
+TypeSystemClang::GetAsObjCInterfaceDecl(const CompilerType &type) {
const clang::ObjCObjectType *objc_class_type =
llvm::dyn_cast<clang::ObjCObjectType>(
ClangUtil::GetCanonicalQualType(type));
@@ -6859,14 +7065,14 @@ ClangASTContext::GetAsObjCInterfaceDecl(const CompilerType &type) {
return nullptr;
}
-clang::FieldDecl *ClangASTContext::AddFieldToRecordType(
+clang::FieldDecl *TypeSystemClang::AddFieldToRecordType(
const CompilerType &type, llvm::StringRef 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());
+ TypeSystemClang *ast =
+ llvm::dyn_cast_or_null<TypeSystemClang>(type.GetTypeSystem());
if (!ast)
return nullptr;
clang::ASTContext &clang_ast = ast->getASTContext();
@@ -6887,15 +7093,13 @@ clang::FieldDecl *ClangASTContext::AddFieldToRecordType(
clang::RecordDecl *record_decl = ast->GetAsRecordDecl(type);
if (record_decl) {
- field = clang::FieldDecl::Create(
- clang_ast, record_decl, clang::SourceLocation(),
- clang::SourceLocation(),
- ident, // Identifier
- ClangUtil::GetQualType(field_clang_type), // Field type
- nullptr, // TInfo *
- bit_width, // BitWidth
- false, // Mutable
- clang::ICIS_NoInit); // HasInit
+ field = clang::FieldDecl::CreateDeserialized(clang_ast, 0);
+ field->setDeclContext(record_decl);
+ field->setDeclName(ident);
+ field->setType(ClangUtil::GetQualType(field_clang_type));
+ if (bit_width)
+ field->setBitWidth(bit_width);
+ SetMemberOwningModule(field, record_decl);
if (name.empty()) {
// Determine whether this field corresponds to an anonymous struct or
@@ -6913,13 +7117,11 @@ clang::FieldDecl *ClangASTContext::AddFieldToRecordType(
if (field) {
field->setAccess(
- ClangASTContext::ConvertAccessTypeToAccessSpecifier(access));
+ TypeSystemClang::ConvertAccessTypeToAccessSpecifier(access));
record_decl->addDecl(field);
-#ifdef LLDB_CONFIGURATION_DEBUG
VerifyDecl(field);
-#endif
}
} else {
clang::ObjCInterfaceDecl *class_interface_decl =
@@ -6930,32 +7132,32 @@ clang::FieldDecl *ClangASTContext::AddFieldToRecordType(
field_clang_type.GetCompleteType();
- field = clang::ObjCIvarDecl::Create(
- clang_ast, class_interface_decl, clang::SourceLocation(),
- clang::SourceLocation(),
- ident, // Identifier
- ClangUtil::GetQualType(field_clang_type), // Field type
- nullptr, // TypeSourceInfo *
- ConvertAccessTypeToObjCIvarAccessControl(access), bit_width,
- is_synthesized);
+ auto *ivar = clang::ObjCIvarDecl::CreateDeserialized(clang_ast, 0);
+ ivar->setDeclContext(class_interface_decl);
+ ivar->setDeclName(ident);
+ ivar->setType(ClangUtil::GetQualType(field_clang_type));
+ ivar->setAccessControl(ConvertAccessTypeToObjCIvarAccessControl(access));
+ if (bit_width)
+ ivar->setBitWidth(bit_width);
+ ivar->setSynthesize(is_synthesized);
+ field = ivar;
+ SetMemberOwningModule(field, class_interface_decl);
if (field) {
class_interface_decl->addDecl(field);
-#ifdef LLDB_CONFIGURATION_DEBUG
VerifyDecl(field);
-#endif
}
}
}
return field;
}
-void ClangASTContext::BuildIndirectFields(const CompilerType &type) {
+void TypeSystemClang::BuildIndirectFields(const CompilerType &type) {
if (!type)
return;
- ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
+ TypeSystemClang *ast = llvm::dyn_cast<TypeSystemClang>(type.GetTypeSystem());
if (!ast)
return;
@@ -7001,10 +7203,11 @@ void ClangASTContext::BuildIndirectFields(const CompilerType &type) {
ast->getASTContext(), record_decl, clang::SourceLocation(),
nested_field_decl->getIdentifier(),
nested_field_decl->getType(), {chain, 2});
+ SetMemberOwningModule(indirect_field, record_decl);
indirect_field->setImplicit();
- indirect_field->setAccess(ClangASTContext::UnifyAccessSpecifiers(
+ indirect_field->setAccess(TypeSystemClang::UnifyAccessSpecifiers(
field_pos->getAccess(), nested_field_decl->getAccess()));
indirect_fields.push_back(indirect_field);
@@ -7031,10 +7234,11 @@ void ClangASTContext::BuildIndirectFields(const CompilerType &type) {
nested_indirect_field_decl->getIdentifier(),
nested_indirect_field_decl->getType(),
{chain, nested_chain_size + 1});
+ SetMemberOwningModule(indirect_field, record_decl);
indirect_field->setImplicit();
- indirect_field->setAccess(ClangASTContext::UnifyAccessSpecifiers(
+ indirect_field->setAccess(TypeSystemClang::UnifyAccessSpecifiers(
field_pos->getAccess(), nested_indirect_field_decl->getAccess()));
indirect_fields.push_back(indirect_field);
@@ -7057,10 +7261,10 @@ void ClangASTContext::BuildIndirectFields(const CompilerType &type) {
}
}
-void ClangASTContext::SetIsPacked(const CompilerType &type) {
+void TypeSystemClang::SetIsPacked(const CompilerType &type) {
if (type) {
- ClangASTContext *ast =
- llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
+ TypeSystemClang *ast =
+ llvm::dyn_cast<TypeSystemClang>(type.GetTypeSystem());
if (ast) {
clang::RecordDecl *record_decl = GetAsRecordDecl(type);
@@ -7073,13 +7277,13 @@ void ClangASTContext::SetIsPacked(const CompilerType &type) {
}
}
-clang::VarDecl *ClangASTContext::AddVariableToRecordType(
+clang::VarDecl *TypeSystemClang::AddVariableToRecordType(
const CompilerType &type, llvm::StringRef name,
const CompilerType &var_type, AccessType access) {
if (!type.IsValid() || !var_type.IsValid())
return nullptr;
- ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
+ TypeSystemClang *ast = llvm::dyn_cast<TypeSystemClang>(type.GetTypeSystem());
if (!ast)
return nullptr;
@@ -7092,30 +7296,54 @@ clang::VarDecl *ClangASTContext::AddVariableToRecordType(
if (!name.empty())
ident = &ast->getASTContext().Idents.get(name);
- var_decl = clang::VarDecl::Create(
- ast->getASTContext(), // ASTContext &
- record_decl, // DeclContext *
- clang::SourceLocation(), // clang::SourceLocation StartLoc
- clang::SourceLocation(), // clang::SourceLocation IdLoc
- ident, // clang::IdentifierInfo *
- ClangUtil::GetQualType(var_type), // Variable clang::QualType
- nullptr, // TypeSourceInfo *
- clang::SC_Static); // StorageClass
+ var_decl = clang::VarDecl::CreateDeserialized(ast->getASTContext(), 0);
+ var_decl->setDeclContext(record_decl);
+ var_decl->setDeclName(ident);
+ var_decl->setType(ClangUtil::GetQualType(var_type));
+ var_decl->setStorageClass(clang::SC_Static);
+ SetMemberOwningModule(var_decl, record_decl);
if (!var_decl)
return nullptr;
var_decl->setAccess(
- ClangASTContext::ConvertAccessTypeToAccessSpecifier(access));
+ TypeSystemClang::ConvertAccessTypeToAccessSpecifier(access));
record_decl->addDecl(var_decl);
-#ifdef LLDB_CONFIGURATION_DEBUG
VerifyDecl(var_decl);
-#endif
return var_decl;
}
-clang::CXXMethodDecl *ClangASTContext::AddMethodToCXXRecordType(
+void TypeSystemClang::SetIntegerInitializerForVariable(
+ VarDecl *var, const llvm::APInt &init_value) {
+ assert(!var->hasInit() && "variable already initialized");
+
+ clang::ASTContext &ast = var->getASTContext();
+ QualType qt = var->getType();
+ assert(qt->isIntegralOrEnumerationType() &&
+ "only integer or enum types supported");
+ // If the variable is an enum type, take the underlying integer type as
+ // the type of the integer literal.
+ if (const EnumType *enum_type = llvm::dyn_cast<EnumType>(qt.getTypePtr())) {
+ const EnumDecl *enum_decl = enum_type->getDecl();
+ qt = enum_decl->getIntegerType();
+ }
+ var->setInit(IntegerLiteral::Create(ast, init_value, qt.getUnqualifiedType(),
+ SourceLocation()));
+}
+
+void TypeSystemClang::SetFloatingInitializerForVariable(
+ clang::VarDecl *var, const llvm::APFloat &init_value) {
+ assert(!var->hasInit() && "variable already initialized");
+
+ clang::ASTContext &ast = var->getASTContext();
+ QualType qt = var->getType();
+ assert(qt->isFloatingType() && "only floating point types supported");
+ var->setInit(FloatingLiteral::Create(
+ ast, init_value, true, qt.getUnqualifiedType(), SourceLocation()));
+}
+
+clang::CXXMethodDecl *TypeSystemClang::AddMethodToCXXRecordType(
lldb::opaque_compiler_type_t type, llvm::StringRef name,
const char *mangled_name, const CompilerType &method_clang_type,
lldb::AccessType access, bool is_virtual, bool is_static, bool is_inline,
@@ -7158,29 +7386,34 @@ clang::CXXMethodDecl *ClangASTContext::AddMethodToCXXRecordType(
return nullptr; // skip everything artificial
const clang::ExplicitSpecifier explicit_spec(
- nullptr /*expr*/, is_explicit
- ? clang::ExplicitSpecKind::ResolvedTrue
- : clang::ExplicitSpecKind::ResolvedFalse);
+ nullptr /*expr*/, is_explicit ? clang::ExplicitSpecKind::ResolvedTrue
+ : clang::ExplicitSpecKind::ResolvedFalse);
+
if (name.startswith("~")) {
- 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,
- ConstexprSpecKind::CSK_unspecified);
+ cxx_dtor_decl =
+ clang::CXXDestructorDecl::CreateDeserialized(getASTContext(), 0);
+ cxx_dtor_decl->setDeclContext(cxx_record_decl);
+ cxx_dtor_decl->setDeclName(
+ getASTContext().DeclarationNames.getCXXDestructorName(
+ getASTContext().getCanonicalType(record_qual_type)));
+ cxx_dtor_decl->setType(method_qual_type);
+ cxx_dtor_decl->setImplicit(is_artificial);
+ cxx_dtor_decl->setInlineSpecified(is_inline);
+ cxx_dtor_decl->setConstexprKind(CSK_unspecified);
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 *
- explicit_spec, is_inline, is_artificial, CSK_unspecified);
+ cxx_ctor_decl = clang::CXXConstructorDecl::CreateDeserialized(
+ getASTContext(), 0, 0);
+ cxx_ctor_decl->setDeclContext(cxx_record_decl);
+ cxx_ctor_decl->setDeclName(
+ getASTContext().DeclarationNames.getCXXConstructorName(
+ getASTContext().getCanonicalType(record_qual_type)));
+ cxx_ctor_decl->setType(method_qual_type);
+ cxx_ctor_decl->setImplicit(is_artificial);
+ cxx_ctor_decl->setInlineSpecified(is_inline);
+ cxx_ctor_decl->setConstexprKind(CSK_unspecified);
+ cxx_ctor_decl->setNumCtorInitializers(0);
+ cxx_ctor_decl->setExplicitSpecifier(explicit_spec);
cxx_method_decl = cxx_ctor_decl;
} else {
clang::StorageClass SC = is_static ? clang::SC_Static : clang::SC_None;
@@ -7193,44 +7426,50 @@ clang::CXXMethodDecl *ClangASTContext::AddMethodToCXXRecordType(
// create a method and add it to the class, clang will assert and
// crash, so we need to make sure things are acceptable.
const bool is_method = true;
- if (!ClangASTContext::CheckOverloadedOperatorKindParameterCount(
+ if (!TypeSystemClang::CheckOverloadedOperatorKindParameterCount(
is_method, 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, CSK_unspecified, clang::SourceLocation());
+ cxx_method_decl =
+ clang::CXXMethodDecl::CreateDeserialized(getASTContext(), 0);
+ cxx_method_decl->setDeclContext(cxx_record_decl);
+ cxx_method_decl->setDeclName(
+ getASTContext().DeclarationNames.getCXXOperatorName(op_kind));
+ cxx_method_decl->setType(method_qual_type);
+ cxx_method_decl->setStorageClass(SC);
+ cxx_method_decl->setInlineSpecified(is_inline);
+ cxx_method_decl->setConstexprKind(CSK_unspecified);
} 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, explicit_spec, CSK_unspecified, clang::SourceLocation());
+ auto *cxx_conversion_decl =
+ clang::CXXConversionDecl::CreateDeserialized(getASTContext(), 0);
+ cxx_conversion_decl->setDeclContext(cxx_record_decl);
+ cxx_conversion_decl->setDeclName(
+ getASTContext().DeclarationNames.getCXXConversionFunctionName(
+ getASTContext().getCanonicalType(
+ function_type->getReturnType())));
+ cxx_conversion_decl->setType(method_qual_type);
+ cxx_conversion_decl->setInlineSpecified(is_inline);
+ cxx_conversion_decl->setExplicitSpecifier(explicit_spec);
+ cxx_conversion_decl->setConstexprKind(CSK_unspecified);
+ cxx_method_decl = cxx_conversion_decl;
}
}
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, CSK_unspecified, clang::SourceLocation());
+ cxx_method_decl =
+ clang::CXXMethodDecl::CreateDeserialized(getASTContext(), 0);
+ cxx_method_decl->setDeclContext(cxx_record_decl);
+ cxx_method_decl->setDeclName(decl_name);
+ cxx_method_decl->setType(method_qual_type);
+ cxx_method_decl->setInlineSpecified(is_inline);
+ cxx_method_decl->setStorageClass(SC);
+ cxx_method_decl->setConstexprKind(CSK_unspecified);
}
}
+ SetMemberOwningModule(cxx_method_decl, cxx_record_decl);
clang::AccessSpecifier access_specifier =
- ClangASTContext::ConvertAccessTypeToAccessSpecifier(access);
+ TypeSystemClang::ConvertAccessTypeToAccessSpecifier(access);
cxx_method_decl->setAccess(access_specifier);
cxx_method_decl->setVirtualAsWritten(is_virtual);
@@ -7290,14 +7529,12 @@ clang::CXXMethodDecl *ClangASTContext::AddMethodToCXXRecordType(
}
}
-#ifdef LLDB_CONFIGURATION_DEBUG
VerifyDecl(cxx_method_decl);
-#endif
return cxx_method_decl;
}
-void ClangASTContext::AddMethodOverridesForCXXRecordType(
+void TypeSystemClang::AddMethodOverridesForCXXRecordType(
lldb::opaque_compiler_type_t type) {
if (auto *record = GetAsCXXRecordDecl(type))
for (auto *method : record->methods())
@@ -7307,7 +7544,7 @@ void ClangASTContext::AddMethodOverridesForCXXRecordType(
#pragma mark C++ Base Classes
std::unique_ptr<clang::CXXBaseSpecifier>
-ClangASTContext::CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type,
+TypeSystemClang::CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type,
AccessType access, bool is_virtual,
bool base_of_class) {
if (!type)
@@ -7315,12 +7552,12 @@ ClangASTContext::CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type,
return std::make_unique<clang::CXXBaseSpecifier>(
clang::SourceRange(), is_virtual, base_of_class,
- ClangASTContext::ConvertAccessTypeToAccessSpecifier(access),
+ TypeSystemClang::ConvertAccessTypeToAccessSpecifier(access),
getASTContext().getTrivialTypeSourceInfo(GetQualType(type)),
clang::SourceLocation());
}
-bool ClangASTContext::TransferBaseClasses(
+bool TypeSystemClang::TransferBaseClasses(
lldb::opaque_compiler_type_t type,
std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases) {
if (!type)
@@ -7339,10 +7576,10 @@ bool ClangASTContext::TransferBaseClasses(
return true;
}
-bool ClangASTContext::SetObjCSuperClass(
+bool TypeSystemClang::SetObjCSuperClass(
const CompilerType &type, const CompilerType &superclass_clang_type) {
- ClangASTContext *ast =
- llvm::dyn_cast_or_null<ClangASTContext>(type.GetTypeSystem());
+ TypeSystemClang *ast =
+ llvm::dyn_cast_or_null<TypeSystemClang>(type.GetTypeSystem());
if (!ast)
return false;
clang::ASTContext &clang_ast = ast->getASTContext();
@@ -7362,7 +7599,7 @@ bool ClangASTContext::SetObjCSuperClass(
return false;
}
-bool ClangASTContext::AddObjCClassProperty(
+bool TypeSystemClang::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,
@@ -7370,7 +7607,7 @@ bool ClangASTContext::AddObjCClassProperty(
if (!type || !property_clang_type.IsValid() || property_name == nullptr ||
property_name[0] == '\0')
return false;
- ClangASTContext *ast = llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
+ TypeSystemClang *ast = llvm::dyn_cast<TypeSystemClang>(type.GetTypeSystem());
if (!ast)
return false;
clang::ASTContext &clang_ast = ast->getASTContext();
@@ -7396,15 +7633,15 @@ bool ClangASTContext::AddObjCClassProperty(
prop_type_source = clang_ast.getTrivialTypeSourceInfo(
ClangUtil::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()
- : ClangUtil::GetQualType(property_clang_type),
- prop_type_source);
+ clang::ObjCPropertyDecl *property_decl =
+ clang::ObjCPropertyDecl::CreateDeserialized(clang_ast, 0);
+ property_decl->setDeclContext(class_interface_decl);
+ property_decl->setDeclName(&clang_ast.Idents.get(property_name));
+ property_decl->setType(ivar_decl
+ ? ivar_decl->getType()
+ : ClangUtil::GetQualType(property_clang_type),
+ prop_type_source);
+ SetMemberOwningModule(property_decl, class_interface_decl);
if (!property_decl)
return false;
@@ -7431,7 +7668,7 @@ bool ClangASTContext::AddObjCClassProperty(
setter_sel = clang_ast.Selectors.getSelector(1, &setter_ident);
}
property_decl->setSetterName(setter_sel);
- property_decl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_setter);
+ property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_setter);
if (property_getter_name != nullptr) {
clang::IdentifierInfo *getter_ident =
@@ -7442,33 +7679,34 @@ bool ClangASTContext::AddObjCClassProperty(
getter_sel = clang_ast.Selectors.getSelector(0, &getter_ident);
}
property_decl->setGetterName(getter_sel);
- property_decl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_getter);
+ property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_getter);
if (ivar_decl)
property_decl->setPropertyIvarDecl(ivar_decl);
if (property_attributes & DW_APPLE_PROPERTY_readonly)
- property_decl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_readonly);
+ property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readonly);
if (property_attributes & DW_APPLE_PROPERTY_readwrite)
- property_decl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_readwrite);
+ property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_readwrite);
if (property_attributes & DW_APPLE_PROPERTY_assign)
- property_decl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_assign);
+ property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_assign);
if (property_attributes & DW_APPLE_PROPERTY_retain)
- property_decl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_retain);
+ property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_retain);
if (property_attributes & DW_APPLE_PROPERTY_copy)
- property_decl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_copy);
+ property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_copy);
if (property_attributes & DW_APPLE_PROPERTY_nonatomic)
- property_decl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_nonatomic);
- if (property_attributes & ObjCPropertyDecl::OBJC_PR_nullability)
- property_decl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_nullability);
- if (property_attributes & ObjCPropertyDecl::OBJC_PR_null_resettable)
+ property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_nonatomic);
+ if (property_attributes & ObjCPropertyAttribute::kind_nullability)
+ property_decl->setPropertyAttributes(
+ ObjCPropertyAttribute::kind_nullability);
+ if (property_attributes & ObjCPropertyAttribute::kind_null_resettable)
property_decl->setPropertyAttributes(
- ObjCPropertyDecl::OBJC_PR_null_resettable);
- if (property_attributes & ObjCPropertyDecl::OBJC_PR_class)
- property_decl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_class);
+ ObjCPropertyAttribute::kind_null_resettable);
+ if (property_attributes & ObjCPropertyAttribute::kind_class)
+ property_decl->setPropertyAttributes(ObjCPropertyAttribute::kind_class);
const bool isInstance =
- (property_attributes & ObjCPropertyDecl::OBJC_PR_class) == 0;
+ (property_attributes & ObjCPropertyAttribute::kind_class) == 0;
clang::ObjCMethodDecl *getter = nullptr;
if (!getter_sel.isNull())
@@ -7476,7 +7714,7 @@ bool ClangASTContext::AddObjCClassProperty(
: class_interface_decl->lookupClassMethod(getter_sel);
if (!getter_sel.isNull() && !getter) {
const bool isVariadic = false;
- const bool isPropertyAccessor = false;
+ const bool isPropertyAccessor = true;
const bool isSynthesizedAccessorStub = false;
const bool isImplicitlyDeclared = true;
const bool isDefined = false;
@@ -7484,12 +7722,19 @@ bool ClangASTContext::AddObjCClassProperty(
clang::ObjCMethodDecl::None;
const bool HasRelatedResultType = false;
- getter = clang::ObjCMethodDecl::Create(
- clang_ast, clang::SourceLocation(), clang::SourceLocation(), getter_sel,
- ClangUtil::GetQualType(property_clang_type_to_access), nullptr,
- class_interface_decl, isInstance, isVariadic, isPropertyAccessor,
- isSynthesizedAccessorStub, isImplicitlyDeclared, isDefined, impControl,
- HasRelatedResultType);
+ getter = clang::ObjCMethodDecl::CreateDeserialized(clang_ast, 0);
+ getter->setDeclName(getter_sel);
+ getter->setReturnType(ClangUtil::GetQualType(property_clang_type_to_access));
+ getter->setDeclContext(class_interface_decl);
+ getter->setInstanceMethod(isInstance);
+ getter->setVariadic(isVariadic);
+ getter->setPropertyAccessor(isPropertyAccessor);
+ getter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
+ getter->setImplicit(isImplicitlyDeclared);
+ getter->setDefined(isDefined);
+ getter->setDeclImplementation(impControl);
+ getter->setRelatedResultType(HasRelatedResultType);
+ SetMemberOwningModule(getter, class_interface_decl);
if (getter) {
if (metadata)
@@ -7519,11 +7764,19 @@ bool ClangASTContext::AddObjCClassProperty(
clang::ObjCMethodDecl::None;
const bool HasRelatedResultType = false;
- setter = clang::ObjCMethodDecl::Create(
- clang_ast, clang::SourceLocation(), clang::SourceLocation(), setter_sel,
- result_type, nullptr, class_interface_decl, isInstance, isVariadic,
- isPropertyAccessor, isSynthesizedAccessorStub, isImplicitlyDeclared,
- isDefined, impControl, HasRelatedResultType);
+ setter = clang::ObjCMethodDecl::CreateDeserialized(clang_ast, 0);
+ setter->setDeclName(setter_sel);
+ setter->setReturnType(result_type);
+ setter->setDeclContext(class_interface_decl);
+ setter->setInstanceMethod(isInstance);
+ setter->setVariadic(isVariadic);
+ setter->setPropertyAccessor(isPropertyAccessor);
+ setter->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
+ setter->setImplicit(isImplicitlyDeclared);
+ setter->setDefined(isDefined);
+ setter->setDeclImplementation(impControl);
+ setter->setRelatedResultType(HasRelatedResultType);
+ SetMemberOwningModule(setter, class_interface_decl);
if (setter) {
if (metadata)
@@ -7551,7 +7804,7 @@ bool ClangASTContext::AddObjCClassProperty(
return true;
}
-bool ClangASTContext::IsObjCClassTypeAndHasIVars(const CompilerType &type,
+bool TypeSystemClang::IsObjCClassTypeAndHasIVars(const CompilerType &type,
bool check_superclass) {
clang::ObjCInterfaceDecl *class_interface_decl = GetAsObjCInterfaceDecl(type);
if (class_interface_decl)
@@ -7559,7 +7812,7 @@ bool ClangASTContext::IsObjCClassTypeAndHasIVars(const CompilerType &type,
return false;
}
-clang::ObjCMethodDecl *ClangASTContext::AddMethodToObjCObjectType(
+clang::ObjCMethodDecl *TypeSystemClang::AddMethodToObjCObjectType(
const CompilerType &type,
const char *name, // the full symbol name as seen in the symbol table
// (lldb::opaque_compiler_type_t type, "-[NString
@@ -7573,8 +7826,8 @@ clang::ObjCMethodDecl *ClangASTContext::AddMethodToObjCObjectType(
if (class_interface_decl == nullptr)
return nullptr;
- ClangASTContext *lldb_ast =
- llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
+ TypeSystemClang *lldb_ast =
+ llvm::dyn_cast<TypeSystemClang>(type.GetTypeSystem());
if (lldb_ast == nullptr)
return nullptr;
clang::ASTContext &ast = lldb_ast->getASTContext();
@@ -7588,7 +7841,6 @@ clang::ObjCMethodDecl *ClangASTContext::AddMethodToObjCObjectType(
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 != ']';
@@ -7640,15 +7892,20 @@ clang::ObjCMethodDecl *ClangASTContext::AddMethodToObjCObjectType(
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,
- lldb_ast->GetDeclContextForType(ClangUtil::GetQualType(type)), isInstance,
- isVariadic, isPropertyAccessor, isSynthesizedAccessorStub,
- isImplicitlyDeclared, isDefined, impControl, HasRelatedResultType);
+ auto *objc_method_decl = clang::ObjCMethodDecl::CreateDeserialized(ast, 0);
+ objc_method_decl->setDeclName(method_selector);
+ objc_method_decl->setReturnType(method_function_prototype->getReturnType());
+ objc_method_decl->setDeclContext(
+ lldb_ast->GetDeclContextForType(ClangUtil::GetQualType(type)));
+ objc_method_decl->setInstanceMethod(isInstance);
+ objc_method_decl->setVariadic(isVariadic);
+ objc_method_decl->setPropertyAccessor(isPropertyAccessor);
+ objc_method_decl->setSynthesizedAccessorStub(isSynthesizedAccessorStub);
+ objc_method_decl->setImplicit(isImplicitlyDeclared);
+ objc_method_decl->setDefined(isDefined);
+ objc_method_decl->setDeclImplementation(impControl);
+ objc_method_decl->setRelatedResultType(HasRelatedResultType);
+ SetMemberOwningModule(objc_method_decl, class_interface_decl);
if (objc_method_decl == nullptr)
return nullptr;
@@ -7684,14 +7941,12 @@ clang::ObjCMethodDecl *ClangASTContext::AddMethodToObjCObjectType(
class_interface_decl->addDecl(objc_method_decl);
-#ifdef LLDB_CONFIGURATION_DEBUG
VerifyDecl(objc_method_decl);
-#endif
return objc_method_decl;
}
-bool ClangASTContext::SetHasExternalStorage(lldb::opaque_compiler_type_t type,
+bool TypeSystemClang::SetHasExternalStorage(lldb::opaque_compiler_type_t type,
bool has_extern) {
if (!type)
return false;
@@ -7744,7 +7999,7 @@ bool ClangASTContext::SetHasExternalStorage(lldb::opaque_compiler_type_t type,
#pragma mark TagDecl
-bool ClangASTContext::StartTagDeclarationDefinition(const CompilerType &type) {
+bool TypeSystemClang::StartTagDeclarationDefinition(const CompilerType &type) {
clang::QualType qual_type(ClangUtil::GetQualType(type));
if (!qual_type.isNull()) {
const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
@@ -7769,20 +8024,37 @@ bool ClangASTContext::StartTagDeclarationDefinition(const CompilerType &type) {
return false;
}
-bool ClangASTContext::CompleteTagDeclarationDefinition(
+bool TypeSystemClang::CompleteTagDeclarationDefinition(
const CompilerType &type) {
clang::QualType qual_type(ClangUtil::GetQualType(type));
if (qual_type.isNull())
return false;
// Make sure we use the same methodology as
- // ClangASTContext::StartTagDeclarationDefinition() as to how we start/end
+ // TypeSystemClang::StartTagDeclarationDefinition() as to how we start/end
// the definition.
const clang::TagType *tag_type = qual_type->getAs<clang::TagType>();
if (tag_type) {
clang::TagDecl *tag_decl = tag_type->getDecl();
if (auto *cxx_record_decl = llvm::dyn_cast<CXXRecordDecl>(tag_decl)) {
+ // If we have a move constructor declared but no copy constructor we
+ // need to explicitly mark it as deleted. Usually Sema would do this for
+ // us in Sema::DeclareImplicitCopyConstructor but we don't have a Sema
+ // when building an AST from debug information.
+ // See also:
+ // C++11 [class.copy]p7, p18:
+ // If the class definition declares a move constructor or move assignment
+ // operator, an implicitly declared copy constructor or copy assignment
+ // operator is defined as deleted.
+ if (cxx_record_decl->hasUserDeclaredMoveConstructor() ||
+ cxx_record_decl->hasUserDeclaredMoveAssignment()) {
+ if (cxx_record_decl->needsImplicitCopyConstructor())
+ cxx_record_decl->setImplicitCopyConstructorIsDeleted();
+ if (cxx_record_decl->needsImplicitCopyAssignment())
+ cxx_record_decl->setImplicitCopyAssignmentIsDeleted();
+ }
+
if (!cxx_record_decl->isCompleteDefinition())
cxx_record_decl->completeDefinition();
cxx_record_decl->setHasLoadedFieldsFromExternalStorage(true);
@@ -7801,8 +8073,8 @@ bool ClangASTContext::CompleteTagDeclarationDefinition(
if (enum_decl->isCompleteDefinition())
return true;
- ClangASTContext *lldb_ast =
- llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
+ TypeSystemClang *lldb_ast =
+ llvm::dyn_cast<TypeSystemClang>(type.GetTypeSystem());
if (lldb_ast == nullptr)
return false;
clang::ASTContext &ast = lldb_ast->getASTContext();
@@ -7833,7 +8105,7 @@ bool ClangASTContext::CompleteTagDeclarationDefinition(
return true;
}
-clang::EnumConstantDecl *ClangASTContext::AddEnumerationValueToEnumerationType(
+clang::EnumConstantDecl *TypeSystemClang::AddEnumerationValueToEnumerationType(
const CompilerType &enum_type, const Declaration &decl, const char *name,
const llvm::APSInt &value) {
@@ -7861,28 +8133,28 @@ clang::EnumConstantDecl *ClangASTContext::AddEnumerationValueToEnumerationType(
if (!enutype)
return nullptr;
- clang::EnumConstantDecl *enumerator_decl = clang::EnumConstantDecl::Create(
- getASTContext(), enutype->getDecl(), clang::SourceLocation(),
- name ? &getASTContext().Idents.get(name) : nullptr, // Identifier
- clang::QualType(enutype, 0), nullptr, value);
+ clang::EnumConstantDecl *enumerator_decl =
+ clang::EnumConstantDecl::CreateDeserialized(getASTContext(), 0);
+ enumerator_decl->setDeclContext(enutype->getDecl());
+ if (name && name[0])
+ enumerator_decl->setDeclName(&getASTContext().Idents.get(name));
+ enumerator_decl->setType(clang::QualType(enutype, 0));
+ enumerator_decl->setInitVal(value);
+ SetMemberOwningModule(enumerator_decl, enutype->getDecl());
if (!enumerator_decl)
return nullptr;
enutype->getDecl()->addDecl(enumerator_decl);
-#ifdef LLDB_CONFIGURATION_DEBUG
VerifyDecl(enumerator_decl);
-#endif
-
return enumerator_decl;
}
-clang::EnumConstantDecl *ClangASTContext::AddEnumerationValueToEnumerationType(
+clang::EnumConstantDecl *TypeSystemClang::AddEnumerationValueToEnumerationType(
const CompilerType &enum_type, const Declaration &decl, const char *name,
int64_t enum_value, uint32_t enum_value_bit_size) {
- CompilerType underlying_type =
- GetEnumerationIntegerType(enum_type.GetOpaqueQualType());
+ CompilerType underlying_type = GetEnumerationIntegerType(enum_type);
bool is_signed = false;
underlying_type.IsIntegerType(is_signed);
@@ -7892,29 +8164,23 @@ clang::EnumConstantDecl *ClangASTContext::AddEnumerationValueToEnumerationType(
return AddEnumerationValueToEnumerationType(enum_type, decl, name, value);
}
-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 GetType(enum_decl->getIntegerType());
- }
- }
- return CompilerType();
+CompilerType TypeSystemClang::GetEnumerationIntegerType(CompilerType type) {
+ clang::QualType qt(ClangUtil::GetQualType(type));
+ const clang::Type *clang_type = qt.getTypePtrOrNull();
+ const auto *enum_type = llvm::dyn_cast_or_null<clang::EnumType>(clang_type);
+ if (!enum_type)
+ return CompilerType();
+
+ return GetType(enum_type->getDecl()->getIntegerType());
}
CompilerType
-ClangASTContext::CreateMemberPointerType(const CompilerType &type,
+TypeSystemClang::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());
+ TypeSystemClang *ast =
+ llvm::dyn_cast<TypeSystemClang>(type.GetTypeSystem());
if (!ast)
return CompilerType();
return ast->GetType(ast->getASTContext().getMemberPointerType(
@@ -7929,7 +8195,7 @@ ClangASTContext::CreateMemberPointerType(const CompilerType &type,
#ifndef NDEBUG
LLVM_DUMP_METHOD void
-ClangASTContext::dump(lldb::opaque_compiler_type_t type) const {
+TypeSystemClang::dump(lldb::opaque_compiler_type_t type) const {
if (!type)
return;
clang::QualType qual_type(GetQualType(type));
@@ -7937,12 +8203,12 @@ ClangASTContext::dump(lldb::opaque_compiler_type_t type) const {
}
#endif
-void ClangASTContext::Dump(Stream &s) {
+void TypeSystemClang::Dump(Stream &s) {
Decl *tu = Decl::castFromDeclContext(GetTranslationUnitDecl());
tu->dump(s.AsRawOstream());
}
-void ClangASTContext::DumpFromSymbolFile(Stream &s,
+void TypeSystemClang::DumpFromSymbolFile(Stream &s,
llvm::StringRef symbol_name) {
SymbolFile *symfile = GetSymbolFile();
@@ -7978,11 +8244,12 @@ void ClangASTContext::DumpFromSymbolFile(Stream &s,
continue;
}
}
- GetCanonicalQualType(full_type.GetOpaqueQualType()).dump(s.AsRawOstream());
+ GetCanonicalQualType(full_type.GetOpaqueQualType())
+ .dump(s.AsRawOstream(), getASTContext());
}
}
-void ClangASTContext::DumpValue(
+void TypeSystemClang::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,
@@ -8019,7 +8286,7 @@ void ClangASTContext::DumpValue(
base_class->getType()->getAs<clang::RecordType>()->getDecl());
// Skip empty base classes
- if (!verbose && !ClangASTContext::RecordHasFields(base_class_decl))
+ if (!verbose && !TypeSystemClang::RecordHasFields(base_class_decl))
continue;
if (base_class->isVirtual())
@@ -8374,10 +8641,10 @@ static bool DumpEnumValue(const clang::QualType &qual_type, Stream *s,
// Try to find an exact match for the value.
// At the same time, we're applying a heuristic to determine whether we want
// to print this enum as a bitfield. We're likely dealing with a bitfield if
- // every enumrator is either a one bit value or a superset of the previous
+ // every enumerator is either a one bit value or a superset of the previous
// enumerators. Also 0 doesn't make sense when the enumerators are used as
// flags.
- for (auto enumerator : enum_decl->enumerators()) {
+ for (auto *enumerator : enum_decl->enumerators()) {
uint64_t val = enumerator->getInitVal().getSExtValue();
val = llvm::SignExtend64(val, 8*byte_size);
if (llvm::countPopulation(val) != 1 && (val & ~covered_bits) != 0)
@@ -8409,7 +8676,7 @@ static bool DumpEnumValue(const clang::QualType &qual_type, Stream *s,
uint64_t remaining_value = enum_uvalue;
std::vector<std::pair<uint64_t, llvm::StringRef>> values;
values.reserve(num_enumerators);
- for (auto enumerator : enum_decl->enumerators())
+ for (auto *enumerator : enum_decl->enumerators())
if (auto val = enumerator->getInitVal().getZExtValue())
values.emplace_back(val, enumerator->getName());
@@ -8436,7 +8703,7 @@ static bool DumpEnumValue(const clang::QualType &qual_type, Stream *s,
return true;
}
-bool ClangASTContext::DumpTypeValue(
+bool TypeSystemClang::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,
@@ -8559,7 +8826,7 @@ bool ClangASTContext::DumpTypeValue(
return false;
}
-void ClangASTContext::DumpSummary(lldb::opaque_compiler_type_t type,
+void TypeSystemClang::DumpSummary(lldb::opaque_compiler_type_t type,
ExecutionContext *exe_ctx, Stream *s,
const lldb_private::DataExtractor &data,
lldb::offset_t data_byte_offset,
@@ -8604,9 +8871,10 @@ void ClangASTContext::DumpSummary(lldb::opaque_compiler_type_t type,
}
}
-void ClangASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type) {
+void TypeSystemClang::DumpTypeDescription(lldb::opaque_compiler_type_t type,
+ lldb::DescriptionLevel level) {
StreamFile s(stdout, false);
- DumpTypeDescription(type, &s);
+ DumpTypeDescription(type, &s, level);
CompilerType ct(this, type);
const clang::Type *clang_type = ClangUtil::GetQualType(ct).getTypePtr();
@@ -8616,8 +8884,9 @@ void ClangASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type) {
}
}
-void ClangASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type,
- Stream *s) {
+void TypeSystemClang::DumpTypeDescription(lldb::opaque_compiler_type_t type,
+ Stream *s,
+ lldb::DescriptionLevel level) {
if (type) {
clang::QualType qual_type =
RemoveWrappingTypes(GetQualType(type), {clang::Type::Typedef});
@@ -8631,24 +8900,31 @@ void ClangASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type,
case clang::Type::ObjCInterface: {
GetCompleteType(type);
- const clang::ObjCObjectType *objc_class_type =
+ auto *objc_class_type =
llvm::dyn_cast<clang::ObjCObjectType>(qual_type.getTypePtr());
assert(objc_class_type);
- if (objc_class_type) {
- clang::ObjCInterfaceDecl *class_interface_decl =
+ if (!objc_class_type)
+ break;
+ 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());
- }
- }
+ if (!class_interface_decl)
+ break;
+ if (level == eDescriptionLevelVerbose)
+ class_interface_decl->dump(llvm_ostrm);
+ else
+ class_interface_decl->print(llvm_ostrm,
+ getASTContext().getPrintingPolicy(),
+ 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();
+ auto *typedef_type = qual_type->getAs<clang::TypedefType>();
+ if (!typedef_type)
+ break;
+ const clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
+ if (level == eDescriptionLevelVerbose)
+ typedef_decl->dump(llvm_ostrm);
+ else {
std::string clang_typedef_name(
typedef_decl->getQualifiedNameAsString());
if (!clang_typedef_name.empty()) {
@@ -8661,31 +8937,39 @@ void ClangASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type,
case clang::Type::Record: {
GetCompleteType(type);
- const clang::RecordType *record_type =
- llvm::cast<clang::RecordType>(qual_type.getTypePtr());
+ auto *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());
+ if (level == eDescriptionLevelVerbose)
+ record_decl->dump(llvm_ostrm);
+ else {
+ if (auto *cxx_record_decl =
+ llvm::dyn_cast<clang::CXXRecordDecl>(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);
+ if (auto *tag_type =
+ llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr())) {
+ if (clang::TagDecl *tag_decl = tag_type->getDecl()) {
+ if (level == eDescriptionLevelVerbose)
+ tag_decl->dump(llvm_ostrm);
+ else
+ 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);
+ if (level == eDescriptionLevelVerbose)
+ qual_type->dump(llvm_ostrm, getASTContext());
+ else {
+ std::string clang_type_name(qual_type.getAsString());
+ if (!clang_type_name.empty())
+ s->PutCString(clang_type_name);
+ }
}
}
}
@@ -8693,10 +8977,10 @@ void ClangASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type,
if (buf.size() > 0) {
s->Write(buf.data(), buf.size());
}
- }
+}
}
-void ClangASTContext::DumpTypeName(const CompilerType &type) {
+void TypeSystemClang::DumpTypeName(const CompilerType &type) {
if (ClangUtil::IsClangType(type)) {
clang::QualType qual_type(
ClangUtil::GetCanonicalQualType(ClangUtil::RemoveFastQualifiers(type)));
@@ -8762,28 +9046,28 @@ void ClangASTContext::DumpTypeName(const CompilerType &type) {
llvm::cast<clang::ParenType>(qual_type)->desugar().getAsOpaquePtr()));
default:
- printf("ClangASTContext::DumpTypeName() type_class = %u", type_class);
+ printf("TypeSystemClang::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) {
+clang::ClassTemplateDecl *TypeSystemClang::ParseClassTemplateDecl(
+ clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
+ lldb::AccessType access_type, const char *parent_name, int tag_decl_kind,
+ const TypeSystemClang::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,
+ return CreateClassTemplateDecl(decl_ctx, owning_module, access_type,
template_basename.c_str(), tag_decl_kind,
template_param_infos);
}
return nullptr;
}
-void ClangASTContext::CompleteTagDecl(clang::TagDecl *decl) {
+void TypeSystemClang::CompleteTagDecl(clang::TagDecl *decl) {
SymbolFile *sym_file = GetSymbolFile();
if (sym_file) {
CompilerType clang_type = GetTypeForDecl(decl);
@@ -8792,7 +9076,7 @@ void ClangASTContext::CompleteTagDecl(clang::TagDecl *decl) {
}
}
-void ClangASTContext::CompleteObjCInterfaceDecl(
+void TypeSystemClang::CompleteObjCInterfaceDecl(
clang::ObjCInterfaceDecl *decl) {
SymbolFile *sym_file = GetSymbolFile();
if (sym_file) {
@@ -8802,19 +9086,19 @@ void ClangASTContext::CompleteObjCInterfaceDecl(
}
}
-DWARFASTParser *ClangASTContext::GetDWARFParser() {
+DWARFASTParser *TypeSystemClang::GetDWARFParser() {
if (!m_dwarf_ast_parser_up)
- m_dwarf_ast_parser_up.reset(new DWARFASTParserClang(*this));
+ m_dwarf_ast_parser_up = std::make_unique<DWARFASTParserClang>(*this);
return m_dwarf_ast_parser_up.get();
}
-PDBASTParser *ClangASTContext::GetPDBParser() {
+PDBASTParser *TypeSystemClang::GetPDBParser() {
if (!m_pdb_ast_parser_up)
- m_pdb_ast_parser_up.reset(new PDBASTParser(*this));
+ m_pdb_ast_parser_up = std::make_unique<PDBASTParser>(*this);
return m_pdb_ast_parser_up.get();
}
-bool ClangASTContext::LayoutRecordType(
+bool TypeSystemClang::LayoutRecordType(
const clang::RecordDecl *record_decl, uint64_t &bit_size,
uint64_t &alignment,
llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
@@ -8836,7 +9120,7 @@ bool ClangASTContext::LayoutRecordType(
// CompilerDecl override functions
-ConstString ClangASTContext::DeclGetName(void *opaque_decl) {
+ConstString TypeSystemClang::DeclGetName(void *opaque_decl) {
if (opaque_decl) {
clang::NamedDecl *nd =
llvm::dyn_cast<NamedDecl>((clang::Decl *)opaque_decl);
@@ -8846,7 +9130,7 @@ ConstString ClangASTContext::DeclGetName(void *opaque_decl) {
return ConstString();
}
-ConstString ClangASTContext::DeclGetMangledName(void *opaque_decl) {
+ConstString TypeSystemClang::DeclGetMangledName(void *opaque_decl) {
if (opaque_decl) {
clang::NamedDecl *nd =
llvm::dyn_cast<clang::NamedDecl>((clang::Decl *)opaque_decl);
@@ -8856,11 +9140,15 @@ ConstString ClangASTContext::DeclGetMangledName(void *opaque_decl) {
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);
+ mc->mangleName(
+ clang::GlobalDecl(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);
+ mc->mangleName(
+ clang::GlobalDecl(llvm::dyn_cast<clang::CXXDestructorDecl>(nd),
+ Dtor_Complete),
+ llvm_ostrm);
} else {
mc->mangleName(nd, llvm_ostrm);
}
@@ -8872,13 +9160,13 @@ ConstString ClangASTContext::DeclGetMangledName(void *opaque_decl) {
return ConstString();
}
-CompilerDeclContext ClangASTContext::DeclGetDeclContext(void *opaque_decl) {
+CompilerDeclContext TypeSystemClang::DeclGetDeclContext(void *opaque_decl) {
if (opaque_decl)
return CreateDeclContext(((clang::Decl *)opaque_decl)->getDeclContext());
return CompilerDeclContext();
}
-CompilerType ClangASTContext::DeclGetFunctionReturnType(void *opaque_decl) {
+CompilerType TypeSystemClang::DeclGetFunctionReturnType(void *opaque_decl) {
if (clang::FunctionDecl *func_decl =
llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
return GetType(func_decl->getReturnType());
@@ -8889,7 +9177,7 @@ CompilerType ClangASTContext::DeclGetFunctionReturnType(void *opaque_decl) {
return CompilerType();
}
-size_t ClangASTContext::DeclGetFunctionNumArguments(void *opaque_decl) {
+size_t TypeSystemClang::DeclGetFunctionNumArguments(void *opaque_decl) {
if (clang::FunctionDecl *func_decl =
llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl))
return func_decl->param_size();
@@ -8900,7 +9188,7 @@ size_t ClangASTContext::DeclGetFunctionNumArguments(void *opaque_decl) {
return 0;
}
-CompilerType ClangASTContext::DeclGetFunctionArgumentType(void *opaque_decl,
+CompilerType TypeSystemClang::DeclGetFunctionArgumentType(void *opaque_decl,
size_t idx) {
if (clang::FunctionDecl *func_decl =
llvm::dyn_cast<clang::FunctionDecl>((clang::Decl *)opaque_decl)) {
@@ -8920,7 +9208,7 @@ CompilerType ClangASTContext::DeclGetFunctionArgumentType(void *opaque_decl,
// CompilerDeclContext functions
-std::vector<CompilerDecl> ClangASTContext::DeclContextFindDeclByName(
+std::vector<CompilerDecl> TypeSystemClang::DeclContextFindDeclByName(
void *opaque_decl_ctx, ConstString name, const bool ignore_using_decls) {
std::vector<CompilerDecl> found_decls;
if (opaque_decl_ctx) {
@@ -8961,14 +9249,14 @@ std::vector<CompilerDecl> ClangASTContext::DeclContextFindDeclByName(
IdentifierInfo *ii = nd->getIdentifier();
if (ii != nullptr &&
ii->getName().equals(name.AsCString(nullptr)))
- found_decls.push_back(CompilerDecl(this, nd));
+ found_decls.push_back(GetCompilerDecl(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));
+ found_decls.push_back(GetCompilerDecl(nd));
}
}
}
@@ -9017,7 +9305,7 @@ std::vector<CompilerDecl> ClangASTContext::DeclContextFindDeclByName(
// 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,
+uint32_t TypeSystemClang::CountDeclLevels(clang::DeclContext *frame_decl_ctx,
clang::DeclContext *child_decl_ctx,
ConstString *child_name,
CompilerType *child_type) {
@@ -9099,7 +9387,7 @@ uint32_t ClangASTContext::CountDeclLevels(clang::DeclContext *frame_decl_ctx,
return LLDB_INVALID_DECL_LEVEL;
}
-ConstString ClangASTContext::DeclContextGetName(void *opaque_decl_ctx) {
+ConstString TypeSystemClang::DeclContextGetName(void *opaque_decl_ctx) {
if (opaque_decl_ctx) {
clang::NamedDecl *named_decl =
llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
@@ -9110,7 +9398,7 @@ ConstString ClangASTContext::DeclContextGetName(void *opaque_decl_ctx) {
}
ConstString
-ClangASTContext::DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) {
+TypeSystemClang::DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) {
if (opaque_decl_ctx) {
clang::NamedDecl *named_decl =
llvm::dyn_cast<clang::NamedDecl>((clang::DeclContext *)opaque_decl_ctx);
@@ -9121,7 +9409,7 @@ ClangASTContext::DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) {
return ConstString();
}
-bool ClangASTContext::DeclContextIsClassMethod(
+bool TypeSystemClang::DeclContextIsClassMethod(
void *opaque_decl_ctx, lldb::LanguageType *language_ptr,
bool *is_instance_method_ptr, ConstString *language_object_name_ptr) {
if (opaque_decl_ctx) {
@@ -9161,7 +9449,7 @@ bool ClangASTContext::DeclContextIsClassMethod(
return false;
}
-bool ClangASTContext::DeclContextIsContainedInLookup(
+bool TypeSystemClang::DeclContextIsContainedInLookup(
void *opaque_decl_ctx, void *other_opaque_decl_ctx) {
auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
auto *other = (clang::DeclContext *)other_opaque_decl_ctx;
@@ -9179,18 +9467,18 @@ bool ClangASTContext::DeclContextIsContainedInLookup(
}
static bool IsClangDeclContext(const CompilerDeclContext &dc) {
- return dc.IsValid() && isa<ClangASTContext>(dc.GetTypeSystem());
+ return dc.IsValid() && isa<TypeSystemClang>(dc.GetTypeSystem());
}
clang::DeclContext *
-ClangASTContext::DeclContextGetAsDeclContext(const CompilerDeclContext &dc) {
+TypeSystemClang::DeclContextGetAsDeclContext(const CompilerDeclContext &dc) {
if (IsClangDeclContext(dc))
return (clang::DeclContext *)dc.GetOpaqueDeclContext();
return nullptr;
}
ObjCMethodDecl *
-ClangASTContext::DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc) {
+TypeSystemClang::DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc) {
if (IsClangDeclContext(dc))
return llvm::dyn_cast<clang::ObjCMethodDecl>(
(clang::DeclContext *)dc.GetOpaqueDeclContext());
@@ -9198,7 +9486,7 @@ ClangASTContext::DeclContextGetAsObjCMethodDecl(const CompilerDeclContext &dc) {
}
CXXMethodDecl *
-ClangASTContext::DeclContextGetAsCXXMethodDecl(const CompilerDeclContext &dc) {
+TypeSystemClang::DeclContextGetAsCXXMethodDecl(const CompilerDeclContext &dc) {
if (IsClangDeclContext(dc))
return llvm::dyn_cast<clang::CXXMethodDecl>(
(clang::DeclContext *)dc.GetOpaqueDeclContext());
@@ -9206,7 +9494,7 @@ ClangASTContext::DeclContextGetAsCXXMethodDecl(const CompilerDeclContext &dc) {
}
clang::FunctionDecl *
-ClangASTContext::DeclContextGetAsFunctionDecl(const CompilerDeclContext &dc) {
+TypeSystemClang::DeclContextGetAsFunctionDecl(const CompilerDeclContext &dc) {
if (IsClangDeclContext(dc))
return llvm::dyn_cast<clang::FunctionDecl>(
(clang::DeclContext *)dc.GetOpaqueDeclContext());
@@ -9214,7 +9502,7 @@ ClangASTContext::DeclContextGetAsFunctionDecl(const CompilerDeclContext &dc) {
}
clang::NamespaceDecl *
-ClangASTContext::DeclContextGetAsNamespaceDecl(const CompilerDeclContext &dc) {
+TypeSystemClang::DeclContextGetAsNamespaceDecl(const CompilerDeclContext &dc) {
if (IsClangDeclContext(dc))
return llvm::dyn_cast<clang::NamespaceDecl>(
(clang::DeclContext *)dc.GetOpaqueDeclContext());
@@ -9222,39 +9510,40 @@ ClangASTContext::DeclContextGetAsNamespaceDecl(const CompilerDeclContext &dc) {
}
ClangASTMetadata *
-ClangASTContext::DeclContextGetMetaData(const CompilerDeclContext &dc,
+TypeSystemClang::DeclContextGetMetaData(const CompilerDeclContext &dc,
const Decl *object) {
- ClangASTContext *ast = llvm::cast<ClangASTContext>(dc.GetTypeSystem());
+ TypeSystemClang *ast = llvm::cast<TypeSystemClang>(dc.GetTypeSystem());
return ast->GetMetadata(object);
}
clang::ASTContext *
-ClangASTContext::DeclContextGetClangASTContext(const CompilerDeclContext &dc) {
- ClangASTContext *ast =
- llvm::dyn_cast_or_null<ClangASTContext>(dc.GetTypeSystem());
+TypeSystemClang::DeclContextGetTypeSystemClang(const CompilerDeclContext &dc) {
+ TypeSystemClang *ast =
+ llvm::dyn_cast_or_null<TypeSystemClang>(dc.GetTypeSystem());
if (ast)
return &ast->getASTContext();
return nullptr;
}
-ClangASTContextForExpressions::ClangASTContextForExpressions(
+TypeSystemClangForExpressions::TypeSystemClangForExpressions(
Target &target, llvm::Triple triple)
- : ClangASTContext(triple), m_target_wp(target.shared_from_this()),
+ : TypeSystemClang("scratch ASTContext", triple),
+ m_target_wp(target.shared_from_this()),
m_persistent_variables(new ClangPersistentVariables) {
- m_scratch_ast_source_up.reset(new ClangASTSource(
- target.shared_from_this(), target.GetClangASTImporter()));
+ m_scratch_ast_source_up = std::make_unique<ClangASTSource>(
+ target.shared_from_this(), m_persistent_variables->GetClangASTImporter());
m_scratch_ast_source_up->InstallASTContext(*this);
llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source(
m_scratch_ast_source_up->CreateProxy());
SetExternalSource(proxy_ast_source);
}
-void ClangASTContextForExpressions::Finalize() {
- ClangASTContext::Finalize();
+void TypeSystemClangForExpressions::Finalize() {
+ TypeSystemClang::Finalize();
m_scratch_ast_source_up.reset();
}
-UserExpression *ClangASTContextForExpressions::GetUserExpression(
+UserExpression *TypeSystemClangForExpressions::GetUserExpression(
llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language,
Expression::ResultType desired_type,
const EvaluateExpressionOptions &options,
@@ -9267,7 +9556,7 @@ UserExpression *ClangASTContextForExpressions::GetUserExpression(
desired_type, options, ctx_obj);
}
-FunctionCaller *ClangASTContextForExpressions::GetFunctionCaller(
+FunctionCaller *TypeSystemClangForExpressions::GetFunctionCaller(
const CompilerType &return_type, const Address &function_address,
const ValueList &arg_value_list, const char *name) {
TargetSP target_sp = m_target_wp.lock();
@@ -9283,7 +9572,7 @@ FunctionCaller *ClangASTContextForExpressions::GetFunctionCaller(
}
UtilityFunction *
-ClangASTContextForExpressions::GetUtilityFunction(const char *text,
+TypeSystemClangForExpressions::GetUtilityFunction(const char *text,
const char *name) {
TargetSP target_sp = m_target_wp.lock();
if (!target_sp)
@@ -9293,6 +9582,6 @@ ClangASTContextForExpressions::GetUtilityFunction(const char *text,
}
PersistentExpressionState *
-ClangASTContextForExpressions::GetPersistentExpressionState() {
+TypeSystemClangForExpressions::GetPersistentExpressionState() {
return m_persistent_variables.get();
}
diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index 338417b20b8a..9475e4d9f442 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -1,4 +1,4 @@
-//===-- ClangASTContext.h ---------------------------------------*- C++ -*-===//
+//===-- TypeSystemClang.h ---------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_ClangASTContext_h_
-#define liblldb_ClangASTContext_h_
+#ifndef LLDB_SOURCE_PLUGINS_TYPESYSTEM_CLANG_TYPESYSTEMCLANG_H
+#define LLDB_SOURCE_PLUGINS_TYPESYSTEM_CLANG_TYPESYSTEMCLANG_H
#include <stdint.h>
@@ -21,16 +21,19 @@
#include <vector>
#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTFwd.h"
#include "clang/AST/TemplateBase.h"
+#include "clang/Basic/TargetInfo.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/SmallVector.h"
-#include "lldb/Core/ClangForward.h"
+#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
#include "lldb/Expression/ExpressionVariable.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Flags.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Logging.h"
#include "lldb/lldb-enumerations.h"
@@ -38,11 +41,69 @@
class DWARFASTParserClang;
class PDBASTParser;
+namespace clang {
+class FileManager;
+class HeaderSearch;
+class ModuleMap;
+} // namespace clang
+
namespace lldb_private {
+class ClangASTMetadata;
+class ClangASTSource;
class Declaration;
-class ClangASTContext : public TypeSystem {
+/// A Clang module ID.
+class OptionalClangModuleID {
+ unsigned m_id = 0;
+
+public:
+ OptionalClangModuleID() = default;
+ explicit OptionalClangModuleID(unsigned id) : m_id(id) {}
+ bool HasValue() const { return m_id != 0; }
+ unsigned GetValue() const { return m_id; }
+};
+
+/// The implementation of lldb::Type's m_payload field for TypeSystemClang.
+class TypePayloadClang {
+ /// The Layout is as follows:
+ /// \verbatim
+ /// bit 0..30 ... Owning Module ID.
+ /// bit 31 ...... IsCompleteObjCClass.
+ /// \endverbatim
+ Type::Payload m_payload = 0;
+
+public:
+ TypePayloadClang() = default;
+ explicit TypePayloadClang(OptionalClangModuleID owning_module,
+ bool is_complete_objc_class = false);
+ explicit TypePayloadClang(uint32_t opaque_payload) : m_payload(opaque_payload) {}
+ operator Type::Payload() { return m_payload; }
+
+ static constexpr unsigned ObjCClassBit = 1 << 31;
+ bool IsCompleteObjCClass() { return Flags(m_payload).Test(ObjCClassBit); }
+ void SetIsCompleteObjCClass(bool is_complete_objc_class) {
+ m_payload = is_complete_objc_class ? Flags(m_payload).Set(ObjCClassBit)
+ : Flags(m_payload).Clear(ObjCClassBit);
+ }
+ OptionalClangModuleID GetOwningModule() {
+ return OptionalClangModuleID(Flags(m_payload).Clear(ObjCClassBit));
+ }
+ void SetOwningModule(OptionalClangModuleID id);
+ /// \}
+};
+
+/// A TypeSystem implementation based on Clang.
+///
+/// This class uses a single clang::ASTContext as the backend for storing
+/// its types and declarations. Every clang::ASTContext should also just have
+/// a single associated TypeSystemClang instance that manages it.
+///
+/// The clang::ASTContext instance can either be created by TypeSystemClang
+/// itself or it can adopt an existing clang::ASTContext (for example, when
+/// it is necessary to provide a TypeSystem interface for an existing
+/// clang::ASTContext that was created by clang::CompilerInstance).
+class TypeSystemClang : public TypeSystem {
// LLVM RTTI support
static char ID;
@@ -55,21 +116,24 @@ public:
bool isA(const void *ClassID) const override { return ClassID == &ID; }
static bool classof(const TypeSystem *ts) { return ts->isA(&ID); }
- /// Constructs a ClangASTContext with an ASTContext using the given triple.
+ /// Constructs a TypeSystemClang with an ASTContext using the given triple.
///
+ /// \param name The name for the TypeSystemClang (for logging purposes)
/// \param triple The llvm::Triple used for the ASTContext. The triple defines
/// certain characteristics of the ASTContext and its types
/// (e.g., whether certain primitive types exist or what their
/// signedness is).
- explicit ClangASTContext(llvm::Triple triple);
+ explicit TypeSystemClang(llvm::StringRef name, llvm::Triple triple);
- /// Constructs a ClangASTContext that uses an existing ASTContext internally.
+ /// Constructs a TypeSystemClang that uses an existing ASTContext internally.
/// Useful when having an existing ASTContext created by Clang.
///
+ /// \param name The name for the TypeSystemClang (for logging purposes)
/// \param existing_ctxt An existing ASTContext.
- explicit ClangASTContext(clang::ASTContext &existing_ctxt);
+ explicit TypeSystemClang(llvm::StringRef name,
+ clang::ASTContext &existing_ctxt);
- ~ClangASTContext() override;
+ ~TypeSystemClang() override;
void Finalize() override;
@@ -90,20 +154,25 @@ public:
static void Terminate();
- static ClangASTContext *GetASTContext(clang::ASTContext *ast_ctx);
+ static TypeSystemClang *GetASTContext(clang::ASTContext *ast_ctx);
- static ClangASTContext *GetScratch(Target &target,
+ static TypeSystemClang *GetScratch(Target &target,
bool create_on_demand = true) {
auto type_system_or_err = target.GetScratchTypeSystemForLanguage(
lldb::eLanguageTypeC, create_on_demand);
if (auto err = type_system_or_err.takeError()) {
LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET),
- std::move(err), "Couldn't get scratch ClangASTContext");
+ std::move(err), "Couldn't get scratch TypeSystemClang");
return nullptr;
}
- return llvm::dyn_cast<ClangASTContext>(&type_system_or_err.get());
+ return llvm::dyn_cast<TypeSystemClang>(&type_system_or_err.get());
}
+ /// Returns the display name of this TypeSystemClang that indicates what
+ /// purpose it serves in LLDB. Used for example in logs.
+ llvm::StringRef getDisplayName() const { return m_display_name; }
+
+ /// Returns the clang::ASTContext instance managed by this TypeSystemClang.
clang::ASTContext &getASTContext();
clang::MangleContext *getMangleContext();
@@ -121,7 +190,7 @@ public:
llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> &ast_source_up);
bool GetCompleteDecl(clang::Decl *decl) {
- return ClangASTContext::GetCompleteDecl(&getASTContext(), decl);
+ return TypeSystemClang::GetCompleteDecl(&getASTContext(), decl);
}
static void DumpDeclHiearchy(clang::Decl *decl);
@@ -169,16 +238,16 @@ public:
bool ignore_qualifiers = false);
/// Creates a CompilerType form the given QualType with the current
- /// ClangASTContext instance as the CompilerType's typesystem.
+ /// TypeSystemClang instance as the CompilerType's typesystem.
/// \param qt The QualType for a type that belongs to the ASTContext of this
- /// ClangASTContext.
+ /// TypeSystemClang.
/// \return The CompilerType representing the given QualType. If the
/// QualType's type pointer is a nullptr then the function returns an
/// invalid CompilerType.
CompilerType GetType(clang::QualType qt) {
if (qt.getTypePtrOrNull() == nullptr)
return CompilerType();
- // Check that the type actually belongs to this ClangASTContext.
+ // Check that the type actually belongs to this TypeSystemClang.
assert(qt->getAsTagDecl() == nullptr ||
&qt->getAsTagDecl()->getASTContext() == &getASTContext());
return CompilerType(this, qt.getAsOpaquePtr());
@@ -246,7 +315,14 @@ public:
static uint32_t GetNumBaseClasses(const clang::CXXRecordDecl *cxx_record_decl,
bool omit_empty_base_classes);
+ /// Synthesize a clang::Module and return its ID or a default-constructed ID.
+ OptionalClangModuleID GetOrCreateClangModule(llvm::StringRef name,
+ OptionalClangModuleID parent,
+ bool is_framework = false,
+ bool is_explicit = false);
+
CompilerType CreateRecordType(clang::DeclContext *decl_ctx,
+ OptionalClangModuleID owning_module,
lldb::AccessType access_type,
llvm::StringRef name, int kind,
lldb::LanguageType language,
@@ -272,6 +348,7 @@ public:
clang::FunctionTemplateDecl *
CreateFunctionTemplateDecl(clang::DeclContext *decl_ctx,
+ OptionalClangModuleID owning_module,
clang::FunctionDecl *func_decl, const char *name,
const TemplateParameterInfos &infos);
@@ -281,6 +358,7 @@ public:
clang::ClassTemplateDecl *
CreateClassTemplateDecl(clang::DeclContext *decl_ctx,
+ OptionalClangModuleID owning_module,
lldb::AccessType access_type, const char *class_name,
int kind, const TemplateParameterInfos &infos);
@@ -288,7 +366,7 @@ public:
CreateTemplateTemplateParmDecl(const char *template_name);
clang::ClassTemplateSpecializationDecl *CreateClassTemplateSpecializationDecl(
- clang::DeclContext *decl_ctx,
+ clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
clang::ClassTemplateDecl *class_template_decl, int kind,
const TemplateParameterInfos &infos);
@@ -308,8 +386,9 @@ public:
static bool RecordHasFields(const clang::RecordDecl *record_decl);
CompilerType CreateObjCClass(llvm::StringRef name,
- clang::DeclContext *decl_ctx, bool isForwardDecl,
- bool isInternal,
+ clang::DeclContext *decl_ctx,
+ OptionalClangModuleID owning_module,
+ bool isForwardDecl, bool isInternal,
ClangASTMetadata *metadata = nullptr);
bool SetTagTypeKind(clang::QualType type, int kind) const;
@@ -319,21 +398,23 @@ public:
int *assigned_accessibilities,
size_t num_assigned_accessibilities);
- // Returns a mask containing bits from the ClangASTContext::eTypeXXX
+ // Returns a mask containing bits from the TypeSystemClang::eTypeXXX
// enumerations
// Namespace Declarations
clang::NamespaceDecl *
GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx,
+ OptionalClangModuleID owning_module,
bool is_inline = false);
// Function Types
clang::FunctionDecl *
- CreateFunctionDeclaration(clang::DeclContext *decl_ctx, const char *name,
- const CompilerType &function_Type, int storage,
- bool is_inline);
+ CreateFunctionDeclaration(clang::DeclContext *decl_ctx,
+ OptionalClangModuleID owning_module,
+ const char *name, const CompilerType &function_Type,
+ int storage, bool is_inline);
CompilerType CreateFunctionType(const CompilerType &result_type,
const CompilerType *args, unsigned num_args,
@@ -347,11 +428,11 @@ public:
type_quals, clang::CC_C);
}
- clang::ParmVarDecl *CreateParameterDeclaration(clang::DeclContext *decl_ctx,
- const char *name,
- const CompilerType &param_type,
- int storage,
- bool add_decl=false);
+ clang::ParmVarDecl *
+ CreateParameterDeclaration(clang::DeclContext *decl_ctx,
+ OptionalClangModuleID owning_module,
+ const char *name, const CompilerType &param_type,
+ int storage, bool add_decl = false);
void SetFunctionParameters(clang::FunctionDecl *function_decl,
clang::ParmVarDecl **params, unsigned num_params);
@@ -366,6 +447,7 @@ public:
// Enumeration Types
CompilerType CreateEnumerationType(const char *name,
clang::DeclContext *decl_ctx,
+ OptionalClangModuleID owning_module,
const Declaration &decl,
const CompilerType &integer_qual_type,
bool is_scoped);
@@ -385,7 +467,7 @@ public:
DWARFASTParser *GetDWARFParser() override;
PDBASTParser *GetPDBParser() override;
- // ClangASTContext callbacks for external source lookups.
+ // TypeSystemClang callbacks for external source lookups.
void CompleteTagDecl(clang::TagDecl *);
void CompleteObjCInterfaceDecl(clang::ObjCInterfaceDecl *);
@@ -398,6 +480,16 @@ public:
llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
&vbase_offsets);
+ /// Creates a CompilerDecl from the given Decl with the current
+ /// TypeSystemClang instance as its typesystem.
+ /// The Decl has to come from the ASTContext of this
+ /// TypeSystemClang.
+ CompilerDecl GetCompilerDecl(clang::Decl *decl) {
+ assert(&decl->getASTContext() == &getASTContext() &&
+ "CreateCompilerDecl for Decl from wrong ASTContext?");
+ return CompilerDecl(this, decl);
+ }
+
// CompilerDecl override functions
ConstString DeclGetName(void *opaque_decl) override;
@@ -417,11 +509,15 @@ public:
// CompilerDeclContext override functions
/// Creates a CompilerDeclContext from the given DeclContext
- /// with the current ClangASTContext instance as its typesystem.
+ /// with the current TypeSystemClang instance as its typesystem.
/// The DeclContext has to come from the ASTContext of this
- /// ClangASTContext.
+ /// TypeSystemClang.
CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx);
+ /// Set the owning module for \p decl.
+ static void SetOwningModule(clang::Decl *decl,
+ OptionalClangModuleID owning_module);
+
std::vector<CompilerDecl>
DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name,
const bool ignore_using_decls) override;
@@ -459,10 +555,14 @@ public:
const clang::Decl *object);
static clang::ASTContext *
- DeclContextGetClangASTContext(const CompilerDeclContext &dc);
+ DeclContextGetTypeSystemClang(const CompilerDeclContext &dc);
// Tests
+#ifndef NDEBUG
+ bool Verify(lldb::opaque_compiler_type_t type) override;
+#endif
+
bool IsArrayType(lldb::opaque_compiler_type_t type,
CompilerType *element_type, uint64_t *size,
bool *is_incomplete) override;
@@ -566,6 +666,8 @@ public:
ConstString GetTypeName(lldb::opaque_compiler_type_t type) override;
+ ConstString GetDisplayTypeName(lldb::opaque_compiler_type_t type) override;
+
uint32_t GetTypeInfo(lldb::opaque_compiler_type_t type,
CompilerType *pointee_or_element_compiler_type) override;
@@ -578,11 +680,13 @@ public:
// 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.
+ /// Using the current type, create a new typedef to that type using
+ /// "typedef_name" as the name and "decl_ctx" as the decl context.
+ /// \param payload is an opaque TypePayloadClang.
static CompilerType
CreateTypedefType(const CompilerType &type, const char *typedef_name,
- const CompilerDeclContext &compiler_decl_ctx);
+ const CompilerDeclContext &compiler_decl_ctx,
+ uint32_t opaque_payload);
CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type,
uint64_t *stride) override;
@@ -633,7 +737,8 @@ public:
CompilerType CreateTypedef(lldb::opaque_compiler_type_t type,
const char *name,
- const CompilerDeclContext &decl_ctx) override;
+ const CompilerDeclContext &decl_ctx,
+ uint32_t opaque_payload) override;
// If the current object represents a typedef type, get the underlying type
CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override;
@@ -768,6 +873,24 @@ public:
const CompilerType &var_type,
lldb::AccessType access);
+ /// Initializes a variable with an integer value.
+ /// \param var The variable to initialize. Must not already have an
+ /// initializer and must have an integer or enum type.
+ /// \param init_value The integer value that the variable should be
+ /// initialized to. Has to match the bit width of the
+ /// variable type.
+ static void SetIntegerInitializerForVariable(clang::VarDecl *var,
+ const llvm::APInt &init_value);
+
+ /// Initializes a variable with a floating point value.
+ /// \param var The variable to initialize. Must not already have an
+ /// initializer and must have a floating point type.
+ /// \param init_value The float value that the variable should be
+ /// initialized to.
+ static void
+ SetFloatingInitializerForVariable(clang::VarDecl *var,
+ const llvm::APFloat &init_value);
+
clang::CXXMethodDecl *AddMethodToCXXRecordType(
lldb::opaque_compiler_type_t type, llvm::StringRef name,
const char *mangled_name, const CompilerType &method_type,
@@ -822,7 +945,10 @@ public:
const CompilerType &enum_type, const Declaration &decl, const char *name,
const llvm::APSInt &value);
- CompilerType GetEnumerationIntegerType(lldb::opaque_compiler_type_t type);
+ /// Returns the underlying integer type for an enum type. If the given type
+ /// is invalid or not an enum-type, the function returns an invalid
+ /// CompilerType.
+ CompilerType GetEnumerationIntegerType(CompilerType type);
// Pointers & References
@@ -867,10 +993,12 @@ public:
lldb::offset_t data_offset, size_t data_byte_size) override;
void DumpTypeDescription(
- lldb::opaque_compiler_type_t type) override; // Dump to stdout
+ lldb::opaque_compiler_type_t type,
+ lldb::DescriptionLevel level = lldb::eDescriptionLevelFull) override;
- void DumpTypeDescription(lldb::opaque_compiler_type_t type,
- Stream *s) override;
+ void DumpTypeDescription(
+ lldb::opaque_compiler_type_t type, Stream *s,
+ lldb::DescriptionLevel level = lldb::eDescriptionLevelFull) override;
static void DumpTypeName(const CompilerType &type);
@@ -889,20 +1017,24 @@ public:
GetAsObjCInterfaceDecl(const CompilerType &type);
clang::ClassTemplateDecl *ParseClassTemplateDecl(
- clang::DeclContext *decl_ctx, lldb::AccessType access_type,
- const char *parent_name, int tag_decl_kind,
- const ClangASTContext::TemplateParameterInfos &template_param_infos);
+ clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module,
+ lldb::AccessType access_type, const char *parent_name, int tag_decl_kind,
+ const TypeSystemClang::TemplateParameterInfos &template_param_infos);
- clang::BlockDecl *CreateBlockDeclaration(clang::DeclContext *ctx);
+ clang::BlockDecl *CreateBlockDeclaration(clang::DeclContext *ctx,
+ OptionalClangModuleID owning_module);
clang::UsingDirectiveDecl *
CreateUsingDirectiveDeclaration(clang::DeclContext *decl_ctx,
+ OptionalClangModuleID owning_module,
clang::NamespaceDecl *ns_decl);
clang::UsingDecl *CreateUsingDeclaration(clang::DeclContext *current_decl_ctx,
+ OptionalClangModuleID owning_module,
clang::NamedDecl *target);
clang::VarDecl *CreateVariableDeclaration(clang::DeclContext *decl_context,
+ OptionalClangModuleID owning_module,
const char *name,
clang::QualType type);
@@ -925,11 +1057,18 @@ public:
clang::DeclarationName
GetDeclarationName(const char *name, const CompilerType &function_clang_type);
+ clang::LangOptions *GetLangOpts() const {
+ return m_language_options_up.get();
+ }
+ clang::SourceManager *GetSourceMgr() const {
+ return m_source_manager_up.get();
+ }
+
private:
const clang::ClassTemplateSpecializationDecl *
GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type);
- // Classes that inherit from ClangASTContext can see and modify these
+ // Classes that inherit from TypeSystemClang can see and modify these
std::string m_target_triple;
std::unique_ptr<clang::ASTContext> m_ast_up;
std::unique_ptr<clang::LangOptions> m_language_options_up;
@@ -942,11 +1081,17 @@ private:
std::unique_ptr<clang::IdentifierTable> m_identifier_table_up;
std::unique_ptr<clang::SelectorTable> m_selector_table_up;
std::unique_ptr<clang::Builtin::Context> m_builtins_up;
+ std::unique_ptr<clang::HeaderSearch> m_header_search_up;
+ std::unique_ptr<clang::ModuleMap> m_module_map_up;
std::unique_ptr<DWARFASTParserClang> m_dwarf_ast_parser_up;
std::unique_ptr<PDBASTParser> m_pdb_ast_parser_up;
std::unique_ptr<clang::MangleContext> m_mangle_ctx_up;
uint32_t m_pointer_byte_size = 0;
bool m_ast_owned = false;
+ /// A string describing what this TypeSystemClang represents (e.g.,
+ /// AST for debug information, an expression, some other utility ClangAST).
+ /// Useful for logging and debugging.
+ std::string m_display_name;
typedef llvm::DenseMap<const clang::Decl *, ClangASTMetadata> DeclMetadataMap;
/// Maps Decls to their associated ClangASTMetadata.
@@ -961,19 +1106,21 @@ private:
/// ASTContext wasn't created by parsing source code.
clang::Sema *m_sema = nullptr;
- // For ClangASTContext only
- ClangASTContext(const ClangASTContext &);
- const ClangASTContext &operator=(const ClangASTContext &);
+ // For TypeSystemClang only
+ TypeSystemClang(const TypeSystemClang &);
+ const TypeSystemClang &operator=(const TypeSystemClang &);
/// Creates the internal ASTContext.
void CreateASTContext();
void SetTargetTriple(llvm::StringRef target_triple);
};
-class ClangASTContextForExpressions : public ClangASTContext {
+/// The TypeSystemClang instance used for the scratch ASTContext in a
+/// lldb::Target.
+class TypeSystemClangForExpressions : public TypeSystemClang {
public:
- ClangASTContextForExpressions(Target &target, llvm::Triple triple);
+ TypeSystemClangForExpressions(Target &target, llvm::Triple triple);
- ~ClangASTContextForExpressions() override = default;
+ ~TypeSystemClangForExpressions() override = default;
void Finalize() override;
@@ -995,7 +1142,7 @@ public:
PersistentExpressionState *GetPersistentExpressionState() override;
private:
lldb::TargetWP m_target_wp;
- std::unique_ptr<PersistentExpressionState>
+ std::unique_ptr<ClangPersistentVariables>
m_persistent_variables; // These are the persistent variables associated
// with this process for the expression parser
std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
@@ -1003,4 +1150,4 @@ private:
} // namespace lldb_private
-#endif // liblldb_ClangASTContext_h_
+#endif // LLDB_SOURCE_PLUGINS_TYPESYSTEM_CLANG_TYPESYSTEMCLANG_H
diff --git a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
index 4aa9fb634b61..1bc071c2b161 100644
--- a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
+++ b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
@@ -1,4 +1,4 @@
-//===-- UnwindAssemblyInstEmulation.cpp --------------------------*- C++-*-===//
+//===-- UnwindAssemblyInstEmulation.cpp -----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -28,6 +28,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE(UnwindAssemblyInstEmulation)
+
// UnwindAssemblyInstEmulation method definitions
bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly(
@@ -123,18 +125,12 @@ bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly(
// Add the initial state to the save list with offset 0.
saved_unwind_states.insert({0, {last_row, m_register_values}});
- // cache the pc register number (in whatever register numbering this
- // UnwindPlan uses) for quick reference during instruction parsing.
- RegisterInfo pc_reg_info;
- m_inst_emulator_up->GetRegisterInfo(
- eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, pc_reg_info);
-
- // cache the return address register number (in whatever register
+ // cache the stack pointer register number (in whatever register
// numbering this UnwindPlan uses) for quick reference during
// instruction parsing.
- RegisterInfo ra_reg_info;
+ RegisterInfo sp_reg_info;
m_inst_emulator_up->GetRegisterInfo(
- eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA, ra_reg_info);
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, sp_reg_info);
// The architecture dependent condition code of the last processed
// instruction.
@@ -165,6 +161,23 @@ bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly(
*newrow = *it->second.first;
m_curr_row.reset(newrow);
m_register_values = it->second.second;
+ // re-set the CFA register ivars to match the
+ // new m_curr_row.
+ if (sp_reg_info.name &&
+ m_curr_row->GetCFAValue().IsRegisterPlusOffset()) {
+ uint32_t row_cfa_regnum =
+ m_curr_row->GetCFAValue().GetRegisterNumber();
+ lldb::RegisterKind row_kind =
+ m_unwind_plan_ptr->GetRegisterKind();
+ // set m_cfa_reg_info to the row's CFA reg.
+ m_inst_emulator_up->GetRegisterInfo(row_kind, row_cfa_regnum,
+ m_cfa_reg_info);
+ // set m_fp_is_cfa.
+ if (sp_reg_info.kinds[row_kind] == row_cfa_regnum)
+ m_fp_is_cfa = false;
+ else
+ m_fp_is_cfa = true;
+ }
}
m_inst_emulator_up->SetInstruction(inst->GetOpcode(),
@@ -195,6 +208,23 @@ bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly(
std::make_shared<UnwindPlan::Row>(*saved_state.first);
m_curr_row->SetOffset(current_offset);
m_register_values = saved_state.second;
+ // re-set the CFA register ivars to match the
+ // new m_curr_row.
+ if (sp_reg_info.name &&
+ m_curr_row->GetCFAValue().IsRegisterPlusOffset()) {
+ uint32_t row_cfa_regnum =
+ m_curr_row->GetCFAValue().GetRegisterNumber();
+ lldb::RegisterKind row_kind =
+ m_unwind_plan_ptr->GetRegisterKind();
+ // set m_cfa_reg_info to the row's CFA reg.
+ m_inst_emulator_up->GetRegisterInfo(row_kind, row_cfa_regnum,
+ m_cfa_reg_info);
+ // set m_fp_is_cfa.
+ if (sp_reg_info.kinds[row_kind] == row_cfa_regnum)
+ m_fp_is_cfa = false;
+ else
+ m_fp_is_cfa = true;
+ }
bool replace_existing =
true; // The last instruction might already
// created a row for this offset and
diff --git a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
index 9125bd5b1fe3..5784a42a8269 100644
--- a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
+++ b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_UnwindAssemblyInstEmulation_h_
-#define liblldb_UnwindAssemblyInstEmulation_h_
+#ifndef LLDB_SOURCE_PLUGINS_UNWINDASSEMBLY_INSTEMULATION_UNWINDASSEMBLYINSTEMULATION_H
+#define LLDB_SOURCE_PLUGINS_UNWINDASSEMBLY_INSTEMULATION_UNWINDASSEMBLYINSTEMULATION_H
#include "lldb/Core/EmulateInstruction.h"
#include "lldb/Symbol/UnwindPlan.h"
@@ -151,4 +151,4 @@ private:
uint32_t m_forward_branch_offset;
};
-#endif // liblldb_UnwindAssemblyInstEmulation_h_
+#endif // LLDB_SOURCE_PLUGINS_UNWINDASSEMBLY_INSTEMULATION_UNWINDASSEMBLYINSTEMULATION_H
diff --git a/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp b/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
index ce168f021047..fe1275d5b0cf 100644
--- a/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
+++ b/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
@@ -1,4 +1,4 @@
-//===-- UnwindAssembly-x86.cpp ----------------------------------*- C++ -*-===//
+//===-- UnwindAssembly-x86.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -30,6 +30,8 @@
using namespace lldb;
using namespace lldb_private;
+LLDB_PLUGIN_DEFINE_ADV(UnwindAssembly_x86, UnwindAssemblyX86)
+
// UnwindAssemblyParser_x86 method definitions
UnwindAssembly_x86::UnwindAssembly_x86(const ArchSpec &arch)
@@ -139,7 +141,7 @@ bool UnwindAssembly_x86::AugmentUnwindPlanFromCallSite(
// and we don't need to modify it at all.
if (first_row_pc_loc.GetOffset() == -wordsize) {
- do_augment_unwindplan = false;
+ return true;
}
}
}
diff --git a/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h b/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h
index 7c198bbc33af..3e1588f2065c 100644
--- a/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h
+++ b/lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_UnwindAssembly_x86_h_
-#define liblldb_UnwindAssembly_x86_h_
+#ifndef LLDB_SOURCE_PLUGINS_UNWINDASSEMBLY_X86_UNWINDASSEMBLY_X86_H
+#define LLDB_SOURCE_PLUGINS_UNWINDASSEMBLY_X86_UNWINDASSEMBLY_X86_H
#include "x86AssemblyInspectionEngine.h"
@@ -62,4 +62,4 @@ private:
lldb_private::x86AssemblyInspectionEngine *m_assembly_inspection_engine;
};
-#endif // liblldb_UnwindAssembly_x86_h_
+#endif // LLDB_SOURCE_PLUGINS_UNWINDASSEMBLY_X86_UNWINDASSEMBLY_X86_H
diff --git a/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp b/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
index bf6f60a2d26c..36e7b90cad24 100644
--- a/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
+++ b/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
@@ -1,4 +1,4 @@
-//===-- x86AssemblyInspectionEngine.cpp -------------------------*- C++ -*-===//
+//===-- x86AssemblyInspectionEngine.cpp -----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h b/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h
index 680598abdeff..f39dce1afaa6 100644
--- a/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h
+++ b/lldb/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_x86AssemblyInspectionEngine_h_
-#define liblldb_x86AssemblyInspectionEngine_h_
+#ifndef LLDB_SOURCE_PLUGINS_UNWINDASSEMBLY_X86_X86ASSEMBLYINSPECTIONENGINE_H
+#define LLDB_SOURCE_PLUGINS_UNWINDASSEMBLY_X86_X86ASSEMBLYINSPECTIONENGINE_H
#include "llvm-c/Disassembler.h"
@@ -191,9 +191,11 @@ private:
::LLVMDisasmContextRef m_disasm_context;
- DISALLOW_COPY_AND_ASSIGN(x86AssemblyInspectionEngine);
+ x86AssemblyInspectionEngine(const x86AssemblyInspectionEngine &) = delete;
+ const x86AssemblyInspectionEngine &
+ operator=(const x86AssemblyInspectionEngine &) = delete;
};
} // namespace lldb_private
-#endif // liblldb_x86AssemblyInspectionEngine_h_
+#endif // LLDB_SOURCE_PLUGINS_UNWINDASSEMBLY_X86_X86ASSEMBLYINSPECTIONENGINE_H
diff --git a/lldb/source/Symbol/ArmUnwindInfo.cpp b/lldb/source/Symbol/ArmUnwindInfo.cpp
index fdf4e30b2db5..f2887035e5cf 100644
--- a/lldb/source/Symbol/ArmUnwindInfo.cpp
+++ b/lldb/source/Symbol/ArmUnwindInfo.cpp
@@ -1,4 +1,4 @@
-//===-- ArmUnwindInfo.cpp ---------------------------------------*- C++ -*-===//
+//===-- ArmUnwindInfo.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -29,7 +29,7 @@
using namespace lldb;
using namespace lldb_private;
-// Converts a prel31 avlue to lldb::addr_t with sign extension
+// Converts a prel31 value to lldb::addr_t with sign extension
static addr_t Prel31ToAddr(uint32_t prel31) {
addr_t res = prel31;
if (prel31 & (1 << 30))
diff --git a/lldb/source/Symbol/Block.cpp b/lldb/source/Symbol/Block.cpp
index bf380064200a..afcdf3e21e19 100644
--- a/lldb/source/Symbol/Block.cpp
+++ b/lldb/source/Symbol/Block.cpp
@@ -1,4 +1,4 @@
-//===-- Block.cpp -----------------------------------------------*- C++ -*-===//
+//===-- Block.cpp ---------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Symbol/ClangExternalASTSourceCallbacks.cpp b/lldb/source/Symbol/ClangExternalASTSourceCallbacks.cpp
deleted file mode 100644
index 008c2acd9b48..000000000000
--- a/lldb/source/Symbol/ClangExternalASTSourceCallbacks.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-//===-- ClangExternalASTSourceCallbacks.cpp ---------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Symbol/ClangExternalASTSourceCallbacks.h"
-#include "lldb/Symbol/ClangASTContext.h"
-
-#include "clang/AST/Decl.h"
-
-using namespace lldb_private;
-
-void ClangExternalASTSourceCallbacks::CompleteType(clang::TagDecl *tag_decl) {
- m_ast.CompleteTagDecl(tag_decl);
-}
-
-void ClangExternalASTSourceCallbacks::CompleteType(
- clang::ObjCInterfaceDecl *objc_decl) {
- m_ast.CompleteObjCInterfaceDecl(objc_decl);
-}
-
-bool ClangExternalASTSourceCallbacks::layoutRecordType(
- const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
- llvm::DenseMap<const clang::FieldDecl *, uint64_t> &FieldOffsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &BaseOffsets,
- llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
- &VirtualBaseOffsets) {
- return m_ast.LayoutRecordType(Record, Size, Alignment, FieldOffsets,
- BaseOffsets, VirtualBaseOffsets);
-}
-
-void ClangExternalASTSourceCallbacks::FindExternalLexicalDecls(
- const clang::DeclContext *decl_ctx,
- llvm::function_ref<bool(clang::Decl::Kind)> IsKindWeWant,
- llvm::SmallVectorImpl<clang::Decl *> &decls) {
- if (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/lldb/source/Symbol/CompactUnwindInfo.cpp b/lldb/source/Symbol/CompactUnwindInfo.cpp
index 3eee7f785f36..1bb7cd1fc05b 100644
--- a/lldb/source/Symbol/CompactUnwindInfo.cpp
+++ b/lldb/source/Symbol/CompactUnwindInfo.cpp
@@ -1,4 +1,4 @@
-//===-- CompactUnwindInfo.cpp -----------------------------------*- C++ -*-===//
+//===-- CompactUnwindInfo.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Symbol/CompileUnit.cpp b/lldb/source/Symbol/CompileUnit.cpp
index b05036e27fcf..0c67bf5b702a 100644
--- a/lldb/source/Symbol/CompileUnit.cpp
+++ b/lldb/source/Symbol/CompileUnit.cpp
@@ -1,4 +1,4 @@
-//===-- CompileUnit.cpp -----------------------------------------*- C++ -*-===//
+//===-- CompileUnit.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Symbol/CompilerDecl.cpp b/lldb/source/Symbol/CompilerDecl.cpp
index 48d9169c1a7a..3cafa9535a72 100644
--- a/lldb/source/Symbol/CompilerDecl.cpp
+++ b/lldb/source/Symbol/CompilerDecl.cpp
@@ -1,4 +1,4 @@
-//===-- CompilerDecl.cpp ----------------------------------------*- C++ -*-===//
+//===-- CompilerDecl.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Symbol/CompilerDeclContext.cpp b/lldb/source/Symbol/CompilerDeclContext.cpp
index 581e0872a6a7..a3af568e7c99 100644
--- a/lldb/source/Symbol/CompilerDeclContext.cpp
+++ b/lldb/source/Symbol/CompilerDeclContext.cpp
@@ -1,4 +1,4 @@
-//===-- CompilerDeclContext.cpp ---------------------------------*- C++ -*-===//
+//===-- CompilerDeclContext.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp
index 09930f7a800e..f819c9f8ce23 100644
--- a/lldb/source/Symbol/CompilerType.cpp
+++ b/lldb/source/Symbol/CompilerType.cpp
@@ -1,4 +1,4 @@
-//===-- CompilerType.cpp ----------------------------------------*- C++ -*-===//
+//===-- CompilerType.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -268,19 +268,6 @@ size_t CompilerType::GetPointerByteSize() const {
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);
@@ -288,7 +275,11 @@ ConstString CompilerType::GetTypeName() const {
return ConstString("<invalid>");
}
-ConstString CompilerType::GetDisplayTypeName() const { return GetTypeName(); }
+ConstString CompilerType::GetDisplayTypeName() const {
+ if (IsValid())
+ return m_type_system->GetDisplayTypeName(m_type);
+ return ConstString("<invalid>");
+}
uint32_t CompilerType::GetTypeInfo(
CompilerType *pointee_or_element_compiler_type) const {
@@ -448,11 +439,11 @@ CompilerType CompilerType::AddRestrictModifier() const {
return CompilerType();
}
-CompilerType
-CompilerType::CreateTypedef(const char *name,
- const CompilerDeclContext &decl_ctx) const {
+CompilerType CompilerType::CreateTypedef(const char *name,
+ const CompilerDeclContext &decl_ctx,
+ uint32_t payload) const {
if (IsValid())
- return m_type_system->CreateTypedef(m_type, name, decl_ctx);
+ return m_type_system->CreateTypedef(m_type, name, decl_ctx, payload);
else
return CompilerType();
}
@@ -715,7 +706,6 @@ CompilerType::GetIndexOfChildWithName(const char *name,
}
// Dumping types
-#define DEPTH_INCREMENT 2
void CompilerType::DumpValue(ExecutionContext *exe_ctx, Stream *s,
lldb::Format format, const DataExtractor &data,
@@ -753,14 +743,15 @@ void CompilerType::DumpSummary(ExecutionContext *exe_ctx, Stream *s,
data_byte_size);
}
-void CompilerType::DumpTypeDescription() const {
+void CompilerType::DumpTypeDescription(lldb::DescriptionLevel level) const {
if (IsValid())
- m_type_system->DumpTypeDescription(m_type);
+ m_type_system->DumpTypeDescription(m_type, level);
}
-void CompilerType::DumpTypeDescription(Stream *s) const {
+void CompilerType::DumpTypeDescription(Stream *s,
+ lldb::DescriptionLevel level) const {
if (IsValid()) {
- m_type_system->DumpTypeDescription(m_type, s);
+ m_type_system->DumpTypeDescription(m_type, s, level);
}
}
@@ -874,6 +865,12 @@ bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data,
return false;
}
+#ifndef NDEBUG
+bool CompilerType::Verify() const {
+ return !IsValid() || m_type_system->Verify(m_type);
+}
+#endif
+
bool lldb_private::operator==(const lldb_private::CompilerType &lhs,
const lldb_private::CompilerType &rhs) {
return lhs.GetTypeSystem() == rhs.GetTypeSystem() &&
diff --git a/lldb/source/Symbol/DWARFCallFrameInfo.cpp b/lldb/source/Symbol/DWARFCallFrameInfo.cpp
index b4e74e9a2898..3111c33c7108 100644
--- a/lldb/source/Symbol/DWARFCallFrameInfo.cpp
+++ b/lldb/source/Symbol/DWARFCallFrameInfo.cpp
@@ -1,4 +1,4 @@
-//===-- DWARFCallFrameInfo.cpp ----------------------------------*- C++ -*-===//
+//===-- DWARFCallFrameInfo.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -690,7 +690,7 @@ bool DWARFCallFrameInfo::FDEToUnwindPlan(dw_offset_t dwarf_offset,
UnwindPlan::Row *newrow = new UnwindPlan::Row;
*newrow = *row.get();
row.reset(newrow);
- row->SetOffset(m_cfi_data.GetPointer(&offset) -
+ row->SetOffset(m_cfi_data.GetAddress(&offset) -
startaddr.GetFileAddress());
break;
}
diff --git a/lldb/source/Symbol/DebugMacros.cpp b/lldb/source/Symbol/DebugMacros.cpp
index d119a78868a4..d6a4ca96a30a 100644
--- a/lldb/source/Symbol/DebugMacros.cpp
+++ b/lldb/source/Symbol/DebugMacros.cpp
@@ -1,4 +1,4 @@
-//===-- DebugMacros.cpp -----------------------------------------*- C++ -*-===//
+//===-- DebugMacros.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Symbol/DeclVendor.cpp b/lldb/source/Symbol/DeclVendor.cpp
index 9ccf422e3bea..cf87f4f879b1 100644
--- a/lldb/source/Symbol/DeclVendor.cpp
+++ b/lldb/source/Symbol/DeclVendor.cpp
@@ -1,4 +1,4 @@
-//===-- DeclVendor.cpp ------------------------------------------*- C++ -*-===//
+//===-- DeclVendor.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Symbol/Declaration.cpp b/lldb/source/Symbol/Declaration.cpp
index 4d0975d34256..48d8013811d9 100644
--- a/lldb/source/Symbol/Declaration.cpp
+++ b/lldb/source/Symbol/Declaration.cpp
@@ -1,4 +1,4 @@
-//===-- Declaration.cpp -----------------------------------------*- C++ -*-===//
+//===-- Declaration.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Symbol/FuncUnwinders.cpp b/lldb/source/Symbol/FuncUnwinders.cpp
index 7a6f3cefea66..30266120d05e 100644
--- a/lldb/source/Symbol/FuncUnwinders.cpp
+++ b/lldb/source/Symbol/FuncUnwinders.cpp
@@ -1,4 +1,4 @@
-//===-- FuncUnwinders.cpp ----------------------------------*- C++ -*-===//
+//===-- FuncUnwinders.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp
index e92585ccfed7..67013f6dd8b1 100644
--- a/lldb/source/Symbol/Function.cpp
+++ b/lldb/source/Symbol/Function.cpp
@@ -1,4 +1,4 @@
-//===-- Function.cpp --------------------------------------------*- C++ -*-===//
+//===-- Function.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -82,25 +82,24 @@ void InlineFunctionInfo::Dump(Stream *s, bool show_fullpaths) const {
m_mangled.Dump(s);
}
-void InlineFunctionInfo::DumpStopContext(Stream *s,
- LanguageType language) const {
+void InlineFunctionInfo::DumpStopContext(Stream *s) const {
// s->Indent("[inlined] ");
s->Indent();
if (m_mangled)
- s->PutCString(m_mangled.GetName(language).AsCString());
+ s->PutCString(m_mangled.GetName().AsCString());
else
s->PutCString(m_name.AsCString());
}
-ConstString InlineFunctionInfo::GetName(LanguageType language) const {
+ConstString InlineFunctionInfo::GetName() const {
if (m_mangled)
- return m_mangled.GetName(language);
+ return m_mangled.GetName();
return m_name;
}
-ConstString InlineFunctionInfo::GetDisplayName(LanguageType language) const {
+ConstString InlineFunctionInfo::GetDisplayName() const {
if (m_mangled)
- return m_mangled.GetDisplayDemangledName(language);
+ return m_mangled.GetDisplayDemangledName();
return m_name;
}
@@ -121,10 +120,32 @@ size_t InlineFunctionInfo::MemorySize() const {
/// @name Call site related structures
/// @{
+lldb::addr_t CallEdge::GetLoadAddress(lldb::addr_t unresolved_pc,
+ Function &caller, Target &target) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+
+ const Address &caller_start_addr = caller.GetAddressRange().GetBaseAddress();
+
+ ModuleSP caller_module_sp = caller_start_addr.GetModule();
+ if (!caller_module_sp) {
+ LLDB_LOG(log, "GetLoadAddress: cannot get Module for caller");
+ return LLDB_INVALID_ADDRESS;
+ }
+
+ SectionList *section_list = caller_module_sp->GetSectionList();
+ if (!section_list) {
+ LLDB_LOG(log, "GetLoadAddress: cannot get SectionList for Module");
+ return LLDB_INVALID_ADDRESS;
+ }
+
+ Address the_addr = Address(unresolved_pc, section_list);
+ lldb::addr_t load_addr = the_addr.GetLoadAddress(&target);
+ return load_addr;
+}
+
lldb::addr_t CallEdge::GetReturnPCAddress(Function &caller,
Target &target) const {
- const Address &base = caller.GetAddressRange().GetBaseAddress();
- return base.GetLoadAddress(&target) + return_pc;
+ return GetLoadAddress(GetUnresolvedReturnPCAddress(), caller, target);
}
void DirectCallEdge::ParseSymbolFileAndResolve(ModuleList &images) {
@@ -269,6 +290,8 @@ void Function::GetEndLineSourceInfo(FileSpec &source_file, uint32_t &line_no) {
}
llvm::ArrayRef<std::unique_ptr<CallEdge>> Function::GetCallEdges() {
+ std::lock_guard<std::mutex> guard(m_call_edges_lock);
+
if (m_call_edges_resolved)
return m_call_edges;
@@ -288,36 +311,34 @@ llvm::ArrayRef<std::unique_ptr<CallEdge>> Function::GetCallEdges() {
m_call_edges = sym_file->ParseCallEdgesInFunction(GetID());
// Sort the call edges to speed up return_pc lookups.
- llvm::sort(m_call_edges.begin(), m_call_edges.end(),
- [](const std::unique_ptr<CallEdge> &LHS,
- const std::unique_ptr<CallEdge> &RHS) {
- return LHS->GetUnresolvedReturnPCAddress() <
- RHS->GetUnresolvedReturnPCAddress();
- });
+ llvm::sort(m_call_edges, [](const std::unique_ptr<CallEdge> &LHS,
+ const std::unique_ptr<CallEdge> &RHS) {
+ return LHS->GetSortKey() < RHS->GetSortKey();
+ });
return m_call_edges;
}
llvm::ArrayRef<std::unique_ptr<CallEdge>> Function::GetTailCallingEdges() {
- // Call edges are sorted by return PC, and tail calling edges have invalid
- // return PCs. Find them at the end of the list.
- return GetCallEdges().drop_until([](const std::unique_ptr<CallEdge> &edge) {
- return edge->GetUnresolvedReturnPCAddress() == LLDB_INVALID_ADDRESS;
- });
+ // Tail calling edges are sorted at the end of the list. Find them by dropping
+ // all non-tail-calls.
+ return GetCallEdges().drop_until(
+ [](const std::unique_ptr<CallEdge> &edge) { return edge->IsTailCall(); });
}
CallEdge *Function::GetCallEdgeForReturnAddress(addr_t return_pc,
Target &target) {
auto edges = GetCallEdges();
auto edge_it =
- std::lower_bound(edges.begin(), edges.end(), return_pc,
- [&](const std::unique_ptr<CallEdge> &edge, addr_t pc) {
- return edge->GetReturnPCAddress(*this, target) < pc;
- });
+ llvm::partition_point(edges, [&](const std::unique_ptr<CallEdge> &edge) {
+ return std::make_pair(edge->IsTailCall(),
+ edge->GetReturnPCAddress(*this, target)) <
+ std::make_pair(false, return_pc);
+ });
if (edge_it == edges.end() ||
edge_it->get()->GetReturnPCAddress(*this, target) != return_pc)
return nullptr;
- return &const_cast<CallEdge &>(*edge_it->get());
+ return edge_it->get();
}
Block &Function::GetBlock(bool can_create) {
@@ -349,9 +370,9 @@ void Function::GetDescription(Stream *s, lldb::DescriptionLevel level,
*s << "id = " << (const UserID &)*this;
if (name)
- *s << ", name = \"" << name.GetCString() << '"';
+ s->AsRawOstream() << ", name = \"" << name << '"';
if (mangled)
- *s << ", mangled = \"" << mangled.GetCString() << '"';
+ s->AsRawOstream() << ", mangled = \"" << mangled << '"';
*s << ", range = ";
Address::DumpStyle fallback_style;
if (level == eDescriptionLevelVerbose)
@@ -404,11 +425,11 @@ lldb::DisassemblerSP Function::GetInstructions(const ExecutionContext &exe_ctx,
const char *flavor,
bool prefer_file_cache) {
ModuleSP module_sp(GetAddressRange().GetBaseAddress().GetModule());
- if (module_sp) {
+ if (module_sp && exe_ctx.HasTargetScope()) {
const bool prefer_file_cache = false;
return Disassembler::DisassembleRange(module_sp->GetArchitecture(), nullptr,
- flavor, exe_ctx, GetAddressRange(),
- prefer_file_cache);
+ flavor, exe_ctx.GetTargetRef(),
+ GetAddressRange(), prefer_file_cache);
}
return lldb::DisassemblerSP();
}
@@ -465,7 +486,7 @@ bool Function::IsTopLevelFunction() {
}
ConstString Function::GetDisplayName() const {
- return m_mangled.GetDisplayDemangledName(GetLanguage());
+ return m_mangled.GetDisplayDemangledName();
}
CompilerDeclContext Function::GetDeclContext() {
@@ -633,15 +654,9 @@ lldb::LanguageType Function::GetLanguage() const {
}
ConstString Function::GetName() const {
- LanguageType language = lldb::eLanguageTypeUnknown;
- if (m_comp_unit)
- language = m_comp_unit->GetLanguage();
- return m_mangled.GetName(language);
+ return m_mangled.GetName();
}
ConstString Function::GetNameNoArguments() const {
- LanguageType language = lldb::eLanguageTypeUnknown;
- if (m_comp_unit)
- language = m_comp_unit->GetLanguage();
- return m_mangled.GetName(language, Mangled::ePreferDemangledWithoutArguments);
+ return m_mangled.GetName(Mangled::ePreferDemangledWithoutArguments);
}
diff --git a/lldb/source/Symbol/LineEntry.cpp b/lldb/source/Symbol/LineEntry.cpp
index bb3828fef784..a3907f4dd9c0 100644
--- a/lldb/source/Symbol/LineEntry.cpp
+++ b/lldb/source/Symbol/LineEntry.cpp
@@ -1,4 +1,4 @@
-//===-- LineEntry.cpp -------------------------------------------*- C++ -*-===//
+//===-- LineEntry.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Symbol/LineTable.cpp b/lldb/source/Symbol/LineTable.cpp
index fecc90c409f2..19c39bd0aeb5 100644
--- a/lldb/source/Symbol/LineTable.cpp
+++ b/lldb/source/Symbol/LineTable.cpp
@@ -1,4 +1,4 @@
-//===-- LineTable.cpp -------------------------------------------*- C++ -*-===//
+//===-- LineTable.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -21,6 +21,18 @@ using namespace lldb_private;
LineTable::LineTable(CompileUnit *comp_unit)
: m_comp_unit(comp_unit), m_entries() {}
+LineTable::LineTable(CompileUnit *comp_unit,
+ std::vector<std::unique_ptr<LineSequence>> &&sequences)
+ : m_comp_unit(comp_unit), m_entries() {
+ LineTable::Entry::LessThanBinaryPredicate less_than_bp(this);
+ llvm::stable_sort(sequences, less_than_bp);
+ for (const auto &sequence : sequences) {
+ LineSequenceImpl *seq = static_cast<LineSequenceImpl *>(sequence.get());
+ m_entries.insert(m_entries.end(), seq->m_entries.begin(),
+ seq->m_entries.end());
+ }
+}
+
// Destructor
LineTable::~LineTable() {}
@@ -50,8 +62,8 @@ LineSequence::LineSequence() {}
void LineTable::LineSequenceImpl::Clear() { m_entries.clear(); }
-LineSequence *LineTable::CreateLineSequenceContainer() {
- return new LineTable::LineSequenceImpl();
+std::unique_ptr<LineSequence> LineTable::CreateLineSequenceContainer() {
+ return std::make_unique<LineTable::LineSequenceImpl>();
}
void LineTable::AppendLineEntryToSequence(
@@ -154,6 +166,14 @@ operator()(const LineTable::Entry &a, const LineTable::Entry &b) const {
#undef LT_COMPARE
}
+bool LineTable::Entry::LessThanBinaryPredicate::
+operator()(const std::unique_ptr<LineSequence> &sequence_a,
+ const std::unique_ptr<LineSequence> &sequence_b) const {
+ auto *seq_a = static_cast<const LineSequenceImpl *>(sequence_a.get());
+ auto *seq_b = static_cast<const LineSequenceImpl *>(sequence_b.get());
+ return (*this)(seq_a->m_entries.front(), seq_b->m_entries.front());
+}
+
uint32_t LineTable::GetSize() const { return m_entries.size(); }
bool LineTable::GetLineEntryAtIndex(uint32_t idx, LineEntry &line_entry) {
diff --git a/lldb/source/Symbol/LocateSymbolFile.cpp b/lldb/source/Symbol/LocateSymbolFile.cpp
index d2b39d6acd70..95ae2ca7917a 100644
--- a/lldb/source/Symbol/LocateSymbolFile.cpp
+++ b/lldb/source/Symbol/LocateSymbolFile.cpp
@@ -1,4 +1,4 @@
-//===-- LocateSymbolFile.cpp ------------------------------------*- C++ -*-===//
+//===-- LocateSymbolFile.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Symbol/LocateSymbolFileMacOSX.cpp b/lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
index 5ee632ec2077..251605085c58 100644
--- a/lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
+++ b/lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
@@ -1,4 +1,4 @@
-//===-- LocateSymbolFileMacOSX.cpp ------------------------------*- C++ -*-===//
+//===-- LocateSymbolFileMacOSX.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -253,48 +253,34 @@ int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec,
FileSpec Symbols::FindSymbolFileInBundle(const FileSpec &dsym_bundle_fspec,
const lldb_private::UUID *uuid,
const ArchSpec *arch) {
- char path[PATH_MAX];
- if (dsym_bundle_fspec.GetPath(path, sizeof(path)) == 0)
- return {};
-
- ::strncat(path, "/Contents/Resources/DWARF", sizeof(path) - strlen(path) - 1);
-
- DIR *dirp = opendir(path);
- if (!dirp)
- return {};
-
- // Make sure we close the directory before exiting this scope.
- auto cleanup_dir = llvm::make_scope_exit([&]() { closedir(dirp); });
-
- FileSpec dsym_fspec;
- dsym_fspec.GetDirectory().SetCString(path);
- struct dirent *dp;
- while ((dp = readdir(dirp)) != NULL) {
- // Only search directories
- if (dp->d_type == DT_DIR || dp->d_type == DT_UNKNOWN) {
- if (dp->d_namlen == 1 && dp->d_name[0] == '.')
- continue;
-
- if (dp->d_namlen == 2 && dp->d_name[0] == '.' && dp->d_name[1] == '.')
- continue;
- }
-
- if (dp->d_type == DT_REG || dp->d_type == DT_UNKNOWN) {
- dsym_fspec.GetFilename().SetCString(dp->d_name);
- ModuleSpecList module_specs;
- if (ObjectFile::GetModuleSpecifications(dsym_fspec, 0, 0, module_specs)) {
- ModuleSpec spec;
- for (size_t i = 0; i < module_specs.GetSize(); ++i) {
- bool got_spec = module_specs.GetModuleSpecAtIndex(i, spec);
- UNUSED_IF_ASSERT_DISABLED(got_spec);
- assert(got_spec);
- if ((uuid == NULL ||
- (spec.GetUUIDPtr() && spec.GetUUID() == *uuid)) &&
- (arch == NULL ||
- (spec.GetArchitecturePtr() &&
- spec.GetArchitecture().IsCompatibleMatch(*arch)))) {
- return dsym_fspec;
- }
+ std::string dsym_bundle_path = dsym_bundle_fspec.GetPath();
+ llvm::SmallString<128> buffer(dsym_bundle_path);
+ llvm::sys::path::append(buffer, "Contents", "Resources", "DWARF");
+
+ std::error_code EC;
+ llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> vfs =
+ FileSystem::Instance().GetVirtualFileSystem();
+ llvm::vfs::recursive_directory_iterator Iter(*vfs, buffer.str(), EC);
+ llvm::vfs::recursive_directory_iterator End;
+ for (; Iter != End && !EC; Iter.increment(EC)) {
+ llvm::ErrorOr<llvm::vfs::Status> Status = vfs->status(Iter->path());
+ if (Status->isDirectory())
+ continue;
+
+ FileSpec dsym_fspec(Iter->path());
+ ModuleSpecList module_specs;
+ if (ObjectFile::GetModuleSpecifications(dsym_fspec, 0, 0, module_specs)) {
+ ModuleSpec spec;
+ for (size_t i = 0; i < module_specs.GetSize(); ++i) {
+ bool got_spec = module_specs.GetModuleSpecAtIndex(i, spec);
+ assert(got_spec); // The call has side-effects so can't be inlined.
+ UNUSED_IF_ASSERT_DISABLED(got_spec);
+ if ((uuid == nullptr ||
+ (spec.GetUUIDPtr() && spec.GetUUID() == *uuid)) &&
+ (arch == nullptr ||
+ (spec.GetArchitecturePtr() &&
+ spec.GetArchitecture().IsCompatibleMatch(*arch)))) {
+ return dsym_fspec;
}
}
}
diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp
index 8a72b5fe6f67..6b552dd0c19e 100644
--- a/lldb/source/Symbol/ObjectFile.cpp
+++ b/lldb/source/Symbol/ObjectFile.cpp
@@ -1,4 +1,4 @@
-//===-- ObjectFile.cpp ------------------------------------------*- C++ -*-===//
+//===-- ObjectFile.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -47,8 +47,8 @@ ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file,
FileSpec archive_file;
ObjectContainerCreateInstance create_object_container_callback;
- const bool file_exists = FileSystem::Instance().Exists(*file);
if (!data_sp) {
+ const bool file_exists = FileSystem::Instance().Exists(*file);
// We have an object name which most likely means we have a .o file in
// a static archive (.a file). Try and see if we have a cached archive
// first without reading any data first
@@ -207,9 +207,11 @@ ObjectFileSP ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp,
size_t ObjectFile::GetModuleSpecifications(const FileSpec &file,
lldb::offset_t file_offset,
lldb::offset_t file_size,
- ModuleSpecList &specs) {
- DataBufferSP data_sp =
- FileSystem::Instance().CreateDataBuffer(file.GetPath(), 512, file_offset);
+ ModuleSpecList &specs,
+ DataBufferSP data_sp) {
+ if (!data_sp)
+ data_sp = FileSystem::Instance().CreateDataBuffer(file.GetPath(), 512,
+ file_offset);
if (data_sp) {
if (file_size == 0) {
const lldb::offset_t actual_file_size =
@@ -367,6 +369,7 @@ AddressClass ObjectFile::GetAddressClass(addr_t file_addr) {
case eSectionTypeDWARFDebugStrDwo:
case eSectionTypeDWARFDebugStrOffsets:
case eSectionTypeDWARFDebugStrOffsetsDwo:
+ case eSectionTypeDWARFDebugTuIndex:
case eSectionTypeDWARFDebugTypes:
case eSectionTypeDWARFDebugTypesDwo:
case eSectionTypeDWARFAppleNames:
diff --git a/lldb/source/Symbol/PostfixExpression.cpp b/lldb/source/Symbol/PostfixExpression.cpp
index 8ecd571ed929..588b3f92c3f4 100644
--- a/lldb/source/Symbol/PostfixExpression.cpp
+++ b/lldb/source/Symbol/PostfixExpression.cpp
@@ -1,4 +1,4 @@
-//===-- PostfixExpression.cpp -----------------------------------*- C++ -*-===//
+//===-- PostfixExpression.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp
index 3ace153d32ab..8d099e0cc7e1 100644
--- a/lldb/source/Symbol/Symbol.cpp
+++ b/lldb/source/Symbol/Symbol.cpp
@@ -1,4 +1,4 @@
-//===-- Symbol.cpp ----------------------------------------------*- C++ -*-===//
+//===-- Symbol.cpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -120,7 +120,7 @@ bool Symbol::ValueIsAddress() const {
}
ConstString Symbol::GetDisplayName() const {
- return m_mangled.GetDisplayDemangledName(GetLanguage());
+ return m_mangled.GetDisplayDemangledName();
}
ConstString Symbol::GetReExportedSymbolName() const {
@@ -203,7 +203,7 @@ void Symbol::GetDescription(Stream *s, lldb::DescriptionLevel level,
s->Printf(", value = 0x%16.16" PRIx64,
m_addr_range.GetBaseAddress().GetOffset());
}
- ConstString demangled = m_mangled.GetDemangledName(GetLanguage());
+ ConstString demangled = m_mangled.GetDemangledName();
if (demangled)
s->Printf(", name=\"%s\"", demangled.AsCString());
if (m_mangled.GetMangledName())
@@ -219,7 +219,7 @@ void Symbol::Dump(Stream *s, Target *target, uint32_t index,
// Make sure the size of the symbol is up to date before dumping
GetByteSize();
- ConstString name = m_mangled.GetName(GetLanguage(), name_preference);
+ ConstString name = m_mangled.GetName(name_preference);
if (ValueIsAddress()) {
if (!m_addr_range.GetBaseAddress().Dump(s, nullptr,
Address::DumpStyleFileAddress))
@@ -333,7 +333,7 @@ uint32_t Symbol::GetPrologueByteSize() {
bool Symbol::Compare(ConstString name, SymbolType type) const {
if (type == eSymbolTypeAny || m_type == type)
return m_mangled.GetMangledName() == name ||
- m_mangled.GetDemangledName(GetLanguage()) == name;
+ m_mangled.GetDemangledName() == name;
return false;
}
@@ -496,11 +496,10 @@ lldb::addr_t Symbol::GetLoadAddress(Target *target) const {
return LLDB_INVALID_ADDRESS;
}
-ConstString Symbol::GetName() const { return m_mangled.GetName(GetLanguage()); }
+ConstString Symbol::GetName() const { return m_mangled.GetName(); }
ConstString Symbol::GetNameNoArguments() const {
- return m_mangled.GetName(GetLanguage(),
- Mangled::ePreferDemangledWithoutArguments);
+ return m_mangled.GetName(Mangled::ePreferDemangledWithoutArguments);
}
lldb::addr_t Symbol::ResolveCallableAddress(Target &target) const {
@@ -542,11 +541,11 @@ lldb::DisassemblerSP Symbol::GetInstructions(const ExecutionContext &exe_ctx,
const char *flavor,
bool prefer_file_cache) {
ModuleSP module_sp(m_addr_range.GetBaseAddress().GetModule());
- if (module_sp) {
+ if (module_sp && exe_ctx.HasTargetScope()) {
const bool prefer_file_cache = false;
return Disassembler::DisassembleRange(module_sp->GetArchitecture(), nullptr,
- flavor, exe_ctx, m_addr_range,
- prefer_file_cache);
+ flavor, exe_ctx.GetTargetRef(),
+ m_addr_range, prefer_file_cache);
}
return lldb::DisassemblerSP();
}
diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp
index 9eb805976f95..12c2077154b9 100644
--- a/lldb/source/Symbol/SymbolContext.cpp
+++ b/lldb/source/Symbol/SymbolContext.cpp
@@ -1,4 +1,4 @@
-//===-- SymbolContext.cpp ---------------------------------------*- C++ -*-===//
+//===-- SymbolContext.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -117,9 +117,7 @@ bool SymbolContext::DumpStopContext(Stream *s, ExecutionContextScope *exe_scope,
Block *inlined_block = block->GetContainingInlinedBlock();
const InlineFunctionInfo *inlined_block_info =
inlined_block->GetInlinedFunctionInfo();
- s->Printf(
- " [inlined] %s",
- inlined_block_info->GetName(function->GetLanguage()).GetCString());
+ s->Printf(" [inlined] %s", inlined_block_info->GetName().GetCString());
lldb_private::AddressRange block_range;
if (inlined_block->GetRangeContainingAddress(addr, block_range)) {
@@ -657,12 +655,12 @@ SymbolContext::GetFunctionName(Mangled::NamePreference preference) const {
const InlineFunctionInfo *inline_info =
inlined_block->GetInlinedFunctionInfo();
if (inline_info)
- return inline_info->GetName(function->GetLanguage());
+ return inline_info->GetName();
}
}
- return function->GetMangled().GetName(function->GetLanguage(), preference);
+ return function->GetMangled().GetName(preference);
} else if (symbol && symbol->ValueIsAddress()) {
- return symbol->GetMangled().GetName(symbol->GetLanguage(), preference);
+ return symbol->GetMangled().GetName(preference);
} else {
// No function, return an empty string.
return ConstString();
@@ -970,7 +968,7 @@ bool SymbolContextSpecifier::AddSpecification(const char *spec_string,
// CompUnits can't necessarily be resolved here, since an inlined function
// might show up in a number of CompUnits. Instead we just convert to a
// FileSpec and store it away.
- m_file_spec_up.reset(new FileSpec(spec_string));
+ m_file_spec_up = std::make_unique<FileSpec>(spec_string);
m_type |= eFileSpecified;
break;
case eLineStartSpecified:
@@ -1076,19 +1074,17 @@ bool SymbolContextSpecifier::SymbolContextMatches(SymbolContext &sc) {
if (inline_info != nullptr) {
was_inlined = true;
const Mangled &name = inline_info->GetMangled();
- if (!name.NameMatches(func_name, sc.function->GetLanguage()))
+ if (!name.NameMatches(func_name))
return false;
}
}
// If it wasn't inlined, check the name in the function or symbol:
if (!was_inlined) {
if (sc.function != nullptr) {
- if (!sc.function->GetMangled().NameMatches(func_name,
- sc.function->GetLanguage()))
+ if (!sc.function->GetMangled().NameMatches(func_name))
return false;
} else if (sc.symbol != nullptr) {
- if (!sc.symbol->GetMangled().NameMatches(func_name,
- sc.symbol->GetLanguage()))
+ if (!sc.symbol->GetMangled().NameMatches(func_name))
return false;
}
}
diff --git a/lldb/source/Symbol/SymbolFile.cpp b/lldb/source/Symbol/SymbolFile.cpp
index 90f7d1011716..3f9cdefc8d41 100644
--- a/lldb/source/Symbol/SymbolFile.cpp
+++ b/lldb/source/Symbol/SymbolFile.cpp
@@ -1,4 +1,4 @@
-//===-- SymbolFile.cpp ------------------------------------------*- C++ -*-===//
+//===-- SymbolFile.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -105,7 +105,7 @@ uint32_t SymbolFile::ResolveSymbolContext(const FileSpec &file_spec,
}
void SymbolFile::FindGlobalVariables(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
+ const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
VariableList &variables) {}
@@ -114,7 +114,7 @@ void SymbolFile::FindGlobalVariables(const RegularExpression &regex,
VariableList &variables) {}
void SymbolFile::FindFunctions(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
+ const CompilerDeclContext &parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines,
SymbolContextList &sc_list) {}
@@ -130,7 +130,7 @@ void SymbolFile::GetMangledNamesForFunction(
}
void SymbolFile::FindTypes(
- ConstString name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {}
diff --git a/lldb/source/Symbol/SymbolVendor.cpp b/lldb/source/Symbol/SymbolVendor.cpp
index 1e1dea71d7f3..0a5acbc48eb4 100644
--- a/lldb/source/Symbol/SymbolVendor.cpp
+++ b/lldb/source/Symbol/SymbolVendor.cpp
@@ -1,4 +1,4 @@
-//===-- SymbolVendor.cpp ----------------------------------------*- C++ -*-===//
+//===-- SymbolVendor.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -51,7 +51,7 @@ SymbolVendor *SymbolVendor::FindPlugin(const lldb::ModuleSP &module_sp,
}
if (!sym_objfile_sp)
sym_objfile_sp = module_sp->GetObjectFile()->shared_from_this();
- instance_up.reset(new SymbolVendor(module_sp));
+ instance_up = std::make_unique<SymbolVendor>(module_sp);
instance_up->AddSymbolFileRepresentation(sym_objfile_sp);
return instance_up.release();
}
diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp
index f5bd22ee5ee2..3f697e6076b3 100644
--- a/lldb/source/Symbol/Symtab.cpp
+++ b/lldb/source/Symbol/Symtab.cpp
@@ -1,4 +1,4 @@
-//===-- Symtab.cpp ----------------------------------------------*- C++ -*-===//
+//===-- Symtab.cpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -299,7 +299,7 @@ void Symtab::InitNameIndexes() {
// Symbol name strings that didn't match a Mangled::ManglingScheme, are
// stored in the demangled field.
- if (ConstString name = mangled.GetDemangledName(symbol->GetLanguage())) {
+ if (ConstString name = mangled.GetDemangledName()) {
m_name_to_index.Append(name, value);
if (symbol->ContainsLinkerAnnotations()) {
@@ -425,7 +425,7 @@ void Symtab::AppendSymbolNamesToMap(const IndexCollection &indexes,
const Mangled &mangled = symbol->GetMangled();
if (add_demangled) {
- if (ConstString name = mangled.GetDemangledName(symbol->GetLanguage()))
+ if (ConstString name = mangled.GetDemangledName())
name_to_index_map.Append(name, value);
}
diff --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp
index f194356a0a07..307e99ac84b6 100644
--- a/lldb/source/Symbol/Type.cpp
+++ b/lldb/source/Symbol/Type.cpp
@@ -1,4 +1,4 @@
-//===-- Type.cpp ------------------------------------------------*- C++ -*-===//
+//===-- Type.cpp ----------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -143,15 +143,14 @@ Type::Type(lldb::user_id_t uid, SymbolFile *symbol_file, ConstString name,
llvm::Optional<uint64_t> byte_size, SymbolContextScope *context,
user_id_t encoding_uid, EncodingDataType encoding_uid_type,
const Declaration &decl, const CompilerType &compiler_type,
- ResolveState compiler_type_resolve_state)
+ ResolveState compiler_type_resolve_state, uint32_t opaque_payload)
: std::enable_shared_from_this<Type>(), UserID(uid), m_name(name),
m_symbol_file(symbol_file), m_context(context), m_encoding_type(nullptr),
m_encoding_uid(encoding_uid), m_encoding_uid_type(encoding_uid_type),
m_decl(decl), m_compiler_type(compiler_type),
- m_compiler_type_resolve_state(
- compiler_type ? compiler_type_resolve_state
- : ResolveState::Unresolved),
- m_is_complete_objc_class(false) {
+ m_compiler_type_resolve_state(compiler_type ? compiler_type_resolve_state
+ : ResolveState::Unresolved),
+ m_payload(opaque_payload) {
if (byte_size) {
m_byte_size = *byte_size;
m_byte_size_has_value = true;
@@ -235,7 +234,7 @@ void Type::GetDescription(Stream *s, lldb::DescriptionLevel level,
}
}
-void Type::Dump(Stream *s, bool show_context) {
+void Type::Dump(Stream *s, bool show_context, lldb::DescriptionLevel level) {
s->Printf("%p: ", static_cast<void *>(this));
s->Indent();
*s << "Type" << static_cast<const UserID &>(*this) << ' ';
@@ -256,7 +255,7 @@ void Type::Dump(Stream *s, bool show_context) {
if (m_compiler_type.IsValid()) {
*s << ", compiler_type = " << m_compiler_type.GetOpaqueQualType() << ' ';
- GetForwardCompilerType().DumpTypeDescription(s);
+ GetForwardCompilerType().DumpTypeDescription(s, level);
} else if (m_encoding_uid != LLDB_INVALID_UID) {
s->Format(", type_data = {0:x-16}", m_encoding_uid);
switch (m_encoding_uid_type) {
@@ -303,7 +302,7 @@ void Type::Dump(Stream *s, bool show_context) {
ConstString Type::GetName() {
if (!m_name)
- m_name = GetForwardCompilerType().GetConstTypeName();
+ m_name = GetForwardCompilerType().GetTypeName();
return m_name;
}
@@ -313,7 +312,7 @@ void Type::DumpValue(ExecutionContext *exe_ctx, Stream *s,
const DataExtractor &data, uint32_t data_byte_offset,
bool show_types, bool show_summary, bool verbose,
lldb::Format format) {
- if (ResolveClangType(ResolveState::Forward)) {
+ if (ResolveCompilerType(ResolveState::Forward)) {
if (show_types) {
s->PutChar('(');
if (verbose)
@@ -466,7 +465,7 @@ bool Type::WriteToMemory(ExecutionContext *exe_ctx, lldb::addr_t addr,
const Declaration &Type::GetDeclaration() const { return m_decl; }
-bool Type::ResolveClangType(ResolveState compiler_type_resolve_state) {
+bool Type::ResolveCompilerType(ResolveState compiler_type_resolve_state) {
// TODO: This needs to consider the correct type system to use.
Type *encoding_type = nullptr;
if (!m_compiler_type.IsValid()) {
@@ -506,7 +505,7 @@ bool Type::ResolveClangType(ResolveState compiler_type_resolve_state) {
case eEncodingIsTypedefUID:
m_compiler_type = encoding_type->GetForwardCompilerType().CreateTypedef(
m_name.AsCString("__lldb_invalid_typedef_name"),
- GetSymbolFile()->GetDeclContextContainingUID(GetID()));
+ GetSymbolFile()->GetDeclContextContainingUID(GetID()), m_payload);
m_name.Clear();
break;
@@ -536,7 +535,7 @@ bool Type::ResolveClangType(ResolveState compiler_type_resolve_state) {
LLDB_LOG_ERROR(
lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_SYMBOLS),
std::move(err),
- "Unable to construct void type from ClangASTContext");
+ "Unable to construct void type from TypeSystemClang");
} else {
CompilerType void_compiler_type =
type_system_or_err->GetBasicTypeFromAST(eBasicTypeVoid);
@@ -564,7 +563,7 @@ bool Type::ResolveClangType(ResolveState compiler_type_resolve_state) {
case eEncodingIsTypedefUID:
m_compiler_type = void_compiler_type.CreateTypedef(
m_name.AsCString("__lldb_invalid_typedef_name"),
- GetSymbolFile()->GetDeclContextContainingUID(GetID()));
+ GetSymbolFile()->GetDeclContextContainingUID(GetID()), m_payload);
break;
case eEncodingIsPointerUID:
@@ -627,7 +626,7 @@ bool Type::ResolveClangType(ResolveState compiler_type_resolve_state) {
break;
}
}
- encoding_type->ResolveClangType(encoding_compiler_type_resolve_state);
+ encoding_type->ResolveCompilerType(encoding_compiler_type_resolve_state);
}
}
return m_compiler_type.IsValid();
@@ -642,22 +641,22 @@ uint32_t Type::GetEncodingMask() {
}
CompilerType Type::GetFullCompilerType() {
- ResolveClangType(ResolveState::Full);
+ ResolveCompilerType(ResolveState::Full);
return m_compiler_type;
}
CompilerType Type::GetLayoutCompilerType() {
- ResolveClangType(ResolveState::Layout);
+ ResolveCompilerType(ResolveState::Layout);
return m_compiler_type;
}
CompilerType Type::GetForwardCompilerType() {
- ResolveClangType(ResolveState::Forward);
+ ResolveCompilerType(ResolveState::Forward);
return m_compiler_type;
}
ConstString Type::GetQualifiedName() {
- return GetForwardCompilerType().GetConstTypeName();
+ return GetForwardCompilerType().GetTypeName();
}
bool Type::GetTypeScopeAndBasename(const llvm::StringRef& name,
diff --git a/lldb/source/Symbol/TypeList.cpp b/lldb/source/Symbol/TypeList.cpp
index 1813e8ecca9a..f0506c7c5bfc 100644
--- a/lldb/source/Symbol/TypeList.cpp
+++ b/lldb/source/Symbol/TypeList.cpp
@@ -1,4 +1,4 @@
-//===-- TypeList.cpp --------------------------------------------*- C++ -*-===//
+//===-- TypeList.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -107,7 +107,8 @@ void TypeList::RemoveMismatchedTypes(const char *qualified_typename,
type_basename = qualified_typename;
type_scope = "";
}
- return RemoveMismatchedTypes(type_scope, type_basename, type_class,
+ return RemoveMismatchedTypes(std::string(type_scope),
+ std::string(type_basename), type_class,
exact_match);
}
diff --git a/lldb/source/Symbol/TypeMap.cpp b/lldb/source/Symbol/TypeMap.cpp
index 4ee1026bed24..e810d3020073 100644
--- a/lldb/source/Symbol/TypeMap.cpp
+++ b/lldb/source/Symbol/TypeMap.cpp
@@ -1,4 +1,4 @@
-//===-- TypeMap.cpp --------------------------------------------*- C++ -*-===//
+//===-- TypeMap.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -121,9 +121,9 @@ bool TypeMap::Remove(const lldb::TypeSP &type_sp) {
return false;
}
-void TypeMap::Dump(Stream *s, bool show_context) {
+void TypeMap::Dump(Stream *s, bool show_context, lldb::DescriptionLevel level) {
for (iterator pos = m_types.begin(), end = m_types.end(); pos != end; ++pos) {
- pos->second->Dump(s, show_context);
+ pos->second->Dump(s, show_context, level);
}
}
@@ -137,7 +137,8 @@ void TypeMap::RemoveMismatchedTypes(const char *qualified_typename,
type_basename = qualified_typename;
type_scope = "";
}
- return RemoveMismatchedTypes(type_scope, type_basename, type_class,
+ return RemoveMismatchedTypes(std::string(type_scope),
+ std::string(type_basename), type_class,
exact_match);
}
diff --git a/lldb/source/Symbol/TypeSystem.cpp b/lldb/source/Symbol/TypeSystem.cpp
index 29a49a6fb1d4..5e57813c28bd 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -1,4 +1,4 @@
-//===-- TypeSystem.cpp ------------------------------------------*- C++ -*-===//
+//===-- TypeSystem.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -70,6 +70,10 @@ lldb::TypeSystemSP TypeSystem::CreateInstance(lldb::LanguageType language,
return CreateInstanceHelper(language, nullptr, target);
}
+#ifndef NDEBUG
+bool TypeSystem::Verify(lldb::opaque_compiler_type_t type) { return true; }
+#endif
+
bool TypeSystem::IsAnonymousType(lldb::opaque_compiler_type_t type) {
return false;
}
@@ -109,7 +113,8 @@ TypeSystem::AddRestrictModifier(lldb::opaque_compiler_type_t type) {
CompilerType TypeSystem::CreateTypedef(lldb::opaque_compiler_type_t type,
const char *name,
- const CompilerDeclContext &decl_ctx) {
+ const CompilerDeclContext &decl_ctx,
+ uint32_t opaque_payload) {
return CompilerType();
}
@@ -239,7 +244,7 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
}
error = llvm::make_error<llvm::StringError>(
"TypeSystem for language " +
- llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+ llvm::StringRef(Language::GetNameForLanguageType(language)) +
" doesn't exist",
llvm::inconvertibleErrorCode());
return std::move(error);
@@ -256,7 +261,7 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
}
error = llvm::make_error<llvm::StringError>(
"TypeSystem for language " +
- llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+ llvm::StringRef(Language::GetNameForLanguageType(language)) +
" doesn't exist",
llvm::inconvertibleErrorCode());
return std::move(error);
@@ -266,7 +271,7 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
if (!can_create) {
error = llvm::make_error<llvm::StringError>(
"Unable to find type system for language " +
- llvm::toStringRef(Language::GetNameForLanguageType(language)),
+ llvm::StringRef(Language::GetNameForLanguageType(language)),
llvm::inconvertibleErrorCode());
} else {
// Cache even if we get a shared pointer that contains a null type system
@@ -279,7 +284,7 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
}
error = llvm::make_error<llvm::StringError>(
"TypeSystem for language " +
- llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+ llvm::StringRef(Language::GetNameForLanguageType(language)) +
" doesn't exist",
llvm::inconvertibleErrorCode());
}
@@ -308,7 +313,7 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
}
error = llvm::make_error<llvm::StringError>(
"TypeSystem for language " +
- llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+ llvm::StringRef(Language::GetNameForLanguageType(language)) +
" doesn't exist",
llvm::inconvertibleErrorCode());
return std::move(error);
@@ -325,7 +330,7 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
}
error = llvm::make_error<llvm::StringError>(
"TypeSystem for language " +
- llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+ llvm::StringRef(Language::GetNameForLanguageType(language)) +
" doesn't exist",
llvm::inconvertibleErrorCode());
return std::move(error);
@@ -335,7 +340,7 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
if (!can_create) {
error = llvm::make_error<llvm::StringError>(
"Unable to find type system for language " +
- llvm::toStringRef(Language::GetNameForLanguageType(language)),
+ llvm::StringRef(Language::GetNameForLanguageType(language)),
llvm::inconvertibleErrorCode());
} else {
// Cache even if we get a shared pointer that contains a null type system
@@ -348,7 +353,7 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType language,
}
error = llvm::make_error<llvm::StringError>(
"TypeSystem for language " +
- llvm::toStringRef(Language::GetNameForLanguageType(language)) +
+ llvm::StringRef(Language::GetNameForLanguageType(language)) +
" doesn't exist",
llvm::inconvertibleErrorCode());
}
diff --git a/lldb/source/Symbol/UnwindPlan.cpp b/lldb/source/Symbol/UnwindPlan.cpp
index 15443ce5d8ac..e8906f38e2ff 100644
--- a/lldb/source/Symbol/UnwindPlan.cpp
+++ b/lldb/source/Symbol/UnwindPlan.cpp
@@ -1,4 +1,4 @@
-//===-- UnwindPlan.cpp ----------------------------------*- C++ -*-===//
+//===-- UnwindPlan.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -15,6 +15,7 @@
#include "lldb/Target/Thread.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/Log.h"
+#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
using namespace lldb;
using namespace lldb_private;
@@ -79,13 +80,10 @@ GetByteOrderAndAddrSize(Thread *thread) {
static void DumpDWARFExpr(Stream &s, llvm::ArrayRef<uint8_t> expr, Thread *thread) {
if (auto order_and_width = GetByteOrderAndAddrSize(thread)) {
- DataExtractor extractor(expr.data(), expr.size(), order_and_width->first,
- order_and_width->second);
- if (!DWARFExpression::PrintDWARFExpression(s, extractor,
- order_and_width->second,
- /*dwarf_ref_size*/ 4,
- /*location_expression*/ false))
- s.PutCString("invalid-dwarf-expr");
+ llvm::DataExtractor data(expr, order_and_width->first == eByteOrderLittle,
+ order_and_width->second);
+ llvm::DWARFExpression(data, order_and_width->second, llvm::dwarf::DWARF32)
+ .print(s.AsRawOstream(), nullptr, nullptr);
} else
s.PutCString("dwarf-expr");
}
diff --git a/lldb/source/Symbol/UnwindTable.cpp b/lldb/source/Symbol/UnwindTable.cpp
index 045957a67b3b..3faa528a339f 100644
--- a/lldb/source/Symbol/UnwindTable.cpp
+++ b/lldb/source/Symbol/UnwindTable.cpp
@@ -1,4 +1,4 @@
-//===-- UnwindTable.cpp -----------------------------------------*- C++ -*-===//
+//===-- UnwindTable.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -57,26 +57,28 @@ void UnwindTable::Initialize() {
SectionSP sect = sl->FindSectionByType(eSectionTypeEHFrame, true);
if (sect.get()) {
- m_eh_frame_up.reset(
- new DWARFCallFrameInfo(*object_file, sect, DWARFCallFrameInfo::EH));
+ m_eh_frame_up = std::make_unique<DWARFCallFrameInfo>(
+ *object_file, sect, DWARFCallFrameInfo::EH);
}
sect = sl->FindSectionByType(eSectionTypeDWARFDebugFrame, true);
if (sect) {
- m_debug_frame_up.reset(
- new DWARFCallFrameInfo(*object_file, sect, DWARFCallFrameInfo::DWARF));
+ m_debug_frame_up = std::make_unique<DWARFCallFrameInfo>(
+ *object_file, sect, DWARFCallFrameInfo::DWARF);
}
sect = sl->FindSectionByType(eSectionTypeCompactUnwind, true);
if (sect) {
- m_compact_unwind_up.reset(new CompactUnwindInfo(*object_file, sect));
+ m_compact_unwind_up =
+ std::make_unique<CompactUnwindInfo>(*object_file, sect);
}
sect = sl->FindSectionByType(eSectionTypeARMexidx, true);
if (sect) {
SectionSP sect_extab = sl->FindSectionByType(eSectionTypeARMextab, true);
if (sect_extab.get()) {
- m_arm_unwind_up.reset(new ArmUnwindInfo(*object_file, sect, sect_extab));
+ m_arm_unwind_up =
+ std::make_unique<ArmUnwindInfo>(*object_file, sect, sect_extab);
}
}
}
diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp
index a0496824a0a3..6c18ef15e1a2 100644
--- a/lldb/source/Symbol/Variable.cpp
+++ b/lldb/source/Symbol/Variable.cpp
@@ -1,4 +1,4 @@
-//===-- Variable.cpp --------------------------------------------*- C++ -*-===//
+//===-- Variable.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -68,7 +68,7 @@ lldb::LanguageType Variable::GetLanguage() const {
}
ConstString Variable::GetName() const {
- ConstString name = m_mangled.GetName(GetLanguage());
+ ConstString name = m_mangled.GetName();
if (name)
return name;
return m_name;
@@ -82,16 +82,13 @@ bool Variable::NameMatches(ConstString name) const {
SymbolContext variable_sc;
m_owner_scope->CalculateSymbolContext(&variable_sc);
- LanguageType language = eLanguageTypeUnknown;
- if (variable_sc.comp_unit)
- language = variable_sc.comp_unit->GetLanguage();
- return m_mangled.NameMatches(name, language);
+ return m_mangled.NameMatches(name);
}
bool Variable::NameMatches(const RegularExpression &regex) const {
if (regex.Execute(m_name.AsCString()))
return true;
if (m_mangled)
- return m_mangled.NameMatches(regex, GetLanguage());
+ return m_mangled.NameMatches(regex);
return false;
}
@@ -532,7 +529,7 @@ static void PrivateAutoCompleteMembers(
i, member_name, nullptr, nullptr, nullptr);
if (partial_member_name.empty() ||
- member_name.find(partial_member_name) == 0) {
+ llvm::StringRef(member_name).startswith(partial_member_name)) {
if (member_name == partial_member_name) {
PrivateAutoComplete(
frame, partial_path,
@@ -684,8 +681,8 @@ static void PrivateAutoComplete(
break;
}
- std::string token(partial_path, 0, pos);
- remaining_partial_path = partial_path.substr(pos);
+ std::string token(std::string(partial_path), 0, pos);
+ remaining_partial_path = std::string(partial_path.substr(pos));
if (compiler_type.IsValid()) {
PrivateAutoCompleteMembers(frame, token, remaining_partial_path,
diff --git a/lldb/source/Symbol/VariableList.cpp b/lldb/source/Symbol/VariableList.cpp
index 51312472e265..f7a441472bc0 100644
--- a/lldb/source/Symbol/VariableList.cpp
+++ b/lldb/source/Symbol/VariableList.cpp
@@ -1,4 +1,4 @@
-//===-- VariableList.cpp ----------------------------------------*- C++ -*-===//
+//===-- VariableList.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/ABI.cpp b/lldb/source/Target/ABI.cpp
index 58396ba70586..4320eb93adfc 100644
--- a/lldb/source/Target/ABI.cpp
+++ b/lldb/source/Target/ABI.cpp
@@ -1,4 +1,4 @@
-//===-- ABI.cpp -------------------------------------------------*- C++ -*-===//
+//===-- ABI.cpp -----------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -17,6 +17,7 @@
#include "lldb/Target/Thread.h"
#include "lldb/Utility/Log.h"
#include "llvm/Support/TargetRegistry.h"
+#include <cctype>
using namespace lldb;
using namespace lldb_private;
@@ -41,20 +42,27 @@ ABI::FindPlugin(lldb::ProcessSP process_sp, const ArchSpec &arch) {
ABI::~ABI() = default;
-bool ABI::GetRegisterInfoByName(ConstString name, RegisterInfo &info) {
+bool RegInfoBasedABI::GetRegisterInfoByName(ConstString name, RegisterInfo &info) {
uint32_t count = 0;
const RegisterInfo *register_info_array = GetRegisterInfoArray(count);
if (register_info_array) {
const char *unique_name_cstr = name.GetCString();
uint32_t i;
for (i = 0; i < count; ++i) {
- if (register_info_array[i].name == unique_name_cstr) {
+ const char *reg_name = register_info_array[i].name;
+ assert(ConstString(reg_name).GetCString() == reg_name &&
+ "register_info_array[i].name not from a ConstString?");
+ if (reg_name == unique_name_cstr) {
info = register_info_array[i];
return true;
}
}
for (i = 0; i < count; ++i) {
- if (register_info_array[i].alt_name == unique_name_cstr) {
+ const char *reg_alt_name = register_info_array[i].alt_name;
+ assert((reg_alt_name == nullptr ||
+ ConstString(reg_alt_name).GetCString() == reg_alt_name) &&
+ "register_info_array[i].alt_name not from a ConstString?");
+ if (reg_alt_name == unique_name_cstr) {
info = register_info_array[i];
return true;
}
@@ -89,10 +97,8 @@ ValueObjectSP ABI::GetReturnValueObject(Thread &thread, CompilerType &ast_type,
if (!persistent_expression_state)
return {};
- auto prefix = persistent_expression_state->GetPersistentVariablePrefix();
ConstString persistent_variable_name =
- persistent_expression_state->GetNextPersistentVariableName(target,
- prefix);
+ persistent_expression_state->GetNextPersistentVariableName();
lldb::ValueObjectSP const_valobj_sp;
@@ -212,7 +218,7 @@ std::unique_ptr<llvm::MCRegisterInfo> ABI::MakeMCRegisterInfo(const ArchSpec &ar
return info_up;
}
-void ABI::AugmentRegisterInfo(RegisterInfo &info) {
+void RegInfoBasedABI::AugmentRegisterInfo(RegisterInfo &info) {
if (info.kinds[eRegisterKindEHFrame] != LLDB_INVALID_REGNUM &&
info.kinds[eRegisterKindDWARF] != LLDB_INVALID_REGNUM)
return;
@@ -228,3 +234,44 @@ void ABI::AugmentRegisterInfo(RegisterInfo &info) {
if (info.kinds[eRegisterKindGeneric] == LLDB_INVALID_REGNUM)
info.kinds[eRegisterKindGeneric] = abi_info.kinds[eRegisterKindGeneric];
}
+
+void MCBasedABI::AugmentRegisterInfo(RegisterInfo &info) {
+ uint32_t eh, dwarf;
+ std::tie(eh, dwarf) = GetEHAndDWARFNums(info.name);
+
+ if (info.kinds[eRegisterKindEHFrame] == LLDB_INVALID_REGNUM)
+ info.kinds[eRegisterKindEHFrame] = eh;
+ if (info.kinds[eRegisterKindDWARF] == LLDB_INVALID_REGNUM)
+ info.kinds[eRegisterKindDWARF] = dwarf;
+ if (info.kinds[eRegisterKindGeneric] == LLDB_INVALID_REGNUM)
+ info.kinds[eRegisterKindGeneric] = GetGenericNum(info.name);
+}
+
+std::pair<uint32_t, uint32_t>
+MCBasedABI::GetEHAndDWARFNums(llvm::StringRef name) {
+ std::string mc_name = GetMCName(name.str());
+ for (char &c : mc_name)
+ c = std::toupper(c);
+ int eh = -1;
+ int dwarf = -1;
+ for (unsigned reg = 0; reg < m_mc_register_info_up->getNumRegs(); ++reg) {
+ if (m_mc_register_info_up->getName(reg) == mc_name) {
+ eh = m_mc_register_info_up->getDwarfRegNum(reg, /*isEH=*/true);
+ dwarf = m_mc_register_info_up->getDwarfRegNum(reg, /*isEH=*/false);
+ break;
+ }
+ }
+ return std::pair<uint32_t, uint32_t>(eh == -1 ? LLDB_INVALID_REGNUM : eh,
+ dwarf == -1 ? LLDB_INVALID_REGNUM
+ : dwarf);
+}
+
+void MCBasedABI::MapRegisterName(std::string &name, llvm::StringRef from_prefix,
+ llvm::StringRef to_prefix) {
+ llvm::StringRef name_ref = name;
+ if (!name_ref.consume_front(from_prefix))
+ return;
+ uint64_t _;
+ if (name_ref.empty() || to_integer(name_ref, _, 10))
+ name = (to_prefix + name_ref).str();
+}
diff --git a/lldb/source/Target/AssertFrameRecognizer.cpp b/lldb/source/Target/AssertFrameRecognizer.cpp
new file mode 100644
index 000000000000..d87459ac2fdd
--- /dev/null
+++ b/lldb/source/Target/AssertFrameRecognizer.cpp
@@ -0,0 +1,168 @@
+#include "lldb/Core/Module.h"
+#include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/StackFrameList.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
+
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Logging.h"
+
+#include "lldb/Target/AssertFrameRecognizer.h"
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_private;
+
+namespace lldb_private {
+
+/// Stores a function module spec, symbol name and possibly an alternate symbol
+/// name.
+struct SymbolLocation {
+ FileSpec module_spec;
+ std::vector<ConstString> symbols;
+};
+
+/// Fetches the abort frame location depending on the current platform.
+///
+/// \param[in] os
+/// The target's os type.
+/// \param[in,out] location
+/// The struct that will contain the abort module spec and symbol names.
+/// \return
+/// \b true, if the platform is supported
+/// \b false, otherwise.
+bool GetAbortLocation(llvm::Triple::OSType os, SymbolLocation &location) {
+ switch (os) {
+ case llvm::Triple::Darwin:
+ case llvm::Triple::MacOSX:
+ location.module_spec = FileSpec("libsystem_kernel.dylib");
+ location.symbols.push_back(ConstString("__pthread_kill"));
+ break;
+ case llvm::Triple::Linux:
+ location.module_spec = FileSpec("libc.so.6");
+ location.symbols.push_back(ConstString("raise"));
+ location.symbols.push_back(ConstString("__GI_raise"));
+ location.symbols.push_back(ConstString("gsignal"));
+ break;
+ default:
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND));
+ LLDB_LOG(log, "AssertFrameRecognizer::GetAbortLocation Unsupported OS");
+ return false;
+ }
+
+ return true;
+}
+
+/// Fetches the assert frame location depending on the current platform.
+///
+/// \param[in] os
+/// The target's os type.
+/// \param[in,out] location
+/// The struct that will contain the assert module spec and symbol names.
+/// \return
+/// \b true, if the platform is supported
+/// \b false, otherwise.
+bool GetAssertLocation(llvm::Triple::OSType os, SymbolLocation &location) {
+ switch (os) {
+ case llvm::Triple::Darwin:
+ case llvm::Triple::MacOSX:
+ location.module_spec = FileSpec("libsystem_c.dylib");
+ location.symbols.push_back(ConstString("__assert_rtn"));
+ break;
+ case llvm::Triple::Linux:
+ location.module_spec = FileSpec("libc.so.6");
+ location.symbols.push_back(ConstString("__assert_fail"));
+ location.symbols.push_back(ConstString("__GI___assert_fail"));
+ break;
+ default:
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND));
+ LLDB_LOG(log, "AssertFrameRecognizer::GetAssertLocation Unsupported OS");
+ return false;
+ }
+
+ return true;
+}
+
+void RegisterAssertFrameRecognizer(Process *process) {
+ static llvm::once_flag g_once_flag;
+ llvm::call_once(g_once_flag, [process]() {
+ Target &target = process->GetTarget();
+ llvm::Triple::OSType os = target.GetArchitecture().GetTriple().getOS();
+ SymbolLocation location;
+
+ if (!GetAbortLocation(os, location))
+ return;
+
+ StackFrameRecognizerManager::AddRecognizer(
+ StackFrameRecognizerSP(new AssertFrameRecognizer()),
+ location.module_spec.GetFilename(), location.symbols,
+ /*first_instruction_only*/ false);
+ });
+}
+
+} // namespace lldb_private
+
+lldb::RecognizedStackFrameSP
+AssertFrameRecognizer::RecognizeFrame(lldb::StackFrameSP frame_sp) {
+ ThreadSP thread_sp = frame_sp->GetThread();
+ ProcessSP process_sp = thread_sp->GetProcess();
+ Target &target = process_sp->GetTarget();
+ llvm::Triple::OSType os = target.GetArchitecture().GetTriple().getOS();
+ SymbolLocation location;
+
+ if (!GetAssertLocation(os, location))
+ return RecognizedStackFrameSP();
+
+ const uint32_t frames_to_fetch = 5;
+ const uint32_t last_frame_index = frames_to_fetch - 1;
+ StackFrameSP prev_frame_sp = nullptr;
+
+ // Fetch most relevant frame
+ for (uint32_t frame_index = 0; frame_index < frames_to_fetch; frame_index++) {
+ prev_frame_sp = thread_sp->GetStackFrameAtIndex(frame_index);
+
+ if (!prev_frame_sp) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND));
+ LLDB_LOG(log, "Abort Recognizer: Hit unwinding bound ({1} frames)!",
+ frames_to_fetch);
+ break;
+ }
+
+ SymbolContext sym_ctx =
+ prev_frame_sp->GetSymbolContext(eSymbolContextEverything);
+
+ if (!sym_ctx.module_sp->GetFileSpec().FileEquals(location.module_spec))
+ continue;
+
+ ConstString func_name = sym_ctx.GetFunctionName();
+
+ if (llvm::is_contained(location.symbols, func_name)) {
+ // We go a frame beyond the assert location because the most relevant
+ // frame for the user is the one in which the assert function was called.
+ // If the assert location is the last frame fetched, then it is set as
+ // the most relevant frame.
+
+ StackFrameSP most_relevant_frame_sp = thread_sp->GetStackFrameAtIndex(
+ std::min(frame_index + 1, last_frame_index));
+
+ // Pass assert location to AbortRecognizedStackFrame to set as most
+ // relevant frame.
+ return lldb::RecognizedStackFrameSP(
+ new AssertRecognizedStackFrame(most_relevant_frame_sp));
+ }
+ }
+
+ return RecognizedStackFrameSP();
+}
+
+AssertRecognizedStackFrame::AssertRecognizedStackFrame(
+ StackFrameSP most_relevant_frame_sp)
+ : m_most_relevant_frame(most_relevant_frame_sp) {
+ m_stop_desc = "hit program assert";
+}
+
+lldb::StackFrameSP AssertRecognizedStackFrame::GetMostRelevantFrame() {
+ return m_most_relevant_frame;
+}
diff --git a/lldb/source/Target/ExecutionContext.cpp b/lldb/source/Target/ExecutionContext.cpp
index a24a098eb300..20932ee63dce 100644
--- a/lldb/source/Target/ExecutionContext.cpp
+++ b/lldb/source/Target/ExecutionContext.cpp
@@ -1,4 +1,4 @@
-//===-- ExecutionContext.cpp ------------------------------------*- C++ -*-===//
+//===-- ExecutionContext.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/InstrumentationRuntime.cpp b/lldb/source/Target/InstrumentationRuntime.cpp
index 4c2eb064fbb0..9f22a1be20cc 100644
--- a/lldb/source/Target/InstrumentationRuntime.cpp
+++ b/lldb/source/Target/InstrumentationRuntime.cpp
@@ -1,4 +1,4 @@
-//===-- InstrumentationRuntime.cpp ------------------------------*- C++ -*-===//
+//===-- InstrumentationRuntime.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp b/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp
index f2767ffbff0d..7f82581cc601 100644
--- a/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp
+++ b/lldb/source/Target/InstrumentationRuntimeStopInfo.cpp
@@ -1,4 +1,4 @@
-//===-- InstrumentationRuntimeStopInfo.cpp ----------------------*- C++ -*-===//
+//===-- InstrumentationRuntimeStopInfo.cpp --------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/JITLoader.cpp b/lldb/source/Target/JITLoader.cpp
index e7c13bddcb36..8ff349e063b6 100644
--- a/lldb/source/Target/JITLoader.cpp
+++ b/lldb/source/Target/JITLoader.cpp
@@ -1,4 +1,4 @@
-//===-- JITLoader.cpp -------------------------------------------*- C++ -*-===//
+//===-- JITLoader.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/JITLoaderList.cpp b/lldb/source/Target/JITLoaderList.cpp
index 4d1f06d0843e..f5a90d58d588 100644
--- a/lldb/source/Target/JITLoaderList.cpp
+++ b/lldb/source/Target/JITLoaderList.cpp
@@ -1,4 +1,4 @@
-//===-- JITLoaderList.cpp ---------------------------------------*- C++ -*-===//
+//===-- JITLoaderList.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/Language.cpp b/lldb/source/Target/Language.cpp
index 10a9ddd56c44..b1a8a9517f3f 100644
--- a/lldb/source/Target/Language.cpp
+++ b/lldb/source/Target/Language.cpp
@@ -1,5 +1,4 @@
-//===-- Language.cpp -------------------------------------------------*- C++
-//-*-===//
+//===-- Language.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -140,13 +139,6 @@ Language::GetPossibleFormattersMatches(ValueObject &valobj,
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;
diff --git a/lldb/source/Target/LanguageRuntime.cpp b/lldb/source/Target/LanguageRuntime.cpp
index 32dd805a00b1..58ad70c2b902 100644
--- a/lldb/source/Target/LanguageRuntime.cpp
+++ b/lldb/source/Target/LanguageRuntime.cpp
@@ -1,4 +1,4 @@
-//===-- LanguageRuntime.cpp -------------------------------------*- C++ -*-===//
+//===-- LanguageRuntime.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -78,8 +78,7 @@ void ExceptionSearchFilter::UpdateModuleListIfNeeded() {
}
}
-SearchFilterSP
-ExceptionSearchFilter::DoCopyForBreakpoint(Breakpoint &breakpoint) {
+SearchFilterSP ExceptionSearchFilter::DoCreateCopy() {
return SearchFilterSP(
new ExceptionSearchFilter(TargetSP(), m_language, false));
}
@@ -154,17 +153,17 @@ public:
}
protected:
- BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override {
+ BreakpointResolverSP CopyForBreakpoint(BreakpointSP &breakpoint) override {
BreakpointResolverSP ret_sp(
new ExceptionBreakpointResolver(m_language, m_catch_bp, m_throw_bp));
- ret_sp->SetBreakpoint(&breakpoint);
+ ret_sp->SetBreakpoint(breakpoint);
return ret_sp;
}
bool SetActualResolver() {
- ProcessSP process_sp;
- if (m_breakpoint) {
- process_sp = m_breakpoint->GetTarget().GetProcessSP();
+ BreakpointSP breakpoint_sp = GetBreakpoint();
+ if (breakpoint_sp) {
+ ProcessSP process_sp = breakpoint_sp->GetTarget().GetProcessSP();
if (process_sp) {
bool refreash_resolver = !m_actual_resolver_sp;
if (m_language_runtime == nullptr) {
@@ -181,7 +180,7 @@ protected:
if (refreash_resolver && m_language_runtime) {
m_actual_resolver_sp = m_language_runtime->CreateExceptionResolver(
- m_breakpoint, m_catch_bp, m_throw_bp);
+ breakpoint_sp, m_catch_bp, m_throw_bp);
}
} else {
m_actual_resolver_sp.reset();
diff --git a/lldb/source/Target/Memory.cpp b/lldb/source/Target/Memory.cpp
index 7c77cc06eb03..a7ed1a3d97b7 100644
--- a/lldb/source/Target/Memory.cpp
+++ b/lldb/source/Target/Memory.cpp
@@ -1,4 +1,4 @@
-//===-- Memory.cpp ----------------------------------------------*- C++ -*-===//
+//===-- Memory.cpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -116,7 +116,7 @@ bool MemoryCache::RemoveInvalidRange(lldb::addr_t base_addr,
const InvalidRanges::Entry *entry = m_invalid_ranges.GetEntryAtIndex(idx);
if (entry->GetRangeBase() == base_addr &&
entry->GetByteSize() == byte_size)
- return m_invalid_ranges.RemoveEntrtAtIndex(idx);
+ return m_invalid_ranges.RemoveEntryAtIndex(idx);
}
}
return false;
@@ -232,8 +232,13 @@ size_t MemoryCache::Read(addr_t addr, void *dst, size_t dst_len,
if (process_bytes_read == 0)
return dst_len - bytes_left;
- if (process_bytes_read != cache_line_byte_size)
+ if (process_bytes_read != cache_line_byte_size) {
+ if (process_bytes_read < data_buffer_heap_up->GetByteSize()) {
+ dst_len -= data_buffer_heap_up->GetByteSize() - process_bytes_read;
+ bytes_left = process_bytes_read;
+ }
data_buffer_heap_up->SetByteSize(process_bytes_read);
+ }
m_L2_cache[curr_addr] = DataBufferSP(data_buffer_heap_up.release());
// We have read data and put it into the cache, continue through the
// loop again to get the data out of the cache...
diff --git a/lldb/source/Target/MemoryHistory.cpp b/lldb/source/Target/MemoryHistory.cpp
index 37148e1e72e9..0ebf796a56bb 100644
--- a/lldb/source/Target/MemoryHistory.cpp
+++ b/lldb/source/Target/MemoryHistory.cpp
@@ -1,4 +1,4 @@
-//===-- MemoryHistory.cpp ---------------------------------------*- C++ -*-===//
+//===-- MemoryHistory.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/MemoryRegionInfo.cpp b/lldb/source/Target/MemoryRegionInfo.cpp
index 2c31563786aa..c7fb349ee1cc 100644
--- a/lldb/source/Target/MemoryRegionInfo.cpp
+++ b/lldb/source/Target/MemoryRegionInfo.cpp
@@ -1,4 +1,4 @@
-//===-- MemoryRegionInfo.cpp ------------------------------------*- C++ -*-===//
+//===-- MemoryRegionInfo.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/ModuleCache.cpp b/lldb/source/Target/ModuleCache.cpp
index 124cdacfb4d2..20661a7b7a25 100644
--- a/lldb/source/Target/ModuleCache.cpp
+++ b/lldb/source/Target/ModuleCache.cpp
@@ -1,4 +1,4 @@
-//===--------------------- ModuleCache.cpp ----------------------*- C++ -*-===//
+//===-- ModuleCache.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -169,7 +169,7 @@ ModuleLock::ModuleLock(const FileSpec &root_dir_spec, const UUID &uuid,
return;
}
- m_lock.reset(new lldb_private::LockFile(m_file_up->GetDescriptor()));
+ m_lock = std::make_unique<lldb_private::LockFile>(m_file_up->GetDescriptor());
error = m_lock->WriteLock(0, 1);
if (error.Fail())
error.SetErrorStringWithFormat("Failed to lock file: %s",
diff --git a/lldb/source/Target/OperatingSystem.cpp b/lldb/source/Target/OperatingSystem.cpp
index c78c197db5be..ddffab4553cc 100644
--- a/lldb/source/Target/OperatingSystem.cpp
+++ b/lldb/source/Target/OperatingSystem.cpp
@@ -1,4 +1,4 @@
-//===-- OperatingSystem.cpp -------------------------------------*- C++ -*-===//
+//===-- OperatingSystem.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/PathMappingList.cpp b/lldb/source/Target/PathMappingList.cpp
index 58c2c43c9368..b22673f55471 100644
--- a/lldb/source/Target/PathMappingList.cpp
+++ b/lldb/source/Target/PathMappingList.cpp
@@ -1,4 +1,4 @@
-//===-- PathMappingList.cpp -------------------------------------*- C++ -*-===//
+//===-- PathMappingList.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index aaf48f35f921..16787141bee0 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -1,4 +1,4 @@
-//===-- Platform.cpp --------------------------------------------*- C++ -*-===//
+//===-- Platform.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -12,9 +12,6 @@
#include <memory>
#include <vector>
-#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/Path.h"
-
#include "lldb/Breakpoint/BreakpointIDList.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
@@ -26,6 +23,7 @@
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/OptionParser.h"
+#include "lldb/Interpreter/OptionValueFileSpec.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Interpreter/Property.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -39,8 +37,8 @@
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StructuredData.h"
-
#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
// Define these constants from POSIX mman.h rather than include the file so
// that they will be correct even when compiled on Linux.
@@ -93,6 +91,7 @@ PlatformProperties::PlatformProperties() {
module_cache_dir = FileSpec(user_home_dir.c_str());
module_cache_dir.AppendPathComponent(".lldb");
module_cache_dir.AppendPathComponent("module_cache");
+ SetDefaultModuleCacheDirectory(module_cache_dir);
SetModuleCacheDirectory(module_cache_dir);
}
@@ -117,6 +116,14 @@ bool PlatformProperties::SetModuleCacheDirectory(const FileSpec &dir_spec) {
nullptr, ePropertyModuleCacheDirectory, dir_spec);
}
+void PlatformProperties::SetDefaultModuleCacheDirectory(
+ const FileSpec &dir_spec) {
+ auto f_spec_opt = m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpec(
+ nullptr, false, ePropertyModuleCacheDirectory);
+ assert(f_spec_opt);
+ f_spec_opt->SetDefaultValue(dir_spec);
+}
+
/// Get the native host platform plug-in.
///
/// There should only be one of these for each host that LLDB runs
@@ -421,9 +428,6 @@ void Platform::GetStatus(Stream &strm) {
strm.EOL();
}
- if (GetOSKernelDescription(s))
- strm.Printf(" Kernel: %s\n", s.c_str());
-
if (IsHost()) {
strm.Printf(" Hostname: %s\n", GetHostname());
} else {
@@ -443,6 +447,9 @@ void Platform::GetStatus(Stream &strm) {
if (!specific_info.empty())
strm.Printf("Platform-specific connection: %s\n", specific_info.c_str());
+
+ if (GetOSKernelDescription(s))
+ strm.Printf(" Kernel: %s\n", s.c_str());
}
llvm::VersionTuple Platform::GetOSVersion(Process *process) {
@@ -1144,10 +1151,10 @@ Platform::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
process_sp->SetShouldDetach(false);
// If we didn't have any file actions, the pseudo terminal might have
- // been used where the slave side was given as the file to open for
+ // been used where the secondary side was given as the file to open for
// stdin/out/err after we have already opened the master so we can
// read/write stdin/out/err.
- int pty_fd = launch_info.GetPTY().ReleaseMasterFileDescriptor();
+ int pty_fd = launch_info.GetPTY().ReleasePrimaryFileDescriptor();
if (pty_fd != PseudoTerminal::invalid_fd) {
process_sp->SetSTDIOFileDescriptor(pty_fd);
}
@@ -1400,11 +1407,11 @@ OptionGroupPlatformRSync::SetOptionValue(uint32_t option_idx,
break;
case 'R':
- m_rsync_opts.assign(option_arg);
+ m_rsync_opts.assign(std::string(option_arg));
break;
case 'P':
- m_rsync_prefix.assign(option_arg);
+ m_rsync_prefix.assign(std::string(option_arg));
break;
case 'i':
@@ -1446,7 +1453,7 @@ OptionGroupPlatformSSH::SetOptionValue(uint32_t option_idx,
break;
case 'S':
- m_ssh_opts.assign(option_arg);
+ m_ssh_opts.assign(std::string(option_arg));
break;
default:
@@ -1473,7 +1480,7 @@ lldb_private::Status OptionGroupPlatformCaching::SetOptionValue(
char short_option = (char)GetDefinitions()[option_idx].short_option;
switch (short_option) {
case 'c':
- m_cache_dir.assign(option_arg);
+ m_cache_dir.assign(std::string(option_arg));
break;
default:
@@ -1764,9 +1771,23 @@ Status Platform::UnloadImage(lldb_private::Process *process,
lldb::ProcessSP Platform::ConnectProcess(llvm::StringRef connect_url,
llvm::StringRef plugin_name,
- lldb_private::Debugger &debugger,
- lldb_private::Target *target,
- lldb_private::Status &error) {
+ Debugger &debugger, Target *target,
+ Status &error) {
+ return DoConnectProcess(connect_url, plugin_name, debugger, nullptr, target,
+ error);
+}
+
+lldb::ProcessSP Platform::ConnectProcessSynchronous(
+ llvm::StringRef connect_url, llvm::StringRef plugin_name,
+ Debugger &debugger, Stream &stream, Target *target, Status &error) {
+ return DoConnectProcess(connect_url, plugin_name, debugger, &stream, target,
+ error);
+}
+
+lldb::ProcessSP Platform::DoConnectProcess(llvm::StringRef connect_url,
+ llvm::StringRef plugin_name,
+ Debugger &debugger, Stream *stream,
+ Target *target, Status &error) {
error.Clear();
if (!target) {
@@ -1793,12 +1814,34 @@ lldb::ProcessSP Platform::ConnectProcess(llvm::StringRef connect_url,
lldb::ProcessSP process_sp =
target->CreateProcess(debugger.GetListener(), plugin_name, nullptr);
+
if (!process_sp)
return nullptr;
- error = process_sp->ConnectRemote(&debugger.GetOutputStream(), connect_url);
- if (error.Fail())
+ // If this private method is called with a stream we are synchronous.
+ const bool synchronous = stream != nullptr;
+
+ ListenerSP listener_sp(
+ Listener::MakeListener("lldb.Process.ConnectProcess.hijack"));
+ if (synchronous)
+ process_sp->HijackProcessEvents(listener_sp);
+
+ error = process_sp->ConnectRemote(connect_url);
+ if (error.Fail()) {
+ if (synchronous)
+ process_sp->RestoreProcessEvents();
return nullptr;
+ }
+
+ if (synchronous) {
+ EventSP event_sp;
+ process_sp->WaitForProcessToStop(llvm::None, &event_sp, true, listener_sp,
+ nullptr);
+ process_sp->RestoreProcessEvents();
+ bool pop_process_io_handler = false;
+ Process::HandleProcessStateChangedEvent(event_sp, stream,
+ pop_process_io_handler);
+ }
return process_sp;
}
@@ -1812,6 +1855,7 @@ size_t Platform::ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
size_t Platform::GetSoftwareBreakpointTrapOpcode(Target &target,
BreakpointSite *bp_site) {
ArchSpec arch = target.GetArchitecture();
+ assert(arch.IsValid());
const uint8_t *trap_opcode = nullptr;
size_t trap_opcode_size = 0;
@@ -1855,6 +1899,12 @@ size_t Platform::GetSoftwareBreakpointTrapOpcode(Target &target,
}
} break;
+ case llvm::Triple::avr: {
+ static const uint8_t g_hex_opcode[] = {0x98, 0x95};
+ trap_opcode = g_hex_opcode;
+ trap_opcode_size = sizeof(g_hex_opcode);
+ } break;
+
case llvm::Triple::mips:
case llvm::Triple::mips64: {
static const uint8_t g_hex_opcode[] = {0x00, 0x00, 0x00, 0x0d};
@@ -1902,8 +1952,7 @@ size_t Platform::GetSoftwareBreakpointTrapOpcode(Target &target,
} break;
default:
- llvm_unreachable(
- "Unhandled architecture in Platform::GetSoftwareBreakpointTrapOpcode");
+ return 0;
}
assert(bp_site);
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 6711dc37eca6..d777a2713911 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -1,4 +1,4 @@
-//===-- Process.cpp ---------------------------------------------*- C++ -*-===//
+//===-- Process.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -38,6 +38,7 @@
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ABI.h"
+#include "lldb/Target/AssertFrameRecognizer.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/InstrumentationRuntime.h"
#include "lldb/Target/JITLoader.h"
@@ -59,6 +60,7 @@
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/ThreadPlanBase.h"
#include "lldb/Target/ThreadPlanCallFunction.h"
+#include "lldb/Target/ThreadPlanStack.h"
#include "lldb/Target/UnixSignals.h"
#include "lldb/Utility/Event.h"
#include "lldb/Utility/Log.h"
@@ -118,8 +120,30 @@ public:
enum {
#define LLDB_PROPERTIES_process
#include "TargetPropertiesEnum.inc"
+ ePropertyExperimental,
};
+#define LLDB_PROPERTIES_process_experimental
+#include "TargetProperties.inc"
+
+enum {
+#define LLDB_PROPERTIES_process_experimental
+#include "TargetPropertiesEnum.inc"
+};
+
+class ProcessExperimentalOptionValueProperties : public OptionValueProperties {
+public:
+ ProcessExperimentalOptionValueProperties()
+ : OptionValueProperties(
+ ConstString(Properties::GetExperimentalSettingsName())) {}
+};
+
+ProcessExperimentalProperties::ProcessExperimentalProperties()
+ : Properties(OptionValuePropertiesSP(
+ new ProcessExperimentalOptionValueProperties())) {
+ m_collection_sp->Initialize(g_process_experimental_properties);
+}
+
ProcessProperties::ProcessProperties(lldb_private::Process *process)
: Properties(),
m_process(process) // Can be nullptr for global ProcessProperties
@@ -139,6 +163,14 @@ ProcessProperties::ProcessProperties(lldb_private::Process *process)
ePropertyPythonOSPluginPath,
[this] { m_process->LoadOperatingSystemPlugin(true); });
}
+
+ m_experimental_properties_up =
+ std::make_unique<ProcessExperimentalProperties>();
+ m_collection_sp->AppendProperty(
+ ConstString(Properties::GetExperimentalSettingsName()),
+ ConstString("Experimental settings - setting these won't produce "
+ "errors if the setting is not present."),
+ true, m_experimental_properties_up->GetValueProperties());
}
ProcessProperties::~ProcessProperties() = default;
@@ -227,6 +259,12 @@ bool ProcessProperties::GetWarningsOptimization() const {
nullptr, idx, g_process_properties[idx].default_uint_value != 0);
}
+bool ProcessProperties::GetWarningsUnsupportedLanguage() const {
+ const uint32_t idx = ePropertyWarningUnsupportedLanguage;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(
+ nullptr, idx, g_process_properties[idx].default_uint_value != 0);
+}
+
bool ProcessProperties::GetStopOnExec() const {
const uint32_t idx = ePropertyStopOnExec;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
@@ -240,6 +278,29 @@ std::chrono::seconds ProcessProperties::GetUtilityExpressionTimeout() const {
return std::chrono::seconds(value);
}
+bool ProcessProperties::GetOSPluginReportsAllThreads() const {
+ const bool fail_value = true;
+ const Property *exp_property =
+ m_collection_sp->GetPropertyAtIndex(nullptr, true, ePropertyExperimental);
+ OptionValueProperties *exp_values =
+ exp_property->GetValue()->GetAsProperties();
+ if (!exp_values)
+ return fail_value;
+
+ return exp_values->GetPropertyAtIndexAsBoolean(
+ nullptr, ePropertyOSPluginReportsAllThreads, fail_value);
+}
+
+void ProcessProperties::SetOSPluginReportsAllThreads(bool does_report) {
+ const Property *exp_property =
+ m_collection_sp->GetPropertyAtIndex(nullptr, true, ePropertyExperimental);
+ OptionValueProperties *exp_values =
+ exp_property->GetValue()->GetAsProperties();
+ if (exp_values)
+ exp_values->SetPropertyAtIndexAsBoolean(
+ nullptr, ePropertyOSPluginReportsAllThreads, does_report);
+}
+
Status ProcessLaunchCommandOptions::SetOptionValue(
uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) {
@@ -476,7 +537,7 @@ Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp,
m_mod_id(), m_process_unique_id(0), m_thread_index_id(0),
m_thread_id_to_index_id_map(), m_exit_status(-1), m_exit_string(),
m_exit_status_mutex(), m_thread_mutex(), m_thread_list_real(this),
- m_thread_list(this), m_extended_thread_list(this),
+ m_thread_list(this), m_thread_plans(*this), m_extended_thread_list(this),
m_extended_thread_stop_id(0), m_queue_list(this), m_queue_list_stop_id(0),
m_notifications(), m_image_tokens(), m_listener_sp(listener_sp),
m_breakpoint_site_list(), m_dynamic_checkers_up(),
@@ -538,6 +599,8 @@ Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp,
target_sp->GetPlatform()->GetDefaultMemoryCacheLineSize();
if (!value_sp->OptionWasSet() && platform_cache_line_size != 0)
value_sp->SetUInt64Value(platform_cache_line_size);
+
+ RegisterAssertFrameRecognizer(this);
}
Process::~Process() {
@@ -597,6 +660,7 @@ void Process::Finalize() {
m_system_runtime_up.reset();
m_dyld_up.reset();
m_jit_loaders_up.reset();
+ m_thread_plans.Clear();
m_thread_list_real.Destroy();
m_thread_list.Destroy();
m_extended_thread_list.Destroy();
@@ -934,11 +998,17 @@ bool Process::HandleProcessStateChangedEvent(const EventSP &event_sp,
Debugger &debugger = process_sp->GetTarget().GetDebugger();
if (debugger.GetTargetList().GetSelectedTarget().get() ==
&process_sp->GetTarget()) {
+ ThreadSP thread_sp = process_sp->GetThreadList().GetSelectedThread();
+
+ if (!thread_sp || !thread_sp->IsValid())
+ return false;
+
const bool only_threads_with_stop_reason = true;
- const uint32_t start_frame = 0;
+ const uint32_t start_frame = thread_sp->GetSelectedFrameIndex();
const uint32_t num_frames = 1;
const uint32_t num_frames_with_source = 1;
const bool stop_format = true;
+
process_sp->GetStatus(*stream);
process_sp->GetThreadStatus(*stream, only_threads_with_stop_reason,
start_frame, num_frames,
@@ -949,14 +1019,11 @@ bool Process::HandleProcessStateChangedEvent(const EventSP &event_sp,
ValueObjectSP valobj_sp = StopInfo::GetCrashingDereference(
curr_thread_stop_info_sp, &crashing_address);
if (valobj_sp) {
- const bool qualify_cxx_base_classes = false;
-
const ValueObject::GetExpressionPathFormat format =
ValueObject::GetExpressionPathFormat::
eGetExpressionPathFormatHonorPointers;
stream->PutCString("Likely cause: ");
- valobj_sp->GetExpressionPath(*stream, qualify_cxx_base_classes,
- format);
+ valobj_sp->GetExpressionPath(*stream, format);
stream->Printf(" accessed 0x%" PRIx64 "\n", crashing_address);
}
}
@@ -1176,9 +1243,12 @@ void Process::UpdateThreadListIfNeeded() {
const uint32_t stop_id = GetStopID();
if (m_thread_list.GetSize(false) == 0 ||
stop_id != m_thread_list.GetStopID()) {
+ bool clear_unused_threads = true;
const StateType state = GetPrivateState();
if (StateIsStoppedState(state, true)) {
std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex());
+ m_thread_list.SetStopID(stop_id);
+
// m_thread_list does have its own mutex, but we need to hold onto the
// mutex between the call to UpdateThreadList(...) and the
// os->UpdateThreadList(...) so it doesn't change on us
@@ -1199,6 +1269,10 @@ void Process::UpdateThreadListIfNeeded() {
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();
+ // See if the OS plugin reports all threads. If it does, then
+ // it is safe to clear unseen thread's plans here. Otherwise we
+ // should preserve them in case they show up again:
+ clear_unused_threads = GetOSPluginReportsAllThreads();
// 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
@@ -1225,7 +1299,7 @@ void Process::UpdateThreadListIfNeeded() {
target.SetPreferDynamicValue(saved_prefer_dynamic);
} else {
// No OS plug-in, the new thread list is the same as the real thread
- // list
+ // list.
new_thread_list = real_thread_list;
}
@@ -1242,10 +1316,42 @@ void Process::UpdateThreadListIfNeeded() {
m_queue_list_stop_id = GetLastNaturalStopID();
}
}
+ // Now update the plan stack map.
+ // If we do have an OS plugin, any absent real threads in the
+ // m_thread_list have already been removed from the ThreadPlanStackMap.
+ // So any remaining threads are OS Plugin threads, and those we want to
+ // preserve in case they show up again.
+ m_thread_plans.Update(m_thread_list, clear_unused_threads);
}
}
}
+ThreadPlanStack *Process::FindThreadPlans(lldb::tid_t tid) {
+ return m_thread_plans.Find(tid);
+}
+
+bool Process::PruneThreadPlansForTID(lldb::tid_t tid) {
+ return m_thread_plans.PrunePlansForTID(tid);
+}
+
+void Process::PruneThreadPlans() {
+ m_thread_plans.Update(GetThreadList(), true, false);
+}
+
+bool Process::DumpThreadPlansForTID(Stream &strm, lldb::tid_t tid,
+ lldb::DescriptionLevel desc_level,
+ bool internal, bool condense_trivial,
+ bool skip_unreported_plans) {
+ return m_thread_plans.DumpPlansForTID(
+ strm, tid, desc_level, internal, condense_trivial, skip_unreported_plans);
+}
+void Process::DumpThreadPlans(Stream &strm, lldb::DescriptionLevel desc_level,
+ bool internal, bool condense_trivial,
+ bool skip_unreported_plans) {
+ m_thread_plans.DumpPlans(strm, desc_level, internal, condense_trivial,
+ skip_unreported_plans);
+}
+
void Process::UpdateQueueListIfNeeded() {
if (m_system_runtime_up) {
if (m_queue_list.GetSize() == 0 ||
@@ -2643,7 +2749,7 @@ DataExtractor Process::GetAuxvData() { return DataExtractor(); }
JITLoaderList &Process::GetJITLoaders() {
if (!m_jit_loaders_up) {
- m_jit_loaders_up.reset(new JITLoaderList());
+ m_jit_loaders_up = std::make_unique<JITLoaderList>();
JITLoader::LoadPlugins(this, *m_jit_loaders_up);
}
return *m_jit_loaders_up;
@@ -2793,9 +2899,9 @@ Status Process::Attach(ProcessAttachInfo &attach_info) {
match_info.GetProcessInfo() = attach_info;
match_info.SetNameMatchType(NameMatch::Equals);
platform_sp->FindProcesses(match_info, process_infos);
- const uint32_t num_matches = process_infos.GetSize();
+ const uint32_t num_matches = process_infos.size();
if (num_matches == 1) {
- attach_pid = process_infos.GetProcessIDAtIndex(0);
+ attach_pid = process_infos[0].GetProcessID();
// Fall through and attach using the above process ID
} else {
match_info.GetProcessInfo().GetExecutableFile().GetPath(
@@ -2804,7 +2910,7 @@ Status Process::Attach(ProcessAttachInfo &attach_info) {
StreamString s;
ProcessInstanceInfo::DumpTableHeader(s, true, false);
for (size_t i = 0; i < num_matches; i++) {
- process_infos.GetProcessInfoAtIndex(i).DumpAsTableRow(
+ process_infos[i].DumpAsTableRow(
s, platform_sp->GetUserIDResolver(), true, false);
}
error.SetErrorStringWithFormat(
@@ -2990,14 +3096,14 @@ void Process::CompleteAttach() {
}
}
-Status Process::ConnectRemote(Stream *strm, llvm::StringRef remote_url) {
+Status Process::ConnectRemote(llvm::StringRef remote_url) {
m_abi_sp.reset();
m_process_input_reader.reset();
// Find the process and its architecture. Make sure it matches the
// architecture of the current Target, and if not adjust it.
- Status error(DoConnectRemote(strm, remote_url));
+ Status error(DoConnectRemote(remote_url));
if (error.Success()) {
if (GetID() != LLDB_INVALID_PROCESS_ID) {
EventSP event_sp;
@@ -3225,6 +3331,10 @@ Status Process::Detach(bool keep_stopped) {
}
Status Process::Destroy(bool force_kill) {
+ // If we've already called Process::Finalize then there's nothing useful to
+ // be done here. Finalize has actually called Destroy already.
+ if (m_finalize_called)
+ return {};
// 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
@@ -3265,8 +3375,8 @@ Status Process::Destroy(bool force_kill) {
DidDestroy();
StopPrivateStateThread();
}
- m_stdio_communication.Disconnect();
m_stdio_communication.StopReadThread();
+ m_stdio_communication.Disconnect();
m_stdin_forward = false;
if (m_process_input_reader) {
@@ -3335,8 +3445,8 @@ bool Process::ShouldBroadcastEvent(Event *event_ptr) {
case eStateExited:
case eStateUnloaded:
m_stdio_communication.SynchronizeWithReadThread();
- m_stdio_communication.Disconnect();
m_stdio_communication.StopReadThread();
+ m_stdio_communication.Disconnect();
m_stdin_forward = false;
LLVM_FALLTHROUGH;
@@ -3889,6 +3999,114 @@ ConstString Process::ProcessEventData::GetFlavor() const {
return ProcessEventData::GetFlavorString();
}
+bool Process::ProcessEventData::ShouldStop(Event *event_ptr,
+ bool &found_valid_stopinfo) {
+ found_valid_stopinfo = false;
+
+ ProcessSP process_sp(m_process_wp.lock());
+ if (!process_sp)
+ return false;
+
+ ThreadList &curr_thread_list = process_sp->GetThreadList();
+ uint32_t num_threads = curr_thread_list.GetSize();
+ uint32_t idx;
+
+ // The actions might change one of the thread's stop_info's opinions about
+ // whether we should stop the process, so we need to query that as we go.
+
+ // One other complication here, is that we try to catch any case where the
+ // target has run (except for expressions) and immediately exit, but if we
+ // get that wrong (which is possible) then the thread list might have
+ // changed, and that would cause our iteration here to crash. We could
+ // make a copy of the thread list, but we'd really like to also know if it
+ // has changed at all, so we make up a vector of the thread ID's and check
+ // what we get back against this list & bag out if anything differs.
+ ThreadList not_suspended_thread_list(process_sp.get());
+ std::vector<uint32_t> thread_index_array(num_threads);
+ uint32_t not_suspended_idx = 0;
+ for (idx = 0; idx < num_threads; ++idx) {
+ lldb::ThreadSP thread_sp = curr_thread_list.GetThreadAtIndex(idx);
+
+ /*
+ Filter out all suspended threads, they could not be the reason
+ of stop and no need to perform any actions on them.
+ */
+ if (thread_sp->GetResumeState() != eStateSuspended) {
+ not_suspended_thread_list.AddThread(thread_sp);
+ thread_index_array[not_suspended_idx] = thread_sp->GetIndexID();
+ not_suspended_idx++;
+ }
+ }
+
+ // Use this to track whether we should continue from here. We will only
+ // continue the target running if no thread says we should stop. Of course
+ // if some thread's PerformAction actually sets the target running, then it
+ // doesn't matter what the other threads say...
+
+ bool still_should_stop = false;
+
+ // Sometimes - for instance if we have a bug in the stub we are talking to,
+ // we stop but no thread has a valid stop reason. In that case we should
+ // just stop, because we have no way of telling what the right thing to do
+ // is, and it's better to let the user decide than continue behind their
+ // backs.
+
+ for (idx = 0; idx < not_suspended_thread_list.GetSize(); ++idx) {
+ curr_thread_list = process_sp->GetThreadList();
+ if (curr_thread_list.GetSize() != num_threads) {
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STEP |
+ LIBLLDB_LOG_PROCESS));
+ LLDB_LOGF(
+ log,
+ "Number of threads changed from %u to %u while processing event.",
+ num_threads, curr_thread_list.GetSize());
+ break;
+ }
+
+ lldb::ThreadSP thread_sp = not_suspended_thread_list.GetThreadAtIndex(idx);
+
+ if (thread_sp->GetIndexID() != thread_index_array[idx]) {
+ Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STEP |
+ LIBLLDB_LOG_PROCESS));
+ LLDB_LOGF(log,
+ "The thread at position %u changed from %u to %u while "
+ "processing event.",
+ idx, thread_index_array[idx], thread_sp->GetIndexID());
+ break;
+ }
+
+ StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
+ if (stop_info_sp && stop_info_sp->IsValid()) {
+ found_valid_stopinfo = true;
+ bool this_thread_wants_to_stop;
+ if (stop_info_sp->GetOverrideShouldStop()) {
+ this_thread_wants_to_stop =
+ stop_info_sp->GetOverriddenShouldStopValue();
+ } else {
+ stop_info_sp->PerformAction(event_ptr);
+ // The stop action might restart the target. If it does, then we
+ // want to mark that in the event so that whoever is receiving it
+ // will know to wait for the running event and reflect that state
+ // appropriately. We also need to stop processing actions, since they
+ // aren't expecting the target to be running.
+
+ // FIXME: we might have run.
+ if (stop_info_sp->HasTargetRunSinceMe()) {
+ SetRestarted(true);
+ break;
+ }
+
+ this_thread_wants_to_stop = stop_info_sp->ShouldStop(event_ptr);
+ }
+
+ if (!still_should_stop)
+ still_should_stop = this_thread_wants_to_stop;
+ }
+ }
+
+ return still_should_stop;
+}
+
void Process::ProcessEventData::DoOnRemoval(Event *event_ptr) {
ProcessSP process_sp(m_process_wp.lock());
@@ -3923,121 +4141,40 @@ void Process::ProcessEventData::DoOnRemoval(Event *event_ptr) {
if (m_interrupted)
return;
- // If we're stopped and haven't restarted, then do the StopInfo actions here:
- if (m_state == eStateStopped && !m_restarted) {
- ThreadList &curr_thread_list = process_sp->GetThreadList();
- uint32_t num_threads = curr_thread_list.GetSize();
- uint32_t idx;
-
- // The actions might change one of the thread's stop_info's opinions about
- // whether we should stop the process, so we need to query that as we go.
-
- // One other complication here, is that we try to catch any case where the
- // target has run (except for expressions) and immediately exit, but if we
- // get that wrong (which is possible) then the thread list might have
- // changed, and that would cause our iteration here to crash. We could
- // make a copy of the thread list, but we'd really like to also know if it
- // has changed at all, so we make up a vector of the thread ID's and check
- // what we get back against this list & bag out if anything differs.
- std::vector<uint32_t> thread_index_array(num_threads);
- for (idx = 0; idx < num_threads; ++idx)
- thread_index_array[idx] =
- curr_thread_list.GetThreadAtIndex(idx)->GetIndexID();
-
- // Use this to track whether we should continue from here. We will only
- // continue the target running if no thread says we should stop. Of course
- // if some thread's PerformAction actually sets the target running, then it
- // doesn't matter what the other threads say...
-
- bool still_should_stop = false;
-
- // Sometimes - for instance if we have a bug in the stub we are talking to,
- // we stop but no thread has a valid stop reason. In that case we should
- // just stop, because we have no way of telling what the right thing to do
- // is, and it's better to let the user decide than continue behind their
- // backs.
-
- bool does_anybody_have_an_opinion = false;
-
- for (idx = 0; idx < num_threads; ++idx) {
- curr_thread_list = process_sp->GetThreadList();
- if (curr_thread_list.GetSize() != num_threads) {
- Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STEP |
- LIBLLDB_LOG_PROCESS));
- LLDB_LOGF(
- log,
- "Number of threads changed from %u to %u while processing event.",
- num_threads, curr_thread_list.GetSize());
- break;
- }
-
- lldb::ThreadSP thread_sp = curr_thread_list.GetThreadAtIndex(idx);
-
- if (thread_sp->GetIndexID() != thread_index_array[idx]) {
- Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STEP |
- LIBLLDB_LOG_PROCESS));
- LLDB_LOGF(log,
- "The thread at position %u changed from %u to %u while "
- "processing event.",
- idx, thread_index_array[idx], thread_sp->GetIndexID());
- break;
- }
-
- StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
- if (stop_info_sp && stop_info_sp->IsValid()) {
- does_anybody_have_an_opinion = true;
- bool this_thread_wants_to_stop;
- if (stop_info_sp->GetOverrideShouldStop()) {
- this_thread_wants_to_stop =
- stop_info_sp->GetOverriddenShouldStopValue();
- } else {
- stop_info_sp->PerformAction(event_ptr);
- // The stop action might restart the target. If it does, then we
- // want to mark that in the event so that whoever is receiving it
- // will know to wait for the running event and reflect that state
- // appropriately. We also need to stop processing actions, since they
- // aren't expecting the target to be running.
-
- // FIXME: we might have run.
- if (stop_info_sp->HasTargetRunSinceMe()) {
- SetRestarted(true);
- break;
- }
+ // If we're not stopped or have restarted, then skip the StopInfo actions:
+ if (m_state != eStateStopped || m_restarted) {
+ return;
+ }
- this_thread_wants_to_stop = stop_info_sp->ShouldStop(event_ptr);
- }
+ bool does_anybody_have_an_opinion = false;
+ bool still_should_stop = ShouldStop(event_ptr, does_anybody_have_an_opinion);
- if (!still_should_stop)
- still_should_stop = this_thread_wants_to_stop;
- }
- }
+ if (GetRestarted()) {
+ return;
+ }
- if (!GetRestarted()) {
- if (!still_should_stop && does_anybody_have_an_opinion) {
- // We've been asked to continue, so do that here.
+ if (!still_should_stop && does_anybody_have_an_opinion) {
+ // We've been asked to continue, so do that here.
+ SetRestarted(true);
+ // Use the public resume method here, since this is just extending a
+ // public resume.
+ process_sp->PrivateResume();
+ } else {
+ bool hijacked = process_sp->IsHijackedForEvent(eBroadcastBitStateChanged) &&
+ !process_sp->StateChangedIsHijackedForSynchronousResume();
+
+ if (!hijacked) {
+ // If we didn't restart, run the Stop Hooks here.
+ // Don't do that if state changed events aren't hooked up to the
+ // public (or SyncResume) broadcasters. StopHooks are just for
+ // real public stops. They might also restart the target,
+ // so watch for that.
+ process_sp->GetTarget().RunStopHooks();
+ if (process_sp->GetPrivateState() == eStateRunning)
SetRestarted(true);
- // Use the public resume method here, since this is just extending a
- // public resume.
- process_sp->PrivateResume();
- } else {
- bool hijacked =
- process_sp->IsHijackedForEvent(eBroadcastBitStateChanged) &&
- !process_sp->StateChangedIsHijackedForSynchronousResume();
-
- if (!hijacked) {
- // If we didn't restart, run the Stop Hooks here.
- // Don't do that if state changed events aren't hooked up to the
- // public (or SyncResume) broadcasters. StopHooks are just for
- // real public stops. They might also restart the target,
- // so watch for that.
- process_sp->GetTarget().RunStopHooks();
- if (process_sp->GetPrivateState() == eStateRunning)
- SetRestarted(true);
- }
}
}
}
-}
void Process::ProcessEventData::Dump(Stream *s) const {
ProcessSP process_sp(m_process_wp.lock());
@@ -4422,23 +4559,18 @@ protected:
void Process::SetSTDIOFileDescriptor(int fd) {
// First set up the Read Thread for reading/handling process I/O
+ m_stdio_communication.SetConnection(
+ std::make_unique<ConnectionFileDescriptor>(fd, true));
+ if (m_stdio_communication.IsConnected()) {
+ m_stdio_communication.SetReadThreadBytesReceivedCallback(
+ STDIOReadThreadBytesReceived, this);
+ m_stdio_communication.StartReadThread();
- std::unique_ptr<ConnectionFileDescriptor> conn_up(
- new ConnectionFileDescriptor(fd, true));
-
- if (conn_up) {
- m_stdio_communication.SetConnection(conn_up.release());
- if (m_stdio_communication.IsConnected()) {
- m_stdio_communication.SetReadThreadBytesReceivedCallback(
- STDIOReadThreadBytesReceived, this);
- m_stdio_communication.StartReadThread();
+ // Now read thread is set up, set up input reader.
- // Now read thread is set up, set up input reader.
-
- if (!m_process_input_reader)
- m_process_input_reader =
- std::make_shared<IOHandlerProcessSTDIO>(this, fd);
- }
+ if (!m_process_input_reader)
+ m_process_input_reader =
+ std::make_shared<IOHandlerProcessSTDIO>(this, fd);
}
}
@@ -4460,7 +4592,8 @@ bool Process::PushProcessIOHandler() {
// existing IOHandler that potentially provides the user interface (e.g.
// the IOHandler for Editline).
bool cancel_top_handler = !m_mod_id.IsRunningUtilityFunction();
- GetTarget().GetDebugger().PushIOHandler(io_handler_sp, cancel_top_handler);
+ GetTarget().GetDebugger().RunIOHandlerAsync(io_handler_sp,
+ cancel_top_handler);
return true;
}
return false;
@@ -4469,7 +4602,7 @@ bool Process::PushProcessIOHandler() {
bool Process::PopProcessIOHandler() {
IOHandlerSP io_handler_sp(m_process_input_reader);
if (io_handler_sp)
- return GetTarget().GetDebugger().PopIOHandler(io_handler_sp);
+ return GetTarget().GetDebugger().RemoveIOHandler(io_handler_sp);
return false;
}
@@ -4553,13 +4686,27 @@ GetExpressionTimeout(const EvaluateExpressionOptions &options,
}
static llvm::Optional<ExpressionResults>
-HandleStoppedEvent(Thread &thread, const ThreadPlanSP &thread_plan_sp,
+HandleStoppedEvent(lldb::tid_t thread_id, const ThreadPlanSP &thread_plan_sp,
RestorePlanState &restorer, const EventSP &event_sp,
EventSP &event_to_broadcast_sp,
- const EvaluateExpressionOptions &options, bool handle_interrupts) {
+ const EvaluateExpressionOptions &options,
+ bool handle_interrupts) {
Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STEP | LIBLLDB_LOG_PROCESS);
- ThreadPlanSP plan = thread.GetCompletedPlan();
+ ThreadSP thread_sp = thread_plan_sp->GetTarget()
+ .GetProcessSP()
+ ->GetThreadList()
+ .FindThreadByID(thread_id);
+ if (!thread_sp) {
+ LLDB_LOG(log,
+ "The thread on which we were running the "
+ "expression: tid = {0}, exited while "
+ "the expression was running.",
+ thread_id);
+ return eExpressionThreadVanished;
+ }
+
+ ThreadPlanSP plan = thread_sp->GetCompletedPlan();
if (plan == thread_plan_sp && plan->PlanSucceeded()) {
LLDB_LOG(log, "execution completed successfully");
@@ -4569,7 +4716,7 @@ HandleStoppedEvent(Thread &thread, const ThreadPlanSP &thread_plan_sp,
return eExpressionCompleted;
}
- StopInfoSP stop_info_sp = thread.GetStopInfo();
+ StopInfoSP stop_info_sp = thread_sp->GetStopInfo();
if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonBreakpoint &&
stop_info_sp->ShouldNotify(event_sp.get())) {
LLDB_LOG(log, "stopped for breakpoint: {0}.", stop_info_sp->GetDescription());
@@ -4631,6 +4778,10 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
return eExpressionSetupError;
}
+ // Record the thread's id so we can tell when a thread we were using
+ // to run the expression exits during the expression evaluation.
+ lldb::tid_t expr_thread_id = thread->GetID();
+
// We need to change some of the thread plan attributes for the thread plan
// runner. This will restore them when we are done:
@@ -4775,7 +4926,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
LLDB_LOGF(log,
"Process::RunThreadPlan(): Resuming thread %u - 0x%4.4" PRIx64
" to run thread plan \"%s\".",
- thread->GetIndexID(), thread->GetID(), s.GetData());
+ thread_idx_id, expr_thread_id, s.GetData());
}
bool got_event;
@@ -4975,33 +5126,23 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
switch (stop_state) {
case lldb::eStateStopped: {
- // We stopped, figure out what we are going to do now.
- ThreadSP thread_sp =
- GetThreadList().FindThreadByIndexID(thread_idx_id);
- if (!thread_sp) {
- // Ooh, our thread has vanished. Unlikely that this was
- // successful execution...
- LLDB_LOGF(log,
- "Process::RunThreadPlan(): execution completed "
- "but our thread (index-id=%u) has vanished.",
- thread_idx_id);
- return_value = eExpressionInterrupted;
- } else if (Process::ProcessEventData::GetRestartedFromEvent(
- event_sp.get())) {
+ if (Process::ProcessEventData::GetRestartedFromEvent(
+ event_sp.get())) {
// If we were restarted, we just need to go back up to fetch
// another event.
- if (log) {
- LLDB_LOGF(log, "Process::RunThreadPlan(): Got a stop and "
- "restart, so we'll continue waiting.");
- }
+ LLDB_LOGF(log, "Process::RunThreadPlan(): Got a stop and "
+ "restart, so we'll continue waiting.");
keep_going = true;
do_resume = false;
handle_running_event = true;
} else {
const bool handle_interrupts = true;
return_value = *HandleStoppedEvent(
- *thread, thread_plan_sp, thread_plan_restorer, event_sp,
- event_to_broadcast_sp, options, handle_interrupts);
+ expr_thread_id, thread_plan_sp, thread_plan_restorer,
+ event_sp, event_to_broadcast_sp, options,
+ handle_interrupts);
+ if (return_value == eExpressionThreadVanished)
+ keep_going = false;
}
} break;
@@ -5123,8 +5264,9 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
// job. Check that here:
const bool handle_interrupts = false;
if (auto result = HandleStoppedEvent(
- *thread, thread_plan_sp, thread_plan_restorer, event_sp,
- event_to_broadcast_sp, options, handle_interrupts)) {
+ expr_thread_id, thread_plan_sp, thread_plan_restorer,
+ event_sp, event_to_broadcast_sp, options,
+ handle_interrupts)) {
return_value = *result;
back_to_top = false;
break;
@@ -5196,6 +5338,13 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
m_public_state.SetValueNoLock(old_state);
}
+ // If our thread went away on us, we need to get out of here without
+ // doing any more work. We don't have to clean up the thread plan, that
+ // will have happened when the Thread was destroyed.
+ if (return_value == eExpressionThreadVanished) {
+ return return_value;
+ }
+
if (return_value != eExpressionCompleted && log) {
// Print a backtrace into the log so we can figure out where we are:
StreamString s;
@@ -5384,7 +5533,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
}
const char *Process::ExecutionResultAsCString(ExpressionResults result) {
- const char *result_name;
+ const char *result_name = "<unknown>";
switch (result) {
case eExpressionCompleted:
@@ -5414,6 +5563,8 @@ const char *Process::ExecutionResultAsCString(ExpressionResults result) {
case eExpressionStoppedForDebug:
result_name = "eExpressionStoppedForDebug";
break;
+ case eExpressionThreadVanished:
+ result_name = "eExpressionThreadVanished";
}
return result_name;
}
@@ -5662,9 +5813,6 @@ void Process::PrintWarning(uint64_t warning_type, const void *repeat_key,
StreamSP stream_sp = GetTarget().GetDebugger().GetAsyncOutputStream();
if (!stream_sp)
return;
- if (warning_type == eWarningsOptimization && !GetWarningsOptimization()) {
- return;
- }
if (repeat_key != nullptr) {
WarningsCollection::iterator it = m_warnings_issued.find(warning_type);
@@ -5689,8 +5837,11 @@ void Process::PrintWarning(uint64_t warning_type, const void *repeat_key,
}
void Process::PrintWarningOptimization(const SymbolContext &sc) {
- if (GetWarningsOptimization() && sc.module_sp &&
- !sc.module_sp->GetFileSpec().GetFilename().IsEmpty() && sc.function &&
+ if (!GetWarningsOptimization())
+ return;
+ if (!sc.module_sp)
+ return;
+ if (!sc.module_sp->GetFileSpec().GetFilename().IsEmpty() && sc.function &&
sc.function->GetIsOptimized()) {
PrintWarning(Process::Warnings::eWarningsOptimization, sc.module_sp.get(),
"%s was compiled with optimization - stepping may behave "
@@ -5699,6 +5850,25 @@ void Process::PrintWarningOptimization(const SymbolContext &sc) {
}
}
+void Process::PrintWarningUnsupportedLanguage(const SymbolContext &sc) {
+ if (!GetWarningsUnsupportedLanguage())
+ return;
+ if (!sc.module_sp)
+ return;
+ LanguageType language = sc.GetLanguage();
+ if (language == eLanguageTypeUnknown)
+ return;
+ auto type_system_or_err = sc.module_sp->GetTypeSystemForLanguage(language);
+ if (auto err = type_system_or_err.takeError()) {
+ llvm::consumeError(std::move(err));
+ PrintWarning(Process::Warnings::eWarningsUnsupportedLanguage,
+ sc.module_sp.get(),
+ "This version of LLDB has no plugin for the %s language. "
+ "Inspection of frame variables will be limited.\n",
+ Language::GetNameForLanguageType(language));
+ }
+}
+
bool Process::GetProcessInfo(ProcessInstanceInfo &info) {
info.Clear();
@@ -5749,12 +5919,12 @@ size_t Process::AddImageToken(lldb::addr_t image_ptr) {
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;
+ return LLDB_INVALID_ADDRESS;
}
void Process::ResetImageToken(size_t token) {
if (token < m_image_tokens.size())
- m_image_tokens[token] = LLDB_INVALID_IMAGE_TOKEN;
+ m_image_tokens[token] = LLDB_INVALID_ADDRESS;
}
Address
@@ -5771,12 +5941,11 @@ Process::AdvanceAddressToNextBranchInstruction(Address default_stop_addr,
if (!default_stop_addr.IsValid())
return retval;
- ExecutionContext exe_ctx(this);
const char *plugin_name = nullptr;
const char *flavor = nullptr;
const bool prefer_file_cache = true;
disassembler_sp = Disassembler::DisassembleRange(
- target.GetArchitecture(), plugin_name, flavor, exe_ctx, range_bounds,
+ target.GetArchitecture(), plugin_name, flavor, GetTarget(), range_bounds,
prefer_file_cache);
if (disassembler_sp)
insn_list = &disassembler_sp->GetInstructionList();
diff --git a/lldb/source/Target/Queue.cpp b/lldb/source/Target/Queue.cpp
index fc2a93dbe899..67eae6327673 100644
--- a/lldb/source/Target/Queue.cpp
+++ b/lldb/source/Target/Queue.cpp
@@ -1,4 +1,4 @@
-//===-- Queue.cpp -----------------------------------------------*- C++ -*-===//
+//===-- Queue.cpp ---------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/QueueItem.cpp b/lldb/source/Target/QueueItem.cpp
index 47ff9e028fcb..740b2a6771a2 100644
--- a/lldb/source/Target/QueueItem.cpp
+++ b/lldb/source/Target/QueueItem.cpp
@@ -1,4 +1,4 @@
-//===-- QueueItem.cpp -------------------------------------------*- C++ -*-===//
+//===-- QueueItem.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/QueueList.cpp b/lldb/source/Target/QueueList.cpp
index 796825135187..84ec24f03f51 100644
--- a/lldb/source/Target/QueueList.cpp
+++ b/lldb/source/Target/QueueList.cpp
@@ -1,4 +1,4 @@
-//===-- QueueList.cpp -------------------------------------------*- C++ -*-===//
+//===-- QueueList.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/RegisterContext.cpp b/lldb/source/Target/RegisterContext.cpp
index f29cf435d028..cdc7653cea6d 100644
--- a/lldb/source/Target/RegisterContext.cpp
+++ b/lldb/source/Target/RegisterContext.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContext.cpp -------------------------------------*- C++ -*-===//
+//===-- RegisterContext.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -274,6 +274,24 @@ uint32_t RegisterContext::SetHardwareBreakpoint(lldb::addr_t addr,
return LLDB_INVALID_INDEX32;
}
+// Used when parsing DWARF and EH frame information and any other object file
+// sections that contain register numbers in them.
+uint32_t
+RegisterContext::ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
+ uint32_t num) {
+ const uint32_t num_regs = GetRegisterCount();
+
+ assert(kind < kNumRegisterKinds);
+ for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) {
+ const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg_idx);
+
+ if (reg_info->kinds[kind] == num)
+ return reg_idx;
+ }
+
+ return LLDB_INVALID_REGNUM;
+}
+
bool RegisterContext::ClearHardwareBreakpoint(uint32_t hw_idx) { return false; }
uint32_t RegisterContext::NumSupportedHardwareWatchpoints() { return 0; }
@@ -397,6 +415,17 @@ Status RegisterContext::WriteRegisterValueToMemory(
return error;
}
+lldb::ByteOrder RegisterContext::GetByteOrder() {
+ // Get the target process whose privileged thread was used for the register
+ // read.
+ lldb::ByteOrder byte_order = lldb::eByteOrderInvalid;
+ lldb_private::Process *process = CalculateProcess().get();
+
+ if (process)
+ byte_order = process->GetByteOrder();
+ return byte_order;
+}
+
bool RegisterContext::ReadAllRegisterValues(
lldb_private::RegisterCheckpoint &reg_checkpoint) {
return ReadAllRegisterValues(reg_checkpoint.GetData());
diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/lldb/source/Target/RegisterContextUnwind.cpp
index 49a589f14989..f33f4180be23 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ b/lldb/source/Target/RegisterContextUnwind.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextLLDB.cpp --------------------------------*- C++ -*-===//
+//===-- RegisterContextUnwind.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "lldb/Target/RegisterContextUnwind.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/Module.h"
@@ -34,8 +35,6 @@
#include "lldb/Utility/RegisterValue.h"
#include "lldb/lldb-private.h"
-#include "RegisterContextLLDB.h"
-
#include <memory>
using namespace lldb;
@@ -49,11 +48,11 @@ static ConstString GetSymbolOrFunctionName(const SymbolContext &sym_ctx) {
return ConstString();
}
-RegisterContextLLDB::RegisterContextLLDB(Thread &thread,
- const SharedPtr &next_frame,
- SymbolContext &sym_ctx,
- uint32_t frame_number,
- UnwindLLDB &unwind_lldb)
+RegisterContextUnwind::RegisterContextUnwind(Thread &thread,
+ const SharedPtr &next_frame,
+ SymbolContext &sym_ctx,
+ uint32_t frame_number,
+ UnwindLLDB &unwind_lldb)
: RegisterContext(thread, frame_number), m_thread(thread),
m_fast_unwind_plan_sp(), m_full_unwind_plan_sp(),
m_fallback_unwind_plan_sp(), m_all_registers_available(false),
@@ -79,7 +78,7 @@ RegisterContextLLDB::RegisterContextLLDB(Thread &thread,
}
}
-bool RegisterContextLLDB::IsUnwindPlanValidForCurrentPC(
+bool RegisterContextUnwind::IsUnwindPlanValidForCurrentPC(
lldb::UnwindPlanSP unwind_plan_sp, int &valid_pc_offset) {
if (!unwind_plan_sp)
return false;
@@ -107,10 +106,10 @@ bool RegisterContextLLDB::IsUnwindPlanValidForCurrentPC(
return false;
}
-// Initialize a RegisterContextLLDB which is the first frame of a stack -- the
+// Initialize a RegisterContextUnwind which is the first frame of a stack -- the
// zeroth frame or currently executing frame.
-void RegisterContextLLDB::InitializeZerothFrame() {
+void RegisterContextUnwind::InitializeZerothFrame() {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND));
ExecutionContext exe_ctx(m_thread.shared_from_this());
RegisterContextSP reg_ctx_sp = m_thread.GetRegisterContext();
@@ -260,10 +259,10 @@ void RegisterContextLLDB::InitializeZerothFrame() {
m_full_unwind_plan_sp->GetSourceName().GetCString());
}
-// Initialize a RegisterContextLLDB for the non-zeroth frame -- rely on the
-// RegisterContextLLDB "below" it to provide things like its current pc value.
+// Initialize a RegisterContextUnwind for the non-zeroth frame -- rely on the
+// RegisterContextUnwind "below" it to provide things like its current pc value.
-void RegisterContextLLDB::InitializeNonZerothFrame() {
+void RegisterContextUnwind::InitializeNonZerothFrame() {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND));
if (IsFrameZero()) {
m_frame_type = eNotAValidFrame;
@@ -328,9 +327,13 @@ void RegisterContextLLDB::InitializeNonZerothFrame() {
// If we don't have a Module for some reason, we're not going to find
// symbol/function information - just stick in some reasonable defaults and
- // hope we can unwind past this frame.
+ // hope we can unwind past this frame. If we're above a trap handler,
+ // we may be at a bogus address because we jumped through a bogus function
+ // pointer and trapped, so don't force the arch default unwind plan in that
+ // case.
ModuleSP pc_module_sp(m_current_pc.GetModule());
- if (!m_current_pc.IsValid() || !pc_module_sp) {
+ if ((!m_current_pc.IsValid() || !pc_module_sp) &&
+ above_trap_handler == false) {
UnwindLogMsg("using architectural default unwind method");
// Test the pc value to see if we know it's in an unmapped/non-executable
@@ -591,7 +594,7 @@ void RegisterContextLLDB::InitializeNonZerothFrame() {
(uint64_t)m_afa);
}
-bool RegisterContextLLDB::CheckIfLoopingStack() {
+bool RegisterContextUnwind::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 break out to avoid a possible infinite loop in lldb
@@ -599,15 +602,16 @@ bool RegisterContextLLDB::CheckIfLoopingStack() {
// 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
+ // hanlders, hand written assembly without ABI compliance) 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();
+ RegisterContextUnwind::SharedPtr next_frame = GetNextFrame();
if (next_frame) {
- RegisterContextLLDB::SharedPtr next_next_frame = next_frame->GetNextFrame();
+ RegisterContextUnwind::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)) {
if (next_next_frame_cfa == m_cfa) {
@@ -619,7 +623,7 @@ bool RegisterContextLLDB::CheckIfLoopingStack() {
return false;
}
-bool RegisterContextLLDB::IsFrameZero() const { return m_frame_number == 0; }
+bool RegisterContextUnwind::IsFrameZero() const { return m_frame_number == 0; }
// Find a fast unwind plan for this frame, if possible.
//
@@ -632,7 +636,7 @@ bool RegisterContextLLDB::IsFrameZero() const { return m_frame_number == 0; }
// 4. m_current_offset_backed_up_one should have the current byte offset into
// the function, maybe backed up by 1, -1 if unknown
-UnwindPlanSP RegisterContextLLDB::GetFastUnwindPlanForFrame() {
+UnwindPlanSP RegisterContextUnwind::GetFastUnwindPlanForFrame() {
UnwindPlanSP unwind_plan_sp;
ModuleSP pc_module_sp(m_current_pc.GetModule());
@@ -683,7 +687,7 @@ UnwindPlanSP RegisterContextLLDB::GetFastUnwindPlanForFrame() {
// 4. m_current_offset_backed_up_one should have the current byte offset into
// the function, maybe backed up by 1, -1 if unknown
-UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
+UnwindPlanSP RegisterContextUnwind::GetFullUnwindPlanForFrame() {
UnwindPlanSP unwind_plan_sp;
UnwindPlanSP arch_default_unwind_plan_sp;
ExecutionContext exe_ctx(m_thread.shared_from_this());
@@ -963,33 +967,33 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
return arch_default_unwind_plan_sp;
}
-void RegisterContextLLDB::InvalidateAllRegisters() {
+void RegisterContextUnwind::InvalidateAllRegisters() {
m_frame_type = eNotAValidFrame;
}
-size_t RegisterContextLLDB::GetRegisterCount() {
+size_t RegisterContextUnwind::GetRegisterCount() {
return m_thread.GetRegisterContext()->GetRegisterCount();
}
-const RegisterInfo *RegisterContextLLDB::GetRegisterInfoAtIndex(size_t reg) {
+const RegisterInfo *RegisterContextUnwind::GetRegisterInfoAtIndex(size_t reg) {
return m_thread.GetRegisterContext()->GetRegisterInfoAtIndex(reg);
}
-size_t RegisterContextLLDB::GetRegisterSetCount() {
+size_t RegisterContextUnwind::GetRegisterSetCount() {
return m_thread.GetRegisterContext()->GetRegisterSetCount();
}
-const RegisterSet *RegisterContextLLDB::GetRegisterSet(size_t reg_set) {
+const RegisterSet *RegisterContextUnwind::GetRegisterSet(size_t reg_set) {
return m_thread.GetRegisterContext()->GetRegisterSet(reg_set);
}
-uint32_t RegisterContextLLDB::ConvertRegisterKindToRegisterNumber(
+uint32_t RegisterContextUnwind::ConvertRegisterKindToRegisterNumber(
lldb::RegisterKind kind, uint32_t num) {
return m_thread.GetRegisterContext()->ConvertRegisterKindToRegisterNumber(
kind, num);
}
-bool RegisterContextLLDB::ReadRegisterValueFromRegisterLocation(
+bool RegisterContextUnwind::ReadRegisterValueFromRegisterLocation(
lldb_private::UnwindLLDB::RegisterLocation regloc,
const RegisterInfo *reg_info, RegisterValue &value) {
if (!IsValid())
@@ -1042,7 +1046,7 @@ bool RegisterContextLLDB::ReadRegisterValueFromRegisterLocation(
return success;
}
-bool RegisterContextLLDB::WriteRegisterValueToRegisterLocation(
+bool RegisterContextUnwind::WriteRegisterValueToRegisterLocation(
lldb_private::UnwindLLDB::RegisterLocation regloc,
const RegisterInfo *reg_info, const RegisterValue &value) {
if (!IsValid())
@@ -1084,17 +1088,17 @@ bool RegisterContextLLDB::WriteRegisterValueToRegisterLocation(
return success;
}
-bool RegisterContextLLDB::IsValid() const {
+bool RegisterContextUnwind::IsValid() const {
return m_frame_type != eNotAValidFrame;
}
// After the final stack frame in a stack walk we'll get one invalid
// (eNotAValidFrame) stack frame -- one past the end of the stack walk. But
-// higher-level code will need to tell the differnece between "the unwind plan
+// higher-level code will need to tell the difference between "the unwind plan
// below this frame failed" versus "we successfully completed the stack walk"
// so this method helps to disambiguate that.
-bool RegisterContextLLDB::IsTrapHandlerFrame() const {
+bool RegisterContextUnwind::IsTrapHandlerFrame() const {
return m_frame_type == eTrapHandlerFrame;
}
@@ -1106,11 +1110,11 @@ bool RegisterContextLLDB::IsTrapHandlerFrame() const {
// we're displaying bad data and we may have skipped one frame of their real
// program in the process of getting back on track.
-bool RegisterContextLLDB::IsSkipFrame() const {
+bool RegisterContextUnwind::IsSkipFrame() const {
return m_frame_type == eSkipFrame;
}
-bool RegisterContextLLDB::IsTrapHandlerSymbol(
+bool RegisterContextUnwind::IsTrapHandlerSymbol(
lldb_private::Process *process,
const lldb_private::SymbolContext &m_sym_ctx) const {
PlatformSP platform_sp(process->GetTarget().GetPlatform());
@@ -1140,7 +1144,7 @@ bool RegisterContextLLDB::IsTrapHandlerSymbol(
// frame)'s register value?
enum UnwindLLDB::RegisterSearchResult
-RegisterContextLLDB::SavedLocationForRegister(
+RegisterContextUnwind::SavedLocationForRegister(
uint32_t lldb_regnum, lldb_private::UnwindLLDB::RegisterLocation &regloc) {
RegisterNumber regnum(m_thread, eRegisterKindLLDB, lldb_regnum);
@@ -1206,15 +1210,28 @@ RegisterContextLLDB::SavedLocationForRegister(
if (pc_regnum.IsValid() && pc_regnum == regnum &&
m_full_unwind_plan_sp->GetReturnAddressRegister() !=
LLDB_INVALID_REGNUM) {
-
- return_address_reg.init(
- m_thread, m_full_unwind_plan_sp->GetRegisterKind(),
- m_full_unwind_plan_sp->GetReturnAddressRegister());
- regnum = return_address_reg;
- UnwindLogMsg("requested caller's saved PC but this UnwindPlan uses a "
- "RA reg; getting %s (%d) instead",
- return_address_reg.GetName(),
- return_address_reg.GetAsKind(eRegisterKindLLDB));
+ // If this is a trap handler frame, we should have access to
+ // the complete register context when the interrupt/async
+ // signal was received, we should fetch the actual saved $pc
+ // value instead of the Return Address register.
+ // If $pc is not available, fall back to the RA reg.
+ UnwindPlan::Row::RegisterLocation scratch;
+ if (m_frame_type == eTrapHandlerFrame &&
+ active_row->GetRegisterInfo
+ (pc_regnum.GetAsKind (unwindplan_registerkind), scratch)) {
+ UnwindLogMsg("Providing pc register instead of rewriting to "
+ "RA reg because this is a trap handler and there is "
+ "a location for the saved pc register value.");
+ } else {
+ return_address_reg.init(
+ m_thread, m_full_unwind_plan_sp->GetRegisterKind(),
+ m_full_unwind_plan_sp->GetReturnAddressRegister());
+ regnum = return_address_reg;
+ UnwindLogMsg("requested caller's saved PC but this UnwindPlan uses a "
+ "RA reg; getting %s (%d) instead",
+ return_address_reg.GetName(),
+ return_address_reg.GetAsKind(eRegisterKindLLDB));
+ }
} else {
if (regnum.GetAsKind(unwindplan_registerkind) == LLDB_INVALID_REGNUM) {
if (unwindplan_registerkind == eRegisterKindGeneric) {
@@ -1562,7 +1579,7 @@ RegisterContextLLDB::SavedLocationForRegister(
// Often in these cases, if we just do a dumb stack walk we'll get past this
// tricky frame and our usual techniques can continue to be used.
-bool RegisterContextLLDB::TryFallbackUnwindPlan() {
+bool RegisterContextUnwind::TryFallbackUnwindPlan() {
if (m_fallback_unwind_plan_sp.get() == nullptr)
return false;
@@ -1692,7 +1709,7 @@ bool RegisterContextLLDB::TryFallbackUnwindPlan() {
return true;
}
-bool RegisterContextLLDB::ForceSwitchToFallbackUnwindPlan() {
+bool RegisterContextUnwind::ForceSwitchToFallbackUnwindPlan() {
if (m_fallback_unwind_plan_sp.get() == nullptr)
return false;
@@ -1739,7 +1756,7 @@ bool RegisterContextLLDB::ForceSwitchToFallbackUnwindPlan() {
return false;
}
-void RegisterContextLLDB::PropagateTrapHandlerFlagFromUnwindPlan(
+void RegisterContextUnwind::PropagateTrapHandlerFlagFromUnwindPlan(
lldb::UnwindPlanSP unwind_plan) {
if (unwind_plan->GetUnwindPlanForSignalTrap() != eLazyBoolYes) {
// Unwind plan does not indicate trap handler. Do nothing. We may
@@ -1786,7 +1803,7 @@ void RegisterContextLLDB::PropagateTrapHandlerFlagFromUnwindPlan(
}
}
-bool RegisterContextLLDB::ReadFrameAddress(
+bool RegisterContextUnwind::ReadFrameAddress(
lldb::RegisterKind row_register_kind, UnwindPlan::Row::FAValue &fa,
addr_t &address) {
RegisterValue reg_value;
@@ -1905,7 +1922,7 @@ bool RegisterContextLLDB::ReadFrameAddress(
return false;
}
-lldb::addr_t RegisterContextLLDB::GetReturnAddressHint(int32_t plan_offset) {
+lldb::addr_t RegisterContextUnwind::GetReturnAddressHint(int32_t plan_offset) {
addr_t hint;
if (!ReadGPRValue(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP, hint))
return LLDB_INVALID_ADDRESS;
@@ -1946,8 +1963,8 @@ lldb::addr_t RegisterContextLLDB::GetReturnAddressHint(int32_t plan_offset) {
// value for frame 1, we need to ask
// where frame 0 (the "next" frame) saved that and retrieve the value.
-bool RegisterContextLLDB::ReadGPRValue(lldb::RegisterKind register_kind,
- uint32_t regnum, addr_t &value) {
+bool RegisterContextUnwind::ReadGPRValue(lldb::RegisterKind register_kind,
+ uint32_t regnum, addr_t &value) {
if (!IsValid())
return false;
@@ -1995,16 +2012,16 @@ bool RegisterContextLLDB::ReadGPRValue(lldb::RegisterKind register_kind,
return false;
}
-bool RegisterContextLLDB::ReadGPRValue(const RegisterNumber &regnum,
- addr_t &value) {
+bool RegisterContextUnwind::ReadGPRValue(const RegisterNumber &regnum,
+ addr_t &value) {
return ReadGPRValue(regnum.GetRegisterKind(), regnum.GetRegisterNumber(),
value);
}
// Find the value of a register in THIS frame
-bool RegisterContextLLDB::ReadRegister(const RegisterInfo *reg_info,
- RegisterValue &value) {
+bool RegisterContextUnwind::ReadRegister(const RegisterInfo *reg_info,
+ RegisterValue &value) {
if (!IsValid())
return false;
@@ -2034,8 +2051,8 @@ bool RegisterContextLLDB::ReadRegister(const RegisterInfo *reg_info,
return ReadRegisterValueFromRegisterLocation(regloc, reg_info, value);
}
-bool RegisterContextLLDB::WriteRegister(const RegisterInfo *reg_info,
- const RegisterValue &value) {
+bool RegisterContextUnwind::WriteRegister(const RegisterInfo *reg_info,
+ const RegisterValue &value) {
if (!IsValid())
return false;
@@ -2060,19 +2077,19 @@ bool RegisterContextLLDB::WriteRegister(const RegisterInfo *reg_info,
}
// Don't need to implement this one
-bool RegisterContextLLDB::ReadAllRegisterValues(lldb::DataBufferSP &data_sp) {
+bool RegisterContextUnwind::ReadAllRegisterValues(lldb::DataBufferSP &data_sp) {
return false;
}
// Don't need to implement this one
-bool RegisterContextLLDB::WriteAllRegisterValues(
+bool RegisterContextUnwind::WriteAllRegisterValues(
const lldb::DataBufferSP &data_sp) {
return false;
}
// Retrieve the pc value for THIS from
-bool RegisterContextLLDB::GetCFA(addr_t &cfa) {
+bool RegisterContextUnwind::GetCFA(addr_t &cfa) {
if (!IsValid()) {
return false;
}
@@ -2083,21 +2100,21 @@ bool RegisterContextLLDB::GetCFA(addr_t &cfa) {
return true;
}
-RegisterContextLLDB::SharedPtr RegisterContextLLDB::GetNextFrame() const {
- RegisterContextLLDB::SharedPtr regctx;
+RegisterContextUnwind::SharedPtr RegisterContextUnwind::GetNextFrame() const {
+ RegisterContextUnwind::SharedPtr regctx;
if (m_frame_number == 0)
return regctx;
return m_parent_unwind.GetRegisterContextForFrameNum(m_frame_number - 1);
}
-RegisterContextLLDB::SharedPtr RegisterContextLLDB::GetPrevFrame() const {
- RegisterContextLLDB::SharedPtr regctx;
+RegisterContextUnwind::SharedPtr RegisterContextUnwind::GetPrevFrame() const {
+ RegisterContextUnwind::SharedPtr regctx;
return m_parent_unwind.GetRegisterContextForFrameNum(m_frame_number + 1);
}
// Retrieve the address of the start of the function of THIS frame
-bool RegisterContextLLDB::GetStartPC(addr_t &start_pc) {
+bool RegisterContextUnwind::GetStartPC(addr_t &start_pc) {
if (!IsValid())
return false;
@@ -2121,7 +2138,7 @@ bool RegisterContextLLDB::GetStartPC(addr_t &start_pc) {
// Retrieve the current pc value for THIS frame, as saved by the NEXT frame.
-bool RegisterContextLLDB::ReadPC(addr_t &pc) {
+bool RegisterContextUnwind::ReadPC(addr_t &pc) {
if (!IsValid())
return false;
@@ -2153,7 +2170,7 @@ bool RegisterContextLLDB::ReadPC(addr_t &pc) {
}
}
-void RegisterContextLLDB::UnwindLogMsg(const char *fmt, ...) {
+void RegisterContextUnwind::UnwindLogMsg(const char *fmt, ...) {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND));
if (log) {
va_list args;
@@ -2175,7 +2192,7 @@ void RegisterContextLLDB::UnwindLogMsg(const char *fmt, ...) {
}
}
-void RegisterContextLLDB::UnwindLogMsgVerbose(const char *fmt, ...) {
+void RegisterContextUnwind::UnwindLogMsgVerbose(const char *fmt, ...) {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND));
if (log && log->GetVerbose()) {
va_list args;
diff --git a/lldb/source/Target/RegisterNumber.cpp b/lldb/source/Target/RegisterNumber.cpp
index 63b58d3582fd..0ea9f212c693 100644
--- a/lldb/source/Target/RegisterNumber.cpp
+++ b/lldb/source/Target/RegisterNumber.cpp
@@ -1,4 +1,4 @@
-//===--------------------- RegisterNumber.cpp -------------------*- C++ -*-===//
+//===-- RegisterNumber.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/RemoteAwarePlatform.cpp b/lldb/source/Target/RemoteAwarePlatform.cpp
index faa217ac83ef..f53158b06b8f 100644
--- a/lldb/source/Target/RemoteAwarePlatform.cpp
+++ b/lldb/source/Target/RemoteAwarePlatform.cpp
@@ -1,4 +1,4 @@
-//===-- RemoteAwarePlatform.cpp ---------------------------------*- C++ -*-===//
+//===-- RemoteAwarePlatform.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,12 +7,17 @@
//===----------------------------------------------------------------------===//
#include "lldb/Target/RemoteAwarePlatform.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleList.h"
+#include "lldb/Core/ModuleSpec.h"
#include "lldb/Host/FileCache.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb_private;
+using namespace lldb;
bool RemoteAwarePlatform::GetModuleSpec(const FileSpec &module_file_spec,
const ArchSpec &arch,
@@ -21,7 +26,148 @@ bool RemoteAwarePlatform::GetModuleSpec(const FileSpec &module_file_spec,
return m_remote_platform_sp->GetModuleSpec(module_file_spec, arch,
module_spec);
- return Platform::GetModuleSpec(module_file_spec, arch, module_spec);
+ return false;
+}
+
+Status RemoteAwarePlatform::ResolveExecutable(
+ const ModuleSpec &module_spec, ModuleSP &exe_module_sp,
+ const FileSpecList *module_search_paths_ptr) {
+ Status 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 exe_file, resolve the executable location based
+ // on the current path variables
+ if (!FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec())) {
+ resolved_module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
+ resolved_module_spec.GetFileSpec().SetFile(exe_path,
+ FileSpec::Style::native);
+ FileSystem::Instance().Resolve(resolved_module_spec.GetFileSpec());
+ }
+
+ if (!FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec()))
+ FileSystem::Instance().ResolveExecutableLocation(
+ resolved_module_spec.GetFileSpec());
+
+ // Resolve any executable within a bundle on MacOSX
+ Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
+
+ if (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec()))
+ error.Clear();
+ else {
+ const uint32_t permissions = FileSystem::Instance().GetPermissions(
+ resolved_module_spec.GetFileSpec());
+ if (permissions && (permissions & eFilePermissionsEveryoneR) == 0)
+ error.SetErrorStringWithFormat(
+ "executable '%s' is not readable",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ else
+ error.SetErrorStringWithFormat(
+ "unable to find executable for '%s'",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+ } else {
+ if (m_remote_platform_sp) {
+ return GetCachedExecutable(resolved_module_spec, exe_module_sp,
+ module_search_paths_ptr,
+ *m_remote_platform_sp);
+ }
+
+ // 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 (FileSystem::Instance().Exists(resolved_module_spec.GetFileSpec()))
+ error.Clear();
+ else
+ error.SetErrorStringWithFormat("the platform is not currently "
+ "connected, and '%s' doesn't exist in "
+ "the system root.",
+ exe_path);
+ }
+
+ if (error.Success()) {
+ if (resolved_module_spec.GetArchitecture().IsValid()) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ module_search_paths_ptr, nullptr, nullptr);
+ if (error.Fail()) {
+ // If we failed, it may be because the vendor and os aren't known. If
+ // that is the case, try setting them to the host architecture and give
+ // it another try.
+ llvm::Triple &module_triple =
+ resolved_module_spec.GetArchitecture().GetTriple();
+ bool is_vendor_specified =
+ (module_triple.getVendor() != llvm::Triple::UnknownVendor);
+ bool is_os_specified =
+ (module_triple.getOS() != llvm::Triple::UnknownOS);
+ if (!is_vendor_specified || !is_os_specified) {
+ const llvm::Triple &host_triple =
+ HostInfo::GetArchitecture(HostInfo::eArchKindDefault).GetTriple();
+
+ if (!is_vendor_specified)
+ module_triple.setVendorName(host_triple.getVendorName());
+ if (!is_os_specified)
+ module_triple.setOSName(host_triple.getOSName());
+
+ error = ModuleList::GetSharedModule(resolved_module_spec,
+ exe_module_sp, module_search_paths_ptr, nullptr, nullptr);
+ }
+ }
+
+ // TODO find out why exe_module_sp might be NULL
+ if (error.Fail() || !exe_module_sp || !exe_module_sp->GetObjectFile()) {
+ 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, nullptr, nullptr);
+ // 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 (FileSystem::Instance().Readable(
+ resolved_module_spec.GetFileSpec())) {
+ error.SetErrorStringWithFormat(
+ "'%s' doesn't contain any '%s' platform architectures: %s",
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ GetPluginName().GetCString(), arch_names.GetData());
+ } else {
+ error.SetErrorStringWithFormat(
+ "'%s' is not readable",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+ }
+ }
+ }
+
+ return error;
}
Status RemoteAwarePlatform::RunShellCommand(
diff --git a/lldb/source/Target/SectionLoadHistory.cpp b/lldb/source/Target/SectionLoadHistory.cpp
index ec16b58b4451..f329d425e34b 100644
--- a/lldb/source/Target/SectionLoadHistory.cpp
+++ b/lldb/source/Target/SectionLoadHistory.cpp
@@ -1,4 +1,4 @@
-//===-- SectionLoadHistory.cpp ----------------------------------*- C++ -*-===//
+//===-- SectionLoadHistory.cpp --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/SectionLoadList.cpp b/lldb/source/Target/SectionLoadList.cpp
index f2546a893194..f1a626b04802 100644
--- a/lldb/source/Target/SectionLoadList.cpp
+++ b/lldb/source/Target/SectionLoadList.cpp
@@ -1,4 +1,4 @@
-//===-- SectionLoadList.cpp -------------------------------------*- C++ -*-===//
+//===-- SectionLoadList.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -253,6 +253,6 @@ void SectionLoadList::Dump(Stream &s, Target *target) {
++pos) {
s.Printf("addr = 0x%16.16" PRIx64 ", section = %p: ", pos->first,
static_cast<void *>(pos->second.get()));
- pos->second->Dump(&s, target, 0);
+ pos->second->Dump(s.AsRawOstream(), s.GetIndentLevel(), target, 0);
}
}
diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp
index 5c6ea7a03933..3d6cc5dc90b3 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -1,4 +1,4 @@
-//===-- StackFrame.cpp ------------------------------------------*- C++ -*-===//
+//===-- StackFrame.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -606,7 +606,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
}
// We are dumping at least one child
- while (separator_idx != std::string::npos) {
+ while (!var_expr.empty()) {
// Calculate the next separator index ahead of time
ValueObjectSP child_valobj_sp;
const char separator_type = var_expr[0];
@@ -673,7 +673,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
if (actual_is_ptr != expr_is_ptr) {
// Incorrect use of "." with a pointer, or "->" with a
// class/union/struct instance or reference.
- valobj_sp->GetExpressionPath(var_expr_path_strm, false);
+ valobj_sp->GetExpressionPath(var_expr_path_strm);
if (actual_is_ptr)
error.SetErrorStringWithFormat(
"\"%s\" is a pointer and . was used to attempt to access "
@@ -709,7 +709,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
"this frame",
name_const_string.GetCString());
} else {
- valobj_sp->GetExpressionPath(var_expr_path_strm, false);
+ valobj_sp->GetExpressionPath(var_expr_path_strm);
if (child_name) {
error.SetErrorStringWithFormat(
"\"%s\" is not a member of \"(%s) %s\"",
@@ -782,7 +782,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
Status error;
ValueObjectSP temp(valobj_sp->Dereference(error));
if (error.Fail()) {
- valobj_sp->GetExpressionPath(var_expr_path_strm, false);
+ valobj_sp->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
"could not dereference \"(%s) %s\"",
valobj_sp->GetTypeName().AsCString("<invalid type>"),
@@ -800,7 +800,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
Status error;
ValueObjectSP temp(valobj_sp->GetChildAtIndex(0, true));
if (error.Fail()) {
- valobj_sp->GetExpressionPath(var_expr_path_strm, false);
+ valobj_sp->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
"could not get item 0 for \"(%s) %s\"",
valobj_sp->GetTypeName().AsCString("<invalid type>"),
@@ -837,7 +837,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
|| synthetic == valobj_sp) /* synthetic is the same as
the original object */
{
- valobj_sp->GetExpressionPath(var_expr_path_strm, false);
+ valobj_sp->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
"\"(%s) %s\" is not an array type",
valobj_sp->GetTypeName().AsCString("<invalid type>"),
@@ -846,7 +846,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
static_cast<uint32_t>(child_index) >=
synthetic
->GetNumChildren() /* synthetic does not have that many values */) {
- valobj_sp->GetExpressionPath(var_expr_path_strm, false);
+ valobj_sp->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
"array index %ld is not valid for \"(%s) %s\"", child_index,
valobj_sp->GetTypeName().AsCString("<invalid type>"),
@@ -854,7 +854,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
} else {
child_valobj_sp = synthetic->GetChildAtIndex(child_index, true);
if (!child_valobj_sp) {
- valobj_sp->GetExpressionPath(var_expr_path_strm, false);
+ valobj_sp->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
"array index %ld is not valid for \"(%s) %s\"", child_index,
valobj_sp->GetTypeName().AsCString("<invalid type>"),
@@ -865,7 +865,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
child_valobj_sp =
valobj_sp->GetSyntheticArrayMember(child_index, true);
if (!child_valobj_sp) {
- valobj_sp->GetExpressionPath(var_expr_path_strm, false);
+ valobj_sp->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
"failed to use pointer as array for index %ld for "
"\"(%s) %s\"",
@@ -884,7 +884,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
valobj_sp->GetSyntheticArrayMember(child_index, true);
if (!child_valobj_sp) {
- valobj_sp->GetExpressionPath(var_expr_path_strm, false);
+ valobj_sp->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
"array index %ld is not valid for \"(%s) %s\"", child_index,
valobj_sp->GetTypeName().AsCString("<invalid type>"),
@@ -895,7 +895,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
child_valobj_sp = valobj_sp->GetSyntheticBitFieldChild(
child_index, child_index, true);
if (!child_valobj_sp) {
- valobj_sp->GetExpressionPath(var_expr_path_strm, false);
+ valobj_sp->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
"bitfield range %ld-%ld is not valid for \"(%s) %s\"",
child_index, child_index,
@@ -909,7 +909,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
|| synthetic == valobj_sp) /* synthetic is the same as the
original object */
{
- valobj_sp->GetExpressionPath(var_expr_path_strm, false);
+ valobj_sp->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
"\"(%s) %s\" is not an array type",
valobj_sp->GetTypeName().AsCString("<invalid type>"),
@@ -918,7 +918,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
static_cast<uint32_t>(child_index) >=
synthetic
->GetNumChildren() /* synthetic does not have that many values */) {
- valobj_sp->GetExpressionPath(var_expr_path_strm, false);
+ valobj_sp->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
"array index %ld is not valid for \"(%s) %s\"", child_index,
valobj_sp->GetTypeName().AsCString("<invalid type>"),
@@ -926,7 +926,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
} else {
child_valobj_sp = synthetic->GetChildAtIndex(child_index, true);
if (!child_valobj_sp) {
- valobj_sp->GetExpressionPath(var_expr_path_strm, false);
+ valobj_sp->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
"array index %ld is not valid for \"(%s) %s\"", child_index,
valobj_sp->GetTypeName().AsCString("<invalid type>"),
@@ -940,7 +940,6 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
return ValueObjectSP();
}
- separator_idx = var_expr.find_first_of(".-[");
if (use_dynamic != eNoDynamicValues) {
ValueObjectSP dynamic_value_sp(
child_valobj_sp->GetDynamicValue(use_dynamic));
@@ -982,7 +981,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
Status error;
ValueObjectSP temp(valobj_sp->Dereference(error));
if (error.Fail()) {
- valobj_sp->GetExpressionPath(var_expr_path_strm, false);
+ valobj_sp->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
"could not dereference \"(%s) %s\"",
valobj_sp->GetTypeName().AsCString("<invalid type>"),
@@ -999,7 +998,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
Status error;
ValueObjectSP temp(valobj_sp->GetChildAtIndex(0, true));
if (error.Fail()) {
- valobj_sp->GetExpressionPath(var_expr_path_strm, false);
+ valobj_sp->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
"could not get item 0 for \"(%s) %s\"",
valobj_sp->GetTypeName().AsCString("<invalid type>"),
@@ -1013,7 +1012,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
child_valobj_sp =
valobj_sp->GetSyntheticBitFieldChild(child_index, final_index, true);
if (!child_valobj_sp) {
- valobj_sp->GetExpressionPath(var_expr_path_strm, false);
+ valobj_sp->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
"bitfield range %ld-%ld is not valid for \"(%s) %s\"", child_index,
final_index, valobj_sp->GetTypeName().AsCString("<invalid type>"),
@@ -1025,7 +1024,6 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
return ValueObjectSP();
}
- separator_idx = var_expr.find_first_of(".-[");
if (use_dynamic != eNoDynamicValues) {
ValueObjectSP dynamic_value_sp(
child_valobj_sp->GetDynamicValue(use_dynamic));
@@ -1039,7 +1037,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
default:
// Failure...
{
- valobj_sp->GetExpressionPath(var_expr_path_strm, false);
+ valobj_sp->GetExpressionPath(var_expr_path_strm);
error.SetErrorStringWithFormat(
"unexpected char '%c' encountered after \"%s\" in \"%s\"",
separator_type, var_expr_path_strm.GetData(),
@@ -1051,9 +1049,6 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
if (child_valobj_sp)
valobj_sp = child_valobj_sp;
-
- if (var_expr.empty())
- break;
}
if (valobj_sp) {
if (deref) {
@@ -1321,14 +1316,13 @@ lldb::ValueObjectSP StackFrame::GuessValueForAddress(lldb::addr_t addr) {
pc_range.GetBaseAddress() = GetFrameCodeAddress();
pc_range.SetByteSize(target_arch.GetMaximumOpcodeByteSize());
- ExecutionContext exe_ctx(shared_from_this());
-
const char *plugin_name = nullptr;
const char *flavor = nullptr;
const bool prefer_file_cache = false;
- DisassemblerSP disassembler_sp = Disassembler::DisassembleRange(
- target_arch, plugin_name, flavor, exe_ctx, pc_range, prefer_file_cache);
+ DisassemblerSP disassembler_sp =
+ Disassembler::DisassembleRange(target_arch, plugin_name, flavor,
+ *target_sp, pc_range, prefer_file_cache);
if (!disassembler_sp || !disassembler_sp->GetInstructionList().GetSize()) {
return ValueObjectSP();
@@ -1500,7 +1494,7 @@ lldb::ValueObjectSP DoGuessValueAt(StackFrame &frame, ConstString reg,
// +18 that assigns to rdi, and calls itself recursively for that dereference
// DoGuessValueAt(frame, rdi, 8, dis, vars, 0x18) finds the instruction at
// +14 that assigns to rdi, and calls itself recursively for that
- // derefernece
+ // dereference
// DoGuessValueAt(frame, rbp, -8, dis, vars, 0x14) finds "f" in the
// variable list.
// Returns a ValueObject for f. (That's what was stored at rbp-8 at +14)
@@ -1702,13 +1696,12 @@ lldb::ValueObjectSP StackFrame::GuessValueForRegisterAndOffset(ConstString reg,
return ValueObjectSP();
}
- ExecutionContext exe_ctx(shared_from_this());
-
const char *plugin_name = nullptr;
const char *flavor = nullptr;
const bool prefer_file_cache = false;
- DisassemblerSP disassembler_sp = Disassembler::DisassembleRange(
- target_arch, plugin_name, flavor, exe_ctx, pc_range, prefer_file_cache);
+ DisassemblerSP disassembler_sp =
+ Disassembler::DisassembleRange(target_arch, plugin_name, flavor,
+ *target_sp, pc_range, prefer_file_cache);
if (!disassembler_sp || !disassembler_sp->GetInstructionList().GetSize()) {
return ValueObjectSP();
@@ -1863,6 +1856,7 @@ void StackFrame::UpdatePreviousFrameFromCurrentFrame(StackFrame &curr_frame) {
m_concrete_frame_index = curr_frame.m_concrete_frame_index;
m_reg_context_sp = curr_frame.m_reg_context_sp;
m_frame_code_addr = curr_frame.m_frame_code_addr;
+ m_behaves_like_zeroth_frame = curr_frame.m_behaves_like_zeroth_frame;
assert(!m_sc.target_sp || !curr_frame.m_sc.target_sp ||
m_sc.target_sp.get() == curr_frame.m_sc.target_sp.get());
assert(!m_sc.module_sp || !curr_frame.m_sc.module_sp ||
@@ -1942,16 +1936,14 @@ bool StackFrame::GetStatus(Stream &strm, bool show_frame_info, bool show_source,
const uint32_t disasm_lines = debugger.GetDisassemblyLineCount();
if (disasm_lines > 0) {
const ArchSpec &target_arch = target->GetArchitecture();
- AddressRange pc_range;
- pc_range.GetBaseAddress() = GetFrameCodeAddress();
- pc_range.SetByteSize(disasm_lines *
- target_arch.GetMaximumOpcodeByteSize());
const char *plugin_name = nullptr;
const char *flavor = nullptr;
const bool mixed_source_and_assembly = false;
Disassembler::Disassemble(
target->GetDebugger(), target_arch, plugin_name, flavor,
- exe_ctx, pc_range, disasm_lines, mixed_source_and_assembly, 0,
+ exe_ctx, GetFrameCodeAddress(),
+ {Disassembler::Limit::Instructions, disasm_lines},
+ mixed_source_and_assembly, 0,
Disassembler::eOptionMarkPCAddress, strm);
}
}
diff --git a/lldb/source/Target/StackFrameList.cpp b/lldb/source/Target/StackFrameList.cpp
index 87b49849bc99..e4f5d3028366 100644
--- a/lldb/source/Target/StackFrameList.cpp
+++ b/lldb/source/Target/StackFrameList.cpp
@@ -1,4 +1,4 @@
-//===-- StackFrameList.cpp --------------------------------------*- C++ -*-===//
+//===-- StackFrameList.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -218,17 +218,14 @@ void StackFrameList::SetCurrentInlinedDepth(uint32_t new_depth) {
}
void StackFrameList::GetOnlyConcreteFramesUpTo(uint32_t end_idx,
- Unwind *unwinder) {
+ Unwind &unwinder) {
assert(m_thread.IsValid() && "Expected valid thread");
assert(m_frames.size() <= end_idx && "Expected there to be frames to fill");
if (end_idx < m_concrete_frames_fetched)
return;
- if (!unwinder)
- return;
-
- uint32_t num_frames = unwinder->GetFramesUpTo(end_idx);
+ uint32_t num_frames = unwinder.GetFramesUpTo(end_idx);
if (num_frames <= end_idx + 1) {
// Done unwinding.
m_concrete_frames_fetched = UINT32_MAX;
@@ -239,13 +236,22 @@ void StackFrameList::GetOnlyConcreteFramesUpTo(uint32_t end_idx,
m_frames.resize(num_frames);
}
+/// A sequence of calls that comprise some portion of a backtrace. Each frame
+/// is represented as a pair of a callee (Function *) and an address within the
+/// callee.
+struct CallDescriptor {
+ Function *func;
+ CallEdge::AddrType address_type = CallEdge::AddrType::Call;
+ addr_t address = LLDB_INVALID_ADDRESS;
+};
+using CallSequence = std::vector<CallDescriptor>;
+
/// Find the unique path through the call graph from \p begin (with return PC
/// \p return_pc) to \p end. On success this path is stored into \p path, and
/// on failure \p path is unchanged.
static void FindInterveningFrames(Function &begin, Function &end,
ExecutionContext &exe_ctx, Target &target,
- addr_t return_pc,
- std::vector<Function *> &path,
+ addr_t return_pc, CallSequence &path,
ModuleList &images, Log *log) {
LLDB_LOG(log, "Finding frames between {0} and {1}, retn-pc={2:x}",
begin.GetDisplayName(), end.GetDisplayName(), return_pc);
@@ -278,24 +284,27 @@ static void FindInterveningFrames(Function &begin, Function &end,
// Fully explore the set of functions reachable from the first edge via tail
// calls in order to detect ambiguous executions.
struct DFS {
- std::vector<Function *> active_path = {};
- std::vector<Function *> solution_path = {};
+ CallSequence active_path = {};
+ CallSequence solution_path = {};
llvm::SmallPtrSet<Function *, 2> visited_nodes = {};
bool ambiguous = false;
Function *end;
ModuleList &images;
+ Target &target;
ExecutionContext &context;
- DFS(Function *end, ModuleList &images, ExecutionContext &context)
- : end(end), images(images), context(context) {}
+ DFS(Function *end, ModuleList &images, Target &target,
+ ExecutionContext &context)
+ : end(end), images(images), target(target), context(context) {}
- void search(Function &first_callee, std::vector<Function *> &path) {
- dfs(first_callee);
+ void search(CallEdge &first_edge, Function &first_callee,
+ CallSequence &path) {
+ dfs(first_edge, first_callee);
if (!ambiguous)
path = std::move(solution_path);
}
- void dfs(Function &callee) {
+ void dfs(CallEdge &current_edge, Function &callee) {
// Found a path to the target function.
if (&callee == end) {
if (solution_path.empty())
@@ -315,13 +324,16 @@ static void FindInterveningFrames(Function &begin, Function &end,
}
// Search the calls made from this callee.
- active_path.push_back(&callee);
+ active_path.push_back(CallDescriptor{&callee});
for (const auto &edge : callee.GetTailCallingEdges()) {
Function *next_callee = edge->GetCallee(images, context);
if (!next_callee)
continue;
- dfs(*next_callee);
+ std::tie(active_path.back().address_type, active_path.back().address) =
+ edge->GetCallerAddress(callee, target);
+
+ dfs(*edge, *next_callee);
if (ambiguous)
return;
}
@@ -329,7 +341,7 @@ static void FindInterveningFrames(Function &begin, Function &end,
}
};
- DFS(&end, images, exe_ctx).search(*first_callee, path);
+ DFS(&end, images, target, exe_ctx).search(*first_edge, *first_callee, path);
}
/// Given that \p next_frame will be appended to the frame list, synthesize
@@ -348,6 +360,11 @@ static void FindInterveningFrames(Function &begin, Function &end,
/// | ... | <- Not-yet-visited frames.
/// --------------
void StackFrameList::SynthesizeTailCallFrames(StackFrame &next_frame) {
+ // Cannot synthesize tail call frames when the stack is empty (there is no
+ // "previous" frame).
+ if (m_frames.empty())
+ return;
+
TargetSP target_sp = next_frame.CalculateTarget();
if (!target_sp)
return;
@@ -358,7 +375,6 @@ void StackFrameList::SynthesizeTailCallFrames(StackFrame &next_frame) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
- assert(!m_frames.empty() && "Cannot synthesize frames in an empty stack");
StackFrame &prev_frame = *m_frames.back().get();
// Find the functions prev_frame and next_frame are stopped in. The function
@@ -378,7 +394,7 @@ void StackFrameList::SynthesizeTailCallFrames(StackFrame &next_frame) {
// Try to find the unique sequence of (tail) calls which led from next_frame
// to prev_frame.
- std::vector<Function *> path;
+ CallSequence path;
addr_t return_pc = next_reg_ctx_sp->GetPC();
Target &target = *target_sp.get();
ModuleList &images = next_frame.CalculateTarget()->GetImages();
@@ -388,14 +404,17 @@ void StackFrameList::SynthesizeTailCallFrames(StackFrame &next_frame) {
path, images, log);
// Push synthetic tail call frames.
- for (Function *callee : llvm::reverse(path)) {
+ for (auto calleeInfo : llvm::reverse(path)) {
+ Function *callee = calleeInfo.func;
uint32_t frame_idx = m_frames.size();
uint32_t concrete_frame_idx = next_frame.GetConcreteFrameIndex();
addr_t cfa = LLDB_INVALID_ADDRESS;
bool cfa_is_valid = false;
- addr_t pc =
- callee->GetAddressRange().GetBaseAddress().GetLoadAddress(&target);
- constexpr bool behaves_like_zeroth_frame = false;
+ addr_t pc = calleeInfo.address;
+ // If the callee address refers to the call instruction, we do not want to
+ // subtract 1 from this value.
+ const bool behaves_like_zeroth_frame =
+ calleeInfo.address_type == CallEdge::AddrType::Call;
SymbolContext sc;
callee->CalculateSymbolContext(&sc);
auto synth_frame = std::make_shared<StackFrame>(
@@ -403,7 +422,7 @@ void StackFrameList::SynthesizeTailCallFrames(StackFrame &next_frame) {
cfa_is_valid, pc, StackFrame::Kind::Artificial,
behaves_like_zeroth_frame, &sc);
m_frames.push_back(synth_frame);
- LLDB_LOG(log, "Pushed frame {0}", callee->GetDisplayName());
+ LLDB_LOG(log, "Pushed frame {0} at {1:x}", callee->GetDisplayName(), pc);
}
// If any frames were created, adjust next_frame's index.
@@ -421,7 +440,7 @@ void StackFrameList::GetFramesUpTo(uint32_t end_idx) {
if (m_frames.size() > end_idx || GetAllFramesFetched())
return;
- Unwind *unwinder = m_thread.GetUnwinder();
+ Unwind &unwinder = m_thread.GetUnwinder();
if (!m_show_inlined_frames) {
GetOnlyConcreteFramesUpTo(end_idx, unwinder);
@@ -459,9 +478,8 @@ void StackFrameList::GetFramesUpTo(uint32_t end_idx) {
RegisterContextSP reg_ctx_sp(m_thread.GetRegisterContext());
if (reg_ctx_sp) {
- const bool success = unwinder &&
- unwinder->GetFrameInfoAtIndex(
- idx, cfa, pc, behaves_like_zeroth_frame);
+ const bool success = unwinder.GetFrameInfoAtIndex(
+ idx, cfa, pc, behaves_like_zeroth_frame);
// There shouldn't be any way not to get the frame info for frame
// 0. But if the unwinder can't make one, lets make one by hand
// with the SP as the CFA and see if that gets any further.
@@ -480,9 +498,8 @@ void StackFrameList::GetFramesUpTo(uint32_t end_idx) {
cfa = unwind_frame_sp->m_id.GetCallFrameAddress();
}
} else {
- const bool success = unwinder &&
- unwinder->GetFrameInfoAtIndex(
- idx, cfa, pc, behaves_like_zeroth_frame);
+ const bool success =
+ unwinder.GetFrameInfoAtIndex(idx, cfa, pc, behaves_like_zeroth_frame);
if (!success) {
// We've gotten to the end of the stack.
SetAllFramesFetched();
@@ -665,31 +682,28 @@ StackFrameSP StackFrameList::GetFrameAtIndex(uint32_t idx) {
// GetFramesUpTo.
frame_sp = m_frames[idx];
} else {
- Unwind *unwinder = m_thread.GetUnwinder();
- if (unwinder) {
- addr_t pc, cfa;
- bool behaves_like_zeroth_frame = (idx == 0);
- if (unwinder->GetFrameInfoAtIndex(idx, cfa, pc,
- behaves_like_zeroth_frame)) {
- const bool cfa_is_valid = true;
- frame_sp = std::make_shared<StackFrame>(
- m_thread.shared_from_this(), idx, idx, cfa, cfa_is_valid, pc,
- StackFrame::Kind::Regular, behaves_like_zeroth_frame, nullptr);
-
- Function *function =
- frame_sp->GetSymbolContext(eSymbolContextFunction).function;
- if (function) {
- // When we aren't showing inline functions we always use the top
- // most function block as the scope.
- frame_sp->SetSymbolContextScope(&function->GetBlock(false));
- } else {
- // Set the symbol scope from the symbol regardless if it is nullptr
- // or valid.
- frame_sp->SetSymbolContextScope(
- frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol);
- }
- SetFrameAtIndex(idx, frame_sp);
+ addr_t pc, cfa;
+ bool behaves_like_zeroth_frame = (idx == 0);
+ if (m_thread.GetUnwinder().GetFrameInfoAtIndex(
+ idx, cfa, pc, behaves_like_zeroth_frame)) {
+ const bool cfa_is_valid = true;
+ frame_sp = std::make_shared<StackFrame>(
+ m_thread.shared_from_this(), idx, idx, cfa, cfa_is_valid, pc,
+ StackFrame::Kind::Regular, behaves_like_zeroth_frame, nullptr);
+
+ Function *function =
+ frame_sp->GetSymbolContext(eSymbolContextFunction).function;
+ if (function) {
+ // When we aren't showing inline functions we always use the top
+ // most function block as the scope.
+ frame_sp->SetSymbolContextScope(&function->GetBlock(false));
+ } else {
+ // Set the symbol scope from the symbol regardless if it is nullptr
+ // or valid.
+ frame_sp->SetSymbolContextScope(
+ frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol);
}
+ SetFrameAtIndex(idx, frame_sp);
}
}
} else if (original_idx == 0) {
diff --git a/lldb/source/Target/StackFrameRecognizer.cpp b/lldb/source/Target/StackFrameRecognizer.cpp
index 75a6cd215126..7dc6e9d1e490 100644
--- a/lldb/source/Target/StackFrameRecognizer.cpp
+++ b/lldb/source/Target/StackFrameRecognizer.cpp
@@ -1,4 +1,4 @@
-//===-- StackFrameRecognizer.cpp --------------------------------*- C++ -*-===//
+//===-- StackFrameRecognizer.cpp ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -50,31 +50,42 @@ ScriptedStackFrameRecognizer::RecognizeFrame(lldb::StackFrameSP frame) {
class StackFrameRecognizerManagerImpl {
public:
- void AddRecognizer(StackFrameRecognizerSP recognizer,
- ConstString module, ConstString symbol,
+ void AddRecognizer(StackFrameRecognizerSP recognizer, ConstString module,
+ llvm::ArrayRef<ConstString> symbols,
bool first_instruction_only) {
- m_recognizers.push_front({(uint32_t)m_recognizers.size(), false, recognizer, false, module, RegularExpressionSP(),
- symbol, RegularExpressionSP(),
- first_instruction_only});
+ m_recognizers.push_front({(uint32_t)m_recognizers.size(), false, recognizer,
+ false, module, RegularExpressionSP(), symbols,
+ RegularExpressionSP(), first_instruction_only});
}
void AddRecognizer(StackFrameRecognizerSP recognizer,
RegularExpressionSP module, RegularExpressionSP symbol,
bool first_instruction_only) {
- m_recognizers.push_front({(uint32_t)m_recognizers.size(), false, recognizer, true, ConstString(), module,
- ConstString(), symbol, first_instruction_only});
+ m_recognizers.push_front(
+ {(uint32_t)m_recognizers.size(), false, recognizer, true, ConstString(),
+ module, std::vector<ConstString>(), symbol, first_instruction_only});
}
- void ForEach(
- std::function<void(uint32_t recognized_id, std::string recognizer_name, std::string module,
- std::string symbol, bool regexp)> const &callback) {
+ void ForEach(std::function<
+ void(uint32_t recognized_id, std::string recognizer_name,
+ std::string module, llvm::ArrayRef<ConstString> symbols,
+ bool regexp)> const &callback) {
for (auto entry : m_recognizers) {
if (entry.is_regexp) {
- callback(entry.recognizer_id, entry.recognizer->GetName(), entry.module_regexp->GetText(),
- entry.symbol_regexp->GetText(), true);
+ std::string module_name;
+ std::string symbol_name;
+
+ if (entry.module_regexp)
+ module_name = entry.module_regexp->GetText().str();
+ if (entry.symbol_regexp)
+ symbol_name = entry.symbol_regexp->GetText().str();
+
+ callback(entry.recognizer_id, entry.recognizer->GetName(), module_name,
+ llvm::makeArrayRef(ConstString(symbol_name)), true);
+
} else {
- callback(entry.recognizer_id, entry.recognizer->GetName(), entry.module.GetCString(),
- entry.symbol.GetCString(), false);
+ callback(entry.recognizer_id, entry.recognizer->GetName(),
+ entry.module.GetCString(), entry.symbols, false);
}
}
}
@@ -91,8 +102,8 @@ public:
}
StackFrameRecognizerSP GetRecognizerForFrame(StackFrameSP frame) {
- const SymbolContext &symctx =
- frame->GetSymbolContext(eSymbolContextModule | eSymbolContextFunction);
+ const SymbolContext &symctx = frame->GetSymbolContext(
+ eSymbolContextModule | eSymbolContextFunction | eSymbolContextSymbol);
ConstString function_name = symctx.GetFunctionName();
ModuleSP module_sp = symctx.module_sp;
if (!module_sp) return StackFrameRecognizerSP();
@@ -110,8 +121,9 @@ public:
if (entry.module_regexp)
if (!entry.module_regexp->Execute(module_name.GetStringRef())) continue;
- if (entry.symbol)
- if (entry.symbol != function_name) continue;
+ if (!entry.symbols.empty())
+ if (!llvm::is_contained(entry.symbols, function_name))
+ continue;
if (entry.symbol_regexp)
if (!entry.symbol_regexp->Execute(function_name.GetStringRef()))
@@ -139,7 +151,7 @@ public:
bool is_regexp;
ConstString module;
RegularExpressionSP module_regexp;
- ConstString symbol;
+ std::vector<ConstString> symbols;
RegularExpressionSP symbol_regexp;
bool first_instruction_only;
};
@@ -155,9 +167,9 @@ StackFrameRecognizerManagerImpl &GetStackFrameRecognizerManagerImpl() {
void StackFrameRecognizerManager::AddRecognizer(
StackFrameRecognizerSP recognizer, ConstString module,
- ConstString symbol, bool first_instruction_only) {
- GetStackFrameRecognizerManagerImpl().AddRecognizer(recognizer, module, symbol,
- first_instruction_only);
+ llvm::ArrayRef<ConstString> symbols, bool first_instruction_only) {
+ GetStackFrameRecognizerManagerImpl().AddRecognizer(
+ recognizer, module, symbols, first_instruction_only);
}
void StackFrameRecognizerManager::AddRecognizer(
@@ -168,8 +180,9 @@ void StackFrameRecognizerManager::AddRecognizer(
}
void StackFrameRecognizerManager::ForEach(
- std::function<void(uint32_t recognized_id, std::string recognizer_name, std::string module,
- std::string symbol, bool regexp)> const &callback) {
+ std::function<void(uint32_t recognized_id, std::string recognizer_name,
+ std::string module, llvm::ArrayRef<ConstString> symbols,
+ bool regexp)> const &callback) {
GetStackFrameRecognizerManagerImpl().ForEach(callback);
}
diff --git a/lldb/source/Target/StackID.cpp b/lldb/source/Target/StackID.cpp
index a8f6b787f4b4..410d5b7e820a 100644
--- a/lldb/source/Target/StackID.cpp
+++ b/lldb/source/Target/StackID.cpp
@@ -1,4 +1,4 @@
-//===-- StackID.cpp ---------------------------------------------*- C++ -*-===//
+//===-- StackID.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp
index 28179b7e1ce0..7e830c6e2bed 100644
--- a/lldb/source/Target/StopInfo.cpp
+++ b/lldb/source/Target/StopInfo.cpp
@@ -1,4 +1,4 @@
-//===-- StopInfo.cpp --------------------------------------------*- C++ -*-===//
+//===-- StopInfo.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -206,7 +206,7 @@ public:
strm.Printf("breakpoint ");
bp_site_sp->GetDescription(&strm, eDescriptionLevelBrief);
- m_description = strm.GetString();
+ m_description = std::string(strm.GetString());
} else {
StreamString strm;
if (m_break_id != LLDB_INVALID_BREAK_ID) {
@@ -239,7 +239,7 @@ public:
" which has been deleted - was at 0x%" PRIx64,
m_value, m_address);
- m_description = strm.GetString();
+ m_description = std::string(strm.GetString());
}
}
}
@@ -453,7 +453,7 @@ protected:
} else {
LLDB_LOGF(log,
"Condition evaluated for breakpoint %s on thread "
- "0x%llx conditon_says_stop: %i.",
+ "0x%llx condition_says_stop: %i.",
loc_desc.GetData(),
static_cast<unsigned long long>(thread_sp->GetID()),
condition_says_stop);
@@ -631,7 +631,7 @@ public:
if (m_description.empty()) {
StreamString strm;
strm.Printf("watchpoint %" PRIi64, m_value);
- m_description = strm.GetString();
+ m_description = std::string(strm.GetString());
}
return m_description.c_str();
}
@@ -969,7 +969,7 @@ public:
strm.Printf("signal %s", signal_name);
else
strm.Printf("signal %" PRIi64, m_value);
- m_description = strm.GetString();
+ m_description = std::string(strm.GetString());
}
}
return m_description.c_str();
@@ -1034,7 +1034,7 @@ public:
if (m_description.empty()) {
StreamString strm;
m_plan_sp->GetDescription(&strm, eDescriptionLevelBrief);
- m_description = strm.GetString();
+ m_description = std::string(strm.GetString());
}
return m_description.c_str();
}
diff --git a/lldb/source/Target/StructuredDataPlugin.cpp b/lldb/source/Target/StructuredDataPlugin.cpp
index a22902d99f7c..bd899d2f7681 100644
--- a/lldb/source/Target/StructuredDataPlugin.cpp
+++ b/lldb/source/Target/StructuredDataPlugin.cpp
@@ -1,4 +1,4 @@
-//===-- StructuredDataPlugin.cpp --------------------------------*- C++ -*-===//
+//===-- StructuredDataPlugin.cpp ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/SystemRuntime.cpp b/lldb/source/Target/SystemRuntime.cpp
index 286bea09f854..cd3d8ba2c7b0 100644
--- a/lldb/source/Target/SystemRuntime.cpp
+++ b/lldb/source/Target/SystemRuntime.cpp
@@ -1,4 +1,4 @@
-//===-- SystemRuntime.cpp ---------------------------------------*- C++ -*-===//
+//===-- SystemRuntime.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 83e6f3062666..dad56376005c 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1,4 +1,4 @@
-//===-- Target.cpp ----------------------------------------------*- C++ -*-===//
+//===-- Target.cpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -27,6 +27,7 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/StructuredDataImpl.h"
#include "lldb/Core/ValueObject.h"
+#include "lldb/Expression/ExpressionVariable.h"
#include "lldb/Expression/REPL.h"
#include "lldb/Expression/UserExpression.h"
#include "lldb/Host/Host.h"
@@ -36,8 +37,6 @@
#include "lldb/Interpreter/OptionGroupWatchpoint.h"
#include "lldb/Interpreter/OptionValues.h"
#include "lldb/Interpreter/Property.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangASTImporter.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Symbol.h"
@@ -91,7 +90,7 @@ Target::Target(Debugger &debugger, const ArchSpec &target_arch,
m_mutex(), m_arch(target_arch), m_images(this), m_section_load_history(),
m_breakpoint_list(false), m_internal_breakpoint_list(true),
m_watchpoint_list(), m_process_sp(), m_search_filter_sp(),
- m_image_search_paths(ImageSearchPathsChanged, this), m_ast_importer_sp(),
+ m_image_search_paths(ImageSearchPathsChanged, this),
m_source_manager_up(), m_stop_hooks(), m_stop_hook_next_id(0),
m_valid(true), m_suppress_stop_hooks(false),
m_is_dummy_target(is_dummy_target),
@@ -114,6 +113,8 @@ Target::Target(Debugger &debugger, const ArchSpec &target_arch,
target_arch.GetArchitectureName(),
target_arch.GetTriple().getTriple().c_str());
}
+
+ UpdateLaunchInfoFromProperties();
}
Target::~Target() {
@@ -128,12 +129,13 @@ void Target::PrimeFromDummyTarget(Target *target) {
m_stop_hooks = target->m_stop_hooks;
- for (BreakpointSP breakpoint_sp : target->m_breakpoint_list.Breakpoints()) {
+ for (const auto &breakpoint_sp : target->m_breakpoint_list.Breakpoints()) {
if (breakpoint_sp->IsInternal())
continue;
- BreakpointSP new_bp(new Breakpoint(*this, *breakpoint_sp.get()));
- AddBreakpoint(new_bp, false);
+ BreakpointSP new_bp(
+ Breakpoint::CopyFromBreakpoint(shared_from_this(), *breakpoint_sp));
+ AddBreakpoint(std::move(new_bp), false);
}
for (auto bp_name_entry : target->m_breakpoint_names) {
@@ -622,7 +624,7 @@ BreakpointSP Target::CreateBreakpoint(SearchFilterSP &filter_sp,
const bool hardware = request_hardware || GetRequireHardwareBreakpoints();
bp_sp.reset(new Breakpoint(*this, filter_sp, resolver_sp, hardware,
resolve_indirect_symbols));
- resolver_sp->SetBreakpoint(bp_sp.get());
+ resolver_sp->SetBreakpoint(bp_sp);
AddBreakpoint(bp_sp, internal);
}
return bp_sp;
@@ -1109,8 +1111,8 @@ Status Target::CreateBreakpointsFromFile(const FileSpec &file,
!Breakpoint::SerializedBreakpointMatchesNames(bkpt_data_sp, names))
continue;
- BreakpointSP bkpt_sp =
- Breakpoint::CreateFromStructuredData(*this, bkpt_data_sp, error);
+ BreakpointSP bkpt_sp = Breakpoint::CreateFromStructuredData(
+ shared_from_this(), bkpt_data_sp, error);
if (!error.Success()) {
error.SetErrorStringWithFormat(
"Error restoring breakpoint %zu from %s: %s.", i,
@@ -1378,7 +1380,6 @@ void Target::ClearModules(bool delete_locations) {
m_section_load_history.Clear();
m_images.Clear();
m_scratch_type_system_map.Clear();
- m_ast_importer_sp.reset();
}
void Target::DidExec() {
@@ -2258,16 +2259,6 @@ Target::GetUtilityFunctionForLanguage(const char *text,
return utility_fn;
}
-ClangASTImporterSP Target::GetClangASTImporter() {
- if (m_valid) {
- if (!m_ast_importer_sp) {
- m_ast_importer_sp = std::make_shared<ClangASTImporter>();
- }
- return m_ast_importer_sp;
- }
- return ClangASTImporterSP();
-}
-
void Target::SettingsInitialize() { Process::SettingsInitialize(); }
void Target::SettingsTerminate() { Process::SettingsTerminate(); }
@@ -2368,11 +2359,9 @@ ExpressionResults Target::EvaluateExpression(
} else {
llvm::StringRef prefix = GetExpressionPrefixContents();
Status error;
- execution_results =
- UserExpression::Evaluate(exe_ctx, options, expr, prefix,
- result_valobj_sp, error, fixed_expression,
- nullptr, // Module
- ctx_obj);
+ execution_results = UserExpression::Evaluate(exe_ctx, options, expr, prefix,
+ result_valobj_sp, error,
+ fixed_expression, ctx_obj);
}
return execution_results;
@@ -2469,7 +2458,7 @@ lldb::addr_t Target::GetBreakableLoadAddress(lldb::addr_t addr) {
SourceManager &Target::GetSourceManager() {
if (!m_source_manager_up)
- m_source_manager_up.reset(new SourceManager(shared_from_this()));
+ m_source_manager_up = std::make_unique<SourceManager>(shared_from_this());
return *m_source_manager_up;
}
@@ -2567,7 +2556,7 @@ void Target::RunStopHooks() {
if (!any_active_hooks)
return;
- CommandReturnObject result;
+ CommandReturnObject result(m_debugger.GetUseColor());
std::vector<ExecutionContext> exc_ctx_with_reasons;
std::vector<SymbolContext> sym_ctx_with_reasons;
@@ -2691,8 +2680,10 @@ Status Target::Install(ProcessLaunchInfo *launch_info) {
if (platform_sp) {
if (platform_sp->IsRemote()) {
if (platform_sp->IsConnected()) {
- // Install all files that have an install path, and always install the
- // main executable when connected to a remote platform
+ // Install all files that have an install path when connected to a
+ // remote platform. If target.auto-install-main-executable is set then
+ // also install the main executable even if it does not have an explicit
+ // install path specified.
const ModuleList &modules = GetImages();
const size_t num_images = modules.GetSize();
for (size_t idx = 0; idx < num_images; ++idx) {
@@ -2703,10 +2694,8 @@ Status Target::Install(ProcessLaunchInfo *launch_info) {
if (local_file) {
FileSpec remote_file(module_sp->GetRemoteInstallFileSpec());
if (!remote_file) {
- if (is_main_executable) // TODO: add setting for always
- // installing main executable???
- {
- // Always install the main executable
+ if (is_main_executable && GetAutoInstallMainExecutable()) {
+ // Automatically install the main executable.
remote_file = platform_sp->GetRemoteWorkingDirectory();
remote_file.AppendPathComponent(
module_sp->GetFileSpec().GetFilename().GetCString());
@@ -2971,11 +2960,6 @@ Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) {
}
}
m_process_sp->RestoreProcessEvents();
- } else {
- Status error2;
- error2.SetErrorStringWithFormat("process launch failed: %s",
- error.AsCString());
- error = error2;
}
return error;
}
@@ -3153,7 +3137,7 @@ Target::StopHook::StopHook(const StopHook &rhs)
m_thread_spec_up(), m_active(rhs.m_active),
m_auto_continue(rhs.m_auto_continue) {
if (rhs.m_thread_spec_up)
- m_thread_spec_up.reset(new ThreadSpec(*rhs.m_thread_spec_up));
+ m_thread_spec_up = std::make_unique<ThreadSpec>(*rhs.m_thread_spec_up);
}
Target::StopHook::~StopHook() = default;
@@ -3360,16 +3344,13 @@ enum {
class TargetOptionValueProperties : public OptionValueProperties {
public:
- TargetOptionValueProperties(ConstString name)
- : OptionValueProperties(name), m_target(nullptr), m_got_host_env(false) {}
+ TargetOptionValueProperties(ConstString name) : OptionValueProperties(name) {}
// This constructor is used when creating TargetOptionValueProperties when it
// is part of a new lldb_private::Target instance. It will copy all current
// global property values as needed
- TargetOptionValueProperties(Target *target,
- const TargetPropertiesSP &target_properties_sp)
- : OptionValueProperties(*target_properties_sp->GetValueProperties()),
- m_target(target), m_got_host_env(false) {}
+ TargetOptionValueProperties(const TargetPropertiesSP &target_properties_sp)
+ : OptionValueProperties(*target_properties_sp->GetValueProperties()) {}
const Property *GetPropertyAtIndex(const ExecutionContext *exe_ctx,
bool will_modify,
@@ -3377,9 +3358,6 @@ public:
// 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 use the one from this instance.
- if (idx == ePropertyEnvVars)
- GetHostEnvironmentIfNeeded();
-
if (exe_ctx) {
Target *target = exe_ctx->GetTargetPtr();
if (target) {
@@ -3392,49 +3370,14 @@ public:
}
return ProtectedGetPropertyAtIndex(idx);
}
-
- lldb::TargetSP GetTargetSP() { return m_target->shared_from_this(); }
-
-protected:
- void GetHostEnvironmentIfNeeded() const {
- if (!m_got_host_env) {
- if (m_target) {
- m_got_host_env = true;
- const uint32_t idx = ePropertyInheritEnv;
- if (GetPropertyAtIndexAsBoolean(
- nullptr, idx, g_target_properties[idx].default_uint_value != 0)) {
- PlatformSP platform_sp(m_target->GetPlatform());
- if (platform_sp) {
- Environment env = platform_sp->GetEnvironment();
- OptionValueDictionary *env_dict =
- GetPropertyAtIndexAsOptionValueDictionary(nullptr,
- ePropertyEnvVars);
- if (env_dict) {
- const bool can_replace = false;
- for (const auto &KV : env) {
- // Don't allow existing keys to be replaced with ones we get
- // from the platform environment
- env_dict->SetValueForKey(
- ConstString(KV.first()),
- OptionValueSP(new OptionValueString(KV.second.c_str())),
- can_replace);
- }
- }
- }
- }
- }
- }
- }
- Target *m_target;
- mutable bool m_got_host_env;
};
// TargetProperties
-#define LLDB_PROPERTIES_experimental
+#define LLDB_PROPERTIES_target_experimental
#include "TargetProperties.inc"
enum {
-#define LLDB_PROPERTIES_experimental
+#define LLDB_PROPERTIES_target_experimental
#include "TargetPropertiesEnum.inc"
};
@@ -3448,15 +3391,15 @@ public:
TargetExperimentalProperties::TargetExperimentalProperties()
: Properties(OptionValuePropertiesSP(
new TargetExperimentalOptionValueProperties())) {
- m_collection_sp->Initialize(g_experimental_properties);
+ m_collection_sp->Initialize(g_target_experimental_properties);
}
// TargetProperties
TargetProperties::TargetProperties(Target *target)
- : Properties(), m_launch_info() {
+ : Properties(), m_launch_info(), m_target(target) {
if (target) {
m_collection_sp = std::make_shared<TargetOptionValueProperties>(
- target, Target::GetGlobalProperties());
+ Target::GetGlobalProperties());
// Set callbacks to update launch_info whenever "settins set" updated any
// of these properties
@@ -3467,6 +3410,10 @@ TargetProperties::TargetProperties(Target *target)
m_collection_sp->SetValueChangedCallback(
ePropertyEnvVars, [this] { EnvVarsValueChangedCallback(); });
m_collection_sp->SetValueChangedCallback(
+ ePropertyUnsetEnvVars, [this] { EnvVarsValueChangedCallback(); });
+ m_collection_sp->SetValueChangedCallback(
+ ePropertyInheritEnv, [this] { EnvVarsValueChangedCallback(); });
+ m_collection_sp->SetValueChangedCallback(
ePropertyInputPath, [this] { InputPathValueChangedCallback(); });
m_collection_sp->SetValueChangedCallback(
ePropertyOutputPath, [this] { OutputPathValueChangedCallback(); });
@@ -3480,29 +3427,19 @@ TargetProperties::TargetProperties(Target *target)
m_collection_sp->SetValueChangedCallback(
ePropertyDisableSTDIO, [this] { DisableSTDIOValueChangedCallback(); });
- m_experimental_properties_up.reset(new TargetExperimentalProperties());
+ m_experimental_properties_up =
+ std::make_unique<TargetExperimentalProperties>();
m_collection_sp->AppendProperty(
ConstString(Properties::GetExperimentalSettingsName()),
ConstString("Experimental settings - setting these won't produce "
"errors if the setting is not present."),
true, m_experimental_properties_up->GetValueProperties());
-
- // Update m_launch_info once it was created
- Arg0ValueChangedCallback();
- RunArgsValueChangedCallback();
- // EnvVarsValueChangedCallback(); // FIXME: cause segfault in
- // Target::GetPlatform()
- InputPathValueChangedCallback();
- OutputPathValueChangedCallback();
- ErrorPathValueChangedCallback();
- DetachOnErrorValueChangedCallback();
- DisableASLRValueChangedCallback();
- DisableSTDIOValueChangedCallback();
} else {
m_collection_sp =
std::make_shared<TargetOptionValueProperties>(ConstString("target"));
m_collection_sp->Initialize(g_target_properties);
- m_experimental_properties_up.reset(new TargetExperimentalProperties());
+ m_experimental_properties_up =
+ std::make_unique<TargetExperimentalProperties>();
m_collection_sp->AppendProperty(
ConstString(Properties::GetExperimentalSettingsName()),
ConstString("Experimental settings - setting these won't produce "
@@ -3516,6 +3453,18 @@ TargetProperties::TargetProperties(Target *target)
TargetProperties::~TargetProperties() = default;
+void TargetProperties::UpdateLaunchInfoFromProperties() {
+ Arg0ValueChangedCallback();
+ RunArgsValueChangedCallback();
+ EnvVarsValueChangedCallback();
+ InputPathValueChangedCallback();
+ OutputPathValueChangedCallback();
+ ErrorPathValueChangedCallback();
+ DetachOnErrorValueChangedCallback();
+ DisableASLRValueChangedCallback();
+ DisableSTDIOValueChangedCallback();
+}
+
bool TargetProperties::GetInjectLocalVariables(
ExecutionContext *exe_ctx) const {
const Property *exp_property = m_collection_sp->GetPropertyAtIndex(
@@ -3657,19 +3606,43 @@ void TargetProperties::SetRunArguments(const Args &args) {
m_launch_info.GetArguments() = args;
}
+Environment TargetProperties::ComputeEnvironment() const {
+ Environment env;
+
+ if (m_target &&
+ m_collection_sp->GetPropertyAtIndexAsBoolean(
+ nullptr, ePropertyInheritEnv,
+ g_target_properties[ePropertyInheritEnv].default_uint_value != 0)) {
+ if (auto platform_sp = m_target->GetPlatform()) {
+ Environment platform_env = platform_sp->GetEnvironment();
+ for (const auto &KV : platform_env)
+ env[KV.first()] = KV.second;
+ }
+ }
+
+ Args property_unset_env;
+ m_collection_sp->GetPropertyAtIndexAsArgs(nullptr, ePropertyUnsetEnvVars,
+ property_unset_env);
+ for (const auto &var : property_unset_env)
+ env.erase(var.ref());
+
+ Args property_env;
+ m_collection_sp->GetPropertyAtIndexAsArgs(nullptr, ePropertyEnvVars,
+ property_env);
+ for (const auto &KV : Environment(property_env))
+ env[KV.first()] = KV.second;
+
+ return env;
+}
+
Environment TargetProperties::GetEnvironment() const {
- // TODO: Get rid of the Args intermediate step
- Args env;
- const uint32_t idx = ePropertyEnvVars;
- m_collection_sp->GetPropertyAtIndexAsArgs(nullptr, idx, env);
- return Environment(env);
+ return ComputeEnvironment();
}
void TargetProperties::SetEnvironment(Environment env) {
// TODO: Get rid of the Args intermediate step
const uint32_t idx = ePropertyEnvVars;
m_collection_sp->SetPropertyAtIndexFromArgs(nullptr, idx, Args(env));
- m_launch_info.GetEnvironment() = std::move(env);
}
bool TargetProperties::GetSkipPrologue() const {
@@ -3741,6 +3714,12 @@ bool TargetProperties::GetEnableAutoApplyFixIts() const {
nullptr, idx, g_target_properties[idx].default_uint_value != 0);
}
+uint64_t TargetProperties::GetNumberOfRetriesWithFixits() const {
+ const uint32_t idx = ePropertyRetriesWithFixIts;
+ return m_collection_sp->GetPropertyAtIndexAsUInt64(
+ nullptr, idx, g_target_properties[idx].default_uint_value);
+}
+
bool TargetProperties::GetEnableNotifyAboutFixIts() const {
const uint32_t idx = ePropertyNotifyAboutFixIts;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
@@ -3970,6 +3949,12 @@ void TargetProperties::SetRequireHardwareBreakpoints(bool b) {
m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
}
+bool TargetProperties::GetAutoInstallMainExecutable() const {
+ const uint32_t idx = ePropertyAutoInstallMainExecutable;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(
+ nullptr, idx, g_target_properties[idx].default_uint_value != 0);
+}
+
void TargetProperties::Arg0ValueChangedCallback() {
m_launch_info.SetArg0(GetArg0());
}
@@ -3981,7 +3966,7 @@ void TargetProperties::RunArgsValueChangedCallback() {
}
void TargetProperties::EnvVarsValueChangedCallback() {
- m_launch_info.GetEnvironment() = GetEnvironment();
+ m_launch_info.GetEnvironment() = ComputeEnvironment();
}
void TargetProperties::InputPathValueChangedCallback() {
@@ -4073,7 +4058,7 @@ Target::TargetEventData::GetModuleListFromEvent(const Event *event_ptr) {
return module_list;
}
-std::recursive_mutex &Target::GetAPIMutex() {
+std::recursive_mutex &Target::GetAPIMutex() {
if (GetProcessSP() && GetProcessSP()->CurrentThreadIsPrivateStateThread())
return m_private_mutex;
else
diff --git a/lldb/source/Target/TargetList.cpp b/lldb/source/Target/TargetList.cpp
index 1b4db0c2aba5..3974cb5de419 100644
--- a/lldb/source/Target/TargetList.cpp
+++ b/lldb/source/Target/TargetList.cpp
@@ -1,4 +1,4 @@
-//===-- TargetList.cpp ------------------------------------------*- C++ -*-===//
+//===-- TargetList.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -398,6 +398,8 @@ Status TargetList::CreateTargetInternal(Debugger &debugger,
if (user_exe_path_is_bundle)
exe_module_sp->GetFileSpec().GetPath(resolved_bundle_exe_path,
sizeof(resolved_bundle_exe_path));
+ if (target_sp->GetPreloadSymbols())
+ exe_module_sp->PreloadSymbols();
}
} else {
// No file was specified, just create an empty target with any arch if a
diff --git a/lldb/source/Target/TargetProperties.td b/lldb/source/Target/TargetProperties.td
index ff8062aaa2cb..ae3abe354856 100644
--- a/lldb/source/Target/TargetProperties.td
+++ b/lldb/source/Target/TargetProperties.td
@@ -1,6 +1,6 @@
include "../../include/lldb/Core/PropertiesBase.td"
-let Definition = "experimental" in {
+let Definition = "target_experimental" in {
def InjectLocalVars : Property<"inject-local-vars", "Boolean">,
Global, DefaultTrue,
Desc<"If true, inject local variables explicitly into the expression text. This will fix symbol resolution when there are name collisions between ivars and local variables. But it can make expressions run much more slowly.">;
@@ -51,6 +51,9 @@ let Definition = "target" in {
def AutoApplyFixIts: Property<"auto-apply-fixits", "Boolean">,
DefaultTrue,
Desc<"Automatically apply fix-it hints to expressions.">;
+ def RetriesWithFixIts: Property<"retries-with-fixits", "UInt64">,
+ DefaultUnsignedValue<1>,
+ Desc<"Maximum number of attempts to fix an expression with Fix-Its">;
def NotifyAboutFixIts: Property<"notify-about-fixits", "Boolean">,
DefaultTrue,
Desc<"Print the fixed expression text.">;
@@ -79,8 +82,11 @@ let Definition = "target" in {
DefaultStringValue<"">,
Desc<"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.">;
def EnvVars: Property<"env-vars", "Dictionary">,
- DefaultUnsignedValue<16>,
- Desc<"A list of all the environment variables to be passed to the executable's environment, and their values.">;
+ ElementType<"String">,
+ Desc<"A list of user provided environment variables to be passed to the executable's environment, and their values.">;
+ def UnsetEnvVars: Property<"unset-env-vars", "Array">,
+ ElementType<"String">,
+ Desc<"A list of environment variable names to be unset in the inferior's environment. This is most useful to unset some host environment variables when target.inherit-env is true. target.env-vars takes precedence over target.unset-env-vars.">;
def InheritEnv: Property<"inherit-env", "Boolean">,
DefaultTrue,
Desc<"Inherit the environment from the process that is running LLDB.">;
@@ -140,7 +146,7 @@ let Definition = "target" in {
Desc<"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.">;
def TrapHandlerNames: Property<"trap-handler-names", "Array">,
Global,
- DefaultUnsignedValue<16>,
+ ElementType<"String">,
Desc<"A list of trap handler function names, e.g. a common Unix user process one is _sigtramp.">;
def DisplayRuntimeSupportValues: Property<"display-runtime-support-values", "Boolean">,
DefaultFalse,
@@ -154,6 +160,16 @@ let Definition = "target" in {
def RequireHardwareBreakpoints: Property<"require-hardware-breakpoint", "Boolean">,
DefaultFalse,
Desc<"Require all breakpoints to be hardware breakpoints.">;
+ def AutoInstallMainExecutable: Property<"auto-install-main-executable", "Boolean">,
+ DefaultTrue,
+ Desc<"Always install the main executable when connected to a remote platform.">;
+}
+
+let Definition = "process_experimental" in {
+ def OSPluginReportsAllThreads: Property<"os-plugin-reports-all-threads", "Boolean">,
+ Global,
+ DefaultTrue,
+ Desc<"Set to False if your OS Plugins doesn't report all threads on each stop.">;
}
let Definition = "process" in {
@@ -161,7 +177,7 @@ let Definition = "process" in {
DefaultFalse,
Desc<"Disable reading and caching of memory in fixed-size units.">;
def ExtraStartCommand: Property<"extra-startup-command", "Array">,
- DefaultUnsignedValue<16>,
+ ElementType<"String">,
Desc<"A list containing extra commands understood by the particular process plugin used. For instance, to turn on debugserver logging set this to 'QSetLogging:bitmask=LOG_DEFAULT;'">;
def IgnoreBreakpointsInExpressions: Property<"ignore-breakpoints-in-expressions", "Boolean">,
Global,
@@ -188,6 +204,9 @@ let Definition = "process" in {
def WarningOptimization: Property<"optimization-warnings", "Boolean">,
DefaultTrue,
Desc<"If true, warn when stopped in code that is optimized where stepping and variable availability may not behave as expected.">;
+ def WarningUnsupportedLanguage: Property<"unsupported-language-warnings", "Boolean">,
+ DefaultTrue,
+ Desc<"If true, warn when stopped in code that is written in a source language that LLDB does not support.">;
def StopOnExec: Property<"stop-on-exec", "Boolean">,
Global,
DefaultTrue,
diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp
index e12b90501103..24cf4bf3ee1e 100644
--- a/lldb/source/Target/Thread.cpp
+++ b/lldb/source/Target/Thread.cpp
@@ -1,4 +1,4 @@
-//===-- Thread.cpp ----------------------------------------------*- C++ -*-===//
+//===-- Thread.cpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,8 +7,6 @@
//===----------------------------------------------------------------------===//
#include "lldb/Target/Thread.h"
-#include "Plugins/Process/Utility/UnwindLLDB.h"
-#include "Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/FormatEntity.h"
@@ -35,6 +33,7 @@
#include "lldb/Target/ThreadPlanCallFunction.h"
#include "lldb/Target/ThreadPlanPython.h"
#include "lldb/Target/ThreadPlanRunToAddress.h"
+#include "lldb/Target/ThreadPlanStack.h"
#include "lldb/Target/ThreadPlanStepInRange.h"
#include "lldb/Target/ThreadPlanStepInstruction.h"
#include "lldb/Target/ThreadPlanStepOut.h"
@@ -43,7 +42,7 @@
#include "lldb/Target/ThreadPlanStepThrough.h"
#include "lldb/Target/ThreadPlanStepUntil.h"
#include "lldb/Target/ThreadSpec.h"
-#include "lldb/Target/Unwind.h"
+#include "lldb/Target/UnwindLLDB.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/State.h"
@@ -230,8 +229,7 @@ Thread::Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id)
m_index_id(use_invalid_index_id ? LLDB_INVALID_INDEX32
: process.GetNextThreadIndexID(tid)),
m_reg_context_sp(), m_state(eStateUnloaded), m_state_mutex(),
- m_plan_stack(), m_completed_plan_stack(), m_frame_mutex(),
- m_curr_frames_sp(), m_prev_frames_sp(),
+ m_frame_mutex(), m_curr_frames_sp(), m_prev_frames_sp(),
m_resume_signal(LLDB_INVALID_SIGNAL_NUMBER),
m_resume_state(eStateRunning), m_temporary_resume_state(eStateRunning),
m_unwinder_up(), m_destroy_called(false),
@@ -242,8 +240,6 @@ Thread::Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id)
static_cast<void *>(this), GetID());
CheckInWithManager();
-
- QueueFundamentalPlan(true);
}
Thread::~Thread() {
@@ -256,30 +252,7 @@ Thread::~Thread() {
}
void Thread::DestroyThread() {
- // Tell any plans on the plan stacks that the thread is being destroyed since
- // any plans that have a thread go away in the middle of might need to do
- // cleanup, or in some cases NOT do cleanup...
- for (auto plan : m_plan_stack)
- plan->ThreadDestroyed();
-
- for (auto plan : m_discarded_plan_stack)
- plan->ThreadDestroyed();
-
- for (auto plan : m_completed_plan_stack)
- plan->ThreadDestroyed();
-
m_destroy_called = true;
- m_plan_stack.clear();
- m_discarded_plan_stack.clear();
- m_completed_plan_stack.clear();
-
- // Push a ThreadPlanNull on the plan stack. That way we can continue
- // assuming that the plan stack is never empty, but if somebody errantly asks
- // questions of a destroyed thread without checking first whether it is
- // destroyed, they won't crash.
- ThreadPlanSP null_plan_sp(new ThreadPlanNull(*this));
- m_plan_stack.push_back(null_plan_sp);
-
m_stop_info_sp.reset();
m_reg_context_sp.reset();
m_unwinder_up.reset();
@@ -298,7 +271,7 @@ 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());
+ FrameSelectedCallback(frame_sp.get());
return frame_sp;
}
@@ -307,7 +280,7 @@ uint32_t Thread::SetSelectedFrame(lldb_private::StackFrame *frame,
uint32_t ret_value = GetStackFrameList()->SetSelectedFrame(frame);
if (broadcast)
BroadcastSelectedFrameChange(frame->GetStackID());
- FunctionOptimizationWarning(frame);
+ FrameSelectedCallback(frame);
return ret_value;
}
@@ -317,7 +290,7 @@ bool Thread::SetSelectedFrameByIndex(uint32_t frame_idx, bool broadcast) {
GetStackFrameList()->SetSelectedFrame(frame_sp.get());
if (broadcast)
BroadcastSelectedFrameChange(frame_sp->GetStackID());
- FunctionOptimizationWarning(frame_sp.get());
+ FrameSelectedCallback(frame_sp.get());
return true;
} else
return false;
@@ -341,7 +314,7 @@ bool Thread::SetSelectedFrameByIndexNoisily(uint32_t frame_idx,
bool show_frame_info = true;
bool show_source = !already_shown;
- FunctionOptimizationWarning(frame_sp.get());
+ FrameSelectedCallback(frame_sp.get());
return frame_sp->GetStatus(output_stream, show_frame_info, show_source);
}
return false;
@@ -349,12 +322,17 @@ bool Thread::SetSelectedFrameByIndexNoisily(uint32_t frame_idx,
return false;
}
-void Thread::FunctionOptimizationWarning(StackFrame *frame) {
- if (frame && frame->HasDebugInformation() &&
- GetProcess()->GetWarningsOptimization()) {
+void Thread::FrameSelectedCallback(StackFrame *frame) {
+ if (!frame)
+ return;
+
+ if (frame->HasDebugInformation() &&
+ (GetProcess()->GetWarningsOptimization() ||
+ GetProcess()->GetWarningsUnsupportedLanguage())) {
SymbolContext sc =
frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextModule);
GetProcess()->PrintWarningOptimization(sc);
+ GetProcess()->PrintWarningUnsupportedLanguage(sc);
}
}
@@ -423,7 +401,7 @@ lldb::StopInfoSP Thread::GetPrivateStopInfo() {
// "m_stop_info_stop_id != process_stop_id" as the condition for the if
// statement below, we must also check the stop info to see if we need to
// override it. See the header documentation in
- // Process::GetStopInfoOverrideCallback() for more information on the stop
+ // Architecture::OverrideStopInfo() for more information on the stop
// info override callback.
if (m_stop_info_override_stop_id != process_stop_id) {
m_stop_info_override_stop_id = process_stop_id;
@@ -524,7 +502,8 @@ bool Thread::CheckpointThreadState(ThreadStateCheckpoint &saved_state) {
if (process_sp)
saved_state.orig_stop_id = process_sp->GetStopID();
saved_state.current_inlined_depth = GetCurrentInlinedDepth();
- saved_state.m_completed_plan_stack = m_completed_plan_stack;
+ saved_state.m_completed_plan_checkpoint =
+ GetPlans().CheckpointCompletedPlans();
return true;
}
@@ -558,7 +537,8 @@ bool Thread::RestoreThreadStateFromCheckpoint(
SetStopInfo(saved_state.stop_info_sp);
GetStackFrameList()->SetCurrentInlinedDepth(
saved_state.current_inlined_depth);
- m_completed_plan_stack = saved_state.m_completed_plan_stack;
+ GetPlans().RestoreCompletedPlanCheckpoint(
+ saved_state.m_completed_plan_checkpoint);
return true;
}
@@ -573,9 +553,68 @@ void Thread::SetState(StateType state) {
m_state = state;
}
+std::string Thread::GetStopDescription() {
+ StackFrameSP frame_sp = GetStackFrameAtIndex(0);
+
+ if (!frame_sp)
+ return GetStopDescriptionRaw();
+
+ auto recognized_frame_sp = frame_sp->GetRecognizedFrame();
+
+ if (!recognized_frame_sp)
+ return GetStopDescriptionRaw();
+
+ std::string recognized_stop_description =
+ recognized_frame_sp->GetStopDescription();
+
+ if (!recognized_stop_description.empty())
+ return recognized_stop_description;
+
+ return GetStopDescriptionRaw();
+}
+
+std::string Thread::GetStopDescriptionRaw() {
+ StopInfoSP stop_info_sp = GetStopInfo();
+ std::string raw_stop_description;
+ if (stop_info_sp && stop_info_sp->IsValid()) {
+ raw_stop_description = stop_info_sp->GetDescription();
+ assert((!raw_stop_description.empty() ||
+ stop_info_sp->GetStopReason() == eStopReasonNone) &&
+ "StopInfo returned an empty description.");
+ }
+ return raw_stop_description;
+}
+
+void Thread::SelectMostRelevantFrame() {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD);
+
+ auto frames_list_sp = GetStackFrameList();
+
+ // Only the top frame should be recognized.
+ auto frame_sp = frames_list_sp->GetFrameAtIndex(0);
+
+ auto recognized_frame_sp = frame_sp->GetRecognizedFrame();
+
+ if (!recognized_frame_sp) {
+ LLDB_LOG(log, "Frame #0 not recognized");
+ return;
+ }
+
+ if (StackFrameSP most_relevant_frame_sp =
+ recognized_frame_sp->GetMostRelevantFrame()) {
+ LLDB_LOG(log, "Found most relevant frame at index {0}",
+ most_relevant_frame_sp->GetFrameIndex());
+ SetSelectedFrame(most_relevant_frame_sp.get());
+ } else {
+ LLDB_LOG(log, "No relevant frame!");
+ }
+}
+
void Thread::WillStop() {
ThreadPlan *current_plan = GetCurrentPlan();
+ SelectMostRelevantFrame();
+
// FIXME: I may decide to disallow threads with no plans. In which
// case this should go to an assert.
@@ -632,8 +671,7 @@ void Thread::SetupForResume() {
bool Thread::ShouldResume(StateType resume_state) {
// At this point clear the completed plan stack.
- m_completed_plan_stack.clear();
- m_discarded_plan_stack.clear();
+ GetPlans().WillResume();
m_override_should_notify = eLazyBoolCalculate;
StateType prev_resume_state = GetTemporaryResumeState();
@@ -744,7 +782,9 @@ bool Thread::ShouldStop(Event *event_ptr) {
LLDB_LOGF(log, "^^^^^^^^ Thread::ShouldStop Begin ^^^^^^^^");
StreamString s;
s.IndentMore();
- DumpThreadPlans(&s);
+ GetProcess()->DumpThreadPlansForTID(
+ s, GetID(), eDescriptionLevelVerbose, true /* internal */,
+ false /* condense_trivial */, true /* skip_unreported */);
LLDB_LOGF(log, "Plan stack initial state:\n%s", s.GetData());
}
@@ -827,7 +867,7 @@ bool Thread::ShouldStop(Event *event_ptr) {
current_plan->GetName(), over_ride_stop);
// We're starting from the base plan, so just let it decide;
- if (PlanIsBasePlan(current_plan)) {
+ if (current_plan->IsBasePlan()) {
should_stop = current_plan->ShouldStop(event_ptr);
LLDB_LOGF(log, "Base plan says should stop: %i.", should_stop);
} else {
@@ -835,7 +875,7 @@ bool Thread::ShouldStop(Event *event_ptr) {
// to do, since presumably if there were other plans they would know what
// to do...
while (true) {
- if (PlanIsBasePlan(current_plan))
+ if (current_plan->IsBasePlan())
break;
should_stop = current_plan->ShouldStop(event_ptr);
@@ -881,7 +921,7 @@ bool Thread::ShouldStop(Event *event_ptr) {
// Discard the stale plans and all plans below them in the stack, plus move
// the completed plans to the completed plan stack
- while (!PlanIsBasePlan(plan_ptr)) {
+ while (!plan_ptr->IsBasePlan()) {
bool stale = plan_ptr->IsPlanStale();
ThreadPlan *examined_plan = plan_ptr;
plan_ptr = GetPreviousPlan(examined_plan);
@@ -908,7 +948,9 @@ bool Thread::ShouldStop(Event *event_ptr) {
if (log) {
StreamString s;
s.IndentMore();
- DumpThreadPlans(&s);
+ GetProcess()->DumpThreadPlansForTID(
+ s, GetID(), eDescriptionLevelVerbose, true /* internal */,
+ false /* condense_trivial */, true /* skip_unreported */);
LLDB_LOGF(log, "Plan stack final state:\n%s", s.GetData());
LLDB_LOGF(log, "vvvvvvvv Thread::ShouldStop End (returning %i) vvvvvvvv",
should_stop);
@@ -947,13 +989,14 @@ Vote Thread::ShouldReportStop(Event *event_ptr) {
return eVoteNoOpinion;
}
- if (m_completed_plan_stack.size() > 0) {
- // Don't use GetCompletedPlan here, since that suppresses private plans.
+ if (GetPlans().AnyCompletedPlans()) {
+ // Pass skip_private = false to GetCompletedPlan, since we want to ask
+ // the last plan, regardless of whether it is private or not.
LLDB_LOGF(log,
"Thread::ShouldReportStop() tid = 0x%4.4" PRIx64
": returning vote for complete stack's back plan",
GetID());
- return m_completed_plan_stack.back()->ShouldReportStop(event_ptr);
+ return GetPlans().GetCompletedPlan(false)->ShouldReportStop(event_ptr);
} else {
Vote thread_vote = eVoteNoOpinion;
ThreadPlan *plan_ptr = GetCurrentPlan();
@@ -962,7 +1005,7 @@ Vote Thread::ShouldReportStop(Event *event_ptr) {
thread_vote = plan_ptr->ShouldReportStop(event_ptr);
break;
}
- if (PlanIsBasePlan(plan_ptr))
+ if (plan_ptr->IsBasePlan())
break;
else
plan_ptr = GetPreviousPlan(plan_ptr);
@@ -984,16 +1027,17 @@ Vote Thread::ShouldReportRun(Event *event_ptr) {
}
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
- if (m_completed_plan_stack.size() > 0) {
- // Don't use GetCompletedPlan here, since that suppresses private plans.
+ if (GetPlans().AnyCompletedPlans()) {
+ // Pass skip_private = false to GetCompletedPlan, since we want to ask
+ // the last plan, regardless of whether it is private or not.
LLDB_LOGF(log,
"Current Plan for thread %d(%p) (0x%4.4" PRIx64
", %s): %s being asked whether we should report run.",
GetIndexID(), static_cast<void *>(this), GetID(),
StateAsCString(GetTemporaryResumeState()),
- m_completed_plan_stack.back()->GetName());
+ GetCompletedPlan()->GetName());
- return m_completed_plan_stack.back()->ShouldReportRun(event_ptr);
+ return GetPlans().GetCompletedPlan(false)->ShouldReportRun(event_ptr);
} else {
LLDB_LOGF(log,
"Current Plan for thread %d(%p) (0x%4.4" PRIx64
@@ -1010,148 +1054,85 @@ bool Thread::MatchesSpec(const ThreadSpec *spec) {
return (spec == nullptr) ? true : spec->ThreadPassesBasicTests(*this);
}
-void Thread::PushPlan(ThreadPlanSP &thread_plan_sp) {
- if (thread_plan_sp) {
- // If the thread plan doesn't already have a tracer, give it its parent's
- // tracer:
- if (!thread_plan_sp->GetThreadPlanTracer()) {
- assert(!m_plan_stack.empty());
- thread_plan_sp->SetThreadPlanTracer(
- m_plan_stack.back()->GetThreadPlanTracer());
- }
- m_plan_stack.push_back(thread_plan_sp);
+ThreadPlanStack &Thread::GetPlans() const {
+ ThreadPlanStack *plans = GetProcess()->FindThreadPlans(GetID());
+ if (plans)
+ return *plans;
- thread_plan_sp->DidPush();
+ // History threads don't have a thread plan, but they do ask get asked to
+ // describe themselves, which usually involves pulling out the stop reason.
+ // That in turn will check for a completed plan on the ThreadPlanStack.
+ // Instead of special-casing at that point, we return a Stack with a
+ // ThreadPlanNull as its base plan. That will give the right answers to the
+ // queries GetDescription makes, and only assert if you try to run the thread.
+ if (!m_null_plan_stack_up)
+ m_null_plan_stack_up = std::make_unique<ThreadPlanStack>(*this, true);
+ return *(m_null_plan_stack_up.get());
+}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
- if (log) {
- StreamString s;
- thread_plan_sp->GetDescription(&s, lldb::eDescriptionLevelFull);
- LLDB_LOGF(log, "Thread::PushPlan(0x%p): \"%s\", tid = 0x%4.4" PRIx64 ".",
- static_cast<void *>(this), s.GetData(),
- thread_plan_sp->GetThread().GetID());
- }
+void Thread::PushPlan(ThreadPlanSP thread_plan_sp) {
+ assert(thread_plan_sp && "Don't push an empty thread plan.");
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+ if (log) {
+ StreamString s;
+ thread_plan_sp->GetDescription(&s, lldb::eDescriptionLevelFull);
+ LLDB_LOGF(log, "Thread::PushPlan(0x%p): \"%s\", tid = 0x%4.4" PRIx64 ".",
+ static_cast<void *>(this), s.GetData(),
+ thread_plan_sp->GetThread().GetID());
}
+
+ GetPlans().PushPlan(std::move(thread_plan_sp));
}
void Thread::PopPlan() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
-
- if (m_plan_stack.size() <= 1)
- return;
- else {
- ThreadPlanSP &plan = m_plan_stack.back();
- if (log) {
- LLDB_LOGF(log, "Popping plan: \"%s\", tid = 0x%4.4" PRIx64 ".",
- plan->GetName(), plan->GetThread().GetID());
- }
- m_completed_plan_stack.push_back(plan);
- plan->WillPop();
- m_plan_stack.pop_back();
+ ThreadPlanSP popped_plan_sp = GetPlans().PopPlan();
+ if (log) {
+ LLDB_LOGF(log, "Popping plan: \"%s\", tid = 0x%4.4" PRIx64 ".",
+ popped_plan_sp->GetName(), popped_plan_sp->GetThread().GetID());
}
}
void Thread::DiscardPlan() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
- if (m_plan_stack.size() > 1) {
- ThreadPlanSP &plan = m_plan_stack.back();
- LLDB_LOGF(log, "Discarding plan: \"%s\", tid = 0x%4.4" PRIx64 ".",
- plan->GetName(), plan->GetThread().GetID());
-
- m_discarded_plan_stack.push_back(plan);
- plan->WillPop();
- m_plan_stack.pop_back();
- }
-}
+ ThreadPlanSP discarded_plan_sp = GetPlans().PopPlan();
-ThreadPlan *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.
- return m_plan_stack.empty() ? nullptr : m_plan_stack.back().get();
+ LLDB_LOGF(log, "Discarding plan: \"%s\", tid = 0x%4.4" PRIx64 ".",
+ discarded_plan_sp->GetName(),
+ discarded_plan_sp->GetThread().GetID());
}
-ThreadPlanSP Thread::GetCompletedPlan() {
- ThreadPlanSP empty_plan_sp;
- if (!m_completed_plan_stack.empty()) {
- for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--) {
- ThreadPlanSP completed_plan_sp;
- completed_plan_sp = m_completed_plan_stack[i];
- if (!completed_plan_sp->GetPrivate())
- return completed_plan_sp;
- }
- }
- return empty_plan_sp;
+ThreadPlan *Thread::GetCurrentPlan() const {
+ return GetPlans().GetCurrentPlan().get();
}
-ValueObjectSP Thread::GetReturnValueObject() {
- if (!m_completed_plan_stack.empty()) {
- for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--) {
- ValueObjectSP return_valobj_sp;
- return_valobj_sp = m_completed_plan_stack[i]->GetReturnValueObject();
- if (return_valobj_sp)
- return return_valobj_sp;
- }
- }
- return ValueObjectSP();
+ThreadPlanSP Thread::GetCompletedPlan() const {
+ return GetPlans().GetCompletedPlan();
}
-ExpressionVariableSP Thread::GetExpressionVariable() {
- if (!m_completed_plan_stack.empty()) {
- for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--) {
- ExpressionVariableSP expression_variable_sp;
- expression_variable_sp =
- m_completed_plan_stack[i]->GetExpressionVariable();
- if (expression_variable_sp)
- return expression_variable_sp;
- }
- }
- return ExpressionVariableSP();
+ValueObjectSP Thread::GetReturnValueObject() const {
+ return GetPlans().GetReturnValueObject();
}
-bool Thread::IsThreadPlanDone(ThreadPlan *plan) {
- if (!m_completed_plan_stack.empty()) {
- for (int i = m_completed_plan_stack.size() - 1; i >= 0; i--) {
- if (m_completed_plan_stack[i].get() == plan)
- return true;
- }
- }
- return false;
+ExpressionVariableSP Thread::GetExpressionVariable() const {
+ return GetPlans().GetExpressionVariable();
}
-bool Thread::WasThreadPlanDiscarded(ThreadPlan *plan) {
- if (!m_discarded_plan_stack.empty()) {
- for (int i = m_discarded_plan_stack.size() - 1; i >= 0; i--) {
- if (m_discarded_plan_stack[i].get() == plan)
- return true;
- }
- }
- return false;
+bool Thread::IsThreadPlanDone(ThreadPlan *plan) const {
+ return GetPlans().IsPlanDone(plan);
}
-bool Thread::CompletedPlanOverridesBreakpoint() {
- return (!m_completed_plan_stack.empty()) ;
+bool Thread::WasThreadPlanDiscarded(ThreadPlan *plan) const {
+ return GetPlans().WasPlanDiscarded(plan);
}
-ThreadPlan *Thread::GetPreviousPlan(ThreadPlan *current_plan) {
- if (current_plan == nullptr)
- return nullptr;
-
- int stack_size = m_completed_plan_stack.size();
- for (int i = stack_size - 1; i > 0; i--) {
- if (current_plan == m_completed_plan_stack[i].get())
- return m_completed_plan_stack[i - 1].get();
- }
-
- if (stack_size > 0 && m_completed_plan_stack[0].get() == current_plan) {
- return GetCurrentPlan();
- }
+bool Thread::CompletedPlanOverridesBreakpoint() const {
+ return GetPlans().AnyCompletedPlans();
+}
- stack_size = m_plan_stack.size();
- for (int i = stack_size - 1; i > 0; i--) {
- if (current_plan == m_plan_stack[i].get())
- return m_plan_stack[i - 1].get();
- }
- return nullptr;
+ThreadPlan *Thread::GetPreviousPlan(ThreadPlan *current_plan) const{
+ return GetPlans().GetPreviousPlan(current_plan);
}
Status Thread::QueueThreadPlan(ThreadPlanSP &thread_plan_sp,
@@ -1185,38 +1166,18 @@ Status Thread::QueueThreadPlan(ThreadPlanSP &thread_plan_sp,
}
void Thread::EnableTracer(bool value, bool single_stepping) {
- int stack_size = m_plan_stack.size();
- for (int i = 0; i < stack_size; i++) {
- if (m_plan_stack[i]->GetThreadPlanTracer()) {
- m_plan_stack[i]->GetThreadPlanTracer()->EnableTracing(value);
- m_plan_stack[i]->GetThreadPlanTracer()->EnableSingleStep(single_stepping);
- }
- }
+ GetPlans().EnableTracer(value, single_stepping);
}
void Thread::SetTracer(lldb::ThreadPlanTracerSP &tracer_sp) {
- int stack_size = m_plan_stack.size();
- for (int i = 0; i < stack_size; i++)
- m_plan_stack[i]->SetThreadPlanTracer(tracer_sp);
+ GetPlans().SetTracer(tracer_sp);
}
-bool Thread::DiscardUserThreadPlansUpToIndex(uint32_t thread_index) {
+bool Thread::DiscardUserThreadPlansUpToIndex(uint32_t plan_index) {
// Count the user thread plans from the back end to get the number of the one
// we want to discard:
- uint32_t idx = 0;
- ThreadPlan *up_to_plan_ptr = nullptr;
-
- for (ThreadPlanSP plan_sp : m_plan_stack) {
- if (plan_sp->GetPrivate())
- continue;
- if (idx == thread_index) {
- up_to_plan_ptr = plan_sp.get();
- break;
- } else
- idx++;
- }
-
+ ThreadPlan *up_to_plan_ptr = GetPlans().GetPlanByIndex(plan_index).get();
if (up_to_plan_ptr == nullptr)
return false;
@@ -1234,30 +1195,7 @@ void Thread::DiscardThreadPlansUpToPlan(ThreadPlan *up_to_plan_ptr) {
"Discarding thread plans for thread tid = 0x%4.4" PRIx64
", up to %p",
GetID(), static_cast<void *>(up_to_plan_ptr));
-
- int stack_size = m_plan_stack.size();
-
- // 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 == nullptr) {
- for (int i = stack_size - 1; i > 0; i--)
- DiscardPlan();
- } else {
- bool found_it = false;
- for (int i = stack_size - 1; i > 0; i--) {
- if (m_plan_stack[i].get() == up_to_plan_ptr)
- found_it = true;
- }
- if (found_it) {
- bool last_one = false;
- for (int i = stack_size - 1; i > 0 && !last_one; i--) {
- if (GetCurrentPlan() == up_to_plan_ptr)
- last_one = true;
- DiscardPlan();
- }
- }
- }
+ GetPlans().DiscardPlansUpToPlan(up_to_plan_ptr);
}
void Thread::DiscardThreadPlans(bool force) {
@@ -1270,73 +1208,20 @@ void Thread::DiscardThreadPlans(bool force) {
}
if (force) {
- int stack_size = m_plan_stack.size();
- for (int i = stack_size - 1; i > 0; i--) {
- DiscardPlan();
- }
+ GetPlans().DiscardAllPlans();
return;
}
-
- while (true) {
- int master_plan_idx;
- bool discard = true;
-
- // Find the first master plan, see if it wants discarding, and if yes
- // discard up to it.
- for (master_plan_idx = m_plan_stack.size() - 1; master_plan_idx >= 0;
- master_plan_idx--) {
- if (m_plan_stack[master_plan_idx]->IsMasterPlan()) {
- discard = m_plan_stack[master_plan_idx]->OkayToDiscard();
- break;
- }
- }
-
- if (discard) {
- // 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?
- DiscardPlan();
- }
-
- // Now discard the master plan itself.
- // The bottom-most plan never gets discarded. "OkayToDiscard" for it
- // means discard it's dependent plans, but not it...
- if (master_plan_idx > 0) {
- DiscardPlan();
- }
- } else {
- // If the master plan doesn't want to get discarded, then we're done.
- break;
- }
- }
-}
-
-bool Thread::PlanIsBasePlan(ThreadPlan *plan_ptr) {
- if (plan_ptr->IsBasePlan())
- return true;
- else if (m_plan_stack.size() == 0)
- return false;
- else
- return m_plan_stack[0].get() == plan_ptr;
+ GetPlans().DiscardConsultingMasterPlans();
}
Status Thread::UnwindInnermostExpression() {
Status error;
- int stack_size = m_plan_stack.size();
-
- // 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--) {
- if (m_plan_stack[i]->GetKind() == ThreadPlan::eKindCallFunction) {
- DiscardThreadPlansUpToPlan(m_plan_stack[i].get());
- return error;
- }
- }
- error.SetErrorString("No expressions currently active on this thread");
+ ThreadPlan *innermost_expr_plan = GetPlans().GetInnermostExpression();
+ if (!innermost_expr_plan) {
+ error.SetErrorString("No expressions currently active on this thread");
+ return error;
+ }
+ DiscardThreadPlansUpToPlan(innermost_expr_plan);
return error;
}
@@ -1502,73 +1387,6 @@ lldb::ThreadPlanSP Thread::QueueThreadPlanForStepScripted(
uint32_t Thread::GetIndexID() const { return m_index_id; }
-static void PrintPlanElement(Stream *s, const ThreadPlanSP &plan,
- lldb::DescriptionLevel desc_level,
- int32_t elem_idx) {
- s->IndentMore();
- s->Indent();
- s->Printf("Element %d: ", elem_idx);
- plan->GetDescription(s, desc_level);
- s->EOL();
- s->IndentLess();
-}
-
-static void PrintPlanStack(Stream *s,
- const std::vector<lldb::ThreadPlanSP> &plan_stack,
- lldb::DescriptionLevel desc_level,
- bool include_internal) {
- int32_t print_idx = 0;
- for (ThreadPlanSP plan_sp : plan_stack) {
- if (include_internal || !plan_sp->GetPrivate()) {
- PrintPlanElement(s, plan_sp, desc_level, print_idx++);
- }
- }
-}
-
-void Thread::DumpThreadPlans(Stream *s, lldb::DescriptionLevel desc_level,
- bool include_internal,
- bool ignore_boring_threads) const {
- uint32_t stack_size;
-
- if (ignore_boring_threads) {
- uint32_t stack_size = m_plan_stack.size();
- uint32_t completed_stack_size = m_completed_plan_stack.size();
- uint32_t discarded_stack_size = m_discarded_plan_stack.size();
- if (stack_size == 1 && completed_stack_size == 0 &&
- discarded_stack_size == 0) {
- s->Printf("thread #%u: tid = 0x%4.4" PRIx64 "\n", GetIndexID(), GetID());
- s->IndentMore();
- s->Indent();
- s->Printf("No active thread plans\n");
- s->IndentLess();
- return;
- }
- }
-
- s->Indent();
- s->Printf("thread #%u: tid = 0x%4.4" PRIx64 ":\n", GetIndexID(), GetID());
- s->IndentMore();
- s->Indent();
- s->Printf("Active plan stack:\n");
- PrintPlanStack(s, m_plan_stack, desc_level, include_internal);
-
- stack_size = m_completed_plan_stack.size();
- if (stack_size > 0) {
- s->Indent();
- s->Printf("Completed Plan Stack:\n");
- PrintPlanStack(s, m_completed_plan_stack, desc_level, include_internal);
- }
-
- stack_size = m_discarded_plan_stack.size();
- if (stack_size > 0) {
- s->Indent();
- s->Printf("Discarded Plan Stack:\n");
- PrintPlanStack(s, m_discarded_plan_stack, desc_level, include_internal);
- }
-
- s->IndentLess();
-}
-
TargetSP Thread::CalculateTarget() {
TargetSP target_sp;
ProcessSP process_sp(GetProcess());
@@ -1600,9 +1418,7 @@ StackFrameListSP Thread::GetStackFrameList() {
void Thread::ClearStackFrames() {
std::lock_guard<std::recursive_mutex> guard(m_frame_mutex);
- Unwind *unwinder = GetUnwinder();
- if (unwinder)
- unwinder->Clear();
+ GetUnwinder().Clear();
// Only store away the old "reference" StackFrameList if we got all its
// frames:
@@ -1773,7 +1589,7 @@ Status Thread::JumpToLine(const FileSpec &file, uint32_t line,
"first location:\n",
file.GetFilename().AsCString(), line);
DumpAddressList(sstr, candidates, target);
- *warnings = sstr.GetString();
+ *warnings = std::string(sstr.GetString());
}
if (!reg_ctx->SetPC(dest))
@@ -2041,37 +1857,10 @@ size_t Thread::GetStackFrameStatus(Stream &strm, uint32_t first_frame,
strm, first_frame, num_frames, show_frame_info, num_frames_with_source);
}
-Unwind *Thread::GetUnwinder() {
- if (!m_unwinder_up) {
- const ArchSpec target_arch(CalculateTarget()->GetArchitecture());
- const llvm::Triple::ArchType machine = target_arch.GetMachine();
- switch (machine) {
- case llvm::Triple::x86_64:
- case llvm::Triple::x86:
- case llvm::Triple::arm:
- case llvm::Triple::aarch64:
- case llvm::Triple::aarch64_32:
- case llvm::Triple::thumb:
- case llvm::Triple::mips:
- case llvm::Triple::mipsel:
- case llvm::Triple::mips64:
- case llvm::Triple::mips64el:
- case llvm::Triple::ppc:
- case llvm::Triple::ppc64:
- case llvm::Triple::ppc64le:
- case llvm::Triple::systemz:
- case llvm::Triple::hexagon:
- case llvm::Triple::arc:
- m_unwinder_up.reset(new UnwindLLDB(*this));
- break;
-
- default:
- if (target_arch.GetTriple().getVendor() == llvm::Triple::Apple)
- m_unwinder_up.reset(new UnwindMacOSXFrameBackchain(*this));
- break;
- }
- }
- return m_unwinder_up.get();
+Unwind &Thread::GetUnwinder() {
+ if (!m_unwinder_up)
+ m_unwinder_up = std::make_unique<UnwindLLDB>(*this);
+ return *m_unwinder_up;
}
void Thread::Flush() {
diff --git a/lldb/source/Target/ThreadCollection.cpp b/lldb/source/Target/ThreadCollection.cpp
index cf3c1e242999..05b041c20dd0 100644
--- a/lldb/source/Target/ThreadCollection.cpp
+++ b/lldb/source/Target/ThreadCollection.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadCollection.cpp ------------------------------------*- C++ -*-===//
+//===-- ThreadCollection.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/ThreadList.cpp b/lldb/source/Target/ThreadList.cpp
index 183b39c2cfa9..032dcc9e5fbd 100644
--- a/lldb/source/Target/ThreadList.cpp
+++ b/lldb/source/Target/ThreadList.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadList.cpp ------------------------------------------*- C++ -*-===//
+//===-- ThreadList.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -715,6 +715,11 @@ void ThreadList::Update(ThreadList &rhs) {
// to work around the issue
collection::iterator rhs_pos, rhs_end = rhs.m_threads.end();
for (rhs_pos = rhs.m_threads.begin(); rhs_pos != rhs_end; ++rhs_pos) {
+ // If this thread has already been destroyed, we don't need to look for
+ // it to destroy it again.
+ if (!(*rhs_pos)->IsValid())
+ continue;
+
const lldb::tid_t tid = (*rhs_pos)->GetID();
bool thread_is_alive = false;
const uint32_t num_threads = m_threads.size();
@@ -726,8 +731,9 @@ void ThreadList::Update(ThreadList &rhs) {
break;
}
}
- if (!thread_is_alive)
+ if (!thread_is_alive) {
(*rhs_pos)->DestroyThread();
+ }
}
}
}
diff --git a/lldb/source/Target/ThreadPlan.cpp b/lldb/source/Target/ThreadPlan.cpp
index ba56f8d15d8a..d8e92b8fd0de 100644
--- a/lldb/source/Target/ThreadPlan.cpp
+++ b/lldb/source/Target/ThreadPlan.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadPlan.cpp ------------------------------------------*- C++ -*-===//
+//===-- ThreadPlan.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -21,9 +21,10 @@ using namespace lldb_private;
// ThreadPlan constructor
ThreadPlan::ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread,
Vote stop_vote, Vote run_vote)
- : m_thread(thread), m_stop_vote(stop_vote), m_run_vote(run_vote),
+ : m_process(*thread.GetProcess().get()), m_tid(thread.GetID()),
+ m_stop_vote(stop_vote), m_run_vote(run_vote),
m_takes_iteration_count(false), m_could_not_resolve_hw_bp(false),
- m_kind(kind), m_name(name), m_plan_complete_mutex(),
+ m_thread(&thread), m_kind(kind), m_name(name), m_plan_complete_mutex(),
m_cached_plan_explains_stop(eLazyBoolCalculate), m_plan_complete(false),
m_plan_private(false), m_okay_to_discard(true), m_is_master_plan(false),
m_plan_succeeded(true) {
@@ -33,6 +34,19 @@ ThreadPlan::ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread,
// Destructor
ThreadPlan::~ThreadPlan() = default;
+Target &ThreadPlan::GetTarget() { return m_process.GetTarget(); }
+
+const Target &ThreadPlan::GetTarget() const { return m_process.GetTarget(); }
+
+Thread &ThreadPlan::GetThread() {
+ if (m_thread)
+ return *m_thread;
+
+ ThreadSP thread_sp = m_process.GetThreadList().FindThreadByID(m_tid);
+ m_thread = thread_sp.get();
+ return *m_thread;
+}
+
bool ThreadPlan::PlanExplainsStop(Event *event_ptr) {
if (m_cached_plan_explains_stop == eLazyBoolCalculate) {
bool actual_value = DoPlanExplainsStop(event_ptr);
@@ -103,7 +117,7 @@ bool ThreadPlan::WillResume(StateType resume_state, bool current_plan) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
if (log) {
- RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
+ RegisterContext *reg_ctx = GetThread().GetRegisterContext().get();
assert(reg_ctx);
addr_t pc = reg_ctx->GetPC();
addr_t sp = reg_ctx->GetSP();
@@ -113,13 +127,17 @@ bool ThreadPlan::WillResume(StateType resume_state, bool current_plan) {
"%s Thread #%u (0x%p): tid = 0x%4.4" PRIx64 ", pc = 0x%8.8" PRIx64
", sp = 0x%8.8" PRIx64 ", fp = 0x%8.8" PRIx64 ", "
"plan = '%s', state = %s, stop others = %d",
- __FUNCTION__, m_thread.GetIndexID(), static_cast<void *>(&m_thread),
- m_thread.GetID(), static_cast<uint64_t>(pc),
+ __FUNCTION__, GetThread().GetIndexID(),
+ static_cast<void *>(&GetThread()), m_tid, static_cast<uint64_t>(pc),
static_cast<uint64_t>(sp), static_cast<uint64_t>(fp), m_name.c_str(),
StateAsCString(resume_state), StopOthers());
}
}
- return DoWillResume(resume_state, current_plan);
+ bool success = DoWillResume(resume_state, current_plan);
+ m_thread = nullptr; // We don't cache the thread pointer over resumes. This
+ // Thread might go away, and another Thread represent
+ // the same underlying object on a later stop.
+ return success;
}
lldb::user_id_t ThreadPlan::GetNextID() {
@@ -174,14 +192,13 @@ bool ThreadPlanNull::ValidatePlan(Stream *error) {
fprintf(stderr,
"error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION, m_thread.GetID(), m_thread.GetProtocolID());
+ LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
#else
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
if (log)
log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION, m_thread.GetID(),
- m_thread.GetProtocolID());
+ LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
#endif
return true;
}
@@ -191,14 +208,13 @@ bool ThreadPlanNull::ShouldStop(Event *event_ptr) {
fprintf(stderr,
"error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION, m_thread.GetID(), m_thread.GetProtocolID());
+ LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
#else
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
if (log)
log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION, m_thread.GetID(),
- m_thread.GetProtocolID());
+ LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
#endif
return true;
}
@@ -208,14 +224,13 @@ bool ThreadPlanNull::WillStop() {
fprintf(stderr,
"error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION, m_thread.GetID(), m_thread.GetProtocolID());
+ LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
#else
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
if (log)
log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION, m_thread.GetID(),
- m_thread.GetProtocolID());
+ LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
#endif
return true;
}
@@ -225,14 +240,13 @@ bool ThreadPlanNull::DoPlanExplainsStop(Event *event_ptr) {
fprintf(stderr,
"error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION, m_thread.GetID(), m_thread.GetProtocolID());
+ LLVM_PRETTY_FUNCTION, GetThread().GetID(), GetThread().GetProtocolID());
#else
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
if (log)
log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION, m_thread.GetID(),
- m_thread.GetProtocolID());
+ LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
#endif
return true;
}
@@ -244,14 +258,13 @@ bool ThreadPlanNull::MischiefManaged() {
fprintf(stderr,
"error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION, m_thread.GetID(), m_thread.GetProtocolID());
+ LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
#else
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
if (log)
log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION, m_thread.GetID(),
- m_thread.GetProtocolID());
+ LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
#endif
return false;
}
@@ -262,14 +275,13 @@ lldb::StateType ThreadPlanNull::GetPlanRunState() {
fprintf(stderr,
"error: %s called on thread that has been destroyed (tid = 0x%" PRIx64
", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION, m_thread.GetID(), m_thread.GetProtocolID());
+ LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
#else
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
if (log)
log->Error("%s called on thread that has been destroyed (tid = 0x%" PRIx64
", ptid = 0x%" PRIx64 ")",
- LLVM_PRETTY_FUNCTION, m_thread.GetID(),
- m_thread.GetProtocolID());
+ LLVM_PRETTY_FUNCTION, m_tid, GetThread().GetProtocolID());
#endif
return eStateRunning;
}
diff --git a/lldb/source/Target/ThreadPlanBase.cpp b/lldb/source/Target/ThreadPlanBase.cpp
index 821643d4bce5..650393d678e8 100644
--- a/lldb/source/Target/ThreadPlanBase.cpp
+++ b/lldb/source/Target/ThreadPlanBase.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadPlanBase.cpp --------------------------------------*- C++ -*-===//
+//===-- ThreadPlanBase.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -34,11 +34,11 @@ ThreadPlanBase::ThreadPlanBase(Thread &thread)
#define THREAD_PLAN_USE_ASSEMBLY_TRACER 1
#ifdef THREAD_PLAN_USE_ASSEMBLY_TRACER
- ThreadPlanTracerSP new_tracer_sp(new ThreadPlanAssemblyTracer(m_thread));
+ ThreadPlanTracerSP new_tracer_sp(new ThreadPlanAssemblyTracer(thread));
#else
ThreadPlanTracerSP new_tracer_sp(new ThreadPlanTracer(m_thread));
#endif
- new_tracer_sp->EnableTracing(m_thread.GetTraceEnabledState());
+ new_tracer_sp->EnableTracing(thread.GetTraceEnabledState());
SetThreadPlanTracer(new_tracer_sp);
SetIsMasterPlan(true);
}
@@ -58,7 +58,7 @@ bool ThreadPlanBase::DoPlanExplainsStop(Event *event_ptr) {
}
Vote ThreadPlanBase::ShouldReportStop(Event *event_ptr) {
- StopInfoSP stop_info_sp = m_thread.GetStopInfo();
+ StopInfoSP stop_info_sp = GetThread().GetStopInfo();
if (stop_info_sp) {
bool should_notify = stop_info_sp->ShouldNotify(event_ptr);
if (should_notify)
@@ -96,8 +96,8 @@ bool ThreadPlanBase::ShouldStop(Event *event_ptr) {
log,
"Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64
" (breakpoint hit.)",
- m_thread.GetID());
- m_thread.DiscardThreadPlans(false);
+ m_tid);
+ GetThread().DiscardThreadPlans(false);
return true;
}
// If we aren't going to stop at this breakpoint, and it is internal,
@@ -125,9 +125,9 @@ bool ThreadPlanBase::ShouldStop(Event *event_ptr) {
LLDB_LOGF(
log,
"Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64
- " (exception: %s)",
- m_thread.GetID(), stop_info_sp->GetDescription());
- m_thread.DiscardThreadPlans(false);
+ " (exception: %s)",
+ m_tid, stop_info_sp->GetDescription());
+ GetThread().DiscardThreadPlans(false);
return true;
case eStopReasonExec:
@@ -138,8 +138,8 @@ bool ThreadPlanBase::ShouldStop(Event *event_ptr) {
log,
"Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64
" (exec.)",
- m_thread.GetID());
- m_thread.DiscardThreadPlans(false);
+ m_tid);
+ GetThread().DiscardThreadPlans(false);
return true;
case eStopReasonThreadExiting:
@@ -148,9 +148,9 @@ bool ThreadPlanBase::ShouldStop(Event *event_ptr) {
LLDB_LOGF(
log,
"Base plan discarding thread plans for thread tid = 0x%4.4" PRIx64
- " (signal: %s)",
- m_thread.GetID(), stop_info_sp->GetDescription());
- m_thread.DiscardThreadPlans(false);
+ " (signal: %s)",
+ m_tid, stop_info_sp->GetDescription());
+ GetThread().DiscardThreadPlans(false);
return true;
} else {
// We're not going to stop, but while we are here, let's figure out
diff --git a/lldb/source/Target/ThreadPlanCallFunction.cpp b/lldb/source/Target/ThreadPlanCallFunction.cpp
index 23d114e30990..dbe26f42c9bf 100644
--- a/lldb/source/Target/ThreadPlanCallFunction.cpp
+++ b/lldb/source/Target/ThreadPlanCallFunction.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadPlanCallFunction.cpp ------------------------------*- C++ -*-===//
+//===-- ThreadPlanCallFunction.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -146,7 +146,7 @@ void ThreadPlanCallFunction::ReportRegisterState(const char *message) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
if (log && log->GetVerbose()) {
StreamString strm;
- RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
+ RegisterContext *reg_ctx = GetThread().GetRegisterContext().get();
log->PutCString(message);
@@ -178,19 +178,19 @@ void ThreadPlanCallFunction::DoTakedown(bool success) {
}
if (!m_takedown_done) {
+ Thread &thread = GetThread();
if (success) {
SetReturnValue();
}
LLDB_LOGF(log,
"ThreadPlanCallFunction(%p): DoTakedown called for thread "
"0x%4.4" PRIx64 ", m_valid: %d complete: %d.\n",
- static_cast<void *>(this), m_thread.GetID(), m_valid,
- IsPlanComplete());
+ static_cast<void *>(this), m_tid, m_valid, IsPlanComplete());
m_takedown_done = true;
m_stop_address =
- m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
+ thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
m_real_stop_info_sp = GetPrivateStopInfo();
- if (!m_thread.RestoreRegisterStateFromCheckpoint(m_stored_thread_state)) {
+ if (!thread.RestoreRegisterStateFromCheckpoint(m_stored_thread_state)) {
LLDB_LOGF(log,
"ThreadPlanCallFunction(%p): DoTakedown failed to restore "
"register state",
@@ -205,8 +205,7 @@ void ThreadPlanCallFunction::DoTakedown(bool success) {
LLDB_LOGF(log,
"ThreadPlanCallFunction(%p): DoTakedown called as no-op for "
"thread 0x%4.4" PRIx64 ", m_valid: %d complete: %d.\n",
- static_cast<void *>(this), m_thread.GetID(), m_valid,
- IsPlanComplete());
+ static_cast<void *>(this), m_tid, m_valid, IsPlanComplete());
}
}
@@ -216,9 +215,8 @@ void ThreadPlanCallFunction::GetDescription(Stream *s, DescriptionLevel level) {
if (level == eDescriptionLevelBrief) {
s->Printf("Function call thread plan");
} else {
- TargetSP target_sp(m_thread.CalculateTarget());
s->Printf("Thread plan to call 0x%" PRIx64,
- m_function_addr.GetLoadAddress(target_sp.get()));
+ m_function_addr.GetLoadAddress(&GetTarget()));
}
}
@@ -283,11 +281,9 @@ bool ThreadPlanCallFunction::DoPlanExplainsStop(Event *event_ptr) {
// m_ignore_breakpoints.
if (stop_reason == eStopReasonBreakpoint) {
- ProcessSP process_sp(m_thread.CalculateProcess());
uint64_t break_site_id = m_real_stop_info_sp->GetValue();
BreakpointSiteSP bp_site_sp;
- if (process_sp)
- bp_site_sp = process_sp->GetBreakpointSiteList().FindByID(break_site_id);
+ bp_site_sp = m_process.GetBreakpointSiteList().FindByID(break_site_id);
if (bp_site_sp) {
uint32_t num_owners = bp_site_sp->GetNumberOfOwners();
bool is_internal = true;
@@ -374,10 +370,11 @@ void ThreadPlanCallFunction::DidPush() {
GetThread().SetStopInfoToNothing();
#ifndef SINGLE_STEP_EXPRESSIONS
- m_subplan_sp = std::make_shared<ThreadPlanRunToAddress>(
- m_thread, m_start_addr, m_stop_other_threads);
+ Thread &thread = GetThread();
+ m_subplan_sp = std::make_shared<ThreadPlanRunToAddress>(thread, m_start_addr,
+ m_stop_other_threads);
- m_thread.QueueThreadPlan(m_subplan_sp, false);
+ thread.QueueThreadPlan(m_subplan_sp, false);
m_subplan_sp->SetPrivate(true);
#endif
}
@@ -399,11 +396,10 @@ bool ThreadPlanCallFunction::MischiefManaged() {
}
void ThreadPlanCallFunction::SetBreakpoints() {
- ProcessSP process_sp(m_thread.CalculateProcess());
- if (m_trap_exceptions && process_sp) {
+ if (m_trap_exceptions) {
m_cxx_language_runtime =
- process_sp->GetLanguageRuntime(eLanguageTypeC_plus_plus);
- m_objc_language_runtime = process_sp->GetLanguageRuntime(eLanguageTypeObjC);
+ m_process.GetLanguageRuntime(eLanguageTypeC_plus_plus);
+ m_objc_language_runtime = m_process.GetLanguageRuntime(eLanguageTypeObjC);
if (m_cxx_language_runtime) {
m_should_clear_cxx_exception_bp =
@@ -463,11 +459,10 @@ bool ThreadPlanCallFunction::RestoreThreadState() {
}
void ThreadPlanCallFunction::SetReturnValue() {
- ProcessSP process_sp(m_thread.GetProcess());
- const ABI *abi = process_sp ? process_sp->GetABI().get() : nullptr;
+ const ABI *abi = m_process.GetABI().get();
if (abi && m_return_type.IsValid()) {
const bool persistent = false;
m_return_valobj_sp =
- abi->GetReturnValueObject(m_thread, m_return_type, persistent);
+ abi->GetReturnValueObject(GetThread(), m_return_type, persistent);
}
}
diff --git a/lldb/source/Target/ThreadPlanCallFunctionUsingABI.cpp b/lldb/source/Target/ThreadPlanCallFunctionUsingABI.cpp
index 3155e6f7965f..52b27309e912 100644
--- a/lldb/source/Target/ThreadPlanCallFunctionUsingABI.cpp
+++ b/lldb/source/Target/ThreadPlanCallFunctionUsingABI.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadPlanCallFunctionUsingABI.cpp ----------------------*- C++ -*-===//
+//===-- ThreadPlanCallFunctionUsingABI.cpp --------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -49,20 +49,18 @@ void ThreadPlanCallFunctionUsingABI::GetDescription(Stream *s,
if (level == eDescriptionLevelBrief) {
s->Printf("Function call thread plan using ABI instead of JIT");
} else {
- TargetSP target_sp(m_thread.CalculateTarget());
s->Printf("Thread plan to call 0x%" PRIx64 " using ABI instead of JIT",
- m_function_addr.GetLoadAddress(target_sp.get()));
+ m_function_addr.GetLoadAddress(&GetTarget()));
}
}
void ThreadPlanCallFunctionUsingABI::SetReturnValue() {
- ProcessSP process_sp(m_thread.GetProcess());
- const ABI *abi = process_sp ? process_sp->GetABI().get() : nullptr;
+ const ABI *abi = m_process.GetABI().get();
// Ask the abi for the return value
if (abi) {
const bool persistent = false;
m_return_valobj_sp =
- abi->GetReturnValueObject(m_thread, m_return_type, persistent);
+ abi->GetReturnValueObject(GetThread(), m_return_type, persistent);
}
}
diff --git a/lldb/source/Target/ThreadPlanCallOnFunctionExit.cpp b/lldb/source/Target/ThreadPlanCallOnFunctionExit.cpp
index 3330adc0c2af..7471e9b3d7ac 100644
--- a/lldb/source/Target/ThreadPlanCallOnFunctionExit.cpp
+++ b/lldb/source/Target/ThreadPlanCallOnFunctionExit.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadPlanCallOnFunctionExit.cpp ------------------------*- C++ -*-===//
+//===-- ThreadPlanCallOnFunctionExit.cpp ----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/ThreadPlanCallUserExpression.cpp b/lldb/source/Target/ThreadPlanCallUserExpression.cpp
index 436938c8f207..00b01c76d900 100644
--- a/lldb/source/Target/ThreadPlanCallUserExpression.cpp
+++ b/lldb/source/Target/ThreadPlanCallUserExpression.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadPlanCallUserExpression.cpp -------------------------*- C++-*-===//
+//===-- ThreadPlanCallUserExpression.cpp ----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -101,8 +101,7 @@ StopInfoSP ThreadPlanCallUserExpression::GetRealStopInfo() {
if (stop_info_sp) {
lldb::addr_t addr = GetStopAddress();
- DynamicCheckerFunctions *checkers =
- m_thread.GetProcess()->GetDynamicCheckers();
+ DynamicCheckerFunctions *checkers = m_process.GetDynamicCheckers();
StreamString s;
if (checkers && checkers->DoCheckersExplainStop(addr, s))
diff --git a/lldb/source/Target/ThreadPlanPython.cpp b/lldb/source/Target/ThreadPlanPython.cpp
index df432a0af3da..8171186319f5 100644
--- a/lldb/source/Target/ThreadPlanPython.cpp
+++ b/lldb/source/Target/ThreadPlanPython.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadPlanPython.cpp ------------------------------------*- C++ -*-===//
+//===-- ThreadPlanPython.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -55,15 +55,16 @@ bool ThreadPlanPython::ValidatePlan(Stream *error) {
return true;
}
+ScriptInterpreter *ThreadPlanPython::GetScriptInterpreter() {
+ return m_process.GetTarget().GetDebugger().GetScriptInterpreter();
+}
+
void ThreadPlanPython::DidPush() {
// We set up the script side in DidPush, so that it can push other plans in
// the constructor, and doesn't have to care about the details of DidPush.
m_did_push = true;
if (!m_class_name.empty()) {
- ScriptInterpreter *script_interp = m_thread.GetProcess()
- ->GetTarget()
- .GetDebugger()
- .GetScriptInterpreter();
+ ScriptInterpreter *script_interp = GetScriptInterpreter();
if (script_interp) {
m_implementation_sp = script_interp->CreateScriptedThreadPlan(
m_class_name.c_str(), m_args_data, m_error_str,
@@ -79,10 +80,7 @@ bool ThreadPlanPython::ShouldStop(Event *event_ptr) {
bool should_stop = true;
if (m_implementation_sp) {
- ScriptInterpreter *script_interp = m_thread.GetProcess()
- ->GetTarget()
- .GetDebugger()
- .GetScriptInterpreter();
+ ScriptInterpreter *script_interp = GetScriptInterpreter();
if (script_interp) {
bool script_error;
should_stop = script_interp->ScriptedThreadPlanShouldStop(
@@ -101,10 +99,7 @@ bool ThreadPlanPython::IsPlanStale() {
bool is_stale = true;
if (m_implementation_sp) {
- ScriptInterpreter *script_interp = m_thread.GetProcess()
- ->GetTarget()
- .GetDebugger()
- .GetScriptInterpreter();
+ ScriptInterpreter *script_interp = GetScriptInterpreter();
if (script_interp) {
bool script_error;
is_stale = script_interp->ScriptedThreadPlanIsStale(m_implementation_sp,
@@ -123,10 +118,7 @@ bool ThreadPlanPython::DoPlanExplainsStop(Event *event_ptr) {
bool explains_stop = true;
if (m_implementation_sp) {
- ScriptInterpreter *script_interp = m_thread.GetProcess()
- ->GetTarget()
- .GetDebugger()
- .GetScriptInterpreter();
+ ScriptInterpreter *script_interp = GetScriptInterpreter();
if (script_interp) {
bool script_error;
explains_stop = script_interp->ScriptedThreadPlanExplainsStop(
@@ -159,10 +151,7 @@ lldb::StateType ThreadPlanPython::GetPlanRunState() {
m_class_name.c_str());
lldb::StateType run_state = eStateRunning;
if (m_implementation_sp) {
- ScriptInterpreter *script_interp = m_thread.GetProcess()
- ->GetTarget()
- .GetDebugger()
- .GetScriptInterpreter();
+ ScriptInterpreter *script_interp = GetScriptInterpreter();
if (script_interp) {
bool script_error;
run_state = script_interp->ScriptedThreadPlanGetRunState(
diff --git a/lldb/source/Target/ThreadPlanRunToAddress.cpp b/lldb/source/Target/ThreadPlanRunToAddress.cpp
index 32ea2e675270..cb4a58b1cf25 100644
--- a/lldb/source/Target/ThreadPlanRunToAddress.cpp
+++ b/lldb/source/Target/ThreadPlanRunToAddress.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadPlanRunToAddress.cpp ------------------------------*- C++ -*-===//
+//===-- ThreadPlanRunToAddress.cpp ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -25,7 +25,7 @@ ThreadPlanRunToAddress::ThreadPlanRunToAddress(Thread &thread, Address &address,
eVoteNoOpinion, eVoteNoOpinion),
m_stop_others(stop_others), m_addresses(), m_break_ids() {
m_addresses.push_back(
- address.GetOpcodeLoadAddress(m_thread.CalculateTarget().get()));
+ address.GetOpcodeLoadAddress(thread.CalculateTarget().get()));
SetInitialBreakpoints();
}
@@ -36,7 +36,7 @@ ThreadPlanRunToAddress::ThreadPlanRunToAddress(Thread &thread,
eVoteNoOpinion, eVoteNoOpinion),
m_stop_others(stop_others), m_addresses(), m_break_ids() {
m_addresses.push_back(
- m_thread.CalculateTarget()->GetOpcodeLoadAddress(address));
+ thread.CalculateTarget()->GetOpcodeLoadAddress(address));
SetInitialBreakpoints();
}
@@ -62,14 +62,13 @@ void ThreadPlanRunToAddress::SetInitialBreakpoints() {
for (size_t i = 0; i < num_addresses; i++) {
Breakpoint *breakpoint;
- breakpoint = m_thread.CalculateTarget()
- ->CreateBreakpoint(m_addresses[i], true, false)
- .get();
+ breakpoint =
+ GetTarget().CreateBreakpoint(m_addresses[i], true, false).get();
if (breakpoint != nullptr) {
if (breakpoint->IsHardware() && !breakpoint->HasResolvedLocations())
m_could_not_resolve_hw_bp = true;
m_break_ids[i] = breakpoint->GetID();
- breakpoint->SetThreadID(m_thread.GetID());
+ breakpoint->SetThreadID(m_tid);
breakpoint->SetBreakpointKind("run-to-address");
}
}
@@ -78,7 +77,7 @@ void ThreadPlanRunToAddress::SetInitialBreakpoints() {
ThreadPlanRunToAddress::~ThreadPlanRunToAddress() {
size_t num_break_ids = m_break_ids.size();
for (size_t i = 0; i < num_break_ids; i++) {
- m_thread.CalculateTarget()->RemoveBreakpointByID(m_break_ids[i]);
+ GetTarget().RemoveBreakpointByID(m_break_ids[i]);
}
m_could_not_resolve_hw_bp = false;
}
@@ -119,7 +118,7 @@ void ThreadPlanRunToAddress::GetDescription(Stream *s,
DumpAddress(s->AsRawOstream(), m_addresses[i], sizeof(addr_t));
s->Printf(" using breakpoint: %d - ", m_break_ids[i]);
Breakpoint *breakpoint =
- m_thread.CalculateTarget()->GetBreakpointByID(m_break_ids[i]).get();
+ GetTarget().GetBreakpointByID(m_break_ids[i]).get();
if (breakpoint)
breakpoint->Dump(s);
else
@@ -178,7 +177,7 @@ bool ThreadPlanRunToAddress::MischiefManaged() {
for (size_t i = 0; i < num_break_ids; i++) {
if (m_break_ids[i] != LLDB_INVALID_BREAK_ID) {
- m_thread.CalculateTarget()->RemoveBreakpointByID(m_break_ids[i]);
+ GetTarget().RemoveBreakpointByID(m_break_ids[i]);
m_break_ids[i] = LLDB_INVALID_BREAK_ID;
}
}
@@ -190,7 +189,7 @@ bool ThreadPlanRunToAddress::MischiefManaged() {
}
bool ThreadPlanRunToAddress::AtOurAddress() {
- lldb::addr_t current_address = m_thread.GetRegisterContext()->GetPC();
+ lldb::addr_t current_address = GetThread().GetRegisterContext()->GetPC();
bool found_it = false;
size_t num_addresses = m_addresses.size();
for (size_t i = 0; i < num_addresses; i++) {
diff --git a/lldb/source/Target/ThreadPlanShouldStopHere.cpp b/lldb/source/Target/ThreadPlanShouldStopHere.cpp
index 9599d8197b07..7774e027c056 100644
--- a/lldb/source/Target/ThreadPlanShouldStopHere.cpp
+++ b/lldb/source/Target/ThreadPlanShouldStopHere.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadPlanShouldStopHere.cpp ----------------------------*- C++ -*-===//
+//===-- ThreadPlanShouldStopHere.cpp --------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/ThreadPlanStack.cpp b/lldb/source/Target/ThreadPlanStack.cpp
new file mode 100644
index 000000000000..1cfc41dcd390
--- /dev/null
+++ b/lldb/source/Target/ThreadPlanStack.cpp
@@ -0,0 +1,508 @@
+//===-- ThreadPlanStack.cpp -------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Target/ThreadPlanStack.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
+#include "lldb/Target/ThreadPlan.h"
+#include "lldb/Utility/Log.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+static void PrintPlanElement(Stream &s, const ThreadPlanSP &plan,
+ lldb::DescriptionLevel desc_level,
+ int32_t elem_idx) {
+ s.IndentMore();
+ s.Indent();
+ s.Printf("Element %d: ", elem_idx);
+ plan->GetDescription(&s, desc_level);
+ s.EOL();
+ s.IndentLess();
+}
+
+ThreadPlanStack::ThreadPlanStack(const Thread &thread, bool make_null) {
+ if (make_null) {
+ // The ThreadPlanNull doesn't do anything to the Thread, so this is actually
+ // still a const operation.
+ m_plans.push_back(
+ ThreadPlanSP(new ThreadPlanNull(const_cast<Thread &>(thread))));
+ }
+}
+
+void ThreadPlanStack::DumpThreadPlans(Stream &s,
+ lldb::DescriptionLevel desc_level,
+ bool include_internal) const {
+ s.IndentMore();
+ PrintOneStack(s, "Active plan stack", m_plans, desc_level, include_internal);
+ PrintOneStack(s, "Completed plan stack", m_completed_plans, desc_level,
+ include_internal);
+ PrintOneStack(s, "Discarded plan stack", m_discarded_plans, desc_level,
+ include_internal);
+ s.IndentLess();
+}
+
+void ThreadPlanStack::PrintOneStack(Stream &s, llvm::StringRef stack_name,
+ const PlanStack &stack,
+ lldb::DescriptionLevel desc_level,
+ bool include_internal) const {
+ // If the stack is empty, just exit:
+ if (stack.empty())
+ return;
+
+ // Make sure there are public completed plans:
+ bool any_public = false;
+ if (!include_internal) {
+ for (auto plan : stack) {
+ if (!plan->GetPrivate()) {
+ any_public = true;
+ break;
+ }
+ }
+ }
+
+ if (include_internal || any_public) {
+ int print_idx = 0;
+ s.Indent();
+ s << stack_name << ":\n";
+ for (auto plan : stack) {
+ if (!include_internal && plan->GetPrivate())
+ continue;
+ PrintPlanElement(s, plan, desc_level, print_idx++);
+ }
+ }
+}
+
+size_t ThreadPlanStack::CheckpointCompletedPlans() {
+ m_completed_plan_checkpoint++;
+ m_completed_plan_store.insert(
+ std::make_pair(m_completed_plan_checkpoint, m_completed_plans));
+ return m_completed_plan_checkpoint;
+}
+
+void ThreadPlanStack::RestoreCompletedPlanCheckpoint(size_t checkpoint) {
+ auto result = m_completed_plan_store.find(checkpoint);
+ assert(result != m_completed_plan_store.end() &&
+ "Asked for a checkpoint that didn't exist");
+ m_completed_plans.swap((*result).second);
+ m_completed_plan_store.erase(result);
+}
+
+void ThreadPlanStack::DiscardCompletedPlanCheckpoint(size_t checkpoint) {
+ m_completed_plan_store.erase(checkpoint);
+}
+
+void ThreadPlanStack::ThreadDestroyed(Thread *thread) {
+ // Tell the plan stacks that this thread is going away:
+ for (ThreadPlanSP plan : m_plans)
+ plan->ThreadDestroyed();
+
+ for (ThreadPlanSP plan : m_discarded_plans)
+ plan->ThreadDestroyed();
+
+ for (ThreadPlanSP plan : m_completed_plans)
+ plan->ThreadDestroyed();
+
+ // Now clear the current plan stacks:
+ m_plans.clear();
+ m_discarded_plans.clear();
+ m_completed_plans.clear();
+
+ // Push a ThreadPlanNull on the plan stack. That way we can continue
+ // assuming that the plan stack is never empty, but if somebody errantly asks
+ // questions of a destroyed thread without checking first whether it is
+ // destroyed, they won't crash.
+ if (thread != nullptr) {
+ lldb::ThreadPlanSP null_plan_sp(new ThreadPlanNull(*thread));
+ m_plans.push_back(null_plan_sp);
+ }
+}
+
+void ThreadPlanStack::EnableTracer(bool value, bool single_stepping) {
+ for (ThreadPlanSP plan : m_plans) {
+ if (plan->GetThreadPlanTracer()) {
+ plan->GetThreadPlanTracer()->EnableTracing(value);
+ plan->GetThreadPlanTracer()->EnableSingleStep(single_stepping);
+ }
+ }
+}
+
+void ThreadPlanStack::SetTracer(lldb::ThreadPlanTracerSP &tracer_sp) {
+ for (ThreadPlanSP plan : m_plans)
+ plan->SetThreadPlanTracer(tracer_sp);
+}
+
+void ThreadPlanStack::PushPlan(lldb::ThreadPlanSP new_plan_sp) {
+ // If the thread plan doesn't already have a tracer, give it its parent's
+ // tracer:
+ // The first plan has to be a base plan:
+ assert((m_plans.size() > 0 || new_plan_sp->IsBasePlan()) &&
+ "Zeroth plan must be a base plan");
+
+ if (!new_plan_sp->GetThreadPlanTracer()) {
+ assert(!m_plans.empty());
+ new_plan_sp->SetThreadPlanTracer(m_plans.back()->GetThreadPlanTracer());
+ }
+ m_plans.push_back(new_plan_sp);
+ new_plan_sp->DidPush();
+}
+
+lldb::ThreadPlanSP ThreadPlanStack::PopPlan() {
+ assert(m_plans.size() > 1 && "Can't pop the base thread plan");
+
+ lldb::ThreadPlanSP plan_sp = std::move(m_plans.back());
+ m_completed_plans.push_back(plan_sp);
+ plan_sp->WillPop();
+ m_plans.pop_back();
+ return plan_sp;
+}
+
+lldb::ThreadPlanSP ThreadPlanStack::DiscardPlan() {
+ assert(m_plans.size() > 1 && "Can't discard the base thread plan");
+
+ lldb::ThreadPlanSP plan_sp = std::move(m_plans.back());
+ m_discarded_plans.push_back(plan_sp);
+ plan_sp->WillPop();
+ m_plans.pop_back();
+ return plan_sp;
+}
+
+// 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.
+void ThreadPlanStack::DiscardPlansUpToPlan(ThreadPlan *up_to_plan_ptr) {
+ int stack_size = m_plans.size();
+
+ if (up_to_plan_ptr == nullptr) {
+ for (int i = stack_size - 1; i > 0; i--)
+ DiscardPlan();
+ return;
+ }
+
+ bool found_it = false;
+ for (int i = stack_size - 1; i > 0; i--) {
+ if (m_plans[i].get() == up_to_plan_ptr) {
+ found_it = true;
+ break;
+ }
+ }
+
+ if (found_it) {
+ bool last_one = false;
+ for (int i = stack_size - 1; i > 0 && !last_one; i--) {
+ if (GetCurrentPlan().get() == up_to_plan_ptr)
+ last_one = true;
+ DiscardPlan();
+ }
+ }
+}
+
+void ThreadPlanStack::DiscardAllPlans() {
+ int stack_size = m_plans.size();
+ for (int i = stack_size - 1; i > 0; i--) {
+ DiscardPlan();
+ }
+ return;
+}
+
+void ThreadPlanStack::DiscardConsultingMasterPlans() {
+ while (true) {
+ int master_plan_idx;
+ bool discard = true;
+
+ // Find the first master plan, see if it wants discarding, and if yes
+ // discard up to it.
+ for (master_plan_idx = m_plans.size() - 1; master_plan_idx >= 0;
+ master_plan_idx--) {
+ if (m_plans[master_plan_idx]->IsMasterPlan()) {
+ discard = m_plans[master_plan_idx]->OkayToDiscard();
+ break;
+ }
+ }
+
+ // If the master plan doesn't want to get discarded, then we're done.
+ if (!discard)
+ return;
+
+ // First pop all the dependent plans:
+ for (int i = m_plans.size() - 1; i > master_plan_idx; i--) {
+ DiscardPlan();
+ }
+
+ // Now discard the master plan itself.
+ // The bottom-most plan never gets discarded. "OkayToDiscard" for it
+ // means discard it's dependent plans, but not it...
+ if (master_plan_idx > 0) {
+ DiscardPlan();
+ }
+ }
+}
+
+lldb::ThreadPlanSP ThreadPlanStack::GetCurrentPlan() const {
+ assert(m_plans.size() != 0 && "There will always be a base plan.");
+ return m_plans.back();
+}
+
+lldb::ThreadPlanSP ThreadPlanStack::GetCompletedPlan(bool skip_private) const {
+ if (m_completed_plans.empty())
+ return {};
+
+ if (!skip_private)
+ return m_completed_plans.back();
+
+ for (int i = m_completed_plans.size() - 1; i >= 0; i--) {
+ lldb::ThreadPlanSP completed_plan_sp;
+ completed_plan_sp = m_completed_plans[i];
+ if (!completed_plan_sp->GetPrivate())
+ return completed_plan_sp;
+ }
+ return {};
+}
+
+lldb::ThreadPlanSP ThreadPlanStack::GetPlanByIndex(uint32_t plan_idx,
+ bool skip_private) const {
+ uint32_t idx = 0;
+
+ for (lldb::ThreadPlanSP plan_sp : m_plans) {
+ if (skip_private && plan_sp->GetPrivate())
+ continue;
+ if (idx == plan_idx)
+ return plan_sp;
+ idx++;
+ }
+ return {};
+}
+
+lldb::ValueObjectSP ThreadPlanStack::GetReturnValueObject() const {
+ if (m_completed_plans.empty())
+ return {};
+
+ for (int i = m_completed_plans.size() - 1; i >= 0; i--) {
+ lldb::ValueObjectSP return_valobj_sp;
+ return_valobj_sp = m_completed_plans[i]->GetReturnValueObject();
+ if (return_valobj_sp)
+ return return_valobj_sp;
+ }
+ return {};
+}
+
+lldb::ExpressionVariableSP ThreadPlanStack::GetExpressionVariable() const {
+ if (m_completed_plans.empty())
+ return {};
+
+ for (int i = m_completed_plans.size() - 1; i >= 0; i--) {
+ lldb::ExpressionVariableSP expression_variable_sp;
+ expression_variable_sp = m_completed_plans[i]->GetExpressionVariable();
+ if (expression_variable_sp)
+ return expression_variable_sp;
+ }
+ return {};
+}
+bool ThreadPlanStack::AnyPlans() const {
+ // There is always a base plan...
+ return m_plans.size() > 1;
+}
+
+bool ThreadPlanStack::AnyCompletedPlans() const {
+ return !m_completed_plans.empty();
+}
+
+bool ThreadPlanStack::AnyDiscardedPlans() const {
+ return !m_discarded_plans.empty();
+}
+
+bool ThreadPlanStack::IsPlanDone(ThreadPlan *in_plan) const {
+ for (auto plan : m_completed_plans) {
+ if (plan.get() == in_plan)
+ return true;
+ }
+ return false;
+}
+
+bool ThreadPlanStack::WasPlanDiscarded(ThreadPlan *in_plan) const {
+ for (auto plan : m_discarded_plans) {
+ if (plan.get() == in_plan)
+ return true;
+ }
+ return false;
+}
+
+ThreadPlan *ThreadPlanStack::GetPreviousPlan(ThreadPlan *current_plan) const {
+ if (current_plan == nullptr)
+ return nullptr;
+
+ // Look first in the completed plans, if the plan is here and there is
+ // a completed plan above it, return that.
+ int stack_size = m_completed_plans.size();
+ for (int i = stack_size - 1; i > 0; i--) {
+ if (current_plan == m_completed_plans[i].get())
+ return m_completed_plans[i - 1].get();
+ }
+
+ // If this is the first completed plan, the previous one is the
+ // bottom of the regular plan stack.
+ if (stack_size > 0 && m_completed_plans[0].get() == current_plan) {
+ return GetCurrentPlan().get();
+ }
+
+ // Otherwise look for it in the regular plans.
+ stack_size = m_plans.size();
+ for (int i = stack_size - 1; i > 0; i--) {
+ if (current_plan == m_plans[i].get())
+ return m_plans[i - 1].get();
+ }
+ return nullptr;
+}
+
+ThreadPlan *ThreadPlanStack::GetInnermostExpression() const {
+ int stack_size = m_plans.size();
+
+ for (int i = stack_size - 1; i > 0; i--) {
+ if (m_plans[i]->GetKind() == ThreadPlan::eKindCallFunction)
+ return m_plans[i].get();
+ }
+ return nullptr;
+}
+
+void ThreadPlanStack::WillResume() {
+ m_completed_plans.clear();
+ m_discarded_plans.clear();
+}
+
+const ThreadPlanStack::PlanStack &
+ThreadPlanStack::GetStackOfKind(ThreadPlanStack::StackKind kind) const {
+ switch (kind) {
+ case ePlans:
+ return m_plans;
+ case eCompletedPlans:
+ return m_completed_plans;
+ case eDiscardedPlans:
+ return m_discarded_plans;
+ }
+ llvm_unreachable("Invalid StackKind value");
+}
+
+void ThreadPlanStackMap::Update(ThreadList &current_threads,
+ bool delete_missing,
+ bool check_for_new) {
+
+ // Now find all the new threads and add them to the map:
+ if (check_for_new) {
+ for (auto thread : current_threads.Threads()) {
+ lldb::tid_t cur_tid = thread->GetID();
+ if (!Find(cur_tid)) {
+ AddThread(*thread.get());
+ thread->QueueFundamentalPlan(true);
+ }
+ }
+ }
+
+ // If we aren't reaping missing threads at this point,
+ // we are done.
+ if (!delete_missing)
+ return;
+ // Otherwise scan for absent TID's.
+ std::vector<lldb::tid_t> missing_threads;
+ // If we are going to delete plans from the plan stack,
+ // then scan for absent TID's:
+ for (auto thread_plans : m_plans_list) {
+ lldb::tid_t cur_tid = thread_plans.first;
+ ThreadSP thread_sp = current_threads.FindThreadByID(cur_tid);
+ if (!thread_sp)
+ missing_threads.push_back(cur_tid);
+ }
+ for (lldb::tid_t tid : missing_threads) {
+ RemoveTID(tid);
+ }
+}
+
+void ThreadPlanStackMap::DumpPlans(Stream &strm,
+ lldb::DescriptionLevel desc_level,
+ bool internal, bool condense_if_trivial,
+ bool skip_unreported) {
+ for (auto elem : m_plans_list) {
+ lldb::tid_t tid = elem.first;
+ uint32_t index_id = 0;
+ ThreadSP thread_sp = m_process.GetThreadList().FindThreadByID(tid);
+
+ if (skip_unreported) {
+ if (!thread_sp)
+ continue;
+ }
+ if (thread_sp)
+ index_id = thread_sp->GetIndexID();
+
+ if (condense_if_trivial) {
+ if (!elem.second.AnyPlans() && !elem.second.AnyCompletedPlans() &&
+ !elem.second.AnyDiscardedPlans()) {
+ strm.Printf("thread #%u: tid = 0x%4.4" PRIx64 "\n", index_id, tid);
+ strm.IndentMore();
+ strm.Indent();
+ strm.Printf("No active thread plans\n");
+ strm.IndentLess();
+ return;
+ }
+ }
+
+ strm.Indent();
+ strm.Printf("thread #%u: tid = 0x%4.4" PRIx64 ":\n", index_id, tid);
+
+ elem.second.DumpThreadPlans(strm, desc_level, internal);
+ }
+}
+
+bool ThreadPlanStackMap::DumpPlansForTID(Stream &strm, lldb::tid_t tid,
+ lldb::DescriptionLevel desc_level,
+ bool internal,
+ bool condense_if_trivial,
+ bool skip_unreported) {
+ uint32_t index_id = 0;
+ ThreadSP thread_sp = m_process.GetThreadList().FindThreadByID(tid);
+
+ if (skip_unreported) {
+ if (!thread_sp) {
+ strm.Format("Unknown TID: {0}", tid);
+ return false;
+ }
+ }
+
+ if (thread_sp)
+ index_id = thread_sp->GetIndexID();
+ ThreadPlanStack *stack = Find(tid);
+ if (!stack) {
+ strm.Format("Unknown TID: {0}\n", tid);
+ return false;
+ }
+
+ if (condense_if_trivial) {
+ if (!stack->AnyPlans() && !stack->AnyCompletedPlans() &&
+ !stack->AnyDiscardedPlans()) {
+ strm.Printf("thread #%u: tid = 0x%4.4" PRIx64 "\n", index_id, tid);
+ strm.IndentMore();
+ strm.Indent();
+ strm.Printf("No active thread plans\n");
+ strm.IndentLess();
+ return true;
+ }
+ }
+
+ strm.Indent();
+ strm.Printf("thread #%u: tid = 0x%4.4" PRIx64 ":\n", index_id, tid);
+
+ stack->DumpThreadPlans(strm, desc_level, internal);
+ return true;
+}
+
+bool ThreadPlanStackMap::PrunePlansForTID(lldb::tid_t tid) {
+ // We only remove the plans for unreported TID's.
+ ThreadSP thread_sp = m_process.GetThreadList().FindThreadByID(tid);
+ if (thread_sp)
+ return false;
+
+ return RemoveTID(tid);
+}
diff --git a/lldb/source/Target/ThreadPlanStepInRange.cpp b/lldb/source/Target/ThreadPlanStepInRange.cpp
index ab1f6a21a862..c5f81d6665a1 100644
--- a/lldb/source/Target/ThreadPlanStepInRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepInRange.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadPlanStepInRange.cpp -------------------------------*- C++ -*-===//
+//===-- ThreadPlanStepInRange.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -69,7 +69,7 @@ void ThreadPlanStepInRange::SetupAvoidNoDebug(
LazyBool step_in_avoids_code_without_debug_info,
LazyBool step_out_avoids_code_without_debug_info) {
bool avoid_nodebug = true;
-
+ Thread &thread = GetThread();
switch (step_in_avoids_code_without_debug_info) {
case eLazyBoolYes:
avoid_nodebug = true;
@@ -78,7 +78,7 @@ void ThreadPlanStepInRange::SetupAvoidNoDebug(
avoid_nodebug = false;
break;
case eLazyBoolCalculate:
- avoid_nodebug = m_thread.GetStepInAvoidsNoDebug();
+ avoid_nodebug = thread.GetStepInAvoidsNoDebug();
break;
}
if (avoid_nodebug)
@@ -94,7 +94,7 @@ void ThreadPlanStepInRange::SetupAvoidNoDebug(
avoid_nodebug = false;
break;
case eLazyBoolCalculate:
- avoid_nodebug = m_thread.GetStepOutAvoidsNoDebug();
+ avoid_nodebug = thread.GetStepOutAvoidsNoDebug();
break;
}
if (avoid_nodebug)
@@ -145,9 +145,8 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
if (log) {
StreamString s;
- DumpAddress(
- s.AsRawOstream(), m_thread.GetRegisterContext()->GetPC(),
- m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
+ DumpAddress(s.AsRawOstream(), GetThread().GetRegisterContext()->GetPC(),
+ GetTarget().GetArchitecture().GetAddressByteSize());
LLDB_LOGF(log, "ThreadPlanStepInRange reached %s.", s.GetData());
}
@@ -180,6 +179,7 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
FrameComparison frame_order = CompareCurrentFrameToStartFrame();
+ Thread &thread = GetThread();
if (frame_order == eFrameCompareOlder ||
frame_order == eFrameCompareSameParent) {
// If we're in an older frame then we should stop.
@@ -189,7 +189,7 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
// I'm going to make the assumption that you wouldn't RETURN to a
// trampoline. So if we are in a trampoline we think the frame is older
// because the trampoline confused the backtracer.
- m_sub_plan_sp = m_thread.QueueThreadPlanForStepThrough(
+ m_sub_plan_sp = thread.QueueThreadPlanForStepThrough(
m_stack_id, false, stop_others, m_status);
if (!m_sub_plan_sp) {
// Otherwise check the ShouldStopHere for step out:
@@ -233,7 +233,7 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
// We may have set the plan up above in the FrameIsOlder section:
if (!m_sub_plan_sp)
- m_sub_plan_sp = m_thread.QueueThreadPlanForStepThrough(
+ m_sub_plan_sp = thread.QueueThreadPlanForStepThrough(
m_stack_id, false, stop_others, m_status);
if (log) {
@@ -254,10 +254,10 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
if (!m_sub_plan_sp && frame_order == eFrameCompareYounger &&
m_step_past_prologue) {
- lldb::StackFrameSP curr_frame = m_thread.GetStackFrameAtIndex(0);
+ lldb::StackFrameSP curr_frame = thread.GetStackFrameAtIndex(0);
if (curr_frame) {
size_t bytes_to_skip = 0;
- lldb::addr_t curr_addr = m_thread.GetRegisterContext()->GetPC();
+ lldb::addr_t curr_addr = thread.GetRegisterContext()->GetPC();
Address func_start_address;
SymbolContext sc = curr_frame->GetSymbolContext(eSymbolContextFunction |
@@ -265,25 +265,20 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
if (sc.function) {
func_start_address = sc.function->GetAddressRange().GetBaseAddress();
- if (curr_addr ==
- func_start_address.GetLoadAddress(
- m_thread.CalculateTarget().get()))
+ if (curr_addr == func_start_address.GetLoadAddress(&GetTarget()))
bytes_to_skip = sc.function->GetPrologueByteSize();
} else if (sc.symbol) {
func_start_address = sc.symbol->GetAddress();
- if (curr_addr ==
- func_start_address.GetLoadAddress(
- m_thread.CalculateTarget().get()))
+ if (curr_addr == func_start_address.GetLoadAddress(&GetTarget()))
bytes_to_skip = sc.symbol->GetPrologueByteSize();
}
if (bytes_to_skip == 0 && sc.symbol) {
- TargetSP target = m_thread.CalculateTarget();
- const Architecture *arch = target->GetArchitecturePlugin();
+ const Architecture *arch = GetTarget().GetArchitecturePlugin();
if (arch) {
Address curr_sec_addr;
- target->GetSectionLoadList().ResolveLoadAddress(curr_addr,
- curr_sec_addr);
+ GetTarget().GetSectionLoadList().ResolveLoadAddress(curr_addr,
+ curr_sec_addr);
bytes_to_skip = arch->GetBytesToSkip(*sc.symbol, curr_sec_addr);
}
}
@@ -293,7 +288,7 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP);
LLDB_LOGF(log, "Pushing past prologue ");
- m_sub_plan_sp = m_thread.QueueThreadPlanForRunToAddress(
+ m_sub_plan_sp = thread.QueueThreadPlanForRunToAddress(
false, func_start_address, true, m_status);
}
}
@@ -316,7 +311,7 @@ void ThreadPlanStepInRange::SetAvoidRegexp(const char *name) {
if (m_avoid_regexp_up)
*m_avoid_regexp_up = RegularExpression(name_ref);
else
- m_avoid_regexp_up.reset(new RegularExpression(name_ref));
+ m_avoid_regexp_up = std::make_unique<RegularExpression>(name_ref);
}
void ThreadPlanStepInRange::SetDefaultFlagValue(uint32_t new_value) {
@@ -486,15 +481,16 @@ bool ThreadPlanStepInRange::DoWillResume(lldb::StateType resume_state,
bool current_plan) {
m_virtual_step = false;
if (resume_state == eStateStepping && current_plan) {
+ Thread &thread = GetThread();
// See if we are about to step over a virtual inlined call.
- bool step_without_resume = m_thread.DecrementCurrentInlinedDepth();
+ bool step_without_resume = thread.DecrementCurrentInlinedDepth();
if (step_without_resume) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
LLDB_LOGF(log,
"ThreadPlanStepInRange::DoWillResume: returning false, "
"inline_depth: %d",
- m_thread.GetCurrentInlinedDepth());
- SetStopInfo(StopInfo::CreateStopReasonToTrace(m_thread));
+ thread.GetCurrentInlinedDepth());
+ SetStopInfo(StopInfo::CreateStopReasonToTrace(thread));
// FIXME: Maybe it would be better to create a InlineStep stop reason, but
// then
diff --git a/lldb/source/Target/ThreadPlanStepInstruction.cpp b/lldb/source/Target/ThreadPlanStepInstruction.cpp
index afcc9d608b27..c0da735c44b6 100644
--- a/lldb/source/Target/ThreadPlanStepInstruction.cpp
+++ b/lldb/source/Target/ThreadPlanStepInstruction.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadPlanStepInstruction.cpp ---------------------------*- C++ -*-===//
+//===-- ThreadPlanStepInstruction.cpp -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -36,14 +36,15 @@ ThreadPlanStepInstruction::ThreadPlanStepInstruction(Thread &thread,
ThreadPlanStepInstruction::~ThreadPlanStepInstruction() = default;
void ThreadPlanStepInstruction::SetUpState() {
- m_instruction_addr = m_thread.GetRegisterContext()->GetPC(0);
- StackFrameSP start_frame_sp(m_thread.GetStackFrameAtIndex(0));
+ Thread &thread = GetThread();
+ m_instruction_addr = thread.GetRegisterContext()->GetPC(0);
+ StackFrameSP start_frame_sp(thread.GetStackFrameAtIndex(0));
m_stack_id = start_frame_sp->GetStackID();
m_start_has_symbol =
start_frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol != nullptr;
- StackFrameSP parent_frame_sp = m_thread.GetStackFrameAtIndex(1);
+ StackFrameSP parent_frame_sp = thread.GetStackFrameAtIndex(1);
if (parent_frame_sp)
m_parent_frame_id = parent_frame_sp->GetStackID();
}
@@ -95,18 +96,19 @@ bool ThreadPlanStepInstruction::DoPlanExplainsStop(Event *event_ptr) {
bool ThreadPlanStepInstruction::IsPlanStale() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
- StackID cur_frame_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
+ Thread &thread = GetThread();
+ StackID cur_frame_id = thread.GetStackFrameAtIndex(0)->GetStackID();
if (cur_frame_id == m_stack_id) {
// Set plan Complete when we reach next instruction
- uint64_t pc = m_thread.GetRegisterContext()->GetPC(0);
- uint32_t max_opcode_size = m_thread.CalculateTarget()
- ->GetArchitecture().GetMaximumOpcodeByteSize();
+ uint64_t pc = thread.GetRegisterContext()->GetPC(0);
+ uint32_t max_opcode_size =
+ GetTarget().GetArchitecture().GetMaximumOpcodeByteSize();
bool next_instruction_reached = (pc > m_instruction_addr) &&
(pc <= m_instruction_addr + max_opcode_size);
if (next_instruction_reached) {
SetPlanComplete();
}
- return (m_thread.GetRegisterContext()->GetPC(0) != m_instruction_addr);
+ return (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
@@ -123,10 +125,10 @@ bool ThreadPlanStepInstruction::IsPlanStale() {
}
bool ThreadPlanStepInstruction::ShouldStop(Event *event_ptr) {
+ Thread &thread = GetThread();
if (m_step_over) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
-
- StackFrameSP cur_frame_sp = m_thread.GetStackFrameAtIndex(0);
+ StackFrameSP cur_frame_sp = thread.GetStackFrameAtIndex(0);
if (!cur_frame_sp) {
LLDB_LOGF(
log,
@@ -138,7 +140,7 @@ bool ThreadPlanStepInstruction::ShouldStop(Event *event_ptr) {
StackID cur_frame_zero_id = cur_frame_sp->GetStackID();
if (cur_frame_zero_id == m_stack_id || m_stack_id < cur_frame_zero_id) {
- if (m_thread.GetRegisterContext()->GetPC(0) != m_instruction_addr) {
+ if (thread.GetRegisterContext()->GetPC(0) != m_instruction_addr) {
if (--m_iteration_count <= 0) {
SetPlanComplete();
return true;
@@ -152,7 +154,7 @@ bool ThreadPlanStepInstruction::ShouldStop(Event *event_ptr) {
return false;
} else {
// We've stepped in, step back out again:
- StackFrame *return_frame = m_thread.GetStackFrameAtIndex(1).get();
+ StackFrame *return_frame = thread.GetStackFrameAtIndex(1).get();
if (return_frame) {
if (return_frame->GetStackID() != m_parent_frame_id ||
m_start_has_symbol) {
@@ -162,7 +164,7 @@ bool ThreadPlanStepInstruction::ShouldStop(Event *event_ptr) {
if (cur_frame_sp->IsInlined()) {
StackFrameSP parent_frame_sp =
- m_thread.GetFrameWithStackID(m_stack_id);
+ thread.GetFrameWithStackID(m_stack_id);
if (parent_frame_sp &&
parent_frame_sp->GetConcreteFrameIndex() ==
@@ -181,24 +183,20 @@ bool ThreadPlanStepInstruction::ShouldStop(Event *event_ptr) {
StreamString s;
s.PutCString("Stepped in to: ");
addr_t stop_addr =
- m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
+ thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
DumpAddress(s.AsRawOstream(), stop_addr,
- m_thread.CalculateTarget()
- ->GetArchitecture()
- .GetAddressByteSize());
+ GetTarget().GetArchitecture().GetAddressByteSize());
s.PutCString(" stepping out to: ");
addr_t return_addr = return_frame->GetRegisterContext()->GetPC();
DumpAddress(s.AsRawOstream(), return_addr,
- m_thread.CalculateTarget()
- ->GetArchitecture()
- .GetAddressByteSize());
+ GetTarget().GetArchitecture().GetAddressByteSize());
LLDB_LOGF(log, "%s.", s.GetData());
}
// StepInstruction should probably have the tri-state RunMode, but
// for now it is safer to run others.
const bool stop_others = false;
- m_thread.QueueThreadPlanForStepOutNoShouldStop(
+ thread.QueueThreadPlanForStepOutNoShouldStop(
false, nullptr, true, stop_others, eVoteNo, eVoteNoOpinion, 0,
m_status);
return false;
@@ -219,7 +217,7 @@ bool ThreadPlanStepInstruction::ShouldStop(Event *event_ptr) {
}
}
} else {
- lldb::addr_t pc_addr = m_thread.GetRegisterContext()->GetPC(0);
+ lldb::addr_t pc_addr = thread.GetRegisterContext()->GetPC(0);
if (pc_addr != m_instruction_addr) {
if (--m_iteration_count <= 0) {
SetPlanComplete();
diff --git a/lldb/source/Target/ThreadPlanStepOut.cpp b/lldb/source/Target/ThreadPlanStepOut.cpp
index f15a343aaa38..9f0749c0fdb3 100644
--- a/lldb/source/Target/ThreadPlanStepOut.cpp
+++ b/lldb/source/Target/ThreadPlanStepOut.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadPlanStepOut.cpp -----------------------------------*- C++ -*-===//
+//===-- ThreadPlanStepOut.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -47,13 +47,11 @@ ThreadPlanStepOut::ThreadPlanStepOut(
SetFlagsToDefault();
SetupAvoidNoDebug(step_out_avoids_code_without_debug_info);
- m_step_from_insn = m_thread.GetRegisterContext()->GetPC(0);
+ m_step_from_insn = thread.GetRegisterContext()->GetPC(0);
uint32_t return_frame_index = frame_idx + 1;
- StackFrameSP return_frame_sp(
- m_thread.GetStackFrameAtIndex(return_frame_index));
- StackFrameSP immediate_return_from_sp(
- m_thread.GetStackFrameAtIndex(frame_idx));
+ StackFrameSP return_frame_sp(thread.GetStackFrameAtIndex(return_frame_index));
+ StackFrameSP immediate_return_from_sp(thread.GetStackFrameAtIndex(frame_idx));
if (!return_frame_sp || !immediate_return_from_sp)
return; // we can't do anything here. ValidatePlan() will return false.
@@ -63,7 +61,7 @@ ThreadPlanStepOut::ThreadPlanStepOut(
m_stepped_past_frames.push_back(return_frame_sp);
++return_frame_index;
- return_frame_sp = m_thread.GetStackFrameAtIndex(return_frame_index);
+ return_frame_sp = thread.GetStackFrameAtIndex(return_frame_index);
// We never expect to see an artificial frame without a regular ancestor.
// If this happens, log the issue and defensively refuse to step out.
@@ -85,7 +83,7 @@ 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 = std::make_shared<ThreadPlanStepOut>(
- m_thread, nullptr, false, stop_others, eVoteNoOpinion, eVoteNoOpinion,
+ thread, nullptr, false, stop_others, eVoteNoOpinion, eVoteNoOpinion,
frame_idx - 1, eLazyBoolNo, continue_to_next_branch);
static_cast<ThreadPlanStepOut *>(m_step_out_to_inline_plan_sp.get())
->SetShouldStopHereCallbacks(nullptr, nullptr);
@@ -114,28 +112,22 @@ ThreadPlanStepOut::ThreadPlanStepOut(
range = return_address_sc.line_entry.GetSameLineContiguousAddressRange(
include_inlined_functions);
if (range.GetByteSize() > 0) {
- return_address =
- m_thread.GetProcess()->AdvanceAddressToNextBranchInstruction(
- return_address, range);
+ return_address = m_process.AdvanceAddressToNextBranchInstruction(
+ return_address, range);
}
}
}
- m_return_addr =
- return_address.GetLoadAddress(&m_thread.GetProcess()->GetTarget());
+ m_return_addr = return_address.GetLoadAddress(&m_process.GetTarget());
if (m_return_addr == LLDB_INVALID_ADDRESS)
return;
// Perform some additional validation on the return address.
uint32_t permissions = 0;
- if (!m_thread.GetProcess()->GetLoadAddressPermissions(m_return_addr,
- permissions)) {
- m_constructor_errors.Printf("Return address (0x%" PRIx64
- ") permissions not found.",
- m_return_addr);
- LLDB_LOGF(log, "ThreadPlanStepOut(%p): %s", static_cast<void *>(this),
- m_constructor_errors.GetData());
- return;
+ if (!m_process.GetLoadAddressPermissions(m_return_addr, permissions)) {
+ LLDB_LOGF(log, "ThreadPlanStepOut(%p): Return address (0x%" PRIx64
+ ") permissions not found.", static_cast<void *>(this),
+ m_return_addr);
} else if (!(permissions & ePermissionsExecutable)) {
m_constructor_errors.Printf("Return address (0x%" PRIx64
") did not point to executable memory.",
@@ -145,14 +137,13 @@ ThreadPlanStepOut::ThreadPlanStepOut(
return;
}
- Breakpoint *return_bp = m_thread.CalculateTarget()
- ->CreateBreakpoint(m_return_addr, true, false)
- .get();
+ Breakpoint *return_bp =
+ GetTarget().CreateBreakpoint(m_return_addr, true, false).get();
if (return_bp != nullptr) {
if (return_bp->IsHardware() && !return_bp->HasResolvedLocations())
m_could_not_resolve_hw_bp = true;
- return_bp->SetThreadID(m_thread.GetID());
+ return_bp->SetThreadID(m_tid);
m_return_bp_id = return_bp->GetID();
return_bp->SetBreakpointKind("step-out");
}
@@ -178,7 +169,7 @@ void ThreadPlanStepOut::SetupAvoidNoDebug(
avoid_nodebug = false;
break;
case eLazyBoolCalculate:
- avoid_nodebug = m_thread.GetStepOutAvoidsNoDebug();
+ avoid_nodebug = GetThread().GetStepOutAvoidsNoDebug();
break;
}
if (avoid_nodebug)
@@ -188,15 +179,16 @@ void ThreadPlanStepOut::SetupAvoidNoDebug(
}
void ThreadPlanStepOut::DidPush() {
+ Thread &thread = GetThread();
if (m_step_out_to_inline_plan_sp)
- m_thread.QueueThreadPlan(m_step_out_to_inline_plan_sp, false);
+ thread.QueueThreadPlan(m_step_out_to_inline_plan_sp, false);
else if (m_step_through_inline_plan_sp)
- m_thread.QueueThreadPlan(m_step_through_inline_plan_sp, false);
+ thread.QueueThreadPlan(m_step_through_inline_plan_sp, false);
}
ThreadPlanStepOut::~ThreadPlanStepOut() {
if (m_return_bp_id != LLDB_INVALID_BREAK_ID)
- m_thread.CalculateTarget()->RemoveBreakpointByID(m_return_bp_id);
+ GetTarget().RemoveBreakpointByID(m_return_bp_id);
}
void ThreadPlanStepOut::GetDescription(Stream *s,
@@ -212,7 +204,7 @@ void ThreadPlanStepOut::GetDescription(Stream *s,
s->Printf("Stepping out from ");
Address tmp_address;
if (tmp_address.SetLoadAddress(m_step_from_insn, &GetTarget())) {
- tmp_address.Dump(s, &GetThread(), Address::DumpStyleResolvedDescription,
+ tmp_address.Dump(s, &m_process, Address::DumpStyleResolvedDescription,
Address::DumpStyleLoadAddress);
} else {
s->Printf("address 0x%" PRIx64 "", (uint64_t)m_step_from_insn);
@@ -224,7 +216,7 @@ void ThreadPlanStepOut::GetDescription(Stream *s,
s->Printf(" returning to frame at ");
if (tmp_address.SetLoadAddress(m_return_addr, &GetTarget())) {
- tmp_address.Dump(s, &GetThread(), Address::DumpStyleResolvedDescription,
+ tmp_address.Dump(s, &m_process, Address::DumpStyleResolvedDescription,
Address::DumpStyleLoadAddress);
} else {
s->Printf("address 0x%" PRIx64 "", (uint64_t)m_return_addr);
@@ -235,6 +227,9 @@ void ThreadPlanStepOut::GetDescription(Stream *s,
}
}
+ if (m_stepped_past_frames.empty())
+ return;
+
s->Printf("\n");
for (StackFrameSP frame_sp : m_stepped_past_frames) {
s->Printf("Stepped out past: ");
@@ -296,12 +291,12 @@ bool ThreadPlanStepOut::DoPlanExplainsStop(Event *event_ptr) {
// 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()));
+ m_process.GetBreakpointSiteList().FindByID(stop_info_sp->GetValue()));
if (site_sp && site_sp->IsBreakpointAtThisSite(m_return_bp_id)) {
bool done;
- StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
+ StackID frame_zero_id =
+ GetThread().GetStackFrameAtIndex(0)->GetStackID();
if (m_step_out_to_id == frame_zero_id)
done = true;
@@ -368,7 +363,7 @@ bool ThreadPlanStepOut::ShouldStop(Event *event_ptr) {
}
if (!done) {
- StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
+ StackID frame_zero_id = GetThread().GetStackFrameAtIndex(0)->GetStackID();
done = !(frame_zero_id < m_step_out_to_id);
}
@@ -402,8 +397,7 @@ bool ThreadPlanStepOut::DoWillResume(StateType resume_state,
return false;
if (current_plan) {
- Breakpoint *return_bp =
- m_thread.CalculateTarget()->GetBreakpointByID(m_return_bp_id).get();
+ Breakpoint *return_bp = GetTarget().GetBreakpointByID(m_return_bp_id).get();
if (return_bp != nullptr)
return_bp->SetEnabled(true);
}
@@ -412,8 +406,7 @@ bool ThreadPlanStepOut::DoWillResume(StateType resume_state,
bool ThreadPlanStepOut::WillStop() {
if (m_return_bp_id != LLDB_INVALID_BREAK_ID) {
- Breakpoint *return_bp =
- m_thread.CalculateTarget()->GetBreakpointByID(m_return_bp_id).get();
+ Breakpoint *return_bp = GetTarget().GetBreakpointByID(m_return_bp_id).get();
if (return_bp != nullptr)
return_bp->SetEnabled(false);
}
@@ -434,7 +427,7 @@ bool ThreadPlanStepOut::MischiefManaged() {
if (log)
LLDB_LOGF(log, "Completed step out plan.");
if (m_return_bp_id != LLDB_INVALID_BREAK_ID) {
- m_thread.CalculateTarget()->RemoveBreakpointByID(m_return_bp_id);
+ GetTarget().RemoveBreakpointByID(m_return_bp_id);
m_return_bp_id = LLDB_INVALID_BREAK_ID;
}
@@ -449,7 +442,8 @@ bool ThreadPlanStepOut::QueueInlinedStepPlan(bool queue_now) {
// Now figure out the range of this inlined block, and set up a "step through
// range" plan for that. If we've been provided with a context, then use the
// block in that context.
- StackFrameSP immediate_return_from_sp(m_thread.GetStackFrameAtIndex(0));
+ Thread &thread = GetThread();
+ StackFrameSP immediate_return_from_sp(thread.GetStackFrameAtIndex(0));
if (!immediate_return_from_sp)
return false;
@@ -476,7 +470,7 @@ bool ThreadPlanStepOut::QueueInlinedStepPlan(bool queue_now) {
m_step_through_inline_plan_sp =
std::make_shared<ThreadPlanStepOverRange>(
- m_thread, inline_range, inlined_sc, run_mode, avoid_no_debug);
+ thread, inline_range, inlined_sc, run_mode, avoid_no_debug);
ThreadPlanStepOverRange *step_through_inline_plan_ptr =
static_cast<ThreadPlanStepOverRange *>(
m_step_through_inline_plan_sp.get());
@@ -496,7 +490,7 @@ bool ThreadPlanStepOut::QueueInlinedStepPlan(bool queue_now) {
}
if (queue_now)
- m_thread.QueueThreadPlan(m_step_through_inline_plan_sp, false);
+ thread.QueueThreadPlan(m_step_through_inline_plan_sp, false);
return true;
}
}
@@ -517,10 +511,10 @@ void ThreadPlanStepOut::CalculateReturnValue() {
m_immediate_step_from_function->GetCompilerType()
.GetFunctionReturnType();
if (return_compiler_type) {
- lldb::ABISP abi_sp = m_thread.GetProcess()->GetABI();
+ lldb::ABISP abi_sp = m_process.GetABI();
if (abi_sp)
m_return_valobj_sp =
- abi_sp->GetReturnValueObject(m_thread, return_compiler_type);
+ abi_sp->GetReturnValueObject(GetThread(), return_compiler_type);
}
}
}
@@ -529,6 +523,6 @@ bool ThreadPlanStepOut::IsPlanStale() {
// If we are still lower on the stack than the frame we are returning to,
// then there's something for us to do. Otherwise, we're stale.
- StackID frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
+ StackID frame_zero_id = GetThread().GetStackFrameAtIndex(0)->GetStackID();
return !(frame_zero_id < m_step_out_to_id);
}
diff --git a/lldb/source/Target/ThreadPlanStepOverBreakpoint.cpp b/lldb/source/Target/ThreadPlanStepOverBreakpoint.cpp
index 725669b1e9a8..f3d35a91fcbc 100644
--- a/lldb/source/Target/ThreadPlanStepOverBreakpoint.cpp
+++ b/lldb/source/Target/ThreadPlanStepOverBreakpoint.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadPlanStepOverBreakpoint.cpp ------------------------*- C++ -*-===//
+//===-- ThreadPlanStepOverBreakpoint.cpp ----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -30,9 +30,9 @@ ThreadPlanStepOverBreakpoint::ThreadPlanStepOverBreakpoint(Thread &thread)
m_auto_continue(false), m_reenabled_breakpoint_site(false)
{
- m_breakpoint_addr = m_thread.GetRegisterContext()->GetPC();
+ m_breakpoint_addr = thread.GetRegisterContext()->GetPC();
m_breakpoint_site_id =
- m_thread.GetProcess()->GetBreakpointSiteList().FindIDByAddress(
+ thread.GetProcess()->GetBreakpointSiteList().FindIDByAddress(
m_breakpoint_addr);
}
@@ -86,7 +86,7 @@ bool ThreadPlanStepOverBreakpoint::DoPlanExplainsStop(Event *event_ptr) {
// Be careful, however, as we may have "seen a breakpoint under the PC
// because we stopped without changing the PC, in which case we do want
// to re-claim this stop so we'll try again.
- lldb::addr_t pc_addr = m_thread.GetRegisterContext()->GetPC();
+ lldb::addr_t pc_addr = GetThread().GetRegisterContext()->GetPC();
if (pc_addr == m_breakpoint_addr) {
LLDB_LOGF(log,
@@ -120,10 +120,9 @@ bool ThreadPlanStepOverBreakpoint::DoWillResume(StateType resume_state,
bool current_plan) {
if (current_plan) {
BreakpointSiteSP bp_site_sp(
- m_thread.GetProcess()->GetBreakpointSiteList().FindByAddress(
- m_breakpoint_addr));
+ m_process.GetBreakpointSiteList().FindByAddress(m_breakpoint_addr));
if (bp_site_sp && bp_site_sp->IsEnabled()) {
- m_thread.GetProcess()->DisableBreakpointSite(bp_site_sp.get());
+ m_process.DisableBreakpointSite(bp_site_sp.get());
m_reenabled_breakpoint_site = false;
}
}
@@ -140,7 +139,7 @@ void ThreadPlanStepOverBreakpoint::WillPop() {
}
bool ThreadPlanStepOverBreakpoint::MischiefManaged() {
- lldb::addr_t pc_addr = m_thread.GetRegisterContext()->GetPC();
+ lldb::addr_t pc_addr = GetThread().GetRegisterContext()->GetPC();
if (pc_addr == m_breakpoint_addr) {
// If we are still at the PC of our breakpoint, then for some reason we
@@ -161,10 +160,9 @@ void ThreadPlanStepOverBreakpoint::ReenableBreakpointSite() {
if (!m_reenabled_breakpoint_site) {
m_reenabled_breakpoint_site = true;
BreakpointSiteSP bp_site_sp(
- m_thread.GetProcess()->GetBreakpointSiteList().FindByAddress(
- m_breakpoint_addr));
+ m_process.GetBreakpointSiteList().FindByAddress(m_breakpoint_addr));
if (bp_site_sp) {
- m_thread.GetProcess()->EnableBreakpointSite(bp_site_sp.get());
+ m_process.EnableBreakpointSite(bp_site_sp.get());
}
}
}
@@ -181,5 +179,5 @@ bool ThreadPlanStepOverBreakpoint::ShouldAutoContinue(Event *event_ptr) {
}
bool ThreadPlanStepOverBreakpoint::IsPlanStale() {
- return m_thread.GetRegisterContext()->GetPC() != m_breakpoint_addr;
+ return GetThread().GetRegisterContext()->GetPC() != m_breakpoint_addr;
}
diff --git a/lldb/source/Target/ThreadPlanStepOverRange.cpp b/lldb/source/Target/ThreadPlanStepOverRange.cpp
index 3dc1967e6d4e..1bf3d5352c5b 100644
--- a/lldb/source/Target/ThreadPlanStepOverRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepOverRange.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadPlanStepOverRange.cpp -----------------------------*- C++ -*-===//
+//===-- ThreadPlanStepOverRange.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -85,7 +85,7 @@ void ThreadPlanStepOverRange::SetupAvoidNoDebug(
avoid_nodebug = false;
break;
case eLazyBoolCalculate:
- avoid_nodebug = m_thread.GetStepOutAvoidsNoDebug();
+ avoid_nodebug = GetThread().GetStepOutAvoidsNoDebug();
break;
}
if (avoid_nodebug)
@@ -125,12 +125,12 @@ bool ThreadPlanStepOverRange::IsEquivalentContext(
bool ThreadPlanStepOverRange::ShouldStop(Event *event_ptr) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
+ Thread &thread = GetThread();
if (log) {
StreamString s;
- DumpAddress(
- s.AsRawOstream(), m_thread.GetRegisterContext()->GetPC(),
- m_thread.CalculateTarget()->GetArchitecture().GetAddressByteSize());
+ DumpAddress(s.AsRawOstream(), thread.GetRegisterContext()->GetPC(),
+ GetTarget().GetArchitecture().GetAddressByteSize());
LLDB_LOGF(log, "ThreadPlanStepOverRange reached %s.", s.GetData());
}
@@ -151,8 +151,8 @@ bool ThreadPlanStepOverRange::ShouldStop(Event *event_ptr) {
// because the trampoline confused the backtracer. As below, we step
// through first, and then try to figure out how to get back out again.
- new_plan_sp = m_thread.QueueThreadPlanForStepThrough(m_stack_id, false,
- stop_others, m_status);
+ new_plan_sp = thread.QueueThreadPlanForStepThrough(m_stack_id, false,
+ stop_others, m_status);
if (new_plan_sp && log)
LLDB_LOGF(log,
@@ -161,7 +161,7 @@ bool ThreadPlanStepOverRange::ShouldStop(Event *event_ptr) {
// Make sure we really are in a new frame. Do that by unwinding and seeing
// if the start function really is our start function...
for (uint32_t i = 1;; ++i) {
- StackFrameSP older_frame_sp = m_thread.GetStackFrameAtIndex(i);
+ StackFrameSP older_frame_sp = thread.GetStackFrameAtIndex(i);
if (!older_frame_sp) {
// We can't unwind the next frame we should just get out of here &
// stop...
@@ -171,12 +171,16 @@ bool ThreadPlanStepOverRange::ShouldStop(Event *event_ptr) {
const SymbolContext &older_context =
older_frame_sp->GetSymbolContext(eSymbolContextEverything);
if (IsEquivalentContext(older_context)) {
- new_plan_sp = m_thread.QueueThreadPlanForStepOutNoShouldStop(
+ // If we have the next-branch-breakpoint in the range, we can just
+ // rely on that breakpoint to trigger once we return to the range.
+ if (m_next_branch_bp_sp)
+ return false;
+ new_plan_sp = thread.QueueThreadPlanForStepOutNoShouldStop(
false, nullptr, true, stop_others, eVoteNo, eVoteNoOpinion, 0,
m_status, true);
break;
} else {
- new_plan_sp = m_thread.QueueThreadPlanForStepThrough(
+ new_plan_sp = thread.QueueThreadPlanForStepThrough(
m_stack_id, false, stop_others, m_status);
// If we found a way through, then we should stop recursing.
if (new_plan_sp)
@@ -196,8 +200,8 @@ bool ThreadPlanStepOverRange::ShouldStop(Event *event_ptr) {
// we are in a stub then it's likely going to be hard to get out from
// here. It is probably easiest to step into the stub, and then it will
// be straight-forward to step out.
- new_plan_sp = m_thread.QueueThreadPlanForStepThrough(
- m_stack_id, false, stop_others, m_status);
+ new_plan_sp = thread.QueueThreadPlanForStepThrough(m_stack_id, false,
+ stop_others, m_status);
} else {
// The current clang (at least through 424) doesn't always get the
// address range for the DW_TAG_inlined_subroutines right, so that when
@@ -212,7 +216,7 @@ bool ThreadPlanStepOverRange::ShouldStop(Event *event_ptr) {
if (m_addr_context.line_entry.IsValid()) {
SymbolContext sc;
- StackFrameSP frame_sp = m_thread.GetStackFrameAtIndex(0);
+ StackFrameSP frame_sp = thread.GetStackFrameAtIndex(0);
sc = frame_sp->GetSymbolContext(eSymbolContextEverything);
if (sc.line_entry.IsValid()) {
if (sc.line_entry.original_file !=
@@ -278,7 +282,7 @@ bool ThreadPlanStepOverRange::ShouldStop(Event *event_ptr) {
m_addr_context.line_entry.original_file) {
const bool abort_other_plans = false;
const RunMode stop_other_threads = RunMode::eAllThreads;
- lldb::addr_t cur_pc = m_thread.GetStackFrameAtIndex(0)
+ lldb::addr_t cur_pc = thread.GetStackFrameAtIndex(0)
->GetRegisterContext()
->GetPC();
AddressRange step_range(
@@ -286,7 +290,7 @@ bool ThreadPlanStepOverRange::ShouldStop(Event *event_ptr) {
next_line_address.GetLoadAddress(&GetTarget()) -
cur_pc);
- new_plan_sp = m_thread.QueueThreadPlanForStepOverRange(
+ new_plan_sp = thread.QueueThreadPlanForStepOverRange(
abort_other_plans, step_range, sc, stop_other_threads,
m_status);
break;
@@ -365,23 +369,24 @@ bool ThreadPlanStepOverRange::DoWillResume(lldb::StateType resume_state,
if (resume_state != eStateSuspended && m_first_resume) {
m_first_resume = false;
if (resume_state == eStateStepping && current_plan) {
+ Thread &thread = GetThread();
// See if we are about to step over an inlined call in the middle of the
// inlined stack, if so figure out its extents and reset our range to
// step over that.
- bool in_inlined_stack = m_thread.DecrementCurrentInlinedDepth();
+ bool in_inlined_stack = thread.DecrementCurrentInlinedDepth();
if (in_inlined_stack) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
LLDB_LOGF(log,
"ThreadPlanStepInRange::DoWillResume: adjusting range to "
"the frame at inlined depth %d.",
- m_thread.GetCurrentInlinedDepth());
- StackFrameSP stack_sp = m_thread.GetStackFrameAtIndex(0);
+ thread.GetCurrentInlinedDepth());
+ StackFrameSP stack_sp = thread.GetStackFrameAtIndex(0);
if (stack_sp) {
Block *frame_block = stack_sp->GetFrameBlock();
- lldb::addr_t curr_pc = m_thread.GetRegisterContext()->GetPC();
+ lldb::addr_t curr_pc = thread.GetRegisterContext()->GetPC();
AddressRange my_range;
if (frame_block->GetRangeContainingLoadAddress(
- curr_pc, m_thread.GetProcess()->GetTarget(), my_range)) {
+ curr_pc, m_process.GetTarget(), my_range)) {
m_address_ranges.clear();
m_address_ranges.push_back(my_range);
if (log) {
@@ -390,11 +395,7 @@ bool ThreadPlanStepOverRange::DoWillResume(lldb::StateType resume_state,
frame_block->GetInlinedFunctionInfo();
const char *name;
if (inline_info)
- name =
- inline_info
- ->GetName(frame_block->CalculateSymbolContextFunction()
- ->GetLanguage())
- .AsCString();
+ name = inline_info->GetName().AsCString();
else
name = "<unknown-notinlined>";
diff --git a/lldb/source/Target/ThreadPlanStepRange.cpp b/lldb/source/Target/ThreadPlanStepRange.cpp
index d1c56165da50..f4b2ee3d08a2 100644
--- a/lldb/source/Target/ThreadPlanStepRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepRange.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadPlanStepRange.cpp ---------------------------------*- C++ -*-===//
+//===-- ThreadPlanStepRange.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -41,8 +41,8 @@ ThreadPlanStepRange::ThreadPlanStepRange(ThreadPlanKind kind, const char *name,
m_given_ranges_only(given_ranges_only) {
m_use_fast_step = GetTarget().GetUseFastStepping();
AddRange(range);
- m_stack_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
- StackFrameSP parent_stack = m_thread.GetStackFrameAtIndex(1);
+ m_stack_id = thread.GetStackFrameAtIndex(0)->GetStackID();
+ StackFrameSP parent_stack = thread.GetStackFrameAtIndex(1);
if (parent_stack)
m_parent_stack_id = parent_stack->GetStackID();
}
@@ -88,13 +88,11 @@ void ThreadPlanStepRange::AddRange(const AddressRange &new_range) {
void ThreadPlanStepRange::DumpRanges(Stream *s) {
size_t num_ranges = m_address_ranges.size();
if (num_ranges == 1) {
- m_address_ranges[0].Dump(s, m_thread.CalculateTarget().get(),
- Address::DumpStyleLoadAddress);
+ m_address_ranges[0].Dump(s, &GetTarget(), Address::DumpStyleLoadAddress);
} else {
for (size_t i = 0; i < num_ranges; i++) {
s->Printf(" %" PRIu64 ": ", uint64_t(i));
- m_address_ranges[i].Dump(s, m_thread.CalculateTarget().get(),
- Address::DumpStyleLoadAddress);
+ m_address_ranges[i].Dump(s, &GetTarget(), Address::DumpStyleLoadAddress);
}
}
}
@@ -102,20 +100,20 @@ void ThreadPlanStepRange::DumpRanges(Stream *s) {
bool ThreadPlanStepRange::InRange() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
bool ret_value = false;
-
- lldb::addr_t pc_load_addr = m_thread.GetRegisterContext()->GetPC();
+ Thread &thread = GetThread();
+ lldb::addr_t pc_load_addr = thread.GetRegisterContext()->GetPC();
size_t num_ranges = m_address_ranges.size();
for (size_t i = 0; i < num_ranges; i++) {
- ret_value = m_address_ranges[i].ContainsLoadAddress(
- pc_load_addr, m_thread.CalculateTarget().get());
+ ret_value =
+ m_address_ranges[i].ContainsLoadAddress(pc_load_addr, &GetTarget());
if (ret_value)
break;
}
if (!ret_value && !m_given_ranges_only) {
// See if we've just stepped to another part of the same line number...
- StackFrame *frame = m_thread.GetStackFrameAtIndex(0).get();
+ StackFrame *frame = thread.GetStackFrameAtIndex(0).get();
SymbolContext new_context(
frame->GetSymbolContext(eSymbolContextEverything));
@@ -132,8 +130,8 @@ bool ThreadPlanStepRange::InRange() {
ret_value = true;
if (log) {
StreamString s;
- m_addr_context.line_entry.Dump(&s, m_thread.CalculateTarget().get(),
- true, Address::DumpStyleLoadAddress,
+ m_addr_context.line_entry.Dump(&s, &GetTarget(), true,
+ Address::DumpStyleLoadAddress,
Address::DumpStyleLoadAddress, true);
LLDB_LOGF(
@@ -151,8 +149,8 @@ bool ThreadPlanStepRange::InRange() {
ret_value = true;
if (log) {
StreamString s;
- m_addr_context.line_entry.Dump(&s, m_thread.CalculateTarget().get(),
- true, Address::DumpStyleLoadAddress,
+ m_addr_context.line_entry.Dump(&s, &GetTarget(), true,
+ Address::DumpStyleLoadAddress,
Address::DumpStyleLoadAddress, true);
LLDB_LOGF(log,
@@ -161,7 +159,7 @@ bool ThreadPlanStepRange::InRange() {
s.GetData());
}
} else if (new_context.line_entry.range.GetBaseAddress().GetLoadAddress(
- m_thread.CalculateTarget().get()) != pc_load_addr) {
+ &GetTarget()) != pc_load_addr) {
// Another thing that sometimes happens here is that we step out of
// one line into the MIDDLE of another line. So far I mostly see
// this due to bugs in the debug information. But we probably don't
@@ -174,8 +172,8 @@ bool ThreadPlanStepRange::InRange() {
ret_value = true;
if (log) {
StreamString s;
- m_addr_context.line_entry.Dump(&s, m_thread.CalculateTarget().get(),
- true, Address::DumpStyleLoadAddress,
+ m_addr_context.line_entry.Dump(&s, &GetTarget(), true,
+ Address::DumpStyleLoadAddress,
Address::DumpStyleLoadAddress, true);
LLDB_LOGF(log,
@@ -195,14 +193,14 @@ bool ThreadPlanStepRange::InRange() {
}
bool ThreadPlanStepRange::InSymbol() {
- lldb::addr_t cur_pc = m_thread.GetRegisterContext()->GetPC();
+ lldb::addr_t cur_pc = GetThread().GetRegisterContext()->GetPC();
if (m_addr_context.function != nullptr) {
return m_addr_context.function->GetAddressRange().ContainsLoadAddress(
- cur_pc, m_thread.CalculateTarget().get());
+ cur_pc, &GetTarget());
} else if (m_addr_context.symbol && m_addr_context.symbol->ValueIsAddress()) {
AddressRange range(m_addr_context.symbol->GetAddressRef(),
m_addr_context.symbol->GetByteSize());
- return range.ContainsLoadAddress(cur_pc, m_thread.CalculateTarget().get());
+ return range.ContainsLoadAddress(cur_pc, &GetTarget());
}
return false;
}
@@ -216,15 +214,15 @@ bool ThreadPlanStepRange::InSymbol() {
lldb::FrameComparison ThreadPlanStepRange::CompareCurrentFrameToStartFrame() {
FrameComparison frame_order;
-
- StackID cur_frame_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
+ Thread &thread = GetThread();
+ StackID cur_frame_id = thread.GetStackFrameAtIndex(0)->GetStackID();
if (cur_frame_id == m_stack_id) {
frame_order = eFrameCompareEqual;
} else if (cur_frame_id < m_stack_id) {
frame_order = eFrameCompareYounger;
} else {
- StackFrameSP cur_parent_frame = m_thread.GetStackFrameAtIndex(1);
+ StackFrameSP cur_parent_frame = thread.GetStackFrameAtIndex(1);
StackID cur_parent_id;
if (cur_parent_frame)
cur_parent_id = cur_parent_frame->GetStackID();
@@ -264,12 +262,11 @@ InstructionList *ThreadPlanStepRange::GetInstructionsForAddress(
if (!m_instruction_ranges[i]) {
// Disassemble the address range given:
- ExecutionContext exe_ctx(m_thread.GetProcess());
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, flavor, exe_ctx,
+ GetTarget().GetArchitecture(), plugin_name, flavor, GetTarget(),
m_address_ranges[i], prefer_file_cache);
}
if (!m_instruction_ranges[i])
@@ -378,11 +375,10 @@ bool ThreadPlanStepRange::SetNextBranchBreakpoint() {
"ThreadPlanStepRange::SetNextBranchBreakpoint - Setting "
"breakpoint %d (site %d) to run to address 0x%" PRIx64,
m_next_branch_bp_sp->GetID(), bp_site_id,
- run_to_address.GetLoadAddress(
- &m_thread.GetProcess()->GetTarget()));
+ run_to_address.GetLoadAddress(&m_process.GetTarget()));
}
- m_next_branch_bp_sp->SetThreadID(m_thread.GetID());
+ m_next_branch_bp_sp->SetThreadID(m_tid);
m_next_branch_bp_sp->SetBreakpointKind("next-branch-location");
return true;
@@ -401,7 +397,7 @@ bool ThreadPlanStepRange::NextRangeBreakpointExplainsStop(
break_id_t bp_site_id = stop_info_sp->GetValue();
BreakpointSiteSP bp_site_sp =
- m_thread.GetProcess()->GetBreakpointSiteList().FindByID(bp_site_id);
+ m_process.GetBreakpointSiteList().FindByID(bp_site_id);
if (!bp_site_sp)
return false;
else if (!bp_site_sp->IsBreakpointAtThisSite(m_next_branch_bp_sp->GetID()))
@@ -488,11 +484,11 @@ bool ThreadPlanStepRange::IsPlanStale() {
// check that we are in the same symbol.
if (!InRange()) {
// Set plan Complete when we reach next instruction just after the range
- lldb::addr_t addr = m_thread.GetRegisterContext()->GetPC() - 1;
+ lldb::addr_t addr = GetThread().GetRegisterContext()->GetPC() - 1;
size_t num_ranges = m_address_ranges.size();
for (size_t i = 0; i < num_ranges; i++) {
- bool in_range = m_address_ranges[i].ContainsLoadAddress(
- addr, m_thread.CalculateTarget().get());
+ bool in_range =
+ m_address_ranges[i].ContainsLoadAddress(addr, &GetTarget());
if (in_range) {
SetPlanComplete();
}
diff --git a/lldb/source/Target/ThreadPlanStepThrough.cpp b/lldb/source/Target/ThreadPlanStepThrough.cpp
index 8c7b180fce2d..06b626935aba 100644
--- a/lldb/source/Target/ThreadPlanStepThrough.cpp
+++ b/lldb/source/Target/ThreadPlanStepThrough.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadPlanStepThrough.cpp -------------------------------*- C++ -*-===//
+//===-- ThreadPlanStepThrough.cpp -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -44,21 +44,20 @@ ThreadPlanStepThrough::ThreadPlanStepThrough(Thread &thread,
// some inlined code that we're in the middle of by doing this, but it's
// easier than trying to figure out where the inlined code might return to.
- StackFrameSP return_frame_sp = m_thread.GetFrameWithStackID(m_stack_id);
+ StackFrameSP return_frame_sp = thread.GetFrameWithStackID(m_stack_id);
if (return_frame_sp) {
m_backstop_addr = return_frame_sp->GetFrameCodeAddress().GetLoadAddress(
- m_thread.CalculateTarget().get());
+ thread.CalculateTarget().get());
Breakpoint *return_bp =
- m_thread.GetProcess()
- ->GetTarget()
+ m_process.GetTarget()
.CreateBreakpoint(m_backstop_addr, true, false)
.get();
if (return_bp != nullptr) {
if (return_bp->IsHardware() && !return_bp->HasResolvedLocations())
m_could_not_resolve_hw_bp = true;
- return_bp->SetThreadID(m_thread.GetID());
+ return_bp->SetThreadID(m_tid);
m_backstop_bkpt_id = return_bp->GetID();
return_bp->SetBreakpointKind("step-through-backstop");
}
@@ -79,18 +78,17 @@ void ThreadPlanStepThrough::DidPush() {
}
void ThreadPlanStepThrough::LookForPlanToStepThroughFromCurrentPC() {
- DynamicLoader *loader = m_thread.GetProcess()->GetDynamicLoader();
+ Thread &thread = GetThread();
+ DynamicLoader *loader = thread.GetProcess()->GetDynamicLoader();
if (loader)
- m_sub_plan_sp =
- loader->GetStepThroughTrampolinePlan(m_thread, m_stop_others);
+ m_sub_plan_sp = loader->GetStepThroughTrampolinePlan(thread, m_stop_others);
// If the DynamicLoader was unable to provide us with a ThreadPlan, then we
// try the LanguageRuntimes.
if (!m_sub_plan_sp) {
- for (LanguageRuntime *runtime :
- m_thread.GetProcess()->GetLanguageRuntimes()) {
+ for (LanguageRuntime *runtime : m_process.GetLanguageRuntimes()) {
m_sub_plan_sp =
- runtime->GetStepThroughTrampolinePlan(m_thread, m_stop_others);
+ runtime->GetStepThroughTrampolinePlan(thread, m_stop_others);
if (m_sub_plan_sp)
break;
@@ -223,7 +221,7 @@ bool ThreadPlanStepThrough::WillStop() { return true; }
void ThreadPlanStepThrough::ClearBackstopBreakpoint() {
if (m_backstop_bkpt_id != LLDB_INVALID_BREAK_ID) {
- m_thread.GetProcess()->GetTarget().RemoveBreakpointByID(m_backstop_bkpt_id);
+ m_process.GetTarget().RemoveBreakpointByID(m_backstop_bkpt_id);
m_backstop_bkpt_id = LLDB_INVALID_BREAK_ID;
m_could_not_resolve_hw_bp = false;
}
@@ -244,15 +242,15 @@ bool ThreadPlanStepThrough::MischiefManaged() {
}
bool ThreadPlanStepThrough::HitOurBackstopBreakpoint() {
- StopInfoSP stop_info_sp(m_thread.GetStopInfo());
+ Thread &thread = GetThread();
+ StopInfoSP stop_info_sp(thread.GetStopInfo());
if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonBreakpoint) {
break_id_t stop_value = (break_id_t)stop_info_sp->GetValue();
BreakpointSiteSP cur_site_sp =
- m_thread.GetProcess()->GetBreakpointSiteList().FindByID(stop_value);
+ m_process.GetBreakpointSiteList().FindByID(stop_value);
if (cur_site_sp &&
cur_site_sp->IsBreakpointAtThisSite(m_backstop_bkpt_id)) {
- StackID cur_frame_zero_id =
- m_thread.GetStackFrameAtIndex(0)->GetStackID();
+ StackID cur_frame_zero_id = thread.GetStackFrameAtIndex(0)->GetStackID();
if (cur_frame_zero_id == m_return_stack_id) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
diff --git a/lldb/source/Target/ThreadPlanStepUntil.cpp b/lldb/source/Target/ThreadPlanStepUntil.cpp
index 54d276337488..650fa624cd52 100644
--- a/lldb/source/Target/ThreadPlanStepUntil.cpp
+++ b/lldb/source/Target/ThreadPlanStepUntil.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadPlanStepUntil.cpp ---------------------------------*- C++ -*-===//
+//===-- ThreadPlanStepUntil.cpp -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -34,17 +34,16 @@ ThreadPlanStepUntil::ThreadPlanStepUntil(Thread &thread,
m_should_stop(false), m_ran_analyze(false), m_explains_stop(false),
m_until_points(), m_stop_others(stop_others) {
// Stash away our "until" addresses:
- TargetSP target_sp(m_thread.CalculateTarget());
+ TargetSP target_sp(thread.CalculateTarget());
- StackFrameSP frame_sp(m_thread.GetStackFrameAtIndex(frame_idx));
+ StackFrameSP frame_sp(thread.GetStackFrameAtIndex(frame_idx));
if (frame_sp) {
m_step_from_insn = frame_sp->GetStackID().GetPC();
- lldb::user_id_t thread_id = m_thread.GetID();
// Find the return address and set a breakpoint there:
// FIXME - can we do this more securely if we know first_insn?
- StackFrameSP return_frame_sp(m_thread.GetStackFrameAtIndex(frame_idx + 1));
+ StackFrameSP return_frame_sp(thread.GetStackFrameAtIndex(frame_idx + 1));
if (return_frame_sp) {
// TODO: add inline functionality
m_return_addr = return_frame_sp->GetStackID().GetPC();
@@ -54,7 +53,7 @@ ThreadPlanStepUntil::ThreadPlanStepUntil(Thread &thread,
if (return_bp != nullptr) {
if (return_bp->IsHardware() && !return_bp->HasResolvedLocations())
m_could_not_resolve_hw_bp = true;
- return_bp->SetThreadID(thread_id);
+ return_bp->SetThreadID(m_tid);
m_return_bp_id = return_bp->GetID();
return_bp->SetBreakpointKind("until-return-backstop");
}
@@ -67,7 +66,7 @@ ThreadPlanStepUntil::ThreadPlanStepUntil(Thread &thread,
Breakpoint *until_bp =
target_sp->CreateBreakpoint(address_list[i], true, false).get();
if (until_bp != nullptr) {
- until_bp->SetThreadID(thread_id);
+ until_bp->SetThreadID(m_tid);
m_until_points[address_list[i]] = until_bp->GetID();
until_bp->SetBreakpointKind("until-target");
} else {
@@ -80,17 +79,15 @@ ThreadPlanStepUntil::ThreadPlanStepUntil(Thread &thread,
ThreadPlanStepUntil::~ThreadPlanStepUntil() { Clear(); }
void ThreadPlanStepUntil::Clear() {
- TargetSP target_sp(m_thread.CalculateTarget());
- if (target_sp) {
- if (m_return_bp_id != LLDB_INVALID_BREAK_ID) {
- target_sp->RemoveBreakpointByID(m_return_bp_id);
- m_return_bp_id = LLDB_INVALID_BREAK_ID;
- }
+ Target &target = GetTarget();
+ if (m_return_bp_id != LLDB_INVALID_BREAK_ID) {
+ target.RemoveBreakpointByID(m_return_bp_id);
+ m_return_bp_id = LLDB_INVALID_BREAK_ID;
+ }
- until_collection::iterator pos, end = m_until_points.end();
- for (pos = m_until_points.begin(); pos != end; pos++) {
- target_sp->RemoveBreakpointByID((*pos).second);
- }
+ until_collection::iterator pos, end = m_until_points.end();
+ for (pos = m_until_points.begin(); pos != end; pos++) {
+ target.RemoveBreakpointByID((*pos).second);
}
m_until_points.clear();
m_could_not_resolve_hw_bp = false;
@@ -158,8 +155,7 @@ void ThreadPlanStepUntil::AnalyzeStop() {
// 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());
+ m_process.GetBreakpointSiteList().FindByID(stop_info_sp->GetValue());
if (!this_site) {
m_explains_stop = false;
return;
@@ -196,17 +192,17 @@ void ThreadPlanStepUntil::AnalyzeStop() {
for (pos = m_until_points.begin(); pos != end; pos++) {
if (this_site->IsBreakpointAtThisSite((*pos).second)) {
// If we're at the right stack depth, then we're done.
-
+ Thread &thread = GetThread();
bool done;
StackID frame_zero_id =
- m_thread.GetStackFrameAtIndex(0)->GetStackID();
+ 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);
+ StackFrameSP older_frame_sp = thread.GetStackFrameAtIndex(1);
// But if we can't even unwind one frame we should just get out
// of here & stop...
@@ -280,20 +276,16 @@ StateType ThreadPlanStepUntil::GetPlanRunState() { return eStateRunning; }
bool ThreadPlanStepUntil::DoWillResume(StateType resume_state,
bool current_plan) {
if (current_plan) {
- TargetSP target_sp(m_thread.CalculateTarget());
- if (target_sp) {
- Breakpoint *return_bp =
- target_sp->GetBreakpointByID(m_return_bp_id).get();
- if (return_bp != nullptr)
- return_bp->SetEnabled(true);
+ Target &target = GetTarget();
+ Breakpoint *return_bp = target.GetBreakpointByID(m_return_bp_id).get();
+ 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 != nullptr)
- until_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.GetBreakpointByID((*pos).second).get();
+ if (until_bp != nullptr)
+ until_bp->SetEnabled(true);
}
}
@@ -304,18 +296,16 @@ bool ThreadPlanStepUntil::DoWillResume(StateType resume_state,
}
bool ThreadPlanStepUntil::WillStop() {
- TargetSP target_sp(m_thread.CalculateTarget());
- if (target_sp) {
- Breakpoint *return_bp = target_sp->GetBreakpointByID(m_return_bp_id).get();
- 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 != nullptr)
- until_bp->SetEnabled(false);
- }
+ Target &target = GetTarget();
+ Breakpoint *return_bp = target.GetBreakpointByID(m_return_bp_id).get();
+ 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.GetBreakpointByID((*pos).second).get();
+ if (until_bp != nullptr)
+ until_bp->SetEnabled(false);
}
return true;
}
diff --git a/lldb/source/Target/ThreadPlanTracer.cpp b/lldb/source/Target/ThreadPlanTracer.cpp
index b50c1636b7ff..c00415f3c1ee 100644
--- a/lldb/source/Target/ThreadPlanTracer.cpp
+++ b/lldb/source/Target/ThreadPlanTracer.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadPlanTracer.cpp ------------------------------------*- C++ -*-===//
+//===-- ThreadPlanTracer.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -34,23 +34,32 @@ using namespace lldb_private;
#pragma mark ThreadPlanTracer
ThreadPlanTracer::ThreadPlanTracer(Thread &thread, lldb::StreamSP &stream_sp)
- : m_thread(thread), m_single_step(true), m_enabled(false),
- m_stream_sp(stream_sp) {}
+ : m_process(*thread.GetProcess().get()), m_tid(thread.GetID()),
+ m_single_step(true), m_enabled(false), m_stream_sp(stream_sp) {}
ThreadPlanTracer::ThreadPlanTracer(Thread &thread)
- : m_thread(thread), m_single_step(true), m_enabled(false), m_stream_sp() {}
+ : m_process(*thread.GetProcess().get()), m_tid(thread.GetID()),
+ m_single_step(true), m_enabled(false), m_stream_sp() {}
Stream *ThreadPlanTracer::GetLogStream() {
if (m_stream_sp)
return m_stream_sp.get();
else {
- TargetSP target_sp(m_thread.CalculateTarget());
+ TargetSP target_sp(GetThread().CalculateTarget());
if (target_sp)
return &(target_sp->GetDebugger().GetOutputStream());
}
return nullptr;
}
+Thread &ThreadPlanTracer::GetThread() {
+ if (m_thread)
+ return *m_thread;
+
+ ThreadSP thread_sp = m_process.GetThreadList().FindThreadByID(m_tid);
+ m_thread = thread_sp.get();
+ return *m_thread;
+}
void ThreadPlanTracer::Log() {
SymbolContext sc;
bool show_frame_index = false;
@@ -58,8 +67,8 @@ void ThreadPlanTracer::Log() {
Stream *stream = GetLogStream();
if (stream) {
- m_thread.GetStackFrameAtIndex(0)->Dump(stream, show_frame_index,
- show_fullpaths);
+ GetThread().GetStackFrameAtIndex(0)->Dump(stream, show_frame_index,
+ show_fullpaths);
stream->Printf("\n");
stream->Flush();
}
@@ -67,7 +76,7 @@ void ThreadPlanTracer::Log() {
bool ThreadPlanTracer::TracerExplainsStop() {
if (m_enabled && m_single_step) {
- lldb::StopInfoSP stop_info = m_thread.GetStopInfo();
+ lldb::StopInfoSP stop_info = GetThread().GetStopInfo();
return (stop_info->GetStopReason() == eStopReasonTrace);
} else
return false;
@@ -87,13 +96,13 @@ ThreadPlanAssemblyTracer::ThreadPlanAssemblyTracer(Thread &thread)
Disassembler *ThreadPlanAssemblyTracer::GetDisassembler() {
if (!m_disassembler_sp)
m_disassembler_sp = Disassembler::FindPlugin(
- m_thread.GetProcess()->GetTarget().GetArchitecture(), nullptr, nullptr);
+ m_process.GetTarget().GetArchitecture(), nullptr, nullptr);
return m_disassembler_sp.get();
}
TypeFromUser ThreadPlanAssemblyTracer::GetIntPointerType() {
if (!m_intptr_type.IsValid()) {
- if (auto target_sp = m_thread.CalculateTarget()) {
+ if (auto target_sp = m_process.CalculateTarget()) {
auto type_system_or_err =
target_sp->GetScratchTypeSystemForLanguage(eLanguageTypeC);
if (auto err = type_system_or_err.takeError()) {
@@ -125,29 +134,27 @@ void ThreadPlanAssemblyTracer::Log() {
if (!stream)
return;
- RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
+ RegisterContext *reg_ctx = GetThread().GetRegisterContext().get();
lldb::addr_t pc = reg_ctx->GetPC();
- ProcessSP process_sp(m_thread.GetProcess());
Address pc_addr;
bool addr_valid = false;
uint8_t buffer[16] = {0}; // Must be big enough for any single instruction
- addr_valid = process_sp->GetTarget().GetSectionLoadList().ResolveLoadAddress(
+ addr_valid = m_process.GetTarget().GetSectionLoadList().ResolveLoadAddress(
pc, pc_addr);
- pc_addr.Dump(stream, &m_thread, Address::DumpStyleResolvedDescription,
+ pc_addr.Dump(stream, &GetThread(), Address::DumpStyleResolvedDescription,
Address::DumpStyleModuleWithFileAddress);
stream->PutCString(" ");
Disassembler *disassembler = GetDisassembler();
if (disassembler) {
Status err;
- process_sp->ReadMemory(pc, buffer, sizeof(buffer), err);
+ m_process.ReadMemory(pc, buffer, sizeof(buffer), err);
if (err.Success()) {
- DataExtractor extractor(buffer, sizeof(buffer),
- process_sp->GetByteOrder(),
- process_sp->GetAddressByteSize());
+ DataExtractor extractor(buffer, sizeof(buffer), m_process.GetByteOrder(),
+ m_process.GetAddressByteSize());
bool data_from_file = false;
if (addr_valid)
@@ -167,10 +174,7 @@ void ThreadPlanAssemblyTracer::Log() {
Instruction *instruction =
instruction_list.GetInstructionAtIndex(0).get();
const FormatEntity::Entry *disassemble_format =
- m_thread.GetProcess()
- ->GetTarget()
- .GetDebugger()
- .GetDisassemblyFormat();
+ m_process.GetTarget().GetDebugger().GetDisassemblyFormat();
instruction->Dump(stream, max_opcode_byte_size, show_address,
show_bytes, nullptr, nullptr, nullptr,
disassemble_format, 0);
@@ -178,7 +182,7 @@ void ThreadPlanAssemblyTracer::Log() {
}
}
- const ABI *abi = process_sp->GetABI().get();
+ const ABI *abi = m_process.GetABI().get();
TypeFromUser intptr_type = GetIntPointerType();
if (abi && intptr_type.IsValid()) {
@@ -192,7 +196,7 @@ void ThreadPlanAssemblyTracer::Log() {
value_list.PushValue(value);
}
- if (abi->GetArgumentValues(m_thread, value_list)) {
+ if (abi->GetArgumentValues(GetThread(), value_list)) {
for (int arg_index = 0; arg_index < num_args; ++arg_index) {
stream->Printf(
"\n\targ[%d]=%llx", arg_index,
@@ -205,7 +209,7 @@ void ThreadPlanAssemblyTracer::Log() {
}
if (m_register_values.empty()) {
- RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
+ RegisterContext *reg_ctx = GetThread().GetRegisterContext().get();
m_register_values.resize(reg_ctx->GetRegisterCount());
}
diff --git a/lldb/source/Target/ThreadSpec.cpp b/lldb/source/Target/ThreadSpec.cpp
index 1a733cb551e5..1f6639379c45 100644
--- a/lldb/source/Target/ThreadSpec.cpp
+++ b/lldb/source/Target/ThreadSpec.cpp
@@ -1,4 +1,4 @@
-//===-- ThreadSpec.cpp ------------------------------------------*- C++ -*-===//
+//===-- ThreadSpec.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Target/UnixSignals.cpp b/lldb/source/Target/UnixSignals.cpp
index 33090a72df54..dce32adbf0a3 100644
--- a/lldb/source/Target/UnixSignals.cpp
+++ b/lldb/source/Target/UnixSignals.cpp
@@ -1,4 +1,4 @@
-//===-- UnixSignals.cpp -----------------------------------------*- C++ -*-===//
+//===-- UnixSignals.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -145,10 +145,8 @@ bool UnixSignals::SignalIsValid(int32_t signo) const {
}
ConstString UnixSignals::GetShortName(ConstString name) const {
- if (name) {
- const char *signame = name.AsCString();
- return ConstString(signame + 3); // Remove "SIG" from name
- }
+ if (name)
+ return ConstString(name.GetStringRef().substr(3)); // Remove "SIG" from name
return name;
}
diff --git a/lldb/source/Target/UnwindAssembly.cpp b/lldb/source/Target/UnwindAssembly.cpp
index d3d8068687c0..3a87e3da5bca 100644
--- a/lldb/source/Target/UnwindAssembly.cpp
+++ b/lldb/source/Target/UnwindAssembly.cpp
@@ -1,4 +1,4 @@
-//===-- UnwindAssembly.cpp --------------------------------------*- C++ -*-===//
+//===-- UnwindAssembly.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp b/lldb/source/Target/UnwindLLDB.cpp
index 74fc90e88547..980ad4d2e342 100644
--- a/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp
+++ b/lldb/source/Target/UnwindLLDB.cpp
@@ -1,4 +1,4 @@
-//===-- UnwindLLDB.cpp -------------------------------------*- C++ -*-===//
+//===-- UnwindLLDB.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//
+#include "lldb/Target/UnwindLLDB.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/FuncUnwinders.h"
#include "lldb/Symbol/Function.h"
@@ -13,13 +14,11 @@
#include "lldb/Target/ABI.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/RegisterContextUnwind.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/Log.h"
-#include "RegisterContextLLDB.h"
-#include "UnwindLLDB.h"
-
using namespace lldb;
using namespace lldb_private;
@@ -77,7 +76,7 @@ bool UnwindLLDB::AddFirstFrame() {
// First, set up the 0th (initial) frame
CursorSP first_cursor_sp(new Cursor());
- RegisterContextLLDBSP reg_ctx_sp(new RegisterContextLLDB(
+ RegisterContextLLDBSP reg_ctx_sp(new RegisterContextUnwind(
m_thread, RegisterContextLLDBSP(), first_cursor_sp->sctx, 0, *this));
if (reg_ctx_sp.get() == nullptr)
goto unwind_done;
@@ -126,7 +125,7 @@ UnwindLLDB::CursorSP UnwindLLDB::GetOneMoreFrame(ABI *abi) {
uint32_t cur_idx = m_frames.size();
CursorSP cursor_sp(new Cursor());
- RegisterContextLLDBSP reg_ctx_sp(new RegisterContextLLDB(
+ RegisterContextLLDBSP reg_ctx_sp(new RegisterContextUnwind(
m_thread, prev_frame->reg_ctx_lldb_sp, cursor_sp->sctx, cur_idx, *this));
uint64_t max_stack_depth = m_thread.GetMaxBacktraceDepth();
@@ -148,7 +147,7 @@ UnwindLLDB::CursorSP UnwindLLDB::GetOneMoreFrame(ABI *abi) {
}
if (reg_ctx_sp.get() == nullptr) {
- // If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to
+ // If the RegisterContextUnwind 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()) {
@@ -187,7 +186,7 @@ UnwindLLDB::CursorSP UnwindLLDB::GetOneMoreFrame(ABI *abi) {
return nullptr;
}
if (!reg_ctx_sp->GetCFA(cursor_sp->cfa)) {
- // If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to
+ // If the RegisterContextUnwind 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()) {
@@ -243,7 +242,7 @@ UnwindLLDB::CursorSP UnwindLLDB::GetOneMoreFrame(ABI *abi) {
}
}
if (!reg_ctx_sp->ReadPC(cursor_sp->start_pc)) {
- // If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to
+ // If the RegisterContextUnwind 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()) {
@@ -262,7 +261,7 @@ UnwindLLDB::CursorSP UnwindLLDB::GetOneMoreFrame(ABI *abi) {
return nullptr;
}
if (abi && !abi->CodeAddressIsValid(cursor_sp->start_pc)) {
- // If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to
+ // If the RegisterContextUnwind 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()) {
diff --git a/lldb/source/Utility/ARM64_DWARF_Registers.h b/lldb/source/Utility/ARM64_DWARF_Registers.h
index 64f69d643565..ed8ff722088d 100644
--- a/lldb/source/Utility/ARM64_DWARF_Registers.h
+++ b/lldb/source/Utility/ARM64_DWARF_Registers.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef utility_ARM64_DWARF_Registers_h_
-#define utility_ARM64_DWARF_Registers_h_
+#ifndef LLDB_SOURCE_UTILITY_ARM64_DWARF_REGISTERS_H
+#define LLDB_SOURCE_UTILITY_ARM64_DWARF_REGISTERS_H
#include "lldb/lldb-private.h"
@@ -51,7 +51,31 @@ enum {
sp = x31,
pc = 32,
cpsr = 33,
- // 34-63 reserved
+ // 34-45 reserved
+
+ // 64-bit SVE Vector granule pseudo register
+ vg = 46,
+
+ // VG ́8-bit SVE first fault register
+ ffr = 47,
+
+ // VG x ́8-bit SVE predicate registers
+ p0 = 48,
+ p1,
+ p2,
+ p3,
+ p4,
+ p5,
+ p6,
+ p7,
+ p8,
+ p9,
+ p10,
+ p11,
+ p12,
+ p13,
+ p14,
+ p15,
// V0-V31 (128 bit vector registers)
v0 = 64,
@@ -85,11 +109,43 @@ enum {
v28,
v29,
v30,
- v31
+ v31,
- // 96-127 reserved
+ // VG ́64-bit SVE vector registers
+ z0 = 96,
+ z1,
+ z2,
+ z3,
+ z4,
+ z5,
+ z6,
+ z7,
+ z8,
+ z9,
+ z10,
+ z11,
+ z12,
+ z13,
+ z14,
+ z15,
+ z16,
+ z17,
+ z18,
+ z19,
+ z20,
+ z21,
+ z22,
+ z23,
+ z24,
+ z25,
+ z26,
+ z27,
+ z28,
+ z29,
+ z30,
+ z31
};
} // namespace arm64_dwarf
-#endif // utility_ARM64_DWARF_Registers_h_
+#endif // LLDB_SOURCE_UTILITY_ARM64_DWARF_REGISTERS_H
diff --git a/lldb/source/Utility/ARM64_ehframe_Registers.h b/lldb/source/Utility/ARM64_ehframe_Registers.h
index 9b5cd931bf28..c235891ec015 100644
--- a/lldb/source/Utility/ARM64_ehframe_Registers.h
+++ b/lldb/source/Utility/ARM64_ehframe_Registers.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef utility_ARM64_ehframe_Registers_h_
-#define utility_ARM64_ehframe_Registers_h_
+#ifndef LLDB_SOURCE_UTILITY_ARM64_EHFRAME_REGISTERS_H
+#define LLDB_SOURCE_UTILITY_ARM64_EHFRAME_REGISTERS_H
// The register numbers used in the eh_frame unwind information.
// Should be the same as DWARF register numbers.
@@ -49,10 +49,34 @@ enum {
lr, // aka x30
sp, // aka x31 aka wzr
pc, // value is 32
- cpsr
-};
+ cpsr,
+ // 34-45 reserved
-enum {
+ // 64-bit SVE Vector granule pseudo register
+ vg = 46,
+
+ // VG ́8-bit SVE first fault register
+ ffr = 47,
+
+ // VG x ́8-bit SVE predicate registers
+ p0 = 48,
+ p1,
+ p2,
+ p3,
+ p4,
+ p5,
+ p6,
+ p7,
+ p8,
+ p9,
+ p10,
+ p11,
+ p12,
+ p13,
+ p14,
+ p15,
+
+ // V0-V31 (128 bit vector registers)
v0 = 64,
v1,
v2,
@@ -84,8 +108,42 @@ enum {
v28,
v29,
v30,
- v31 // 95
+ v31,
+
+ // VG ́64-bit SVE vector registers
+ z0 = 96,
+ z1,
+ z2,
+ z3,
+ z4,
+ z5,
+ z6,
+ z7,
+ z8,
+ z9,
+ z10,
+ z11,
+ z12,
+ z13,
+ z14,
+ z15,
+ z16,
+ z17,
+ z18,
+ z19,
+ z20,
+ z21,
+ z22,
+ z23,
+ z24,
+ z25,
+ z26,
+ z27,
+ z28,
+ z29,
+ z30,
+ z31
};
}
-#endif // utility_ARM64_ehframe_Registers_h_
+#endif // LLDB_SOURCE_UTILITY_ARM64_EHFRAME_REGISTERS_H
diff --git a/lldb/source/Utility/ARM_DWARF_Registers.h b/lldb/source/Utility/ARM_DWARF_Registers.h
index e33210dfbfbd..8a3018b27e7e 100644
--- a/lldb/source/Utility/ARM_DWARF_Registers.h
+++ b/lldb/source/Utility/ARM_DWARF_Registers.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef utility_ARM_DWARF_Registers_h_
-#define utility_ARM_DWARF_Registers_h_
+#ifndef LLDB_SOURCE_UTILITY_ARM_DWARF_REGISTERS_H
+#define LLDB_SOURCE_UTILITY_ARM_DWARF_REGISTERS_H
#include "lldb/lldb-private.h"
@@ -204,4 +204,4 @@ enum {
dwarf_q15
};
-#endif // utility_ARM_DWARF_Registers_h_
+#endif // LLDB_SOURCE_UTILITY_ARM_DWARF_REGISTERS_H
diff --git a/lldb/source/Utility/ARM_ehframe_Registers.h b/lldb/source/Utility/ARM_ehframe_Registers.h
index 1816b1d97497..c64e1db0c3cd 100644
--- a/lldb/source/Utility/ARM_ehframe_Registers.h
+++ b/lldb/source/Utility/ARM_ehframe_Registers.h
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef utility_ARM_ehframe_Registers_h_
-#define utility_ARM_ehframe_Registers_h_
+#ifndef LLDB_SOURCE_UTILITY_ARM_EHFRAME_REGISTERS_H
+#define LLDB_SOURCE_UTILITY_ARM_EHFRAME_REGISTERS_H
// The register numbers used in the eh_frame unwind information.
// Should be the same as DWARF register numbers.
@@ -33,4 +33,4 @@ enum {
ehframe_cpsr
};
-#endif // utility_ARM_ehframe_Registers_h_
+#endif // LLDB_SOURCE_UTILITY_ARM_EHFRAME_REGISTERS_H
diff --git a/lldb/source/Utility/ArchSpec.cpp b/lldb/source/Utility/ArchSpec.cpp
index 3dae25ceacd6..ca1ce4b3d378 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -1,4 +1,4 @@
-//===-- ArchSpec.cpp --------------------------------------------*- C++ -*-===//
+//===-- ArchSpec.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -100,9 +100,9 @@ static const CoreDefinition g_core_definitions[] = {
{eByteOrderLittle, 8, 4, 4, llvm::Triple::aarch64,
ArchSpec::eCore_arm_armv8, "armv8"},
{eByteOrderLittle, 4, 2, 4, llvm::Triple::arm,
- ArchSpec::eCore_arm_armv8l, "armv8l"},
+ ArchSpec::eCore_arm_armv8l, "armv8l"},
{eByteOrderLittle, 4, 4, 4, llvm::Triple::aarch64_32,
- ArchSpec::eCore_arm_arm64_32, "arm64_32"},
+ ArchSpec::eCore_arm_arm64_32, "arm64_32"},
{eByteOrderLittle, 8, 4, 4, llvm::Triple::aarch64,
ArchSpec::eCore_arm_aarch64, "aarch64"},
@@ -216,7 +216,12 @@ static const CoreDefinition g_core_definitions[] = {
ArchSpec::eCore_uknownMach32, "unknown-mach-32"},
{eByteOrderLittle, 8, 4, 4, llvm::Triple::UnknownArch,
ArchSpec::eCore_uknownMach64, "unknown-mach-64"},
- {eByteOrderLittle, 4, 2, 4, llvm::Triple::arc, ArchSpec::eCore_arc, "arc"}
+ {eByteOrderLittle, 4, 2, 4, llvm::Triple::arc, ArchSpec::eCore_arc, "arc"},
+
+ {eByteOrderLittle, 2, 2, 4, llvm::Triple::avr, ArchSpec::eCore_avr, "avr"},
+
+ {eByteOrderLittle, 4, 1, 4, llvm::Triple::wasm32, ArchSpec::eCore_wasm32,
+ "wasm32"},
};
// Ensure that we have an entry in the g_core_definitions for each core. If you
@@ -445,6 +450,8 @@ static const ArchDefinitionEntry g_elf_arch_entries[] = {
LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu}, // HEXAGON
{ArchSpec::eCore_arc, llvm::ELF::EM_ARC_COMPACT2, LLDB_INVALID_CPUTYPE,
0xFFFFFFFFu, 0xFFFFFFFFu}, // ARC
+ {ArchSpec::eCore_avr, llvm::ELF::EM_AVR, LLDB_INVALID_CPUTYPE,
+ 0xFFFFFFFFu, 0xFFFFFFFFu}, // AVR
};
static const ArchDefinition g_elf_arch_def = {
@@ -1460,3 +1467,15 @@ void ArchSpec::DumpTriple(llvm::raw_ostream &s) const {
if (!environ_str.empty())
s << "-" << environ_str;
}
+
+void llvm::yaml::ScalarTraits<ArchSpec>::output(const ArchSpec &Val, void *,
+ raw_ostream &Out) {
+ Val.DumpTriple(Out);
+}
+
+llvm::StringRef
+llvm::yaml::ScalarTraits<ArchSpec>::input(llvm::StringRef Scalar, void *,
+ ArchSpec &Val) {
+ Val = ArchSpec(Scalar);
+ return {};
+}
diff --git a/lldb/source/Utility/Args.cpp b/lldb/source/Utility/Args.cpp
index 9fcc833ce432..f718c6f9ff1c 100644
--- a/lldb/source/Utility/Args.cpp
+++ b/lldb/source/Utility/Args.cpp
@@ -1,4 +1,4 @@
-//===-- Args.cpp ------------------------------------------------*- C++ -*-===//
+//===-- Args.cpp ----------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -44,7 +44,7 @@ static llvm::StringRef ParseDoubleQuotes(llvm::StringRef quoted,
break;
}
- // If the character after the backslash is not a whitelisted escapable
+ // If the character after the backslash is not an allowed escapable
// character, we leave the character sequence untouched.
if (strchr(k_escapable_characters, quoted.front()) == nullptr)
result += '\\';
@@ -111,7 +111,7 @@ ParseSingleArgument(llvm::StringRef command) {
break;
}
- // If the character after the backslash is not a whitelisted escapable
+ // If the character after the backslash is not an allowed escapable
// character, we leave the character sequence untouched.
if (strchr(" \t\\'\"`", command.front()) == nullptr)
arg += '\\';
@@ -546,7 +546,7 @@ void Args::ExpandEscapedCharacters(const char *src, std::string &dst) {
dst.clear();
if (src) {
for (const char *p = src; *p != '\0'; ++p) {
- if (isprint(*p))
+ if (llvm::isPrint(*p))
dst.append(1, *p);
else {
switch (*p) {
@@ -635,7 +635,7 @@ void OptionsWithRaw::SetFromString(llvm::StringRef arg_string) {
// If the string doesn't start with a dash, we just have no options and just
// a raw part.
if (!arg_string.startswith("-")) {
- m_suffix = original_args;
+ m_suffix = std::string(original_args);
return;
}
@@ -655,7 +655,7 @@ void OptionsWithRaw::SetFromString(llvm::StringRef arg_string) {
// The remaining line is the raw suffix, and the line we parsed so far
// needs to be interpreted as arguments.
m_has_args = true;
- m_suffix = arg_string;
+ m_suffix = std::string(arg_string);
found_suffix = true;
// The length of the prefix after parsing.
@@ -681,6 +681,23 @@ void OptionsWithRaw::SetFromString(llvm::StringRef arg_string) {
// If we didn't find a suffix delimiter, the whole string is the raw suffix.
if (!found_suffix) {
found_suffix = true;
- m_suffix = original_args;
+ m_suffix = std::string(original_args);
}
}
+
+void llvm::yaml::MappingTraits<Args::ArgEntry>::mapping(IO &io,
+ Args::ArgEntry &v) {
+ MappingNormalization<NormalizedArgEntry, Args::ArgEntry> keys(io, v);
+ io.mapRequired("value", keys->value);
+ io.mapRequired("quote", keys->quote);
+}
+
+void llvm::yaml::MappingTraits<Args>::mapping(IO &io, Args &v) {
+ io.mapRequired("entries", v.m_entries);
+
+ // Recompute m_argv vector.
+ v.m_argv.clear();
+ for (auto &entry : v.m_entries)
+ v.m_argv.push_back(entry.data());
+ v.m_argv.push_back(nullptr);
+}
diff --git a/lldb/source/Utility/Baton.cpp b/lldb/source/Utility/Baton.cpp
index 7bba10dcec96..d6bc8e308587 100644
--- a/lldb/source/Utility/Baton.cpp
+++ b/lldb/source/Utility/Baton.cpp
@@ -1,4 +1,4 @@
-//===-- Baton.cpp -----------------------------------------------*- C++ -*-===//
+//===-- Baton.cpp ---------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/Broadcaster.cpp b/lldb/source/Utility/Broadcaster.cpp
index ee0c39f8fd42..342548c0b0e6 100644
--- a/lldb/source/Utility/Broadcaster.cpp
+++ b/lldb/source/Utility/Broadcaster.cpp
@@ -1,4 +1,4 @@
-//===-- Broadcaster.cpp -----------------------------------------*- C++ -*-===//
+//===-- Broadcaster.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -30,7 +30,7 @@ Broadcaster::Broadcaster(BroadcasterManagerSP manager_sp, const char *name)
m_manager_sp(std::move(manager_sp)), m_broadcaster_name(name) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
LLDB_LOG(log, "{0} Broadcaster::Broadcaster(\"{1}\")",
- static_cast<void *>(this), GetBroadcasterName().AsCString());
+ static_cast<void *>(this), GetBroadcasterName());
}
Broadcaster::BroadcasterImpl::BroadcasterImpl(Broadcaster &broadcaster)
@@ -40,7 +40,7 @@ Broadcaster::BroadcasterImpl::BroadcasterImpl(Broadcaster &broadcaster)
Broadcaster::~Broadcaster() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
LLDB_LOG(log, "{0} Broadcaster::~Broadcaster(\"{1}\")",
- static_cast<void *>(this), GetBroadcasterName().AsCString());
+ static_cast<void *>(this), GetBroadcasterName());
Clear();
}
@@ -373,8 +373,8 @@ bool BroadcasterManager::UnregisterListenerForEvents(
if (event_bits_to_remove != iter_event_bits) {
uint32_t new_event_bits = iter_event_bits & ~event_bits_to_remove;
- to_be_readded.push_back(
- BroadcastEventSpec(event_spec.GetBroadcasterClass(), new_event_bits));
+ to_be_readded.emplace_back(event_spec.GetBroadcasterClass(),
+ new_event_bits);
}
m_event_map.erase(iter);
}
@@ -406,7 +406,7 @@ void BroadcasterManager::RemoveListener(Listener *listener) {
listener_collection::iterator iter = m_listeners.begin(),
end_iter = m_listeners.end();
- std::find_if(iter, end_iter, predicate);
+ iter = std::find_if(iter, end_iter, predicate);
if (iter != end_iter)
m_listeners.erase(iter);
diff --git a/lldb/source/Utility/CompletionRequest.cpp b/lldb/source/Utility/CompletionRequest.cpp
index 3b5a4570e324..8f9dbb79d37b 100644
--- a/lldb/source/Utility/CompletionRequest.cpp
+++ b/lldb/source/Utility/CompletionRequest.cpp
@@ -1,4 +1,4 @@
-//===-- CompletionRequest.cpp -----------------------------------*- C++ -*-===//
+//===-- CompletionRequest.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/Connection.cpp b/lldb/source/Utility/Connection.cpp
index 483a0c941be4..d5fcd4f3462f 100644
--- a/lldb/source/Utility/Connection.cpp
+++ b/lldb/source/Utility/Connection.cpp
@@ -1,4 +1,4 @@
-//===-- Connection.cpp ------------------------------------------*- C++ -*-===//
+//===-- Connection.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/ConstString.cpp b/lldb/source/Utility/ConstString.cpp
index e90bb929bb81..62f79b3df7a5 100644
--- a/lldb/source/Utility/ConstString.cpp
+++ b/lldb/source/Utility/ConstString.cpp
@@ -1,4 +1,4 @@
-//===-- ConstString.cpp -----------------------------------------*- C++ -*-===//
+//===-- ConstString.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -29,9 +29,37 @@ using namespace lldb_private;
class Pool {
public:
+ /// The default BumpPtrAllocatorImpl slab size.
+ static const size_t AllocatorSlabSize = 4096;
+ static const size_t SizeThreshold = AllocatorSlabSize;
+ /// Every Pool has its own allocator which receives an equal share of
+ /// the ConstString allocations. This means that when allocating many
+ /// ConstStrings, every allocator sees only its small share of allocations and
+ /// assumes LLDB only allocated a small amount of memory so far. In reality
+ /// LLDB allocated a total memory that is N times as large as what the
+ /// allocator sees (where N is the number of string pools). This causes that
+ /// the BumpPtrAllocator continues a long time to allocate memory in small
+ /// chunks which only makes sense when allocating a small amount of memory
+ /// (which is true from the perspective of a single allocator). On some
+ /// systems doing all these small memory allocations causes LLDB to spend
+ /// a lot of time in malloc, so we need to force all these allocators to
+ /// behave like one allocator in terms of scaling their memory allocations
+ /// with increased demand. To do this we set the growth delay for each single
+ /// allocator to a rate so that our pool of allocators scales their memory
+ /// allocations similar to a single BumpPtrAllocatorImpl.
+ ///
+ /// Currently we have 256 string pools and the normal growth delay of the
+ /// BumpPtrAllocatorImpl is 128 (i.e., the memory allocation size increases
+ /// every 128 full chunks), so by changing the delay to 1 we get a
+ /// total growth delay in our allocator collection of 256/1 = 256. This is
+ /// still only half as fast as a normal allocator but we can't go any faster
+ /// without decreasing the number of string pools.
+ static const size_t AllocatorGrowthDelay = 1;
+ typedef llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, AllocatorSlabSize,
+ SizeThreshold, AllocatorGrowthDelay>
+ Allocator;
typedef const char *StringPoolValueType;
- typedef llvm::StringMap<StringPoolValueType, llvm::BumpPtrAllocator>
- StringPool;
+ typedef llvm::StringMap<StringPoolValueType, Allocator> StringPool;
typedef llvm::StringMapEntry<StringPoolValueType> StringPoolEntryType;
static StringPoolEntryType &
@@ -307,5 +335,17 @@ size_t ConstString::StaticMemorySize() {
void llvm::format_provider<ConstString>::format(const ConstString &CS,
llvm::raw_ostream &OS,
llvm::StringRef Options) {
- format_provider<StringRef>::format(CS.AsCString(), OS, Options);
+ format_provider<StringRef>::format(CS.GetStringRef(), OS, Options);
+}
+
+void llvm::yaml::ScalarTraits<ConstString>::output(const ConstString &Val,
+ void *, raw_ostream &Out) {
+ Out << Val.GetStringRef();
+}
+
+llvm::StringRef
+llvm::yaml::ScalarTraits<ConstString>::input(llvm::StringRef Scalar, void *,
+ ConstString &Val) {
+ Val = ConstString(Scalar);
+ return {};
}
diff --git a/lldb/source/Utility/DataBufferHeap.cpp b/lldb/source/Utility/DataBufferHeap.cpp
index 5bff7775f138..3aa0b6b0ac40 100644
--- a/lldb/source/Utility/DataBufferHeap.cpp
+++ b/lldb/source/Utility/DataBufferHeap.cpp
@@ -1,4 +1,4 @@
-//===-- DataBufferHeap.cpp --------------------------------------*- C++ -*-===//
+//===-- DataBufferHeap.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/DataBufferLLVM.cpp b/lldb/source/Utility/DataBufferLLVM.cpp
index c20e1b06f52e..235123a31cee 100644
--- a/lldb/source/Utility/DataBufferLLVM.cpp
+++ b/lldb/source/Utility/DataBufferLLVM.cpp
@@ -1,4 +1,4 @@
-//===--- DataBufferLLVM.cpp -------------------------------------*- C++ -*-===//
+//===-- DataBufferLLVM.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/DataEncoder.cpp b/lldb/source/Utility/DataEncoder.cpp
index 8a1036e26dce..7532ac1fdcaf 100644
--- a/lldb/source/Utility/DataEncoder.cpp
+++ b/lldb/source/Utility/DataEncoder.cpp
@@ -1,4 +1,4 @@
-//===-- DataEncoder.cpp -----------------------------------------*- C++ -*-===//
+//===-- DataEncoder.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/DataExtractor.cpp b/lldb/source/Utility/DataExtractor.cpp
index fed2a1326b86..64b878d7dee7 100644
--- a/lldb/source/Utility/DataExtractor.cpp
+++ b/lldb/source/Utility/DataExtractor.cpp
@@ -1,4 +1,4 @@
-//===-- DataExtractor.cpp ---------------------------------------*- C++ -*-===//
+//===-- DataExtractor.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -15,7 +15,6 @@
#include "lldb/Utility/DataBuffer.h"
#include "lldb/Utility/DataBufferHeap.h"
-#include "lldb/Utility/Endian.h"
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Stream.h"
@@ -24,6 +23,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/LEB128.h"
#include "llvm/Support/MD5.h"
#include "llvm/Support/MathExtras.h"
@@ -133,7 +133,7 @@ DataExtractor::DataExtractor(const void *data, offset_t length,
m_end(const_cast<uint8_t *>(static_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) {
- assert(addr_size == 4 || addr_size == 8);
+ assert(addr_size >= 1 && addr_size <= 8);
}
// Make a shared pointer reference to the shared data in "data_sp" and set the
@@ -146,7 +146,7 @@ DataExtractor::DataExtractor(const DataBufferSP &data_sp, ByteOrder endian,
: m_start(nullptr), m_end(nullptr), m_byte_order(endian),
m_addr_size(addr_size), m_data_sp(),
m_target_byte_size(target_byte_size) {
- assert(addr_size == 4 || addr_size == 8);
+ assert(addr_size >= 1 && addr_size <= 8);
SetData(data_sp);
}
@@ -160,7 +160,7 @@ DataExtractor::DataExtractor(const DataExtractor &data, offset_t offset,
: m_start(nullptr), m_end(nullptr), m_byte_order(data.m_byte_order),
m_addr_size(data.m_addr_size), m_data_sp(),
m_target_byte_size(target_byte_size) {
- assert(m_addr_size == 4 || m_addr_size == 8);
+ assert(m_addr_size >= 1 && m_addr_size <= 8);
if (data.ValidOffset(offset)) {
offset_t bytes_available = data.GetByteSize() - offset;
if (length > bytes_available)
@@ -173,7 +173,7 @@ DataExtractor::DataExtractor(const DataExtractor &rhs)
: m_start(rhs.m_start), m_end(rhs.m_end), m_byte_order(rhs.m_byte_order),
m_addr_size(rhs.m_addr_size), m_data_sp(rhs.m_data_sp),
m_target_byte_size(rhs.m_target_byte_size) {
- assert(m_addr_size == 4 || m_addr_size == 8);
+ assert(m_addr_size >= 1 && m_addr_size <= 8);
}
// Assignment operator
@@ -251,7 +251,7 @@ lldb::offset_t DataExtractor::SetData(const DataExtractor &data,
offset_t data_offset,
offset_t data_length) {
m_addr_size = data.m_addr_size;
- assert(m_addr_size == 4 || m_addr_size == 8);
+ assert(m_addr_size >= 1 && m_addr_size <= 8);
// If "data" contains shared pointer to data, then we can use that
if (data.m_data_sp) {
m_byte_order = data.m_byte_order;
@@ -604,59 +604,30 @@ uint64_t DataExtractor::GetMaxU64Bitfield(offset_t *offset_ptr, size_t size,
int64_t DataExtractor::GetMaxS64Bitfield(offset_t *offset_ptr, size_t size,
uint32_t bitfield_bit_size,
uint32_t bitfield_bit_offset) const {
+ assert(size >= 1 && "GetMaxS64Bitfield size must be >= 1");
+ assert(size <= 8 && "GetMaxS64Bitfield size must be <= 8");
int64_t sval64 = GetMaxS64(offset_ptr, size);
- if (bitfield_bit_size > 0) {
- int32_t lsbcount = bitfield_bit_offset;
- if (m_byte_order == eByteOrderBig)
- lsbcount = size * 8 - bitfield_bit_offset - bitfield_bit_size;
- if (lsbcount > 0)
- sval64 >>= lsbcount;
- uint64_t bitfield_mask =
- ((static_cast<uint64_t>(1)) << bitfield_bit_size) - 1;
- sval64 &= bitfield_mask;
- // sign extend if needed
- if (sval64 & ((static_cast<uint64_t>(1)) << (bitfield_bit_size - 1)))
- sval64 |= ~bitfield_mask;
- }
+ if (bitfield_bit_size == 0)
+ return sval64;
+ int32_t lsbcount = bitfield_bit_offset;
+ if (m_byte_order == eByteOrderBig)
+ lsbcount = size * 8 - bitfield_bit_offset - bitfield_bit_size;
+ if (lsbcount > 0)
+ sval64 >>= lsbcount;
+ uint64_t bitfield_mask = llvm::maskTrailingOnes<uint64_t>(bitfield_bit_size);
+ sval64 &= bitfield_mask;
+ // sign extend if needed
+ if (sval64 & ((static_cast<uint64_t>(1)) << (bitfield_bit_size - 1)))
+ sval64 |= ~bitfield_mask;
return sval64;
}
float DataExtractor::GetFloat(offset_t *offset_ptr) const {
- typedef float float_type;
- float_type val = 0.0;
- const size_t src_size = sizeof(float_type);
- const float_type *src =
- static_cast<const float_type *>(GetData(offset_ptr, src_size));
- if (src) {
- if (m_byte_order != endian::InlHostByteOrder()) {
- const uint8_t *src_data = reinterpret_cast<const uint8_t *>(src);
- uint8_t *dst_data = reinterpret_cast<uint8_t *>(&val);
- for (size_t i = 0; i < sizeof(float_type); ++i)
- dst_data[sizeof(float_type) - 1 - i] = src_data[i];
- } else {
- val = *src;
- }
- }
- return val;
+ return Get<float>(offset_ptr, 0.0f);
}
double DataExtractor::GetDouble(offset_t *offset_ptr) const {
- typedef double float_type;
- float_type val = 0.0;
- const size_t src_size = sizeof(float_type);
- const float_type *src =
- static_cast<const float_type *>(GetData(offset_ptr, src_size));
- if (src) {
- if (m_byte_order != endian::InlHostByteOrder()) {
- const uint8_t *src_data = reinterpret_cast<const uint8_t *>(src);
- uint8_t *dst_data = reinterpret_cast<uint8_t *>(&val);
- for (size_t i = 0; i < sizeof(float_type); ++i)
- dst_data[sizeof(float_type) - 1 - i] = src_data[i];
- } else {
- val = *src;
- }
- }
- return val;
+ return Get<double>(offset_ptr, 0.0);
}
long double DataExtractor::GetLongDouble(offset_t *offset_ptr) const {
@@ -679,26 +650,15 @@ long double DataExtractor::GetLongDouble(offset_t *offset_ptr) const {
//
// RETURNS the address that was extracted, or zero on failure.
uint64_t DataExtractor::GetAddress(offset_t *offset_ptr) const {
- assert(m_addr_size == 4 || m_addr_size == 8);
+ assert(m_addr_size >= 1 && m_addr_size <= 8);
return GetMaxU64(offset_ptr, m_addr_size);
}
uint64_t DataExtractor::GetAddress_unchecked(offset_t *offset_ptr) const {
- assert(m_addr_size == 4 || m_addr_size == 8);
+ assert(m_addr_size >= 1 && m_addr_size <= 8);
return GetMaxU64_unchecked(offset_ptr, m_addr_size);
}
-// Extract a single pointer from the data and update the offset pointed to by
-// "offset_ptr". The size of the extracted pointer comes from the
-// "this->m_addr_size" member variable and should be set correctly prior to
-// extracting any pointer values.
-//
-// RETURNS the pointer that was extracted, or zero on failure.
-uint64_t DataExtractor::GetPointer(offset_t *offset_ptr) const {
- assert(m_addr_size == 4 || m_addr_size == 8);
- return GetMaxU64(offset_ptr, m_addr_size);
-}
-
size_t DataExtractor::ExtractBytes(offset_t offset, offset_t length,
ByteOrder dst_byte_order, void *dst) const {
const uint8_t *src = PeekData(offset, length);
@@ -887,26 +847,10 @@ uint64_t DataExtractor::GetULEB128(offset_t *offset_ptr) const {
if (src == nullptr)
return 0;
- const uint8_t *end = m_end;
-
- if (src < end) {
- uint64_t result = *src++;
- if (result >= 0x80) {
- result &= 0x7f;
- int shift = 7;
- while (src < end) {
- uint8_t byte = *src++;
- result |= static_cast<uint64_t>(byte & 0x7f) << shift;
- if ((byte & 0x80) == 0)
- break;
- shift += 7;
- }
- }
- *offset_ptr = src - m_start;
- return result;
- }
-
- return 0;
+ unsigned byte_count = 0;
+ uint64_t result = llvm::decodeULEB128(src, &byte_count, m_end);
+ *offset_ptr += byte_count;
+ return result;
}
// Extracts an signed LEB128 number from this object's data starting at the
@@ -920,33 +864,10 @@ int64_t DataExtractor::GetSLEB128(offset_t *offset_ptr) const {
if (src == nullptr)
return 0;
- const uint8_t *end = m_end;
-
- if (src < end) {
- int64_t result = 0;
- int shift = 0;
- int size = sizeof(int64_t) * 8;
-
- uint8_t byte = 0;
- int bytecount = 0;
-
- while (src < end) {
- bytecount++;
- byte = *src++;
- result |= static_cast<int64_t>(byte & 0x7f) << shift;
- shift += 7;
- if ((byte & 0x80) == 0)
- break;
- }
-
- // Sign bit of byte is 2nd high order bit (0x40)
- if (shift < size && (byte & 0x40))
- result |= -(1 << shift);
-
- *offset_ptr += bytecount;
- return result;
- }
- return 0;
+ unsigned byte_count = 0;
+ int64_t result = llvm::decodeSLEB128(src, &byte_count, m_end);
+ *offset_ptr += byte_count;
+ return result;
}
// Skips a ULEB128 number (signed or unsigned) from this object's data starting
@@ -1012,7 +933,7 @@ lldb::offset_t DataExtractor::PutToLog(Log *log, offset_t start_offset,
break;
case TypeChar: {
char ch = GetU8(&offset);
- sstr.Printf(" %c", isprint(ch) ? ch : ' ');
+ sstr.Printf(" %c", llvm::isPrint(ch) ? ch : ' ');
} break;
case TypeUInt16:
sstr.Printf(" %4.4x", GetU16(&offset));
diff --git a/lldb/source/Utility/Environment.cpp b/lldb/source/Utility/Environment.cpp
index 8cafd3024618..5666c2c12ffd 100644
--- a/lldb/source/Utility/Environment.cpp
+++ b/lldb/source/Utility/Environment.cpp
@@ -1,4 +1,4 @@
-//===-- Environment.cpp -----------------------------------------*- C++ -*-===//
+//===-- Environment.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/Event.cpp b/lldb/source/Utility/Event.cpp
index 579d0dac86ed..50cc7f061dc6 100644
--- a/lldb/source/Utility/Event.cpp
+++ b/lldb/source/Utility/Event.cpp
@@ -1,4 +1,4 @@
-//===-- Event.cpp -----------------------------------------------*- C++ -*-===//
+//===-- Event.cpp ---------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -125,7 +125,7 @@ ConstString EventDataBytes::GetFlavor() const {
void EventDataBytes::Dump(Stream *s) const {
size_t num_printable_chars =
- std::count_if(m_bytes.begin(), m_bytes.end(), isprint);
+ std::count_if(m_bytes.begin(), m_bytes.end(), llvm::isPrint);
if (num_printable_chars == m_bytes.size())
s->Format("\"{0}\"", m_bytes);
else
diff --git a/lldb/source/Utility/FileSpec.cpp b/lldb/source/Utility/FileSpec.cpp
index 5c216d947f75..1ec5d60e2780 100644
--- a/lldb/source/Utility/FileSpec.cpp
+++ b/lldb/source/Utility/FileSpec.cpp
@@ -1,4 +1,4 @@
-//===-- FileSpec.cpp --------------------------------------------*- C++ -*-===//
+//===-- FileSpec.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -537,3 +537,19 @@ void llvm::format_provider<FileSpec>::format(const FileSpec &F,
if (!file.empty())
Stream << file;
}
+
+void llvm::yaml::ScalarEnumerationTraits<FileSpecStyle>::enumeration(
+ IO &io, FileSpecStyle &value) {
+ io.enumCase(value, "windows", FileSpecStyle(FileSpec::Style::windows));
+ io.enumCase(value, "posix", FileSpecStyle(FileSpec::Style::posix));
+ io.enumCase(value, "native", FileSpecStyle(FileSpec::Style::native));
+}
+
+void llvm::yaml::MappingTraits<FileSpec>::mapping(IO &io, FileSpec &f) {
+ io.mapRequired("directory", f.m_directory);
+ io.mapRequired("file", f.m_filename);
+ io.mapRequired("resolved", f.m_is_resolved);
+ FileSpecStyle style = f.m_style;
+ io.mapRequired("style", style);
+ f.m_style = style;
+}
diff --git a/lldb/source/Utility/IOObject.cpp b/lldb/source/Utility/IOObject.cpp
index 5e3ccddb6a30..964edce0ce10 100644
--- a/lldb/source/Utility/IOObject.cpp
+++ b/lldb/source/Utility/IOObject.cpp
@@ -1,4 +1,4 @@
-//===-- IOObject.cpp --------------------------------------------*- C++ -*-===//
+//===-- IOObject.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/LLDBAssert.cpp b/lldb/source/Utility/LLDBAssert.cpp
index 361d6d04a28f..6ae0ee50ef14 100644
--- a/lldb/source/Utility/LLDBAssert.cpp
+++ b/lldb/source/Utility/LLDBAssert.cpp
@@ -1,4 +1,4 @@
-//===--------------------- LLDBAssert.cpp ------------------------*- C++-*-===//
+//===-- LLDBAssert.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/Listener.cpp b/lldb/source/Utility/Listener.cpp
index c2e537ba7dee..d2a4f3293963 100644
--- a/lldb/source/Utility/Listener.cpp
+++ b/lldb/source/Utility/Listener.cpp
@@ -1,4 +1,4 @@
-//===-- Listener.cpp --------------------------------------------*- C++ -*-===//
+//===-- Listener.cpp ------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/Log.cpp b/lldb/source/Utility/Log.cpp
index ab5e630114a6..4df82f2bf4d7 100644
--- a/lldb/source/Utility/Log.cpp
+++ b/lldb/source/Utility/Log.cpp
@@ -1,4 +1,4 @@
-//===-- Log.cpp -------------------------------------------------*- C++ -*-===//
+//===-- Log.cpp -----------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -138,7 +138,7 @@ void Log::VAPrintf(const char *format, va_list args) {
Stream << Content << "\n";
- WriteMessage(FinalMessage.str());
+ WriteMessage(std::string(FinalMessage.str()));
}
// Printing of errors that are not fatal.
diff --git a/lldb/source/Utility/Logging.cpp b/lldb/source/Utility/Logging.cpp
index 22f38192fa5d..435017e9d744 100644
--- a/lldb/source/Utility/Logging.cpp
+++ b/lldb/source/Utility/Logging.cpp
@@ -1,4 +1,4 @@
-//===-- Logging.cpp ---------------------------------------------*- C++ -*-===//
+//===-- Logging.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/NameMatches.cpp b/lldb/source/Utility/NameMatches.cpp
index 5c9579ea7332..1c8cd6a0ca31 100644
--- a/lldb/source/Utility/NameMatches.cpp
+++ b/lldb/source/Utility/NameMatches.cpp
@@ -1,4 +1,4 @@
-//===-- NameMatches.cpp -----------------------------------------*- C++ -*-===//
+//===-- NameMatches.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/PPC64LE_DWARF_Registers.h b/lldb/source/Utility/PPC64LE_DWARF_Registers.h
index 548c1fda8600..cd53e7a2abd0 100644
--- a/lldb/source/Utility/PPC64LE_DWARF_Registers.h
+++ b/lldb/source/Utility/PPC64LE_DWARF_Registers.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef utility_PPC64LE_DWARF_Registers_h_
-#define utility_PPC64LE_DWARF_Registers_h_
+#ifndef LLDB_SOURCE_UTILITY_PPC64LE_DWARF_REGISTERS_H
+#define LLDB_SOURCE_UTILITY_PPC64LE_DWARF_REGISTERS_H
#include "lldb/lldb-private.h"
@@ -190,4 +190,4 @@ enum {
} // namespace ppc64le_dwarf
-#endif // utility_PPC64LE_DWARF_Registers_h_
+#endif // LLDB_SOURCE_UTILITY_PPC64LE_DWARF_REGISTERS_H
diff --git a/lldb/source/Utility/PPC64_DWARF_Registers.h b/lldb/source/Utility/PPC64_DWARF_Registers.h
index 6ba5b6ac3727..4f279be01b27 100644
--- a/lldb/source/Utility/PPC64_DWARF_Registers.h
+++ b/lldb/source/Utility/PPC64_DWARF_Registers.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef utility_PPC64_DWARF_Registers_h_
-#define utility_PPC64_DWARF_Registers_h_
+#ifndef LLDB_SOURCE_UTILITY_PPC64_DWARF_REGISTERS_H
+#define LLDB_SOURCE_UTILITY_PPC64_DWARF_REGISTERS_H
#include "lldb/lldb-private.h"
@@ -123,4 +123,4 @@ enum {
} // namespace ppc64_dwarf
-#endif // utility_PPC64_DWARF_Registers_h_
+#endif // LLDB_SOURCE_UTILITY_PPC64_DWARF_REGISTERS_H
diff --git a/lldb/source/Utility/ProcessInfo.cpp b/lldb/source/Utility/ProcessInfo.cpp
index b159e2641973..aae48d6a4872 100644
--- a/lldb/source/Utility/ProcessInfo.cpp
+++ b/lldb/source/Utility/ProcessInfo.cpp
@@ -1,4 +1,4 @@
-//===-- ProcessInfo.cpp -----------------------------------------*- C++ -*-===//
+//===-- ProcessInfo.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -18,6 +18,7 @@
using namespace lldb;
using namespace lldb_private;
+using namespace lldb_private::repro;
ProcessInfo::ProcessInfo()
: m_executable(), m_arguments(), m_environment(), m_uid(UINT32_MAX),
@@ -75,7 +76,7 @@ void ProcessInfo::SetExecutableFile(const FileSpec &exe_file,
llvm::StringRef ProcessInfo::GetArg0() const { return m_arg0; }
-void ProcessInfo::SetArg0(llvm::StringRef arg) { m_arg0 = arg; }
+void ProcessInfo::SetArg0(llvm::StringRef arg) { m_arg0 = std::string(arg); }
void ProcessInfo::SetArguments(char const **argv,
bool first_arg_is_executable) {
@@ -331,3 +332,100 @@ void ProcessInstanceInfoMatch::Clear() {
m_name_match_type = NameMatch::Ignore;
m_match_all_users = false;
}
+
+void llvm::yaml::MappingTraits<ProcessInstanceInfo>::mapping(
+ IO &io, ProcessInstanceInfo &Info) {
+ io.mapRequired("executable", Info.m_executable);
+ io.mapRequired("arg0", Info.m_arg0);
+ io.mapRequired("args", Info.m_arguments);
+ io.mapRequired("arch", Info.m_arch);
+ io.mapRequired("uid", Info.m_uid);
+ io.mapRequired("gid", Info.m_gid);
+ io.mapRequired("pid", Info.m_pid);
+ io.mapRequired("effective-uid", Info.m_euid);
+ io.mapRequired("effective-gid", Info.m_egid);
+ io.mapRequired("parent-pid", Info.m_parent_pid);
+}
+
+llvm::Expected<std::unique_ptr<ProcessInfoRecorder>>
+ProcessInfoRecorder::Create(const FileSpec &filename) {
+ std::error_code ec;
+ auto recorder =
+ std::make_unique<ProcessInfoRecorder>(std::move(filename), ec);
+ if (ec)
+ return llvm::errorCodeToError(ec);
+ return std::move(recorder);
+}
+
+void ProcessInfoProvider::Keep() {
+ std::vector<std::string> files;
+ for (auto &recorder : m_process_info_recorders) {
+ recorder->Stop();
+ files.push_back(recorder->GetFilename().GetPath());
+ }
+
+ FileSpec file = GetRoot().CopyByAppendingPathComponent(Info::file);
+ std::error_code ec;
+ llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::OF_Text);
+ if (ec)
+ return;
+ llvm::yaml::Output yout(os);
+ yout << files;
+}
+
+void ProcessInfoProvider::Discard() { m_process_info_recorders.clear(); }
+
+ProcessInfoRecorder *ProcessInfoProvider::GetNewProcessInfoRecorder() {
+ std::size_t i = m_process_info_recorders.size() + 1;
+ std::string filename = (llvm::Twine(Info::name) + llvm::Twine("-") +
+ llvm::Twine(i) + llvm::Twine(".yaml"))
+ .str();
+ auto recorder_or_error = ProcessInfoRecorder::Create(
+ GetRoot().CopyByAppendingPathComponent(filename));
+ if (!recorder_or_error) {
+ llvm::consumeError(recorder_or_error.takeError());
+ return nullptr;
+ }
+
+ m_process_info_recorders.push_back(std::move(*recorder_or_error));
+ return m_process_info_recorders.back().get();
+}
+
+void ProcessInfoRecorder::Record(const ProcessInstanceInfoList &process_infos) {
+ if (!m_record)
+ return;
+ llvm::yaml::Output yout(m_os);
+ yout << const_cast<ProcessInstanceInfoList &>(process_infos);
+ m_os.flush();
+}
+
+llvm::Optional<ProcessInstanceInfoList>
+repro::GetReplayProcessInstanceInfoList() {
+ static std::unique_ptr<repro::MultiLoader<repro::ProcessInfoProvider>>
+ loader = repro::MultiLoader<repro::ProcessInfoProvider>::Create(
+ repro::Reproducer::Instance().GetLoader());
+
+ if (!loader)
+ return {};
+
+ llvm::Optional<std::string> nextfile = loader->GetNextFile();
+ if (!nextfile)
+ return {};
+
+ auto error_or_file = llvm::MemoryBuffer::getFile(*nextfile);
+ if (std::error_code err = error_or_file.getError())
+ return {};
+
+ ProcessInstanceInfoList infos;
+ llvm::yaml::Input yin((*error_or_file)->getBuffer());
+ yin >> infos;
+
+ if (auto err = yin.error())
+ return {};
+
+ return infos;
+}
+
+char ProcessInfoProvider::ID = 0;
+const char *ProcessInfoProvider::Info::file = "process-info.yaml";
+const char *ProcessInfoProvider::Info::name = "process-info";
diff --git a/lldb/source/Utility/RegisterValue.cpp b/lldb/source/Utility/RegisterValue.cpp
index 36790f5d8efa..7f545c214a4c 100644
--- a/lldb/source/Utility/RegisterValue.cpp
+++ b/lldb/source/Utility/RegisterValue.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterValue.cpp ---------------------------------------*- C++ -*-===//
+//===-- RegisterValue.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -441,7 +441,7 @@ Status RegisterValue::SetValueFromString(const RegisterInfo *reg_info,
break;
case eEncodingIEEE754: {
- std::string value_string = value_str;
+ std::string value_string = std::string(value_str);
if (byte_size == sizeof(float)) {
if (::sscanf(value_string.c_str(), "%f", &flt_val) != 1) {
error.SetErrorStringWithFormat("'%s' is not a valid float string value",
@@ -728,7 +728,8 @@ const void *RegisterValue::GetBytes() const {
case eTypeFloat:
case eTypeDouble:
case eTypeLongDouble:
- return m_scalar.GetBytes();
+ m_scalar.GetBytes(buffer.bytes);
+ return buffer.bytes;
case eTypeBytes:
return buffer.bytes;
}
@@ -810,7 +811,7 @@ bool RegisterValue::operator==(const RegisterValue &rhs) const {
if (buffer.length != rhs.buffer.length)
return false;
else {
- uint8_t length = buffer.length;
+ uint16_t length = buffer.length;
if (length > kMaxRegisterByteSize)
length = kMaxRegisterByteSize;
return memcmp(buffer.bytes, rhs.buffer.bytes, length) == 0;
diff --git a/lldb/source/Utility/RegularExpression.cpp b/lldb/source/Utility/RegularExpression.cpp
index fd9d963f7294..20bebbfe15f2 100644
--- a/lldb/source/Utility/RegularExpression.cpp
+++ b/lldb/source/Utility/RegularExpression.cpp
@@ -1,4 +1,4 @@
-//===-- RegularExpression.cpp -----------------------------------*- C++ -*-===//
+//===-- RegularExpression.cpp ---------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -13,7 +13,7 @@
using namespace lldb_private;
RegularExpression::RegularExpression(llvm::StringRef str)
- : m_regex_text(str),
+ : m_regex_text(std::string(str)),
// m_regex does not reference str anymore after it is constructed.
m_regex(llvm::Regex(str)) {}
@@ -35,7 +35,7 @@ llvm::StringRef RegularExpression::GetText() const { return m_regex_text; }
llvm::Error RegularExpression::GetError() const {
std::string error;
if (!m_regex.isValid(error))
- return llvm::make_error<llvm::StringError>(llvm::inconvertibleErrorCode(),
- error);
+ return llvm::make_error<llvm::StringError>(error,
+ llvm::inconvertibleErrorCode());
return llvm::Error::success();
}
diff --git a/lldb/source/Utility/Reproducer.cpp b/lldb/source/Utility/Reproducer.cpp
index b11e1a577ed2..7620ab2c389d 100644
--- a/lldb/source/Utility/Reproducer.cpp
+++ b/lldb/source/Utility/Reproducer.cpp
@@ -1,4 +1,4 @@
-//===-- Reproducer.cpp ------------------------------------------*- C++ -*-===//
+//===-- Reproducer.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -18,6 +18,15 @@ using namespace lldb_private::repro;
using namespace llvm;
using namespace llvm::yaml;
+static llvm::Optional<bool> GetEnv(const char *var) {
+ std::string val = llvm::StringRef(getenv(var)).lower();
+ if (val == "0" || val == "off")
+ return false;
+ if (val == "1" || val == "on")
+ return true;
+ return {};
+}
+
Reproducer &Reproducer::Instance() { return *InstanceImpl(); }
llvm::Error Reproducer::Initialize(ReproducerMode mode,
@@ -27,12 +36,12 @@ llvm::Error Reproducer::Initialize(ReproducerMode mode,
// The environment can override the capture mode.
if (mode != ReproducerMode::Replay) {
- std::string env =
- llvm::StringRef(getenv("LLDB_CAPTURE_REPRODUCER")).lower();
- if (env == "0" || env == "off")
- mode = ReproducerMode::Off;
- else if (env == "1" || env == "on")
- mode = ReproducerMode::Capture;
+ if (llvm::Optional<bool> override = GetEnv("LLDB_CAPTURE_REPRODUCER")) {
+ if (*override)
+ mode = ReproducerMode::Capture;
+ else
+ mode = ReproducerMode::Off;
+ }
}
switch (mode) {
@@ -53,7 +62,9 @@ llvm::Error Reproducer::Initialize(ReproducerMode mode,
return Instance().SetCapture(root);
} break;
case ReproducerMode::Replay:
- return Instance().SetReplay(root);
+ return Instance().SetReplay(root, /*passive*/ false);
+ case ReproducerMode::PassiveReplay:
+ return Instance().SetReplay(root, /*passive*/ true);
case ReproducerMode::Off:
break;
};
@@ -118,7 +129,7 @@ llvm::Error Reproducer::SetCapture(llvm::Optional<FileSpec> root) {
return Error::success();
}
-llvm::Error Reproducer::SetReplay(llvm::Optional<FileSpec> root) {
+llvm::Error Reproducer::SetReplay(llvm::Optional<FileSpec> root, bool passive) {
std::lock_guard<std::mutex> guard(m_mutex);
if (root && m_generator)
@@ -131,7 +142,7 @@ llvm::Error Reproducer::SetReplay(llvm::Optional<FileSpec> root) {
return Error::success();
}
- m_loader.emplace(*root);
+ m_loader.emplace(*root, passive);
if (auto e = m_loader->LoadIndex())
return e;
@@ -158,8 +169,12 @@ Generator::Generator(FileSpec root) : m_root(MakeAbsolute(std::move(root))) {
}
Generator::~Generator() {
- if (!m_done)
- Discard();
+ if (!m_done) {
+ if (m_auto_generate)
+ Keep();
+ else
+ Discard();
+ }
}
ProviderBase *Generator::Register(std::unique_ptr<ProviderBase> provider) {
@@ -190,6 +205,10 @@ void Generator::Discard() {
llvm::sys::fs::remove_directories(m_root.GetPath());
}
+void Generator::SetAutoGenerate(bool b) { m_auto_generate = b; }
+
+bool Generator::IsAutoGenerate() const { return m_auto_generate; }
+
const FileSpec &Generator::GetRoot() const { return m_root; }
void Generator::AddProvidersToIndex() {
@@ -210,8 +229,9 @@ void Generator::AddProvidersToIndex() {
yout << files;
}
-Loader::Loader(FileSpec root)
- : m_root(MakeAbsolute(std::move(root))), m_loaded(false) {}
+Loader::Loader(FileSpec root, bool passive)
+ : m_root(MakeAbsolute(std::move(root))), m_loaded(false),
+ m_passive_replay(passive) {}
llvm::Error Loader::LoadIndex() {
if (m_loaded)
@@ -252,40 +272,15 @@ DataRecorder::Create(const FileSpec &filename) {
return std::move(recorder);
}
-DataRecorder *CommandProvider::GetNewDataRecorder() {
- std::size_t i = m_data_recorders.size() + 1;
- std::string filename = (llvm::Twine(Info::name) + llvm::Twine("-") +
- llvm::Twine(i) + llvm::Twine(".yaml"))
- .str();
- auto recorder_or_error =
- DataRecorder::Create(GetRoot().CopyByAppendingPathComponent(filename));
- if (!recorder_or_error) {
- llvm::consumeError(recorder_or_error.takeError());
- return nullptr;
- }
-
- m_data_recorders.push_back(std::move(*recorder_or_error));
- return m_data_recorders.back().get();
-}
-
-void CommandProvider::Keep() {
- std::vector<std::string> files;
- for (auto &recorder : m_data_recorders) {
- recorder->Stop();
- files.push_back(recorder->GetFilename().GetPath());
- }
-
- FileSpec file = GetRoot().CopyByAppendingPathComponent(Info::file);
+llvm::Expected<std::unique_ptr<YamlRecorder>>
+YamlRecorder::Create(const FileSpec &filename) {
std::error_code ec;
- llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::OF_Text);
+ auto recorder = std::make_unique<YamlRecorder>(std::move(filename), ec);
if (ec)
- return;
- yaml::Output yout(os);
- yout << files;
+ return llvm::errorCodeToError(ec);
+ return std::move(recorder);
}
-void CommandProvider::Discard() { m_data_recorders.clear(); }
-
void VersionProvider::Keep() {
FileSpec file = GetRoot().CopyByAppendingPathComponent(Info::file);
std::error_code ec;
@@ -304,6 +299,11 @@ void WorkingDirectoryProvider::Keep() {
os << m_cwd << "\n";
}
+void FileProvider::recordInterestingDirectory(const llvm::Twine &dir) {
+ if (m_collector)
+ m_collector->addDirectory(dir);
+}
+
void ProviderBase::anchor() {}
char CommandProvider::ID = 0;
char FileProvider::ID = 0;
diff --git a/lldb/source/Utility/ReproducerInstrumentation.cpp b/lldb/source/Utility/ReproducerInstrumentation.cpp
index 473786ef4d3e..09aea69d8313 100644
--- a/lldb/source/Utility/ReproducerInstrumentation.cpp
+++ b/lldb/source/Utility/ReproducerInstrumentation.cpp
@@ -1,4 +1,4 @@
-//===-- ReproducerInstrumentation.cpp ---------------------------*- C++ -*-===//
+//===-- ReproducerInstrumentation.cpp -------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -8,6 +8,9 @@
#include "lldb/Utility/ReproducerInstrumentation.h"
#include "lldb/Utility/Reproducer.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <thread>
using namespace lldb_private;
using namespace lldb_private::repro;
@@ -21,19 +24,66 @@ void IndexToObject::AddObjectForIndexImpl(unsigned idx, void *object) {
m_mapping[idx] = object;
}
+std::vector<void *> IndexToObject::GetAllObjects() const {
+ std::vector<std::pair<unsigned, void *>> pairs;
+ for (auto &e : m_mapping) {
+ pairs.emplace_back(e.first, e.second);
+ }
+
+ // Sort based on index.
+ std::sort(pairs.begin(), pairs.end(),
+ [](auto &lhs, auto &rhs) { return lhs.first < rhs.first; });
+
+ std::vector<void *> objects;
+ objects.reserve(pairs.size());
+ for (auto &p : pairs) {
+ objects.push_back(p.second);
+ }
+
+ return objects;
+}
+
+template <> const uint8_t *Deserializer::Deserialize<const uint8_t *>() {
+ return Deserialize<uint8_t *>();
+}
+
+template <> void *Deserializer::Deserialize<void *>() {
+ return const_cast<void *>(Deserialize<const void *>());
+}
+
+template <> const void *Deserializer::Deserialize<const void *>() {
+ return nullptr;
+}
+
template <> char *Deserializer::Deserialize<char *>() {
return const_cast<char *>(Deserialize<const char *>());
}
template <> const char *Deserializer::Deserialize<const char *>() {
- auto pos = m_buffer.find('\0');
- if (pos == llvm::StringRef::npos)
+ const size_t size = Deserialize<size_t>();
+ if (size == std::numeric_limits<size_t>::max())
return nullptr;
+ assert(HasData(size + 1));
const char *str = m_buffer.data();
- m_buffer = m_buffer.drop_front(pos + 1);
+ m_buffer = m_buffer.drop_front(size + 1);
+#ifdef LLDB_REPRO_INSTR_TRACE
+ llvm::errs() << "Deserializing with " << LLVM_PRETTY_FUNCTION << " -> \""
+ << str << "\"\n";
+#endif
return str;
}
+template <> const char **Deserializer::Deserialize<const char **>() {
+ const size_t size = Deserialize<size_t>();
+ if (size == 0)
+ return nullptr;
+ const char **r =
+ reinterpret_cast<const char **>(calloc(size + 1, sizeof(char *)));
+ for (size_t i = 0; i < size; ++i)
+ r[i] = Deserialize<const char *>();
+ return r;
+}
+
bool Registry::Replay(const FileSpec &file) {
auto error_or_file = llvm::MemoryBuffer::getFile(file.GetPath());
if (auto err = error_or_file.getError())
@@ -43,11 +93,19 @@ bool Registry::Replay(const FileSpec &file) {
}
bool Registry::Replay(llvm::StringRef buffer) {
+ Deserializer deserializer(buffer);
+ return Replay(deserializer);
+}
+
+bool Registry::Replay(Deserializer &deserializer) {
#ifndef LLDB_REPRO_INSTR_TRACE
Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_API);
#endif
- Deserializer deserializer(buffer);
+ // Disable buffering stdout so that we approximate the way things get flushed
+ // during an interactive session.
+ setvbuf(stdout, nullptr, _IONBF, 0);
+
while (deserializer.HasData(1)) {
unsigned id = deserializer.Deserialize<unsigned>();
@@ -60,6 +118,10 @@ bool Registry::Replay(llvm::StringRef buffer) {
GetReplayer(id)->operator()(deserializer);
}
+ // Add a small artificial delay to ensure that all asynchronous events have
+ // completed before we exit.
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+
return true;
}
@@ -83,6 +145,22 @@ std::string Registry::GetSignature(unsigned id) {
return m_ids[id].second.ToString();
}
+void Registry::CheckID(unsigned expected, unsigned actual) {
+ if (expected != actual) {
+ llvm::errs() << "Reproducer expected signature " << expected << ": '"
+ << GetSignature(expected) << "'\n";
+ llvm::errs() << "Reproducer actual signature " << actual << ": '"
+ << GetSignature(actual) << "'\n";
+ llvm::report_fatal_error(
+ "Detected reproducer replay divergence. Refusing to continue.");
+ }
+
+#ifdef LLDB_REPRO_INSTR_TRACE
+ llvm::errs() << "Replaying " << actual << ": " << GetSignature(actual)
+ << "\n";
+#endif
+}
+
Replayer *Registry::GetReplayer(unsigned id) {
assert(m_ids.count(id) != 0 && "ID not in registry");
return m_ids[id].first;
@@ -101,6 +179,15 @@ unsigned ObjectToIndex::GetIndexForObjectImpl(const void *object) {
return m_mapping[object];
}
+Recorder::Recorder()
+ : m_serializer(nullptr), m_pretty_func(), m_pretty_args(),
+ m_local_boundary(false), m_result_recorded(true) {
+ if (!g_global_boundary) {
+ g_global_boundary = true;
+ m_local_boundary = true;
+ }
+}
+
Recorder::Recorder(llvm::StringRef pretty_func, std::string &&pretty_args)
: m_serializer(nullptr), m_pretty_func(pretty_func),
m_pretty_args(pretty_args), m_local_boundary(false),
@@ -119,4 +206,25 @@ Recorder::~Recorder() {
UpdateBoundary();
}
+void InstrumentationData::Initialize(Serializer &serializer,
+ Registry &registry) {
+ InstanceImpl().emplace(serializer, registry);
+}
+
+void InstrumentationData::Initialize(Deserializer &deserializer,
+ Registry &registry) {
+ InstanceImpl().emplace(deserializer, registry);
+}
+
+InstrumentationData &InstrumentationData::Instance() {
+ if (!InstanceImpl())
+ InstanceImpl().emplace();
+ return *InstanceImpl();
+}
+
+llvm::Optional<InstrumentationData> &InstrumentationData::InstanceImpl() {
+ static llvm::Optional<InstrumentationData> g_instrumentation_data;
+ return g_instrumentation_data;
+}
+
bool lldb_private::repro::Recorder::g_global_boundary;
diff --git a/lldb/source/Utility/Scalar.cpp b/lldb/source/Utility/Scalar.cpp
index a9293e87220b..6c48bbde532f 100644
--- a/lldb/source/Utility/Scalar.cpp
+++ b/lldb/source/Utility/Scalar.cpp
@@ -1,4 +1,4 @@
-//===-- Scalar.cpp ----------------------------------------------*- C++ -*-===//
+//===-- Scalar.cpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,14 +7,14 @@
//===----------------------------------------------------------------------===//
#include "lldb/Utility/Scalar.h"
-
+#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Endian.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/lldb-types.h"
-
+#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/SmallString.h"
#include <cinttypes>
@@ -23,6 +23,63 @@
using namespace lldb;
using namespace lldb_private;
+using llvm::APFloat;
+using llvm::APInt;
+
+namespace {
+enum class Category { Void, Integral, Float };
+}
+
+static Category GetCategory(Scalar::Type type) {
+ switch (type) {
+ case Scalar::e_void:
+ return Category::Void;
+ case Scalar::e_float:
+ case Scalar::e_double:
+ case Scalar::e_long_double:
+ return Category::Float;
+ case Scalar::e_sint:
+ case Scalar::e_slong:
+ case Scalar::e_slonglong:
+ case Scalar::e_sint128:
+ case Scalar::e_sint256:
+ case Scalar::e_sint512:
+ case Scalar::e_uint:
+ case Scalar::e_ulong:
+ case Scalar::e_ulonglong:
+ case Scalar::e_uint128:
+ case Scalar::e_uint256:
+ case Scalar::e_uint512:
+ return Category::Integral;
+ }
+ llvm_unreachable("Unhandled type!");
+}
+
+static bool IsSigned(Scalar::Type type) {
+ switch (type) {
+ case Scalar::e_void:
+ case Scalar::e_uint:
+ case Scalar::e_ulong:
+ case Scalar::e_ulonglong:
+ case Scalar::e_uint128:
+ case Scalar::e_uint256:
+ case Scalar::e_uint512:
+ return false;
+ case Scalar::e_sint:
+ case Scalar::e_slong:
+ case Scalar::e_slonglong:
+ case Scalar::e_sint128:
+ case Scalar::e_sint256:
+ case Scalar::e_sint512:
+ case Scalar::e_float:
+ case Scalar::e_double:
+ case Scalar::e_long_double:
+ return true;
+ }
+ llvm_unreachable("Unhandled type!");
+}
+
+
// Promote to max type currently follows the ANSI C rule for type promotion in
// expressions.
static Scalar::Type PromoteToMaxType(
@@ -73,112 +130,49 @@ Scalar::Scalar() : m_type(e_void), m_float(static_cast<float>(0)) {}
bool Scalar::GetData(DataExtractor &data, size_t limit_byte_size) const {
size_t byte_size = GetByteSize();
- if (byte_size > 0) {
- const uint8_t *bytes = static_cast<const uint8_t *>(GetBytes());
-
- if (limit_byte_size < byte_size) {
- 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...
- byte_size = limit_byte_size;
- } 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
- bytes += byte_size - limit_byte_size;
- byte_size = limit_byte_size;
- }
+ if (byte_size == 0) {
+ data.Clear();
+ return false;
+ }
+ auto buffer_up = std::make_unique<DataBufferHeap>(byte_size, 0);
+ GetBytes(buffer_up->GetData());
+ lldb::offset_t offset = 0;
+
+ if (limit_byte_size < byte_size) {
+ 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...
+ byte_size = limit_byte_size;
+ } 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
+ offset = byte_size - limit_byte_size;
+ byte_size = limit_byte_size;
}
-
- data.SetData(bytes, byte_size, endian::InlHostByteOrder());
- return true;
}
- data.Clear();
- return false;
+
+ data.SetData(std::move(buffer_up), offset, byte_size);
+ data.SetByteOrder(endian::InlHostByteOrder());
+ return true;
}
-const void *Scalar::GetBytes() const {
- const uint64_t *apint_words;
- const uint8_t *bytes;
- static float_t flt_val;
- static double_t dbl_val;
- static uint64_t swapped_words[8];
- switch (m_type) {
- case e_void:
+void Scalar::GetBytes(llvm::MutableArrayRef<uint8_t> storage) const {
+ assert(storage.size() >= GetByteSize());
+
+ const auto &store = [&](const llvm::APInt val) {
+ StoreIntToMemory(val, storage.data(), (val.getBitWidth() + 7) / 8);
+ };
+ switch (GetCategory(m_type)) {
+ case Category::Void:
+ break;
+ case Category::Integral:
+ store(m_integer);
+ break;
+ case Category::Float:
+ store(m_float.bitcastToAPInt());
break;
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- bytes = reinterpret_cast<const uint8_t *>(m_integer.getRawData());
- // getRawData always returns a pointer to an uint64_t. If we have a
- // smaller type, we need to update the pointer on big-endian systems.
- if (endian::InlHostByteOrder() == eByteOrderBig) {
- size_t byte_size = m_integer.getBitWidth() / 8;
- if (byte_size < 8)
- bytes += 8 - byte_size;
- }
- return bytes;
- // getRawData always returns a pointer to an array of uint64_t values,
- // where the least-significant word always comes first. On big-endian
- // systems we need to swap the words.
- case e_sint128:
- case e_uint128:
- apint_words = m_integer.getRawData();
- if (endian::InlHostByteOrder() == eByteOrderBig) {
- swapped_words[0] = apint_words[1];
- swapped_words[1] = apint_words[0];
- apint_words = swapped_words;
- }
- return static_cast<const void *>(apint_words);
- case e_sint256:
- case e_uint256:
- apint_words = m_integer.getRawData();
- if (endian::InlHostByteOrder() == eByteOrderBig) {
- swapped_words[0] = apint_words[3];
- swapped_words[1] = apint_words[2];
- swapped_words[2] = apint_words[1];
- swapped_words[3] = apint_words[0];
- apint_words = swapped_words;
- }
- return static_cast<const void *>(apint_words);
- case e_sint512:
- case e_uint512:
- apint_words = m_integer.getRawData();
- if (endian::InlHostByteOrder() == eByteOrderBig) {
- swapped_words[0] = apint_words[7];
- swapped_words[1] = apint_words[6];
- swapped_words[2] = apint_words[5];
- swapped_words[3] = apint_words[4];
- swapped_words[4] = apint_words[3];
- swapped_words[5] = apint_words[2];
- swapped_words[6] = apint_words[1];
- swapped_words[7] = apint_words[0];
- apint_words = swapped_words;
- }
- return static_cast<const void *>(apint_words);
- case e_float:
- flt_val = m_float.convertToFloat();
- return static_cast<const void *>(&flt_val);
- case e_double:
- dbl_val = m_float.convertToDouble();
- return static_cast<const void *>(&dbl_val);
- case e_long_double:
- llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- apint_words = ldbl_val.getRawData();
- // getRawData always returns a pointer to an array of two uint64_t values,
- // where the least-significant word always comes first. On big-endian
- // systems we need to swap the two words.
- if (endian::InlHostByteOrder() == eByteOrderBig) {
- swapped_words[0] = apint_words[1];
- swapped_words[1] = apint_words[0];
- apint_words = swapped_words;
- }
- return static_cast<const void *>(apint_words);
}
- return nullptr;
}
size_t Scalar::GetByteSize() const {
@@ -209,26 +203,12 @@ size_t Scalar::GetByteSize() const {
}
bool Scalar::IsZero() const {
- llvm::APInt zero_int = llvm::APInt::getNullValue(m_integer.getBitWidth() / 8);
- switch (m_type) {
- case e_void:
+ switch (GetCategory(m_type)) {
+ case Category::Void:
break;
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_uint512:
- case e_sint512:
- return llvm::APInt::isSameValue(zero_int, m_integer);
- case e_float:
- case e_double:
- case e_long_double:
+ case Category::Integral:
+ return m_integer.isNullValue();
+ case Category::Float:
return m_float.isZero();
}
return false;
@@ -238,171 +218,18 @@ void Scalar::GetValue(Stream *s, bool show_type) const {
if (show_type)
s->Printf("(%s) ", GetTypeAsCString());
- switch (m_type) {
- case e_void:
+ switch (GetCategory(m_type)) {
+ case Category::Void:
break;
- case e_sint:
- case e_slong:
- case e_slonglong:
- case e_sint128:
- case e_sint256:
- case e_sint512:
- s->PutCString(m_integer.toString(10, true));
+ case Category::Integral:
+ s->PutCString(m_integer.toString(10, IsSigned(m_type)));
break;
- case e_uint:
- case e_ulong:
- case e_ulonglong:
- case e_uint128:
- case e_uint256:
- case e_uint512:
- s->PutCString(m_integer.toString(10, false));
- break;
- case e_float:
- case e_double:
- case e_long_double:
+ case Category::Float:
llvm::SmallString<24> string;
m_float.toString(string);
- s->Printf("%s", string.c_str());
- break;
- }
-}
-
-const char *Scalar::GetTypeAsCString() const {
- switch (m_type) {
- case e_void:
- return "void";
- case e_sint:
- return "int";
- case e_uint:
- return "unsigned int";
- case e_slong:
- return "long";
- 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_sint256:
- return "int256_t";
- case e_uint256:
- return "unsigned int256_t";
- case e_sint512:
- return "int512_t";
- case e_uint512:
- return "unsigned int512_t";
- case e_float:
- return "float";
- case e_double:
- return "double";
- case e_long_double:
- return "long double";
- }
- return "<invalid Scalar type>";
-}
-
-Scalar &Scalar::operator=(const int v) {
- m_type = e_sint;
- m_integer = llvm::APInt(sizeof(int) * 8, v, true);
- return *this;
-}
-
-Scalar &Scalar::operator=(unsigned int v) {
- m_type = e_uint;
- m_integer = llvm::APInt(sizeof(int) * 8, v);
- return *this;
-}
-
-Scalar &Scalar::operator=(long v) {
- m_type = e_slong;
- m_integer = llvm::APInt(sizeof(long) * 8, v, true);
- return *this;
-}
-
-Scalar &Scalar::operator=(unsigned long v) {
- m_type = e_ulong;
- m_integer = llvm::APInt(sizeof(long) * 8, v);
- return *this;
-}
-
-Scalar &Scalar::operator=(long long v) {
- m_type = e_slonglong;
- m_integer = llvm::APInt(sizeof(long) * 8, v, true);
- return *this;
-}
-
-Scalar &Scalar::operator=(unsigned long long v) {
- m_type = e_ulonglong;
- m_integer = llvm::APInt(sizeof(long long) * 8, v);
- return *this;
-}
-
-Scalar &Scalar::operator=(float v) {
- m_type = e_float;
- m_float = llvm::APFloat(v);
- return *this;
-}
-
-Scalar &Scalar::operator=(double v) {
- m_type = e_double;
- m_float = llvm::APFloat(v);
- return *this;
-}
-
-Scalar &Scalar::operator=(long double v) {
- m_type = e_long_double;
- if (m_ieee_quad)
- m_float = llvm::APFloat(llvm::APFloat::IEEEquad(),
- llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
- (reinterpret_cast<type128 *>(&v))->x));
- else
- m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended(),
- llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
- (reinterpret_cast<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;
- case 256:
- if (m_integer.isSignedIntN(BITWIDTH_INT256))
- m_type = e_sint256;
- else
- m_type = e_uint256;
- break;
- case 512:
- if (m_integer.isSignedIntN(BITWIDTH_INT512))
- m_type = e_sint512;
- else
- m_type = e_uint512;
+ s->PutCString(string);
break;
}
- return *this;
}
Scalar::~Scalar() = default;
@@ -427,716 +254,111 @@ Scalar::Type Scalar::GetBestTypeForBitSize(size_t bit_size, bool sign) {
return Scalar::e_void;
}
-void Scalar::TruncOrExtendTo(Scalar::Type type, uint16_t bits) {
+void Scalar::TruncOrExtendTo(uint16_t bits, bool sign) {
+ m_integer = sign ? m_integer.sextOrTrunc(bits) : m_integer.zextOrTrunc(bits);
+ m_type = GetBestTypeForBitSize(bits, sign);
+}
+
+static size_t GetBitSize(Scalar::Type type) {
switch (type) {
- case e_sint:
- case e_slong:
- case e_slonglong:
- case e_sint128:
- case e_sint256:
- case e_sint512:
- m_integer = m_integer.sextOrTrunc(bits);
- break;
- case e_uint:
- case e_ulong:
- case e_ulonglong:
- case e_uint128:
- case e_uint256:
- case e_uint512:
- m_integer = m_integer.zextOrTrunc(bits);
- break;
- default:
- llvm_unreachable("Promoting a Scalar to a specific number of bits is only "
- "supported for integer types.");
+ case Scalar::e_void:
+ return 0;
+ case Scalar::e_sint:
+ return 8 * sizeof(int);
+ case Scalar::e_uint:
+ return 8 * sizeof(unsigned int);
+ case Scalar::e_slong:
+ return 8 * sizeof(long);
+ case Scalar::e_ulong:
+ return 8 * sizeof(unsigned long);
+ case Scalar::e_slonglong:
+ return 8 * sizeof(long long);
+ case Scalar::e_ulonglong:
+ return 8 * sizeof(unsigned long long);
+ case Scalar::e_sint128:
+ case Scalar::e_uint128:
+ return BITWIDTH_INT128;
+ case Scalar::e_sint256:
+ case Scalar::e_uint256:
+ return BITWIDTH_INT256;
+ case Scalar::e_sint512:
+ case Scalar::e_uint512:
+ return BITWIDTH_INT512;
+ case Scalar::e_float:
+ return 8 * sizeof(float);
+ case Scalar::e_double:
+ return 8 * sizeof(double);
+ case Scalar::e_long_double:
+ return 8 * sizeof(long double);
}
- m_type = type;
+ llvm_unreachable("Unhandled type!");
+}
+
+static const llvm::fltSemantics &GetFltSemantics(Scalar::Type type) {
+ switch (type) {
+ case Scalar::e_void:
+ case Scalar::e_sint:
+ case Scalar::e_slong:
+ case Scalar::e_slonglong:
+ case Scalar::e_sint128:
+ case Scalar::e_sint256:
+ case Scalar::e_sint512:
+ case Scalar::e_uint:
+ case Scalar::e_ulong:
+ case Scalar::e_ulonglong:
+ case Scalar::e_uint128:
+ case Scalar::e_uint256:
+ case Scalar::e_uint512:
+ llvm_unreachable("Only floating point types supported!");
+ case Scalar::e_float:
+ return llvm::APFloat::IEEEsingle();
+ case Scalar::e_double:
+ return llvm::APFloat::IEEEdouble();
+ case Scalar::e_long_double:
+ return llvm::APFloat::x87DoubleExtended();
+ }
+ llvm_unreachable("Unhandled type!");
}
bool Scalar::Promote(Scalar::Type type) {
bool success = false;
- switch (m_type) {
- case e_void:
- break;
-
- case e_sint:
- switch (type) {
- case e_void:
- break;
- case e_sint:
- success = true;
- break;
- case e_uint:
- m_integer = m_integer.sextOrTrunc(sizeof(uint_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.sextOrTrunc(sizeof(ulong_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.sextOrTrunc(sizeof(ulonglong_t) * 8);
- success = true;
- break;
-
- case e_sint128:
- case e_uint128:
- m_integer = m_integer.sextOrTrunc(BITWIDTH_INT128);
- success = true;
- break;
-
- case e_sint256:
- case e_uint256:
- m_integer = m_integer.sextOrTrunc(BITWIDTH_INT256);
- success = true;
- break;
-
- case e_sint512:
- case e_uint512:
- m_integer = m_integer.sextOrTrunc(BITWIDTH_INT512);
- success = true;
- break;
-
- case e_float:
- m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
- m_float.convertFromAPInt(m_integer, true,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
-
- case e_double:
- m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
- m_float.convertFromAPInt(m_integer, true,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
-
- case e_long_double:
- m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
- : llvm::APFloat::x87DoubleExtended());
- m_float.convertFromAPInt(m_integer, true,
- llvm::APFloat::rmNearestTiesToEven);
- 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_integer = m_integer.zextOrTrunc(sizeof(slong_t) * 8);
- success = true;
- break;
-
- case e_ulong:
- m_integer = m_integer.zextOrTrunc(sizeof(ulong_t) * 8);
- success = true;
- break;
-
- case e_slonglong:
- m_integer = m_integer.zextOrTrunc(sizeof(slonglong_t) * 8);
- success = true;
- break;
-
- case e_ulonglong:
- m_integer = m_integer.zextOrTrunc(sizeof(ulonglong_t) * 8);
- success = true;
- break;
-
- case e_sint128:
- case e_uint128:
- m_integer = m_integer.zextOrTrunc(BITWIDTH_INT128);
- success = true;
- break;
-
- case e_sint256:
- case e_uint256:
- m_integer = m_integer.zextOrTrunc(BITWIDTH_INT256);
- success = true;
- break;
-
- case e_sint512:
- case e_uint512:
- m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512);
- success = true;
- break;
-
- case e_float:
- m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
- m_float.convertFromAPInt(m_integer, false,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
-
- case e_double:
- m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
- m_float.convertFromAPInt(m_integer, false,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
-
- case e_long_double:
- m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
- : llvm::APFloat::x87DoubleExtended());
- m_float.convertFromAPInt(m_integer, false,
- llvm::APFloat::rmNearestTiesToEven);
- 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_integer = m_integer.sextOrTrunc(sizeof(ulong_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.sextOrTrunc(sizeof(ulonglong_t) * 8);
- success = true;
- break;
-
- case e_sint128:
- case e_uint128:
- m_integer = m_integer.sextOrTrunc(BITWIDTH_INT128);
- success = true;
- break;
-
- case e_sint256:
- case e_uint256:
- m_integer = m_integer.sextOrTrunc(BITWIDTH_INT256);
- success = true;
- break;
-
- case e_sint512:
- case e_uint512:
- m_integer = m_integer.sextOrTrunc(BITWIDTH_INT512);
- success = true;
- break;
-
- case e_float:
- m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
- m_float.convertFromAPInt(m_integer, true,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
-
- case e_double:
- m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
- m_float.convertFromAPInt(m_integer, true,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
-
- case e_long_double:
- m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
- : llvm::APFloat::x87DoubleExtended());
- m_float.convertFromAPInt(m_integer, true,
- llvm::APFloat::rmNearestTiesToEven);
- 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_integer = m_integer.zextOrTrunc(sizeof(slonglong_t) * 8);
- success = true;
- break;
-
- case e_ulonglong:
- m_integer = m_integer.zextOrTrunc(sizeof(ulonglong_t) * 8);
- success = true;
- break;
-
- case e_sint128:
- case e_uint128:
- m_integer = m_integer.zextOrTrunc(BITWIDTH_INT128);
- success = true;
- break;
-
- case e_sint256:
- case e_uint256:
- m_integer = m_integer.zextOrTrunc(BITWIDTH_INT256);
- success = true;
- break;
-
- case e_sint512:
- case e_uint512:
- m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512);
- success = true;
- break;
-
- case e_float:
- m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
- m_float.convertFromAPInt(m_integer, false,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
-
- case e_double:
- m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
- m_float.convertFromAPInt(m_integer, false,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
-
- case e_long_double:
- m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
- : llvm::APFloat::x87DoubleExtended());
- m_float.convertFromAPInt(m_integer, false,
- llvm::APFloat::rmNearestTiesToEven);
- 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_integer = m_integer.sextOrTrunc(sizeof(ulonglong_t) * 8);
- success = true;
- break;
-
- case e_sint128:
- case e_uint128:
- m_integer = m_integer.sextOrTrunc(BITWIDTH_INT128);
- success = true;
- break;
-
- case e_sint256:
- case e_uint256:
- m_integer = m_integer.sextOrTrunc(BITWIDTH_INT256);
- success = true;
- break;
-
- case e_sint512:
- case e_uint512:
- m_integer = m_integer.sextOrTrunc(BITWIDTH_INT512);
- success = true;
- break;
-
- case e_float:
- m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
- m_float.convertFromAPInt(m_integer, true,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
-
- case e_double:
- m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
- m_float.convertFromAPInt(m_integer, true,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
-
- case e_long_double:
- m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
- : llvm::APFloat::x87DoubleExtended());
- m_float.convertFromAPInt(m_integer, true,
- llvm::APFloat::rmNearestTiesToEven);
- 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_sint128:
- case e_uint128:
- m_integer = m_integer.zextOrTrunc(BITWIDTH_INT128);
- success = true;
- break;
-
- case e_sint256:
- case e_uint256:
- m_integer = m_integer.zextOrTrunc(BITWIDTH_INT256);
- success = true;
- break;
-
- case e_sint512:
- case e_uint512:
- m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512);
- success = true;
- break;
-
- case e_float:
- m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
- m_float.convertFromAPInt(m_integer, false,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
-
- case e_double:
- m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
- m_float.convertFromAPInt(m_integer, false,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
-
- case e_long_double:
- m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
- : llvm::APFloat::x87DoubleExtended());
- m_float.convertFromAPInt(m_integer, false,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
- }
+ switch (GetCategory(m_type)) {
+ case Category::Void:
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 = m_integer.sextOrTrunc(BITWIDTH_INT128);
- success = true;
- break;
-
- case e_sint256:
- case e_uint256:
- m_integer = m_integer.sextOrTrunc(BITWIDTH_INT256);
- success = true;
- break;
-
- case e_sint512:
- case e_uint512:
- m_integer = m_integer.sextOrTrunc(BITWIDTH_INT512);
- success = true;
+ case Category::Integral:
+ switch (GetCategory(type)) {
+ case Category::Void:
break;
-
- case e_float:
- m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
- m_float.convertFromAPInt(m_integer, true,
- llvm::APFloat::rmNearestTiesToEven);
+ case Category::Integral:
+ if (type < m_type)
+ break;
success = true;
+ if (IsSigned(m_type))
+ m_integer = m_integer.sextOrTrunc(GetBitSize(type));
+ else
+ m_integer = m_integer.zextOrTrunc(GetBitSize(type));
break;
-
- case e_double:
- m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
- m_float.convertFromAPInt(m_integer, true,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
-
- case e_long_double:
- m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
- : llvm::APFloat::x87DoubleExtended());
- m_float.convertFromAPInt(m_integer, true,
+ case Category::Float:
+ m_float = llvm::APFloat(GetFltSemantics(type));
+ m_float.convertFromAPInt(m_integer, IsSigned(m_type),
llvm::APFloat::rmNearestTiesToEven);
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_sint256:
- case e_uint256:
- m_integer = m_integer.zextOrTrunc(BITWIDTH_INT256);
- success = true;
- break;
-
- case e_sint512:
- case e_uint512:
- m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512);
- success = true;
- break;
-
- case e_float:
- m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
- m_float.convertFromAPInt(m_integer, false,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
-
- case e_double:
- m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
- m_float.convertFromAPInt(m_integer, false,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
-
- case e_long_double:
- m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
- : llvm::APFloat::x87DoubleExtended());
- m_float.convertFromAPInt(m_integer, false,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
- }
- break;
-
- case e_sint256:
- 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:
- case e_uint128:
+ case Category::Float:
+ switch (GetCategory(type)) {
+ case Category::Void:
+ case Category::Integral:
break;
- case e_sint256:
- success = true;
- break;
- case e_uint256:
- m_integer = m_integer.sextOrTrunc(BITWIDTH_INT256);
- success = true;
- break;
-
- case e_sint512:
- case e_uint512:
- m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512);
- success = true;
- break;
-
- case e_float:
- m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
- m_float.convertFromAPInt(m_integer, true,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
-
- case e_double:
- m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
- m_float.convertFromAPInt(m_integer, true,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
-
- case e_long_double:
- m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
- : llvm::APFloat::x87DoubleExtended());
- m_float.convertFromAPInt(m_integer, true,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
- }
- break;
-
- case e_uint256:
- 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:
- case e_uint128:
- case e_sint256:
- break;
- case e_uint256:
- success = true;
- break;
-
- case e_sint512:
- case e_uint512:
- m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512);
- success = true;
- break;
-
- case e_float:
- m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
- m_float.convertFromAPInt(m_integer, false,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
-
- case e_double:
- m_float = llvm::APFloat(llvm::APFloat::IEEEdouble());
- m_float.convertFromAPInt(m_integer, false,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
-
- case e_long_double:
- m_float = llvm::APFloat(m_ieee_quad ? llvm::APFloat::IEEEquad()
- : llvm::APFloat::x87DoubleExtended());
- m_float.convertFromAPInt(m_integer, false,
- llvm::APFloat::rmNearestTiesToEven);
- success = true;
- break;
- }
- break;
-
- case e_sint512:
- case e_uint512:
- lldbassert(false && "unimplemented");
- 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:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_uint512:
- case e_sint512:
- break;
- case e_float:
- success = true;
- break;
- case e_double:
- m_float = llvm::APFloat(static_cast<double_t>(m_float.convertToFloat()));
- success = true;
- break;
-
- case e_long_double: {
- bool ignore;
- m_float.convert(m_ieee_quad ? llvm::APFloat::IEEEquad()
- : llvm::APFloat::x87DoubleExtended(),
- llvm::APFloat::rmNearestTiesToEven, &ignore);
- 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_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
- case e_float:
- break;
- case e_double:
- success = true;
- break;
- case e_long_double: {
+ case Category::Float:
+ if (type < m_type)
+ break;
bool ignore;
- m_float.convert(m_ieee_quad ? llvm::APFloat::IEEEquad()
- : llvm::APFloat::x87DoubleExtended(),
- llvm::APFloat::rmNearestTiesToEven, &ignore);
success = true;
- break;
- }
+ m_float.convert(GetFltSemantics(type), llvm::APFloat::rmNearestTiesToEven,
+ &ignore);
}
- break;
-
- case e_long_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_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
- case e_float:
- case e_double:
- break;
- case e_long_double:
- success = true;
- break;
- }
- break;
}
if (success)
@@ -1338,444 +560,132 @@ bool Scalar::MakeUnsigned() {
return success;
}
-signed char Scalar::SChar(char fail_value) const {
- switch (m_type) {
- case e_void:
+static llvm::APInt ToAPInt(const llvm::APFloat &f, unsigned bits,
+ bool is_unsigned) {
+ llvm::APSInt result(bits, is_unsigned);
+ bool isExact;
+ f.convertToInteger(result, llvm::APFloat::rmTowardZero, &isExact);
+ return std::move(result);
+}
+
+template <typename T> T Scalar::GetAs(T fail_value) const {
+ switch (GetCategory(m_type)) {
+ case Category::Void:
break;
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
- return static_cast<schar_t>(
- (m_integer.sextOrTrunc(sizeof(schar_t) * 8)).getSExtValue());
- case e_float:
- return static_cast<schar_t>(m_float.convertToFloat());
- case e_double:
- return static_cast<schar_t>(m_float.convertToDouble());
- case e_long_double:
- llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return static_cast<schar_t>(
- (ldbl_val.sextOrTrunc(sizeof(schar_t) * 8)).getSExtValue());
+ case Category::Integral:
+ if (IsSigned(m_type))
+ return m_integer.sextOrTrunc(sizeof(T) * 8).getSExtValue();
+ return m_integer.zextOrTrunc(sizeof(T) * 8).getZExtValue();
+ case Category::Float:
+ return ToAPInt(m_float, sizeof(T) * 8, std::is_unsigned<T>::value)
+ .getSExtValue();
}
return fail_value;
}
+signed char Scalar::SChar(signed char fail_value) const {
+ return GetAs<signed char>(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:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
- return static_cast<uchar_t>(
- (m_integer.zextOrTrunc(sizeof(uchar_t) * 8)).getZExtValue());
- case e_float:
- return static_cast<uchar_t>(m_float.convertToFloat());
- case e_double:
- return static_cast<uchar_t>(m_float.convertToDouble());
- case e_long_double:
- llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return static_cast<uchar_t>(
- (ldbl_val.zextOrTrunc(sizeof(uchar_t) * 8)).getZExtValue());
- }
- return fail_value;
+ return GetAs<unsigned char>(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:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
- return static_cast<sshort_t>(
- (m_integer.sextOrTrunc(sizeof(sshort_t) * 8)).getSExtValue());
- case e_float:
- return static_cast<sshort_t>(m_float.convertToFloat());
- case e_double:
- return static_cast<sshort_t>(m_float.convertToDouble());
- case e_long_double:
- llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return static_cast<sshort_t>(
- (ldbl_val.sextOrTrunc(sizeof(sshort_t) * 8)).getSExtValue());
- }
- return fail_value;
+ return GetAs<short>(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:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
- return static_cast<ushort_t>(
- (m_integer.zextOrTrunc(sizeof(ushort_t) * 8)).getZExtValue());
- case e_float:
- return static_cast<ushort_t>(m_float.convertToFloat());
- case e_double:
- return static_cast<ushort_t>(m_float.convertToDouble());
- case e_long_double:
- llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return static_cast<ushort_t>(
- (ldbl_val.zextOrTrunc(sizeof(ushort_t) * 8)).getZExtValue());
- }
- return fail_value;
+ return GetAs<unsigned short>(fail_value);
}
-int Scalar::SInt(int fail_value) const {
- switch (m_type) {
- case e_void:
- break;
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
- return static_cast<sint_t>(
- (m_integer.sextOrTrunc(sizeof(sint_t) * 8)).getSExtValue());
- case e_float:
- return static_cast<sint_t>(m_float.convertToFloat());
- case e_double:
- return static_cast<sint_t>(m_float.convertToDouble());
- case e_long_double:
- llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return static_cast<sint_t>(
- (ldbl_val.sextOrTrunc(sizeof(sint_t) * 8)).getSExtValue());
- }
- return fail_value;
-}
+int Scalar::SInt(int fail_value) const { return GetAs<int>(fail_value); }
unsigned int Scalar::UInt(unsigned int fail_value) const {
- switch (m_type) {
- case e_void:
- break;
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
- return static_cast<uint_t>(
- (m_integer.zextOrTrunc(sizeof(uint_t) * 8)).getZExtValue());
- case e_float:
- return static_cast<uint_t>(m_float.convertToFloat());
- case e_double:
- return static_cast<uint_t>(m_float.convertToDouble());
- case e_long_double:
- llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return static_cast<uint_t>(
- (ldbl_val.zextOrTrunc(sizeof(uint_t) * 8)).getZExtValue());
- }
- return fail_value;
+ return GetAs<unsigned int>(fail_value);
}
-long Scalar::SLong(long fail_value) const {
- switch (m_type) {
- case e_void:
- break;
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
- return static_cast<slong_t>(
- (m_integer.sextOrTrunc(sizeof(slong_t) * 8)).getSExtValue());
- case e_float:
- return static_cast<slong_t>(m_float.convertToFloat());
- case e_double:
- return static_cast<slong_t>(m_float.convertToDouble());
- case e_long_double:
- llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return static_cast<slong_t>(
- (ldbl_val.sextOrTrunc(sizeof(slong_t) * 8)).getSExtValue());
- }
- return fail_value;
-}
+long Scalar::SLong(long fail_value) const { return GetAs<long>(fail_value); }
unsigned long Scalar::ULong(unsigned long fail_value) const {
- switch (m_type) {
- case e_void:
- break;
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
- return static_cast<ulong_t>(
- (m_integer.zextOrTrunc(sizeof(ulong_t) * 8)).getZExtValue());
- case e_float:
- return static_cast<ulong_t>(m_float.convertToFloat());
- case e_double:
- return static_cast<ulong_t>(m_float.convertToDouble());
- case e_long_double:
- llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return static_cast<ulong_t>(
- (ldbl_val.zextOrTrunc(sizeof(ulong_t) * 8)).getZExtValue());
- }
- return fail_value;
+ return GetAs<unsigned long>(fail_value);
}
long long Scalar::SLongLong(long long fail_value) const {
- switch (m_type) {
- case e_void:
- break;
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
- return static_cast<slonglong_t>(
- (m_integer.sextOrTrunc(sizeof(slonglong_t) * 8)).getSExtValue());
- case e_float:
- return static_cast<slonglong_t>(m_float.convertToFloat());
- case e_double:
- return static_cast<slonglong_t>(m_float.convertToDouble());
- case e_long_double:
- llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return static_cast<slonglong_t>(
- (ldbl_val.sextOrTrunc(sizeof(slonglong_t) * 8)).getSExtValue());
- }
- return fail_value;
+ return GetAs<long long>(fail_value);
}
unsigned long long Scalar::ULongLong(unsigned long long fail_value) const {
- switch (m_type) {
- case e_void:
- break;
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
- return static_cast<ulonglong_t>(
- (m_integer.zextOrTrunc(sizeof(ulonglong_t) * 8)).getZExtValue());
- case e_float:
- return static_cast<ulonglong_t>(m_float.convertToFloat());
- case e_double: {
- double d_val = m_float.convertToDouble();
- llvm::APInt rounded_double =
- llvm::APIntOps::RoundDoubleToAPInt(d_val, sizeof(ulonglong_t) * 8);
- return static_cast<ulonglong_t>(
- (rounded_double.zextOrTrunc(sizeof(ulonglong_t) * 8)).getZExtValue());
- }
- case e_long_double:
- llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return static_cast<ulonglong_t>(
- (ldbl_val.zextOrTrunc(sizeof(ulonglong_t) * 8)).getZExtValue());
- }
- return fail_value;
+ return GetAs<unsigned long long>(fail_value);
}
-llvm::APInt Scalar::SInt128(llvm::APInt &fail_value) const {
- switch (m_type) {
- case e_void:
+llvm::APInt Scalar::SInt128(const llvm::APInt &fail_value) const {
+ switch (GetCategory(m_type)) {
+ case Category::Void:
break;
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
+ case Category::Integral:
return m_integer;
- case e_float:
- case e_double:
- case e_long_double:
- return m_float.bitcastToAPInt();
+ case Category::Float:
+ return ToAPInt(m_float, 128, /*is_unsigned=*/false);
}
return fail_value;
}
llvm::APInt Scalar::UInt128(const llvm::APInt &fail_value) const {
- switch (m_type) {
- case e_void:
+ switch (GetCategory(m_type)) {
+ case Category::Void:
break;
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
+ case Category::Integral:
return m_integer;
- case e_float:
- case e_double:
- case e_long_double:
- return m_float.bitcastToAPInt();
+ case Category::Float:
+ return ToAPInt(m_float, 128, /*is_unsigned=*/true);
}
return fail_value;
}
float Scalar::Float(float fail_value) const {
- switch (m_type) {
- case e_void:
+ switch (GetCategory(m_type)) {
+ case Category::Void:
break;
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
+ case Category::Integral:
+ if (IsSigned(m_type))
+ return llvm::APIntOps::RoundSignedAPIntToFloat(m_integer);
return llvm::APIntOps::RoundAPIntToFloat(m_integer);
- case e_float:
- return m_float.convertToFloat();
- case e_double:
- return static_cast<float_t>(m_float.convertToDouble());
- case e_long_double:
- llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return ldbl_val.bitsToFloat();
+
+ case Category::Float: {
+ APFloat result = m_float;
+ bool losesInfo;
+ result.convert(APFloat::IEEEsingle(), APFloat::rmNearestTiesToEven,
+ &losesInfo);
+ return result.convertToFloat();
+ }
}
return fail_value;
}
double Scalar::Double(double fail_value) const {
- switch (m_type) {
- case e_void:
+ switch (GetCategory(m_type)) {
+ case Category::Void:
break;
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
+ case Category::Integral:
+ if (IsSigned(m_type))
+ return llvm::APIntOps::RoundSignedAPIntToDouble(m_integer);
return llvm::APIntOps::RoundAPIntToDouble(m_integer);
- case e_float:
- return static_cast<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();
+
+ case Category::Float: {
+ APFloat result = m_float;
+ bool losesInfo;
+ result.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven,
+ &losesInfo);
+ return result.convertToDouble();
+ }
}
return fail_value;
}
long double Scalar::LongDouble(long double fail_value) const {
- switch (m_type) {
- case e_void:
- break;
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
- return static_cast<long_double_t>(
- llvm::APIntOps::RoundAPIntToDouble(m_integer));
- case e_float:
- return static_cast<long_double_t>(m_float.convertToFloat());
- case e_double:
- return static_cast<long_double_t>(m_float.convertToDouble());
- case e_long_double:
- llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return static_cast<long_double_t>(ldbl_val.bitsToDouble());
- }
- return fail_value;
+ /// No way to get more precision at the moment.
+ return static_cast<long double>(Double(fail_value));
}
Scalar &Scalar::operator+=(const Scalar &rhs) {
@@ -1784,27 +694,14 @@ Scalar &Scalar::operator+=(const Scalar &rhs) {
const Scalar *b;
if ((m_type = PromoteToMaxType(*this, rhs, temp_value, a, b)) !=
Scalar::e_void) {
- switch (m_type) {
- case e_void:
+ switch (GetCategory(m_type)) {
+ case Category::Void:
break;
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
+ case Category::Integral:
m_integer = a->m_integer + b->m_integer;
break;
- case e_float:
- case e_double:
- case e_long_double:
+ case Category::Float:
m_float = a->m_float + b->m_float;
break;
}
@@ -1813,99 +710,22 @@ Scalar &Scalar::operator+=(const Scalar &rhs) {
}
Scalar &Scalar::operator<<=(const Scalar &rhs) {
- switch (m_type) {
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
+ if (GetCategory(m_type) == Category::Integral &&
+ GetCategory(rhs.m_type) == Category::Integral)
+ m_integer <<= rhs.m_integer;
+ else
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:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
- 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:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
- m_integer = m_integer << rhs.m_integer;
- break;
- }
- break;
- }
return *this;
}
bool Scalar::ShiftRightLogical(const Scalar &rhs) {
- switch (m_type) {
- 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:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
- 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:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
- m_integer = m_integer.lshr(rhs.m_integer);
- break;
- }
- break;
+ if (GetCategory(m_type) == Category::Integral &&
+ GetCategory(rhs.m_type) == Category::Integral) {
+ m_integer = m_integer.lshr(rhs.m_integer);
+ return true;
}
- return m_type != e_void;
+ m_type = e_void;
+ return false;
}
Scalar &Scalar::operator>>=(const Scalar &rhs) {
@@ -1957,50 +777,11 @@ Scalar &Scalar::operator>>=(const Scalar &rhs) {
}
Scalar &Scalar::operator&=(const Scalar &rhs) {
- switch (m_type) {
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
+ if (GetCategory(m_type) == Category::Integral &&
+ GetCategory(rhs.m_type) == Category::Integral)
+ m_integer &= rhs.m_integer;
+ else
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:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
- 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:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
- m_integer &= rhs.m_integer;
- break;
- }
- break;
- }
return *this;
}
@@ -2036,26 +817,13 @@ bool Scalar::AbsoluteValue() {
}
bool Scalar::UnaryNegate() {
- switch (m_type) {
- case e_void:
+ switch (GetCategory(m_type)) {
+ case Category::Void:
break;
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
+ case Category::Integral:
m_integer = -m_integer;
return true;
- case e_float:
- case e_double:
- case e_long_double:
+ case Category::Float:
m_float.changeSign();
return true;
}
@@ -2063,62 +831,17 @@ bool Scalar::UnaryNegate() {
}
bool Scalar::OnesComplement() {
- switch (m_type) {
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- case e_sint512:
- case e_uint512:
+ if (GetCategory(m_type) == Category::Integral) {
m_integer = ~m_integer;
return true;
-
- case e_void:
- case e_float:
- case e_double:
- case e_long_double:
- break;
}
+
return false;
}
const Scalar lldb_private::operator+(const Scalar &lhs, const Scalar &rhs) {
- Scalar result;
- Scalar temp_value;
- const Scalar *a;
- const Scalar *b;
- if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) !=
- Scalar::e_void) {
- switch (result.m_type) {
- 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:
- case Scalar::e_sint256:
- case Scalar::e_uint256:
- case Scalar::e_sint512:
- case Scalar::e_uint512:
- result.m_integer = a->m_integer + b->m_integer;
- break;
- case Scalar::e_float:
- case Scalar::e_double:
- case Scalar::e_long_double:
- result.m_float = a->m_float + b->m_float;
- break;
- }
- }
+ Scalar result = lhs;
+ result += rhs;
return result;
}
@@ -2129,26 +852,13 @@ const Scalar lldb_private::operator-(const Scalar &lhs, const Scalar &rhs) {
const Scalar *b;
if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) !=
Scalar::e_void) {
- switch (result.m_type) {
- case Scalar::e_void:
+ switch (GetCategory(result.m_type)) {
+ case Category::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:
- case Scalar::e_sint256:
- case Scalar::e_uint256:
- case Scalar::e_sint512:
- case Scalar::e_uint512:
+ case Category::Integral:
result.m_integer = a->m_integer - b->m_integer;
break;
- case Scalar::e_float:
- case Scalar::e_double:
- case Scalar::e_long_double:
+ case Category::Float:
result.m_float = a->m_float - b->m_float;
break;
}
@@ -2162,40 +872,20 @@ const Scalar lldb_private::operator/(const Scalar &lhs, const Scalar &rhs) {
const Scalar *a;
const Scalar *b;
if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) !=
- Scalar::e_void) {
- switch (result.m_type) {
- case Scalar::e_void:
+ Scalar::e_void &&
+ !b->IsZero()) {
+ switch (GetCategory(result.m_type)) {
+ case Category::Void:
break;
- case Scalar::e_sint:
- case Scalar::e_slong:
- case Scalar::e_slonglong:
- case Scalar::e_sint128:
- case Scalar::e_sint256:
- case Scalar::e_sint512:
- if (b->m_integer != 0) {
+ case Category::Integral:
+ if (IsSigned(result.m_type))
result.m_integer = a->m_integer.sdiv(b->m_integer);
- return result;
- }
- break;
- case Scalar::e_uint:
- case Scalar::e_ulong:
- case Scalar::e_ulonglong:
- case Scalar::e_uint128:
- case Scalar::e_uint256:
- case Scalar::e_uint512:
- if (b->m_integer != 0) {
+ else
result.m_integer = a->m_integer.udiv(b->m_integer);
- 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;
+ return result;
+ case Category::Float:
+ result.m_float = a->m_float / b->m_float;
+ return result;
}
}
// For division only, the only way it should make it here is if a promotion
@@ -2211,26 +901,13 @@ const Scalar lldb_private::operator*(const Scalar &lhs, const Scalar &rhs) {
const Scalar *b;
if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) !=
Scalar::e_void) {
- switch (result.m_type) {
- case Scalar::e_void:
+ switch (GetCategory(result.m_type)) {
+ case Category::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:
- case Scalar::e_sint256:
- case Scalar::e_uint256:
- case Scalar::e_sint512:
- case Scalar::e_uint512:
+ case Category::Integral:
result.m_integer = a->m_integer * b->m_integer;
break;
- case Scalar::e_float:
- case Scalar::e_double:
- case Scalar::e_long_double:
+ case Category::Float:
result.m_float = a->m_float * b->m_float;
break;
}
@@ -2245,29 +922,10 @@ const Scalar lldb_private::operator&(const Scalar &lhs, const Scalar &rhs) {
const Scalar *b;
if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) !=
Scalar::e_void) {
- switch (result.m_type) {
- 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:
- case Scalar::e_sint256:
- case Scalar::e_uint256:
- case Scalar::e_sint512:
- case Scalar::e_uint512:
+ if (GetCategory(result.m_type) == Category::Integral)
result.m_integer = a->m_integer & b->m_integer;
- break;
- case Scalar::e_void:
- case Scalar::e_float:
- case Scalar::e_double:
- case Scalar::e_long_double:
- // No bitwise AND on floats, doubles of long doubles
+ else
result.m_type = Scalar::e_void;
- break;
- }
}
return result;
}
@@ -2279,30 +937,10 @@ const Scalar lldb_private::operator|(const Scalar &lhs, const Scalar &rhs) {
const Scalar *b;
if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) !=
Scalar::e_void) {
- switch (result.m_type) {
- 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:
- case Scalar::e_sint256:
- case Scalar::e_uint256:
- case Scalar::e_sint512:
- case Scalar::e_uint512:
+ if (GetCategory(result.m_type) == Category::Integral)
result.m_integer = a->m_integer | b->m_integer;
- break;
-
- case Scalar::e_void:
- case Scalar::e_float:
- case Scalar::e_double:
- case Scalar::e_long_double:
- // No bitwise AND on floats, doubles of long doubles
+ else
result.m_type = Scalar::e_void;
- break;
- }
}
return result;
}
@@ -2314,33 +952,12 @@ const Scalar lldb_private::operator%(const Scalar &lhs, const Scalar &rhs) {
const Scalar *b;
if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) !=
Scalar::e_void) {
- switch (result.m_type) {
- default:
- break;
- case Scalar::e_void:
- break;
- case Scalar::e_sint:
- case Scalar::e_slong:
- case Scalar::e_slonglong:
- case Scalar::e_sint128:
- case Scalar::e_sint256:
- case Scalar::e_sint512:
- if (b->m_integer != 0) {
+ if (!b->IsZero() && GetCategory(result.m_type) == Category::Integral) {
+ if (IsSigned(result.m_type))
result.m_integer = a->m_integer.srem(b->m_integer);
- return result;
- }
- break;
- case Scalar::e_uint:
- case Scalar::e_ulong:
- case Scalar::e_ulonglong:
- case Scalar::e_uint128:
- case Scalar::e_uint256:
- case Scalar::e_uint512:
- if (b->m_integer != 0) {
+ else
result.m_integer = a->m_integer.urem(b->m_integer);
- return result;
- }
- break;
+ return result;
}
}
result.m_type = Scalar::e_void;
@@ -2354,30 +971,10 @@ const Scalar lldb_private::operator^(const Scalar &lhs, const Scalar &rhs) {
const Scalar *b;
if ((result.m_type = PromoteToMaxType(lhs, rhs, temp_value, a, b)) !=
Scalar::e_void) {
- switch (result.m_type) {
- 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:
- case Scalar::e_sint256:
- case Scalar::e_uint256:
- case Scalar::e_sint512:
- case Scalar::e_uint512:
+ if (GetCategory(result.m_type) == Category::Integral)
result.m_integer = a->m_integer ^ b->m_integer;
- break;
-
- case Scalar::e_void:
- case Scalar::e_float:
- case Scalar::e_double:
- case Scalar::e_long_double:
- // No bitwise AND on floats, doubles of long doubles
+ else
result.m_type = Scalar::e_void;
- break;
- }
}
return result;
}
@@ -2406,116 +1003,60 @@ Status Scalar::SetValueFromCString(const char *value_str, Encoding encoding,
error.SetErrorString("Invalid encoding.");
break;
- case eEncodingUint:
- if (byte_size <= sizeof(uint64_t)) {
- uint64_t uval64;
- if (!llvm::to_integer(value_str, uval64))
- error.SetErrorStringWithFormat(
- "'%s' is not a valid unsigned integer string value", value_str);
- else if (!UIntValueIsValidForSize(uval64, byte_size))
- error.SetErrorStringWithFormat(
- "value 0x%" PRIx64 " is too large to fit in a %" PRIu64
- " byte unsigned integer value",
- uval64, static_cast<uint64_t>(byte_size));
- else {
- m_type = Scalar::GetValueTypeForUnsignedIntegerWithByteSize(byte_size);
- switch (m_type) {
- 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 "",
- static_cast<uint64_t>(byte_size));
- break;
- }
- }
- } else {
- error.SetErrorStringWithFormat(
- "unsupported unsigned integer byte size: %" PRIu64 "",
- static_cast<uint64_t>(byte_size));
- return error;
- }
- break;
-
case eEncodingSint:
- if (byte_size <= sizeof(int64_t)) {
- int64_t sval64;
- if (!llvm::to_integer(value_str, sval64))
- error.SetErrorStringWithFormat(
- "'%s' is not a valid signed integer string value", value_str);
- else if (!SIntValueIsValidForSize(sval64, byte_size))
- error.SetErrorStringWithFormat(
- "value 0x%" PRIx64 " is too large to fit in a %" PRIu64
- " byte signed integer value",
- sval64, static_cast<uint64_t>(byte_size));
- else {
- m_type = Scalar::GetValueTypeForSignedIntegerWithByteSize(byte_size);
- switch (m_type) {
- 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 "",
- static_cast<uint64_t>(byte_size));
- break;
- }
- }
- } else {
- error.SetErrorStringWithFormat(
- "unsupported signed integer byte size: %" PRIu64 "",
- static_cast<uint64_t>(byte_size));
- return error;
+ case eEncodingUint: {
+ llvm::StringRef str = value_str;
+ bool is_signed = encoding == eEncodingSint;
+ bool is_negative = is_signed && str.consume_front("-");
+ APInt integer;
+ if (str.getAsInteger(0, integer)) {
+ error.SetErrorStringWithFormatv(
+ "'{0}' is not a valid integer string value", value_str);
+ break;
+ }
+ bool fits;
+ if (is_signed) {
+ integer = integer.zext(integer.getBitWidth() + 1);
+ if (is_negative)
+ integer.negate();
+ fits = integer.isSignedIntN(byte_size * 8);
+ } else
+ fits = integer.isIntN(byte_size * 8);
+ if (!fits) {
+ error.SetErrorStringWithFormatv(
+ "value {0} is too large to fit in a {1} byte integer value",
+ value_str, byte_size);
+ break;
}
+ m_type = GetBestTypeForBitSize(8 * byte_size, is_signed);
+ if (m_type == e_void) {
+ error.SetErrorStringWithFormatv("unsupported integer byte size: {0}",
+ byte_size);
+ break;
+ }
+ if (is_signed)
+ m_integer = integer.sextOrTrunc(GetBitSize(m_type));
+ else
+ m_integer = integer.zextOrTrunc(GetBitSize(m_type));
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", &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", &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", &l_val) == 1) {
- m_float = llvm::APFloat(
- llvm::APFloat::x87DoubleExtended(),
- llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
- (reinterpret_cast<type128 *>(&l_val))->x));
- m_type = e_long_double;
- } else
- error.SetErrorStringWithFormat("'%s' is not a valid float string value",
- value_str);
- } else {
- error.SetErrorStringWithFormat("unsupported float byte size: %" PRIu64 "",
- static_cast<uint64_t>(byte_size));
- return error;
+ case eEncodingIEEE754: {
+ Type type = GetValueTypeForFloatWithByteSize(byte_size);
+ if (type == e_void) {
+ error.SetErrorStringWithFormatv("unsupported float byte size: {0}",
+ byte_size);
+ break;
}
+ APFloat f(GetFltSemantics(type));
+ if (llvm::Expected<APFloat::opStatus> op =
+ f.convertFromString(value_str, APFloat::rmNearestTiesToEven)) {
+ m_type = type;
+ m_float = std::move(f);
+ } else
+ error = op.takeError();
break;
+ }
case eEncodingVector:
error.SetErrorString("vector encoding unsupported.");
diff --git a/lldb/source/Utility/SelectHelper.cpp b/lldb/source/Utility/SelectHelper.cpp
index 9f5ca586e1ef..40c85bee6072 100644
--- a/lldb/source/Utility/SelectHelper.cpp
+++ b/lldb/source/Utility/SelectHelper.cpp
@@ -1,4 +1,4 @@
-//===-- SelectHelper.cpp ----------------------------------------*- C++ -*-===//
+//===-- SelectHelper.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/SharingPtr.cpp b/lldb/source/Utility/SharingPtr.cpp
deleted file mode 100644
index 45f2a773758b..000000000000
--- a/lldb/source/Utility/SharingPtr.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-//===---------------------SharingPtr.cpp ------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Utility/SharingPtr.h"
-
-#if defined(ENABLE_SP_LOGGING)
-
-// 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 <assert.h>
-#include <execinfo.h>
-
-#include "llvm/ADT/STLExtras.h"
-
-#include <map>
-#include <mutex>
-#include <vector>
-
-class Backtrace {
-public:
- Backtrace();
-
- ~Backtrace();
-
- void GetFrames();
-
- void Dump() const;
-
-private:
- void *m_sp_this;
- std::vector<void *> m_frames;
-};
-
-Backtrace::Backtrace() : m_frames() {}
-
-Backtrace::~Backtrace() {}
-
-void Backtrace::GetFrames() {
- void *frames[1024];
- const int count = ::backtrace(frames, llvm::array_lengthof(frames));
- if (count > 2)
- m_frames.assign(frames + 2, frames + (count - 2));
-}
-
-void Backtrace::Dump() const {
- if (!m_frames.empty())
- ::backtrace_symbols_fd(m_frames.data(), m_frames.size(), STDOUT_FILENO);
- write(STDOUT_FILENO, "\n\n", 2);
-}
-
-extern "C" void track_sp(void *sp_this, void *ptr, long use_count) {
- typedef std::pair<void *, Backtrace> PtrBacktracePair;
- typedef std::map<void *, PtrBacktracePair> PtrToBacktraceMap;
- static std::mutex g_mutex;
- std::lock_guard<std::mutex> guard(g_mutex);
- static PtrToBacktraceMap g_map;
-
- if (sp_this) {
- printf("sp(%p) -> %p %lu\n", sp_this, ptr, use_count);
-
- if (ptr) {
- Backtrace bt;
- bt.GetFrames();
- g_map[sp_this] = std::make_pair(ptr, bt);
- } else {
- g_map.erase(sp_this);
- }
- } else {
- if (ptr)
- printf("Searching for shared pointers that are tracking %p: ", ptr);
- else
- printf("Dump all live shared pointres: ");
-
- uint32_t matches = 0;
- PtrToBacktraceMap::iterator pos, end = g_map.end();
- for (pos = g_map.begin(); pos != end; ++pos) {
- if (ptr == NULL || pos->second.first == ptr) {
- ++matches;
- printf("\nsp(%p): %p\n", pos->first, pos->second.first);
- pos->second.second.Dump();
- }
- }
- if (matches == 0) {
- printf("none.\n");
- }
- }
-}
-// Put dump_sp_refs in the lldb namespace to it gets through our exports lists
-// filter in the LLDB.framework or lldb.so
-namespace lldb {
-
-void dump_sp_refs(void *ptr) {
- // Use a specially crafted call to "track_sp" which will dump info on all
- // live shared pointers that reference "ptr"
- track_sp(NULL, ptr, 0);
-}
-}
-
-#endif
-
-namespace lldb_private {
-
-namespace imp {
-
-shared_count::~shared_count() {}
-
-void shared_count::add_shared() {
-#ifdef _MSC_VER
- _InterlockedIncrement(&shared_owners_);
-#else
- ++shared_owners_;
-#endif
-}
-
-void shared_count::release_shared() {
-#ifdef _MSC_VER
- if (_InterlockedDecrement(&shared_owners_) == -1)
-#else
- if (--shared_owners_ == -1)
-#endif
- {
- on_zero_shared();
- delete this;
- }
-}
-
-} // imp
-
-} // namespace lldb
diff --git a/lldb/source/Utility/State.cpp b/lldb/source/Utility/State.cpp
index 51fe92bad77e..2d76b801dcaa 100644
--- a/lldb/source/Utility/State.cpp
+++ b/lldb/source/Utility/State.cpp
@@ -1,4 +1,4 @@
-//===-- State.cpp -----------------------------------------------*- C++ -*-===//
+//===-- State.cpp ---------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/Status.cpp b/lldb/source/Utility/Status.cpp
index b74db72773dd..e3c4284a8e8a 100644
--- a/lldb/source/Utility/Status.cpp
+++ b/lldb/source/Utility/Status.cpp
@@ -1,5 +1,4 @@
-//===-- Status.cpp -----------------------------------------------*- C++
-//-*-===//
+//===-- Status.cpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -43,8 +42,13 @@ Status::Status() : m_code(0), m_type(eErrorTypeInvalid), m_string() {}
Status::Status(ValueType err, ErrorType type)
: m_code(err), m_type(type), m_string() {}
+// This logic is confusing because c++ calls the traditional (posix) errno codes
+// "generic errors", while we use the term "generic" to mean completely
+// arbitrary (text-based) errors.
Status::Status(std::error_code EC)
- : m_code(EC.value()), m_type(ErrorType::eErrorTypeGeneric),
+ : m_code(EC.value()),
+ m_type(EC.category() == std::generic_category() ? eErrorTypePOSIX
+ : eErrorTypeGeneric),
m_string(EC.message()) {}
Status::Status(const char *format, ...)
@@ -242,7 +246,7 @@ void Status::SetErrorString(llvm::StringRef err_str) {
if (Success())
SetErrorToGenericError();
}
- m_string = err_str;
+ m_string = std::string(err_str);
}
/// Set the current error string to a formatted error string.
@@ -271,7 +275,7 @@ int Status::SetErrorStringWithVarArg(const char *format, va_list args) {
llvm::SmallString<1024> buf;
VASprintf(buf, format, args);
- m_string = buf.str();
+ m_string = std::string(buf.str());
return buf.size();
} else {
m_string.clear();
diff --git a/lldb/source/Utility/Stream.cpp b/lldb/source/Utility/Stream.cpp
index b336cb6b5185..a0623bfa6e54 100644
--- a/lldb/source/Utility/Stream.cpp
+++ b/lldb/source/Utility/Stream.cpp
@@ -1,4 +1,4 @@
-//===-- Stream.cpp ----------------------------------------------*- C++ -*-===//
+//===-- Stream.cpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -22,13 +22,14 @@
using namespace lldb;
using namespace lldb_private;
-Stream::Stream(uint32_t flags, uint32_t addr_size, ByteOrder byte_order)
+Stream::Stream(uint32_t flags, uint32_t addr_size, ByteOrder byte_order,
+ bool colors)
: m_flags(flags), m_addr_size(addr_size), m_byte_order(byte_order),
- m_indent_level(0), m_forwarder(*this) {}
+ m_indent_level(0), m_forwarder(*this, colors) {}
-Stream::Stream()
+Stream::Stream(bool colors)
: m_flags(0), m_addr_size(4), m_byte_order(endian::InlHostByteOrder()),
- m_indent_level(0), m_forwarder(*this) {}
+ m_indent_level(0), m_forwarder(*this, colors) {}
// Destructor
Stream::~Stream() {}
@@ -126,15 +127,10 @@ size_t Stream::PrintfVarArg(const char *format, va_list args) {
// Print and End of Line character to the stream
size_t Stream::EOL() { return PutChar('\n'); }
-// Indent the current line using the current indentation level and print an
-// optional string following the indentation spaces.
-size_t Stream::Indent(const char *s) {
- return Printf("%*.*s%s", m_indent_level, m_indent_level, "", s ? s : "");
-}
-
size_t Stream::Indent(llvm::StringRef str) {
- return Printf("%*.*s%s", m_indent_level, m_indent_level, "",
- str.str().c_str());
+ const size_t ind_length = PutCString(std::string(m_indent_level, ' '));
+ const size_t str_length = PutCString(str);
+ return ind_length + str_length;
}
// Stream a character "ch" out to this stream.
diff --git a/lldb/source/Utility/StreamCallback.cpp b/lldb/source/Utility/StreamCallback.cpp
index b3d3adea78bc..c10f678d7a28 100644
--- a/lldb/source/Utility/StreamCallback.cpp
+++ b/lldb/source/Utility/StreamCallback.cpp
@@ -1,4 +1,4 @@
-//===-- StreamCallback.cpp -------------------------------------*- C++ -*-===//
+//===-- StreamCallback.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/StreamString.cpp b/lldb/source/Utility/StreamString.cpp
index 6b5b7d337fcc..190be588e887 100644
--- a/lldb/source/Utility/StreamString.cpp
+++ b/lldb/source/Utility/StreamString.cpp
@@ -1,4 +1,4 @@
-//===-- StreamString.cpp ----------------------------------------*- C++ -*-===//
+//===-- StreamString.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/StringExtractor.cpp b/lldb/source/Utility/StringExtractor.cpp
index 87fe4f13e450..0553a63a021e 100644
--- a/lldb/source/Utility/StringExtractor.cpp
+++ b/lldb/source/Utility/StringExtractor.cpp
@@ -1,4 +1,4 @@
-//===-- StringExtractor.cpp -------------------------------------*- C++ -*-===//
+//===-- StringExtractor.cpp -----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/Utility/StringExtractor.h"
+#include "llvm/ADT/StringExtras.h"
#include <tuple>
@@ -365,6 +366,6 @@ bool StringExtractor::GetNameColonValue(llvm::StringRef &name,
void StringExtractor::SkipSpaces() {
const size_t n = m_packet.size();
- while (m_index < n && isspace(m_packet[m_index]))
+ while (m_index < n && llvm::isSpace(m_packet[m_index]))
++m_index;
}
diff --git a/lldb/source/Utility/StringExtractorGDBRemote.cpp b/lldb/source/Utility/StringExtractorGDBRemote.cpp
index a011e9246d15..cfe7577e4863 100644
--- a/lldb/source/Utility/StringExtractorGDBRemote.cpp
+++ b/lldb/source/Utility/StringExtractorGDBRemote.cpp
@@ -1,4 +1,4 @@
-//===-- StringExtractorGDBRemote.cpp ----------------------------*- C++ -*-===//
+//===-- StringExtractorGDBRemote.cpp --------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/StringLexer.cpp b/lldb/source/Utility/StringLexer.cpp
index c357cb0fb553..947472a014eb 100644
--- a/lldb/source/Utility/StringLexer.cpp
+++ b/lldb/source/Utility/StringLexer.cpp
@@ -1,4 +1,4 @@
-//===--------------------- StringLexer.cpp -----------------------*- C++-*-===//
+//===-- StringLexer.cpp ---------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/StringList.cpp b/lldb/source/Utility/StringList.cpp
index 5e06b6b69fc0..809c5a02acf6 100644
--- a/lldb/source/Utility/StringList.cpp
+++ b/lldb/source/Utility/StringList.cpp
@@ -1,4 +1,4 @@
-//===-- StringList.cpp ------------------------------------------*- C++ -*-===//
+//===-- StringList.cpp ----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -199,7 +199,7 @@ std::string StringList::CopyList(const char *item_preamble,
strm << item_preamble;
strm << GetStringAtIndex(i);
}
- return strm.GetString();
+ return std::string(strm.GetString());
}
StringList &StringList::operator<<(const char *str) {
diff --git a/lldb/source/Utility/StructuredData.cpp b/lldb/source/Utility/StructuredData.cpp
index d5d7a7ec99a0..df1b35618e4a 100644
--- a/lldb/source/Utility/StructuredData.cpp
+++ b/lldb/source/Utility/StructuredData.cpp
@@ -1,4 +1,4 @@
-//===---------------------StructuredData.cpp ---------------------*- C++-*-===//
+//===-- StructuredData.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -156,7 +156,7 @@ void StructuredData::String::Serialize(json::OStream &s) const {
void StructuredData::Dictionary::Serialize(json::OStream &s) const {
s.objectBegin();
for (const auto &pair : m_dict) {
- s.attributeBegin(pair.first.AsCString());
+ s.attributeBegin(pair.first.GetStringRef());
pair.second->Serialize(s);
s.attributeEnd();
}
diff --git a/lldb/source/Utility/TildeExpressionResolver.cpp b/lldb/source/Utility/TildeExpressionResolver.cpp
index b58f45728ce7..c8a0800cb807 100644
--- a/lldb/source/Utility/TildeExpressionResolver.cpp
+++ b/lldb/source/Utility/TildeExpressionResolver.cpp
@@ -1,4 +1,4 @@
-//===--------------------- TildeExpressionResolver.cpp ----------*- C++ -*-===//
+//===-- TildeExpressionResolver.cpp ---------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/Timer.cpp b/lldb/source/Utility/Timer.cpp
index 6b46d8ba7364..d55c9863117b 100644
--- a/lldb/source/Utility/Timer.cpp
+++ b/lldb/source/Utility/Timer.cpp
@@ -1,4 +1,4 @@
-//===-- Timer.cpp -----------------------------------------------*- C++ -*-===//
+//===-- Timer.cpp ---------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -15,6 +15,7 @@
#include <vector>
#include <assert.h>
+#include <inttypes.h>
#include <stdarg.h>
#include <stdio.h>
diff --git a/lldb/source/Utility/UUID.cpp b/lldb/source/Utility/UUID.cpp
index 2a73f9a482ff..4177b43de818 100644
--- a/lldb/source/Utility/UUID.cpp
+++ b/lldb/source/Utility/UUID.cpp
@@ -1,4 +1,4 @@
-//===-- UUID.cpp ------------------------------------------------*- C++ -*-===//
+//===-- UUID.cpp ----------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -61,10 +61,9 @@ static inline int xdigit_to_int(char ch) {
llvm::StringRef
UUID::DecodeUUIDBytesFromString(llvm::StringRef p,
- llvm::SmallVectorImpl<uint8_t> &uuid_bytes,
- uint32_t num_uuid_bytes) {
+ llvm::SmallVectorImpl<uint8_t> &uuid_bytes) {
uuid_bytes.clear();
- while (!p.empty()) {
+ while (p.size() >= 2) {
if (isxdigit(p[0]) && isxdigit(p[1])) {
int hi_nibble = xdigit_to_int(p[0]);
int lo_nibble = xdigit_to_int(p[1]);
@@ -73,11 +72,6 @@ UUID::DecodeUUIDBytesFromString(llvm::StringRef p,
// Skip both hex digits
p = p.drop_front(2);
-
- // Increment the byte that we are decoding within the UUID value and
- // break out if we are done
- if (uuid_bytes.size() == num_uuid_bytes)
- break;
} else if (p.front() == '-') {
// Skip dashes
p = p.drop_front();
@@ -89,35 +83,30 @@ UUID::DecodeUUIDBytesFromString(llvm::StringRef p,
return p;
}
-size_t UUID::SetFromStringRef(llvm::StringRef str, uint32_t num_uuid_bytes) {
+bool UUID::SetFromStringRef(llvm::StringRef str) {
llvm::StringRef p = str;
// Skip leading whitespace characters
p = p.ltrim();
llvm::SmallVector<uint8_t, 20> bytes;
- llvm::StringRef rest =
- UUID::DecodeUUIDBytesFromString(p, bytes, num_uuid_bytes);
-
- // If we successfully decoded a UUID, return the amount of characters that
- // were consumed
- if (bytes.size() == num_uuid_bytes) {
- *this = fromData(bytes);
- return str.size() - rest.size();
- }
+ llvm::StringRef rest = UUID::DecodeUUIDBytesFromString(p, bytes);
+
+ // Return false if we could not consume the entire string or if the parsed
+ // UUID is empty.
+ if (!rest.empty() || bytes.empty())
+ return false;
- // Else return zero to indicate we were not able to parse a UUID value
- return 0;
+ *this = fromData(bytes);
+ return true;
}
-size_t UUID::SetFromOptionalStringRef(llvm::StringRef str,
- uint32_t num_uuid_bytes) {
- size_t num_chars_consumed = SetFromStringRef(str, num_uuid_bytes);
- if (num_chars_consumed) {
+bool UUID::SetFromOptionalStringRef(llvm::StringRef str) {
+ bool result = SetFromStringRef(str);
+ if (result) {
if (llvm::all_of(m_bytes, [](uint8_t b) { return b == 0; }))
Clear();
}
-
- return num_chars_consumed;
-}
+ return result;
+}
diff --git a/lldb/source/Utility/UriParser.cpp b/lldb/source/Utility/UriParser.cpp
index b446958f2f47..8169b0eee121 100644
--- a/lldb/source/Utility/UriParser.cpp
+++ b/lldb/source/Utility/UriParser.cpp
@@ -1,4 +1,4 @@
-//===-- UriParser.cpp -------------------------------------------*- C++ -*-===//
+//===-- UriParser.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -42,7 +42,7 @@ bool UriParser::Parse(llvm::StringRef uri, llvm::StringRef &scheme,
// Extract hostname
if (!host_port.empty() && host_port[0] == '[') {
// hostname is enclosed with square brackets.
- pos = host_port.find(']');
+ pos = host_port.rfind(']');
if (pos == std::string::npos)
return false;
diff --git a/lldb/source/Utility/UserID.cpp b/lldb/source/Utility/UserID.cpp
index b76a1cd84f82..8e0146b93498 100644
--- a/lldb/source/Utility/UserID.cpp
+++ b/lldb/source/Utility/UserID.cpp
@@ -1,4 +1,4 @@
-//===-- UserID.cpp ----------------------------------------------*- C++ -*-===//
+//===-- UserID.cpp --------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/UserIDResolver.cpp b/lldb/source/Utility/UserIDResolver.cpp
index 8aac6f948cd2..73bdde77cc0f 100644
--- a/lldb/source/Utility/UserIDResolver.cpp
+++ b/lldb/source/Utility/UserIDResolver.cpp
@@ -1,4 +1,4 @@
-//===-- UserIDResolver.cpp --------------------------------------*- C++ -*-===//
+//===-- UserIDResolver.cpp ------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/VASprintf.cpp b/lldb/source/Utility/VASprintf.cpp
index 2ee0f6676fa7..aea68dfff9f1 100644
--- a/lldb/source/Utility/VASprintf.cpp
+++ b/lldb/source/Utility/VASprintf.cpp
@@ -1,4 +1,4 @@
-//===-- VASprintf.cpp -------------------------------------------*- C++ -*-===//
+//===-- VASprintf.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/VMRange.cpp b/lldb/source/Utility/VMRange.cpp
index c8c3334138d3..16c50d6e81b8 100644
--- a/lldb/source/Utility/VMRange.cpp
+++ b/lldb/source/Utility/VMRange.cpp
@@ -1,4 +1,4 @@
-//===-- VMRange.cpp ---------------------------------------------*- C++ -*-===//
+//===-- VMRange.cpp -------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Utility/XcodeSDK.cpp b/lldb/source/Utility/XcodeSDK.cpp
new file mode 100644
index 000000000000..066bf457966c
--- /dev/null
+++ b/lldb/source/Utility/XcodeSDK.cpp
@@ -0,0 +1,309 @@
+//===-- XcodeSDK.cpp ------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/XcodeSDK.h"
+#include "lldb/Utility/FileSpec.h"
+
+#include "lldb/lldb-types.h"
+
+#include "llvm/ADT/Triple.h"
+
+#include <string>
+
+using namespace lldb;
+using namespace lldb_private;
+
+static llvm::StringRef GetName(XcodeSDK::Type type) {
+ switch (type) {
+ case XcodeSDK::MacOSX:
+ return "MacOSX";
+ case XcodeSDK::iPhoneSimulator:
+ return "iPhoneSimulator";
+ case XcodeSDK::iPhoneOS:
+ return "iPhoneOS";
+ case XcodeSDK::AppleTVSimulator:
+ return "AppleTVSimulator";
+ case XcodeSDK::AppleTVOS:
+ return "AppleTVOS";
+ case XcodeSDK::WatchSimulator:
+ return "WatchSimulator";
+ case XcodeSDK::watchOS:
+ return "WatchOS";
+ case XcodeSDK::bridgeOS:
+ return "bridgeOS";
+ case XcodeSDK::Linux:
+ return "Linux";
+ case XcodeSDK::unknown:
+ return {};
+ }
+ llvm_unreachable("Unhandled sdk type!");
+}
+
+XcodeSDK::XcodeSDK(XcodeSDK::Info info) : m_name(GetName(info.type).str()) {
+ if (!m_name.empty()) {
+ if (!info.version.empty())
+ m_name += info.version.getAsString();
+ if (info.internal)
+ m_name += ".Internal";
+ m_name += ".sdk";
+ }
+}
+
+XcodeSDK &XcodeSDK::operator=(XcodeSDK other) {
+ m_name = other.m_name;
+ return *this;
+}
+
+bool XcodeSDK::operator==(XcodeSDK other) {
+ return m_name == other.m_name;
+}
+
+static XcodeSDK::Type ParseSDKName(llvm::StringRef &name) {
+ if (name.consume_front("MacOSX"))
+ return XcodeSDK::MacOSX;
+ if (name.consume_front("iPhoneSimulator"))
+ return XcodeSDK::iPhoneSimulator;
+ if (name.consume_front("iPhoneOS"))
+ return XcodeSDK::iPhoneOS;
+ if (name.consume_front("AppleTVSimulator"))
+ return XcodeSDK::AppleTVSimulator;
+ if (name.consume_front("AppleTVOS"))
+ return XcodeSDK::AppleTVOS;
+ if (name.consume_front("WatchSimulator"))
+ return XcodeSDK::WatchSimulator;
+ if (name.consume_front("WatchOS"))
+ return XcodeSDK::watchOS;
+ if (name.consume_front("bridgeOS"))
+ return XcodeSDK::bridgeOS;
+ if (name.consume_front("Linux"))
+ return XcodeSDK::Linux;
+ static_assert(XcodeSDK::Linux == XcodeSDK::numSDKTypes - 1,
+ "New SDK type was added, update this list!");
+ return XcodeSDK::unknown;
+}
+
+static llvm::VersionTuple ParseSDKVersion(llvm::StringRef &name) {
+ unsigned i = 0;
+ while (i < name.size() && name[i] >= '0' && name[i] <= '9')
+ ++i;
+ if (i == name.size() || name[i++] != '.')
+ return {};
+ while (i < name.size() && name[i] >= '0' && name[i] <= '9')
+ ++i;
+ if (i == name.size() || name[i++] != '.')
+ return {};
+
+ llvm::VersionTuple version;
+ version.tryParse(name.slice(0, i - 1));
+ name = name.drop_front(i);
+ return version;
+}
+
+static bool ParseAppleInternalSDK(llvm::StringRef &name) {
+ return name.consume_front("Internal.") || name.consume_front(".Internal.");
+}
+
+XcodeSDK::Info XcodeSDK::Parse() const {
+ XcodeSDK::Info info;
+ llvm::StringRef input(m_name);
+ info.type = ParseSDKName(input);
+ info.version = ParseSDKVersion(input);
+ info.internal = ParseAppleInternalSDK(input);
+ return info;
+}
+
+bool XcodeSDK::IsAppleInternalSDK() const {
+ llvm::StringRef input(m_name);
+ ParseSDKName(input);
+ ParseSDKVersion(input);
+ return ParseAppleInternalSDK(input);
+}
+
+llvm::VersionTuple XcodeSDK::GetVersion() const {
+ llvm::StringRef input(m_name);
+ ParseSDKName(input);
+ return ParseSDKVersion(input);
+}
+
+XcodeSDK::Type XcodeSDK::GetType() const {
+ llvm::StringRef input(m_name);
+ return ParseSDKName(input);
+}
+
+llvm::StringRef XcodeSDK::GetString() const { return m_name; }
+
+bool XcodeSDK::Info::operator<(const Info &other) const {
+ return std::tie(type, version, internal) <
+ std::tie(other.type, other.version, other.internal);
+}
+
+bool XcodeSDK::Info::operator==(const Info &other) const {
+ return std::tie(type, version, internal) ==
+ std::tie(other.type, other.version, other.internal);
+}
+
+void XcodeSDK::Merge(XcodeSDK other) {
+ // The "bigger" SDK always wins.
+ auto l = Parse();
+ auto r = other.Parse();
+ if (l < r)
+ *this = other;
+ else {
+ // The Internal flag always wins.
+ if (llvm::StringRef(m_name).endswith(".sdk"))
+ if (!l.internal && r.internal)
+ m_name =
+ m_name.substr(0, m_name.size() - 3) + std::string("Internal.sdk");
+ }
+}
+
+std::string XcodeSDK::GetCanonicalName(XcodeSDK::Info info) {
+ std::string name;
+ switch (info.type) {
+ case MacOSX:
+ name = "macosx";
+ break;
+ case iPhoneSimulator:
+ name = "iphonesimulator";
+ break;
+ case iPhoneOS:
+ name = "iphoneos";
+ break;
+ case AppleTVSimulator:
+ name = "appletvsimulator";
+ break;
+ case AppleTVOS:
+ name = "appletvos";
+ break;
+ case WatchSimulator:
+ name = "watchsimulator";
+ break;
+ case watchOS:
+ name = "watchos";
+ break;
+ case bridgeOS:
+ name = "bridgeos";
+ break;
+ case Linux:
+ name = "linux";
+ break;
+ case unknown:
+ return {};
+ }
+ if (!info.version.empty())
+ name += info.version.getAsString();
+ if (info.internal)
+ name += ".internal";
+ return name;
+}
+
+bool XcodeSDK::SDKSupportsModules(XcodeSDK::Type sdk_type,
+ llvm::VersionTuple version) {
+ switch (sdk_type) {
+ case Type::MacOSX:
+ return version >= llvm::VersionTuple(10, 10);
+ case Type::iPhoneOS:
+ case Type::iPhoneSimulator:
+ case Type::AppleTVOS:
+ case Type::AppleTVSimulator:
+ return version >= llvm::VersionTuple(8);
+ case Type::watchOS:
+ case Type::WatchSimulator:
+ return version >= llvm::VersionTuple(6);
+ default:
+ return false;
+ }
+
+ return false;
+}
+
+bool XcodeSDK::SupportsSwift() const {
+ XcodeSDK::Info info = Parse();
+ switch (info.type) {
+ case Type::MacOSX:
+ return info.version.empty() || info.version >= llvm::VersionTuple(10, 10);
+ case Type::iPhoneOS:
+ case Type::iPhoneSimulator:
+ return info.version.empty() || info.version >= llvm::VersionTuple(8);
+ case Type::AppleTVSimulator:
+ case Type::AppleTVOS:
+ return info.version.empty() || info.version >= llvm::VersionTuple(9);
+ case Type::WatchSimulator:
+ case Type::watchOS:
+ return info.version.empty() || info.version >= llvm::VersionTuple(2);
+ case Type::Linux:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool XcodeSDK::SDKSupportsModules(XcodeSDK::Type desired_type,
+ const FileSpec &sdk_path) {
+ ConstString last_path_component = sdk_path.GetLastPathComponent();
+
+ if (!last_path_component)
+ return false;
+
+ XcodeSDK sdk(last_path_component.GetStringRef().str());
+ if (sdk.GetType() != desired_type)
+ return false;
+ return SDKSupportsModules(sdk.GetType(), sdk.GetVersion());
+}
+
+XcodeSDK::Type XcodeSDK::GetSDKTypeForTriple(const llvm::Triple &triple) {
+ using namespace llvm;
+ switch (triple.getOS()) {
+ case Triple::MacOSX:
+ case Triple::Darwin:
+ return XcodeSDK::MacOSX;
+ case Triple::IOS:
+ switch (triple.getEnvironment()) {
+ case Triple::MacABI:
+ return XcodeSDK::MacOSX;
+ case Triple::Simulator:
+ return XcodeSDK::iPhoneSimulator;
+ default:
+ return XcodeSDK::iPhoneOS;
+ }
+ case Triple::TvOS:
+ if (triple.getEnvironment() == Triple::Simulator)
+ return XcodeSDK::AppleTVSimulator;
+ return XcodeSDK::AppleTVOS;
+ case Triple::WatchOS:
+ if (triple.getEnvironment() == Triple::Simulator)
+ return XcodeSDK::WatchSimulator;
+ return XcodeSDK::watchOS;
+ case Triple::Linux:
+ return XcodeSDK::Linux;
+ default:
+ return XcodeSDK::unknown;
+ }
+}
+
+std::string XcodeSDK::FindXcodeContentsDirectoryInPath(llvm::StringRef path) {
+ auto begin = llvm::sys::path::begin(path);
+ auto end = llvm::sys::path::end(path);
+
+ // Iterate over the path components until we find something that ends with
+ // .app. If the next component is Contents then we've found the Contents
+ // directory.
+ for (auto it = begin; it != end; ++it) {
+ if (it->endswith(".app")) {
+ auto next = it;
+ if (++next != end && *next == "Contents") {
+ llvm::SmallString<128> buffer;
+ llvm::sys::path::append(buffer, begin, ++next,
+ llvm::sys::path::Style::posix);
+ return buffer.str().str();
+ }
+ }
+ }
+
+ return {};
+}
diff --git a/lldb/source/lldb.cpp b/lldb/source/lldb.cpp
index c96f5d9ee7e1..6d4ed66074dc 100644
--- a/lldb/source/lldb.cpp
+++ b/lldb/source/lldb.cpp
@@ -1,4 +1,4 @@
-//===-- lldb.cpp ------------------------------------------------*- C++ -*-===//
+//===-- lldb.cpp ----------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -50,8 +50,10 @@ const char *lldb_private::GetVersion() {
g_version_str += " (";
if (lldb_repo)
g_version_str += lldb_repo;
+ if (lldb_repo && lldb_rev)
+ g_version_str += " ";
if (lldb_rev) {
- g_version_str += " revision ";
+ g_version_str += "revision ";
g_version_str += lldb_rev;
}
g_version_str += ")";
diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index 73874389aa1b..cea9e5a44aa8 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -9,6 +9,7 @@
#include "Driver.h"
#include "lldb/API/SBCommandInterpreter.h"
+#include "lldb/API/SBCommandInterpreterRunOptions.h"
#include "lldb/API/SBCommandReturnObject.h"
#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBFile.h"
@@ -360,13 +361,8 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, bool &exiting) {
if (m_option_data.m_process_name.empty() &&
m_option_data.m_process_pid == LLDB_INVALID_PROCESS_ID) {
- // If the option data args array is empty that means the file was not
- // specified with -f and we need to get it from the input args.
- if (m_option_data.m_args.empty()) {
- if (auto *arg = args.getLastArgNoClaim(OPT_INPUT)) {
- m_option_data.m_args.push_back(arg->getAsString((args)));
- }
- }
+ for (auto *arg : args.filtered(OPT_INPUT))
+ m_option_data.m_args.push_back(arg->getAsString((args)));
// Any argument following -- is an argument for the inferior.
if (auto *arg = args.getLastArgNoClaim(OPT_REM)) {
@@ -587,74 +583,75 @@ int Driver::MainLoop() {
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;
+ bool go_interactive = true;
if ((commands_data != nullptr) && (commands_size != 0u)) {
- bool success = true;
FILE *commands_file =
PrepareCommandsForSourcing(commands_data, commands_size);
- if (commands_file != nullptr) {
- m_debugger.SetInputFileHandle(commands_file, true);
-
- // Set the debugger into Sync mode when running the command file.
- // Otherwise command files
- // that run the target won't run in a sensible way.
- bool old_async = m_debugger.GetAsync();
- m_debugger.SetAsync(false);
- int num_errors = 0;
-
- SBCommandInterpreterRunOptions options;
- options.SetStopOnError(true);
- if (m_option_data.m_batch)
- options.SetStopOnCrash(true);
-
- m_debugger.RunCommandInterpreter(handle_events, spawn_thread, options,
- num_errors, quit_requested,
- stopped_for_crash);
-
- if (m_option_data.m_batch && stopped_for_crash &&
- !m_option_data.m_after_crash_commands.empty()) {
- SBStream crash_commands_stream;
- WriteCommandsForSourcing(eCommandPlacementAfterCrash,
- crash_commands_stream);
- const char *crash_commands_data = crash_commands_stream.GetData();
- const size_t crash_commands_size = crash_commands_stream.GetSize();
- commands_file = PrepareCommandsForSourcing(crash_commands_data,
- crash_commands_size);
- if (commands_file != nullptr) {
- bool local_quit_requested;
- bool local_stopped_for_crash;
- m_debugger.SetInputFileHandle(commands_file, true);
-
- m_debugger.RunCommandInterpreter(handle_events, spawn_thread, options,
- num_errors, local_quit_requested,
- local_stopped_for_crash);
- if (local_quit_requested)
- quit_requested = true;
- }
- }
- m_debugger.SetAsync(old_async);
- } else
- success = false;
- // Something went wrong with command pipe
- if (!success) {
+ if (commands_file == nullptr) {
+ // We should have already printed an error in PrepareCommandsForSourcing.
exit(1);
}
- }
- // Now set the input file handle to STDIN and run the command
- // interpreter again in interactive mode or repl mode and let the debugger
- // take ownership of stdin
+ 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);
+
+ SBCommandInterpreterRunOptions options;
+ options.SetAutoHandleEvents(true);
+ options.SetSpawnThread(false);
+ options.SetStopOnError(true);
+ options.SetStopOnCrash(m_option_data.m_batch);
+
+ SBCommandInterpreterRunResult results =
+ m_debugger.RunCommandInterpreter(options);
+ if (results.GetResult() == lldb::eCommandInterpreterResultQuitRequested)
+ go_interactive = false;
+ if (m_option_data.m_batch &&
+ results.GetResult() != lldb::eCommandInterpreterResultInferiorCrash)
+ go_interactive = false;
+
+ // When running in batch mode and stopped because of an error, exit with a
+ // non-zero exit status.
+ if (m_option_data.m_batch &&
+ results.GetResult() == lldb::eCommandInterpreterResultCommandError)
+ exit(1);
- bool go_interactive = true;
- if (quit_requested)
- go_interactive = false;
- else if (m_option_data.m_batch && !stopped_for_crash)
- go_interactive = false;
+ if (m_option_data.m_batch &&
+ results.GetResult() == lldb::eCommandInterpreterResultInferiorCrash &&
+ !m_option_data.m_after_crash_commands.empty()) {
+ SBStream crash_commands_stream;
+ WriteCommandsForSourcing(eCommandPlacementAfterCrash,
+ crash_commands_stream);
+ const char *crash_commands_data = crash_commands_stream.GetData();
+ const size_t crash_commands_size = crash_commands_stream.GetSize();
+ commands_file =
+ PrepareCommandsForSourcing(crash_commands_data, crash_commands_size);
+ if (commands_file != nullptr) {
+ m_debugger.SetInputFileHandle(commands_file, true);
+ SBCommandInterpreterRunResult local_results =
+ m_debugger.RunCommandInterpreter(options);
+ if (local_results.GetResult() ==
+ lldb::eCommandInterpreterResultQuitRequested)
+ go_interactive = false;
+
+ // When running in batch mode and an error occurred while sourcing
+ // the crash commands, exit with a non-zero exit status.
+ if (m_option_data.m_batch &&
+ local_results.GetResult() ==
+ lldb::eCommandInterpreterResultCommandError)
+ exit(1);
+ }
+ }
+ m_debugger.SetAsync(old_async);
+ }
+ // Now set the input file handle to STDIN and run the command interpreter
+ // again in interactive mode or repl mode and let the debugger take ownership
+ // of stdin.
if (go_interactive) {
m_debugger.SetInputFileHandle(stdin, true);
@@ -763,10 +760,15 @@ EXAMPLES:
The debugger can be started in several modes.
Passing an executable as a positional argument prepares lldb to debug the
- given executable. Arguments passed after -- are considered arguments to the
- debugged executable.
+ given executable. To disambiguate between arguments passed to lldb and
+ arguments passed to the debugged executable, arguments starting with a - must
+ be passed after --.
+
+ lldb --arch x86_64 /path/to/program program argument -- --arch arvm7
+
+ For convenience, passing the executable after -- is also supported.
- lldb --arch x86_64 /path/to/program -- --arch arvm7
+ lldb --arch x86_64 -- /path/to/program program argument --arch arvm7
Passing one of the attach options causes lldb to immediately attach to the
given process.
@@ -795,11 +797,12 @@ EXAMPLES:
llvm::outs() << examples << '\n';
}
-llvm::Optional<int> InitializeReproducer(opt::InputArgList &input_args) {
+llvm::Optional<int> InitializeReproducer(llvm::StringRef argv0,
+ opt::InputArgList &input_args) {
if (auto *replay_path = input_args.getLastArg(OPT_replay)) {
- const bool skip_version_check = input_args.hasArg(OPT_skip_version_check);
+ const bool no_version_check = input_args.hasArg(OPT_no_version_check);
if (const char *error =
- SBReproducer::Replay(replay_path->getValue(), skip_version_check)) {
+ SBReproducer::Replay(replay_path->getValue(), no_version_check)) {
WithColor::error() << "reproducer replay failed: " << error << '\n';
return 1;
}
@@ -807,9 +810,21 @@ llvm::Optional<int> InitializeReproducer(opt::InputArgList &input_args) {
}
bool capture = input_args.hasArg(OPT_capture);
+ bool generate_on_exit = input_args.hasArg(OPT_generate_on_exit);
auto *capture_path = input_args.getLastArg(OPT_capture_path);
+ if (generate_on_exit && !capture) {
+ WithColor::warning()
+ << "-reproducer-generate-on-exit specified without -capture\n";
+ }
+
if (capture || capture_path) {
+ // Register the reproducer signal handler.
+ if (!input_args.hasArg(OPT_no_generate_on_signal)) {
+ llvm::sys::AddSignalHandler(reproducer_handler,
+ const_cast<char *>(argv0.data()));
+ }
+
if (capture_path) {
if (!capture)
WithColor::warning() << "-capture-path specified without -capture\n";
@@ -824,6 +839,8 @@ llvm::Optional<int> InitializeReproducer(opt::InputArgList &input_args) {
return 1;
}
}
+ if (generate_on_exit)
+ SBReproducer::SetAutoGenerate(true);
}
return llvm::None;
@@ -840,24 +857,27 @@ int main(int argc, char const *argv[]) {
unsigned MAC;
ArrayRef<const char *> arg_arr = makeArrayRef(argv + 1, argc - 1);
opt::InputArgList input_args = T.ParseArgs(arg_arr, MAI, MAC);
+ llvm::StringRef argv0 = llvm::sys::path::filename(argv[0]);
if (input_args.hasArg(OPT_help)) {
- printHelp(T, llvm::sys::path::filename(argv[0]));
+ printHelp(T, argv0);
return 0;
}
- for (auto *arg : input_args.filtered(OPT_UNKNOWN)) {
- WithColor::warning() << "ignoring unknown option: " << arg->getSpelling()
- << '\n';
+ // Error out on unknown options.
+ if (input_args.hasArg(OPT_UNKNOWN)) {
+ for (auto *arg : input_args.filtered(OPT_UNKNOWN)) {
+ WithColor::error() << "unknown option: " << arg->getSpelling() << '\n';
+ }
+ llvm::errs() << "Use '" << argv0
+ << " --help' for a complete list of options.\n";
+ return 1;
}
- if (auto exit_code = InitializeReproducer(input_args)) {
+ if (auto exit_code = InitializeReproducer(argv[0], input_args)) {
return *exit_code;
}
- // Register the reproducer signal handler.
- llvm::sys::AddSignalHandler(reproducer_handler, const_cast<char *>(argv[0]));
-
SBError error = SBDebugger::InitializeWithErrorHandling();
if (error.Fail()) {
WithColor::error() << "initialization failed: " << error.GetCString()
diff --git a/lldb/tools/driver/Driver.h b/lldb/tools/driver/Driver.h
index f442458ae401..2d91491a2540 100644
--- a/lldb/tools/driver/Driver.h
+++ b/lldb/tools/driver/Driver.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Driver_h_
-#define lldb_Driver_h_
+#ifndef LLDB_TOOLS_DRIVER_DRIVER_H
+#define LLDB_TOOLS_DRIVER_DRIVER_H
#include "Platform.h"
@@ -99,4 +99,4 @@ private:
OptionData m_option_data;
};
-#endif // lldb_Driver_h_
+#endif // LLDB_TOOLS_DRIVER_DRIVER_H
diff --git a/lldb/tools/driver/Options.td b/lldb/tools/driver/Options.td
index c237f568f64c..96f696ec3ca6 100644
--- a/lldb/tools/driver/Options.td
+++ b/lldb/tools/driver/Options.td
@@ -232,7 +232,11 @@ def capture_path: Separate<["--", "-"], "capture-path">,
def replay: Separate<["--", "-"], "replay">,
MetaVarName<"<filename>">,
HelpText<"Tells the debugger to replay a reproducer from <filename>.">;
-def skip_version_check: F<"reproducer-skip-version-check">,
- HelpText<"Skip the reproducer version check.">;
+def no_version_check: F<"reproducer-no-version-check">,
+ HelpText<"Disable the reproducer version check.">;
+def no_generate_on_signal: F<"reproducer-no-generate-on-signal">,
+ HelpText<"Don't generate reproducer when a signal is received.">;
+def generate_on_exit: F<"reproducer-generate-on-exit">,
+ HelpText<"Generate reproducer on exit.">;
def REM : R<["--"], "">;
diff --git a/lldb/tools/driver/Platform.h b/lldb/tools/driver/Platform.h
index cf6c4ec8e146..6b893f91f442 100644
--- a/lldb/tools/driver/Platform.h
+++ b/lldb/tools/driver/Platform.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Platform_h_
-#define lldb_Platform_h_
+#ifndef LLDB_TOOLS_DRIVER_PLATFORM_H
+#define LLDB_TOOLS_DRIVER_PLATFORM_H
#include "lldb/Host/Config.h"
@@ -87,4 +87,4 @@ extern int tcgetattr(int fildes, struct termios *termios_p);
#include <sys/time.h>
#endif
-#endif // lldb_Platform_h_
+#endif // LLDB_TOOLS_DRIVER_PLATFORM_H
diff --git a/lldb/tools/lldb-instr/Instrument.cpp b/lldb/tools/lldb-instr/Instrument.cpp
index 9b2970030cb0..8ec01304891b 100644
--- a/lldb/tools/lldb-instr/Instrument.cpp
+++ b/lldb/tools/lldb-instr/Instrument.cpp
@@ -194,10 +194,9 @@ public:
ParamTypes.push_back(T.getAsString(Policy));
ParamNames.push_back(P->getNameAsString());
- // Currently we don't support functions that have void pointers or
- // function pointers as an argument, in which case we insert a dummy
- // macro.
- ShouldInsertDummy |= T->isFunctionPointerType() || T->isVoidPointerType();
+ // Currently we don't support functions that have function pointers as an
+ // argument, in which case we insert a dummy macro.
+ ShouldInsertDummy |= T->isFunctionPointerType();
}
// Convert the two lists to string for the macros.
diff --git a/lldb/tools/lldb-mi/lldb-mi.exports b/lldb/tools/lldb-mi/lldb-mi.exports
deleted file mode 100644
index e69de29bb2d1..000000000000
--- a/lldb/tools/lldb-mi/lldb-mi.exports
+++ /dev/null
diff --git a/lldb/tools/lldb-server/Acceptor.cpp b/lldb/tools/lldb-server/Acceptor.cpp
index 2cfb34d215c8..b8be9c5c2661 100644
--- a/lldb/tools/lldb-server/Acceptor.cpp
+++ b/lldb/tools/lldb-server/Acceptor.cpp
@@ -118,7 +118,7 @@ std::unique_ptr<Acceptor> Acceptor::Create(StringRef name,
return (local_port != 0) ? llvm::to_string(local_port) : "";
};
} else {
- const std::string socket_name = name;
+ const std::string socket_name = std::string(name);
local_socket_id = [socket_name]() { return socket_name; };
}
diff --git a/lldb/tools/lldb-server/Acceptor.h b/lldb/tools/lldb-server/Acceptor.h
index 1e7337f14113..b441e92dcd22 100644
--- a/lldb/tools/lldb-server/Acceptor.h
+++ b/lldb/tools/lldb-server/Acceptor.h
@@ -5,8 +5,8 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_server_Acceptor_h_
-#define lldb_server_Acceptor_h_
+#ifndef LLDB_TOOLS_LLDB_SERVER_ACCEPTOR_H
+#define LLDB_TOOLS_LLDB_SERVER_ACCEPTOR_H
#include "lldb/Host/Socket.h"
#include "lldb/Utility/Connection.h"
@@ -57,4 +57,4 @@ private:
} // namespace lldb_server
} // namespace lldb_private
-#endif // lldb_server_Acceptor_h_
+#endif // LLDB_TOOLS_LLDB_SERVER_ACCEPTOR_H
diff --git a/lldb/tools/lldb-server/LLDBServerUtilities.h b/lldb/tools/lldb-server/LLDBServerUtilities.h
index 3ade1f9f5b8a..b59d1e411540 100644
--- a/lldb/tools/lldb-server/LLDBServerUtilities.h
+++ b/lldb/tools/lldb-server/LLDBServerUtilities.h
@@ -1,3 +1,7 @@
+#ifndef LLDB_TOOLS_LLDB_SERVER_LLDBSERVERUTILITIES_H
+
+#define LLDB_TOOLS_LLDB_SERVER_LLDBSERVERUTILITIES_H
+
//===-- LLDBServerUtilities.h -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
@@ -21,3 +25,5 @@ public:
};
}
}
+
+#endif
diff --git a/lldb/tools/lldb-server/SystemInitializerLLGS.h b/lldb/tools/lldb-server/SystemInitializerLLGS.h
index 59a1fa14e81c..f3d015e94f8c 100644
--- a/lldb/tools/lldb-server/SystemInitializerLLGS.h
+++ b/lldb/tools/lldb-server/SystemInitializerLLGS.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SYSTEMINITIALIZERLLGS_H
-#define LLDB_SYSTEMINITIALIZERLLGS_H
+#ifndef LLDB_TOOLS_LLDB_SERVER_SYSTEMINITIALIZERLLGS_H
+#define LLDB_TOOLS_LLDB_SERVER_SYSTEMINITIALIZERLLGS_H
#include "lldb/Initialization/SystemInitializer.h"
#include "lldb/Initialization/SystemInitializerCommon.h"
@@ -18,4 +18,4 @@ public:
void Terminate() override;
};
-#endif // LLDB_SYSTEMINITIALIZERLLGS_H
+#endif // LLDB_TOOLS_LLDB_SERVER_SYSTEMINITIALIZERLLGS_H
diff --git a/lldb/tools/lldb-server/lldb-platform.cpp b/lldb/tools/lldb-server/lldb-platform.cpp
index a6fb5639d642..33f918ffc2a1 100644
--- a/lldb/tools/lldb-server/lldb-platform.cpp
+++ b/lldb/tools/lldb-server/lldb-platform.cpp
@@ -96,7 +96,7 @@ static void display_usage(const char *progname, const char *subcommand) {
static Status save_socket_id_to_file(const std::string &socket_id,
const FileSpec &file_spec) {
- FileSpec temp_file_spec(file_spec.GetDirectory().AsCString());
+ FileSpec temp_file_spec(file_spec.GetDirectory().GetStringRef());
Status error(llvm::sys::fs::create_directory(temp_file_spec.GetPath()));
if (error.Fail())
return Status("Failed to create directory %s: %s",
@@ -343,7 +343,7 @@ int main_platform(int argc, char *argv[]) {
// connections while a connection is active.
acceptor_up.reset();
}
- platform.SetConnection(conn);
+ platform.SetConnection(std::unique_ptr<Connection>(conn));
if (platform.IsConnected()) {
if (inferior_arguments.GetArgumentCount() > 0) {
diff --git a/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp b/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
index 6e73d0c53de3..ccf48275f42c 100644
--- a/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
+++ b/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
@@ -55,18 +55,18 @@ struct CommandOption {
Required = Option->getValue("Required");
// Add the full and short name for this option.
- FullName = Option->getValueAsString("FullName");
- ShortName = Option->getValueAsString("ShortName");
+ FullName = std::string(Option->getValueAsString("FullName"));
+ ShortName = std::string(Option->getValueAsString("ShortName"));
if (auto A = Option->getValue("ArgType"))
ArgType = A->getValue()->getAsUnquotedString();
OptionalArg = Option->getValue("OptionalArg") != nullptr;
if (Option->getValue("Validator"))
- Validator = Option->getValueAsString("Validator");
+ Validator = std::string(Option->getValueAsString("Validator"));
if (Option->getValue("ArgEnum"))
- ArgEnum = Option->getValueAsString("ArgEnum");
+ ArgEnum = std::string(Option->getValueAsString("ArgEnum"));
if (Option->getValue("Completions"))
Completions = Option->getValueAsListOfStrings("Completions");
diff --git a/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp b/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp
index f36deeebf906..e3522f2c7b2d 100644
--- a/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp
+++ b/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp
@@ -35,8 +35,9 @@ static void emitProperty(Record *Property, raw_ostream &OS) {
OS << ", ";
// Emit the property type.
+ llvm::StringRef type = Property->getValueAsString("Type");
OS << "OptionValue::eType";
- OS << Property->getValueAsString("Type");
+ OS << type;
OS << ", ";
// Emit the property's global value.
@@ -46,11 +47,12 @@ static void emitProperty(Record *Property, raw_ostream &OS) {
bool hasDefaultUnsignedValue = Property->getValue("HasDefaultUnsignedValue");
bool hasDefaultEnumValue = Property->getValue("HasDefaultEnumValue");
bool hasDefaultStringValue = Property->getValue("HasDefaultStringValue");
+ bool hasElementType = Property->getValue("HasElementType");
// Guarantee that every property has a default value.
assert((hasDefaultUnsignedValue || hasDefaultEnumValue ||
- hasDefaultStringValue) &&
- "Property must have a default value");
+ hasDefaultStringValue || hasElementType) &&
+ "Property must have a default value or an element type");
// Guarantee that no property has both a default unsigned value and a default
// enum value, since they're bothed stored in the same field.
@@ -72,11 +74,18 @@ static void emitProperty(Record *Property, raw_ostream &OS) {
!(Property->getValueAsString("Type") == "Enum" && !hasDefaultEnumValue) &&
"Enum property must have a enum default value.");
+ // Guarantee that only arrays and dictionaries have an element type;
+ assert(((type != "Array" && type != "Dictionary") || hasElementType) &&
+ "Only dictionaries and arrays can have an element type.");
+
// Emit the default uint value.
if (hasDefaultUnsignedValue) {
OS << std::to_string(Property->getValueAsInt("DefaultUnsignedValue"));
} else if (hasDefaultEnumValue) {
OS << Property->getValueAsString("DefaultEnumValue");
+ } else if (hasElementType) {
+ OS << "OptionValue::eType";
+ OS << Property->getValueAsString("ElementType");
} else {
OS << "0";
}
diff --git a/lldb/utils/TableGen/LLDBTableGenBackends.h b/lldb/utils/TableGen/LLDBTableGenBackends.h
index b424abfce9a7..88ae0888c22d 100644
--- a/lldb/utils/TableGen/LLDBTableGenBackends.h
+++ b/lldb/utils/TableGen/LLDBTableGenBackends.h
@@ -13,8 +13,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LLDB_UTILS_TABLEGEN_TABLEGENBACKENDS_H
-#define LLVM_LLDB_UTILS_TABLEGEN_TABLEGENBACKENDS_H
+#ifndef LLDB_UTILS_TABLEGEN_LLDBTABLEGENBACKENDS_H
+#define LLDB_UTILS_TABLEGEN_LLDBTABLEGENBACKENDS_H
#include "llvm/ADT/StringRef.h"
diff --git a/lldb/utils/TableGen/LLDBTableGenUtils.h b/lldb/utils/TableGen/LLDBTableGenUtils.h
index 5553cecafb12..76f0df9a23f6 100644
--- a/lldb/utils/TableGen/LLDBTableGenUtils.h
+++ b/lldb/utils/TableGen/LLDBTableGenUtils.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LLDB_UTILS_TABLEGEN_TABLEGENUTILS_H
-#define LLVM_LLDB_UTILS_TABLEGEN_TABLEGENUTILS_H
+#ifndef LLDB_UTILS_TABLEGEN_LLDBTABLEGENUTILS_H
+#define LLDB_UTILS_TABLEGEN_LLDBTABLEGENUTILS_H
#include "llvm/ADT/StringRef.h"
#include <map>