aboutsummaryrefslogtreecommitdiffstats
path: root/source/Plugins
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-01-19 10:06:29 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-01-19 10:06:29 +0000
commit94994d372d014ce4c8758b9605d63fae651bd8aa (patch)
tree51c0b708bd59f205d6b35cb2a8c24d62f0c33d77 /source/Plugins
parent39be7ce23363d12ae3e49aeb1fdb2bfeb892e836 (diff)
downloadsrc-94994d372d014ce4c8758b9605d63fae651bd8aa.tar.gz
src-94994d372d014ce4c8758b9605d63fae651bd8aa.zip
Vendor import of lldb trunk r351319 (just before the release_80 branchvendor/lldb/lldb-trunk-r351319
Notes
Notes: svn path=/vendor/lldb/dist/; revision=343181 svn path=/vendor/lldb/lldb-trunk-r351319/; revision=343182; tag=vendor/lldb/lldb-trunk-r351319
Diffstat (limited to 'source/Plugins')
-rw-r--r--source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp46
-rw-r--r--source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h4
-rw-r--r--source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp218
-rw-r--r--source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h4
-rw-r--r--source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp35
-rw-r--r--source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h4
-rw-r--r--source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp86
-rw-r--r--source/Plugins/ABI/SysV-arm/ABISysV_arm.h4
-rw-r--r--source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp73
-rw-r--r--source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h4
-rw-r--r--source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp11
-rw-r--r--source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h4
-rw-r--r--source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp57
-rw-r--r--source/Plugins/ABI/SysV-i386/ABISysV_i386.h4
-rw-r--r--source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp21
-rw-r--r--source/Plugins/ABI/SysV-mips/ABISysV_mips.h4
-rw-r--r--source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp68
-rw-r--r--source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h4
-rw-r--r--source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp94
-rw-r--r--source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h4
-rw-r--r--source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp62
-rw-r--r--source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h4
-rw-r--r--source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp56
-rw-r--r--source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h8
-rw-r--r--source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp87
-rw-r--r--source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h4
-rw-r--r--source/Plugins/Architecture/Arm/ArchitectureArm.cpp30
-rw-r--r--source/Plugins/Architecture/Arm/ArchitectureArm.h6
-rw-r--r--source/Plugins/Architecture/CMakeLists.txt1
-rw-r--r--source/Plugins/Architecture/Mips/ArchitectureMips.cpp241
-rw-r--r--source/Plugins/Architecture/Mips/ArchitectureMips.h52
-rw-r--r--source/Plugins/Architecture/Mips/CMakeLists.txt10
-rw-r--r--source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp123
-rw-r--r--source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h16
-rw-r--r--source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp97
-rw-r--r--source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h6
-rw-r--r--source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp18
-rw-r--r--source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h4
-rw-r--r--source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h5
-rw-r--r--source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp47
-rw-r--r--source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h6
-rw-r--r--source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp47
-rw-r--r--source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h13
-rw-r--r--source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp19
-rw-r--r--source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h8
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp2
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.h3
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp16
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h3
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp14
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h4
-rw-r--r--source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h4
-rw-r--r--source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp36
-rw-r--r--source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h4
-rw-r--r--source/Plugins/ExpressionParser/CMakeLists.txt1
-rw-r--r--source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp3
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp54
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp2
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h10
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h4
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp352
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h38
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h4
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp6
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h4
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangHost.cpp13
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp9
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h4
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp146
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangUserExpression.h18
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp2
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h4
-rw-r--r--source/Plugins/ExpressionParser/Clang/IRForTarget.cpp42
-rw-r--r--source/Plugins/ExpressionParser/Go/CMakeLists.txt13
-rw-r--r--source/Plugins/ExpressionParser/Go/GoAST.h1977
-rw-r--r--source/Plugins/ExpressionParser/Go/GoLexer.cpp350
-rw-r--r--source/Plugins/ExpressionParser/Go/GoLexer.h181
-rw-r--r--source/Plugins/ExpressionParser/Go/GoParser.cpp886
-rw-r--r--source/Plugins/ExpressionParser/Go/GoParser.h145
-rw-r--r--source/Plugins/ExpressionParser/Go/GoUserExpression.cpp668
-rw-r--r--source/Plugins/ExpressionParser/Go/GoUserExpression.h94
-rw-r--r--source/Plugins/ExpressionParser/Go/gen_go_ast.py464
-rw-r--r--source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp96
-rw-r--r--source/Plugins/Instruction/ARM/EmulationStateARM.cpp4
-rw-r--r--source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp18
-rw-r--r--source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h4
-rw-r--r--source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp137
-rw-r--r--source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp130
-rw-r--r--source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h4
-rw-r--r--source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h4
-rw-r--r--source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h4
-rw-r--r--source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h4
-rw-r--r--source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp8
-rw-r--r--source/Plugins/JITLoader/GDB/JITLoaderGDB.h4
-rw-r--r--source/Plugins/Language/CMakeLists.txt4
-rw-r--r--source/Plugins/Language/CPlusPlus/BlockPointer.cpp6
-rw-r--r--source/Plugins/Language/CPlusPlus/CMakeLists.txt5
-rw-r--r--source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp216
-rw-r--r--source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h11
-rw-r--r--source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h4
-rw-r--r--source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp14
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxx.cpp186
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxx.h31
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp19
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp15
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxList.cpp4
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxMap.cpp4
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp85
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp4
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp256
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxVariant.h31
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxVector.cpp38
-rw-r--r--source/Plugins/Language/CPlusPlus/LibStdcpp.cpp11
-rw-r--r--source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp99
-rw-r--r--source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h51
-rw-r--r--source/Plugins/Language/ClangCommon/CMakeLists.txt9
-rw-r--r--source/Plugins/Language/ClangCommon/ClangHighlighter.cpp237
-rw-r--r--source/Plugins/Language/ClangCommon/ClangHighlighter.h38
-rw-r--r--source/Plugins/Language/Go/CMakeLists.txt13
-rw-r--r--source/Plugins/Language/Go/GoFormatterFunctions.cpp152
-rw-r--r--source/Plugins/Language/Go/GoFormatterFunctions.h43
-rw-r--r--source/Plugins/Language/Go/GoLanguage.cpp127
-rw-r--r--source/Plugins/Language/Go/GoLanguage.h63
-rw-r--r--source/Plugins/Language/Java/CMakeLists.txt12
-rw-r--r--source/Plugins/Language/Java/JavaFormatterFunctions.cpp167
-rw-r--r--source/Plugins/Language/Java/JavaFormatterFunctions.h35
-rw-r--r--source/Plugins/Language/Java/JavaLanguage.cpp101
-rw-r--r--source/Plugins/Language/Java/JavaLanguage.h52
-rw-r--r--source/Plugins/Language/OCaml/CMakeLists.txt12
-rw-r--r--source/Plugins/Language/OCaml/OCamlLanguage.cpp63
-rw-r--r--source/Plugins/Language/OCaml/OCamlLanguage.h51
-rw-r--r--source/Plugins/Language/ObjC/CF.cpp2
-rw-r--r--source/Plugins/Language/ObjC/CMakeLists.txt1
-rw-r--r--source/Plugins/Language/ObjC/Cocoa.cpp67
-rw-r--r--source/Plugins/Language/ObjC/NSArray.cpp31
-rw-r--r--source/Plugins/Language/ObjC/NSDictionary.cpp4
-rw-r--r--source/Plugins/Language/ObjC/NSError.cpp4
-rw-r--r--source/Plugins/Language/ObjC/NSException.cpp158
-rw-r--r--source/Plugins/Language/ObjC/NSIndexPath.cpp10
-rw-r--r--source/Plugins/Language/ObjC/NSSet.cpp4
-rw-r--r--source/Plugins/Language/ObjC/NSString.cpp13
-rw-r--r--source/Plugins/Language/ObjC/ObjCLanguage.cpp20
-rw-r--r--source/Plugins/Language/ObjC/ObjCLanguage.h11
-rw-r--r--source/Plugins/Language/ObjCPlusPlus/CMakeLists.txt3
-rw-r--r--source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp9
-rw-r--r--source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h11
-rw-r--r--source/Plugins/LanguageRuntime/CMakeLists.txt2
-rw-r--r--source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp188
-rw-r--r--source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h7
-rw-r--r--source/Plugins/LanguageRuntime/Go/CMakeLists.txt2
-rw-r--r--source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.cpp215
-rw-r--r--source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.h86
-rw-r--r--source/Plugins/LanguageRuntime/Java/CMakeLists.txt10
-rw-r--r--source/Plugins/LanguageRuntime/Java/JavaLanguageRuntime.cpp157
-rw-r--r--source/Plugins/LanguageRuntime/Java/JavaLanguageRuntime.h78
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp15
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h4
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp2
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h4
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp124
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h12
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp9
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h4
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp94
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h4
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp8
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h4
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h4
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp15
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h4
-rw-r--r--source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp4
-rw-r--r--source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h4
-rw-r--r--source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp82
-rw-r--r--source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h10
-rw-r--r--source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp4
-rw-r--r--source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h4
-rw-r--r--source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp9
-rw-r--r--source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h3
-rw-r--r--source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h6
-rw-r--r--source/Plugins/ObjectFile/Breakpad/CMakeLists.txt11
-rw-r--r--source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp315
-rw-r--r--source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h109
-rw-r--r--source/Plugins/ObjectFile/CMakeLists.txt3
-rw-r--r--source/Plugins/ObjectFile/ELF/ELFHeader.cpp29
-rw-r--r--source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp735
-rw-r--r--source/Plugins/ObjectFile/ELF/ObjectFileELF.h28
-rw-r--r--source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp16
-rw-r--r--source/Plugins/ObjectFile/JIT/ObjectFileJIT.h8
-rw-r--r--source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp435
-rw-r--r--source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h21
-rw-r--r--source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp441
-rw-r--r--source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h19
-rw-r--r--source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp2
-rw-r--r--source/Plugins/OperatingSystem/CMakeLists.txt1
-rw-r--r--source/Plugins/OperatingSystem/Go/CMakeLists.txt10
-rw-r--r--source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp498
-rw-r--r--source/Plugins/OperatingSystem/Go/OperatingSystemGo.h90
-rw-r--r--source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp10
-rw-r--r--source/Plugins/OperatingSystem/Python/OperatingSystemPython.h4
-rw-r--r--source/Plugins/Platform/Android/AdbClient.cpp3
-rw-r--r--source/Plugins/Platform/Android/PlatformAndroid.cpp12
-rw-r--r--source/Plugins/Platform/Android/PlatformAndroid.h4
-rw-r--r--source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp1
-rw-r--r--source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h4
-rw-r--r--source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp14
-rw-r--r--source/Plugins/Platform/Kalimba/PlatformKalimba.cpp5
-rw-r--r--source/Plugins/Platform/Kalimba/PlatformKalimba.h4
-rw-r--r--source/Plugins/Platform/Linux/PlatformLinux.cpp16
-rw-r--r--source/Plugins/Platform/MacOSX/CMakeLists.txt1
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp9
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h4
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp37
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h4
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp37
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h4
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformDarwin.cpp131
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformDarwin.h21
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp127
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h31
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp23
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformMacOSX.h4
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp186
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h73
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp6
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h4
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp6
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h4
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp99
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h12
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp8
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h4
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp37
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h4
-rw-r--r--source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.h4
-rw-r--r--source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm4
-rw-r--r--source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp16
-rw-r--r--source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp8
-rw-r--r--source/Plugins/Platform/POSIX/PlatformPOSIX.cpp39
-rw-r--r--source/Plugins/Platform/POSIX/PlatformPOSIX.h4
-rw-r--r--source/Plugins/Platform/Windows/PlatformWindows.cpp32
-rw-r--r--source/Plugins/Platform/Windows/PlatformWindows.h4
-rw-r--r--source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp21
-rw-r--r--source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h4
-rw-r--r--source/Plugins/Process/Darwin/NativeProcessDarwin.cpp13
-rw-r--r--source/Plugins/Process/Darwin/NativeProcessDarwin.h1
-rw-r--r--source/Plugins/Process/FreeBSD/FreeBSDThread.cpp8
-rw-r--r--source/Plugins/Process/FreeBSD/FreeBSDThread.h2
-rw-r--r--source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp31
-rw-r--r--source/Plugins/Process/FreeBSD/ProcessMonitor.cpp7
-rw-r--r--source/Plugins/Process/FreeBSD/ProcessMonitor.h3
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIX.h3
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp2
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp2
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp2
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp2
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp2
-rw-r--r--source/Plugins/Process/Linux/NativeProcessLinux.cpp325
-rw-r--r--source/Plugins/Process/Linux/NativeProcessLinux.h16
-rw-r--r--source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp2
-rw-r--r--source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp2
-rw-r--r--source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp5
-rw-r--r--source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp5
-rw-r--r--source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp2
-rw-r--r--source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp2
-rwxr-xr-xsource/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp2
-rw-r--r--source/Plugins/Process/Linux/NativeThreadLinux.cpp2
-rw-r--r--source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp24
-rw-r--r--source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.h8
-rw-r--r--source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp22
-rw-r--r--source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h5
-rw-r--r--source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.cpp4
-rw-r--r--source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm.h4
-rw-r--r--source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.cpp4
-rw-r--r--source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_arm64.h4
-rw-r--r--source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.cpp4
-rw-r--r--source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_i386.h4
-rw-r--r--source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.cpp4
-rw-r--r--source/Plugins/Process/MacOSX-Kernel/RegisterContextKDP_x86_64.h4
-rw-r--r--source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp4
-rw-r--r--source/Plugins/Process/NetBSD/CMakeLists.txt1
-rw-r--r--source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp128
-rw-r--r--source/Plugins/Process/NetBSD/NativeProcessNetBSD.h15
-rw-r--r--source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp2
-rw-r--r--source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp4
-rw-r--r--source/Plugins/Process/POSIX/ProcessPOSIXLog.h4
-rw-r--r--source/Plugins/Process/Utility/ARMUtils.h2
-rw-r--r--source/Plugins/Process/Utility/CMakeLists.txt1
-rw-r--r--source/Plugins/Process/Utility/DynamicRegisterInfo.cpp4
-rw-r--r--source/Plugins/Process/Utility/DynamicRegisterInfo.h4
-rw-r--r--source/Plugins/Process/Utility/FreeBSDSignals.cpp4
-rw-r--r--source/Plugins/Process/Utility/FreeBSDSignals.h1
-rw-r--r--source/Plugins/Process/Utility/GDBRemoteSignals.cpp3
-rw-r--r--source/Plugins/Process/Utility/GDBRemoteSignals.h4
-rw-r--r--source/Plugins/Process/Utility/HistoryThread.h8
-rw-r--r--source/Plugins/Process/Utility/HistoryUnwind.h4
-rw-r--r--source/Plugins/Process/Utility/LinuxProcMaps.cpp113
-rw-r--r--source/Plugins/Process/Utility/LinuxProcMaps.h28
-rw-r--r--source/Plugins/Process/Utility/LinuxSignals.cpp3
-rw-r--r--source/Plugins/Process/Utility/LinuxSignals.h4
-rw-r--r--source/Plugins/Process/Utility/MipsLinuxSignals.cpp3
-rw-r--r--source/Plugins/Process/Utility/MipsLinuxSignals.h4
-rw-r--r--source/Plugins/Process/Utility/NetBSDSignals.cpp4
-rw-r--r--source/Plugins/Process/Utility/NetBSDSignals.h1
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp9
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_arm.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp21
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp10
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_i386.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp12
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDummy.cpp2
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDummy.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextHistory.cpp2
-rw-r--r--source/Plugins/Process/Utility/RegisterContextHistory.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLLDB.cpp180
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLLDB.h11
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp8
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMach_arm.cpp4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMach_arm.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMach_i386.cpp4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMach_i386.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMach_x86_64.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMemory.cpp6
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMemory.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp6
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextThreadMemory.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContext_x86.h2
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_arm.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_arm64.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_i386.h1
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_mips.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_mips64.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_ppc64.h1
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_ppc64le.h1
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_s390x.h4
-rw-r--r--source/Plugins/Process/Utility/StopInfoMachException.cpp57
-rw-r--r--source/Plugins/Process/Utility/StopInfoMachException.h4
-rw-r--r--source/Plugins/Process/Utility/ThreadMemory.h4
-rw-r--r--source/Plugins/Process/Utility/UnwindLLDB.cpp23
-rw-r--r--source/Plugins/Process/Utility/UnwindLLDB.h4
-rw-r--r--source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp4
-rw-r--r--source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h4
-rw-r--r--source/Plugins/Process/Windows/Common/DebuggerThread.cpp16
-rw-r--r--source/Plugins/Process/Windows/Common/DebuggerThread.h2
-rw-r--r--source/Plugins/Process/Windows/Common/ForwardDecl.h2
-rw-r--r--source/Plugins/Process/Windows/Common/ProcessWindows.cpp104
-rw-r--r--source/Plugins/Process/Windows/Common/ProcessWindows.h4
-rw-r--r--source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp7
-rw-r--r--source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp2
-rw-r--r--source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp14
-rw-r--r--source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp2
-rw-r--r--source/Plugins/Process/elf-core/ProcessElfCore.cpp59
-rw-r--r--source/Plugins/Process/elf-core/ProcessElfCore.h10
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp2
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp2
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp2
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp2
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp2
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp2
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp2
-rw-r--r--source/Plugins/Process/gdb-remote/CMakeLists.txt2
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp2
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp212
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h98
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp57
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h2
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp143
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h156
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp204
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h83
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp3
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h4
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp51
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h4
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp18
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h4
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp18
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h4
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp12
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h4
-rw-r--r--source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp215
-rw-r--r--source/Plugins/Process/gdb-remote/ProcessGDBRemote.h12
-rw-r--r--source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h4
-rw-r--r--source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp13
-rw-r--r--source/Plugins/Process/gdb-remote/ThreadGDBRemote.h4
-rw-r--r--source/Plugins/Process/mach-core/ProcessMachCore.cpp78
-rw-r--r--source/Plugins/Process/mach-core/ProcessMachCore.h4
-rw-r--r--source/Plugins/Process/mach-core/ThreadMachCore.cpp4
-rw-r--r--source/Plugins/Process/mach-core/ThreadMachCore.h4
-rw-r--r--source/Plugins/Process/minidump/CMakeLists.txt2
-rw-r--r--source/Plugins/Process/minidump/MinidumpParser.cpp354
-rw-r--r--source/Plugins/Process/minidump/MinidumpParser.h24
-rw-r--r--source/Plugins/Process/minidump/MinidumpTypes.cpp4
-rw-r--r--source/Plugins/Process/minidump/MinidumpTypes.h65
-rw-r--r--source/Plugins/Process/minidump/ProcessMinidump.cpp334
-rw-r--r--source/Plugins/Process/minidump/ProcessMinidump.h14
-rw-r--r--source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp532
-rw-r--r--source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h93
-rw-r--r--source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp834
-rw-r--r--source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h83
-rw-r--r--source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp2
-rw-r--r--source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h2
-rw-r--r--source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp2
-rw-r--r--source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h2
-rw-r--r--source/Plugins/Process/minidump/ThreadMinidump.cpp28
-rw-r--r--source/Plugins/Process/minidump/ThreadMinidump.h4
-rw-r--r--source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h4
-rw-r--r--source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp11
-rw-r--r--source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h4
-rw-r--r--source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp177
-rw-r--r--source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h45
-rw-r--r--source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp42
-rw-r--r--source/Plugins/SymbolFile/Breakpad/CMakeLists.txt12
-rw-r--r--source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp223
-rw-r--r--source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h146
-rw-r--r--source/Plugins/SymbolFile/CMakeLists.txt2
-rw-r--r--source/Plugins/SymbolFile/DWARF/CMakeLists.txt3
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFASTParser.h12
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp308
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h37
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp772
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.h84
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp510
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.h81
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp210
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.h59
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp6
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h17
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp8
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFAttribute.h11
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp31
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h4
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp4
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDIE.h5
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h1
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h2
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp140
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h28
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp146
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h18
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp2
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp178
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h46
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h4
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp4
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDefines.h2
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp248
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFFormValue.h8
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp108
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFUnit.h11
-rw-r--r--source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp10
-rw-r--r--source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp4
-rw-r--r--source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h4
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp397
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h96
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp182
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h55
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp39
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h10
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h4
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp9
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h4
-rw-r--r--source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp4
-rw-r--r--source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h4
-rw-r--r--source/Plugins/SymbolFile/NativePDB/CMakeLists.txt21
-rw-r--r--source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp217
-rw-r--r--source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h95
-rw-r--r--source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp673
-rw-r--r--source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.h42
-rw-r--r--source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp1348
-rw-r--r--source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h144
-rw-r--r--source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp200
-rw-r--r--source/Plugins/SymbolFile/NativePDB/PdbIndex.h162
-rw-r--r--source/Plugins/SymbolFile/NativePDB/PdbSymUid.cpp161
-rw-r--r--source/Plugins/SymbolFile/NativePDB/PdbSymUid.h126
-rw-r--r--source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp750
-rw-r--r--source/Plugins/SymbolFile/NativePDB/PdbUtil.h159
-rw-r--r--source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp1571
-rw-r--r--source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h245
-rw-r--r--source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp191
-rw-r--r--source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h75
-rw-r--r--source/Plugins/SymbolFile/PDB/CMakeLists.txt1
-rw-r--r--source/Plugins/SymbolFile/PDB/PDBASTParser.cpp1005
-rw-r--r--source/Plugins/SymbolFile/PDB/PDBASTParser.h67
-rw-r--r--source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp658
-rw-r--r--source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp591
-rw-r--r--source/Plugins/SymbolFile/PDB/SymbolFilePDB.h69
-rw-r--r--source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp38
-rw-r--r--source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h33
-rw-r--r--source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp9
-rw-r--r--source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h4
-rw-r--r--source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp26
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp7
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h4
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp7
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h4
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp7
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h4
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp7
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h4
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp9
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h3
-rw-r--r--source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp2
-rw-r--r--source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h6
-rw-r--r--source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp8
-rw-r--r--source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h4
-rw-r--r--source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp344
-rw-r--r--source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h7
525 files changed, 19647 insertions, 14855 deletions
diff --git a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
index e0e293d7ae68..9055660f2d6c 100644
--- a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
+++ b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
@@ -9,19 +9,13 @@
#include "ABIMacOSX_arm.h"
-// C Includes
-// C++ Includes
#include <vector>
-// Other libraries and framework includes
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
-// Project includes
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegisterValue.h"
-#include "lldb/Core/Scalar.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Symbol/UnwindPlan.h"
@@ -30,6 +24,8 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/RegisterValue.h"
+#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/Status.h"
#include "Plugins/Process/Utility/ARMDefines.h"
@@ -1327,16 +1323,13 @@ size_t ABIMacOSX_arm::GetRedZoneSize() const { return 0; }
ABISP
ABIMacOSX_arm::CreateInstance(ProcessSP process_sp, const ArchSpec &arch) {
- static ABISP g_abi_sp;
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::arm) ||
(arch_type == llvm::Triple::thumb)) {
- if (!g_abi_sp)
- g_abi_sp.reset(new ABIMacOSX_arm(process_sp));
- return g_abi_sp;
+ return ABISP(new ABIMacOSX_arm(process_sp));
}
}
@@ -1477,14 +1470,16 @@ bool ABIMacOSX_arm::GetArgumentValues(Thread &thread, ValueList &values) const {
if (compiler_type) {
bool is_signed = false;
size_t bit_width = 0;
- if (compiler_type.IsIntegerOrEnumerationType(is_signed)) {
- bit_width = compiler_type.GetBitSize(&thread);
- } else if (compiler_type.IsPointerOrReferenceType()) {
- bit_width = compiler_type.GetBitSize(&thread);
- } else {
+ llvm::Optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
+ if (!bit_size)
+ return false;
+ if (compiler_type.IsIntegerOrEnumerationType(is_signed))
+ bit_width = *bit_size;
+ else if (compiler_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 < 4) {
@@ -1581,9 +1576,11 @@ ValueObjectSP ABIMacOSX_arm::GetReturnValueObjectImpl(
const RegisterInfo *r0_reg_info = reg_ctx->GetRegisterInfoByName("r0", 0);
if (compiler_type.IsIntegerOrEnumerationType(is_signed)) {
- size_t bit_width = compiler_type.GetBitSize(&thread);
+ llvm::Optional<uint64_t> bit_width = compiler_type.GetBitSize(&thread);
+ if (!bit_width)
+ return return_valobj_sp;
- switch (bit_width) {
+ switch (*bit_width) {
default:
return return_valobj_sp;
case 128:
@@ -1599,14 +1596,17 @@ ValueObjectSP ABIMacOSX_arm::GetReturnValueObjectImpl(
const RegisterInfo *r3_reg_info =
reg_ctx->GetRegisterInfoByName("r3", 0);
if (r1_reg_info && r2_reg_info && r3_reg_info) {
- const size_t byte_size = compiler_type.GetByteSize(&thread);
+ llvm::Optional<uint64_t> byte_size =
+ compiler_type.GetByteSize(&thread);
+ if (!byte_size)
+ return return_valobj_sp;
ProcessSP process_sp(thread.GetProcess());
- if (byte_size <= r0_reg_info->byte_size + r1_reg_info->byte_size +
- r2_reg_info->byte_size +
- r3_reg_info->byte_size &&
+ if (*byte_size <= r0_reg_info->byte_size + r1_reg_info->byte_size +
+ r2_reg_info->byte_size +
+ r3_reg_info->byte_size &&
process_sp) {
std::unique_ptr<DataBufferHeap> heap_data_ap(
- new DataBufferHeap(byte_size, 0));
+ new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order = process_sp->GetByteOrder();
RegisterValue r0_reg_value;
RegisterValue r1_reg_value;
diff --git a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h
index d3c20e1e618f..94f1e31a1235 100644
--- a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h
+++ b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h
@@ -10,10 +10,6 @@
#ifndef liblldb_ABIMacOSX_arm_h_
#define liblldb_ABIMacOSX_arm_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
diff --git a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
index 85f864ec7561..d8706c4a9cdd 100644
--- a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
+++ b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
@@ -9,18 +9,13 @@
#include "ABIMacOSX_arm64.h"
-// C Includes
-// C++ Includes
#include <vector>
-// Other libraries and framework includes
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegisterValue.h"
-#include "lldb/Core/Scalar.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Symbol/UnwindPlan.h"
@@ -30,6 +25,8 @@
#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"
@@ -1667,15 +1664,12 @@ size_t ABIMacOSX_arm64::GetRedZoneSize() const { return 128; }
ABISP
ABIMacOSX_arm64::CreateInstance(ProcessSP process_sp, const ArchSpec &arch) {
- static ABISP g_abi_sp;
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) {
- if (!g_abi_sp)
- g_abi_sp.reset(new ABIMacOSX_arm64(process_sp));
- return g_abi_sp;
+ return ABISP(new ABIMacOSX_arm64(process_sp));
}
}
@@ -1768,90 +1762,92 @@ bool ABIMacOSX_arm64::GetArgumentValues(Thread &thread,
return false;
CompilerType value_type = value->GetCompilerType();
- if (value_type) {
- bool is_signed = false;
- size_t bit_width = 0;
- if (value_type.IsIntegerOrEnumerationType(is_signed)) {
- bit_width = value_type.GetBitSize(&thread);
- } else if (value_type.IsPointerOrReferenceType()) {
- bit_width = value_type.GetBitSize(&thread);
- } else {
- // We only handle integer, pointer and reference types currently...
- return false;
- }
+ llvm::Optional<uint64_t> bit_size = value_type.GetBitSize(&thread);
+ if (!bit_size)
+ 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;
- }
+ 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_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)
+ 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;
}
-
- // 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;
+ } 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;
+ }
- sp += arg_byte_size;
- // Align up to the next 8 byte boundary if needed
- if (sp % 8) {
- sp >>= 3;
- sp += 1;
- sp <<= 3;
- }
+ // 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;
}
}
}
@@ -2115,13 +2111,12 @@ static bool LoadValueFromConsecutiveGPRRegisters(
uint32_t &NGRN, // NGRN (see ABI documentation)
uint32_t &NSRN, // NSRN (see ABI documentation)
DataExtractor &data) {
- const size_t byte_size = value_type.GetByteSize(nullptr);
-
- if (byte_size == 0)
+ llvm::Optional<uint64_t> byte_size = value_type.GetByteSize(nullptr);
+ if (!byte_size || *byte_size == 0)
return false;
std::unique_ptr<DataBufferHeap> heap_data_ap(
- new DataBufferHeap(byte_size, 0));
+ new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder();
Status error;
@@ -2133,7 +2128,9 @@ static bool LoadValueFromConsecutiveGPRRegisters(
if (NSRN < 8 && (8 - NSRN) >= homogeneous_count) {
if (!base_type)
return false;
- const size_t base_byte_size = base_type.GetByteSize(nullptr);
+ 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) {
@@ -2144,7 +2141,7 @@ static bool LoadValueFromConsecutiveGPRRegisters(
if (reg_info == nullptr)
return false;
- if (base_byte_size > reg_info->byte_size)
+ if (*base_byte_size > reg_info->byte_size)
return false;
RegisterValue reg_value;
@@ -2153,11 +2150,11 @@ static bool LoadValueFromConsecutiveGPRRegisters(
return false;
// Make sure we have enough room in "heap_data_ap"
- if ((data_offset + base_byte_size) <= heap_data_ap->GetByteSize()) {
+ if ((data_offset + *base_byte_size) <= heap_data_ap->GetByteSize()) {
const size_t bytes_copied = reg_value.GetAsMemoryData(
- reg_info, heap_data_ap->GetBytes() + data_offset, base_byte_size,
+ reg_info, heap_data_ap->GetBytes() + data_offset, *base_byte_size,
byte_order, error);
- if (bytes_copied != base_byte_size)
+ if (bytes_copied != *base_byte_size)
return false;
data_offset += bytes_copied;
++NSRN;
@@ -2172,10 +2169,10 @@ static bool LoadValueFromConsecutiveGPRRegisters(
}
const size_t max_reg_byte_size = 16;
- if (byte_size <= max_reg_byte_size) {
- size_t bytes_left = byte_size;
+ if (*byte_size <= max_reg_byte_size) {
+ size_t bytes_left = *byte_size;
uint32_t data_offset = 0;
- while (data_offset < byte_size) {
+ while (data_offset < *byte_size) {
if (NGRN >= 8)
return false;
@@ -2267,7 +2264,10 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
if (!reg_ctx)
return return_valobj_sp;
- const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
+ 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) {
@@ -2276,7 +2276,7 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
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) {
+ if (*byte_size <= 8) {
const RegisterInfo *x0_reg_info =
reg_ctx->GetRegisterInfoByName("x0", 0);
if (x0_reg_info) {
@@ -2284,7 +2284,7 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
thread.GetRegisterContext()->ReadRegisterAsUnsigned(x0_reg_info,
0);
const bool is_signed = (type_flags & eTypeIsSigned) != 0;
- switch (byte_size) {
+ switch (*byte_size) {
default:
break;
case 16: // uint128_t
@@ -2294,10 +2294,10 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
reg_ctx->GetRegisterInfoByName("x1", 0);
if (x1_reg_info) {
- if (byte_size <=
+ if (*byte_size <=
x0_reg_info->byte_size + x1_reg_info->byte_size) {
std::unique_ptr<DataBufferHeap> heap_data_ap(
- new DataBufferHeap(byte_size, 0));
+ new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order =
exe_ctx.GetProcessRef().GetByteOrder();
RegisterValue x0_reg_value;
@@ -2362,7 +2362,7 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
if (type_flags & eTypeIsComplex) {
// Don't handle complex yet.
} else {
- if (byte_size <= sizeof(long double)) {
+ if (*byte_size <= sizeof(long double)) {
const RegisterInfo *v0_reg_info =
reg_ctx->GetRegisterInfoByName("v0", 0);
RegisterValue v0_value;
@@ -2370,13 +2370,13 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
DataExtractor data;
if (v0_value.GetData(data)) {
lldb::offset_t offset = 0;
- if (byte_size == sizeof(float)) {
+ if (*byte_size == sizeof(float)) {
value.GetScalar() = data.GetFloat(&offset);
success = true;
- } else if (byte_size == sizeof(double)) {
+ } else if (*byte_size == sizeof(double)) {
value.GetScalar() = data.GetDouble(&offset);
success = true;
- } else if (byte_size == sizeof(long double)) {
+ } else if (*byte_size == sizeof(long double)) {
value.GetScalar() = data.GetLongDouble(&offset);
success = true;
}
@@ -2390,14 +2390,14 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
return_valobj_sp = ValueObjectConstResult::Create(
thread.GetStackFrameAtIndex(0).get(), value, ConstString(""));
} else if (type_flags & eTypeIsVector) {
- if (byte_size > 0) {
+ if (*byte_size > 0) {
const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0);
if (v0_info) {
- if (byte_size <= v0_info->byte_size) {
+ if (*byte_size <= v0_info->byte_size) {
std::unique_ptr<DataBufferHeap> heap_data_ap(
- new DataBufferHeap(byte_size, 0));
+ new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder();
RegisterValue reg_value;
if (reg_ctx->ReadRegister(v0_info, reg_value)) {
diff --git a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h
index 2dd7337542db..7a9444c775f4 100644
--- a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h
+++ b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h
@@ -10,10 +10,6 @@
#ifndef liblldb_ABIMacOSX_arm64_h_
#define liblldb_ABIMacOSX_arm64_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Target/ABI.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-private.h"
diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
index 9e5e39ec28ca..a297bd1473b2 100644
--- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
+++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
@@ -9,19 +9,13 @@
#include "ABIMacOSX_i386.h"
-// C Includes
-// C++ Includes
#include <vector>
-// Other libraries and framework includes
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
-// Project includes
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegisterValue.h"
-#include "lldb/Core/Scalar.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Process.h"
@@ -29,6 +23,8 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/RegisterValue.h"
+#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/Status.h"
using namespace lldb;
@@ -714,13 +710,10 @@ size_t ABIMacOSX_i386::GetRedZoneSize() const { return 0; }
ABISP
ABIMacOSX_i386::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
- static ABISP g_abi_sp;
if ((arch.GetTriple().getArch() == llvm::Triple::x86) &&
(arch.GetTriple().isMacOSX() || arch.GetTriple().isiOS() ||
arch.GetTriple().isWatchOS())) {
- if (!g_abi_sp)
- g_abi_sp.reset(new ABIMacOSX_i386(process_sp));
- return g_abi_sp;
+ return ABISP(new ABIMacOSX_i386(process_sp));
}
return ABISP();
}
@@ -831,18 +824,15 @@ bool ABIMacOSX_i386::GetArgumentValues(Thread &thread,
// We currently only support extracting values with Clang QualTypes. Do we
// care about others?
CompilerType compiler_type(value->GetCompilerType());
- if (compiler_type) {
+ llvm::Optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
+ if (bit_size) {
bool is_signed;
-
- if (compiler_type.IsIntegerOrEnumerationType(is_signed)) {
- ReadIntegerArgument(value->GetScalar(),
- compiler_type.GetBitSize(&thread), is_signed,
+ if (compiler_type.IsIntegerOrEnumerationType(is_signed))
+ ReadIntegerArgument(value->GetScalar(), *bit_size, is_signed,
thread.GetProcess().get(), current_stack_argument);
- } else if (compiler_type.IsPointerType()) {
- ReadIntegerArgument(value->GetScalar(),
- compiler_type.GetBitSize(&thread), false,
+ else if (compiler_type.IsPointerType())
+ ReadIntegerArgument(value->GetScalar(), *bit_size, false,
thread.GetProcess().get(), current_stack_argument);
- }
}
}
@@ -943,14 +933,15 @@ ABIMacOSX_i386::GetReturnValueObjectImpl(Thread &thread,
bool is_signed;
if (compiler_type.IsIntegerOrEnumerationType(is_signed)) {
- size_t bit_width = compiler_type.GetBitSize(&thread);
-
+ llvm::Optional<uint64_t> bit_width = compiler_type.GetBitSize(&thread);
+ if (!bit_width)
+ return return_valobj_sp;
unsigned eax_id =
reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB];
unsigned edx_id =
reg_ctx->GetRegisterInfoByName("edx", 0)->kinds[eRegisterKindLLDB];
- switch (bit_width) {
+ switch (*bit_width) {
default:
case 128:
// Scalar can't hold 128-bit literals, so we don't handle this
diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
index e026e3248672..536132d02586 100644
--- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
+++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
@@ -10,10 +10,6 @@
#ifndef liblldb_ABIMacOSX_i386_h_
#define liblldb_ABIMacOSX_i386_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/Value.h"
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
diff --git a/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp b/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
index af7ac469e6db..b93a8525010c 100644
--- a/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
+++ b/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
@@ -9,19 +9,13 @@
#include "ABISysV_arm.h"
-// C Includes
-// C++ Includes
#include <vector>
-// Other libraries and framework includes
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
-// Project includes
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegisterValue.h"
-#include "lldb/Core/Scalar.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Symbol/UnwindPlan.h"
@@ -30,6 +24,8 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/RegisterValue.h"
+#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/Status.h"
#include "Plugins/Process/Utility/ARMDefines.h"
@@ -1328,16 +1324,13 @@ size_t ABISysV_arm::GetRedZoneSize() const { return 0; }
ABISP
ABISysV_arm::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
- static ABISP g_abi_sp;
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::arm) ||
(arch_type == llvm::Triple::thumb)) {
- if (!g_abi_sp)
- g_abi_sp.reset(new ABISysV_arm(process_sp));
- return g_abi_sp;
+ return ABISP(new ABISysV_arm(process_sp));
}
}
@@ -1447,10 +1440,7 @@ bool ABISysV_arm::PrepareTrivialCall(Thread &thread, addr_t sp,
~1ull; // clear bit zero since the CPSR will take care of the mode for us
// Set "pc" to the address requested
- if (!reg_ctx->WriteRegisterFromUnsigned(pc_reg_num, function_addr))
- return false;
-
- return true;
+ return reg_ctx->WriteRegisterFromUnsigned(pc_reg_num, function_addr);
}
bool ABISysV_arm::GetArgumentValues(Thread &thread, ValueList &values) const {
@@ -1481,10 +1471,10 @@ bool ABISysV_arm::GetArgumentValues(Thread &thread, ValueList &values) const {
if (compiler_type) {
bool is_signed = false;
size_t bit_width = 0;
- if (compiler_type.IsIntegerOrEnumerationType(is_signed)) {
- bit_width = compiler_type.GetBitSize(&thread);
- } else if (compiler_type.IsPointerOrReferenceType()) {
- bit_width = compiler_type.GetBitSize(&thread);
+ if (compiler_type.IsIntegerOrEnumerationType(is_signed) ||
+ compiler_type.IsPointerOrReferenceType()) {
+ if (llvm::Optional<uint64_t> size = compiler_type.GetBitSize(&thread))
+ bit_width = *size;
} else {
// We only handle integer, pointer and reference types currently...
return false;
@@ -1590,11 +1580,13 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
const RegisterInfo *r0_reg_info =
reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1);
- size_t bit_width = compiler_type.GetBitSize(&thread);
- size_t byte_size = compiler_type.GetByteSize(&thread);
+ llvm::Optional<uint64_t> bit_width = compiler_type.GetBitSize(&thread);
+ llvm::Optional<uint64_t> byte_size = compiler_type.GetByteSize(&thread);
+ if (!bit_width || !byte_size)
+ return return_valobj_sp;
if (compiler_type.IsIntegerOrEnumerationType(is_signed)) {
- switch (bit_width) {
+ switch (*bit_width) {
default:
return return_valobj_sp;
case 64: {
@@ -1641,28 +1633,28 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
UINT32_MAX;
value.GetScalar() = ptr;
} else if (compiler_type.IsVectorType(nullptr, nullptr)) {
- if (IsArmHardFloat(thread) && (byte_size == 8 || byte_size == 16)) {
+ if (IsArmHardFloat(thread) && (*byte_size == 8 || *byte_size == 16)) {
is_vfp_candidate = true;
vfp_byte_size = 8;
- vfp_count = (byte_size == 8 ? 1 : 2);
- } else if (byte_size <= 16) {
+ vfp_count = (*byte_size == 8 ? 1 : 2);
+ } else if (*byte_size <= 16) {
DataBufferHeap buffer(16, 0);
uint32_t *buffer_ptr = (uint32_t *)buffer.GetBytes();
- for (uint32_t i = 0; 4 * i < byte_size; ++i) {
+ for (uint32_t i = 0; 4 * i < *byte_size; ++i) {
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(
eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + i);
buffer_ptr[i] =
reg_ctx->ReadRegisterAsUnsigned(reg_info, 0) & UINT32_MAX;
}
- value.SetBytes(buffer.GetBytes(), byte_size);
+ value.SetBytes(buffer.GetBytes(), *byte_size);
} else {
- if (!GetReturnValuePassedInMemory(thread, reg_ctx, byte_size, value))
+ if (!GetReturnValuePassedInMemory(thread, reg_ctx, *byte_size, value))
return return_valobj_sp;
}
} else if (compiler_type.IsFloatingPointType(float_count, is_complex)) {
if (float_count == 1 && !is_complex) {
- switch (bit_width) {
+ switch (*bit_width) {
default:
return return_valobj_sp;
case 64: {
@@ -1710,9 +1702,9 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
} else if (is_complex && float_count == 2) {
if (IsArmHardFloat(thread)) {
is_vfp_candidate = true;
- vfp_byte_size = byte_size / 2;
+ vfp_byte_size = *byte_size / 2;
vfp_count = 2;
- } else if (!GetReturnValuePassedInMemory(thread, reg_ctx, bit_width / 8,
+ } else if (!GetReturnValuePassedInMemory(thread, reg_ctx, *bit_width / 8,
value))
return return_valobj_sp;
} else
@@ -1725,19 +1717,21 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
compiler_type.IsHomogeneousAggregate(&base_type);
if (homogeneous_count > 0 && homogeneous_count <= 4) {
+ llvm::Optional<uint64_t> base_byte_size =
+ base_type.GetByteSize(nullptr);
if (base_type.IsVectorType(nullptr, nullptr)) {
- uint64_t base_byte_size = base_type.GetByteSize(nullptr);
- if (base_byte_size == 8 || base_byte_size == 16) {
+ if (base_byte_size &&
+ (*base_byte_size == 8 || *base_byte_size == 16)) {
is_vfp_candidate = true;
vfp_byte_size = 8;
- vfp_count =
- (base_type.GetByteSize(nullptr) == 8 ? homogeneous_count
- : homogeneous_count * 2);
+ vfp_count = (*base_byte_size == 8 ? homogeneous_count
+ : homogeneous_count * 2);
}
} else if (base_type.IsFloatingPointType(float_count, is_complex)) {
if (float_count == 1 && !is_complex) {
is_vfp_candidate = true;
- vfp_byte_size = base_type.GetByteSize(nullptr);
+ if (base_byte_size)
+ vfp_byte_size = *base_byte_size;
vfp_count = homogeneous_count;
}
}
@@ -1752,12 +1746,14 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
compiler_type.GetFieldAtIndex(index, name, NULL, NULL, NULL);
if (base_type.IsFloatingPointType(float_count, is_complex)) {
+ llvm::Optional<uint64_t> base_byte_size =
+ base_type.GetByteSize(nullptr);
if (float_count == 2 && is_complex) {
- if (index != 0 &&
- vfp_byte_size != base_type.GetByteSize(nullptr))
+ if (index != 0 && base_byte_size &&
+ vfp_byte_size != *base_byte_size)
break;
- else
- vfp_byte_size = base_type.GetByteSize(nullptr);
+ else if (base_byte_size)
+ vfp_byte_size = *base_byte_size;
} else
break;
} else
@@ -1773,13 +1769,13 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
}
}
- if (byte_size <= 4) {
+ if (*byte_size <= 4) {
RegisterValue r0_reg_value;
uint32_t raw_value =
reg_ctx->ReadRegisterAsUnsigned(r0_reg_info, 0) & UINT32_MAX;
- value.SetBytes(&raw_value, byte_size);
+ value.SetBytes(&raw_value, *byte_size);
} else if (!is_vfp_candidate) {
- if (!GetReturnValuePassedInMemory(thread, reg_ctx, byte_size, value))
+ if (!GetReturnValuePassedInMemory(thread, reg_ctx, *byte_size, value))
return return_valobj_sp;
}
} else {
@@ -1791,7 +1787,7 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
ProcessSP process_sp(thread.GetProcess());
ByteOrder byte_order = process_sp->GetByteOrder();
- DataBufferSP data_sp(new DataBufferHeap(byte_size, 0));
+ DataBufferSP data_sp(new DataBufferHeap(*byte_size, 0));
uint32_t data_offset = 0;
for (uint32_t reg_index = 0; reg_index < vfp_count; reg_index++) {
@@ -1826,7 +1822,7 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
}
}
- if (data_offset == byte_size) {
+ if (data_offset == *byte_size) {
DataExtractor data;
data.SetByteOrder(byte_order);
data.SetAddressByteSize(process_sp->GetAddressByteSize());
diff --git a/source/Plugins/ABI/SysV-arm/ABISysV_arm.h b/source/Plugins/ABI/SysV-arm/ABISysV_arm.h
index f046968c213d..7f2d658541ab 100644
--- a/source/Plugins/ABI/SysV-arm/ABISysV_arm.h
+++ b/source/Plugins/ABI/SysV-arm/ABISysV_arm.h
@@ -10,10 +10,6 @@
#ifndef liblldb_ABISysV_arm_h_
#define liblldb_ABISysV_arm_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
diff --git a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
index 2c221689954c..dd3f47303be5 100644
--- a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
+++ b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
@@ -9,19 +9,13 @@
#include "ABISysV_arm64.h"
-// C Includes
-// C++ Includes
#include <vector>
-// Other libraries and framework includes
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
-// Project includes
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegisterValue.h"
-#include "lldb/Core/Scalar.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Symbol/UnwindPlan.h"
@@ -31,6 +25,8 @@
#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"
@@ -1671,15 +1667,12 @@ size_t ABISysV_arm64::GetRedZoneSize() const { return 128; }
ABISP
ABISysV_arm64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
- static ABISP g_abi_sp;
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) {
- if (!g_abi_sp)
- g_abi_sp.reset(new ABISysV_arm64(process_sp));
- return g_abi_sp;
+ return ABISP(new ABISysV_arm64(process_sp));
}
}
@@ -1774,10 +1767,13 @@ bool ABISysV_arm64::GetArgumentValues(Thread &thread, ValueList &values) const {
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 = value_type.GetBitSize(&thread);
+ bit_width = *bit_size;
} else if (value_type.IsPointerOrReferenceType()) {
- bit_width = value_type.GetBitSize(&thread);
+ bit_width = *bit_size;
} else {
// We only handle integer, pointer and reference types currently...
return false;
@@ -2090,13 +2086,13 @@ static bool LoadValueFromConsecutiveGPRRegisters(
uint32_t &NGRN, // NGRN (see ABI documentation)
uint32_t &NSRN, // NSRN (see ABI documentation)
DataExtractor &data) {
- const size_t byte_size = value_type.GetByteSize(nullptr);
+ llvm::Optional<uint64_t> byte_size = value_type.GetByteSize(nullptr);
- if (byte_size == 0)
+ if (byte_size || *byte_size == 0)
return false;
std::unique_ptr<DataBufferHeap> heap_data_ap(
- new DataBufferHeap(byte_size, 0));
+ new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder();
Status error;
@@ -2108,7 +2104,9 @@ static bool LoadValueFromConsecutiveGPRRegisters(
if (NSRN < 8 && (8 - NSRN) >= homogeneous_count) {
if (!base_type)
return false;
- const size_t base_byte_size = base_type.GetByteSize(nullptr);
+ 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) {
@@ -2119,7 +2117,7 @@ static bool LoadValueFromConsecutiveGPRRegisters(
if (reg_info == nullptr)
return false;
- if (base_byte_size > reg_info->byte_size)
+ if (*base_byte_size > reg_info->byte_size)
return false;
RegisterValue reg_value;
@@ -2128,11 +2126,11 @@ static bool LoadValueFromConsecutiveGPRRegisters(
return false;
// Make sure we have enough room in "heap_data_ap"
- if ((data_offset + base_byte_size) <= heap_data_ap->GetByteSize()) {
+ if ((data_offset + *base_byte_size) <= heap_data_ap->GetByteSize()) {
const size_t bytes_copied = reg_value.GetAsMemoryData(
- reg_info, heap_data_ap->GetBytes() + data_offset, base_byte_size,
+ reg_info, heap_data_ap->GetBytes() + data_offset, *base_byte_size,
byte_order, error);
- if (bytes_copied != base_byte_size)
+ if (bytes_copied != *base_byte_size)
return false;
data_offset += bytes_copied;
++NSRN;
@@ -2147,10 +2145,10 @@ static bool LoadValueFromConsecutiveGPRRegisters(
}
const size_t max_reg_byte_size = 16;
- if (byte_size <= max_reg_byte_size) {
- size_t bytes_left = byte_size;
+ if (*byte_size <= max_reg_byte_size) {
+ size_t bytes_left = *byte_size;
uint32_t data_offset = 0;
- while (data_offset < byte_size) {
+ while (data_offset < *byte_size) {
if (NGRN >= 8)
return false;
@@ -2235,7 +2233,10 @@ ValueObjectSP ABISysV_arm64::GetReturnValueObjectImpl(
if (!reg_ctx)
return return_valobj_sp;
- const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
+ 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) {
@@ -2244,7 +2245,7 @@ ValueObjectSP ABISysV_arm64::GetReturnValueObjectImpl(
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) {
+ if (*byte_size <= 8) {
const RegisterInfo *x0_reg_info = nullptr;
x0_reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric,
LLDB_REGNUM_GENERIC_ARG1);
@@ -2253,7 +2254,7 @@ ValueObjectSP ABISysV_arm64::GetReturnValueObjectImpl(
thread.GetRegisterContext()->ReadRegisterAsUnsigned(x0_reg_info,
0);
const bool is_signed = (type_flags & eTypeIsSigned) != 0;
- switch (byte_size) {
+ switch (*byte_size) {
default:
break;
case 16: // uint128_t
@@ -2264,10 +2265,10 @@ ValueObjectSP ABISysV_arm64::GetReturnValueObjectImpl(
LLDB_REGNUM_GENERIC_ARG2);
if (x1_reg_info) {
- if (byte_size <=
+ if (*byte_size <=
x0_reg_info->byte_size + x1_reg_info->byte_size) {
std::unique_ptr<DataBufferHeap> heap_data_ap(
- new DataBufferHeap(byte_size, 0));
+ new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order =
exe_ctx.GetProcessRef().GetByteOrder();
RegisterValue x0_reg_value;
@@ -2332,7 +2333,7 @@ ValueObjectSP ABISysV_arm64::GetReturnValueObjectImpl(
if (type_flags & eTypeIsComplex) {
// Don't handle complex yet.
} else {
- if (byte_size <= sizeof(long double)) {
+ if (*byte_size <= sizeof(long double)) {
const RegisterInfo *v0_reg_info =
reg_ctx->GetRegisterInfoByName("v0", 0);
RegisterValue v0_value;
@@ -2340,13 +2341,13 @@ ValueObjectSP ABISysV_arm64::GetReturnValueObjectImpl(
DataExtractor data;
if (v0_value.GetData(data)) {
lldb::offset_t offset = 0;
- if (byte_size == sizeof(float)) {
+ if (*byte_size == sizeof(float)) {
value.GetScalar() = data.GetFloat(&offset);
success = true;
- } else if (byte_size == sizeof(double)) {
+ } else if (*byte_size == sizeof(double)) {
value.GetScalar() = data.GetDouble(&offset);
success = true;
- } else if (byte_size == sizeof(long double)) {
+ } else if (*byte_size == sizeof(long double)) {
value.GetScalar() = data.GetLongDouble(&offset);
success = true;
}
@@ -2359,13 +2360,13 @@ ValueObjectSP ABISysV_arm64::GetReturnValueObjectImpl(
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) {
+ } 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_ap(
- new DataBufferHeap(byte_size, 0));
+ new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder();
RegisterValue reg_value;
if (reg_ctx->ReadRegister(v0_info, reg_value)) {
@@ -2382,7 +2383,7 @@ ValueObjectSP ABISysV_arm64::GetReturnValueObjectImpl(
}
}
} else if (type_flags & eTypeIsStructUnion || type_flags & eTypeIsClass ||
- (type_flags & eTypeIsVector && byte_size > 16)) {
+ (type_flags & eTypeIsVector && *byte_size > 16)) {
DataExtractor data;
uint32_t NGRN = 0; // Search ABI docs for NGRN
diff --git a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h
index 8d23c2419bab..b36b4547e626 100644
--- a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h
+++ b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h
@@ -10,10 +10,6 @@
#ifndef liblldb_ABISysV_arm64_h_
#define liblldb_ABISysV_arm64_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
diff --git a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
index a30416cf5a8e..ca40e9a04d7c 100644
--- a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
+++ b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
@@ -9,16 +9,11 @@
#include "ABISysV_hexagon.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
#include "llvm/ADT/Triple.h"
#include "llvm/IR/DerivedTypes.h"
-// Project includes
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectMemory.h"
@@ -32,6 +27,7 @@
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegisterValue.h"
#include "lldb/Utility/Status.h"
using namespace lldb;
@@ -1020,11 +1016,8 @@ size_t ABISysV_hexagon::GetRedZoneSize() const { return 0; }
ABISP
ABISysV_hexagon::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
- static ABISP g_abi_sp;
if (arch.GetTriple().getArch() == llvm::Triple::hexagon) {
- if (!g_abi_sp)
- g_abi_sp.reset(new ABISysV_hexagon(process_sp));
- return g_abi_sp;
+ return ABISP(new ABISysV_hexagon(process_sp));
}
return ABISP();
}
diff --git a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h
index 5a6809371d9f..6e39c0792e2a 100644
--- a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h
+++ b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h
@@ -11,10 +11,6 @@
#ifndef liblldb_ABISysV_hexagon_h_
#define liblldb_ABISysV_hexagon_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
diff --git a/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp b/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
index e7ddfccea338..3358eb8c2774 100644
--- a/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
+++ b/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
@@ -8,16 +8,11 @@
#include "ABISysV_i386.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
-// Project includes
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectMemory.h"
@@ -31,6 +26,7 @@
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegisterValue.h"
#include "lldb/Utility/Status.h"
using namespace lldb;
@@ -203,12 +199,9 @@ ABISysV_i386::GetRegisterInfoArray(uint32_t &count) {
ABISP
ABISysV_i386::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
- static ABISP g_abi_sp;
if (arch.GetTriple().getVendor() != llvm::Triple::Apple) {
if (arch.GetTriple().getArch() == llvm::Triple::x86) {
- if (!g_abi_sp)
- g_abi_sp.reset(new ABISysV_i386(process_sp));
- return g_abi_sp;
+ return ABISP(new ABISysV_i386(process_sp));
}
}
return ABISP();
@@ -315,15 +308,14 @@ bool ABISysV_i386::GetArgumentValues(Thread &thread, ValueList &values) const {
// Currently: Support for extracting values with Clang QualTypes only.
CompilerType compiler_type(value->GetCompilerType());
- if (compiler_type) {
+ llvm::Optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
+ if (bit_size) {
bool is_signed;
if (compiler_type.IsIntegerOrEnumerationType(is_signed)) {
- ReadIntegerArgument(value->GetScalar(),
- compiler_type.GetBitSize(&thread), is_signed,
+ ReadIntegerArgument(value->GetScalar(), *bit_size, is_signed,
thread.GetProcess().get(), current_stack_argument);
} else if (compiler_type.IsPointerType()) {
- ReadIntegerArgument(value->GetScalar(),
- compiler_type.GetBitSize(&thread), false,
+ ReadIntegerArgument(value->GetScalar(), *bit_size, false,
thread.GetProcess().get(), current_stack_argument);
}
}
@@ -521,7 +513,10 @@ ValueObjectSP ABISysV_i386::GetReturnValueObjectSimple(
(type_flags & eTypeIsEnumeration)) //'Integral' + 'Floating Point'
{
value.SetValueType(Value::eValueTypeScalar);
- const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
+ llvm::Optional<uint64_t> byte_size =
+ return_compiler_type.GetByteSize(nullptr);
+ if (!byte_size)
+ return return_valobj_sp;
bool success = false;
if (type_flags & eTypeIsInteger) // 'Integral' except enum
@@ -535,7 +530,7 @@ ValueObjectSP ABISysV_i386::GetReturnValueObjectSimple(
0xffffffff)
<< 32;
- switch (byte_size) {
+ switch (*byte_size) {
default:
break;
@@ -591,7 +586,7 @@ ValueObjectSP ABISysV_i386::GetReturnValueObjectSimple(
thread.GetStackFrameAtIndex(0).get(), value, ConstString(""));
} else if (type_flags & eTypeIsFloat) // 'Floating Point'
{
- if (byte_size <= 12) // handles float, double, long double, __float80
+ if (*byte_size <= 12) // handles float, double, long double, __float80
{
const RegisterInfo *st0_info = reg_ctx->GetRegisterInfoByName("st0", 0);
RegisterValue st0_value;
@@ -602,21 +597,20 @@ ValueObjectSP ABISysV_i386::GetReturnValueObjectSimple(
lldb::offset_t offset = 0;
long double value_long_double = data.GetLongDouble(&offset);
- if (byte_size == 4) // float is 4 bytes
- {
+ // float is 4 bytes.
+ if (*byte_size == 4) {
float value_float = (float)value_long_double;
value.GetScalar() = value_float;
success = true;
- } else if (byte_size == 8) // double is 8 bytes
- {
+ } else if (*byte_size == 8) {
+ // double is 8 bytes
// On Android Platform: long double is also 8 bytes It will be
// handled here only.
double value_double = (double)value_long_double;
value.GetScalar() = value_double;
success = true;
- } else if (byte_size ==
- 12) // long double and __float80 are 12 bytes on i386
- {
+ } else if (*byte_size == 12) {
+ // long double and __float80 are 12 bytes on i386.
value.GetScalar() = value_long_double;
success = true;
}
@@ -626,7 +620,7 @@ ValueObjectSP ABISysV_i386::GetReturnValueObjectSimple(
if (success)
return_valobj_sp = ValueObjectConstResult::Create(
thread.GetStackFrameAtIndex(0).get(), value, ConstString(""));
- } else if (byte_size == 16) // handles __float128
+ } else if (*byte_size == 16) // handles __float128
{
lldb::addr_t storage_addr = (uint32_t)(
thread.GetRegisterContext()->ReadRegisterAsUnsigned(eax_id, 0) &
@@ -644,18 +638,19 @@ ValueObjectSP ABISysV_i386::GetReturnValueObjectSimple(
// ToDo: Yet to be implemented
} else if (type_flags & eTypeIsVector) // 'Packed'
{
- const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
- if (byte_size > 0) {
+ llvm::Optional<uint64_t> byte_size =
+ return_compiler_type.GetByteSize(nullptr);
+ if (byte_size && *byte_size > 0) {
const RegisterInfo *vec_reg = reg_ctx->GetRegisterInfoByName("xmm0", 0);
if (vec_reg == nullptr)
vec_reg = reg_ctx->GetRegisterInfoByName("mm0", 0);
if (vec_reg) {
- if (byte_size <= vec_reg->byte_size) {
+ if (*byte_size <= vec_reg->byte_size) {
ProcessSP process_sp(thread.GetProcess());
if (process_sp) {
std::unique_ptr<DataBufferHeap> heap_data_ap(
- new DataBufferHeap(byte_size, 0));
+ new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order = process_sp->GetByteOrder();
RegisterValue reg_value;
if (reg_ctx->ReadRegister(vec_reg, reg_value)) {
@@ -672,14 +667,14 @@ ValueObjectSP ABISysV_i386::GetReturnValueObjectSimple(
}
}
}
- } else if (byte_size <= vec_reg->byte_size * 2) {
+ } else if (*byte_size <= vec_reg->byte_size * 2) {
const RegisterInfo *vec_reg2 =
reg_ctx->GetRegisterInfoByName("xmm1", 0);
if (vec_reg2) {
ProcessSP process_sp(thread.GetProcess());
if (process_sp) {
std::unique_ptr<DataBufferHeap> heap_data_ap(
- new DataBufferHeap(byte_size, 0));
+ new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order = process_sp->GetByteOrder();
RegisterValue reg_value;
RegisterValue reg_value2;
diff --git a/source/Plugins/ABI/SysV-i386/ABISysV_i386.h b/source/Plugins/ABI/SysV-i386/ABISysV_i386.h
index 4dce54c4f073..336a2754c6ca 100644
--- a/source/Plugins/ABI/SysV-i386/ABISysV_i386.h
+++ b/source/Plugins/ABI/SysV-i386/ABISysV_i386.h
@@ -10,10 +10,6 @@
#ifndef liblldb_ABISysV_i386_h_
#define liblldb_ABISysV_i386_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
diff --git a/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp b/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
index ce02f8677a63..6f3d2e3b3696 100644
--- a/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
+++ b/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
@@ -9,16 +9,11 @@
#include "ABISysV_mips.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
-// Project includes
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectMemory.h"
@@ -32,6 +27,7 @@
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegisterValue.h"
#include "lldb/Utility/Status.h"
using namespace lldb;
@@ -560,13 +556,10 @@ size_t ABISysV_mips::GetRedZoneSize() const { return 0; }
ABISP
ABISysV_mips::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
- static ABISP g_abi_sp;
const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch();
if ((arch_type == llvm::Triple::mips) ||
(arch_type == llvm::Triple::mipsel)) {
- if (!g_abi_sp)
- g_abi_sp.reset(new ABISysV_mips(process_sp));
- return g_abi_sp;
+ return ABISP(new ABISysV_mips(process_sp));
}
return ABISP();
}
@@ -819,9 +812,11 @@ ValueObjectSP ABISysV_mips::GetReturnValueObjectImpl(
// In MIPS register "r2" (v0) holds the integer function return values
const RegisterInfo *r2_reg_info = reg_ctx->GetRegisterInfoByName("r2", 0);
- size_t bit_width = return_compiler_type.GetBitSize(&thread);
+ llvm::Optional<uint64_t> bit_width = return_compiler_type.GetBitSize(&thread);
+ if (!bit_width)
+ return return_valobj_sp;
if (return_compiler_type.IsIntegerOrEnumerationType(is_signed)) {
- switch (bit_width) {
+ switch (*bit_width) {
default:
return return_valobj_sp;
case 64: {
@@ -880,7 +875,7 @@ ValueObjectSP ABISysV_mips::GetReturnValueObjectImpl(
uint64_t raw_value = reg_ctx->ReadRegisterAsUnsigned(r2_reg_info, 0);
if (count != 1 && is_complex)
return return_valobj_sp;
- switch (bit_width) {
+ switch (*bit_width) {
default:
return return_valobj_sp;
case 32:
@@ -912,7 +907,7 @@ ValueObjectSP ABISysV_mips::GetReturnValueObjectImpl(
lldb::offset_t offset = 0;
if (count == 1 && !is_complex) {
- switch (bit_width) {
+ switch (*bit_width) {
default:
return return_valobj_sp;
case 64: {
diff --git a/source/Plugins/ABI/SysV-mips/ABISysV_mips.h b/source/Plugins/ABI/SysV-mips/ABISysV_mips.h
index 0de8e7751fce..d23dbe9d97bd 100644
--- a/source/Plugins/ABI/SysV-mips/ABISysV_mips.h
+++ b/source/Plugins/ABI/SysV-mips/ABISysV_mips.h
@@ -10,10 +10,6 @@
#ifndef liblldb_ABISysV_mips_h_
#define liblldb_ABISysV_mips_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
diff --git a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
index b958abf25637..1d6738d9fda9 100644
--- a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
+++ b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
@@ -9,16 +9,11 @@
#include "ABISysV_mips64.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
-// Project includes
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectMemory.h"
@@ -32,6 +27,7 @@
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegisterValue.h"
#include "lldb/Utility/Status.h"
using namespace lldb;
@@ -560,13 +556,10 @@ size_t ABISysV_mips64::GetRedZoneSize() const { return 0; }
ABISP
ABISysV_mips64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
- static ABISP g_abi_sp;
const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch();
if ((arch_type == llvm::Triple::mips64) ||
(arch_type == llvm::Triple::mips64el)) {
- if (!g_abi_sp)
- g_abi_sp.reset(new ABISysV_mips64(process_sp));
- return g_abi_sp;
+ return ABISP(new ABISysV_mips64(process_sp));
}
return ABISP();
}
@@ -769,7 +762,10 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
Target *target = exe_ctx.GetTargetPtr();
const ArchSpec target_arch = target->GetArchitecture();
ByteOrder target_byte_order = target_arch.GetByteOrder();
- const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
+ 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);
uint32_t fp_flag =
target_arch.GetFlags() & lldb_private::ArchSpec::eMIPS_ABI_FP_mask;
@@ -788,7 +784,7 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
uint64_t raw_value = reg_ctx->ReadRegisterAsUnsigned(r2_info, 0);
const bool is_signed = (type_flags & eTypeIsSigned) != 0;
- switch (byte_size) {
+ switch (*byte_size) {
default:
break;
@@ -829,7 +825,7 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
// Don't handle complex yet.
} else if (IsSoftFloat(fp_flag)) {
uint64_t raw_value = reg_ctx->ReadRegisterAsUnsigned(r2_info, 0);
- switch (byte_size) {
+ switch (*byte_size) {
case 4:
value.GetScalar() = *((float *)(&raw_value));
success = true;
@@ -854,7 +850,7 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
}
} else {
- if (byte_size <= sizeof(long double)) {
+ if (*byte_size <= sizeof(long double)) {
const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0);
RegisterValue f0_value;
@@ -865,13 +861,13 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
f0_value.GetData(f0_data);
lldb::offset_t offset = 0;
- if (byte_size == sizeof(float)) {
+ if (*byte_size == sizeof(float)) {
value.GetScalar() = (float)f0_data.GetFloat(&offset);
success = true;
- } else if (byte_size == sizeof(double)) {
+ } else if (*byte_size == sizeof(double)) {
value.GetScalar() = (double)f0_data.GetDouble(&offset);
success = true;
- } else if (byte_size == sizeof(long double)) {
+ } else if (*byte_size == sizeof(long double)) {
const RegisterInfo *f2_info =
reg_ctx->GetRegisterInfoByName("f2", 0);
RegisterValue f2_value;
@@ -886,21 +882,21 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
if (target_byte_order == eByteOrderLittle) {
copy_from_extractor = &f0_data;
copy_from_extractor->CopyByteOrderedData(
- 0, 8, data_sp->GetBytes(), byte_size - 8, target_byte_order);
+ 0, 8, data_sp->GetBytes(), *byte_size - 8, target_byte_order);
f2_value.GetData(f2_data);
copy_from_extractor = &f2_data;
copy_from_extractor->CopyByteOrderedData(
- 0, 8, data_sp->GetBytes() + 8, byte_size - 8,
+ 0, 8, data_sp->GetBytes() + 8, *byte_size - 8,
target_byte_order);
} else {
copy_from_extractor = &f0_data;
copy_from_extractor->CopyByteOrderedData(
- 0, 8, data_sp->GetBytes() + 8, byte_size - 8,
+ 0, 8, data_sp->GetBytes() + 8, *byte_size - 8,
target_byte_order);
f2_value.GetData(f2_data);
copy_from_extractor = &f2_data;
copy_from_extractor->CopyByteOrderedData(
- 0, 8, data_sp->GetBytes(), byte_size - 8, target_byte_order);
+ 0, 8, data_sp->GetBytes(), *byte_size - 8, target_byte_order);
}
return_valobj_sp = ValueObjectConstResult::Create(
@@ -917,7 +913,7 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
} else if (type_flags & eTypeIsStructUnion || type_flags & eTypeIsClass ||
type_flags & eTypeIsVector) {
// Any structure of up to 16 bytes in size is returned in the registers.
- if (byte_size <= 16) {
+ if (*byte_size <= 16) {
DataBufferSP data_sp(new DataBufferHeap(16, 0));
DataExtractor return_ext(data_sp, target_byte_order,
target->GetArchitecture().GetAddressByteSize());
@@ -975,8 +971,10 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
CompilerType field_compiler_type =
return_compiler_type.GetFieldAtIndex(
idx, name, &field_bit_offset, nullptr, nullptr);
- const size_t field_byte_width =
+ llvm::Optional<uint64_t> field_byte_width =
field_compiler_type.GetByteSize(nullptr);
+ if (!field_byte_width)
+ return return_valobj_sp;
DataExtractor *copy_from_extractor = nullptr;
uint64_t return_value[2];
@@ -984,7 +982,7 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
if (idx == 0) {
// This case is for long double type.
- if (field_byte_width == 16) {
+ if (*field_byte_width == 16) {
// If structure contains long double type, then it is returned
// in fp0/fp1 registers.
@@ -1002,7 +1000,7 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
return_value[0] = f1_data.GetU64(&offset);
}
- f0_data.SetData(return_value, field_byte_width,
+ f0_data.SetData(return_value, *field_byte_width,
target_byte_order);
}
copy_from_extractor = &f0_data; // This is in f0, copy from
@@ -1016,13 +1014,13 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
// Sanity check to avoid crash
if (!copy_from_extractor ||
- field_byte_width > copy_from_extractor->GetByteSize())
+ *field_byte_width > copy_from_extractor->GetByteSize())
return return_valobj_sp;
// copy the register contents into our data buffer
copy_from_extractor->CopyByteOrderedData(
- 0, field_byte_width,
- data_sp->GetBytes() + (field_bit_offset / 8), field_byte_width,
+ 0, *field_byte_width,
+ data_sp->GetBytes() + (field_bit_offset / 8), *field_byte_width,
target_byte_order);
}
@@ -1045,12 +1043,12 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
idx, name, &field_bit_offset, nullptr, nullptr);
- const size_t field_byte_width =
+ llvm::Optional<uint64_t> field_byte_width =
field_compiler_type.GetByteSize(nullptr);
// if we don't know the size of the field (e.g. invalid type), just
// bail out
- if (field_byte_width == 0)
+ if (!field_byte_width || *field_byte_width == 0)
break;
uint32_t field_byte_offset = field_bit_offset / 8;
@@ -1062,24 +1060,24 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
if (integer_bytes < 8) {
// We have not yet consumed r2 completely.
- if (integer_bytes + field_byte_width + padding <= 8) {
+ if (integer_bytes + *field_byte_width + padding <= 8) {
// This field fits in r2, copy its value from r2 to our result
// structure
- integer_bytes = integer_bytes + field_byte_width +
+ integer_bytes = integer_bytes + *field_byte_width +
padding; // Increase the consumed bytes.
use_r2 = 1;
} else {
// There isn't enough space left in r2 for this field, so this
// will be in r3.
- integer_bytes = integer_bytes + field_byte_width +
+ integer_bytes = integer_bytes + *field_byte_width +
padding; // Increase the consumed bytes.
use_r3 = 1;
}
}
// We already have consumed at-least 8 bytes that means r2 is done,
// and this field will be in r3. Check if this field can fit in r3.
- else if (integer_bytes + field_byte_width + padding <= 16) {
- integer_bytes = integer_bytes + field_byte_width + padding;
+ else if (integer_bytes + *field_byte_width + padding <= 16) {
+ integer_bytes = integer_bytes + *field_byte_width + padding;
use_r3 = 1;
} else {
// There isn't any space left for this field, this should not
@@ -1092,7 +1090,7 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
}
// Vector types up to 16 bytes are returned in GP return registers
if (type_flags & eTypeIsVector) {
- if (byte_size <= 8)
+ if (*byte_size <= 8)
use_r2 = 1;
else {
use_r2 = 1;
diff --git a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h
index 6258c08e35f9..c7670f467114 100644
--- a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h
+++ b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h
@@ -10,10 +10,6 @@
#ifndef liblldb_ABISysV_mips64_h_
#define liblldb_ABISysV_mips64_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
diff --git a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
index e93dcdbe1a59..1fe7a6718a91 100644
--- a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
+++ b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
@@ -9,16 +9,11 @@
#include "ABISysV_ppc.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
-// Project includes
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectMemory.h"
@@ -32,6 +27,7 @@
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegisterValue.h"
#include "lldb/Utility/Status.h"
using namespace lldb;
@@ -224,11 +220,8 @@ size_t ABISysV_ppc::GetRedZoneSize() const { return 224; }
ABISP
ABISysV_ppc::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
- static ABISP g_abi_sp;
if (arch.GetTriple().getArch() == llvm::Triple::ppc) {
- if (!g_abi_sp)
- g_abi_sp.reset(new ABISysV_ppc(process_sp));
- return g_abi_sp;
+ return ABISP(new ABISysV_ppc(process_sp));
}
return ABISP();
}
@@ -405,19 +398,18 @@ bool ABISysV_ppc::GetArgumentValues(Thread &thread, ValueList &values) const {
// We currently only support extracting values with Clang QualTypes. Do we
// care about others?
CompilerType compiler_type = value->GetCompilerType();
- if (!compiler_type)
+ llvm::Optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
+ if (!bit_size)
return false;
bool is_signed;
-
- if (compiler_type.IsIntegerOrEnumerationType(is_signed)) {
- ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread),
- is_signed, thread, argument_register_ids,
- current_argument_register, current_stack_argument);
- } else if (compiler_type.IsPointerType()) {
- ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread),
- false, thread, argument_register_ids,
- current_argument_register, current_stack_argument);
- }
+ if (compiler_type.IsIntegerOrEnumerationType(is_signed))
+ ReadIntegerArgument(value->GetScalar(), *bit_size, is_signed, thread,
+ argument_register_ids, current_argument_register,
+ current_stack_argument);
+ else if (compiler_type.IsPointerType())
+ ReadIntegerArgument(value->GetScalar(), *bit_size, false, thread,
+ argument_register_ids, current_argument_register,
+ current_stack_argument);
}
return true;
@@ -474,8 +466,13 @@ Status ABISysV_ppc::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
error.SetErrorString(
"We don't support returning complex values at present");
else {
- size_t bit_width = compiler_type.GetBitSize(frame_sp.get());
- if (bit_width <= 64) {
+ llvm::Optional<uint64_t> bit_width =
+ compiler_type.GetBitSize(frame_sp.get());
+ if (!bit_width) {
+ error.SetErrorString("can't get type size");
+ return error;
+ }
+ if (*bit_width <= 64) {
DataExtractor data;
Status data_error;
size_t num_bytes = new_value_sp->GetData(data, data_error);
@@ -533,11 +530,14 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectSimple(
if (type_flags & eTypeIsInteger) {
// Extract the register context so we can read arguments from registers
- const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
+ llvm::Optional<uint64_t> byte_size =
+ return_compiler_type.GetByteSize(nullptr);
+ if (!byte_size)
+ return return_valobj_sp;
uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(
reg_ctx->GetRegisterInfoByName("r3", 0), 0);
const bool is_signed = (type_flags & eTypeIsSigned) != 0;
- switch (byte_size) {
+ switch (*byte_size) {
default:
break;
@@ -577,18 +577,19 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectSimple(
if (type_flags & eTypeIsComplex) {
// Don't handle complex yet.
} else {
- const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
- if (byte_size <= sizeof(long double)) {
+ llvm::Optional<uint64_t> byte_size =
+ return_compiler_type.GetByteSize(nullptr);
+ if (byte_size && *byte_size <= sizeof(long double)) {
const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0);
RegisterValue f1_value;
if (reg_ctx->ReadRegister(f1_info, f1_value)) {
DataExtractor data;
if (f1_value.GetData(data)) {
lldb::offset_t offset = 0;
- if (byte_size == sizeof(float)) {
+ if (*byte_size == sizeof(float)) {
value.GetScalar() = (float)data.GetFloat(&offset);
success = true;
- } else if (byte_size == sizeof(double)) {
+ } else if (*byte_size == sizeof(double)) {
value.GetScalar() = (double)data.GetDouble(&offset);
success = true;
}
@@ -610,15 +611,16 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectSimple(
return_valobj_sp = ValueObjectConstResult::Create(
thread.GetStackFrameAtIndex(0).get(), value, ConstString(""));
} else if (type_flags & eTypeIsVector) {
- const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
- if (byte_size > 0) {
+ llvm::Optional<uint64_t> byte_size =
+ return_compiler_type.GetByteSize(nullptr);
+ if (byte_size && *byte_size > 0) {
const RegisterInfo *altivec_reg = reg_ctx->GetRegisterInfoByName("v2", 0);
if (altivec_reg) {
- if (byte_size <= altivec_reg->byte_size) {
+ if (*byte_size <= altivec_reg->byte_size) {
ProcessSP process_sp(thread.GetProcess());
if (process_sp) {
std::unique_ptr<DataBufferHeap> heap_data_ap(
- new DataBufferHeap(byte_size, 0));
+ new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order = process_sp->GetByteOrder();
RegisterValue reg_value;
if (reg_ctx->ReadRegister(altivec_reg, reg_value)) {
@@ -627,9 +629,10 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectSimple(
altivec_reg, heap_data_ap->GetBytes(),
heap_data_ap->GetByteSize(), byte_order, error)) {
DataExtractor data(DataBufferSP(heap_data_ap.release()),
- byte_order, process_sp->GetTarget()
- .GetArchitecture()
- .GetAddressByteSize());
+ byte_order,
+ process_sp->GetTarget()
+ .GetArchitecture()
+ .GetAddressByteSize());
return_valobj_sp = ValueObjectConstResult::Create(
&thread, return_compiler_type, ConstString(""), data);
}
@@ -659,11 +662,13 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectImpl(
if (!reg_ctx_sp)
return return_valobj_sp;
- const size_t bit_width = return_compiler_type.GetBitSize(&thread);
+ llvm::Optional<uint64_t> bit_width = return_compiler_type.GetBitSize(&thread);
+ if (!bit_width)
+ return return_valobj_sp;
if (return_compiler_type.IsAggregateType()) {
Target *target = exe_ctx.GetTargetPtr();
bool is_memory = true;
- if (bit_width <= 128) {
+ if (*bit_width <= 128) {
ByteOrder target_byte_order = target->GetArchitecture().GetByteOrder();
DataBufferSP data_sp(new DataBufferHeap(16, 0));
DataExtractor return_ext(data_sp, target_byte_order,
@@ -701,15 +706,18 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectImpl(
CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
idx, name, &field_bit_offset, nullptr, nullptr);
- const size_t field_bit_width = field_compiler_type.GetBitSize(&thread);
+ llvm::Optional<uint64_t> field_bit_width =
+ field_compiler_type.GetBitSize(&thread);
+ if (!field_bit_width)
+ return return_valobj_sp;
// If there are any unaligned fields, this is stored in memory.
- if (field_bit_offset % field_bit_width != 0) {
+ if (field_bit_offset % *field_bit_width != 0) {
is_memory = true;
break;
}
- uint32_t field_byte_width = field_bit_width / 8;
+ uint32_t field_byte_width = *field_bit_width / 8;
uint32_t field_byte_offset = field_bit_offset / 8;
DataExtractor *copy_from_extractor = nullptr;
@@ -742,13 +750,13 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectImpl(
}
} else if (field_compiler_type.IsFloatingPointType(count, is_complex)) {
// Structs with long doubles are always passed in memory.
- if (field_bit_width == 128) {
+ if (*field_bit_width == 128) {
is_memory = true;
break;
- } else if (field_bit_width == 64) {
+ } else if (*field_bit_width == 64) {
copy_from_offset = 0;
fp_bytes += field_byte_width;
- } else if (field_bit_width == 32) {
+ } else if (*field_bit_width == 32) {
// This one is kind of complicated. If we are in an "eightbyte"
// with another float, we'll be stuffed into an xmm register with
// it. If we are in an "eightbyte" with one or more ints, then we
diff --git a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h
index df3ebe83faf8..3559cbb45200 100644
--- a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h
+++ b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h
@@ -10,10 +10,6 @@
#ifndef liblldb_ABISysV_ppc_h_
#define liblldb_ABISysV_ppc_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
diff --git a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
index d0140a0c894a..fb46b7dc7fb6 100644
--- a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
+++ b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
@@ -9,18 +9,13 @@
#include "ABISysV_ppc64.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
-// Project includes
#include "Utility/PPC64LE_DWARF_Registers.h"
#include "Utility/PPC64_DWARF_Registers.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectMemory.h"
@@ -35,6 +30,7 @@
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegisterValue.h"
#include "lldb/Utility/Status.h"
#include "clang/AST/ASTContext.h"
@@ -284,18 +280,19 @@ bool ABISysV_ppc64::GetArgumentValues(Thread &thread, ValueList &values) const {
// We currently only support extracting values with Clang QualTypes. Do we
// care about others?
CompilerType compiler_type = value->GetCompilerType();
- if (!compiler_type)
+ llvm::Optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
+ if (!bit_size)
return false;
bool is_signed;
if (compiler_type.IsIntegerOrEnumerationType(is_signed)) {
- ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread),
- is_signed, thread, argument_register_ids,
- current_argument_register, current_stack_argument);
+ ReadIntegerArgument(value->GetScalar(), *bit_size, is_signed, thread,
+ argument_register_ids, current_argument_register,
+ current_stack_argument);
} else if (compiler_type.IsPointerType()) {
- ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread),
- false, thread, argument_register_ids,
- current_argument_register, current_stack_argument);
+ ReadIntegerArgument(value->GetScalar(), *bit_size, false, thread,
+ argument_register_ids, current_argument_register,
+ current_stack_argument);
}
}
@@ -353,8 +350,13 @@ Status ABISysV_ppc64::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
error.SetErrorString(
"We don't support returning complex values at present");
else {
- size_t bit_width = compiler_type.GetBitSize(frame_sp.get());
- if (bit_width <= 64) {
+ llvm::Optional<uint64_t> bit_width =
+ compiler_type.GetBitSize(frame_sp.get());
+ if (!bit_width) {
+ error.SetErrorString("can't get size of type");
+ return error;
+ }
+ if (*bit_width <= 64) {
DataExtractor data;
Status data_error;
size_t num_bytes = new_value_sp->GetData(data, data_error);
@@ -575,7 +577,7 @@ private:
ReturnValueExtractor(Thread &thread, CompilerType &type,
RegisterContext *reg_ctx, ProcessSP process_sp)
: m_thread(thread), m_type(type),
- m_byte_size(m_type.GetByteSize(nullptr)),
+ m_byte_size(m_type.GetByteSize(nullptr).getValueOr(0)),
m_data_ap(new DataBufferHeap(m_byte_size, 0)), m_reg_ctx(reg_ctx),
m_process_sp(process_sp), m_byte_order(process_sp->GetByteOrder()),
m_addr_size(
@@ -643,7 +645,7 @@ private:
uint64_t raw_data;
auto reg = GetFPR(reg_index);
if (!reg.GetRawData(raw_data))
- return ValueSP();
+ return {};
// build value from data
ValueSP value_sp(NewScalarValue(type));
@@ -651,8 +653,10 @@ private:
DataExtractor de(&raw_data, sizeof(raw_data), m_byte_order, m_addr_size);
offset_t offset = 0;
- size_t byte_size = type.GetByteSize(nullptr);
- switch (byte_size) {
+ llvm::Optional<uint64_t> byte_size = type.GetByteSize(nullptr);
+ if (!byte_size)
+ return {};
+ switch (*byte_size) {
case sizeof(float):
value_sp->GetScalar() = (float)de.GetDouble(&offset);
break;
@@ -759,7 +763,7 @@ private:
uint64_t addr;
auto reg = GetGPR(0);
if (!reg.GetRawData(addr))
- return ValueObjectSP();
+ return {};
Status error;
size_t rc = m_process_sp->ReadMemory(addr, m_data_ap->GetBytes(),
@@ -773,37 +777,39 @@ private:
// get number of children
const bool omit_empty_base_classes = true;
- uint32_t n = m_type.GetNumChildren(omit_empty_base_classes);
+ uint32_t n = m_type.GetNumChildren(omit_empty_base_classes, nullptr);
if (!n) {
LLDB_LOG(m_log, LOG_PREFIX "No children found in struct");
- return ValueObjectSP();
+ return {};
}
// case 2: homogeneous double or float aggregate
CompilerType elem_type;
if (m_type.IsHomogeneousAggregate(&elem_type)) {
uint32_t type_flags = elem_type.GetTypeInfo();
- uint64_t elem_size = elem_type.GetByteSize(nullptr);
+ llvm::Optional<uint64_t> elem_size = elem_type.GetByteSize(nullptr);
+ if (!elem_size)
+ return {};
if (type_flags & eTypeIsComplex || !(type_flags & eTypeIsFloat)) {
LLDB_LOG(m_log,
LOG_PREFIX "Unexpected type found in homogeneous aggregate");
- return ValueObjectSP();
+ return {};
}
for (uint32_t i = 0; i < n; i++) {
ValueSP val_sp = GetFloatValue(elem_type, i);
if (!val_sp)
- return ValueObjectSP();
+ return {};
// copy to buffer
Status error;
size_t rc = val_sp->GetScalar().GetAsMemoryData(
- m_data_ap->GetBytes() + m_dst_offs, elem_size, m_byte_order, error);
- if (rc != elem_size) {
+ m_data_ap->GetBytes() + m_dst_offs, *elem_size, m_byte_order, error);
+ if (rc != *elem_size) {
LLDB_LOG(m_log, LOG_PREFIX "Failed to get float data");
- return ValueObjectSP();
+ return {};
}
- m_dst_offs += elem_size;
+ m_dst_offs += *elem_size;
}
return BuildValueObject();
}
diff --git a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h
index 52765a773c0b..54f461e1001b 100644
--- a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h
+++ b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h
@@ -10,10 +10,6 @@
#ifndef liblldb_ABISysV_ppc64_h_
#define liblldb_ABISysV_ppc64_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
diff --git a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
index 31e2825c0fa2..d8056ea7d356 100644
--- a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
+++ b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
@@ -9,16 +9,11 @@
#include "ABISysV_s390x.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
-// Project includes
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectMemory.h"
@@ -32,6 +27,7 @@
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegisterValue.h"
#include "lldb/Utility/Status.h"
using namespace lldb;
@@ -206,11 +202,8 @@ size_t ABISysV_s390x::GetRedZoneSize() const { return 0; }
ABISP
ABISysV_s390x::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
- static ABISP g_abi_sp;
if (arch.GetTriple().getArch() == llvm::Triple::systemz) {
- if (!g_abi_sp)
- g_abi_sp.reset(new ABISysV_s390x(process_sp));
- return g_abi_sp;
+ return ABISP(new ABISysV_s390x(process_sp));
}
return ABISP();
}
@@ -383,18 +376,19 @@ bool ABISysV_s390x::GetArgumentValues(Thread &thread, ValueList &values) const {
// We currently only support extracting values with Clang QualTypes. Do we
// care about others?
CompilerType compiler_type = value->GetCompilerType();
- if (!compiler_type)
+ llvm::Optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
+ if (!bit_size)
return false;
bool is_signed;
if (compiler_type.IsIntegerOrEnumerationType(is_signed)) {
- ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread),
- is_signed, thread, argument_register_ids,
- current_argument_register, current_stack_argument);
+ ReadIntegerArgument(value->GetScalar(), *bit_size, is_signed, thread,
+ argument_register_ids, current_argument_register,
+ current_stack_argument);
} else if (compiler_type.IsPointerType()) {
- ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread),
- false, thread, argument_register_ids,
- current_argument_register, current_stack_argument);
+ ReadIntegerArgument(value->GetScalar(), *bit_size, false, thread,
+ argument_register_ids, current_argument_register,
+ current_stack_argument);
}
}
@@ -452,8 +446,13 @@ Status ABISysV_s390x::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
error.SetErrorString(
"We don't support returning complex values at present");
else {
- size_t bit_width = compiler_type.GetBitSize(frame_sp.get());
- if (bit_width <= 64) {
+ llvm::Optional<uint64_t> bit_width =
+ compiler_type.GetBitSize(frame_sp.get());
+ if (!bit_width) {
+ error.SetErrorString("can't get type size");
+ return error;
+ }
+ if (*bit_width <= 64) {
const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0);
RegisterValue f0_value;
DataExtractor data;
@@ -513,13 +512,15 @@ ValueObjectSP ABISysV_s390x::GetReturnValueObjectSimple(
bool success = false;
if (type_flags & eTypeIsInteger) {
- // Extract the register context so we can read arguments from registers
-
- const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
+ // Extract the register context so we can read arguments from registers.
+ llvm::Optional<uint64_t> byte_size =
+ return_compiler_type.GetByteSize(nullptr);
+ if (!byte_size)
+ return return_valobj_sp;
uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(
reg_ctx->GetRegisterInfoByName("r2", 0), 0);
const bool is_signed = (type_flags & eTypeIsSigned) != 0;
- switch (byte_size) {
+ switch (*byte_size) {
default:
break;
@@ -559,21 +560,22 @@ ValueObjectSP ABISysV_s390x::GetReturnValueObjectSimple(
if (type_flags & eTypeIsComplex) {
// Don't handle complex yet.
} else {
- const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
- if (byte_size <= sizeof(long double)) {
+ llvm::Optional<uint64_t> byte_size =
+ return_compiler_type.GetByteSize(nullptr);
+ if (byte_size && *byte_size <= sizeof(long double)) {
const RegisterInfo *f0_info = reg_ctx->GetRegisterInfoByName("f0", 0);
RegisterValue f0_value;
if (reg_ctx->ReadRegister(f0_info, f0_value)) {
DataExtractor data;
if (f0_value.GetData(data)) {
lldb::offset_t offset = 0;
- if (byte_size == sizeof(float)) {
+ if (*byte_size == sizeof(float)) {
value.GetScalar() = (float)data.GetFloat(&offset);
success = true;
- } else if (byte_size == sizeof(double)) {
+ } else if (*byte_size == sizeof(double)) {
value.GetScalar() = (double)data.GetDouble(&offset);
success = true;
- } else if (byte_size == sizeof(long double)) {
+ } else if (*byte_size == sizeof(long double)) {
// Don't handle long double yet.
}
}
diff --git a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h
index 5e3d20d7898b..5433ebb4593e 100644
--- a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h
+++ b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h
@@ -10,10 +10,6 @@
#ifndef liblldb_ABISysV_s390x_h_
#define liblldb_ABISysV_s390x_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
@@ -61,9 +57,7 @@ public:
bool CodeAddressIsValid(lldb::addr_t pc) override {
// Code addressed must be 2 byte aligned
- if (pc & 1ull)
- return false;
- return true;
+ return (pc & 1ull) == 0;
}
const lldb_private::RegisterInfo *
diff --git a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
index 36ae3a49827c..dc3e475e3b8e 100644
--- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
+++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
@@ -9,17 +9,12 @@
#include "ABISysV_x86_64.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Triple.h"
-// Project includes
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectMemory.h"
@@ -33,6 +28,7 @@
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegisterValue.h"
#include "lldb/Utility/Status.h"
using namespace lldb;
@@ -1095,11 +1091,8 @@ size_t ABISysV_x86_64::GetRedZoneSize() const { return 128; }
ABISP
ABISysV_x86_64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
- static ABISP g_abi_sp;
if (arch.GetTriple().getArch() == llvm::Triple::x86_64) {
- if (!g_abi_sp)
- g_abi_sp.reset(new ABISysV_x86_64(process_sp));
- return g_abi_sp;
+ return ABISP(new ABISysV_x86_64(process_sp));
}
return ABISP();
}
@@ -1270,18 +1263,19 @@ bool ABISysV_x86_64::GetArgumentValues(Thread &thread,
// We currently only support extracting values with Clang QualTypes. Do we
// care about others?
CompilerType compiler_type = value->GetCompilerType();
- if (!compiler_type)
+ llvm::Optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
+ if (!bit_size)
return false;
bool is_signed;
if (compiler_type.IsIntegerOrEnumerationType(is_signed)) {
- ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread),
- is_signed, thread, argument_register_ids,
- current_argument_register, current_stack_argument);
+ ReadIntegerArgument(value->GetScalar(), *bit_size, is_signed, thread,
+ argument_register_ids, current_argument_register,
+ current_stack_argument);
} else if (compiler_type.IsPointerType()) {
- ReadIntegerArgument(value->GetScalar(), compiler_type.GetBitSize(&thread),
- false, thread, argument_register_ids,
- current_argument_register, current_stack_argument);
+ ReadIntegerArgument(value->GetScalar(), *bit_size, false, thread,
+ argument_register_ids, current_argument_register,
+ current_stack_argument);
}
}
@@ -1339,8 +1333,13 @@ Status ABISysV_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
error.SetErrorString(
"We don't support returning complex values at present");
else {
- size_t bit_width = compiler_type.GetBitSize(frame_sp.get());
- if (bit_width <= 64) {
+ llvm::Optional<uint64_t> bit_width =
+ compiler_type.GetBitSize(frame_sp.get());
+ if (!bit_width) {
+ error.SetErrorString("can't get type size");
+ return error;
+ }
+ if (*bit_width <= 64) {
const RegisterInfo *xmm0_info =
reg_ctx->GetRegisterInfoByName("xmm0", 0);
RegisterValue xmm0_value;
@@ -1403,11 +1402,14 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple(
if (type_flags & eTypeIsInteger) {
// Extract the register context so we can read arguments from registers
- const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
+ llvm::Optional<uint64_t> byte_size =
+ return_compiler_type.GetByteSize(nullptr);
+ if (!byte_size)
+ return return_valobj_sp;
uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(
reg_ctx->GetRegisterInfoByName("rax", 0), 0);
const bool is_signed = (type_flags & eTypeIsSigned) != 0;
- switch (byte_size) {
+ switch (*byte_size) {
default:
break;
@@ -1447,8 +1449,9 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple(
if (type_flags & eTypeIsComplex) {
// Don't handle complex yet.
} else {
- const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
- if (byte_size <= sizeof(long double)) {
+ llvm::Optional<uint64_t> byte_size =
+ return_compiler_type.GetByteSize(nullptr);
+ if (byte_size && *byte_size <= sizeof(long double)) {
const RegisterInfo *xmm0_info =
reg_ctx->GetRegisterInfoByName("xmm0", 0);
RegisterValue xmm0_value;
@@ -1456,13 +1459,13 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple(
DataExtractor data;
if (xmm0_value.GetData(data)) {
lldb::offset_t offset = 0;
- if (byte_size == sizeof(float)) {
+ if (*byte_size == sizeof(float)) {
value.GetScalar() = (float)data.GetFloat(&offset);
success = true;
- } else if (byte_size == sizeof(double)) {
+ } else if (*byte_size == sizeof(double)) {
value.GetScalar() = (double)data.GetDouble(&offset);
success = true;
- } else if (byte_size == sizeof(long double)) {
+ } else if (*byte_size == sizeof(long double)) {
// Don't handle long double since that can be encoded as 80 bit
// floats...
}
@@ -1485,19 +1488,20 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple(
return_valobj_sp = ValueObjectConstResult::Create(
thread.GetStackFrameAtIndex(0).get(), value, ConstString(""));
} else if (type_flags & eTypeIsVector) {
- const size_t byte_size = return_compiler_type.GetByteSize(nullptr);
- if (byte_size > 0) {
+ llvm::Optional<uint64_t> byte_size =
+ return_compiler_type.GetByteSize(nullptr);
+ if (byte_size && *byte_size > 0) {
const RegisterInfo *altivec_reg =
reg_ctx->GetRegisterInfoByName("xmm0", 0);
if (altivec_reg == nullptr)
altivec_reg = reg_ctx->GetRegisterInfoByName("mm0", 0);
if (altivec_reg) {
- if (byte_size <= altivec_reg->byte_size) {
+ if (*byte_size <= altivec_reg->byte_size) {
ProcessSP process_sp(thread.GetProcess());
if (process_sp) {
std::unique_ptr<DataBufferHeap> heap_data_ap(
- new DataBufferHeap(byte_size, 0));
+ new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order = process_sp->GetByteOrder();
RegisterValue reg_value;
if (reg_ctx->ReadRegister(altivec_reg, reg_value)) {
@@ -1514,14 +1518,14 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple(
}
}
}
- } else if (byte_size <= altivec_reg->byte_size * 2) {
+ } else if (*byte_size <= altivec_reg->byte_size * 2) {
const RegisterInfo *altivec_reg2 =
reg_ctx->GetRegisterInfoByName("xmm1", 0);
if (altivec_reg2) {
ProcessSP process_sp(thread.GetProcess());
if (process_sp) {
std::unique_ptr<DataBufferHeap> heap_data_ap(
- new DataBufferHeap(byte_size, 0));
+ new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order = process_sp->GetByteOrder();
RegisterValue reg_value;
RegisterValue reg_value2;
@@ -1571,11 +1575,13 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
if (!reg_ctx_sp)
return return_valobj_sp;
- const size_t bit_width = return_compiler_type.GetBitSize(&thread);
+ llvm::Optional<uint64_t> bit_width = return_compiler_type.GetBitSize(&thread);
+ if (!bit_width)
+ return return_valobj_sp;
if (return_compiler_type.IsAggregateType()) {
Target *target = exe_ctx.GetTargetPtr();
bool is_memory = true;
- if (bit_width <= 128) {
+ if (*bit_width <= 128) {
ByteOrder target_byte_order = target->GetArchitecture().GetByteOrder();
DataBufferSP data_sp(new DataBufferHeap(16, 0));
DataExtractor return_ext(data_sp, target_byte_order,
@@ -1622,20 +1628,21 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
idx, name, &field_bit_offset, nullptr, nullptr);
- const size_t field_bit_width = field_compiler_type.GetBitSize(&thread);
+ llvm::Optional<uint64_t> field_bit_width =
+ field_compiler_type.GetBitSize(&thread);
// if we don't know the size of the field (e.g. invalid type), just
// bail out
- if (field_bit_width == 0)
+ if (!field_bit_width || *field_bit_width == 0)
break;
// If there are any unaligned fields, this is stored in memory.
- if (field_bit_offset % field_bit_width != 0) {
+ if (field_bit_offset % *field_bit_width != 0) {
is_memory = true;
break;
}
- uint32_t field_byte_width = field_bit_width / 8;
+ uint32_t field_byte_width = *field_bit_width / 8;
uint32_t field_byte_offset = field_bit_offset / 8;
DataExtractor *copy_from_extractor = nullptr;
@@ -1668,10 +1675,10 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
}
} else if (field_compiler_type.IsFloatingPointType(count, is_complex)) {
// Structs with long doubles are always passed in memory.
- if (field_bit_width == 128) {
+ if (*field_bit_width == 128) {
is_memory = true;
break;
- } else if (field_bit_width == 64) {
+ } else if (*field_bit_width == 64) {
// These have to be in a single xmm register.
if (fp_bytes == 0)
copy_from_extractor = &xmm0_data;
@@ -1680,7 +1687,7 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
copy_from_offset = 0;
fp_bytes += field_byte_width;
- } else if (field_bit_width == 32) {
+ } else if (*field_bit_width == 32) {
// This one is kind of complicated. If we are in an "eightbyte"
// with another float, we'll be stuffed into an xmm register with
// it. If we are in an "eightbyte" with one or more ints, then we
diff --git a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h
index 5b67e8656d36..4afc8c4cad62 100644
--- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h
+++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h
@@ -10,10 +10,6 @@
#ifndef liblldb_ABISysV_x86_64_h_
#define liblldb_ABISysV_x86_64_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Target/ABI.h"
#include "lldb/lldb-private.h"
diff --git a/source/Plugins/Architecture/Arm/ArchitectureArm.cpp b/source/Plugins/Architecture/Arm/ArchitectureArm.cpp
index 1b7ecc88c35e..6993222ba5d4 100644
--- a/source/Plugins/Architecture/Arm/ArchitectureArm.cpp
+++ b/source/Plugins/Architecture/Arm/ArchitectureArm.cpp
@@ -126,3 +126,33 @@ void ArchitectureArm::OverrideStopInfo(Thread &thread) const {
}
}
}
+
+addr_t ArchitectureArm::GetCallableLoadAddress(addr_t code_addr,
+ AddressClass addr_class) const {
+ bool is_alternate_isa = false;
+
+ switch (addr_class) {
+ case AddressClass::eData:
+ case AddressClass::eDebug:
+ return LLDB_INVALID_ADDRESS;
+ case AddressClass::eCodeAlternateISA:
+ is_alternate_isa = true;
+ break;
+ default: break;
+ }
+
+ if ((code_addr & 2u) || is_alternate_isa)
+ return code_addr | 1u;
+ return code_addr;
+}
+
+addr_t ArchitectureArm::GetOpcodeLoadAddress(addr_t opcode_addr,
+ AddressClass addr_class) const {
+ switch (addr_class) {
+ case AddressClass::eData:
+ case AddressClass::eDebug:
+ return LLDB_INVALID_ADDRESS;
+ default: break;
+ }
+ return opcode_addr & ~(1ull);
+}
diff --git a/source/Plugins/Architecture/Arm/ArchitectureArm.h b/source/Plugins/Architecture/Arm/ArchitectureArm.h
index 484c4a52fcc6..1a052c76b2c9 100644
--- a/source/Plugins/Architecture/Arm/ArchitectureArm.h
+++ b/source/Plugins/Architecture/Arm/ArchitectureArm.h
@@ -25,6 +25,12 @@ public:
void OverrideStopInfo(Thread &thread) const override;
+ lldb::addr_t GetCallableLoadAddress(lldb::addr_t load_addr,
+ AddressClass addr_class) const override;
+
+ lldb::addr_t GetOpcodeLoadAddress(lldb::addr_t load_addr,
+ AddressClass addr_class) const override;
+
private:
static std::unique_ptr<Architecture> Create(const ArchSpec &arch);
ArchitectureArm() = default;
diff --git a/source/Plugins/Architecture/CMakeLists.txt b/source/Plugins/Architecture/CMakeLists.txt
index 01365a64cf96..14ad91644595 100644
--- a/source/Plugins/Architecture/CMakeLists.txt
+++ b/source/Plugins/Architecture/CMakeLists.txt
@@ -1,2 +1,3 @@
add_subdirectory(Arm)
+add_subdirectory(Mips)
add_subdirectory(PPC64)
diff --git a/source/Plugins/Architecture/Mips/ArchitectureMips.cpp b/source/Plugins/Architecture/Mips/ArchitectureMips.cpp
new file mode 100644
index 000000000000..0cbbd9922321
--- /dev/null
+++ b/source/Plugins/Architecture/Mips/ArchitectureMips.cpp
@@ -0,0 +1,241 @@
+//===-- ArchitectureMips.cpp -------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "Plugins/Architecture/Mips/ArchitectureMips.h"
+#include "lldb/Core/Address.h"
+#include "lldb/Core/Disassembler.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Target/SectionLoadList.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/Log.h"
+
+using namespace lldb_private;
+using namespace lldb;
+
+ConstString ArchitectureMips::GetPluginNameStatic() {
+ return ConstString("mips");
+}
+
+void ArchitectureMips::Initialize() {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(),
+ "Mips-specific algorithms",
+ &ArchitectureMips::Create);
+}
+
+void ArchitectureMips::Terminate() {
+ PluginManager::UnregisterPlugin(&ArchitectureMips::Create);
+}
+
+std::unique_ptr<Architecture> ArchitectureMips::Create(const ArchSpec &arch) {
+ return arch.IsMIPS() ?
+ std::unique_ptr<Architecture>(new ArchitectureMips(arch)) : nullptr;
+}
+
+ConstString ArchitectureMips::GetPluginName() { return GetPluginNameStatic(); }
+uint32_t ArchitectureMips::GetPluginVersion() { return 1; }
+
+addr_t ArchitectureMips::GetCallableLoadAddress(addr_t code_addr,
+ AddressClass addr_class) const {
+ bool is_alternate_isa = false;
+
+ switch (addr_class) {
+ case AddressClass::eData:
+ case AddressClass::eDebug:
+ return LLDB_INVALID_ADDRESS;
+ case AddressClass::eCodeAlternateISA:
+ is_alternate_isa = true;
+ break;
+ default: break;
+ }
+
+ if ((code_addr & 2ull) || is_alternate_isa)
+ return code_addr | 1u;
+ return code_addr;
+}
+
+addr_t ArchitectureMips::GetOpcodeLoadAddress(addr_t opcode_addr,
+ AddressClass addr_class) const {
+ switch (addr_class) {
+ case AddressClass::eData:
+ case AddressClass::eDebug:
+ return LLDB_INVALID_ADDRESS;
+ default: break;
+ }
+ return opcode_addr & ~(1ull);
+}
+
+lldb::addr_t ArchitectureMips::GetBreakableLoadAddress(lldb::addr_t addr,
+ Target &target) const {
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+
+ Address resolved_addr;
+
+ SectionLoadList &section_load_list = target.GetSectionLoadList();
+ if (section_load_list.IsEmpty())
+ // No sections are loaded, so we must assume we are not running yet and
+ // need to operate only on file address.
+ target.ResolveFileAddress(addr, resolved_addr);
+ else
+ target.ResolveLoadAddress(addr, resolved_addr);
+
+ addr_t current_offset = 0;
+
+ // Get the function boundaries to make sure we don't scan back before the
+ // beginning of the current function.
+ ModuleSP temp_addr_module_sp(resolved_addr.GetModule());
+ if (temp_addr_module_sp) {
+ SymbolContext sc;
+ SymbolContextItem resolve_scope =
+ eSymbolContextFunction | eSymbolContextSymbol;
+ temp_addr_module_sp->ResolveSymbolContextForAddress(resolved_addr,
+ resolve_scope, sc);
+ Address sym_addr;
+ if (sc.function)
+ sym_addr = sc.function->GetAddressRange().GetBaseAddress();
+ else if (sc.symbol)
+ sym_addr = sc.symbol->GetAddress();
+
+ addr_t function_start = sym_addr.GetLoadAddress(&target);
+ if (function_start == LLDB_INVALID_ADDRESS)
+ function_start = sym_addr.GetFileAddress();
+
+ if (function_start)
+ current_offset = addr - function_start;
+ }
+
+ // If breakpoint address is start of function then we dont have to do
+ // anything.
+ if (current_offset == 0)
+ return addr;
+
+ ExecutionContext ctx;
+ target.CalculateExecutionContext(ctx);
+ auto insn = GetInstructionAtAddress(ctx, current_offset, addr);
+
+ if (nullptr == insn || !insn->HasDelaySlot())
+ return addr;
+
+ // Adjust the breakable address
+ uint64_t breakable_addr = addr - insn->GetOpcode().GetByteSize();
+ if (log)
+ log->Printf("Target::%s Breakpoint at 0x%8.8" PRIx64
+ " is adjusted to 0x%8.8" PRIx64 " due to delay slot\n",
+ __FUNCTION__, addr, breakable_addr);
+
+ return breakable_addr;
+}
+
+Instruction *ArchitectureMips::GetInstructionAtAddress(
+ const ExecutionContext &exe_ctx, const Address &resolved_addr,
+ addr_t symbol_offset) const {
+
+ auto loop_count = symbol_offset / 2;
+
+ uint32_t arch_flags = m_arch.GetFlags();
+ bool IsMips16 = arch_flags & ArchSpec::eMIPSAse_mips16;
+ bool IsMicromips = arch_flags & ArchSpec::eMIPSAse_micromips;
+
+ if (loop_count > 3) {
+ // Scan previous 6 bytes
+ if (IsMips16 | IsMicromips)
+ loop_count = 3;
+ // For mips-only, instructions are always 4 bytes, so scan previous 4
+ // bytes only.
+ else
+ loop_count = 2;
+ }
+
+ // Create Disassembler Instance
+ lldb::DisassemblerSP disasm_sp(
+ Disassembler::FindPlugin(m_arch, nullptr, nullptr));
+
+ InstructionList instruction_list;
+ InstructionSP prev_insn;
+ bool prefer_file_cache = true; // Read from file
+ uint32_t inst_to_choose = 0;
+
+ Address addr = resolved_addr;
+
+ 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);
+
+ uint32_t num_insns = disasm_sp->GetInstructionList().GetSize();
+ if (num_insns) {
+ prev_insn = disasm_sp->GetInstructionList().GetInstructionAtIndex(0);
+ insn_size = prev_insn->GetOpcode().GetByteSize();
+ if (i == 1 && insn_size == 2) {
+ // This looks like a valid 2-byte instruction (but it could be a part
+ // of upper 4 byte instruction).
+ instruction_list.Append(prev_insn);
+ inst_to_choose = 1;
+ }
+ else if (i == 2) {
+ // Here we may get one 4-byte instruction or two 2-byte instructions.
+ if (num_insns == 2) {
+ // Looks like there are two 2-byte instructions above our
+ // breakpoint target address. Now the upper 2-byte instruction is
+ // either a valid 2-byte instruction or could be a part of it's
+ // upper 4-byte instruction. In both cases we don't care because in
+ // this case lower 2-byte instruction is definitely a valid
+ // instruction and whatever i=1 iteration has found out is true.
+ inst_to_choose = 1;
+ break;
+ }
+ else if (insn_size == 4) {
+ // This instruction claims its a valid 4-byte instruction. But it
+ // could be a part of it's upper 4-byte instruction. Lets try
+ // scanning upper 2 bytes to verify this.
+ instruction_list.Append(prev_insn);
+ inst_to_choose = 2;
+ }
+ }
+ else if (i == 3) {
+ if (insn_size == 4)
+ // FIXME: We reached here that means instruction at [target - 4] has
+ // already claimed to be a 4-byte instruction, and now instruction
+ // at [target - 6] is also claiming that it's a 4-byte instruction.
+ // This can not be true. In this case we can not decide the valid
+ // previous instruction so we let lldb set the breakpoint at the
+ // address given by user.
+ inst_to_choose = 0;
+ else
+ // This is straight-forward
+ inst_to_choose = 2;
+ break;
+ }
+ }
+ else {
+ // Decode failed, bytes do not form a valid instruction. So whatever
+ // previous iteration has found out is true.
+ if (i > 1) {
+ inst_to_choose = i - 1;
+ break;
+ }
+ }
+ }
+
+ // Check if we are able to find any valid instruction.
+ if (inst_to_choose) {
+ if (inst_to_choose > instruction_list.GetSize())
+ inst_to_choose--;
+ return instruction_list.GetInstructionAtIndex(inst_to_choose - 1).get();
+ }
+
+ return nullptr;
+}
diff --git a/source/Plugins/Architecture/Mips/ArchitectureMips.h b/source/Plugins/Architecture/Mips/ArchitectureMips.h
new file mode 100644
index 000000000000..2338daf2e468
--- /dev/null
+++ b/source/Plugins/Architecture/Mips/ArchitectureMips.h
@@ -0,0 +1,52 @@
+//===-- ArchitectureMips.h ---------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_PLUGIN_ARCHITECTURE_MIPS_H
+#define LLDB_PLUGIN_ARCHITECTURE_MIPS_H
+
+#include "lldb/Core/Architecture.h"
+#include "lldb/Utility/ArchSpec.h"
+
+namespace lldb_private {
+
+class ArchitectureMips : public Architecture {
+public:
+ static ConstString GetPluginNameStatic();
+ static void Initialize();
+ static void Terminate();
+
+ ConstString GetPluginName() override;
+ uint32_t GetPluginVersion() override;
+
+ void OverrideStopInfo(Thread &thread) const override {}
+
+ lldb::addr_t GetBreakableLoadAddress(lldb::addr_t addr,
+ Target &) const override;
+
+ lldb::addr_t GetCallableLoadAddress(lldb::addr_t load_addr,
+ AddressClass addr_class) const override;
+
+ lldb::addr_t GetOpcodeLoadAddress(lldb::addr_t load_addr,
+ AddressClass addr_class) const override;
+
+private:
+ Instruction *GetInstructionAtAddress(const ExecutionContext &exe_ctx,
+ 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) {}
+
+ ArchSpec m_arch;
+};
+
+} // namespace lldb_private
+
+#endif // LLDB_PLUGIN_ARCHITECTURE_MIPS_H
diff --git a/source/Plugins/Architecture/Mips/CMakeLists.txt b/source/Plugins/Architecture/Mips/CMakeLists.txt
new file mode 100644
index 000000000000..9734edc6b12b
--- /dev/null
+++ b/source/Plugins/Architecture/Mips/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_lldb_library(lldbPluginArchitectureMips PLUGIN
+ ArchitectureMips.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbTarget
+ lldbUtility
+ LINK_COMPONENTS
+ Support
+ )
diff --git a/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp b/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
index 9b381dd3b96c..5df842250591 100644
--- a/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
+++ b/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
@@ -7,12 +7,8 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-// Project includes
#include "DisassemblerLLVMC.h"
-// Other libraries and framework includes
#include "llvm-c/Disassembler.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/MC/MCAsmInfo.h"
@@ -98,16 +94,15 @@ public:
bool DoesBranch() override {
if (m_does_branch == eLazyBoolCalculate) {
- std::shared_ptr<DisassemblerLLVMC> disasm_sp(GetDisassembler());
- if (disasm_sp) {
- disasm_sp->Lock(this, NULL);
+ 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);
+ GetDisasmToUse(is_alternate_isa, disasm);
const uint8_t *opcode_data = data.GetDataStart();
const size_t opcode_data_len = data.GetByteSize();
llvm::MCInst inst;
@@ -125,7 +120,6 @@ public:
m_does_branch = eLazyBoolNo;
}
}
- disasm_sp->Unlock();
}
}
return m_does_branch == eLazyBoolYes;
@@ -133,16 +127,15 @@ public:
bool HasDelaySlot() override {
if (m_has_delay_slot == eLazyBoolCalculate) {
- std::shared_ptr<DisassemblerLLVMC> disasm_sp(GetDisassembler());
- if (disasm_sp) {
- disasm_sp->Lock(this, NULL);
+ 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);
+ GetDisasmToUse(is_alternate_isa, disasm);
const uint8_t *opcode_data = data.GetDataStart();
const size_t opcode_data_len = data.GetByteSize();
llvm::MCInst inst;
@@ -160,27 +153,14 @@ public:
m_has_delay_slot = eLazyBoolNo;
}
}
- disasm_sp->Unlock();
}
}
return m_has_delay_slot == eLazyBoolYes;
}
DisassemblerLLVMC::MCDisasmInstance *GetDisasmToUse(bool &is_alternate_isa) {
- is_alternate_isa = false;
- std::shared_ptr<DisassemblerLLVMC> disasm_sp(GetDisassembler());
- if (disasm_sp) {
- if (disasm_sp->m_alternate_disasm_up) {
- const AddressClass address_class = GetAddressClass();
-
- if (address_class == AddressClass::eCodeAlternateISA) {
- is_alternate_isa = true;
- return disasm_sp->m_alternate_disasm_up.get();
- }
- }
- return disasm_sp->m_disasm_up.get();
- }
- return nullptr;
+ DisassemblerScope disasm(*this);
+ return GetDisasmToUse(is_alternate_isa, disasm);
}
size_t Decode(const lldb_private::Disassembler &disassembler,
@@ -189,9 +169,9 @@ public:
// All we have to do is read the opcode which can be easy for some
// architectures
bool got_op = false;
- std::shared_ptr<DisassemblerLLVMC> disasm_sp(GetDisassembler());
- if (disasm_sp) {
- const ArchSpec &arch = disasm_sp->GetArchitecture();
+ DisassemblerScope disasm(*this);
+ if (disasm) {
+ const ArchSpec &arch = disasm->GetArchitecture();
const lldb::ByteOrder byte_order = data.GetByteOrder();
const uint32_t min_op_byte_size = arch.GetMinimumOpcodeByteSize();
@@ -232,7 +212,7 @@ public:
if (!got_op) {
bool is_alternate_isa = false;
DisassemblerLLVMC::MCDisasmInstance *mc_disasm_ptr =
- GetDisasmToUse(is_alternate_isa);
+ GetDisasmToUse(is_alternate_isa, disasm);
const llvm::Triple::ArchType machine = arch.GetMachine();
if (machine == llvm::Triple::arm || machine == llvm::Triple::thumb) {
@@ -261,10 +241,8 @@ public:
const addr_t pc = m_address.GetFileAddress();
llvm::MCInst inst;
- disasm_sp->Lock(this, NULL);
const size_t inst_size =
mc_disasm_ptr->GetMCInst(opcode_data, opcode_data_len, pc, inst);
- disasm_sp->Unlock();
if (inst_size == 0)
m_opcode.Clear();
else {
@@ -296,19 +274,19 @@ public:
std::string out_string;
std::string comment_string;
- std::shared_ptr<DisassemblerLLVMC> disasm_sp(GetDisassembler());
- if (disasm_sp) {
+ DisassemblerScope disasm(*this, exe_ctx);
+ if (disasm) {
DisassemblerLLVMC::MCDisasmInstance *mc_disasm_ptr;
if (address_class == AddressClass::eCodeAlternateISA)
- mc_disasm_ptr = disasm_sp->m_alternate_disasm_up.get();
+ mc_disasm_ptr = disasm->m_alternate_disasm_up.get();
else
- mc_disasm_ptr = disasm_sp->m_disasm_up.get();
+ mc_disasm_ptr = disasm->m_disasm_up.get();
lldb::addr_t pc = m_address.GetFileAddress();
m_using_file_addr = true;
- const bool data_from_file = disasm_sp->m_data_from_file;
+ const bool data_from_file = disasm->m_data_from_file;
bool use_hex_immediates = true;
Disassembler::HexImmediateStyle hex_style = Disassembler::eHexStyleC;
@@ -328,8 +306,6 @@ public:
}
}
- disasm_sp->Lock(this, exe_ctx);
-
const uint8_t *opcode_data = data.GetDataStart();
const size_t opcode_data_len = data.GetByteSize();
llvm::MCInst inst;
@@ -345,8 +321,6 @@ public:
}
}
- disasm_sp->Unlock();
-
if (inst_size == 0) {
m_comment.assign("unknown opcode");
inst_size = m_opcode.GetByteSize();
@@ -423,9 +397,27 @@ public:
bool UsingFileAddress() const { return m_using_file_addr; }
size_t GetByteSize() const { return m_opcode.GetByteSize(); }
- std::shared_ptr<DisassemblerLLVMC> GetDisassembler() {
- return m_disasm_wp.lock();
- }
+ /// Grants exclusive access to the disassembler and initializes it with the
+ /// given InstructionLLVMC and an optional ExecutionContext.
+ class DisassemblerScope {
+ std::shared_ptr<DisassemblerLLVMC> m_disasm;
+
+ public:
+ explicit DisassemblerScope(
+ InstructionLLVMC &i,
+ const lldb_private::ExecutionContext *exe_ctx = nullptr)
+ : m_disasm(i.m_disasm_wp.lock()) {
+ m_disasm->m_mutex.lock();
+ m_disasm->m_inst = &i;
+ m_disasm->m_exe_ctx = exe_ctx;
+ }
+ ~DisassemblerScope() { m_disasm->m_mutex.unlock(); }
+
+ /// Evaluates to true if this scope contains a valid disassembler.
+ operator bool() const { return static_cast<bool>(m_disasm); }
+
+ std::shared_ptr<DisassemblerLLVMC> operator->() { return m_disasm; }
+ };
static llvm::StringRef::const_iterator
ConsumeWhitespace(llvm::StringRef::const_iterator osi,
@@ -876,16 +868,15 @@ public:
bool IsCall() override {
if (m_is_call == eLazyBoolCalculate) {
- std::shared_ptr<DisassemblerLLVMC> disasm_sp(GetDisassembler());
- if (disasm_sp) {
- disasm_sp->Lock(this, NULL);
+ 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);
+ GetDisasmToUse(is_alternate_isa, disasm);
const uint8_t *opcode_data = data.GetDataStart();
const size_t opcode_data_len = data.GetByteSize();
llvm::MCInst inst;
@@ -900,7 +891,6 @@ public:
m_is_call = eLazyBoolNo;
}
}
- disasm_sp->Unlock();
}
}
return m_is_call == eLazyBoolYes;
@@ -913,6 +903,24 @@ protected:
LazyBool m_is_call;
bool m_is_valid;
bool m_using_file_addr;
+
+private:
+ DisassemblerLLVMC::MCDisasmInstance *
+ GetDisasmToUse(bool &is_alternate_isa, DisassemblerScope &disasm) {
+ is_alternate_isa = false;
+ if (disasm) {
+ if (disasm->m_alternate_disasm_up) {
+ const AddressClass address_class = GetAddressClass();
+
+ if (address_class == AddressClass::eCodeAlternateISA) {
+ is_alternate_isa = true;
+ return disasm->m_alternate_disasm_up.get();
+ }
+ }
+ return disasm->m_disasm_up.get();
+ }
+ return nullptr;
+ }
};
std::unique_ptr<DisassemblerLLVMC::MCDisasmInstance>
@@ -1114,11 +1122,13 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch,
triple.getSubArch() == llvm::Triple::NoSubArch)
triple.setArchName("armv8.2a");
+ std::string features_str = "";
const char *triple_str = triple.getTriple().c_str();
// ARM Cortex M0-M7 devices only execute thumb instructions
if (arch.IsAlwaysThumbInstructions()) {
triple_str = thumb_arch.GetTriple().getTriple().c_str();
+ features_str += "+fp-armv8,";
}
const char *cpu = "";
@@ -1169,7 +1179,6 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch,
break;
}
- std::string features_str = "";
if (triple.getArch() == llvm::Triple::mips ||
triple.getArch() == llvm::Triple::mipsel ||
triple.getArch() == llvm::Triple::mips64 ||
@@ -1201,7 +1210,8 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch,
if (llvm_arch == llvm::Triple::arm) {
std::string thumb_triple(thumb_arch.GetTriple().getTriple());
m_alternate_disasm_up =
- MCDisasmInstance::Create(thumb_triple.c_str(), "", "", flavor, *this);
+ MCDisasmInstance::Create(thumb_triple.c_str(), "", features_str.c_str(),
+ flavor, *this);
if (!m_alternate_disasm_up)
m_disasm_up.reset();
@@ -1326,10 +1336,7 @@ bool DisassemblerLLVMC::FlavorValidForArchSpec(
if (triple.getArch() == llvm::Triple::x86 ||
triple.getArch() == llvm::Triple::x86_64) {
- if (strcmp(flavor, "intel") == 0 || strcmp(flavor, "att") == 0)
- return true;
- else
- return false;
+ return strcmp(flavor, "intel") == 0 || strcmp(flavor, "att") == 0;
} else
return false;
}
@@ -1368,7 +1375,7 @@ const char *DisassemblerLLVMC::SymbolLookup(uint64_t value, uint64_t *type_ptr,
}
SymbolContext sym_ctx;
- const uint32_t resolve_scope =
+ const SymbolContextItem resolve_scope =
eSymbolContextFunction | eSymbolContextSymbol;
if (pc_so_addr.IsValid() && pc_so_addr.GetModule()) {
pc_so_addr.GetModule()->ResolveSymbolContextForAddress(
diff --git a/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h b/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h
index b7e9ccb34701..8b9f7c37d2b8 100644
--- a/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h
+++ b/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h
@@ -10,13 +10,10 @@
#ifndef liblldb_DisassemblerLLVMC_h_
#define liblldb_DisassemblerLLVMC_h_
-// C Includes
-// C++ Includes
#include <memory>
#include <mutex>
#include <string>
-// Project includes
#include "lldb/Core/Address.h"
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/PluginManager.h"
@@ -77,19 +74,6 @@ protected:
uint64_t ReferencePC,
const char **ReferenceName);
- void Lock(InstructionLLVMC *inst,
- const lldb_private::ExecutionContext *exe_ctx) {
- m_mutex.lock();
- m_inst = inst;
- m_exe_ctx = exe_ctx;
- }
-
- void Unlock() {
- m_inst = NULL;
- m_exe_ctx = NULL;
- m_mutex.unlock();
- }
-
const lldb_private::ExecutionContext *m_exe_ctx;
InstructionLLVMC *m_inst;
std::mutex m_mutex;
diff --git a/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index 8999000dff8c..3a80c68dd4d7 100644
--- a/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ b/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -15,7 +15,6 @@
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/State.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Host/Symbols.h"
#include "lldb/Interpreter/OptionValueProperties.h"
@@ -29,6 +28,7 @@
#include "lldb/Utility/DataBuffer.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/State.h"
#include "DynamicLoaderDarwinKernel.h"
@@ -58,7 +58,7 @@ enum KASLRScanType {
// range looking for a kernel
};
-OptionEnumValueElement g_kaslr_kernel_scan_enum_values[] = {
+static constexpr OptionEnumValueElement g_kaslr_kernel_scan_enum_values[] = {
{eKASLRScanNone, "none",
"Do not read memory looking for a Darwin kernel when attaching."},
{eKASLRScanLowgloAddresses, "basic", "Check for the Darwin kernel's load "
@@ -68,17 +68,15 @@ OptionEnumValueElement g_kaslr_kernel_scan_enum_values[] = {
"the Darwin kernel's load address."},
{eKASLRScanExhaustiveScan, "exhaustive-scan",
"Scan through the entire potential address range of Darwin kernel (only "
- "on 32-bit targets)."},
- {0, NULL, NULL}};
+ "on 32-bit targets)."}};
-static PropertyDefinition g_properties[] = {
- {"load-kexts", OptionValue::eTypeBoolean, true, true, NULL, NULL,
+static constexpr PropertyDefinition g_properties[] = {
+ {"load-kexts", OptionValue::eTypeBoolean, true, true, NULL, {},
"Automatically loads kext images when attaching to a kernel."},
{"scan-type", OptionValue::eTypeEnum, true, eKASLRScanNearPC, NULL,
- g_kaslr_kernel_scan_enum_values, "Control how many reads lldb will make "
- "while searching for a Darwin kernel on "
- "attach."},
- {NULL, OptionValue::eTypeInvalid, false, 0, NULL, NULL, NULL}};
+ OptionEnumValues(g_kaslr_kernel_scan_enum_values),
+ "Control how many reads lldb will make while searching for a Darwin "
+ "kernel on attach."}};
enum { ePropertyLoadKexts, ePropertyScanType };
@@ -149,6 +147,7 @@ DynamicLoader *DynamicLoaderDarwinKernel::CreateInstance(Process *process,
case llvm::Triple::IOS:
case llvm::Triple::TvOS:
case llvm::Triple::WatchOS:
+ // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
if (triple_ref.getVendor() != llvm::Triple::Apple) {
return NULL;
}
@@ -212,13 +211,13 @@ DynamicLoaderDarwinKernel::SearchForKernelAtSameLoadAddr(Process *process) {
exe_objfile->GetStrata() != ObjectFile::eStrataKernel)
return LLDB_INVALID_ADDRESS;
- if (!exe_objfile->GetHeaderAddress().IsValid())
+ if (!exe_objfile->GetBaseAddress().IsValid())
return LLDB_INVALID_ADDRESS;
if (CheckForKernelImageAtAddress(
- exe_objfile->GetHeaderAddress().GetFileAddress(), process) ==
+ exe_objfile->GetBaseAddress().GetFileAddress(), process) ==
exe_module->GetUUID())
- return exe_objfile->GetHeaderAddress().GetFileAddress();
+ return exe_objfile->GetBaseAddress().GetFileAddress();
return LLDB_INVALID_ADDRESS;
}
@@ -294,6 +293,18 @@ DynamicLoaderDarwinKernel::SearchForKernelNearPC(Process *process) {
return LLDB_INVALID_ADDRESS;
addr_t pc = thread->GetRegisterContext()->GetPC(LLDB_INVALID_ADDRESS);
+ // The kernel is always loaded in high memory, if the top bit is zero,
+ // this isn't a kernel.
+ if (process->GetTarget().GetArchitecture().GetAddressByteSize() == 8) {
+ if ((pc & (1ULL << 63)) == 0) {
+ return LLDB_INVALID_ADDRESS;
+ }
+ } else {
+ if ((pc & (1ULL << 31)) == 0) {
+ return LLDB_INVALID_ADDRESS;
+ }
+ }
+
if (pc == LLDB_INVALID_ADDRESS)
return LLDB_INVALID_ADDRESS;
@@ -308,12 +319,13 @@ DynamicLoaderDarwinKernel::SearchForKernelNearPC(Process *process) {
// Search backwards 32 megabytes, looking for the start of the kernel at each
// one-megabyte boundary.
for (int i = 0; i < 32; i++, addr -= 0x100000) {
+ // x86_64 kernels are at offset 0
if (CheckForKernelImageAtAddress(addr, process).IsValid())
return addr;
+ // 32-bit arm kernels are at offset 0x1000 (one 4k page)
if (CheckForKernelImageAtAddress(addr + 0x1000, process).IsValid())
return addr + 0x1000;
- if (CheckForKernelImageAtAddress(addr + 0x2000, process).IsValid())
- return addr + 0x2000;
+ // 64-bit arm kernels are at offset 0x4000 (one 16k page)
if (CheckForKernelImageAtAddress(addr + 0x4000, process).IsValid())
return addr + 0x4000;
}
@@ -352,12 +364,13 @@ lldb::addr_t DynamicLoaderDarwinKernel::SearchForKernelViaExhaustiveSearch(
addr_t addr = kernel_range_low;
while (addr >= kernel_range_low && addr < kernel_range_high) {
+ // x86_64 kernels are at offset 0
if (CheckForKernelImageAtAddress(addr, process).IsValid())
return addr;
+ // 32-bit arm kernels are at offset 0x1000 (one 4k page)
if (CheckForKernelImageAtAddress(addr + 0x1000, process).IsValid())
return addr + 0x1000;
- if (CheckForKernelImageAtAddress(addr + 0x2000, process).IsValid())
- return addr + 0x2000;
+ // 64-bit arm kernels are at offset 0x4000 (one 16k page)
if (CheckForKernelImageAtAddress(addr + 0x4000, process).IsValid())
return addr + 0x4000;
addr += 0x100000;
@@ -388,8 +401,8 @@ DynamicLoaderDarwinKernel::ReadMachHeader(addr_t addr, Process *process, llvm::M
if (::memcmp (&header.magic, &magicks[i], sizeof (uint32_t)) == 0)
found_matching_pattern = true;
- if (found_matching_pattern == false)
- return false;
+ if (!found_matching_pattern)
+ return false;
if (header.magic == llvm::MachO::MH_CIGAM ||
header.magic == llvm::MachO::MH_CIGAM_64) {
@@ -425,7 +438,7 @@ DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress(lldb::addr_t addr,
llvm::MachO::mach_header header;
- if (ReadMachHeader (addr, process, header) == false)
+ if (!ReadMachHeader(addr, process, header))
return UUID();
// First try a quick test -- read the first 4 bytes and see if there is a
@@ -436,8 +449,8 @@ DynamicLoaderDarwinKernel::CheckForKernelImageAtAddress(lldb::addr_t addr,
if (header.filetype == llvm::MachO::MH_EXECUTE &&
(header.flags & llvm::MachO::MH_DYLDLINK) == 0) {
// Create a full module to get the UUID
- ModuleSP memory_module_sp = process->ReadModuleFromMemory(
- FileSpec("temp_mach_kernel", false), addr);
+ ModuleSP memory_module_sp =
+ process->ReadModuleFromMemory(FileSpec("temp_mach_kernel"), addr);
if (!memory_module_sp.get())
return UUID();
@@ -605,16 +618,10 @@ void DynamicLoaderDarwinKernel::KextImageInfo::SetProcessStopId(
bool DynamicLoaderDarwinKernel::KextImageInfo::
operator==(const KextImageInfo &rhs) {
if (m_uuid.IsValid() || rhs.GetUUID().IsValid()) {
- if (m_uuid == rhs.GetUUID()) {
- return true;
- }
- return false;
+ return m_uuid == rhs.GetUUID();
}
- if (m_name == rhs.GetName() && m_load_address == rhs.GetLoadAddress())
- return true;
-
- return false;
+ return m_name == rhs.GetName() && m_load_address == rhs.GetLoadAddress();
}
void DynamicLoaderDarwinKernel::KextImageInfo::SetName(const char *name) {
@@ -647,16 +654,16 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::ReadMemoryModule(
if (m_load_address == LLDB_INVALID_ADDRESS)
return false;
- FileSpec file_spec;
- file_spec.SetFile(m_name.c_str(), false, FileSpec::Style::native);
+ FileSpec file_spec(m_name.c_str());
llvm::MachO::mach_header mh;
size_t size_to_read = 512;
- if (ReadMachHeader (m_load_address, process, mh)) {
- if (mh.magic == llvm::MachO::MH_CIGAM || llvm::MachO::MH_MAGIC)
- size_to_read = sizeof (llvm::MachO::mach_header) + mh.sizeofcmds;
- if (mh.magic == llvm::MachO::MH_CIGAM_64 || llvm::MachO::MH_MAGIC_64)
- size_to_read = sizeof (llvm::MachO::mach_header_64) + mh.sizeofcmds;
+ if (ReadMachHeader(m_load_address, process, mh)) {
+ if (mh.magic == llvm::MachO::MH_CIGAM || mh.magic == llvm::MachO::MH_MAGIC)
+ size_to_read = sizeof(llvm::MachO::mach_header) + mh.sizeofcmds;
+ if (mh.magic == llvm::MachO::MH_CIGAM_64 ||
+ mh.magic == llvm::MachO::MH_MAGIC_64)
+ size_to_read = sizeof(llvm::MachO::mach_header_64) + mh.sizeofcmds;
}
ModuleSP memory_module_sp =
@@ -732,7 +739,7 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::ReadMemoryModule(
}
bool DynamicLoaderDarwinKernel::KextImageInfo::IsKernel() const {
- return m_kernel_image == true;
+ return m_kernel_image;
}
void DynamicLoaderDarwinKernel::KextImageInfo::SetIsKernel(bool is_kernel) {
@@ -784,7 +791,7 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
// to do anything useful. This will force a clal to
if (IsKernel()) {
if (Symbols::DownloadObjectAndSymbolFile(module_spec, true)) {
- if (module_spec.GetFileSpec().Exists()) {
+ if (FileSystem::Instance().Exists(module_spec.GetFileSpec())) {
m_module_sp.reset(new Module(module_spec.GetFileSpec(),
target.GetArchitecture()));
if (m_module_sp.get() &&
@@ -807,7 +814,7 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
PlatformDarwinKernel::GetPluginNameStatic());
if (platform_name == g_platform_name) {
ModuleSpec kext_bundle_module_spec(module_spec);
- FileSpec kext_filespec(m_name.c_str(), false);
+ FileSpec kext_filespec(m_name.c_str());
kext_bundle_module_spec.GetFileSpec() = kext_filespec;
platform_sp->GetSharedModule(
kext_bundle_module_spec, process, m_module_sp,
@@ -847,7 +854,7 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
target.GetImages().AppendIfNeeded(m_module_sp);
if (IsKernel() &&
target.GetExecutableModulePointer() != m_module_sp.get()) {
- target.SetExecutableModule(m_module_sp, false);
+ target.SetExecutableModule(m_module_sp, eLoadDependentsNo);
}
}
}
@@ -932,7 +939,7 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
ObjectFile *kernel_object_file = m_module_sp->GetObjectFile();
if (kernel_object_file) {
addr_t file_address =
- kernel_object_file->GetHeaderAddress().GetFileAddress();
+ kernel_object_file->GetBaseAddress().GetFileAddress();
if (m_load_address != LLDB_INVALID_ADDRESS &&
file_address != LLDB_INVALID_ADDRESS) {
s->Printf("Kernel slid 0x%" PRIx64 " in memory.\n",
@@ -1006,10 +1013,10 @@ void DynamicLoaderDarwinKernel::LoadKernelModuleIfNeeded() {
ObjectFile *kernel_object_file = m_kernel.GetModule()->GetObjectFile();
if (kernel_object_file) {
addr_t load_address =
- kernel_object_file->GetHeaderAddress().GetLoadAddress(
+ kernel_object_file->GetBaseAddress().GetLoadAddress(
&m_process->GetTarget());
addr_t file_address =
- kernel_object_file->GetHeaderAddress().GetFileAddress();
+ kernel_object_file->GetBaseAddress().GetFileAddress();
if (load_address != LLDB_INVALID_ADDRESS && load_address != 0) {
m_kernel.SetLoadAddress(load_address);
if (load_address != file_address) {
@@ -1281,7 +1288,7 @@ bool DynamicLoaderDarwinKernel::ParseKextSummaries(
const uint32_t num_of_new_kexts = kext_summaries.size();
for (uint32_t new_kext = 0; new_kext < num_of_new_kexts; new_kext++) {
- if (to_be_added[new_kext] == true) {
+ if (to_be_added[new_kext]) {
KextImageInfo &image_info = kext_summaries[new_kext];
if (load_kexts) {
if (!image_info.LoadImageUsingMemoryModule(m_process)) {
diff --git a/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h b/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
index 75998f1cc3be..7aacebd9b50f 100644
--- a/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
+++ b/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
@@ -10,17 +10,13 @@
#ifndef liblldb_DynamicLoaderDarwinKernel_h_
#define liblldb_DynamicLoaderDarwinKernel_h_
-// C Includes
-// C++ Includes
#include <mutex>
#include <string>
#include <vector>
-// Other libraries and framework includes
-#include "lldb/Utility/SafeMachO.h"
+#include "lldb/Host/SafeMachO.h"
-// Project includes
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/Process.h"
#include "lldb/Utility/FileSpec.h"
diff --git a/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp b/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
index 5ca20229d018..81eab8fdd970 100644
--- a/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
+++ b/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
@@ -7,9 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
@@ -179,7 +176,7 @@ ModuleSP DynamicLoaderHexagonDYLD::GetTargetExecutable() {
return executable;
// The target executable file does not exits
- if (!executable->GetFileSpec().Exists())
+ if (!FileSystem::Instance().Exists(executable->GetFileSpec()))
return executable;
// Prep module for loading
@@ -205,8 +202,7 @@ ModuleSP DynamicLoaderHexagonDYLD::GetTargetExecutable() {
if (executable.get() != target.GetExecutableModulePointer()) {
// Don't load dependent images since we are in dyld where we will know and
// find out about all images that are loaded
- const bool get_dependent_images = false;
- target.SetExecutableModule(executable, get_dependent_images);
+ target.SetExecutableModule(executable, eLoadDependentsNo);
}
return executable;
@@ -368,7 +364,8 @@ void DynamicLoaderHexagonDYLD::RefreshModules() {
E = m_rendezvous.loaded_end();
for (I = m_rendezvous.loaded_begin(); I != E; ++I) {
- FileSpec file(I->path, true);
+ FileSpec file(I->path);
+ FileSystem::Instance().Resolve(file);
ModuleSP module_sp =
LoadModuleAtAddress(file, I->link_addr, I->base_addr, true);
if (module_sp.get()) {
@@ -392,7 +389,8 @@ void DynamicLoaderHexagonDYLD::RefreshModules() {
E = m_rendezvous.unloaded_end();
for (I = m_rendezvous.unloaded_begin(); I != E; ++I) {
- FileSpec file(I->path, true);
+ FileSpec file(I->path);
+ FileSystem::Instance().Resolve(file);
ModuleSpec module_spec(file);
ModuleSP module_sp = loaded_modules.FindFirstModule(module_spec);
@@ -455,7 +453,7 @@ DynamicLoaderHexagonDYLD::GetStepThroughTrampolinePlan(Thread &thread,
AddressVector::iterator start = addrs.begin();
AddressVector::iterator end = addrs.end();
- std::sort(start, end);
+ llvm::sort(start, end);
addrs.erase(std::unique(start, end), end);
thread_plan_sp.reset(new ThreadPlanRunToAddress(thread, addrs, stop));
}
@@ -486,7 +484,7 @@ void DynamicLoaderHexagonDYLD::LoadAllCurrentModules() {
for (I = m_rendezvous.begin(), E = m_rendezvous.end(); I != E; ++I) {
const char *module_path = I->path.c_str();
- FileSpec file(module_path, false);
+ FileSpec file(module_path);
ModuleSP module_sp =
LoadModuleAtAddress(file, I->link_addr, I->base_addr, true);
if (module_sp.get()) {
diff --git a/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h b/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h
index 200a4171bd1c..d39f14e8b3fb 100644
--- a/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h
+++ b/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h
@@ -10,10 +10,6 @@
#ifndef liblldb_DynamicLoaderHexagonDYLD_h_
#define liblldb_DynamicLoaderHexagonDYLD_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Target/DynamicLoader.h"
diff --git a/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h b/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
index bdf6bae75197..758f358dc618 100644
--- a/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
+++ b/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
@@ -10,14 +10,11 @@
#ifndef liblldb_HexagonDYLDRendezvous_H_
#define liblldb_HexagonDYLDRendezvous_H_
-// C Includes
-#include <limits.h> // for PATH_MAX
-// C++ Includes
+#include <limits.h>
#include <list>
#include <map>
#include <string>
-// Other libraries and framework includes
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index c6439a30c8a3..944be9633e00 100644
--- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -15,7 +15,6 @@
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/State.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Symbol/ClangASTContext.h"
@@ -32,6 +31,7 @@
#include "lldb/Utility/DataBuffer.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/State.h"
//#define ENABLE_DEBUG_PRINTF // COMMENT THIS LINE OUT PRIOR TO CHECKIN
#ifdef ENABLE_DEBUG_PRINTF
@@ -115,7 +115,7 @@ ModuleSP DynamicLoaderDarwin::FindTargetModuleForImageInfo(
// No UUID, we must rely upon the cached module modification time and the
// modification time of the file on disk
if (module_sp->GetModificationTime() !=
- FileSystem::GetModificationTime(module_sp->GetFileSpec()))
+ FileSystem::Instance().GetModificationTime(module_sp->GetFileSpec()))
module_sp.reset();
}
@@ -359,22 +359,24 @@ bool DynamicLoaderDarwin::JSONImageInformationIntoImageInfo(
if (image_sp.get() == nullptr || image_sp->GetAsDictionary() == nullptr)
return false;
StructuredData::Dictionary *image = image_sp->GetAsDictionary();
- if (image->HasKey("load_address") == false ||
- image->HasKey("pathname") == false ||
- image->HasKey("mod_date") == false ||
- image->HasKey("mach_header") == false ||
+ // clang-format off
+ if (!image->HasKey("load_address") ||
+ !image->HasKey("pathname") ||
+ !image->HasKey("mod_date") ||
+ !image->HasKey("mach_header") ||
image->GetValueForKey("mach_header")->GetAsDictionary() == nullptr ||
- image->HasKey("segments") == false ||
+ !image->HasKey("segments") ||
image->GetValueForKey("segments")->GetAsArray() == nullptr ||
- image->HasKey("uuid") == false) {
+ !image->HasKey("uuid")) {
return false;
}
+ // clang-format on
image_infos[i].address =
image->GetValueForKey("load_address")->GetAsInteger()->GetValue();
image_infos[i].mod_date =
image->GetValueForKey("mod_date")->GetAsInteger()->GetValue();
image_infos[i].file_spec.SetFile(
- image->GetValueForKey("pathname")->GetAsString()->GetValue(), false,
+ image->GetValueForKey("pathname")->GetAsString()->GetValue(),
FileSpec::Style::native);
StructuredData::Dictionary *mh =
@@ -400,6 +402,8 @@ bool DynamicLoaderDarwin::JSONImageInformationIntoImageInfo(
image_infos[i].os_type = llvm::Triple::TvOS;
else if (os_name == "watchos")
image_infos[i].os_type = llvm::Triple::WatchOS;
+ // NEED_BRIDGEOS_TRIPLE else if (os_name == "bridgeos")
+ // NEED_BRIDGEOS_TRIPLE image_infos[i].os_type = llvm::Triple::BridgeOS;
}
if (image->HasKey("min_version_os_sdk")) {
image_infos[i].min_version_os_sdk =
@@ -513,11 +517,12 @@ void DynamicLoaderDarwin::UpdateSpecialBinariesFromNewImageInfos(
const size_t image_infos_size = image_infos.size();
for (size_t i = 0; i < image_infos_size; i++) {
if (image_infos[i].header.filetype == llvm::MachO::MH_DYLINKER) {
- // In a "simulator" process (an x86 process that is ios/tvos/watchos) we
- // will have two dyld modules -- a "dyld" that we want to keep track of,
- // and a "dyld_sim" which we don't need to keep track of here. If the
- // target is an x86 system and the OS of the dyld binary is
- // ios/tvos/watchos, then we are looking at dyld_sym.
+ // In a "simulator" process (an x86 process that is
+ // ios/tvos/watchos/bridgeos) we will have two dyld modules --
+ // a "dyld" that we want to keep track of, and a "dyld_sim" which
+ // we don't need to keep track of here. If the target is an x86
+ // system and the OS of the dyld binary is ios/tvos/watchos/bridgeos,
+ // then we are looking at dyld_sym.
// debugserver has only recently (late 2016) started sending up the os
// type for each binary it sees -- so if we don't have an os type, use a
@@ -531,6 +536,7 @@ void DynamicLoaderDarwin::UpdateSpecialBinariesFromNewImageInfos(
if (image_infos[i].os_type != llvm::Triple::OSType::IOS &&
image_infos[i].os_type != llvm::Triple::TvOS &&
image_infos[i].os_type != llvm::Triple::WatchOS) {
+ // NEED_BRIDGEOS_TRIPLE image_infos[i].os_type != llvm::Triple::BridgeOS) {
dyld_idx = i;
}
}
@@ -555,8 +561,7 @@ void DynamicLoaderDarwin::UpdateSpecialBinariesFromNewImageInfos(
target.GetImages().AppendIfNeeded(exe_module_sp);
UpdateImageLoadAddress(exe_module_sp.get(), image_infos[exe_idx]);
if (exe_module_sp.get() != target.GetExecutableModulePointer()) {
- const bool get_dependent_images = false;
- target.SetExecutableModule(exe_module_sp, get_dependent_images);
+ target.SetExecutableModule(exe_module_sp, eLoadDependentsNo);
}
}
}
@@ -709,11 +714,7 @@ bool DynamicLoaderDarwin::AlwaysRelyOnEHUnwindInfo(SymbolContext &sym_ctx) {
return false;
ObjCLanguageRuntime *objc_runtime = m_process->GetObjCLanguageRuntime();
- if (objc_runtime != NULL && objc_runtime->IsModuleObjCLibrary(module_sp)) {
- return true;
- }
-
- return false;
+ return objc_runtime != NULL && objc_runtime->IsModuleObjCLibrary(module_sp);
}
//----------------------------------------------------------------------
@@ -1124,6 +1125,10 @@ bool DynamicLoaderDarwin::UseDYLDSPI(Process *process) {
// watchOS 3 and newer
if (os_type == llvm::Triple::WatchOS && version >= llvm::VersionTuple(3))
use_new_spi_interface = true;
+
+ // NEED_BRIDGEOS_TRIPLE // Any BridgeOS
+ // NEED_BRIDGEOS_TRIPLE if (os_type == llvm::Triple::BridgeOS)
+ // NEED_BRIDGEOS_TRIPLE use_new_spi_interface = true;
}
if (log) {
diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
index a02d1ad9bee3..690253ba5ff2 100644
--- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
+++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
@@ -10,18 +10,14 @@
#ifndef liblldb_DynamicLoaderDarwin_h_
#define liblldb_DynamicLoaderDarwin_h_
-// C Includes
-// C++ Includes
#include <map>
#include <mutex>
#include <vector>
-// Other libraries and framework includes
-// Project includes
+#include "lldb/Host/SafeMachO.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/Process.h"
#include "lldb/Utility/FileSpec.h"
-#include "lldb/Utility/SafeMachO.h"
#include "lldb/Utility/StructuredData.h"
#include "lldb/Utility/UUID.h"
diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
index 4a8ad38d1785..1ff0ec2c7937 100644
--- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
+++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
@@ -12,7 +12,6 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/State.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolVendor.h"
@@ -21,6 +20,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/State.h"
#include "DynamicLoaderDarwin.h"
#include "DynamicLoaderMacOS.h"
@@ -55,6 +55,7 @@ DynamicLoader *DynamicLoaderMacOS::CreateInstance(Process *process,
case llvm::Triple::IOS:
case llvm::Triple::TvOS:
case llvm::Triple::WatchOS:
+ // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
create = triple_ref.getVendor() == llvm::Triple::Apple;
break;
default:
@@ -64,7 +65,7 @@ DynamicLoader *DynamicLoaderMacOS::CreateInstance(Process *process,
}
}
- if (UseDYLDSPI(process) == false) {
+ if (!UseDYLDSPI(process)) {
create = false;
}
@@ -78,7 +79,8 @@ DynamicLoader *DynamicLoaderMacOS::CreateInstance(Process *process,
//----------------------------------------------------------------------
DynamicLoaderMacOS::DynamicLoaderMacOS(Process *process)
: DynamicLoaderDarwin(process), m_image_infos_stop_id(UINT32_MAX),
- m_break_id(LLDB_INVALID_BREAK_ID), m_mutex() {}
+ m_break_id(LLDB_INVALID_BREAK_ID), m_mutex(),
+ m_maybe_image_infos_address(LLDB_INVALID_ADDRESS) {}
//----------------------------------------------------------------------
// Destructor
@@ -94,16 +96,31 @@ bool DynamicLoaderMacOS::ProcessDidExec() {
if (m_process) {
// If we are stopped after an exec, we will have only one thread...
if (m_process->GetThreadList().GetSize() == 1) {
- // See if we are stopped at '_dyld_start'
- ThreadSP thread_sp(m_process->GetThreadList().GetThreadAtIndex(0));
- if (thread_sp) {
- lldb::StackFrameSP frame_sp(thread_sp->GetStackFrameAtIndex(0));
- if (frame_sp) {
- const Symbol *symbol =
- frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol;
- if (symbol) {
- if (symbol->GetName() == ConstString("_dyld_start"))
- did_exec = true;
+ // Maybe we still have an image infos address around? If so see
+ // if that has changed, and if so we have exec'ed.
+ if (m_maybe_image_infos_address != LLDB_INVALID_ADDRESS) {
+ lldb::addr_t image_infos_address = m_process->GetImageInfoAddress();
+ if (image_infos_address != m_maybe_image_infos_address) {
+ // We don't really have to reset this here, since we are going to
+ // call DoInitialImageFetch right away to handle the exec. But in
+ // case anybody looks at it in the meantime, it can't hurt.
+ m_maybe_image_infos_address = image_infos_address;
+ did_exec = true;
+ }
+ }
+
+ if (!did_exec) {
+ // See if we are stopped at '_dyld_start'
+ ThreadSP thread_sp(m_process->GetThreadList().GetThreadAtIndex(0));
+ if (thread_sp) {
+ lldb::StackFrameSP frame_sp(thread_sp->GetStackFrameAtIndex(0));
+ if (frame_sp) {
+ const Symbol *symbol =
+ frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol;
+ if (symbol) {
+ if (symbol->GetName() == ConstString("_dyld_start"))
+ did_exec = true;
+ }
}
}
}
@@ -179,6 +196,7 @@ void DynamicLoaderMacOS::DoInitialImageFetch() {
}
m_dyld_image_infos_stop_id = m_process->GetStopID();
+ m_maybe_image_infos_address = m_process->GetImageInfoAddress();
}
bool DynamicLoaderMacOS::NeedToDoInitialImageFetch() { return true; }
@@ -485,8 +503,7 @@ bool DynamicLoaderMacOS::GetSharedCacheInformation(
info_dict->GetValueForKey("shared_cache_uuid")->GetStringValue();
if (!uuid_str.empty())
uuid.SetFromStringRef(uuid_str);
- if (info_dict->GetValueForKey("no_shared_cache")->GetBooleanValue() ==
- false)
+ if (!info_dict->GetValueForKey("no_shared_cache")->GetBooleanValue())
using_shared_cache = eLazyBoolYes;
else
using_shared_cache = eLazyBoolNo;
diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h
index db90966e5615..6303c066511c 100644
--- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h
+++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
// This is the DynamicLoader plugin for Darwin (macOS / iPhoneOS / tvOS /
-// watchOS)
+// watchOS / BridgeOS)
// platforms late 2016 and newer, where lldb will call dyld SPI functions to get
// information about shared libraries, information about the shared cache, and
// the _dyld_debugger_notification function we put a breakpoint on give us an
@@ -18,17 +18,12 @@
#ifndef liblldb_DynamicLoaderMacOS_h_
#define liblldb_DynamicLoaderMacOS_h_
-// C Includes
-// C++ Includes
#include <mutex>
#include <vector>
-// Other libraries and framework includes
-// Project includes
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/Process.h"
#include "lldb/Utility/FileSpec.h"
-#include "lldb/Utility/SafeMachO.h"
#include "lldb/Utility/StructuredData.h"
#include "lldb/Utility/UUID.h"
@@ -109,6 +104,12 @@ protected:
// loaded/unloaded images
lldb::user_id_t m_break_id;
mutable std::recursive_mutex m_mutex;
+ lldb::addr_t m_maybe_image_infos_address; // If dyld is still maintaining the
+ // all_image_infos address, store it
+ // here so we can use it to detect
+ // exec's when talking to
+ // debugservers that don't support
+ // the "reason:exec" annotation.
private:
DISALLOW_COPY_AND_ASSIGN(DynamicLoaderMacOS);
diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index 265f19d0ca06..ec459a783f94 100644
--- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -13,7 +13,6 @@
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/State.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -27,6 +26,7 @@
#include "lldb/Utility/DataBuffer.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/State.h"
#include "DynamicLoaderDarwin.h"
#include "DynamicLoaderMacOSXDYLD.h"
@@ -75,6 +75,7 @@ DynamicLoader *DynamicLoaderMacOSXDYLD::CreateInstance(Process *process,
case llvm::Triple::IOS:
case llvm::Triple::TvOS:
case llvm::Triple::WatchOS:
+ // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
create = triple_ref.getVendor() == llvm::Triple::Apple;
break;
default:
@@ -84,7 +85,7 @@ DynamicLoader *DynamicLoaderMacOSXDYLD::CreateInstance(Process *process,
}
}
- if (UseDYLDSPI(process) == true) {
+ if (UseDYLDSPI(process)) {
create = false;
}
@@ -121,12 +122,12 @@ bool DynamicLoaderMacOSXDYLD::ProcessDidExec() {
// value differs from the Process' image info address. When a process
// execs itself it might cause a change if ASLR is enabled.
const addr_t shlib_addr = m_process->GetImageInfoAddress();
- if (m_process_image_addr_is_all_images_infos == true &&
+ if (m_process_image_addr_is_all_images_infos &&
shlib_addr != m_dyld_all_image_infos_addr) {
// The image info address from the process is the
// 'dyld_all_image_infos' address and it has changed.
did_exec = true;
- } else if (m_process_image_addr_is_all_images_infos == false &&
+ } else if (!m_process_image_addr_is_all_images_infos &&
shlib_addr == m_dyld.address) {
// The image info address from the process is the mach_header address
// for dyld and it has changed.
@@ -692,9 +693,7 @@ bool DynamicLoaderMacOSXDYLD::ReadImageInfos(
error);
// don't resolve the path
if (error.Success()) {
- const bool resolve_path = false;
- image_infos[i].file_spec.SetFile(raw_path, resolve_path,
- FileSpec::Style::native);
+ image_infos[i].file_spec.SetFile(raw_path, FileSpec::Style::native);
}
}
return true;
@@ -893,7 +892,8 @@ uint32_t DynamicLoaderMacOSXDYLD::ParseLoadCommands(const DataExtractor &data,
const lldb::offset_t name_offset =
load_cmd_offset + data.GetU32(&offset);
const char *path = data.PeekCStr(name_offset);
- lc_id_dylinker->SetFile(path, true, FileSpec::Style::native);
+ lc_id_dylinker->SetFile(path, FileSpec::Style::native);
+ FileSystem::Instance().Resolve(*lc_id_dylinker);
}
break;
@@ -975,9 +975,8 @@ void DynamicLoaderMacOSXDYLD::UpdateImageInfosHeaderAndLoadCommands(
// re-add it back to make sure it is always in the list.
ModuleSP dyld_module_sp(GetDYLDModule());
- const bool get_dependent_images = false;
m_process->GetTarget().SetExecutableModule(exe_module_sp,
- get_dependent_images);
+ eLoadDependentsNo);
if (dyld_module_sp) {
if (target.GetImages().AppendIfNeeded(dyld_module_sp)) {
diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
index 8b5052e4e230..3dc0f15bddf7 100644
--- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
+++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
// This is the DynamicLoader plugin for Darwin (macOS / iPhoneOS / tvOS /
-// watchOS)
+// watchOS / BridgeOS)
// platforms earlier than 2016, where lldb would read the "dyld_all_image_infos"
// dyld internal structure to understand where things were loaded and the
// solib loaded/unloaded notification function we put a breakpoint on gives us
@@ -21,17 +21,13 @@
#ifndef liblldb_DynamicLoaderMacOSXDYLD_h_
#define liblldb_DynamicLoaderMacOSXDYLD_h_
-// C Includes
-// C++ Includes
#include <mutex>
#include <vector>
-// Other libraries and framework includes
-// Project includes
+#include "lldb/Host/SafeMachO.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/Process.h"
#include "lldb/Utility/FileSpec.h"
-#include "lldb/Utility/SafeMachO.h"
#include "lldb/Utility/StructuredData.h"
#include "lldb/Utility/UUID.h"
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp b/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp
index 7dd2b57da0cb..8068795df53a 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp
@@ -100,7 +100,7 @@ const char *AuxVector::GetEntryName(EntryType type) {
#define ENTRY_NAME(_type) \
_type: \
- name = #_type + 5
+ name = &#_type[5]
switch (type) {
case ENTRY_NAME(AUXV_AT_NULL); break;
case ENTRY_NAME(AUXV_AT_IGNORE); break;
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.h b/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.h
index 3b06fe18f0c6..25446e33afd4 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.h
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.h
@@ -10,11 +10,8 @@
#ifndef liblldb_AuxVector_H_
#define liblldb_AuxVector_H_
-// C Includes
-// C++ Includes
#include <vector>
-// Other libraries and framework includes
#include "lldb/lldb-forward.h"
namespace lldb_private {
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
index b1513b51a90a..b30a1ab2cf1f 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -243,7 +243,7 @@ bool DYLDRendezvous::FillSOEntryFromModuleInfo(
entry.base_addr = base_addr;
entry.dyn_addr = dyn_addr;
- entry.file_spec.SetFile(name, false, FileSpec::Style::native);
+ entry.file_spec.SetFile(name, FileSpec::Style::native);
UpdateBaseAddrIfNecessary(entry, name);
@@ -455,14 +455,10 @@ static bool isLoadBiasIncorrect(Target &target, const std::string &file_path) {
// On Android L (API 21, 22) the load address of the "/system/bin/linker"
// isn't filled in correctly.
unsigned os_major = target.GetPlatform()->GetOSVersion().getMajor();
- if (target.GetArchitecture().GetTriple().isAndroid() &&
- (os_major == 21 || os_major == 22) &&
- (file_path == "/system/bin/linker" ||
- file_path == "/system/bin/linker64")) {
- return true;
- }
-
- return false;
+ return target.GetArchitecture().GetTriple().isAndroid() &&
+ (os_major == 21 || os_major == 22) &&
+ (file_path == "/system/bin/linker" ||
+ file_path == "/system/bin/linker64");
}
void DYLDRendezvous::UpdateBaseAddrIfNecessary(SOEntry &entry,
@@ -517,7 +513,7 @@ bool DYLDRendezvous::ReadSOEntryFromMemory(lldb::addr_t addr, SOEntry &entry) {
return false;
std::string file_path = ReadStringFromMemory(entry.path_addr);
- entry.file_spec.SetFile(file_path, false, FileSpec::Style::native);
+ entry.file_spec.SetFile(file_path, FileSpec::Style::native);
UpdateBaseAddrIfNecessary(entry, file_path);
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
index a7071801f569..f1a62c3bf9d8 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
@@ -10,12 +10,9 @@
#ifndef liblldb_Rendezvous_H_
#define liblldb_Rendezvous_H_
-// C Includes
-// C++ Includes
#include <list>
#include <string>
-// Other libraries and framework includes
#include "lldb/Utility/FileSpec.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index 26825d879f04..6774b4fd1291 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -10,10 +10,8 @@
// Main header include
#include "DynamicLoaderPOSIXDYLD.h"
-// Project includes
#include "AuxVector.h"
-// Other libraries and framework includes
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
@@ -29,8 +27,6 @@
#include "lldb/Target/ThreadPlanRunToAddress.h"
#include "lldb/Utility/Log.h"
-// C++ Includes
-// C Includes
using namespace lldb;
using namespace lldb_private;
@@ -121,7 +117,7 @@ void DynamicLoaderPOSIXDYLD::DidAttach() {
EvalSpecialModulesStatus();
// if we dont have a load address we cant re-base
- bool rebase_exec = (load_offset == LLDB_INVALID_ADDRESS) ? false : true;
+ bool rebase_exec = load_offset != LLDB_INVALID_ADDRESS;
// if we have a valid executable
if (executable_sp.get()) {
@@ -500,7 +496,7 @@ DynamicLoaderPOSIXDYLD::GetStepThroughTrampolinePlan(Thread &thread,
AddressVector::iterator start = addrs.begin();
AddressVector::iterator end = addrs.end();
- std::sort(start, end);
+ llvm::sort(start, end);
addrs.erase(std::unique(start, end), end);
thread_plan_sp.reset(new ThreadPlanRunToAddress(thread, addrs, stop));
}
@@ -512,7 +508,7 @@ void DynamicLoaderPOSIXDYLD::LoadVDSO() {
if (m_vdso_base == LLDB_INVALID_ADDRESS)
return;
- FileSpec file("[vdso]", false);
+ FileSpec file("[vdso]");
MemoryRegionInfo info;
Status status = m_process->GetMemoryRegionInfo(m_vdso_base, info);
@@ -543,7 +539,7 @@ ModuleSP DynamicLoaderPOSIXDYLD::LoadInterpreterModule() {
return nullptr;
}
- FileSpec file(info.GetName().GetCString(), false);
+ FileSpec file(info.GetName().GetCString());
ModuleSpec module_spec(file, target.GetArchitecture());
if (ModuleSP module_sp = target.GetSharedModule(module_spec)) {
@@ -756,7 +752,7 @@ void DynamicLoaderPOSIXDYLD::ResolveExecutableModule(
return;
}
- target.SetExecutableModule(module_sp, false);
+ target.SetExecutableModule(module_sp, eLoadDependentsNo);
}
bool DynamicLoaderPOSIXDYLD::AlwaysRelyOnEHUnwindInfo(
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
index 0456baf4a658..c5f2d3bcffbc 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
@@ -10,13 +10,9 @@
#ifndef liblldb_DynamicLoaderPOSIXDYLD_h_
#define liblldb_DynamicLoaderPOSIXDYLD_h_
-// C Includes
-// C++ Includes
#include <map>
#include <memory>
-// Other libraries and framework includes
-// Project includes
#include "DYLDRendezvous.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/ModuleList.h"
diff --git a/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h b/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h
index 2d18ec86afd3..7f8f82c76f72 100644
--- a/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h
+++ b/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h
@@ -10,10 +10,6 @@
#ifndef liblldb_DynamicLoaderStatic_h_
#define liblldb_DynamicLoaderStatic_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/Process.h"
#include "lldb/Utility/FileSpec.h"
diff --git a/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp b/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
index 6502d7a7a58c..9405b1a5cfdc 100644
--- a/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
+++ b/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
@@ -10,12 +10,14 @@
#include "DynamicLoaderWindowsDYLD.h"
+#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadPlanStepInstruction.h"
+#include "lldb/Utility/Log.h"
#include "llvm/ADT/Triple.h"
@@ -60,7 +62,39 @@ DynamicLoader *DynamicLoaderWindowsDYLD::CreateInstance(Process *process,
return nullptr;
}
-void DynamicLoaderWindowsDYLD::DidAttach() {}
+void DynamicLoaderWindowsDYLD::DidAttach() {
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
+ if (log)
+ log->Printf("DynamicLoaderWindowsDYLD::%s()", __FUNCTION__);
+
+ ModuleSP executable = GetTargetExecutable();
+
+ if (!executable.get())
+ return;
+
+ // Try to fetch the load address of the file from the process, since there
+ // could be randomization of the load address.
+
+ // It might happen that the remote has a different dir for the file, so we
+ // only send the basename of the executable in the query. I think this is safe
+ // because I doubt that two executables with the same basenames are loaded in
+ // memory...
+ FileSpec file_spec(
+ executable->GetPlatformFileSpec().GetFilename().GetCString());
+ bool is_loaded;
+ addr_t base_addr = 0;
+ lldb::addr_t load_addr;
+ Status error = m_process->GetFileLoadAddress(file_spec, is_loaded, load_addr);
+ if (error.Success() && is_loaded) {
+ base_addr = load_addr;
+ UpdateLoadedSections(executable, LLDB_INVALID_ADDRESS, base_addr, false);
+ }
+
+ ModuleList module_list;
+ module_list.Append(executable);
+ m_process->GetTarget().ModulesDidLoad(module_list);
+ m_process->LoadModules();
+}
void DynamicLoaderWindowsDYLD::DidLaunch() {}
diff --git a/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h b/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
index de6e295f7891..342b32b10927 100644
--- a/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
+++ b/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
@@ -10,10 +10,6 @@
#ifndef liblldb_Plugins_Process_Windows_DynamicLoaderWindowsDYLD_h_
#define liblldb_Plugins_Process_Windows_DynamicLoaderWindowsDYLD_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Target/DynamicLoader.h"
#include "lldb/lldb-forward.h"
diff --git a/source/Plugins/ExpressionParser/CMakeLists.txt b/source/Plugins/ExpressionParser/CMakeLists.txt
index dc0540ad30a1..17c40aee44cc 100644
--- a/source/Plugins/ExpressionParser/CMakeLists.txt
+++ b/source/Plugins/ExpressionParser/CMakeLists.txt
@@ -1,2 +1 @@
add_subdirectory(Clang)
-add_subdirectory(Go)
diff --git a/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp b/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
index fa49a51f32a6..c2bc18a04e95 100644
--- a/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -87,7 +87,8 @@ void ASTResultSynthesizer::TransformTopLevelDecl(Decl *D) {
SynthesizeObjCMethodResult(method_decl);
}
} else if (FunctionDecl *function_decl = dyn_cast<FunctionDecl>(D)) {
- if (m_ast_context &&
+ // When completing user input the body of the function may be a nullptr.
+ if (m_ast_context && function_decl->hasBody() &&
!function_decl->getNameInfo().getAsString().compare("$__lldb_expr")) {
RecordPersistentTypes(function_decl);
SynthesizeFunctionResult(function_decl);
diff --git a/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index d98a2b25fbb7..84771e59531d 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -332,11 +332,9 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
TypeList types;
- SymbolContext null_sc;
ConstString name(tag_decl->getName().str().c_str());
- i->first->FindTypesInNamespace(null_sc, name, &i->second, UINT32_MAX,
- types);
+ i->first->FindTypesInNamespace(name, &i->second, UINT32_MAX, types);
for (uint32_t ti = 0, te = types.GetSize(); ti != te && !found; ++ti) {
lldb::TypeSP type = types.GetTypeAtIndex(ti);
@@ -366,7 +364,6 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
} else {
TypeList types;
- SymbolContext null_sc;
ConstString name(tag_decl->getName().str().c_str());
CompilerDeclContext namespace_decl;
@@ -374,7 +371,7 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
bool exact_match = false;
llvm::DenseSet<SymbolFile *> searched_symbol_files;
- module_list.FindTypes(null_sc, name, exact_match, UINT32_MAX,
+ module_list.FindTypes(nullptr, name, exact_match, UINT32_MAX,
searched_symbol_files, types);
for (uint32_t ti = 0, te = types.GetSize(); ti != te && !found; ++ti) {
@@ -771,18 +768,16 @@ bool ClangASTSource::IgnoreName(const ConstString name,
static const ConstString id_name("id");
static const ConstString Class_name("Class");
- if (name == id_name || name == Class_name)
- return true;
+ if (m_ast_context->getLangOpts().ObjC)
+ if (name == id_name || name == Class_name)
+ return true;
StringRef name_string_ref = name.GetStringRef();
// The ClangASTSource is not responsible for finding $-names.
- if (name_string_ref.empty() ||
- (ignore_all_dollar_names && name_string_ref.startswith("$")) ||
- name_string_ref.startswith("_$"))
- return true;
-
- return false;
+ return name_string_ref.empty() ||
+ (ignore_all_dollar_names && name_string_ref.startswith("$")) ||
+ name_string_ref.startswith("_$");
}
void ClangASTSource::FindExternalVisibleDecls(
@@ -804,10 +799,8 @@ void ClangASTSource::FindExternalVisibleDecls(
SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor();
if (symbol_vendor) {
- SymbolContext null_sc;
-
found_namespace_decl =
- symbol_vendor->FindNamespace(null_sc, name, &namespace_decl);
+ symbol_vendor->FindNamespace(name, &namespace_decl);
if (found_namespace_decl) {
context.m_namespace_map->push_back(
@@ -837,10 +830,8 @@ void ClangASTSource::FindExternalVisibleDecls(
if (!symbol_vendor)
continue;
- SymbolContext null_sc;
-
found_namespace_decl =
- symbol_vendor->FindNamespace(null_sc, name, &namespace_decl);
+ symbol_vendor->FindNamespace(name, &namespace_decl);
if (found_namespace_decl) {
context.m_namespace_map->push_back(
@@ -860,15 +851,12 @@ void ClangASTSource::FindExternalVisibleDecls(
break;
TypeList types;
- SymbolContext null_sc;
const bool exact_match = true;
llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
if (module_sp && namespace_decl)
- module_sp->FindTypesInNamespace(null_sc, name, &namespace_decl, 1, types);
+ module_sp->FindTypesInNamespace(name, &namespace_decl, 1, types);
else {
- SymbolContext sc;
- sc.module_sp = module_sp;
- m_target->GetImages().FindTypes(sc, name, exact_match, 1,
+ m_target->GetImages().FindTypes(module_sp.get(), name, exact_match, 1,
searched_symbol_files, types);
}
@@ -1655,10 +1643,10 @@ static bool ImportOffsetMap(llvm::DenseMap<const D *, O> &destination_map,
std::vector<PairType> sorted_items;
sorted_items.reserve(source_map.size());
sorted_items.assign(source_map.begin(), source_map.end());
- std::sort(sorted_items.begin(), sorted_items.end(),
- [](const PairType &lhs, const PairType &rhs) {
- return lhs.second < rhs.second;
- });
+ llvm::sort(sorted_items.begin(), sorted_items.end(),
+ [](const PairType &lhs, const PairType &rhs) {
+ return lhs.second < rhs.second;
+ });
for (const auto &item : sorted_items) {
DeclFromUser<D> user_decl(const_cast<D *>(item.first));
@@ -1883,10 +1871,8 @@ void ClangASTSource::CompleteNamespaceMap(
if (!symbol_vendor)
continue;
- SymbolContext null_sc;
-
- found_namespace_decl = symbol_vendor->FindNamespace(
- null_sc, name, &module_parent_namespace_decl);
+ found_namespace_decl =
+ symbol_vendor->FindNamespace(name, &module_parent_namespace_decl);
if (!found_namespace_decl)
continue;
@@ -1918,10 +1904,8 @@ void ClangASTSource::CompleteNamespaceMap(
if (!symbol_vendor)
continue;
- SymbolContext null_sc;
-
found_namespace_decl =
- symbol_vendor->FindNamespace(null_sc, name, &null_namespace_decl);
+ symbol_vendor->FindNamespace(name, &null_namespace_decl);
if (!found_namespace_decl)
continue;
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index 0811a7999920..9c2f8c4b6c92 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -17,7 +17,6 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
-#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Expression/Materializer.h"
@@ -44,6 +43,7 @@
#include "lldb/Target/Thread.h"
#include "lldb/Utility/Endian.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegisterValue.h"
#include "lldb/Utility/Status.h"
#include "lldb/lldb-private.h"
#include "clang/AST/ASTConsumer.h"
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h b/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
index b67387930190..93fa57876bce 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
@@ -10,18 +10,14 @@
#ifndef liblldb_ClangExpressionDeclMap_h_
#define liblldb_ClangExpressionDeclMap_h_
-// C Includes
#include <signal.h>
#include <stdint.h>
-// C++ Includes
#include <vector>
#include "ClangASTSource.h"
#include "ClangExpressionVariable.h"
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/ClangForward.h"
#include "lldb/Core/Value.h"
#include "lldb/Expression/Materializer.h"
@@ -325,12 +321,6 @@ public:
/// @param[in] namespace_decl
/// If valid and module is non-NULL, the parent namespace.
///
- /// @param[in] name
- /// The name as a plain C string. The NameSearchContext contains
- /// a DeclarationName for the name so at first the name may seem
- /// redundant, but ClangExpressionDeclMap operates in RTTI land so
- /// it can't access DeclarationName.
- ///
/// @param[in] current_id
/// The ID for the current FindExternalVisibleDecls invocation,
/// for logging purposes.
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h b/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h
index e0d3ace15bd1..b5b640c9185f 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h
@@ -10,14 +10,10 @@
#ifndef liblldb_ClangExpression_h_
#define liblldb_ClangExpression_h_
-// C Includes
-// C++ Includes
#include <map>
#include <string>
#include <vector>
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/ClangForward.h"
#include "lldb/Expression/ExpressionTypeSystemHelper.h"
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index c5406fcc3340..6650c0db967f 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -7,12 +7,11 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
+#include <cctype>
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTDiagnostic.h"
#include "clang/AST/ExternalASTSource.h"
+#include "clang/AST/PrettyPrinter.h"
#include "clang/Basic/DiagnosticIDs.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceLocation.h"
@@ -34,6 +33,8 @@
#include "clang/Parse/ParseAST.h"
#include "clang/Rewrite/Core/Rewriter.h"
#include "clang/Rewrite/Frontend/FrontendActions.h"
+#include "clang/Sema/CodeCompleteConsumer.h"
+#include "clang/Sema/Sema.h"
#include "clang/Sema/SemaConsumer.h"
#include "llvm/ADT/StringRef.h"
@@ -55,7 +56,6 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Signals.h"
-// Project includes
#include "ClangDiagnostic.h"
#include "ClangExpressionParser.h"
@@ -222,7 +222,7 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope,
Expression &expr,
bool generate_debug_info)
: ExpressionParser(exe_scope, expr, generate_debug_info), m_compiler(),
- m_code_generator(), m_pp_callbacks(nullptr) {
+ m_pp_callbacks(nullptr) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
// We can't compile expressions without a target. So if the exe_scope is
@@ -377,8 +377,7 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope,
m_compiler->getLangOpts().CPlusPlus = true;
break;
case lldb::eLanguageTypeObjC:
- m_compiler->getLangOpts().ObjC1 = true;
- m_compiler->getLangOpts().ObjC2 = true;
+ m_compiler->getLangOpts().ObjC = true;
// FIXME: the following language option is a temporary workaround,
// to "ask for ObjC, get ObjC++" (see comment above).
m_compiler->getLangOpts().CPlusPlus = true;
@@ -399,16 +398,14 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope,
LLVM_FALLTHROUGH;
case lldb::eLanguageTypeC_plus_plus_03:
m_compiler->getLangOpts().CPlusPlus = true;
- // FIXME: the following language option is a temporary workaround,
- // to "ask for C++, get ObjC++". Apple hopes to remove this requirement on
- // non-Apple platforms, but for now it is needed.
- m_compiler->getLangOpts().ObjC1 = true;
+ if (process_sp)
+ m_compiler->getLangOpts().ObjC =
+ process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC) != nullptr;
break;
case lldb::eLanguageTypeObjC_plus_plus:
case lldb::eLanguageTypeUnknown:
default:
- m_compiler->getLangOpts().ObjC1 = true;
- m_compiler->getLangOpts().ObjC2 = true;
+ m_compiler->getLangOpts().ObjC = true;
m_compiler->getLangOpts().CPlusPlus = true;
m_compiler->getLangOpts().CPlusPlus11 = true;
m_compiler->getHeaderSearchOpts().UseLibcxx = true;
@@ -432,7 +429,7 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope,
// long time parsing and importing debug information.
m_compiler->getLangOpts().SpellChecking = false;
- if (process_sp && m_compiler->getLangOpts().ObjC1) {
+ if (process_sp && m_compiler->getLangOpts().ObjC) {
if (process_sp->GetObjCLanguageRuntime()) {
if (process_sp->GetObjCLanguageRuntime()->GetRuntimeVersion() ==
ObjCLanguageRuntime::ObjCRuntimeVersions::eAppleObjC_V2)
@@ -452,6 +449,10 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope,
false; // Debuggers get universal access
m_compiler->getLangOpts().DollarIdents =
true; // $ indicates a persistent variable name
+ // We enable all builtin functions beside the builtins from libc/libm (e.g.
+ // 'fopen'). Those libc functions are already correctly handled by LLDB, and
+ // additionally enabling them as expandable builtins is breaking Clang.
+ m_compiler->getLangOpts().NoBuiltin = true;
// Set CodeGen options
m_compiler->getCodeGenOpts().EmitDeclMetadata = true;
@@ -507,15 +508,14 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope,
// 8. Most of this we get from the CompilerInstance, but we also want to give
// the context an ExternalASTSource.
- m_selector_table.reset(new SelectorTable());
- m_builtin_context.reset(new Builtin::Context());
- std::unique_ptr<clang::ASTContext> ast_context(
- new ASTContext(m_compiler->getLangOpts(), m_compiler->getSourceManager(),
- m_compiler->getPreprocessor().getIdentifierTable(),
- *m_selector_table.get(), *m_builtin_context.get()));
+ auto &PP = m_compiler->getPreprocessor();
+ auto &builtin_context = PP.getBuiltinInfo();
+ builtin_context.initializeBuiltins(PP.getIdentifierTable(),
+ m_compiler->getLangOpts());
- ast_context->InitBuiltinTypes(m_compiler->getTarget());
+ m_compiler->createASTContext();
+ clang::ASTContext &ast_context = m_compiler->getASTContext();
ClangExpressionHelper *type_system_helper =
dyn_cast<ClangExpressionHelper>(m_expr.GetTypeSystemHelper());
@@ -524,14 +524,13 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope,
if (decl_map) {
llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> ast_source(
decl_map->CreateProxy());
- decl_map->InstallASTContext(*ast_context, m_compiler->getFileManager());
- ast_context->setExternalSource(ast_source);
+ decl_map->InstallASTContext(ast_context, m_compiler->getFileManager());
+ ast_context.setExternalSource(ast_source);
}
m_ast_context.reset(
new ClangASTContext(m_compiler->getTargetOpts().Triple.c_str()));
- m_ast_context->setASTContext(ast_context.get());
- m_compiler->setASTContext(ast_context.release());
+ m_ast_context->setASTContext(&ast_context);
std::string module_name("$__lldb_module");
@@ -544,7 +543,270 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope,
ClangExpressionParser::~ClangExpressionParser() {}
+namespace {
+
+//----------------------------------------------------------------------
+/// @class CodeComplete
+///
+/// A code completion consumer for the clang Sema that is responsible for
+/// creating the completion suggestions when a user requests completion
+/// of an incomplete `expr` invocation.
+//----------------------------------------------------------------------
+class CodeComplete : public CodeCompleteConsumer {
+ CodeCompletionTUInfo m_info;
+
+ 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;
+
+ /// 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.
+ ///
+ /// Note: lldb uses '$' in its internal identifiers, so we also allow this.
+ static bool IsIdChar(char c) {
+ return c == '_' || std::isalnum(c) || c == '$';
+ }
+
+ /// Returns true if the given character is used to separate arguments
+ /// in the command line of lldb.
+ static bool IsTokenSeparator(char c) { return c == ' ' || c == '\t'; }
+
+ /// 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) {
+ if (cmd.empty())
+ return cmd;
+
+ // If we are at the start of a word, then all tokens are unrelated to
+ // the current completion logic.
+ if (IsTokenSeparator(cmd.back()))
+ return StringRef();
+
+ // Remove all previous tokens from the string as they are unrelated
+ // to completing the current token.
+ StringRef to_remove = cmd;
+ while (!to_remove.empty() && !IsTokenSeparator(to_remove.back())) {
+ to_remove = to_remove.drop_back();
+ }
+ cmd = cmd.drop_front(to_remove.size());
+
+ return cmd;
+ }
+
+ /// Removes the last identifier token from the given cmd line.
+ StringRef removeLastToken(StringRef cmd) {
+ while (!cmd.empty() && IsIdChar(cmd.back())) {
+ cmd = cmd.drop_back();
+ }
+ return cmd;
+ }
+
+ /// Attemps 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 existing_command = existing.substr(0, pos);
+ // We rewrite the last token with the completion, so let's drop that
+ // token from the command.
+ existing_command = removeLastToken(existing_command);
+ // We also should remove all previous tokens from the command as they
+ // would otherwise be added to the completion that already has the
+ // completion.
+ existing_command = dropUnrelatedFrontTokens(existing_command);
+ return existing_command.str() + completion.str();
+ }
+
+public:
+ /// Constructs a CodeComplete consumer that can be attached to a Sema.
+ /// @param[out] matches
+ /// The list of matches that the lldb completion API expects as a result.
+ /// This may already contain matches, so it's only allowed to append
+ /// to this variable.
+ /// @param[out] expr
+ /// The whole expression string that we are currently parsing. This
+ /// string needs to be equal to the input the user typed, and NOT the
+ /// final code that Clang is parsing.
+ /// @param[out] position
+ /// The character position of the user cursor in the `expr` parameter.
+ ///
+ CodeComplete(CompletionRequest &request, clang::LangOptions ops,
+ std::string expr, unsigned position)
+ : CodeCompleteConsumer(CodeCompleteOptions(), false),
+ m_info(std::make_shared<GlobalCodeCompletionAllocator>()), m_expr(expr),
+ m_position(position), m_request(request), m_desc_policy(ops) {
+
+ // Ensure that the printing policy is producing a description that is as
+ // short as possible.
+ m_desc_policy.SuppressScope = true;
+ m_desc_policy.SuppressTagKeyword = true;
+ m_desc_policy.FullyQualifiedName = false;
+ m_desc_policy.TerseOutput = true;
+ m_desc_policy.IncludeNewlines = false;
+ m_desc_policy.UseVoidForZeroParams = false;
+ m_desc_policy.Bool = true;
+ }
+
+ /// Deregisters and destroys this code-completion consumer.
+ virtual ~CodeComplete() {}
+
+ /// \name Code-completion filtering
+ /// Check if the result should be filtered out.
+ bool isResultFilteredOut(StringRef Filter,
+ CodeCompletionResult Result) override {
+ // This code is mostly copied from CodeCompleteConsumer.
+ switch (Result.Kind) {
+ case CodeCompletionResult::RK_Declaration:
+ return !(
+ Result.Declaration->getIdentifier() &&
+ Result.Declaration->getIdentifier()->getName().startswith(Filter));
+ case CodeCompletionResult::RK_Keyword:
+ return !StringRef(Result.Keyword).startswith(Filter);
+ case CodeCompletionResult::RK_Macro:
+ return !Result.Macro->getName().startswith(Filter);
+ case CodeCompletionResult::RK_Pattern:
+ return !StringRef(Result.Pattern->getAsString()).startswith(Filter);
+ }
+ // If we trigger this assert or the above switch yields a warning, then
+ // CodeCompletionResult has been enhanced with more kinds of completion
+ // results. Expand the switch above in this case.
+ assert(false && "Unknown completion result type?");
+ // If we reach this, then we should just ignore whatever kind of unknown
+ // result we got back. We probably can't turn it into any kind of useful
+ // completion suggestion with the existing code.
+ return true;
+ }
+
+ /// \name Code-completion callbacks
+ /// Process the finalized code-completion results.
+ void ProcessCodeCompleteResults(Sema &SemaRef, CodeCompletionContext Context,
+ CodeCompletionResult *Results,
+ unsigned NumResults) override {
+
+ // The Sema put the incomplete token we try to complete in here during
+ // lexing, so we need to retrieve it here to know what we are completing.
+ StringRef Filter = SemaRef.getPreprocessor().getCodeCompletionFilter();
+
+ // Iterate over all the results. Filter out results we don't want and
+ // process the rest.
+ for (unsigned I = 0; I != NumResults; ++I) {
+ // Filter the results with the information from the Sema.
+ if (!Filter.empty() && isResultFilteredOut(Filter, Results[I]))
+ 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_"))
+ 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);
+ }
+ }
+ }
+
+ /// \param S the semantic-analyzer object for which code-completion is being
+ /// done.
+ ///
+ /// \param CurrentArg the index of the current argument.
+ ///
+ /// \param Candidates an array of overload candidates.
+ ///
+ /// \param NumCandidates the number of overload candidates
+ void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg,
+ OverloadCandidate *Candidates,
+ unsigned NumCandidates,
+ SourceLocation OpenParLoc) override {
+ // At the moment we don't filter out any overloaded candidates.
+ }
+
+ CodeCompletionAllocator &getAllocator() override {
+ return m_info.getAllocator();
+ }
+
+ CodeCompletionTUInfo &getCodeCompletionTUInfo() override { return m_info; }
+};
+} // namespace
+
+bool ClangExpressionParser::Complete(CompletionRequest &request, unsigned line,
+ unsigned pos, unsigned typed_pos) {
+ DiagnosticManager mgr;
+ // We need the raw user expression here because that's what the CodeComplete
+ // class uses to provide completion suggestions.
+ // However, the `Text` method only gives us the transformed expression here.
+ // To actually get the raw user input here, we have to cast our expression to
+ // the LLVMUserExpression which exposes the right API. This should never fail
+ // as we always have a ClangUserExpression whenever we call this.
+ LLVMUserExpression &llvm_expr = *static_cast<LLVMUserExpression *>(&m_expr);
+ CodeComplete CC(request, m_compiler->getLangOpts(), llvm_expr.GetUserText(),
+ 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);
+ return true;
+}
+
unsigned ClangExpressionParser::Parse(DiagnosticManager &diagnostic_manager) {
+ return ParseInternal(diagnostic_manager);
+}
+
+unsigned
+ClangExpressionParser::ParseInternal(DiagnosticManager &diagnostic_manager,
+ CodeCompleteConsumer *completion_consumer,
+ unsigned completion_line,
+ unsigned completion_column) {
ClangDiagnosticManagerAdapter *adapter =
static_cast<ClangDiagnosticManagerAdapter *>(
m_compiler->getDiagnostics().getClient());
@@ -557,10 +819,20 @@ unsigned ClangExpressionParser::Parse(DiagnosticManager &diagnostic_manager) {
clang::SourceManager &source_mgr = m_compiler->getSourceManager();
bool created_main_file = false;
- if (m_compiler->getCodeGenOpts().getDebugInfo() ==
- codegenoptions::FullDebugInfo) {
+
+ // Clang wants to do completion on a real file known by Clang's file manager,
+ // so we have to create one to make this work.
+ // TODO: We probably could also simulate to Clang's file manager that there
+ // is a real file that contains our code.
+ bool should_create_file = completion_consumer != nullptr;
+
+ // We also want a real file on disk if we generate full debug info.
+ should_create_file |= m_compiler->getCodeGenOpts().getDebugInfo() ==
+ codegenoptions::FullDebugInfo;
+
+ if (should_create_file) {
int temp_fd = -1;
- llvm::SmallString<PATH_MAX> result_path;
+ llvm::SmallString<128> result_path;
if (FileSpec tmpdir_file_spec = HostInfo::GetProcessTempDir()) {
tmpdir_file_spec.AppendPathComponent("lldb-%%%%%%.expr");
std::string temp_source_path = tmpdir_file_spec.GetPath();
@@ -603,14 +875,30 @@ unsigned ClangExpressionParser::Parse(DiagnosticManager &diagnostic_manager) {
if (ClangExpressionDeclMap *decl_map = type_system_helper->DeclMap())
decl_map->InstallCodeGenerator(m_code_generator.get());
+ // If we want to parse for code completion, we need to attach our code
+ // completion consumer to the Sema and specify a completion position.
+ // While parsing the Sema will call this consumer with the provided
+ // completion suggestions.
+ if (completion_consumer) {
+ auto main_file = source_mgr.getFileEntryForID(source_mgr.getMainFileID());
+ auto &PP = m_compiler->getPreprocessor();
+ // Lines and columns start at 1 in Clang, but code completion positions are
+ // indexed from 0, so we need to add 1 to the line and column here.
+ ++completion_line;
+ ++completion_column;
+ PP.SetCodeCompletionPoint(main_file, completion_line, completion_column);
+ }
+
if (ast_transformer) {
ast_transformer->Initialize(m_compiler->getASTContext());
ParseAST(m_compiler->getPreprocessor(), ast_transformer,
- m_compiler->getASTContext());
+ m_compiler->getASTContext(), false, TU_Complete,
+ completion_consumer);
} else {
m_code_generator->Initialize(m_compiler->getASTContext());
ParseAST(m_compiler->getPreprocessor(), m_code_generator.get(),
- m_compiler->getASTContext());
+ m_compiler->getASTContext(), false, TU_Complete,
+ completion_consumer);
}
diag_buf->EndSourceFile();
@@ -891,9 +1179,9 @@ lldb_private::Status ClangExpressionParser::PrepareForExecution(
if (!dynamic_checkers->Install(install_diagnostics, exe_ctx)) {
if (install_diagnostics.Diagnostics().size())
- err.SetErrorString("couldn't install checkers, unknown error");
- else
err.SetErrorString(install_diagnostics.GetString().c_str());
+ else
+ err.SetErrorString("couldn't install checkers, unknown error");
return err;
}
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
index 4058ec1270b3..03ff55f614d5 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
@@ -20,6 +20,10 @@
#include <string>
#include <vector>
+namespace clang {
+class CodeCompleteConsumer;
+}
+
namespace lldb_private {
class IRExecutionUnit;
@@ -58,6 +62,9 @@ public:
//------------------------------------------------------------------
~ClangExpressionParser() override;
+ bool Complete(CompletionRequest &request, unsigned line, unsigned pos,
+ unsigned typed_pos) override;
+
//------------------------------------------------------------------
/// Parse a single expression and convert it to IR using Clang. Don't wrap
/// the expression in anything at all.
@@ -143,16 +150,39 @@ public:
std::string GetClangTargetABI(const ArchSpec &target_arch);
private:
+ //------------------------------------------------------------------
+ /// Parses the expression.
+ ///
+ /// @param[in] diagnostic_manager
+ /// The diagnostic manager that should receive the diagnostics
+ /// from the parsing process.
+ ///
+ /// @param[in] completion
+ /// The completion consumer that should be used during parsing
+ /// (or a nullptr if no consumer should be attached).
+ ///
+ /// @param[in] completion_line
+ /// The line in which the completion marker should be placed.
+ /// The first line is represented by the value 0.
+ ///
+ /// @param[in] completion_column
+ /// The column in which the completion marker should be placed.
+ /// The first column is represented by the value 0.
+ ///
+ /// @return
+ /// The number of parsing errors.
+ //-------------------------------------------------------------------
+ unsigned ParseInternal(DiagnosticManager &diagnostic_manager,
+ clang::CodeCompleteConsumer *completion = nullptr,
+ unsigned completion_line = 0,
+ unsigned completion_column = 0);
+
std::unique_ptr<llvm::LLVMContext>
m_llvm_context; ///< The LLVM context to generate IR into
std::unique_ptr<clang::FileManager>
m_file_manager; ///< The Clang file manager object used by the compiler
std::unique_ptr<clang::CompilerInstance>
m_compiler; ///< The Clang compiler used to parse expressions into IR
- std::unique_ptr<clang::Builtin::Context>
- m_builtin_context; ///< Context for Clang built-ins
- std::unique_ptr<clang::SelectorTable>
- m_selector_table; ///< Selector table for Objective-C methods
std::unique_ptr<clang::CodeGenerator>
m_code_generator; ///< The Clang object that generates IR
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h b/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
index 7d5ced5b4705..6886f0940adb 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
@@ -10,20 +10,16 @@
#ifndef liblldb_ClangExpressionVariable_h_
#define liblldb_ClangExpressionVariable_h_
-// C Includes
#include <signal.h>
#include <stdint.h>
#include <string.h>
-// C++ Includes
#include <map>
#include <string>
#include <vector>
-// Other libraries and framework includes
#include "llvm/Support/Casting.h"
-// Project includes
#include "lldb/Core/ClangForward.h"
#include "lldb/Core/Value.h"
#include "lldb/Expression/ExpressionVariable.h"
diff --git a/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp b/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
index e3e0ed49181e..8ec9ff2235f5 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
@@ -12,9 +12,6 @@
#include "ASTStructExtractor.h"
#include "ClangExpressionParser.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
#include "clang/AST/ASTContext.h"
#include "clang/AST/RecordLayout.h"
#include "clang/CodeGen/CodeGenAction.h"
@@ -25,9 +22,7 @@
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/IR/Module.h"
-// Project includes
#include "lldb/Core/Module.h"
-#include "lldb/Core/State.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Expression/IRExecutionUnit.h"
@@ -44,6 +39,7 @@
#include "lldb/Target/ThreadPlanCallFunction.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/State.h"
using namespace lldb_private;
diff --git a/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h b/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h
index 438cf0c713da..9d933bfa6095 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h
@@ -10,10 +10,6 @@
#ifndef liblldb_ClangFunctionCaller_h_
#define liblldb_ClangFunctionCaller_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "ClangExpressionHelper.h"
#include "lldb/Core/Address.h"
diff --git a/source/Plugins/ExpressionParser/Clang/ClangHost.cpp b/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
index 4251d2ee75b9..44a13353818a 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
@@ -17,7 +17,7 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Threading.h"
-// Project includes
+#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
#if !defined(_WIN32)
#include "lldb/Host/posix/HostInfoPosix.h"
@@ -42,7 +42,7 @@ static bool DefaultComputeClangDirectory(FileSpec &file_spec) {
#if defined(__APPLE__)
static bool VerifyClangPath(const llvm::Twine &clang_path) {
- if (llvm::sys::fs::is_directory(clang_path))
+ if (FileSystem::Instance().IsDirectory(clang_path))
return true;
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (log)
@@ -84,7 +84,8 @@ bool lldb_private::ComputeClangDirectory(FileSpec &lldb_shlib_spec,
"Developer/Toolchains/XcodeDefault.xctoolchain",
swift_clang_resource_dir);
if (!verify || VerifyClangPath(clang_path)) {
- file_spec.SetFile(clang_path.c_str(), true, FileSpec::Style::native);
+ file_spec.SetFile(clang_path.c_str(), FileSpec::Style::native);
+ FileSystem::Instance().Resolve(file_spec);
return true;
}
} else if (parent != r_end && *parent == "PrivateFrameworks" &&
@@ -98,7 +99,8 @@ bool lldb_private::ComputeClangDirectory(FileSpec &lldb_shlib_spec,
raw_path.resize(parent - r_end);
llvm::sys::path::append(clang_path, raw_path, swift_clang_resource_dir);
if (!verify || VerifyClangPath(clang_path)) {
- file_spec.SetFile(clang_path.c_str(), true, FileSpec::Style::native);
+ file_spec.SetFile(clang_path.c_str(), FileSpec::Style::native);
+ FileSystem::Instance().Resolve(file_spec);
return true;
}
raw_path = lldb_shlib_spec.GetPath();
@@ -110,7 +112,8 @@ bool lldb_private::ComputeClangDirectory(FileSpec &lldb_shlib_spec,
// Fall back to the Clang resource directory inside the framework.
raw_path.append("LLDB.framework/Resources/Clang");
- file_spec.SetFile(raw_path.c_str(), true, FileSpec::Style::native);
+ file_spec.SetFile(raw_path.c_str(), FileSpec::Style::native);
+ FileSystem::Instance().Resolve(file_spec);
return true;
}
diff --git a/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index 665195f01774..ced21dfe0dda 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -7,11 +7,8 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
#include <mutex>
-// Other libraries and framework includes
#include "clang/Basic/TargetInfo.h"
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Frontend/FrontendActions.h"
@@ -24,7 +21,6 @@
#include "llvm/Support/Path.h"
#include "llvm/Support/Threading.h"
-// Project includes
#include "ClangHost.h"
#include "ClangModulesDeclVendor.h"
@@ -601,7 +597,7 @@ ClangModulesDeclVendor::Create(Target &target) {
{
FileSpec clang_resource_dir = GetClangResourceDir();
- if (llvm::sys::fs::is_directory(clang_resource_dir.GetPath())) {
+ if (FileSystem::Instance().IsDirectory(clang_resource_dir.GetPath())) {
compiler_invocation_arguments.push_back("-resource-dir");
compiler_invocation_arguments.push_back(clang_resource_dir.GetPath());
}
@@ -612,7 +608,8 @@ ClangModulesDeclVendor::Create(Target &target) {
new StoringDiagnosticConsumer);
std::vector<const char *> compiler_invocation_argument_cstrs;
-
+ compiler_invocation_argument_cstrs.reserve(
+ compiler_invocation_arguments.size());
for (const std::string &arg : compiler_invocation_arguments) {
compiler_invocation_argument_cstrs.push_back(arg.c_str());
}
diff --git a/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h b/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
index 59126974616d..c4438c7e2203 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
@@ -10,12 +10,8 @@
#ifndef liblldb_ClangPersistentVariables_h_
#define liblldb_ClangPersistentVariables_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
#include "llvm/ADT/DenseMap.h"
-// Project includes
#include "ClangExpressionVariable.h"
#include "ClangModulesDeclVendor.h"
diff --git a/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
index 2e61f704127a..f42955df07aa 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -376,9 +376,9 @@ static void SetupDeclVendor(ExecutionContext &exe_ctx, Target *target) {
}
}
-llvm::Optional<lldb::LanguageType> ClangUserExpression::GetLanguageForExpr(
+void ClangUserExpression::UpdateLanguageForExpr(
DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx) {
- lldb::LanguageType lang_type = lldb::LanguageType::eLanguageTypeUnknown;
+ m_expr_lang = lldb::LanguageType::eLanguageTypeUnknown;
std::string prefix = m_expr_prefix;
@@ -390,20 +390,29 @@ llvm::Optional<lldb::LanguageType> ClangUserExpression::GetLanguageForExpr(
m_expr_text.c_str()));
if (m_in_cplusplus_method)
- lang_type = lldb::eLanguageTypeC_plus_plus;
+ m_expr_lang = lldb::eLanguageTypeC_plus_plus;
else if (m_in_objectivec_method)
- lang_type = lldb::eLanguageTypeObjC;
+ m_expr_lang = lldb::eLanguageTypeObjC;
else
- lang_type = lldb::eLanguageTypeC;
+ m_expr_lang = lldb::eLanguageTypeC;
- if (!source_code->GetText(m_transformed_text, lang_type, m_in_static_method,
- exe_ctx)) {
+ if (!source_code->GetText(m_transformed_text, m_expr_lang,
+ m_in_static_method, exe_ctx)) {
diagnostic_manager.PutString(eDiagnosticSeverityError,
"couldn't construct expression body");
- return llvm::Optional<lldb::LanguageType>();
+ return;
+ }
+
+ // Find and store the start position of the original code inside the
+ // transformed code. We need this later for the code completion.
+ std::size_t original_start;
+ std::size_t original_end;
+ bool found_bounds = source_code->GetOriginalBodyBounds(
+ m_transformed_text, m_expr_lang, original_start, original_end);
+ if (found_bounds) {
+ m_user_expression_start_pos = original_start;
}
}
- return lang_type;
}
bool ClangUserExpression::PrepareForParsing(
@@ -427,6 +436,8 @@ bool ClangUserExpression::PrepareForParsing(
ApplyObjcCastHack(m_expr_text);
SetupDeclVendor(exe_ctx, m_target);
+
+ UpdateLanguageForExpr(diagnostic_manager, exe_ctx);
return true;
}
@@ -440,11 +451,6 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager,
if (!PrepareForParsing(diagnostic_manager, exe_ctx))
return false;
- lldb::LanguageType lang_type = lldb::LanguageType::eLanguageTypeUnknown;
- if (auto new_lang = GetLanguageForExpr(diagnostic_manager, exe_ctx)) {
- lang_type = new_lang.getValue();
- }
-
if (log)
log->Printf("Parsing the following code:\n%s", m_transformed_text.c_str());
@@ -504,7 +510,7 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager,
const std::string &fixed_expression =
diagnostic_manager.GetFixedExpression();
if (ExpressionSourceCode::GetOriginalBodyBounds(
- fixed_expression, lang_type, fixed_start, fixed_end))
+ fixed_expression, m_expr_lang, fixed_start, fixed_end))
m_fixed_text =
fixed_expression.substr(fixed_start, fixed_end - fixed_start);
}
@@ -591,6 +597,116 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager,
return true;
}
+//------------------------------------------------------------------
+/// Converts an absolute position inside a given code string into
+/// a column/line pair.
+///
+/// @param[in] abs_pos
+/// A absolute position in the code string that we want to convert
+/// to a column/line pair.
+///
+/// @param[in] code
+/// A multi-line string usually representing source code.
+///
+/// @param[out] line
+/// The line in the code that contains the given absolute position.
+/// The first line in the string is indexed as 1.
+///
+/// @param[out] column
+/// The column in the line that contains the absolute position.
+/// The first character in a line is indexed as 0.
+//------------------------------------------------------------------
+static void AbsPosToLineColumnPos(size_t abs_pos, llvm::StringRef code,
+ unsigned &line, unsigned &column) {
+ // Reset to code position to beginning of the file.
+ line = 0;
+ column = 0;
+
+ assert(abs_pos <= code.size() && "Absolute position outside code string?");
+
+ // We have to walk up to the position and count lines/columns.
+ for (std::size_t i = 0; i < abs_pos; ++i) {
+ // If we hit a line break, we go back to column 0 and enter a new line.
+ // We only handle \n because that's what we internally use to make new
+ // lines for our temporary code strings.
+ if (code[i] == '\n') {
+ ++line;
+ column = 0;
+ continue;
+ }
+ ++column;
+ }
+}
+
+bool ClangUserExpression::Complete(ExecutionContext &exe_ctx,
+ CompletionRequest &request,
+ unsigned complete_pos) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+
+ // We don't want any visible feedback when completing an expression. Mostly
+ // because the results we get from an incomplete invocation are probably not
+ // correct.
+ DiagnosticManager diagnostic_manager;
+
+ if (!PrepareForParsing(diagnostic_manager, exe_ctx))
+ return false;
+
+ if (log)
+ log->Printf("Parsing the following code:\n%s", m_transformed_text.c_str());
+
+ //////////////////////////
+ // Parse the expression
+ //
+
+ m_materializer_ap.reset(new Materializer());
+
+ ResetDeclMap(exe_ctx, m_result_delegate, /*keep result in memory*/ true);
+
+ OnExit on_exit([this]() { ResetDeclMap(); });
+
+ if (!DeclMap()->WillParse(exe_ctx, m_materializer_ap.get())) {
+ diagnostic_manager.PutString(
+ eDiagnosticSeverityError,
+ "current process state is unsuitable for expression parsing");
+
+ return false;
+ }
+
+ if (m_options.GetExecutionPolicy() == eExecutionPolicyTopLevel) {
+ DeclMap()->SetLookupsEnabled(true);
+ }
+
+ Process *process = exe_ctx.GetProcessPtr();
+ ExecutionContextScope *exe_scope = process;
+
+ if (!exe_scope)
+ exe_scope = exe_ctx.GetTargetPtr();
+
+ ClangExpressionParser parser(exe_scope, *this, false);
+
+ // We have to find the source code location where the user text is inside
+ // the transformed expression code. When creating the transformed text, we
+ // already stored the absolute position in the m_transformed_text string. The
+ // only thing left to do is to transform it into the line:column format that
+ // Clang expects.
+
+ // The line and column of the user expression inside the transformed source
+ // code.
+ unsigned user_expr_line, user_expr_column;
+ if (m_user_expression_start_pos.hasValue())
+ AbsPosToLineColumnPos(*m_user_expression_start_pos, m_transformed_text,
+ user_expr_line, user_expr_column);
+ else
+ return false;
+
+ // The actual column where we have to complete is the start column of the
+ // user expression + the offset inside the user code that we were given.
+ const unsigned completion_column = user_expr_column + complete_pos;
+ parser.Complete(request, user_expr_line, completion_column, complete_pos);
+
+ return true;
+}
+
bool ClangUserExpression::AddArguments(ExecutionContext &exe_ctx,
std::vector<lldb::addr_t> &args,
lldb::addr_t struct_address,
diff --git a/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h b/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
index ac363bf91747..7e4cba661850 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
@@ -10,12 +10,8 @@
#ifndef liblldb_ClangUserExpression_h_
#define liblldb_ClangUserExpression_h_
-// C Includes
-// C++ Includes
#include <vector>
-// Other libraries and framework includes
-// Project includes
#include "ASTResultSynthesizer.h"
#include "ASTStructExtractor.h"
#include "ClangExpressionDeclMap.h"
@@ -143,6 +139,9 @@ public:
lldb_private::ExecutionPolicy execution_policy,
bool keep_result_in_memory, bool generate_debug_info) override;
+ bool Complete(ExecutionContext &exe_ctx, CompletionRequest &request,
+ unsigned complete_pos) override;
+
ExpressionTypeSystemHelper *GetTypeSystemHelper() override {
return &m_type_system_helper;
}
@@ -174,8 +173,8 @@ private:
lldb::addr_t struct_address,
DiagnosticManager &diagnostic_manager) override;
- llvm::Optional<lldb::LanguageType> GetLanguageForExpr(
- DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx);
+ void UpdateLanguageForExpr(DiagnosticManager &diagnostic_manager,
+ ExecutionContext &exe_ctx);
bool SetupPersistentState(DiagnosticManager &diagnostic_manager,
ExecutionContext &exe_ctx);
bool PrepareForParsing(DiagnosticManager &diagnostic_manager,
@@ -198,6 +197,13 @@ private:
lldb::TargetSP m_target_sp;
};
+ /// The language type of the current expression.
+ lldb::LanguageType m_expr_lang = lldb::eLanguageTypeUnknown;
+
+ /// The absolute character position in the transformed source code where the
+ /// user code (as typed by the user) starts. If the variable is empty, then we
+ /// were not able to calculate this position.
+ llvm::Optional<size_t> m_user_expression_start_pos;
ResultDelegate m_result_delegate;
};
diff --git a/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp b/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
index 0f2aeef27e57..fe6ca450a79d 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
@@ -11,13 +11,11 @@
#include "ClangExpressionDeclMap.h"
#include "ClangExpressionParser.h"
-// C Includes
#include <stdio.h>
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
-// C++ Includes
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
diff --git a/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h b/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
index a897a2b17087..b0650f0eda02 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
@@ -10,14 +10,10 @@
#ifndef liblldb_ClangUtilityFunction_h_
#define liblldb_ClangUtilityFunction_h_
-// C Includes
-// C++ Includes
#include <map>
#include <string>
#include <vector>
-// Other libraries and framework includes
-// Project includes
#include "ClangExpressionHelper.h"
#include "lldb/Core/ClangForward.h"
diff --git a/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index e51c9ee07b9f..3a7cd58b70ab 100644
--- a/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -25,7 +25,6 @@
#include "clang/AST/ASTContext.h"
-#include "lldb/Core/Scalar.h"
#include "lldb/Core/dwarf.h"
#include "lldb/Expression/IRExecutionUnit.h"
#include "lldb/Expression/IRInterpreter.h"
@@ -36,6 +35,7 @@
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Endian.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/StreamString.h"
#include <map>
@@ -310,12 +310,14 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
lldb::TargetSP target_sp(m_execution_unit.GetTarget());
lldb_private::ExecutionContext exe_ctx(target_sp, true);
- if (m_result_type.GetBitSize(exe_ctx.GetBestExecutionContextScope()) == 0) {
+ llvm::Optional<uint64_t> bit_size =
+ m_result_type.GetBitSize(exe_ctx.GetBestExecutionContextScope());
+ if (!bit_size) {
lldb_private::StreamString type_desc_stream;
m_result_type.DumpTypeDescription(&type_desc_stream);
if (log)
- log->Printf("Result type has size 0");
+ log->Printf("Result type has unknown size");
m_error_stream.Printf("Error [IRForTarget]: Size of result type '%s' "
"couldn't be determined\n",
@@ -334,7 +336,8 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
if (log)
log->Printf("Creating a new result global: \"%s\" with size 0x%" PRIx64,
- m_result_name.GetCString(), m_result_type.GetByteSize(nullptr));
+ m_result_name.GetCString(),
+ m_result_type.GetByteSize(nullptr).getValueOr(0));
// Construct a new result global and set up its metadata
@@ -778,11 +781,8 @@ bool IRForTarget::RewriteObjCConstStrings() {
static bool IsObjCSelectorRef(Value *value) {
GlobalVariable *global_variable = dyn_cast<GlobalVariable>(value);
- if (!global_variable || !global_variable->hasName() ||
- !global_variable->getName().startswith("OBJC_SELECTOR_REFERENCES_"))
- return false;
-
- return true;
+ return !(!global_variable || !global_variable->hasName() ||
+ !global_variable->getName().startswith("OBJC_SELECTOR_REFERENCES_"));
}
// This function does not report errors; its callers are responsible.
@@ -953,11 +953,8 @@ bool IRForTarget::RewriteObjCSelectors(BasicBlock &basic_block) {
static bool IsObjCClassReference(Value *value) {
GlobalVariable *global_variable = dyn_cast<GlobalVariable>(value);
- if (!global_variable || !global_variable->hasName() ||
- !global_variable->getName().startswith("OBJC_CLASS_REFERENCES_"))
- return false;
-
- return true;
+ return !(!global_variable || !global_variable->hasName() ||
+ !global_variable->getName().startswith("OBJC_CLASS_REFERENCES_"));
}
// This function does not report errors; its callers are responsible.
@@ -1259,12 +1256,9 @@ bool IRForTarget::MaterializeInitializer(uint8_t *data, Constant *initializer) {
llvm::NextPowerOf2(constant_size) * 8);
lldb_private::Status get_data_error;
- if (!scalar.GetAsMemoryData(data, constant_size,
- lldb_private::endian::InlHostByteOrder(),
- get_data_error))
- return false;
-
- return true;
+ return scalar.GetAsMemoryData(data, constant_size,
+ lldb_private::endian::InlHostByteOrder(),
+ get_data_error) != 0;
} else if (ConstantDataArray *array_initializer =
dyn_cast<ConstantDataArray>(initializer)) {
if (array_initializer->isString()) {
@@ -1376,7 +1370,9 @@ bool IRForTarget::MaybeHandleVariable(Value *llvm_value_ptr) {
value_type = global_variable->getType();
}
- const uint64_t value_size = compiler_type.GetByteSize(nullptr);
+ llvm::Optional<uint64_t> value_size = compiler_type.GetByteSize(nullptr);
+ if (!value_size)
+ return false;
lldb::offset_t value_alignment =
(compiler_type.GetTypeBitAlign() + 7ull) / 8ull;
@@ -1387,13 +1383,13 @@ bool IRForTarget::MaybeHandleVariable(Value *llvm_value_ptr) {
lldb_private::ClangUtil::GetQualType(compiler_type)
.getAsString()
.c_str(),
- PrintType(value_type).c_str(), value_size, value_alignment);
+ PrintType(value_type).c_str(), *value_size, value_alignment);
}
if (named_decl &&
!m_decl_map->AddValueToStruct(
named_decl, lldb_private::ConstString(name.c_str()), llvm_value_ptr,
- value_size, value_alignment)) {
+ *value_size, value_alignment)) {
if (!global_variable->hasExternalLinkage())
return true;
else
diff --git a/source/Plugins/ExpressionParser/Go/CMakeLists.txt b/source/Plugins/ExpressionParser/Go/CMakeLists.txt
deleted file mode 100644
index 3d552aafa0d7..000000000000
--- a/source/Plugins/ExpressionParser/Go/CMakeLists.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-add_lldb_library(lldbPluginExpressionParserGo PLUGIN
- GoLexer.cpp
- GoParser.cpp
- GoUserExpression.cpp
-
- LINK_LIBS
- lldbCore
- lldbExpression
- lldbSymbol
- lldbTarget
- LINK_COMPONENTS
- Support
- )
diff --git a/source/Plugins/ExpressionParser/Go/GoAST.h b/source/Plugins/ExpressionParser/Go/GoAST.h
deleted file mode 100644
index d24e6c548718..000000000000
--- a/source/Plugins/ExpressionParser/Go/GoAST.h
+++ /dev/null
@@ -1,1977 +0,0 @@
-//===-- GoAST.h -------------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// DO NOT EDIT.
-// Generated by gen_go_ast.py
-
-#ifndef liblldb_GoAST_h
-#define liblldb_GoAST_h
-
-#include "Plugins/ExpressionParser/Go/GoLexer.h"
-#include "lldb/lldb-forward.h"
-#include "lldb/lldb-private.h"
-#include "llvm/Support/Casting.h"
-
-namespace lldb_private {
-
-class GoASTNode {
-public:
- typedef GoLexer::TokenType TokenType;
- typedef GoLexer::Token Token;
- enum ChanDir {
- eChanBidir,
- eChanSend,
- eChanRecv,
- };
- enum NodeKind {
- eBadDecl,
- eFuncDecl,
- eGenDecl,
- eArrayType,
- eBadExpr,
- eBasicLit,
- eBinaryExpr,
- eIdent,
- eCallExpr,
- eChanType,
- eCompositeLit,
- eEllipsis,
- eFuncType,
- eFuncLit,
- eIndexExpr,
- eInterfaceType,
- eKeyValueExpr,
- eMapType,
- eParenExpr,
- eSelectorExpr,
- eSliceExpr,
- eStarExpr,
- eStructType,
- eTypeAssertExpr,
- eUnaryExpr,
- eImportSpec,
- eTypeSpec,
- eValueSpec,
- eAssignStmt,
- eBadStmt,
- eBlockStmt,
- eBranchStmt,
- eCaseClause,
- eCommClause,
- eDeclStmt,
- eDeferStmt,
- eEmptyStmt,
- eExprStmt,
- eForStmt,
- eGoStmt,
- eIfStmt,
- eIncDecStmt,
- eLabeledStmt,
- eRangeStmt,
- eReturnStmt,
- eSelectStmt,
- eSendStmt,
- eSwitchStmt,
- eTypeSwitchStmt,
- eField,
- eFieldList,
- };
-
- virtual ~GoASTNode() = default;
-
- NodeKind GetKind() const { return m_kind; }
-
- virtual const char *GetKindName() const = 0;
-
- template <typename V> void WalkChildren(V &v);
-
-protected:
- explicit GoASTNode(NodeKind kind) : m_kind(kind) {}
-
-private:
- const NodeKind m_kind;
-
- GoASTNode(const GoASTNode &) = delete;
- const GoASTNode &operator=(const GoASTNode &) = delete;
-};
-
-class GoASTDecl : public GoASTNode {
-public:
- template <typename R, typename V> R Visit(V *v) const;
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() >= eBadDecl && n->GetKind() <= eGenDecl;
- }
-
-protected:
- explicit GoASTDecl(NodeKind kind) : GoASTNode(kind) {}
-
-private:
- GoASTDecl(const GoASTDecl &) = delete;
- const GoASTDecl &operator=(const GoASTDecl &) = delete;
-};
-
-class GoASTExpr : public GoASTNode {
-public:
- template <typename R, typename V> R Visit(V *v) const;
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() >= eArrayType && n->GetKind() <= eUnaryExpr;
- }
-
-protected:
- explicit GoASTExpr(NodeKind kind) : GoASTNode(kind) {}
-
-private:
- GoASTExpr(const GoASTExpr &) = delete;
- const GoASTExpr &operator=(const GoASTExpr &) = delete;
-};
-
-class GoASTSpec : public GoASTNode {
-public:
- template <typename R, typename V> R Visit(V *v) const;
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() >= eImportSpec && n->GetKind() <= eValueSpec;
- }
-
-protected:
- explicit GoASTSpec(NodeKind kind) : GoASTNode(kind) {}
-
-private:
- GoASTSpec(const GoASTSpec &) = delete;
- const GoASTSpec &operator=(const GoASTSpec &) = delete;
-};
-
-class GoASTStmt : public GoASTNode {
-public:
- template <typename R, typename V> R Visit(V *v) const;
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() >= eAssignStmt && n->GetKind() <= eTypeSwitchStmt;
- }
-
-protected:
- explicit GoASTStmt(NodeKind kind) : GoASTNode(kind) {}
-
-private:
- GoASTStmt(const GoASTStmt &) = delete;
- const GoASTStmt &operator=(const GoASTStmt &) = delete;
-};
-
-class GoASTArrayType : public GoASTExpr {
-public:
- GoASTArrayType(GoASTExpr *len, GoASTExpr *elt)
- : GoASTExpr(eArrayType), m_len_up(len), m_elt_up(elt) {}
- ~GoASTArrayType() override = default;
-
- const char *GetKindName() const override { return "ArrayType"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eArrayType; }
-
- const GoASTExpr *GetLen() const { return m_len_up.get(); }
- void SetLen(GoASTExpr *len) { m_len_up.reset(len); }
-
- const GoASTExpr *GetElt() const { return m_elt_up.get(); }
- void SetElt(GoASTExpr *elt) { m_elt_up.reset(elt); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTExpr> m_len_up;
- std::unique_ptr<GoASTExpr> m_elt_up;
-
- GoASTArrayType(const GoASTArrayType &) = delete;
- const GoASTArrayType &operator=(const GoASTArrayType &) = delete;
-};
-
-class GoASTAssignStmt : public GoASTStmt {
-public:
- explicit GoASTAssignStmt(bool define)
- : GoASTStmt(eAssignStmt), m_define(define) {}
- ~GoASTAssignStmt() override = default;
-
- const char *GetKindName() const override { return "AssignStmt"; }
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() == eAssignStmt;
- }
-
- size_t NumLhs() const { return m_lhs.size(); }
- const GoASTExpr *GetLhs(int i) const { return m_lhs[i].get(); }
- void AddLhs(GoASTExpr *lhs) {
- m_lhs.push_back(std::unique_ptr<GoASTExpr>(lhs));
- }
-
- size_t NumRhs() const { return m_rhs.size(); }
- const GoASTExpr *GetRhs(int i) const { return m_rhs[i].get(); }
- void AddRhs(GoASTExpr *rhs) {
- m_rhs.push_back(std::unique_ptr<GoASTExpr>(rhs));
- }
-
- bool GetDefine() const { return m_define; }
- void SetDefine(bool define) { m_define = define; }
-
-private:
- friend class GoASTNode;
- std::vector<std::unique_ptr<GoASTExpr>> m_lhs;
- std::vector<std::unique_ptr<GoASTExpr>> m_rhs;
- bool m_define;
-
- GoASTAssignStmt(const GoASTAssignStmt &) = delete;
- const GoASTAssignStmt &operator=(const GoASTAssignStmt &) = delete;
-};
-
-class GoASTBadDecl : public GoASTDecl {
-public:
- GoASTBadDecl() : GoASTDecl(eBadDecl) {}
- ~GoASTBadDecl() override = default;
-
- const char *GetKindName() const override { return "BadDecl"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eBadDecl; }
-
- GoASTBadDecl(const GoASTBadDecl &) = delete;
- const GoASTBadDecl &operator=(const GoASTBadDecl &) = delete;
-};
-
-class GoASTBadExpr : public GoASTExpr {
-public:
- GoASTBadExpr() : GoASTExpr(eBadExpr) {}
- ~GoASTBadExpr() override = default;
-
- const char *GetKindName() const override { return "BadExpr"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eBadExpr; }
-
- GoASTBadExpr(const GoASTBadExpr &) = delete;
- const GoASTBadExpr &operator=(const GoASTBadExpr &) = delete;
-};
-
-class GoASTBadStmt : public GoASTStmt {
-public:
- GoASTBadStmt() : GoASTStmt(eBadStmt) {}
- ~GoASTBadStmt() override = default;
-
- const char *GetKindName() const override { return "BadStmt"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eBadStmt; }
-
- GoASTBadStmt(const GoASTBadStmt &) = delete;
- const GoASTBadStmt &operator=(const GoASTBadStmt &) = delete;
-};
-
-class GoASTBasicLit : public GoASTExpr {
-public:
- explicit GoASTBasicLit(Token value) : GoASTExpr(eBasicLit), m_value(value) {}
- ~GoASTBasicLit() override = default;
-
- const char *GetKindName() const override { return "BasicLit"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eBasicLit; }
-
- Token GetValue() const { return m_value; }
- void SetValue(Token value) { m_value = value; }
-
-private:
- friend class GoASTNode;
- Token m_value;
-
- GoASTBasicLit(const GoASTBasicLit &) = delete;
- const GoASTBasicLit &operator=(const GoASTBasicLit &) = delete;
-};
-
-class GoASTBinaryExpr : public GoASTExpr {
-public:
- GoASTBinaryExpr(GoASTExpr *x, GoASTExpr *y, TokenType op)
- : GoASTExpr(eBinaryExpr), m_x_up(x), m_y_up(y), m_op(op) {}
- ~GoASTBinaryExpr() override = default;
-
- const char *GetKindName() const override { return "BinaryExpr"; }
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() == eBinaryExpr;
- }
-
- const GoASTExpr *GetX() const { return m_x_up.get(); }
- void SetX(GoASTExpr *x) { m_x_up.reset(x); }
-
- const GoASTExpr *GetY() const { return m_y_up.get(); }
- void SetY(GoASTExpr *y) { m_y_up.reset(y); }
-
- TokenType GetOp() const { return m_op; }
- void SetOp(TokenType op) { m_op = op; }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTExpr> m_x_up;
- std::unique_ptr<GoASTExpr> m_y_up;
- TokenType m_op;
-
- GoASTBinaryExpr(const GoASTBinaryExpr &) = delete;
- const GoASTBinaryExpr &operator=(const GoASTBinaryExpr &) = delete;
-};
-
-class GoASTBlockStmt : public GoASTStmt {
-public:
- GoASTBlockStmt() : GoASTStmt(eBlockStmt) {}
- ~GoASTBlockStmt() override = default;
-
- const char *GetKindName() const override { return "BlockStmt"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eBlockStmt; }
-
- size_t NumList() const { return m_list.size(); }
- const GoASTStmt *GetList(int i) const { return m_list[i].get(); }
- void AddList(GoASTStmt *list) {
- m_list.push_back(std::unique_ptr<GoASTStmt>(list));
- }
-
-private:
- friend class GoASTNode;
- std::vector<std::unique_ptr<GoASTStmt>> m_list;
-
- GoASTBlockStmt(const GoASTBlockStmt &) = delete;
- const GoASTBlockStmt &operator=(const GoASTBlockStmt &) = delete;
-};
-
-class GoASTIdent : public GoASTExpr {
-public:
- explicit GoASTIdent(Token name) : GoASTExpr(eIdent), m_name(name) {}
- ~GoASTIdent() override = default;
-
- const char *GetKindName() const override { return "Ident"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eIdent; }
-
- Token GetName() const { return m_name; }
- void SetName(Token name) { m_name = name; }
-
-private:
- friend class GoASTNode;
- Token m_name;
-
- GoASTIdent(const GoASTIdent &) = delete;
- const GoASTIdent &operator=(const GoASTIdent &) = delete;
-};
-
-class GoASTBranchStmt : public GoASTStmt {
-public:
- GoASTBranchStmt(GoASTIdent *label, TokenType tok)
- : GoASTStmt(eBranchStmt), m_label_up(label), m_tok(tok) {}
- ~GoASTBranchStmt() override = default;
-
- const char *GetKindName() const override { return "BranchStmt"; }
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() == eBranchStmt;
- }
-
- const GoASTIdent *GetLabel() const { return m_label_up.get(); }
- void SetLabel(GoASTIdent *label) { m_label_up.reset(label); }
-
- TokenType GetTok() const { return m_tok; }
- void SetTok(TokenType tok) { m_tok = tok; }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTIdent> m_label_up;
- TokenType m_tok;
-
- GoASTBranchStmt(const GoASTBranchStmt &) = delete;
- const GoASTBranchStmt &operator=(const GoASTBranchStmt &) = delete;
-};
-
-class GoASTCallExpr : public GoASTExpr {
-public:
- explicit GoASTCallExpr(bool ellipsis)
- : GoASTExpr(eCallExpr), m_ellipsis(ellipsis) {}
- ~GoASTCallExpr() override = default;
-
- const char *GetKindName() const override { return "CallExpr"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eCallExpr; }
-
- const GoASTExpr *GetFun() const { return m_fun_up.get(); }
- void SetFun(GoASTExpr *fun) { m_fun_up.reset(fun); }
-
- size_t NumArgs() const { return m_args.size(); }
- const GoASTExpr *GetArgs(int i) const { return m_args[i].get(); }
- void AddArgs(GoASTExpr *args) {
- m_args.push_back(std::unique_ptr<GoASTExpr>(args));
- }
-
- bool GetEllipsis() const { return m_ellipsis; }
- void SetEllipsis(bool ellipsis) { m_ellipsis = ellipsis; }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTExpr> m_fun_up;
- std::vector<std::unique_ptr<GoASTExpr>> m_args;
- bool m_ellipsis;
-
- GoASTCallExpr(const GoASTCallExpr &) = delete;
- const GoASTCallExpr &operator=(const GoASTCallExpr &) = delete;
-};
-
-class GoASTCaseClause : public GoASTStmt {
-public:
- GoASTCaseClause() : GoASTStmt(eCaseClause) {}
- ~GoASTCaseClause() override = default;
-
- const char *GetKindName() const override { return "CaseClause"; }
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() == eCaseClause;
- }
-
- size_t NumList() const { return m_list.size(); }
- const GoASTExpr *GetList(int i) const { return m_list[i].get(); }
- void AddList(GoASTExpr *list) {
- m_list.push_back(std::unique_ptr<GoASTExpr>(list));
- }
-
- size_t NumBody() const { return m_body.size(); }
- const GoASTStmt *GetBody(int i) const { return m_body[i].get(); }
- void AddBody(GoASTStmt *body) {
- m_body.push_back(std::unique_ptr<GoASTStmt>(body));
- }
-
-private:
- friend class GoASTNode;
- std::vector<std::unique_ptr<GoASTExpr>> m_list;
- std::vector<std::unique_ptr<GoASTStmt>> m_body;
-
- GoASTCaseClause(const GoASTCaseClause &) = delete;
- const GoASTCaseClause &operator=(const GoASTCaseClause &) = delete;
-};
-
-class GoASTChanType : public GoASTExpr {
-public:
- GoASTChanType(ChanDir dir, GoASTExpr *value)
- : GoASTExpr(eChanType), m_dir(dir), m_value_up(value) {}
- ~GoASTChanType() override = default;
-
- const char *GetKindName() const override { return "ChanType"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eChanType; }
-
- ChanDir GetDir() const { return m_dir; }
- void SetDir(ChanDir dir) { m_dir = dir; }
-
- const GoASTExpr *GetValue() const { return m_value_up.get(); }
- void SetValue(GoASTExpr *value) { m_value_up.reset(value); }
-
-private:
- friend class GoASTNode;
- ChanDir m_dir;
- std::unique_ptr<GoASTExpr> m_value_up;
-
- GoASTChanType(const GoASTChanType &) = delete;
- const GoASTChanType &operator=(const GoASTChanType &) = delete;
-};
-
-class GoASTCommClause : public GoASTStmt {
-public:
- GoASTCommClause() : GoASTStmt(eCommClause) {}
- ~GoASTCommClause() override = default;
-
- const char *GetKindName() const override { return "CommClause"; }
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() == eCommClause;
- }
-
- const GoASTStmt *GetComm() const { return m_comm_up.get(); }
- void SetComm(GoASTStmt *comm) { m_comm_up.reset(comm); }
-
- size_t NumBody() const { return m_body.size(); }
- const GoASTStmt *GetBody(int i) const { return m_body[i].get(); }
- void AddBody(GoASTStmt *body) {
- m_body.push_back(std::unique_ptr<GoASTStmt>(body));
- }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTStmt> m_comm_up;
- std::vector<std::unique_ptr<GoASTStmt>> m_body;
-
- GoASTCommClause(const GoASTCommClause &) = delete;
- const GoASTCommClause &operator=(const GoASTCommClause &) = delete;
-};
-
-class GoASTCompositeLit : public GoASTExpr {
-public:
- GoASTCompositeLit() : GoASTExpr(eCompositeLit) {}
- ~GoASTCompositeLit() override = default;
-
- const char *GetKindName() const override { return "CompositeLit"; }
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() == eCompositeLit;
- }
-
- const GoASTExpr *GetType() const { return m_type_up.get(); }
- void SetType(GoASTExpr *type) { m_type_up.reset(type); }
-
- size_t NumElts() const { return m_elts.size(); }
- const GoASTExpr *GetElts(int i) const { return m_elts[i].get(); }
- void AddElts(GoASTExpr *elts) {
- m_elts.push_back(std::unique_ptr<GoASTExpr>(elts));
- }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTExpr> m_type_up;
- std::vector<std::unique_ptr<GoASTExpr>> m_elts;
-
- GoASTCompositeLit(const GoASTCompositeLit &) = delete;
- const GoASTCompositeLit &operator=(const GoASTCompositeLit &) = delete;
-};
-
-class GoASTDeclStmt : public GoASTStmt {
-public:
- explicit GoASTDeclStmt(GoASTDecl *decl)
- : GoASTStmt(eDeclStmt), m_decl_up(decl) {}
- ~GoASTDeclStmt() override = default;
-
- const char *GetKindName() const override { return "DeclStmt"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eDeclStmt; }
-
- const GoASTDecl *GetDecl() const { return m_decl_up.get(); }
- void SetDecl(GoASTDecl *decl) { m_decl_up.reset(decl); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTDecl> m_decl_up;
-
- GoASTDeclStmt(const GoASTDeclStmt &) = delete;
- const GoASTDeclStmt &operator=(const GoASTDeclStmt &) = delete;
-};
-
-class GoASTDeferStmt : public GoASTStmt {
-public:
- explicit GoASTDeferStmt(GoASTCallExpr *call)
- : GoASTStmt(eDeferStmt), m_call_up(call) {}
- ~GoASTDeferStmt() override = default;
-
- const char *GetKindName() const override { return "DeferStmt"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eDeferStmt; }
-
- const GoASTCallExpr *GetCall() const { return m_call_up.get(); }
- void SetCall(GoASTCallExpr *call) { m_call_up.reset(call); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTCallExpr> m_call_up;
-
- GoASTDeferStmt(const GoASTDeferStmt &) = delete;
- const GoASTDeferStmt &operator=(const GoASTDeferStmt &) = delete;
-};
-
-class GoASTEllipsis : public GoASTExpr {
-public:
- explicit GoASTEllipsis(GoASTExpr *elt)
- : GoASTExpr(eEllipsis), m_elt_up(elt) {}
- ~GoASTEllipsis() override = default;
-
- const char *GetKindName() const override { return "Ellipsis"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eEllipsis; }
-
- const GoASTExpr *GetElt() const { return m_elt_up.get(); }
- void SetElt(GoASTExpr *elt) { m_elt_up.reset(elt); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTExpr> m_elt_up;
-
- GoASTEllipsis(const GoASTEllipsis &) = delete;
- const GoASTEllipsis &operator=(const GoASTEllipsis &) = delete;
-};
-
-class GoASTEmptyStmt : public GoASTStmt {
-public:
- GoASTEmptyStmt() : GoASTStmt(eEmptyStmt) {}
- ~GoASTEmptyStmt() override = default;
-
- const char *GetKindName() const override { return "EmptyStmt"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eEmptyStmt; }
-
- GoASTEmptyStmt(const GoASTEmptyStmt &) = delete;
- const GoASTEmptyStmt &operator=(const GoASTEmptyStmt &) = delete;
-};
-
-class GoASTExprStmt : public GoASTStmt {
-public:
- explicit GoASTExprStmt(GoASTExpr *x) : GoASTStmt(eExprStmt), m_x_up(x) {}
- ~GoASTExprStmt() override = default;
-
- const char *GetKindName() const override { return "ExprStmt"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eExprStmt; }
-
- const GoASTExpr *GetX() const { return m_x_up.get(); }
- void SetX(GoASTExpr *x) { m_x_up.reset(x); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTExpr> m_x_up;
-
- GoASTExprStmt(const GoASTExprStmt &) = delete;
- const GoASTExprStmt &operator=(const GoASTExprStmt &) = delete;
-};
-
-class GoASTField : public GoASTNode {
-public:
- GoASTField() : GoASTNode(eField) {}
- ~GoASTField() override = default;
-
- const char *GetKindName() const override { return "Field"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eField; }
-
- size_t NumNames() const { return m_names.size(); }
- const GoASTIdent *GetNames(int i) const { return m_names[i].get(); }
- void AddNames(GoASTIdent *names) {
- m_names.push_back(std::unique_ptr<GoASTIdent>(names));
- }
-
- const GoASTExpr *GetType() const { return m_type_up.get(); }
- void SetType(GoASTExpr *type) { m_type_up.reset(type); }
-
- const GoASTBasicLit *GetTag() const { return m_tag_up.get(); }
- void SetTag(GoASTBasicLit *tag) { m_tag_up.reset(tag); }
-
-private:
- friend class GoASTNode;
- std::vector<std::unique_ptr<GoASTIdent>> m_names;
- std::unique_ptr<GoASTExpr> m_type_up;
- std::unique_ptr<GoASTBasicLit> m_tag_up;
-
- GoASTField(const GoASTField &) = delete;
- const GoASTField &operator=(const GoASTField &) = delete;
-};
-
-class GoASTFieldList : public GoASTNode {
-public:
- GoASTFieldList() : GoASTNode(eFieldList) {}
- ~GoASTFieldList() override = default;
-
- const char *GetKindName() const override { return "FieldList"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eFieldList; }
-
- size_t NumList() const { return m_list.size(); }
- const GoASTField *GetList(int i) const { return m_list[i].get(); }
- void AddList(GoASTField *list) {
- m_list.push_back(std::unique_ptr<GoASTField>(list));
- }
-
-private:
- friend class GoASTNode;
- std::vector<std::unique_ptr<GoASTField>> m_list;
-
- GoASTFieldList(const GoASTFieldList &) = delete;
- const GoASTFieldList &operator=(const GoASTFieldList &) = delete;
-};
-
-class GoASTForStmt : public GoASTStmt {
-public:
- GoASTForStmt(GoASTStmt *init, GoASTExpr *cond, GoASTStmt *post,
- GoASTBlockStmt *body)
- : GoASTStmt(eForStmt), m_init_up(init), m_cond_up(cond), m_post_up(post),
- m_body_up(body) {}
- ~GoASTForStmt() override = default;
-
- const char *GetKindName() const override { return "ForStmt"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eForStmt; }
-
- const GoASTStmt *GetInit() const { return m_init_up.get(); }
- void SetInit(GoASTStmt *init) { m_init_up.reset(init); }
-
- const GoASTExpr *GetCond() const { return m_cond_up.get(); }
- void SetCond(GoASTExpr *cond) { m_cond_up.reset(cond); }
-
- const GoASTStmt *GetPost() const { return m_post_up.get(); }
- void SetPost(GoASTStmt *post) { m_post_up.reset(post); }
-
- const GoASTBlockStmt *GetBody() const { return m_body_up.get(); }
- void SetBody(GoASTBlockStmt *body) { m_body_up.reset(body); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTStmt> m_init_up;
- std::unique_ptr<GoASTExpr> m_cond_up;
- std::unique_ptr<GoASTStmt> m_post_up;
- std::unique_ptr<GoASTBlockStmt> m_body_up;
-
- GoASTForStmt(const GoASTForStmt &) = delete;
- const GoASTForStmt &operator=(const GoASTForStmt &) = delete;
-};
-
-class GoASTFuncType : public GoASTExpr {
-public:
- GoASTFuncType(GoASTFieldList *params, GoASTFieldList *results)
- : GoASTExpr(eFuncType), m_params_up(params), m_results_up(results) {}
- ~GoASTFuncType() override = default;
-
- const char *GetKindName() const override { return "FuncType"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eFuncType; }
-
- const GoASTFieldList *GetParams() const { return m_params_up.get(); }
- void SetParams(GoASTFieldList *params) { m_params_up.reset(params); }
-
- const GoASTFieldList *GetResults() const { return m_results_up.get(); }
- void SetResults(GoASTFieldList *results) { m_results_up.reset(results); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTFieldList> m_params_up;
- std::unique_ptr<GoASTFieldList> m_results_up;
-
- GoASTFuncType(const GoASTFuncType &) = delete;
- const GoASTFuncType &operator=(const GoASTFuncType &) = delete;
-};
-
-class GoASTFuncDecl : public GoASTDecl {
-public:
- GoASTFuncDecl(GoASTFieldList *recv, GoASTIdent *name, GoASTFuncType *type,
- GoASTBlockStmt *body)
- : GoASTDecl(eFuncDecl), m_recv_up(recv), m_name_up(name), m_type_up(type),
- m_body_up(body) {}
- ~GoASTFuncDecl() override = default;
-
- const char *GetKindName() const override { return "FuncDecl"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eFuncDecl; }
-
- const GoASTFieldList *GetRecv() const { return m_recv_up.get(); }
- void SetRecv(GoASTFieldList *recv) { m_recv_up.reset(recv); }
-
- const GoASTIdent *GetName() const { return m_name_up.get(); }
- void SetName(GoASTIdent *name) { m_name_up.reset(name); }
-
- const GoASTFuncType *GetType() const { return m_type_up.get(); }
- void SetType(GoASTFuncType *type) { m_type_up.reset(type); }
-
- const GoASTBlockStmt *GetBody() const { return m_body_up.get(); }
- void SetBody(GoASTBlockStmt *body) { m_body_up.reset(body); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTFieldList> m_recv_up;
- std::unique_ptr<GoASTIdent> m_name_up;
- std::unique_ptr<GoASTFuncType> m_type_up;
- std::unique_ptr<GoASTBlockStmt> m_body_up;
-
- GoASTFuncDecl(const GoASTFuncDecl &) = delete;
- const GoASTFuncDecl &operator=(const GoASTFuncDecl &) = delete;
-};
-
-class GoASTFuncLit : public GoASTExpr {
-public:
- GoASTFuncLit(GoASTFuncType *type, GoASTBlockStmt *body)
- : GoASTExpr(eFuncLit), m_type_up(type), m_body_up(body) {}
- ~GoASTFuncLit() override = default;
-
- const char *GetKindName() const override { return "FuncLit"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eFuncLit; }
-
- const GoASTFuncType *GetType() const { return m_type_up.get(); }
- void SetType(GoASTFuncType *type) { m_type_up.reset(type); }
-
- const GoASTBlockStmt *GetBody() const { return m_body_up.get(); }
- void SetBody(GoASTBlockStmt *body) { m_body_up.reset(body); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTFuncType> m_type_up;
- std::unique_ptr<GoASTBlockStmt> m_body_up;
-
- GoASTFuncLit(const GoASTFuncLit &) = delete;
- const GoASTFuncLit &operator=(const GoASTFuncLit &) = delete;
-};
-
-class GoASTGenDecl : public GoASTDecl {
-public:
- explicit GoASTGenDecl(TokenType tok) : GoASTDecl(eGenDecl), m_tok(tok) {}
- ~GoASTGenDecl() override = default;
-
- const char *GetKindName() const override { return "GenDecl"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eGenDecl; }
-
- TokenType GetTok() const { return m_tok; }
- void SetTok(TokenType tok) { m_tok = tok; }
-
- size_t NumSpecs() const { return m_specs.size(); }
- const GoASTSpec *GetSpecs(int i) const { return m_specs[i].get(); }
- void AddSpecs(GoASTSpec *specs) {
- m_specs.push_back(std::unique_ptr<GoASTSpec>(specs));
- }
-
-private:
- friend class GoASTNode;
- TokenType m_tok;
- std::vector<std::unique_ptr<GoASTSpec>> m_specs;
-
- GoASTGenDecl(const GoASTGenDecl &) = delete;
- const GoASTGenDecl &operator=(const GoASTGenDecl &) = delete;
-};
-
-class GoASTGoStmt : public GoASTStmt {
-public:
- explicit GoASTGoStmt(GoASTCallExpr *call)
- : GoASTStmt(eGoStmt), m_call_up(call) {}
- ~GoASTGoStmt() override = default;
-
- const char *GetKindName() const override { return "GoStmt"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eGoStmt; }
-
- const GoASTCallExpr *GetCall() const { return m_call_up.get(); }
- void SetCall(GoASTCallExpr *call) { m_call_up.reset(call); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTCallExpr> m_call_up;
-
- GoASTGoStmt(const GoASTGoStmt &) = delete;
- const GoASTGoStmt &operator=(const GoASTGoStmt &) = delete;
-};
-
-class GoASTIfStmt : public GoASTStmt {
-public:
- GoASTIfStmt(GoASTStmt *init, GoASTExpr *cond, GoASTBlockStmt *body,
- GoASTStmt *els)
- : GoASTStmt(eIfStmt), m_init_up(init), m_cond_up(cond), m_body_up(body),
- m_els_up(els) {}
- ~GoASTIfStmt() override = default;
-
- const char *GetKindName() const override { return "IfStmt"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eIfStmt; }
-
- const GoASTStmt *GetInit() const { return m_init_up.get(); }
- void SetInit(GoASTStmt *init) { m_init_up.reset(init); }
-
- const GoASTExpr *GetCond() const { return m_cond_up.get(); }
- void SetCond(GoASTExpr *cond) { m_cond_up.reset(cond); }
-
- const GoASTBlockStmt *GetBody() const { return m_body_up.get(); }
- void SetBody(GoASTBlockStmt *body) { m_body_up.reset(body); }
-
- const GoASTStmt *GetEls() const { return m_els_up.get(); }
- void SetEls(GoASTStmt *els) { m_els_up.reset(els); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTStmt> m_init_up;
- std::unique_ptr<GoASTExpr> m_cond_up;
- std::unique_ptr<GoASTBlockStmt> m_body_up;
- std::unique_ptr<GoASTStmt> m_els_up;
-
- GoASTIfStmt(const GoASTIfStmt &) = delete;
- const GoASTIfStmt &operator=(const GoASTIfStmt &) = delete;
-};
-
-class GoASTImportSpec : public GoASTSpec {
-public:
- GoASTImportSpec(GoASTIdent *name, GoASTBasicLit *path)
- : GoASTSpec(eImportSpec), m_name_up(name), m_path_up(path) {}
- ~GoASTImportSpec() override = default;
-
- const char *GetKindName() const override { return "ImportSpec"; }
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() == eImportSpec;
- }
-
- const GoASTIdent *GetName() const { return m_name_up.get(); }
- void SetName(GoASTIdent *name) { m_name_up.reset(name); }
-
- const GoASTBasicLit *GetPath() const { return m_path_up.get(); }
- void SetPath(GoASTBasicLit *path) { m_path_up.reset(path); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTIdent> m_name_up;
- std::unique_ptr<GoASTBasicLit> m_path_up;
-
- GoASTImportSpec(const GoASTImportSpec &) = delete;
- const GoASTImportSpec &operator=(const GoASTImportSpec &) = delete;
-};
-
-class GoASTIncDecStmt : public GoASTStmt {
-public:
- GoASTIncDecStmt(GoASTExpr *x, TokenType tok)
- : GoASTStmt(eIncDecStmt), m_x_up(x), m_tok(tok) {}
- ~GoASTIncDecStmt() override = default;
-
- const char *GetKindName() const override { return "IncDecStmt"; }
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() == eIncDecStmt;
- }
-
- const GoASTExpr *GetX() const { return m_x_up.get(); }
- void SetX(GoASTExpr *x) { m_x_up.reset(x); }
-
- TokenType GetTok() const { return m_tok; }
- void SetTok(TokenType tok) { m_tok = tok; }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTExpr> m_x_up;
- TokenType m_tok;
-
- GoASTIncDecStmt(const GoASTIncDecStmt &) = delete;
- const GoASTIncDecStmt &operator=(const GoASTIncDecStmt &) = delete;
-};
-
-class GoASTIndexExpr : public GoASTExpr {
-public:
- GoASTIndexExpr(GoASTExpr *x, GoASTExpr *index)
- : GoASTExpr(eIndexExpr), m_x_up(x), m_index_up(index) {}
- ~GoASTIndexExpr() override = default;
-
- const char *GetKindName() const override { return "IndexExpr"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eIndexExpr; }
-
- const GoASTExpr *GetX() const { return m_x_up.get(); }
- void SetX(GoASTExpr *x) { m_x_up.reset(x); }
-
- const GoASTExpr *GetIndex() const { return m_index_up.get(); }
- void SetIndex(GoASTExpr *index) { m_index_up.reset(index); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTExpr> m_x_up;
- std::unique_ptr<GoASTExpr> m_index_up;
-
- GoASTIndexExpr(const GoASTIndexExpr &) = delete;
- const GoASTIndexExpr &operator=(const GoASTIndexExpr &) = delete;
-};
-
-class GoASTInterfaceType : public GoASTExpr {
-public:
- explicit GoASTInterfaceType(GoASTFieldList *methods)
- : GoASTExpr(eInterfaceType), m_methods_up(methods) {}
- ~GoASTInterfaceType() override = default;
-
- const char *GetKindName() const override { return "InterfaceType"; }
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() == eInterfaceType;
- }
-
- const GoASTFieldList *GetMethods() const { return m_methods_up.get(); }
- void SetMethods(GoASTFieldList *methods) { m_methods_up.reset(methods); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTFieldList> m_methods_up;
-
- GoASTInterfaceType(const GoASTInterfaceType &) = delete;
- const GoASTInterfaceType &operator=(const GoASTInterfaceType &) = delete;
-};
-
-class GoASTKeyValueExpr : public GoASTExpr {
-public:
- GoASTKeyValueExpr(GoASTExpr *key, GoASTExpr *value)
- : GoASTExpr(eKeyValueExpr), m_key_up(key), m_value_up(value) {}
- ~GoASTKeyValueExpr() override = default;
-
- const char *GetKindName() const override { return "KeyValueExpr"; }
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() == eKeyValueExpr;
- }
-
- const GoASTExpr *GetKey() const { return m_key_up.get(); }
- void SetKey(GoASTExpr *key) { m_key_up.reset(key); }
-
- const GoASTExpr *GetValue() const { return m_value_up.get(); }
- void SetValue(GoASTExpr *value) { m_value_up.reset(value); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTExpr> m_key_up;
- std::unique_ptr<GoASTExpr> m_value_up;
-
- GoASTKeyValueExpr(const GoASTKeyValueExpr &) = delete;
- const GoASTKeyValueExpr &operator=(const GoASTKeyValueExpr &) = delete;
-};
-
-class GoASTLabeledStmt : public GoASTStmt {
-public:
- GoASTLabeledStmt(GoASTIdent *label, GoASTStmt *stmt)
- : GoASTStmt(eLabeledStmt), m_label_up(label), m_stmt_up(stmt) {}
- ~GoASTLabeledStmt() override = default;
-
- const char *GetKindName() const override { return "LabeledStmt"; }
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() == eLabeledStmt;
- }
-
- const GoASTIdent *GetLabel() const { return m_label_up.get(); }
- void SetLabel(GoASTIdent *label) { m_label_up.reset(label); }
-
- const GoASTStmt *GetStmt() const { return m_stmt_up.get(); }
- void SetStmt(GoASTStmt *stmt) { m_stmt_up.reset(stmt); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTIdent> m_label_up;
- std::unique_ptr<GoASTStmt> m_stmt_up;
-
- GoASTLabeledStmt(const GoASTLabeledStmt &) = delete;
- const GoASTLabeledStmt &operator=(const GoASTLabeledStmt &) = delete;
-};
-
-class GoASTMapType : public GoASTExpr {
-public:
- GoASTMapType(GoASTExpr *key, GoASTExpr *value)
- : GoASTExpr(eMapType), m_key_up(key), m_value_up(value) {}
- ~GoASTMapType() override = default;
-
- const char *GetKindName() const override { return "MapType"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eMapType; }
-
- const GoASTExpr *GetKey() const { return m_key_up.get(); }
- void SetKey(GoASTExpr *key) { m_key_up.reset(key); }
-
- const GoASTExpr *GetValue() const { return m_value_up.get(); }
- void SetValue(GoASTExpr *value) { m_value_up.reset(value); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTExpr> m_key_up;
- std::unique_ptr<GoASTExpr> m_value_up;
-
- GoASTMapType(const GoASTMapType &) = delete;
- const GoASTMapType &operator=(const GoASTMapType &) = delete;
-};
-
-class GoASTParenExpr : public GoASTExpr {
-public:
- explicit GoASTParenExpr(GoASTExpr *x) : GoASTExpr(eParenExpr), m_x_up(x) {}
- ~GoASTParenExpr() override = default;
-
- const char *GetKindName() const override { return "ParenExpr"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eParenExpr; }
-
- const GoASTExpr *GetX() const { return m_x_up.get(); }
- void SetX(GoASTExpr *x) { m_x_up.reset(x); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTExpr> m_x_up;
-
- GoASTParenExpr(const GoASTParenExpr &) = delete;
- const GoASTParenExpr &operator=(const GoASTParenExpr &) = delete;
-};
-
-class GoASTRangeStmt : public GoASTStmt {
-public:
- GoASTRangeStmt(GoASTExpr *key, GoASTExpr *value, bool define, GoASTExpr *x,
- GoASTBlockStmt *body)
- : GoASTStmt(eRangeStmt), m_key_up(key), m_value_up(value),
- m_define(define), m_x_up(x), m_body_up(body) {}
- ~GoASTRangeStmt() override = default;
-
- const char *GetKindName() const override { return "RangeStmt"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eRangeStmt; }
-
- const GoASTExpr *GetKey() const { return m_key_up.get(); }
- void SetKey(GoASTExpr *key) { m_key_up.reset(key); }
-
- const GoASTExpr *GetValue() const { return m_value_up.get(); }
- void SetValue(GoASTExpr *value) { m_value_up.reset(value); }
-
- bool GetDefine() const { return m_define; }
- void SetDefine(bool define) { m_define = define; }
-
- const GoASTExpr *GetX() const { return m_x_up.get(); }
- void SetX(GoASTExpr *x) { m_x_up.reset(x); }
-
- const GoASTBlockStmt *GetBody() const { return m_body_up.get(); }
- void SetBody(GoASTBlockStmt *body) { m_body_up.reset(body); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTExpr> m_key_up;
- std::unique_ptr<GoASTExpr> m_value_up;
- bool m_define;
- std::unique_ptr<GoASTExpr> m_x_up;
- std::unique_ptr<GoASTBlockStmt> m_body_up;
-
- GoASTRangeStmt(const GoASTRangeStmt &) = delete;
- const GoASTRangeStmt &operator=(const GoASTRangeStmt &) = delete;
-};
-
-class GoASTReturnStmt : public GoASTStmt {
-public:
- GoASTReturnStmt() : GoASTStmt(eReturnStmt) {}
- ~GoASTReturnStmt() override = default;
-
- const char *GetKindName() const override { return "ReturnStmt"; }
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() == eReturnStmt;
- }
-
- size_t NumResults() const { return m_results.size(); }
- const GoASTExpr *GetResults(int i) const { return m_results[i].get(); }
- void AddResults(GoASTExpr *results) {
- m_results.push_back(std::unique_ptr<GoASTExpr>(results));
- }
-
-private:
- friend class GoASTNode;
- std::vector<std::unique_ptr<GoASTExpr>> m_results;
-
- GoASTReturnStmt(const GoASTReturnStmt &) = delete;
- const GoASTReturnStmt &operator=(const GoASTReturnStmt &) = delete;
-};
-
-class GoASTSelectStmt : public GoASTStmt {
-public:
- explicit GoASTSelectStmt(GoASTBlockStmt *body)
- : GoASTStmt(eSelectStmt), m_body_up(body) {}
- ~GoASTSelectStmt() override = default;
-
- const char *GetKindName() const override { return "SelectStmt"; }
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() == eSelectStmt;
- }
-
- const GoASTBlockStmt *GetBody() const { return m_body_up.get(); }
- void SetBody(GoASTBlockStmt *body) { m_body_up.reset(body); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTBlockStmt> m_body_up;
-
- GoASTSelectStmt(const GoASTSelectStmt &) = delete;
- const GoASTSelectStmt &operator=(const GoASTSelectStmt &) = delete;
-};
-
-class GoASTSelectorExpr : public GoASTExpr {
-public:
- GoASTSelectorExpr(GoASTExpr *x, GoASTIdent *sel)
- : GoASTExpr(eSelectorExpr), m_x_up(x), m_sel_up(sel) {}
- ~GoASTSelectorExpr() override = default;
-
- const char *GetKindName() const override { return "SelectorExpr"; }
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() == eSelectorExpr;
- }
-
- const GoASTExpr *GetX() const { return m_x_up.get(); }
- void SetX(GoASTExpr *x) { m_x_up.reset(x); }
-
- const GoASTIdent *GetSel() const { return m_sel_up.get(); }
- void SetSel(GoASTIdent *sel) { m_sel_up.reset(sel); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTExpr> m_x_up;
- std::unique_ptr<GoASTIdent> m_sel_up;
-
- GoASTSelectorExpr(const GoASTSelectorExpr &) = delete;
- const GoASTSelectorExpr &operator=(const GoASTSelectorExpr &) = delete;
-};
-
-class GoASTSendStmt : public GoASTStmt {
-public:
- GoASTSendStmt(GoASTExpr *chan, GoASTExpr *value)
- : GoASTStmt(eSendStmt), m_chan_up(chan), m_value_up(value) {}
- ~GoASTSendStmt() override = default;
-
- const char *GetKindName() const override { return "SendStmt"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eSendStmt; }
-
- const GoASTExpr *GetChan() const { return m_chan_up.get(); }
- void SetChan(GoASTExpr *chan) { m_chan_up.reset(chan); }
-
- const GoASTExpr *GetValue() const { return m_value_up.get(); }
- void SetValue(GoASTExpr *value) { m_value_up.reset(value); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTExpr> m_chan_up;
- std::unique_ptr<GoASTExpr> m_value_up;
-
- GoASTSendStmt(const GoASTSendStmt &) = delete;
- const GoASTSendStmt &operator=(const GoASTSendStmt &) = delete;
-};
-
-class GoASTSliceExpr : public GoASTExpr {
-public:
- GoASTSliceExpr(GoASTExpr *x, GoASTExpr *low, GoASTExpr *high, GoASTExpr *max,
- bool slice3)
- : GoASTExpr(eSliceExpr), m_x_up(x), m_low_up(low), m_high_up(high),
- m_max_up(max), m_slice3(slice3) {}
- ~GoASTSliceExpr() override = default;
-
- const char *GetKindName() const override { return "SliceExpr"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eSliceExpr; }
-
- const GoASTExpr *GetX() const { return m_x_up.get(); }
- void SetX(GoASTExpr *x) { m_x_up.reset(x); }
-
- const GoASTExpr *GetLow() const { return m_low_up.get(); }
- void SetLow(GoASTExpr *low) { m_low_up.reset(low); }
-
- const GoASTExpr *GetHigh() const { return m_high_up.get(); }
- void SetHigh(GoASTExpr *high) { m_high_up.reset(high); }
-
- const GoASTExpr *GetMax() const { return m_max_up.get(); }
- void SetMax(GoASTExpr *max) { m_max_up.reset(max); }
-
- bool GetSlice3() const { return m_slice3; }
- void SetSlice3(bool slice3) { m_slice3 = slice3; }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTExpr> m_x_up;
- std::unique_ptr<GoASTExpr> m_low_up;
- std::unique_ptr<GoASTExpr> m_high_up;
- std::unique_ptr<GoASTExpr> m_max_up;
- bool m_slice3;
-
- GoASTSliceExpr(const GoASTSliceExpr &) = delete;
- const GoASTSliceExpr &operator=(const GoASTSliceExpr &) = delete;
-};
-
-class GoASTStarExpr : public GoASTExpr {
-public:
- explicit GoASTStarExpr(GoASTExpr *x) : GoASTExpr(eStarExpr), m_x_up(x) {}
- ~GoASTStarExpr() override = default;
-
- const char *GetKindName() const override { return "StarExpr"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eStarExpr; }
-
- const GoASTExpr *GetX() const { return m_x_up.get(); }
- void SetX(GoASTExpr *x) { m_x_up.reset(x); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTExpr> m_x_up;
-
- GoASTStarExpr(const GoASTStarExpr &) = delete;
- const GoASTStarExpr &operator=(const GoASTStarExpr &) = delete;
-};
-
-class GoASTStructType : public GoASTExpr {
-public:
- explicit GoASTStructType(GoASTFieldList *fields)
- : GoASTExpr(eStructType), m_fields_up(fields) {}
- ~GoASTStructType() override = default;
-
- const char *GetKindName() const override { return "StructType"; }
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() == eStructType;
- }
-
- const GoASTFieldList *GetFields() const { return m_fields_up.get(); }
- void SetFields(GoASTFieldList *fields) { m_fields_up.reset(fields); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTFieldList> m_fields_up;
-
- GoASTStructType(const GoASTStructType &) = delete;
- const GoASTStructType &operator=(const GoASTStructType &) = delete;
-};
-
-class GoASTSwitchStmt : public GoASTStmt {
-public:
- GoASTSwitchStmt(GoASTStmt *init, GoASTExpr *tag, GoASTBlockStmt *body)
- : GoASTStmt(eSwitchStmt), m_init_up(init), m_tag_up(tag),
- m_body_up(body) {}
- ~GoASTSwitchStmt() override = default;
-
- const char *GetKindName() const override { return "SwitchStmt"; }
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() == eSwitchStmt;
- }
-
- const GoASTStmt *GetInit() const { return m_init_up.get(); }
- void SetInit(GoASTStmt *init) { m_init_up.reset(init); }
-
- const GoASTExpr *GetTag() const { return m_tag_up.get(); }
- void SetTag(GoASTExpr *tag) { m_tag_up.reset(tag); }
-
- const GoASTBlockStmt *GetBody() const { return m_body_up.get(); }
- void SetBody(GoASTBlockStmt *body) { m_body_up.reset(body); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTStmt> m_init_up;
- std::unique_ptr<GoASTExpr> m_tag_up;
- std::unique_ptr<GoASTBlockStmt> m_body_up;
-
- GoASTSwitchStmt(const GoASTSwitchStmt &) = delete;
- const GoASTSwitchStmt &operator=(const GoASTSwitchStmt &) = delete;
-};
-
-class GoASTTypeAssertExpr : public GoASTExpr {
-public:
- GoASTTypeAssertExpr(GoASTExpr *x, GoASTExpr *type)
- : GoASTExpr(eTypeAssertExpr), m_x_up(x), m_type_up(type) {}
- ~GoASTTypeAssertExpr() override = default;
-
- const char *GetKindName() const override { return "TypeAssertExpr"; }
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() == eTypeAssertExpr;
- }
-
- const GoASTExpr *GetX() const { return m_x_up.get(); }
- void SetX(GoASTExpr *x) { m_x_up.reset(x); }
-
- const GoASTExpr *GetType() const { return m_type_up.get(); }
- void SetType(GoASTExpr *type) { m_type_up.reset(type); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTExpr> m_x_up;
- std::unique_ptr<GoASTExpr> m_type_up;
-
- GoASTTypeAssertExpr(const GoASTTypeAssertExpr &) = delete;
- const GoASTTypeAssertExpr &operator=(const GoASTTypeAssertExpr &) = delete;
-};
-
-class GoASTTypeSpec : public GoASTSpec {
-public:
- GoASTTypeSpec(GoASTIdent *name, GoASTExpr *type)
- : GoASTSpec(eTypeSpec), m_name_up(name), m_type_up(type) {}
- ~GoASTTypeSpec() override = default;
-
- const char *GetKindName() const override { return "TypeSpec"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eTypeSpec; }
-
- const GoASTIdent *GetName() const { return m_name_up.get(); }
- void SetName(GoASTIdent *name) { m_name_up.reset(name); }
-
- const GoASTExpr *GetType() const { return m_type_up.get(); }
- void SetType(GoASTExpr *type) { m_type_up.reset(type); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTIdent> m_name_up;
- std::unique_ptr<GoASTExpr> m_type_up;
-
- GoASTTypeSpec(const GoASTTypeSpec &) = delete;
- const GoASTTypeSpec &operator=(const GoASTTypeSpec &) = delete;
-};
-
-class GoASTTypeSwitchStmt : public GoASTStmt {
-public:
- GoASTTypeSwitchStmt(GoASTStmt *init, GoASTStmt *assign, GoASTBlockStmt *body)
- : GoASTStmt(eTypeSwitchStmt), m_init_up(init), m_assign_up(assign),
- m_body_up(body) {}
- ~GoASTTypeSwitchStmt() override = default;
-
- const char *GetKindName() const override { return "TypeSwitchStmt"; }
-
- static bool classof(const GoASTNode *n) {
- return n->GetKind() == eTypeSwitchStmt;
- }
-
- const GoASTStmt *GetInit() const { return m_init_up.get(); }
- void SetInit(GoASTStmt *init) { m_init_up.reset(init); }
-
- const GoASTStmt *GetAssign() const { return m_assign_up.get(); }
- void SetAssign(GoASTStmt *assign) { m_assign_up.reset(assign); }
-
- const GoASTBlockStmt *GetBody() const { return m_body_up.get(); }
- void SetBody(GoASTBlockStmt *body) { m_body_up.reset(body); }
-
-private:
- friend class GoASTNode;
- std::unique_ptr<GoASTStmt> m_init_up;
- std::unique_ptr<GoASTStmt> m_assign_up;
- std::unique_ptr<GoASTBlockStmt> m_body_up;
-
- GoASTTypeSwitchStmt(const GoASTTypeSwitchStmt &) = delete;
- const GoASTTypeSwitchStmt &operator=(const GoASTTypeSwitchStmt &) = delete;
-};
-
-class GoASTUnaryExpr : public GoASTExpr {
-public:
- GoASTUnaryExpr(TokenType op, GoASTExpr *x)
- : GoASTExpr(eUnaryExpr), m_op(op), m_x_up(x) {}
- ~GoASTUnaryExpr() override = default;
-
- const char *GetKindName() const override { return "UnaryExpr"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eUnaryExpr; }
-
- TokenType GetOp() const { return m_op; }
- void SetOp(TokenType op) { m_op = op; }
-
- const GoASTExpr *GetX() const { return m_x_up.get(); }
- void SetX(GoASTExpr *x) { m_x_up.reset(x); }
-
-private:
- friend class GoASTNode;
- TokenType m_op;
- std::unique_ptr<GoASTExpr> m_x_up;
-
- GoASTUnaryExpr(const GoASTUnaryExpr &) = delete;
- const GoASTUnaryExpr &operator=(const GoASTUnaryExpr &) = delete;
-};
-
-class GoASTValueSpec : public GoASTSpec {
-public:
- GoASTValueSpec() : GoASTSpec(eValueSpec) {}
- ~GoASTValueSpec() override = default;
-
- const char *GetKindName() const override { return "ValueSpec"; }
-
- static bool classof(const GoASTNode *n) { return n->GetKind() == eValueSpec; }
-
- size_t NumNames() const { return m_names.size(); }
- const GoASTIdent *GetNames(int i) const { return m_names[i].get(); }
- void AddNames(GoASTIdent *names) {
- m_names.push_back(std::unique_ptr<GoASTIdent>(names));
- }
-
- const GoASTExpr *GetType() const { return m_type_up.get(); }
- void SetType(GoASTExpr *type) { m_type_up.reset(type); }
-
- size_t NumValues() const { return m_values.size(); }
- const GoASTExpr *GetValues(int i) const { return m_values[i].get(); }
- void AddValues(GoASTExpr *values) {
- m_values.push_back(std::unique_ptr<GoASTExpr>(values));
- }
-
-private:
- friend class GoASTNode;
- std::vector<std::unique_ptr<GoASTIdent>> m_names;
- std::unique_ptr<GoASTExpr> m_type_up;
- std::vector<std::unique_ptr<GoASTExpr>> m_values;
-
- GoASTValueSpec(const GoASTValueSpec &) = delete;
- const GoASTValueSpec &operator=(const GoASTValueSpec &) = delete;
-};
-
-template <typename R, typename V> R GoASTDecl::Visit(V *v) const {
- switch (GetKind()) {
- case eBadDecl:
- return v->VisitBadDecl(llvm::cast<const GoASTBadDecl>(this));
- case eFuncDecl:
- return v->VisitFuncDecl(llvm::cast<const GoASTFuncDecl>(this));
- case eGenDecl:
- return v->VisitGenDecl(llvm::cast<const GoASTGenDecl>(this));
- default:
- assert(false && "Invalid kind");
- }
-}
-
-template <typename R, typename V> R GoASTExpr::Visit(V *v) const {
- switch (GetKind()) {
- case eArrayType:
- return v->VisitArrayType(llvm::cast<const GoASTArrayType>(this));
- case eBadExpr:
- return v->VisitBadExpr(llvm::cast<const GoASTBadExpr>(this));
- case eBasicLit:
- return v->VisitBasicLit(llvm::cast<const GoASTBasicLit>(this));
- case eBinaryExpr:
- return v->VisitBinaryExpr(llvm::cast<const GoASTBinaryExpr>(this));
- case eIdent:
- return v->VisitIdent(llvm::cast<const GoASTIdent>(this));
- case eCallExpr:
- return v->VisitCallExpr(llvm::cast<const GoASTCallExpr>(this));
- case eChanType:
- return v->VisitChanType(llvm::cast<const GoASTChanType>(this));
- case eCompositeLit:
- return v->VisitCompositeLit(llvm::cast<const GoASTCompositeLit>(this));
- case eEllipsis:
- return v->VisitEllipsis(llvm::cast<const GoASTEllipsis>(this));
- case eFuncType:
- return v->VisitFuncType(llvm::cast<const GoASTFuncType>(this));
- case eFuncLit:
- return v->VisitFuncLit(llvm::cast<const GoASTFuncLit>(this));
- case eIndexExpr:
- return v->VisitIndexExpr(llvm::cast<const GoASTIndexExpr>(this));
- case eInterfaceType:
- return v->VisitInterfaceType(llvm::cast<const GoASTInterfaceType>(this));
- case eKeyValueExpr:
- return v->VisitKeyValueExpr(llvm::cast<const GoASTKeyValueExpr>(this));
- case eMapType:
- return v->VisitMapType(llvm::cast<const GoASTMapType>(this));
- case eParenExpr:
- return v->VisitParenExpr(llvm::cast<const GoASTParenExpr>(this));
- case eSelectorExpr:
- return v->VisitSelectorExpr(llvm::cast<const GoASTSelectorExpr>(this));
- case eSliceExpr:
- return v->VisitSliceExpr(llvm::cast<const GoASTSliceExpr>(this));
- case eStarExpr:
- return v->VisitStarExpr(llvm::cast<const GoASTStarExpr>(this));
- case eStructType:
- return v->VisitStructType(llvm::cast<const GoASTStructType>(this));
- case eTypeAssertExpr:
- return v->VisitTypeAssertExpr(llvm::cast<const GoASTTypeAssertExpr>(this));
- case eUnaryExpr:
- return v->VisitUnaryExpr(llvm::cast<const GoASTUnaryExpr>(this));
- default:
- assert(false && "Invalid kind");
- return R();
- }
-}
-
-template <typename R, typename V> R GoASTSpec::Visit(V *v) const {
- switch (GetKind()) {
- case eImportSpec:
- return v->VisitImportSpec(llvm::cast<const GoASTImportSpec>(this));
- case eTypeSpec:
- return v->VisitTypeSpec(llvm::cast<const GoASTTypeSpec>(this));
- case eValueSpec:
- return v->VisitValueSpec(llvm::cast<const GoASTValueSpec>(this));
- default:
- assert(false && "Invalid kind");
- }
-}
-
-template <typename R, typename V> R GoASTStmt::Visit(V *v) const {
- switch (GetKind()) {
- case eAssignStmt:
- return v->VisitAssignStmt(llvm::cast<const GoASTAssignStmt>(this));
- case eBadStmt:
- return v->VisitBadStmt(llvm::cast<const GoASTBadStmt>(this));
- case eBlockStmt:
- return v->VisitBlockStmt(llvm::cast<const GoASTBlockStmt>(this));
- case eBranchStmt:
- return v->VisitBranchStmt(llvm::cast<const GoASTBranchStmt>(this));
- case eCaseClause:
- return v->VisitCaseClause(llvm::cast<const GoASTCaseClause>(this));
- case eCommClause:
- return v->VisitCommClause(llvm::cast<const GoASTCommClause>(this));
- case eDeclStmt:
- return v->VisitDeclStmt(llvm::cast<const GoASTDeclStmt>(this));
- case eDeferStmt:
- return v->VisitDeferStmt(llvm::cast<const GoASTDeferStmt>(this));
- case eEmptyStmt:
- return v->VisitEmptyStmt(llvm::cast<const GoASTEmptyStmt>(this));
- case eExprStmt:
- return v->VisitExprStmt(llvm::cast<const GoASTExprStmt>(this));
- case eForStmt:
- return v->VisitForStmt(llvm::cast<const GoASTForStmt>(this));
- case eGoStmt:
- return v->VisitGoStmt(llvm::cast<const GoASTGoStmt>(this));
- case eIfStmt:
- return v->VisitIfStmt(llvm::cast<const GoASTIfStmt>(this));
- case eIncDecStmt:
- return v->VisitIncDecStmt(llvm::cast<const GoASTIncDecStmt>(this));
- case eLabeledStmt:
- return v->VisitLabeledStmt(llvm::cast<const GoASTLabeledStmt>(this));
- case eRangeStmt:
- return v->VisitRangeStmt(llvm::cast<const GoASTRangeStmt>(this));
- case eReturnStmt:
- return v->VisitReturnStmt(llvm::cast<const GoASTReturnStmt>(this));
- case eSelectStmt:
- return v->VisitSelectStmt(llvm::cast<const GoASTSelectStmt>(this));
- case eSendStmt:
- return v->VisitSendStmt(llvm::cast<const GoASTSendStmt>(this));
- case eSwitchStmt:
- return v->VisitSwitchStmt(llvm::cast<const GoASTSwitchStmt>(this));
- case eTypeSwitchStmt:
- return v->VisitTypeSwitchStmt(llvm::cast<const GoASTTypeSwitchStmt>(this));
- default:
- assert(false && "Invalid kind");
- }
-}
-
-template <typename V> void GoASTNode::WalkChildren(V &v) {
- switch (m_kind) {
-
- case eArrayType: {
- GoASTArrayType *n = llvm::cast<GoASTArrayType>(this);
- (void)n;
- v(n->m_len_up.get());
- v(n->m_elt_up.get());
- return;
- }
- case eAssignStmt: {
- GoASTAssignStmt *n = llvm::cast<GoASTAssignStmt>(this);
- (void)n;
- for (auto &e : n->m_lhs) {
- v(e.get());
- }
- for (auto &e : n->m_rhs) {
- v(e.get());
- }
- return;
- }
- case eBasicLit: {
- GoASTBasicLit *n = llvm::cast<GoASTBasicLit>(this);
- (void)n;
- return;
- }
- case eBinaryExpr: {
- GoASTBinaryExpr *n = llvm::cast<GoASTBinaryExpr>(this);
- (void)n;
- v(n->m_x_up.get());
- v(n->m_y_up.get());
- return;
- }
- case eBlockStmt: {
- GoASTBlockStmt *n = llvm::cast<GoASTBlockStmt>(this);
- (void)n;
- for (auto &e : n->m_list) {
- v(e.get());
- }
- return;
- }
- case eIdent: {
- GoASTIdent *n = llvm::cast<GoASTIdent>(this);
- (void)n;
- return;
- }
- case eBranchStmt: {
- GoASTBranchStmt *n = llvm::cast<GoASTBranchStmt>(this);
- (void)n;
- v(n->m_label_up.get());
- return;
- }
- case eCallExpr: {
- GoASTCallExpr *n = llvm::cast<GoASTCallExpr>(this);
- (void)n;
- v(n->m_fun_up.get());
- for (auto &e : n->m_args) {
- v(e.get());
- }
- return;
- }
- case eCaseClause: {
- GoASTCaseClause *n = llvm::cast<GoASTCaseClause>(this);
- (void)n;
- for (auto &e : n->m_list) {
- v(e.get());
- }
- for (auto &e : n->m_body) {
- v(e.get());
- }
- return;
- }
- case eChanType: {
- GoASTChanType *n = llvm::cast<GoASTChanType>(this);
- (void)n;
- v(n->m_value_up.get());
- return;
- }
- case eCommClause: {
- GoASTCommClause *n = llvm::cast<GoASTCommClause>(this);
- (void)n;
- v(n->m_comm_up.get());
- for (auto &e : n->m_body) {
- v(e.get());
- }
- return;
- }
- case eCompositeLit: {
- GoASTCompositeLit *n = llvm::cast<GoASTCompositeLit>(this);
- (void)n;
- v(n->m_type_up.get());
- for (auto &e : n->m_elts) {
- v(e.get());
- }
- return;
- }
- case eDeclStmt: {
- GoASTDeclStmt *n = llvm::cast<GoASTDeclStmt>(this);
- (void)n;
- v(n->m_decl_up.get());
- return;
- }
- case eDeferStmt: {
- GoASTDeferStmt *n = llvm::cast<GoASTDeferStmt>(this);
- (void)n;
- v(n->m_call_up.get());
- return;
- }
- case eEllipsis: {
- GoASTEllipsis *n = llvm::cast<GoASTEllipsis>(this);
- (void)n;
- v(n->m_elt_up.get());
- return;
- }
- case eExprStmt: {
- GoASTExprStmt *n = llvm::cast<GoASTExprStmt>(this);
- (void)n;
- v(n->m_x_up.get());
- return;
- }
- case eField: {
- GoASTField *n = llvm::cast<GoASTField>(this);
- (void)n;
- for (auto &e : n->m_names) {
- v(e.get());
- }
- v(n->m_type_up.get());
- v(n->m_tag_up.get());
- return;
- }
- case eFieldList: {
- GoASTFieldList *n = llvm::cast<GoASTFieldList>(this);
- (void)n;
- for (auto &e : n->m_list) {
- v(e.get());
- }
- return;
- }
- case eForStmt: {
- GoASTForStmt *n = llvm::cast<GoASTForStmt>(this);
- (void)n;
- v(n->m_init_up.get());
- v(n->m_cond_up.get());
- v(n->m_post_up.get());
- v(n->m_body_up.get());
- return;
- }
- case eFuncType: {
- GoASTFuncType *n = llvm::cast<GoASTFuncType>(this);
- (void)n;
- v(n->m_params_up.get());
- v(n->m_results_up.get());
- return;
- }
- case eFuncDecl: {
- GoASTFuncDecl *n = llvm::cast<GoASTFuncDecl>(this);
- (void)n;
- v(n->m_recv_up.get());
- v(n->m_name_up.get());
- v(n->m_type_up.get());
- v(n->m_body_up.get());
- return;
- }
- case eFuncLit: {
- GoASTFuncLit *n = llvm::cast<GoASTFuncLit>(this);
- (void)n;
- v(n->m_type_up.get());
- v(n->m_body_up.get());
- return;
- }
- case eGenDecl: {
- GoASTGenDecl *n = llvm::cast<GoASTGenDecl>(this);
- (void)n;
- for (auto &e : n->m_specs) {
- v(e.get());
- }
- return;
- }
- case eGoStmt: {
- GoASTGoStmt *n = llvm::cast<GoASTGoStmt>(this);
- (void)n;
- v(n->m_call_up.get());
- return;
- }
- case eIfStmt: {
- GoASTIfStmt *n = llvm::cast<GoASTIfStmt>(this);
- (void)n;
- v(n->m_init_up.get());
- v(n->m_cond_up.get());
- v(n->m_body_up.get());
- v(n->m_els_up.get());
- return;
- }
- case eImportSpec: {
- GoASTImportSpec *n = llvm::cast<GoASTImportSpec>(this);
- (void)n;
- v(n->m_name_up.get());
- v(n->m_path_up.get());
- return;
- }
- case eIncDecStmt: {
- GoASTIncDecStmt *n = llvm::cast<GoASTIncDecStmt>(this);
- (void)n;
- v(n->m_x_up.get());
- return;
- }
- case eIndexExpr: {
- GoASTIndexExpr *n = llvm::cast<GoASTIndexExpr>(this);
- (void)n;
- v(n->m_x_up.get());
- v(n->m_index_up.get());
- return;
- }
- case eInterfaceType: {
- GoASTInterfaceType *n = llvm::cast<GoASTInterfaceType>(this);
- (void)n;
- v(n->m_methods_up.get());
- return;
- }
- case eKeyValueExpr: {
- GoASTKeyValueExpr *n = llvm::cast<GoASTKeyValueExpr>(this);
- (void)n;
- v(n->m_key_up.get());
- v(n->m_value_up.get());
- return;
- }
- case eLabeledStmt: {
- GoASTLabeledStmt *n = llvm::cast<GoASTLabeledStmt>(this);
- (void)n;
- v(n->m_label_up.get());
- v(n->m_stmt_up.get());
- return;
- }
- case eMapType: {
- GoASTMapType *n = llvm::cast<GoASTMapType>(this);
- (void)n;
- v(n->m_key_up.get());
- v(n->m_value_up.get());
- return;
- }
- case eParenExpr: {
- GoASTParenExpr *n = llvm::cast<GoASTParenExpr>(this);
- (void)n;
- v(n->m_x_up.get());
- return;
- }
- case eRangeStmt: {
- GoASTRangeStmt *n = llvm::cast<GoASTRangeStmt>(this);
- (void)n;
- v(n->m_key_up.get());
- v(n->m_value_up.get());
- v(n->m_x_up.get());
- v(n->m_body_up.get());
- return;
- }
- case eReturnStmt: {
- GoASTReturnStmt *n = llvm::cast<GoASTReturnStmt>(this);
- (void)n;
- for (auto &e : n->m_results) {
- v(e.get());
- }
- return;
- }
- case eSelectStmt: {
- GoASTSelectStmt *n = llvm::cast<GoASTSelectStmt>(this);
- (void)n;
- v(n->m_body_up.get());
- return;
- }
- case eSelectorExpr: {
- GoASTSelectorExpr *n = llvm::cast<GoASTSelectorExpr>(this);
- (void)n;
- v(n->m_x_up.get());
- v(n->m_sel_up.get());
- return;
- }
- case eSendStmt: {
- GoASTSendStmt *n = llvm::cast<GoASTSendStmt>(this);
- (void)n;
- v(n->m_chan_up.get());
- v(n->m_value_up.get());
- return;
- }
- case eSliceExpr: {
- GoASTSliceExpr *n = llvm::cast<GoASTSliceExpr>(this);
- (void)n;
- v(n->m_x_up.get());
- v(n->m_low_up.get());
- v(n->m_high_up.get());
- v(n->m_max_up.get());
- return;
- }
- case eStarExpr: {
- GoASTStarExpr *n = llvm::cast<GoASTStarExpr>(this);
- (void)n;
- v(n->m_x_up.get());
- return;
- }
- case eStructType: {
- GoASTStructType *n = llvm::cast<GoASTStructType>(this);
- (void)n;
- v(n->m_fields_up.get());
- return;
- }
- case eSwitchStmt: {
- GoASTSwitchStmt *n = llvm::cast<GoASTSwitchStmt>(this);
- (void)n;
- v(n->m_init_up.get());
- v(n->m_tag_up.get());
- v(n->m_body_up.get());
- return;
- }
- case eTypeAssertExpr: {
- GoASTTypeAssertExpr *n = llvm::cast<GoASTTypeAssertExpr>(this);
- (void)n;
- v(n->m_x_up.get());
- v(n->m_type_up.get());
- return;
- }
- case eTypeSpec: {
- GoASTTypeSpec *n = llvm::cast<GoASTTypeSpec>(this);
- (void)n;
- v(n->m_name_up.get());
- v(n->m_type_up.get());
- return;
- }
- case eTypeSwitchStmt: {
- GoASTTypeSwitchStmt *n = llvm::cast<GoASTTypeSwitchStmt>(this);
- (void)n;
- v(n->m_init_up.get());
- v(n->m_assign_up.get());
- v(n->m_body_up.get());
- return;
- }
- case eUnaryExpr: {
- GoASTUnaryExpr *n = llvm::cast<GoASTUnaryExpr>(this);
- (void)n;
- v(n->m_x_up.get());
- return;
- }
- case eValueSpec: {
- GoASTValueSpec *n = llvm::cast<GoASTValueSpec>(this);
- (void)n;
- for (auto &e : n->m_names) {
- v(e.get());
- }
- v(n->m_type_up.get());
- for (auto &e : n->m_values) {
- v(e.get());
- }
- return;
- }
-
- case eEmptyStmt:
- case eBadDecl:
- case eBadExpr:
- case eBadStmt:
- break;
- }
-}
-
-} // namespace lldb_private
-
-#endif
diff --git a/source/Plugins/ExpressionParser/Go/GoLexer.cpp b/source/Plugins/ExpressionParser/Go/GoLexer.cpp
deleted file mode 100644
index 63e267eaadc2..000000000000
--- a/source/Plugins/ExpressionParser/Go/GoLexer.cpp
+++ /dev/null
@@ -1,350 +0,0 @@
-//===-- GoLexer.cpp ---------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <string.h>
-
-#include "GoLexer.h"
-
-using namespace lldb_private;
-
-llvm::StringMap<GoLexer::TokenType> *GoLexer::m_keywords;
-
-GoLexer::GoLexer(const char *src)
- : m_src(src), m_end(src + strlen(src)), m_last_token(TOK_INVALID, "") {}
-
-bool GoLexer::SkipWhitespace() {
- bool saw_newline = false;
- for (; m_src < m_end; ++m_src) {
- if (*m_src == '\n')
- saw_newline = true;
- if (*m_src == '/' && !SkipComment())
- return saw_newline;
- else if (!IsWhitespace(*m_src))
- return saw_newline;
- }
- return saw_newline;
-}
-
-bool GoLexer::SkipComment() {
- if (m_src[0] == '/' && m_src[1] == '/') {
- for (const char *c = m_src + 2; c < m_end; ++c) {
- if (*c == '\n') {
- m_src = c - 1;
- return true;
- }
- }
- return true;
- } else if (m_src[0] == '/' && m_src[1] == '*') {
- for (const char *c = m_src + 2; c < m_end; ++c) {
- if (c[0] == '*' && c[1] == '/') {
- m_src = c + 1;
- return true;
- }
- }
- }
- return false;
-}
-
-const GoLexer::Token &GoLexer::Lex() {
- bool newline = SkipWhitespace();
- const char *start = m_src;
- m_last_token.m_type = InternalLex(newline);
- m_last_token.m_value = llvm::StringRef(start, m_src - start);
- return m_last_token;
-}
-
-GoLexer::TokenType GoLexer::InternalLex(bool newline) {
- if (m_src >= m_end) {
- return TOK_EOF;
- }
- if (newline) {
- switch (m_last_token.m_type) {
- case TOK_IDENTIFIER:
- case LIT_FLOAT:
- case LIT_IMAGINARY:
- case LIT_INTEGER:
- case LIT_RUNE:
- case LIT_STRING:
- case KEYWORD_BREAK:
- case KEYWORD_CONTINUE:
- case KEYWORD_FALLTHROUGH:
- case KEYWORD_RETURN:
- case OP_PLUS_PLUS:
- case OP_MINUS_MINUS:
- case OP_RPAREN:
- case OP_RBRACK:
- case OP_RBRACE:
- return OP_SEMICOLON;
- default:
- break;
- }
- }
- char c = *m_src;
- switch (c) {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- return DoNumber();
- case '+':
- case '-':
- case '*':
- case '/':
- case '%':
- case '&':
- case '|':
- case '^':
- case '<':
- case '>':
- case '!':
- case ':':
- case ';':
- case '(':
- case ')':
- case '[':
- case ']':
- case '{':
- case '}':
- case ',':
- case '=':
- return DoOperator();
- case '.':
- if (IsDecimal(m_src[1]))
- return DoNumber();
- return DoOperator();
- case '$':
- // For lldb persistent vars.
- return DoIdent();
- case '"':
- case '`':
- return DoString();
- case '\'':
- return DoRune();
- default:
- break;
- }
- if (IsLetterOrDigit(c))
- return DoIdent();
- ++m_src;
- return TOK_INVALID;
-}
-
-GoLexer::TokenType GoLexer::DoOperator() {
- TokenType t = TOK_INVALID;
- if (m_end - m_src > 2) {
- t = LookupKeyword(llvm::StringRef(m_src, 3));
- if (t != TOK_INVALID)
- m_src += 3;
- }
- if (t == TOK_INVALID && m_end - m_src > 1) {
- t = LookupKeyword(llvm::StringRef(m_src, 2));
- if (t != TOK_INVALID)
- m_src += 2;
- }
- if (t == TOK_INVALID) {
- t = LookupKeyword(llvm::StringRef(m_src, 1));
- ++m_src;
- }
- return t;
-}
-
-GoLexer::TokenType GoLexer::DoIdent() {
- const char *start = m_src++;
- while (m_src < m_end && IsLetterOrDigit(*m_src)) {
- ++m_src;
- }
- TokenType kw = LookupKeyword(llvm::StringRef(start, m_src - start));
- if (kw != TOK_INVALID)
- return kw;
- return TOK_IDENTIFIER;
-}
-
-GoLexer::TokenType GoLexer::DoNumber() {
- if (m_src[0] == '0' && (m_src[1] == 'x' || m_src[1] == 'X')) {
- m_src += 2;
- while (IsHexChar(*m_src))
- ++m_src;
- return LIT_INTEGER;
- }
- bool dot_ok = true;
- bool e_ok = true;
- while (true) {
- while (IsDecimal(*m_src))
- ++m_src;
- switch (*m_src) {
- case 'i':
- ++m_src;
- return LIT_IMAGINARY;
- case '.':
- if (!dot_ok)
- return LIT_FLOAT;
- ++m_src;
- dot_ok = false;
- break;
- case 'e':
- case 'E':
- if (!e_ok)
- return LIT_FLOAT;
- dot_ok = e_ok = false;
- ++m_src;
- if (*m_src == '+' || *m_src == '-')
- ++m_src;
- break;
- default:
- if (dot_ok)
- return LIT_INTEGER;
- return LIT_FLOAT;
- }
- }
-}
-
-GoLexer::TokenType GoLexer::DoRune() {
- while (++m_src < m_end) {
- switch (*m_src) {
- case '\'':
- ++m_src;
- return LIT_RUNE;
- case '\n':
- return TOK_INVALID;
- case '\\':
- if (m_src[1] == '\n')
- return TOK_INVALID;
- ++m_src;
- }
- }
- return TOK_INVALID;
-}
-
-GoLexer::TokenType GoLexer::DoString() {
- if (*m_src == '`') {
- while (++m_src < m_end) {
- if (*m_src == '`') {
- ++m_src;
- return LIT_STRING;
- }
- }
- return TOK_INVALID;
- }
- while (++m_src < m_end) {
- switch (*m_src) {
- case '"':
- ++m_src;
- return LIT_STRING;
- case '\n':
- return TOK_INVALID;
- case '\\':
- if (m_src[1] == '\n')
- return TOK_INVALID;
- ++m_src;
- }
- }
- return TOK_INVALID;
-}
-
-GoLexer::TokenType GoLexer::LookupKeyword(llvm::StringRef id) {
- if (m_keywords == nullptr)
- m_keywords = InitKeywords();
- const auto &it = m_keywords->find(id);
- if (it == m_keywords->end())
- return TOK_INVALID;
- return it->second;
-}
-
-llvm::StringRef GoLexer::LookupToken(TokenType t) {
- if (m_keywords == nullptr)
- m_keywords = InitKeywords();
- for (const auto &e : *m_keywords) {
- if (e.getValue() == t)
- return e.getKey();
- }
- return "";
-}
-
-llvm::StringMap<GoLexer::TokenType> *GoLexer::InitKeywords() {
- auto &result = *new llvm::StringMap<TokenType>(128);
- result["break"] = KEYWORD_BREAK;
- result["default"] = KEYWORD_DEFAULT;
- result["func"] = KEYWORD_FUNC;
- result["interface"] = KEYWORD_INTERFACE;
- result["select"] = KEYWORD_SELECT;
- result["case"] = KEYWORD_CASE;
- result["defer"] = KEYWORD_DEFER;
- result["go"] = KEYWORD_GO;
- result["map"] = KEYWORD_MAP;
- result["struct"] = KEYWORD_STRUCT;
- result["chan"] = KEYWORD_CHAN;
- result["else"] = KEYWORD_ELSE;
- result["goto"] = KEYWORD_GOTO;
- result["package"] = KEYWORD_PACKAGE;
- result["switch"] = KEYWORD_SWITCH;
- result["const"] = KEYWORD_CONST;
- result["fallthrough"] = KEYWORD_FALLTHROUGH;
- result["if"] = KEYWORD_IF;
- result["range"] = KEYWORD_RANGE;
- result["type"] = KEYWORD_TYPE;
- result["continue"] = KEYWORD_CONTINUE;
- result["for"] = KEYWORD_FOR;
- result["import"] = KEYWORD_IMPORT;
- result["return"] = KEYWORD_RETURN;
- result["var"] = KEYWORD_VAR;
- result["+"] = OP_PLUS;
- result["-"] = OP_MINUS;
- result["*"] = OP_STAR;
- result["/"] = OP_SLASH;
- result["%"] = OP_PERCENT;
- result["&"] = OP_AMP;
- result["|"] = OP_PIPE;
- result["^"] = OP_CARET;
- result["<<"] = OP_LSHIFT;
- result[">>"] = OP_RSHIFT;
- result["&^"] = OP_AMP_CARET;
- result["+="] = OP_PLUS_EQ;
- result["-="] = OP_MINUS_EQ;
- result["*="] = OP_STAR_EQ;
- result["/="] = OP_SLASH_EQ;
- result["%="] = OP_PERCENT_EQ;
- result["&="] = OP_AMP_EQ;
- result["|="] = OP_PIPE_EQ;
- result["^="] = OP_CARET_EQ;
- result["<<="] = OP_LSHIFT_EQ;
- result[">>="] = OP_RSHIFT_EQ;
- result["&^="] = OP_AMP_CARET_EQ;
- result["&&"] = OP_AMP_AMP;
- result["||"] = OP_PIPE_PIPE;
- result["<-"] = OP_LT_MINUS;
- result["++"] = OP_PLUS_PLUS;
- result["--"] = OP_MINUS_MINUS;
- result["=="] = OP_EQ_EQ;
- result["<"] = OP_LT;
- result[">"] = OP_GT;
- result["="] = OP_EQ;
- result["!"] = OP_BANG;
- result["!="] = OP_BANG_EQ;
- result["<="] = OP_LT_EQ;
- result[">="] = OP_GT_EQ;
- result[":="] = OP_COLON_EQ;
- result["..."] = OP_DOTS;
- result["("] = OP_LPAREN;
- result["["] = OP_LBRACK;
- result["{"] = OP_LBRACE;
- result[","] = OP_COMMA;
- result["."] = OP_DOT;
- result[")"] = OP_RPAREN;
- result["]"] = OP_RBRACK;
- result["}"] = OP_RBRACE;
- result[";"] = OP_SEMICOLON;
- result[":"] = OP_COLON;
- return &result;
-}
diff --git a/source/Plugins/ExpressionParser/Go/GoLexer.h b/source/Plugins/ExpressionParser/Go/GoLexer.h
deleted file mode 100644
index f0b5b336fbe9..000000000000
--- a/source/Plugins/ExpressionParser/Go/GoLexer.h
+++ /dev/null
@@ -1,181 +0,0 @@
-//===-- GoLexer.h -----------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_GoLexer_h
-#define liblldb_GoLexer_h
-
-#include "llvm/ADT/StringMap.h"
-#include "llvm/ADT/StringRef.h"
-
-namespace lldb_private {
-
-class GoLexer {
-public:
- explicit GoLexer(const char *src);
-
- enum TokenType {
- TOK_EOF,
- TOK_INVALID,
- TOK_IDENTIFIER,
- LIT_INTEGER,
- LIT_FLOAT,
- LIT_IMAGINARY,
- LIT_RUNE,
- LIT_STRING,
- KEYWORD_BREAK,
- KEYWORD_DEFAULT,
- KEYWORD_FUNC,
- KEYWORD_INTERFACE,
- KEYWORD_SELECT,
- KEYWORD_CASE,
- KEYWORD_DEFER,
- KEYWORD_GO,
- KEYWORD_MAP,
- KEYWORD_STRUCT,
- KEYWORD_CHAN,
- KEYWORD_ELSE,
- KEYWORD_GOTO,
- KEYWORD_PACKAGE,
- KEYWORD_SWITCH,
- KEYWORD_CONST,
- KEYWORD_FALLTHROUGH,
- KEYWORD_IF,
- KEYWORD_RANGE,
- KEYWORD_TYPE,
- KEYWORD_CONTINUE,
- KEYWORD_FOR,
- KEYWORD_IMPORT,
- KEYWORD_RETURN,
- KEYWORD_VAR,
- OP_PLUS,
- OP_MINUS,
- OP_STAR,
- OP_SLASH,
- OP_PERCENT,
- OP_AMP,
- OP_PIPE,
- OP_CARET,
- OP_LSHIFT,
- OP_RSHIFT,
- OP_AMP_CARET,
- OP_PLUS_EQ,
- OP_MINUS_EQ,
- OP_STAR_EQ,
- OP_SLASH_EQ,
- OP_PERCENT_EQ,
- OP_AMP_EQ,
- OP_PIPE_EQ,
- OP_CARET_EQ,
- OP_LSHIFT_EQ,
- OP_RSHIFT_EQ,
- OP_AMP_CARET_EQ,
- OP_AMP_AMP,
- OP_PIPE_PIPE,
- OP_LT_MINUS,
- OP_PLUS_PLUS,
- OP_MINUS_MINUS,
- OP_EQ_EQ,
- OP_LT,
- OP_GT,
- OP_EQ,
- OP_BANG,
- OP_BANG_EQ,
- OP_LT_EQ,
- OP_GT_EQ,
- OP_COLON_EQ,
- OP_DOTS,
- OP_LPAREN,
- OP_LBRACK,
- OP_LBRACE,
- OP_COMMA,
- OP_DOT,
- OP_RPAREN,
- OP_RBRACK,
- OP_RBRACE,
- OP_SEMICOLON,
- OP_COLON,
- };
-
- struct Token {
- explicit Token(TokenType t, llvm::StringRef text)
- : m_type(t), m_value(text) {}
- TokenType m_type;
- llvm::StringRef m_value;
- };
-
- const Token &Lex();
-
- size_t BytesRemaining() const { return m_end - m_src; }
- llvm::StringRef GetString(int len) const {
- return llvm::StringRef(m_src, len);
- }
-
- static TokenType LookupKeyword(llvm::StringRef id);
- static llvm::StringRef LookupToken(TokenType t);
-
-private:
- bool IsDecimal(char c) { return c >= '0' && c <= '9'; }
- bool IsHexChar(char c) {
- if (c >= '0' && c <= '9')
- return true;
- if (c >= 'A' && c <= 'F')
- return true;
- if (c >= 'a' && c <= 'f')
- return true;
- return false;
- }
- bool IsLetterOrDigit(char c) {
- if (c >= 'a' && c <= 'z')
- return true;
- if (c >= 'A' && c <= 'Z')
- return true;
- if (c == '_')
- return true;
- if (c >= '0' && c <= '9')
- return true;
- // Treat all non-ascii chars as letters for simplicity.
- return 0 != (c & 0x80);
- }
- bool IsWhitespace(char c) {
- switch (c) {
- case ' ':
- case '\t':
- case '\r':
- return true;
- }
- return false;
- }
-
- bool SkipWhitespace();
- bool SkipComment();
-
- TokenType InternalLex(bool newline);
-
- TokenType DoOperator();
-
- TokenType DoIdent();
-
- TokenType DoNumber();
-
- TokenType DoRune();
-
- TokenType DoString();
-
- static llvm::StringMap<TokenType> *InitKeywords();
-
- static llvm::StringMap<TokenType> *m_keywords;
-
- const char *m_src;
- const char *m_end;
- Token m_last_token;
-};
-
-} // namespace lldb_private
-
-#endif
diff --git a/source/Plugins/ExpressionParser/Go/GoParser.cpp b/source/Plugins/ExpressionParser/Go/GoParser.cpp
deleted file mode 100644
index 9c845d02bca0..000000000000
--- a/source/Plugins/ExpressionParser/Go/GoParser.cpp
+++ /dev/null
@@ -1,886 +0,0 @@
-//===-- GoParser.cpp ---------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <vector>
-
-#include "GoParser.h"
-
-#include "Plugins/ExpressionParser/Go/GoAST.h"
-#include "lldb/Utility/Status.h"
-#include "llvm/ADT/SmallString.h"
-
-using namespace lldb_private;
-using namespace lldb;
-
-namespace {
-llvm::StringRef DescribeToken(GoLexer::TokenType t) {
- switch (t) {
- case GoLexer::TOK_EOF:
- return "<eof>";
- case GoLexer::TOK_IDENTIFIER:
- return "identifier";
- case GoLexer::LIT_FLOAT:
- return "float";
- case GoLexer::LIT_IMAGINARY:
- return "imaginary";
- case GoLexer::LIT_INTEGER:
- return "integer";
- case GoLexer::LIT_RUNE:
- return "rune";
- case GoLexer::LIT_STRING:
- return "string";
- default:
- return GoLexer::LookupToken(t);
- }
-}
-} // namespace
-
-class GoParser::Rule {
-public:
- Rule(llvm::StringRef name, GoParser *p)
- : m_name(name), m_parser(p), m_pos(p->m_pos) {}
-
- std::nullptr_t error() {
- if (!m_parser->m_failed) {
- // Set m_error in case this is the top level.
- if (m_parser->m_last_tok == GoLexer::TOK_INVALID)
- m_parser->m_error = m_parser->m_last;
- else
- m_parser->m_error = DescribeToken(m_parser->m_last_tok);
- // And set m_last in case it isn't.
- m_parser->m_last = m_name;
- m_parser->m_last_tok = GoLexer::TOK_INVALID;
- m_parser->m_pos = m_pos;
- }
- return nullptr;
- }
-
-private:
- llvm::StringRef m_name;
- GoParser *m_parser;
- size_t m_pos;
-};
-
-GoParser::GoParser(const char *src)
- : m_lexer(src), m_pos(0), m_last_tok(GoLexer::TOK_INVALID),
- m_failed(false) {}
-
-GoASTStmt *GoParser::Statement() {
- Rule r("Statement", this);
- GoLexer::TokenType t = peek();
- GoASTStmt *ret = nullptr;
- switch (t) {
- case GoLexer::TOK_EOF:
- case GoLexer::OP_SEMICOLON:
- case GoLexer::OP_RPAREN:
- case GoLexer::OP_RBRACE:
- case GoLexer::TOK_INVALID:
- return EmptyStmt();
- case GoLexer::OP_LBRACE:
- return Block();
-
- /* TODO:
-case GoLexer::KEYWORD_GO:
- return GoStmt();
-case GoLexer::KEYWORD_RETURN:
- return ReturnStmt();
-case GoLexer::KEYWORD_BREAK:
-case GoLexer::KEYWORD_CONTINUE:
-case GoLexer::KEYWORD_GOTO:
-case GoLexer::KEYWORD_FALLTHROUGH:
- return BranchStmt();
-case GoLexer::KEYWORD_IF:
- return IfStmt();
-case GoLexer::KEYWORD_SWITCH:
- return SwitchStmt();
-case GoLexer::KEYWORD_SELECT:
- return SelectStmt();
-case GoLexer::KEYWORD_FOR:
- return ForStmt();
-case GoLexer::KEYWORD_DEFER:
- return DeferStmt();
-case GoLexer::KEYWORD_CONST:
-case GoLexer::KEYWORD_TYPE:
-case GoLexer::KEYWORD_VAR:
- return DeclStmt();
-case GoLexer::TOK_IDENTIFIER:
- if ((ret = LabeledStmt()) ||
- (ret = ShortVarDecl()))
- {
- return ret;
- }
-*/
- default:
- break;
- }
- GoASTExpr *expr = Expression();
- if (expr == nullptr)
- return r.error();
- if (/*(ret = SendStmt(expr)) ||*/
- (ret = IncDecStmt(expr)) || (ret = Assignment(expr)) ||
- (ret = ExpressionStmt(expr))) {
- return ret;
- }
- delete expr;
- return r.error();
-}
-
-GoASTStmt *GoParser::ExpressionStmt(GoASTExpr *e) {
- if (Semicolon())
- return new GoASTExprStmt(e);
- return nullptr;
-}
-
-GoASTStmt *GoParser::IncDecStmt(GoASTExpr *e) {
- Rule r("IncDecStmt", this);
- if (match(GoLexer::OP_PLUS_PLUS))
- return Semicolon() ? new GoASTIncDecStmt(e, GoLexer::OP_PLUS_PLUS)
- : r.error();
- if (match(GoLexer::OP_MINUS_MINUS))
- return Semicolon() ? new GoASTIncDecStmt(e, GoLexer::OP_MINUS_MINUS)
- : r.error();
- return nullptr;
-}
-
-GoASTStmt *GoParser::Assignment(lldb_private::GoASTExpr *e) {
- Rule r("Assignment", this);
- std::vector<std::unique_ptr<GoASTExpr>> lhs;
- for (GoASTExpr *l = MoreExpressionList(); l; l = MoreExpressionList())
- lhs.push_back(std::unique_ptr<GoASTExpr>(l));
- switch (peek()) {
- case GoLexer::OP_EQ:
- case GoLexer::OP_PLUS_EQ:
- case GoLexer::OP_MINUS_EQ:
- case GoLexer::OP_PIPE_EQ:
- case GoLexer::OP_CARET_EQ:
- case GoLexer::OP_STAR_EQ:
- case GoLexer::OP_SLASH_EQ:
- case GoLexer::OP_PERCENT_EQ:
- case GoLexer::OP_LSHIFT_EQ:
- case GoLexer::OP_RSHIFT_EQ:
- case GoLexer::OP_AMP_EQ:
- case GoLexer::OP_AMP_CARET_EQ:
- break;
- default:
- return r.error();
- }
- // We don't want to own e until we know this is an assignment.
- std::unique_ptr<GoASTAssignStmt> stmt(new GoASTAssignStmt(false));
- stmt->AddLhs(e);
- for (auto &l : lhs)
- stmt->AddLhs(l.release());
- for (GoASTExpr *r = Expression(); r; r = MoreExpressionList())
- stmt->AddRhs(r);
- if (!Semicolon() || stmt->NumRhs() == 0)
- return new GoASTBadStmt;
- return stmt.release();
-}
-
-GoASTStmt *GoParser::EmptyStmt() {
- if (match(GoLexer::TOK_EOF))
- return nullptr;
- if (Semicolon())
- return new GoASTEmptyStmt;
- return nullptr;
-}
-
-GoASTStmt *GoParser::GoStmt() {
- if (match(GoLexer::KEYWORD_GO)) {
- if (GoASTCallExpr *e =
- llvm::dyn_cast_or_null<GoASTCallExpr>(Expression())) {
- return FinishStmt(new GoASTGoStmt(e));
- }
- m_last = "call expression";
- m_failed = true;
- return new GoASTBadStmt();
- }
- return nullptr;
-}
-
-GoASTStmt *GoParser::ReturnStmt() {
- if (match(GoLexer::KEYWORD_RETURN)) {
- std::unique_ptr<GoASTReturnStmt> r(new GoASTReturnStmt());
- for (GoASTExpr *e = Expression(); e; e = MoreExpressionList())
- r->AddResults(e);
- return FinishStmt(r.release());
- }
- return nullptr;
-}
-
-GoASTStmt *GoParser::BranchStmt() {
- GoLexer::Token *tok;
- if ((tok = match(GoLexer::KEYWORD_BREAK)) ||
- (tok = match(GoLexer::KEYWORD_CONTINUE)) ||
- (tok = match(GoLexer::KEYWORD_GOTO))) {
- auto *e = Identifier();
- if (tok->m_type == GoLexer::KEYWORD_GOTO && !e)
- return syntaxerror();
- return FinishStmt(new GoASTBranchStmt(e, tok->m_type));
- }
- if ((tok = match(GoLexer::KEYWORD_FALLTHROUGH)))
- return FinishStmt(new GoASTBranchStmt(nullptr, tok->m_type));
-
- return nullptr;
-}
-
-GoASTIdent *GoParser::Identifier() {
- if (auto *tok = match(GoLexer::TOK_IDENTIFIER))
- return new GoASTIdent(*tok);
- return nullptr;
-}
-
-GoASTExpr *GoParser::MoreExpressionList() {
- if (match(GoLexer::OP_COMMA)) {
- auto *e = Expression();
- if (!e)
- return syntaxerror();
- return e;
- }
- return nullptr;
-}
-
-GoASTIdent *GoParser::MoreIdentifierList() {
- if (match(GoLexer::OP_COMMA)) {
- auto *i = Identifier();
- if (!i)
- return syntaxerror();
- return i;
- }
- return nullptr;
-}
-
-GoASTExpr *GoParser::Expression() {
- Rule r("Expression", this);
- if (GoASTExpr *ret = OrExpr())
- return ret;
- return r.error();
-}
-
-GoASTExpr *GoParser::UnaryExpr() {
- switch (peek()) {
- case GoLexer::OP_PLUS:
- case GoLexer::OP_MINUS:
- case GoLexer::OP_BANG:
- case GoLexer::OP_CARET:
- case GoLexer::OP_STAR:
- case GoLexer::OP_AMP:
- case GoLexer::OP_LT_MINUS: {
- const GoLexer::Token t = next();
- if (GoASTExpr *e = UnaryExpr()) {
- if (t.m_type == GoLexer::OP_STAR)
- return new GoASTStarExpr(e);
- else
- return new GoASTUnaryExpr(t.m_type, e);
- }
- return syntaxerror();
- }
- default:
- return PrimaryExpr();
- }
-}
-
-GoASTExpr *GoParser::OrExpr() {
- std::unique_ptr<GoASTExpr> l(AndExpr());
- if (l) {
- while (match(GoLexer::OP_PIPE_PIPE)) {
- GoASTExpr *r = AndExpr();
- if (r)
- l.reset(new GoASTBinaryExpr(l.release(), r, GoLexer::OP_PIPE_PIPE));
- else
- return syntaxerror();
- }
- return l.release();
- }
- return nullptr;
-}
-
-GoASTExpr *GoParser::AndExpr() {
- std::unique_ptr<GoASTExpr> l(RelExpr());
- if (l) {
- while (match(GoLexer::OP_AMP_AMP)) {
- GoASTExpr *r = RelExpr();
- if (r)
- l.reset(new GoASTBinaryExpr(l.release(), r, GoLexer::OP_AMP_AMP));
- else
- return syntaxerror();
- }
- return l.release();
- }
- return nullptr;
-}
-
-GoASTExpr *GoParser::RelExpr() {
- std::unique_ptr<GoASTExpr> l(AddExpr());
- if (l) {
- for (GoLexer::Token *t;
- (t = match(GoLexer::OP_EQ_EQ)) || (t = match(GoLexer::OP_BANG_EQ)) ||
- (t = match(GoLexer::OP_LT)) || (t = match(GoLexer::OP_LT_EQ)) ||
- (t = match(GoLexer::OP_GT)) || (t = match(GoLexer::OP_GT_EQ));) {
- GoLexer::TokenType op = t->m_type;
- GoASTExpr *r = AddExpr();
- if (r)
- l.reset(new GoASTBinaryExpr(l.release(), r, op));
- else
- return syntaxerror();
- }
- return l.release();
- }
- return nullptr;
-}
-
-GoASTExpr *GoParser::AddExpr() {
- std::unique_ptr<GoASTExpr> l(MulExpr());
- if (l) {
- for (GoLexer::Token *t;
- (t = match(GoLexer::OP_PLUS)) || (t = match(GoLexer::OP_MINUS)) ||
- (t = match(GoLexer::OP_PIPE)) || (t = match(GoLexer::OP_CARET));) {
- GoLexer::TokenType op = t->m_type;
- GoASTExpr *r = MulExpr();
- if (r)
- l.reset(new GoASTBinaryExpr(l.release(), r, op));
- else
- return syntaxerror();
- }
- return l.release();
- }
- return nullptr;
-}
-
-GoASTExpr *GoParser::MulExpr() {
- std::unique_ptr<GoASTExpr> l(UnaryExpr());
- if (l) {
- for (GoLexer::Token *t;
- (t = match(GoLexer::OP_STAR)) || (t = match(GoLexer::OP_SLASH)) ||
- (t = match(GoLexer::OP_PERCENT)) || (t = match(GoLexer::OP_LSHIFT)) ||
- (t = match(GoLexer::OP_RSHIFT)) || (t = match(GoLexer::OP_AMP)) ||
- (t = match(GoLexer::OP_AMP_CARET));) {
- GoLexer::TokenType op = t->m_type;
- GoASTExpr *r = UnaryExpr();
- if (r)
- l.reset(new GoASTBinaryExpr(l.release(), r, op));
- else
- return syntaxerror();
- }
- return l.release();
- }
- return nullptr;
-}
-
-GoASTExpr *GoParser::PrimaryExpr() {
- GoASTExpr *l;
- GoASTExpr *r;
- (l = Conversion()) || (l = Operand());
- if (!l)
- return nullptr;
- while ((r = Selector(l)) || (r = IndexOrSlice(l)) || (r = TypeAssertion(l)) ||
- (r = Arguments(l))) {
- l = r;
- }
- return l;
-}
-
-GoASTExpr *GoParser::Operand() {
- GoLexer::Token *lit;
- if ((lit = match(GoLexer::LIT_INTEGER)) ||
- (lit = match(GoLexer::LIT_FLOAT)) ||
- (lit = match(GoLexer::LIT_IMAGINARY)) ||
- (lit = match(GoLexer::LIT_RUNE)) || (lit = match(GoLexer::LIT_STRING)))
- return new GoASTBasicLit(*lit);
- if (match(GoLexer::OP_LPAREN)) {
- GoASTExpr *e;
- if (!((e = Expression()) && match(GoLexer::OP_RPAREN)))
- return syntaxerror();
- return e;
- }
- // MethodExpr should be handled by Selector
- if (GoASTExpr *e = CompositeLit())
- return e;
- if (GoASTExpr *n = Name())
- return n;
- return FunctionLit();
-}
-
-GoASTExpr *GoParser::FunctionLit() {
- if (!match(GoLexer::KEYWORD_FUNC))
- return nullptr;
- auto *sig = Signature();
- if (!sig)
- return syntaxerror();
- auto *body = Block();
- if (!body) {
- delete sig;
- return syntaxerror();
- }
- return new GoASTFuncLit(sig, body);
-}
-
-GoASTBlockStmt *GoParser::Block() {
- if (!match(GoLexer::OP_LBRACE))
- return nullptr;
- std::unique_ptr<GoASTBlockStmt> block(new GoASTBlockStmt);
- for (auto *s = Statement(); s; s = Statement())
- block->AddList(s);
- if (!match(GoLexer::OP_RBRACE))
- return syntaxerror();
- return block.release();
-}
-
-GoASTExpr *GoParser::CompositeLit() {
- Rule r("CompositeLit", this);
- GoASTExpr *type;
- (type = StructType()) || (type = ArrayOrSliceType(true)) ||
- (type = MapType()) || (type = Name());
- if (!type)
- return r.error();
- GoASTCompositeLit *lit = LiteralValue();
- if (!lit) {
- delete type;
- return r.error();
- }
- lit->SetType(type);
- return lit;
-}
-
-GoASTCompositeLit *GoParser::LiteralValue() {
- if (!match(GoLexer::OP_LBRACE))
- return nullptr;
- std::unique_ptr<GoASTCompositeLit> lit(new GoASTCompositeLit);
- for (GoASTExpr *e = Element(); e; e = Element()) {
- lit->AddElts(e);
- if (!match(GoLexer::OP_COMMA))
- break;
- }
- if (!mustMatch(GoLexer::OP_RBRACE))
- return nullptr;
- return lit.release();
-}
-
-GoASTExpr *GoParser::Element() {
- GoASTExpr *key;
- if (!((key = Expression()) || (key = LiteralValue())))
- return nullptr;
- if (!match(GoLexer::OP_COLON))
- return key;
- GoASTExpr *value;
- if ((value = Expression()) || (value = LiteralValue()))
- return new GoASTKeyValueExpr(key, value);
- delete key;
- return syntaxerror();
-}
-
-GoASTExpr *GoParser::Selector(GoASTExpr *e) {
- Rule r("Selector", this);
- if (match(GoLexer::OP_DOT)) {
- if (auto *name = Identifier())
- return new GoASTSelectorExpr(e, name);
- }
- return r.error();
-}
-
-GoASTExpr *GoParser::IndexOrSlice(GoASTExpr *e) {
- Rule r("IndexOrSlice", this);
- if (match(GoLexer::OP_LBRACK)) {
- std::unique_ptr<GoASTExpr> i1(Expression()), i2, i3;
- bool slice = false;
- if (match(GoLexer::OP_COLON)) {
- slice = true;
- i2.reset(Expression());
- if (i2 && match(GoLexer::OP_COLON)) {
- i3.reset(Expression());
- if (!i3)
- return syntaxerror();
- }
- }
- if (!(slice || i1))
- return syntaxerror();
- if (!mustMatch(GoLexer::OP_RBRACK))
- return nullptr;
- if (slice) {
- bool slice3 = i3.get();
- return new GoASTSliceExpr(e, i1.release(), i2.release(), i3.release(),
- slice3);
- }
- return new GoASTIndexExpr(e, i1.release());
- }
- return r.error();
-}
-
-GoASTExpr *GoParser::TypeAssertion(GoASTExpr *e) {
- Rule r("TypeAssertion", this);
- if (match(GoLexer::OP_DOT) && match(GoLexer::OP_LPAREN)) {
- if (auto *t = Type()) {
- if (!mustMatch(GoLexer::OP_RPAREN))
- return nullptr;
- return new GoASTTypeAssertExpr(e, t);
- }
- return syntaxerror();
- }
- return r.error();
-}
-
-GoASTExpr *GoParser::Arguments(GoASTExpr *e) {
- if (match(GoLexer::OP_LPAREN)) {
- std::unique_ptr<GoASTCallExpr> call(new GoASTCallExpr(false));
- GoASTExpr *arg;
- // ( ExpressionList | Type [ "," ExpressionList ] )
- for ((arg = Expression()) || (arg = Type()); arg;
- arg = MoreExpressionList()) {
- call->AddArgs(arg);
- }
- if (match(GoLexer::OP_DOTS))
- call->SetEllipsis(true);
-
- // Eat trailing comma
- match(GoLexer::OP_COMMA);
-
- if (!mustMatch(GoLexer::OP_RPAREN))
- return nullptr;
- call->SetFun(e);
- return call.release();
- }
- return nullptr;
-}
-
-GoASTExpr *GoParser::Conversion() {
- Rule r("Conversion", this);
- if (GoASTExpr *t = Type2()) {
- std::unique_ptr<GoASTExpr> owner(t);
- if (match(GoLexer::OP_LPAREN)) {
- GoASTExpr *v = Expression();
- if (!v)
- return syntaxerror();
- match(GoLexer::OP_COMMA);
- if (!mustMatch(GoLexer::OP_RPAREN))
- return r.error();
- GoASTCallExpr *call = new GoASTCallExpr(false);
- call->SetFun(t);
- owner.release();
- call->AddArgs(v);
- return call;
- }
- }
- return r.error();
-}
-
-GoASTExpr *GoParser::Type2() {
- switch (peek()) {
- case GoLexer::OP_LBRACK:
- return ArrayOrSliceType(false);
- case GoLexer::KEYWORD_STRUCT:
- return StructType();
- case GoLexer::KEYWORD_FUNC:
- return FunctionType();
- case GoLexer::KEYWORD_INTERFACE:
- return InterfaceType();
- case GoLexer::KEYWORD_MAP:
- return MapType();
- case GoLexer::KEYWORD_CHAN:
- return ChanType2();
- default:
- return nullptr;
- }
-}
-
-GoASTExpr *GoParser::ArrayOrSliceType(bool allowEllipsis) {
- Rule r("ArrayType", this);
- if (match(GoLexer::OP_LBRACK)) {
- std::unique_ptr<GoASTExpr> len;
- if (allowEllipsis && match(GoLexer::OP_DOTS)) {
- len.reset(new GoASTEllipsis(nullptr));
- } else {
- len.reset(Expression());
- }
-
- if (!match(GoLexer::OP_RBRACK))
- return r.error();
- GoASTExpr *elem = Type();
- if (!elem)
- return syntaxerror();
- return new GoASTArrayType(len.release(), elem);
- }
- return r.error();
-}
-
-GoASTExpr *GoParser::StructType() {
- if (!(match(GoLexer::KEYWORD_STRUCT) && mustMatch(GoLexer::OP_LBRACE)))
- return nullptr;
- std::unique_ptr<GoASTFieldList> fields(new GoASTFieldList);
- while (auto *field = FieldDecl())
- fields->AddList(field);
- if (!mustMatch(GoLexer::OP_RBRACE))
- return nullptr;
- return new GoASTStructType(fields.release());
-}
-
-GoASTField *GoParser::FieldDecl() {
- std::unique_ptr<GoASTField> f(new GoASTField);
- GoASTExpr *t = FieldNamesAndType(f.get());
- if (!t)
- t = AnonymousFieldType();
- if (!t)
- return nullptr;
-
- if (auto *tok = match(GoLexer::LIT_STRING))
- f->SetTag(new GoASTBasicLit(*tok));
- if (!Semicolon())
- return syntaxerror();
- return f.release();
-}
-
-GoASTExpr *GoParser::FieldNamesAndType(GoASTField *field) {
- Rule r("FieldNames", this);
- for (auto *id = Identifier(); id; id = MoreIdentifierList())
- field->AddNames(id);
- if (m_failed)
- return nullptr;
- GoASTExpr *t = Type();
- if (t)
- return t;
- return r.error();
-}
-
-GoASTExpr *GoParser::AnonymousFieldType() {
- bool pointer = match(GoLexer::OP_STAR);
- GoASTExpr *t = Type();
- if (!t)
- return nullptr;
- if (pointer)
- return new GoASTStarExpr(t);
- return t;
-}
-
-GoASTExpr *GoParser::FunctionType() {
- if (!match(GoLexer::KEYWORD_FUNC))
- return nullptr;
- return Signature();
-}
-
-GoASTFuncType *GoParser::Signature() {
- auto *params = Params();
- if (!params)
- return syntaxerror();
- auto *result = Params();
- if (!result) {
- if (auto *t = Type()) {
- result = new GoASTFieldList;
- auto *f = new GoASTField;
- f->SetType(t);
- result->AddList(f);
- }
- }
- return new GoASTFuncType(params, result);
-}
-
-GoASTFieldList *GoParser::Params() {
- if (!match(GoLexer::OP_LPAREN))
- return nullptr;
- std::unique_ptr<GoASTFieldList> l(new GoASTFieldList);
- while (GoASTField *p = ParamDecl()) {
- l->AddList(p);
- if (!match(GoLexer::OP_COMMA))
- break;
- }
- if (!mustMatch(GoLexer::OP_RPAREN))
- return nullptr;
- return l.release();
-}
-
-GoASTField *GoParser::ParamDecl() {
- std::unique_ptr<GoASTField> field(new GoASTField);
- GoASTIdent *id = Identifier();
- if (id) {
- // Try `IdentifierList [ "..." ] Type`.
- // If that fails, backtrack and try `[ "..." ] Type`.
- Rule r("NamedParam", this);
- for (; id; id = MoreIdentifierList())
- field->AddNames(id);
- GoASTExpr *t = ParamType();
- if (t) {
- field->SetType(t);
- return field.release();
- }
- field.reset(new GoASTField);
- r.error();
- }
- GoASTExpr *t = ParamType();
- if (t) {
- field->SetType(t);
- return field.release();
- }
- return nullptr;
-}
-
-GoASTExpr *GoParser::ParamType() {
- bool dots = match(GoLexer::OP_DOTS);
- GoASTExpr *t = Type();
- if (!dots)
- return t;
- if (!t)
- return syntaxerror();
- return new GoASTEllipsis(t);
-}
-
-GoASTExpr *GoParser::InterfaceType() {
- if (!match(GoLexer::KEYWORD_INTERFACE) || !mustMatch(GoLexer::OP_LBRACE))
- return nullptr;
- std::unique_ptr<GoASTFieldList> methods(new GoASTFieldList);
- while (true) {
- Rule r("MethodSpec", this);
- // ( identifier Signature | TypeName ) ;
- std::unique_ptr<GoASTIdent> id(Identifier());
- if (!id)
- break;
- GoASTExpr *type = Signature();
- if (!type) {
- r.error();
- id.reset();
- type = Name();
- }
- if (!Semicolon())
- return syntaxerror();
- auto *f = new GoASTField;
- if (id)
- f->AddNames(id.release());
- f->SetType(type);
- methods->AddList(f);
- }
- if (!mustMatch(GoLexer::OP_RBRACE))
- return nullptr;
- return new GoASTInterfaceType(methods.release());
-}
-
-GoASTExpr *GoParser::MapType() {
- if (!(match(GoLexer::KEYWORD_MAP) && mustMatch(GoLexer::OP_LBRACK)))
- return nullptr;
- std::unique_ptr<GoASTExpr> key(Type());
- if (!key)
- return syntaxerror();
- if (!mustMatch(GoLexer::OP_RBRACK))
- return nullptr;
- auto *elem = Type();
- if (!elem)
- return syntaxerror();
- return new GoASTMapType(key.release(), elem);
-}
-
-GoASTExpr *GoParser::ChanType() {
- Rule r("chan", this);
- if (match(GoLexer::OP_LT_MINUS)) {
- if (match(GoLexer::KEYWORD_CHAN)) {
- auto *elem = Type();
- if (!elem)
- return syntaxerror();
- return new GoASTChanType(GoASTNode::eChanRecv, elem);
- }
- return r.error();
- }
- return ChanType2();
-}
-
-GoASTExpr *GoParser::ChanType2() {
- if (!match(GoLexer::KEYWORD_CHAN))
- return nullptr;
- auto dir = GoASTNode::eChanBidir;
- if (match(GoLexer::OP_LT_MINUS))
- dir = GoASTNode::eChanSend;
- auto *elem = Type();
- if (!elem)
- return syntaxerror();
- return new GoASTChanType(dir, elem);
-}
-
-GoASTExpr *GoParser::Type() {
- if (GoASTExpr *t = Type2())
- return t;
- if (GoASTExpr *t = Name())
- return t;
- if (GoASTExpr *t = ChanType())
- return t;
- if (match(GoLexer::OP_STAR)) {
- GoASTExpr *t = Type();
- if (!t)
- return syntaxerror();
- return new GoASTStarExpr(t);
- }
- if (match(GoLexer::OP_LPAREN)) {
- std::unique_ptr<GoASTExpr> t(Type());
- if (!t || !match(GoLexer::OP_RPAREN))
- return syntaxerror();
- return t.release();
- }
- return nullptr;
-}
-
-bool GoParser::Semicolon() {
- if (match(GoLexer::OP_SEMICOLON))
- return true;
- switch (peek()) {
- case GoLexer::OP_RPAREN:
- case GoLexer::OP_RBRACE:
- case GoLexer::TOK_EOF:
- return true;
- default:
- return false;
- }
-}
-
-GoASTExpr *GoParser::Name() {
- if (auto *id = Identifier()) {
- if (GoASTExpr *qual = QualifiedIdent(id))
- return qual;
- return id;
- }
- return nullptr;
-}
-
-GoASTExpr *GoParser::QualifiedIdent(lldb_private::GoASTIdent *p) {
- Rule r("QualifiedIdent", this);
- llvm::SmallString<32> path(p->GetName().m_value);
- GoLexer::Token *next;
- bool have_slashes = false;
- // LLDB extension: support full/package/path.name
- while (match(GoLexer::OP_SLASH) && (next = match(GoLexer::TOK_IDENTIFIER))) {
- have_slashes = true;
- path.append("/");
- path.append(next->m_value);
- }
- if (match(GoLexer::OP_DOT)) {
- auto *name = Identifier();
- if (name) {
- if (have_slashes) {
- p->SetName(GoLexer::Token(GoLexer::TOK_IDENTIFIER, CopyString(path)));
- }
- return new GoASTSelectorExpr(p, name);
- }
- }
- return r.error();
-}
-
-llvm::StringRef GoParser::CopyString(llvm::StringRef s) {
- return m_strings.insert(std::make_pair(s, 'x')).first->getKey();
-}
-
-void GoParser::GetError(Status &error) {
- llvm::StringRef want;
- if (m_failed)
- want =
- m_last_tok == GoLexer::TOK_INVALID ? DescribeToken(m_last_tok) : m_last;
- else
- want = m_error;
- size_t len = m_lexer.BytesRemaining();
- if (len > 10)
- len = 10;
- llvm::StringRef got;
- if (len == 0)
- got = "<eof>";
- else
- got = m_lexer.GetString(len);
- error.SetErrorStringWithFormat("Syntax error: expected %s before '%s'.",
- want.str().c_str(), got.str().c_str());
-}
diff --git a/source/Plugins/ExpressionParser/Go/GoParser.h b/source/Plugins/ExpressionParser/Go/GoParser.h
deleted file mode 100644
index 9ed2ae2033bd..000000000000
--- a/source/Plugins/ExpressionParser/Go/GoParser.h
+++ /dev/null
@@ -1,145 +0,0 @@
-//===-- GoParser.h -----------------------------------------------*- C++
-//-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_GoParser_h
-#define liblldb_GoParser_h
-
-#include "Plugins/ExpressionParser/Go/GoAST.h"
-#include "Plugins/ExpressionParser/Go/GoLexer.h"
-#include "lldb/lldb-private.h"
-
-namespace lldb_private {
-class GoParser {
-public:
- explicit GoParser(const char *src);
-
- GoASTStmt *Statement();
-
- GoASTStmt *GoStmt();
- GoASTStmt *ReturnStmt();
- GoASTStmt *BranchStmt();
- GoASTStmt *EmptyStmt();
- GoASTStmt *ExpressionStmt(GoASTExpr *e);
- GoASTStmt *IncDecStmt(GoASTExpr *e);
- GoASTStmt *Assignment(GoASTExpr *e);
- GoASTBlockStmt *Block();
-
- GoASTExpr *MoreExpressionList(); // ["," Expression]
- GoASTIdent *MoreIdentifierList(); // ["," Identifier]
-
- GoASTExpr *Expression();
- GoASTExpr *UnaryExpr();
- GoASTExpr *OrExpr();
- GoASTExpr *AndExpr();
- GoASTExpr *RelExpr();
- GoASTExpr *AddExpr();
- GoASTExpr *MulExpr();
- GoASTExpr *PrimaryExpr();
- GoASTExpr *Operand();
- GoASTExpr *Conversion();
-
- GoASTExpr *Selector(GoASTExpr *e);
- GoASTExpr *IndexOrSlice(GoASTExpr *e);
- GoASTExpr *TypeAssertion(GoASTExpr *e);
- GoASTExpr *Arguments(GoASTExpr *e);
-
- GoASTExpr *Type();
- GoASTExpr *Type2();
- GoASTExpr *ArrayOrSliceType(bool allowEllipsis);
- GoASTExpr *StructType();
- GoASTExpr *FunctionType();
- GoASTExpr *InterfaceType();
- GoASTExpr *MapType();
- GoASTExpr *ChanType();
- GoASTExpr *ChanType2();
-
- GoASTExpr *Name();
- GoASTExpr *QualifiedIdent(GoASTIdent *p);
- GoASTIdent *Identifier();
-
- GoASTField *FieldDecl();
- GoASTExpr *AnonymousFieldType();
- GoASTExpr *FieldNamesAndType(GoASTField *f);
-
- GoASTFieldList *Params();
- GoASTField *ParamDecl();
- GoASTExpr *ParamType();
- GoASTFuncType *Signature();
- GoASTExpr *CompositeLit();
- GoASTExpr *FunctionLit();
- GoASTExpr *Element();
- GoASTCompositeLit *LiteralValue();
-
- bool Failed() const { return m_failed; }
- bool AtEOF() const {
- return m_lexer.BytesRemaining() == 0 && m_pos == m_tokens.size();
- }
-
- void GetError(Status &error);
-
-private:
- class Rule;
- friend class Rule;
-
- std::nullptr_t syntaxerror() {
- m_failed = true;
- return nullptr;
- }
- GoLexer::Token &next() {
- if (m_pos >= m_tokens.size()) {
- if (m_pos != 0 && (m_tokens.back().m_type == GoLexer::TOK_EOF ||
- m_tokens.back().m_type == GoLexer::TOK_INVALID))
- return m_tokens.back();
- m_pos = m_tokens.size();
- m_tokens.push_back(m_lexer.Lex());
- }
- return m_tokens[m_pos++];
- }
- GoLexer::TokenType peek() {
- GoLexer::Token &tok = next();
- --m_pos;
- return tok.m_type;
- }
- GoLexer::Token *match(GoLexer::TokenType t) {
- GoLexer::Token &tok = next();
- if (tok.m_type == t)
- return &tok;
- --m_pos;
- m_last_tok = t;
- return nullptr;
- }
- GoLexer::Token *mustMatch(GoLexer::TokenType t) {
- GoLexer::Token *tok = match(t);
- if (tok)
- return tok;
- return syntaxerror();
- }
- bool Semicolon();
-
- GoASTStmt *FinishStmt(GoASTStmt *s) {
- if (!Semicolon())
- m_failed = true;
- return s;
- }
-
- llvm::StringRef CopyString(llvm::StringRef s);
-
- GoLexer m_lexer;
- std::vector<GoLexer::Token> m_tokens;
- size_t m_pos;
- llvm::StringRef m_error;
- llvm::StringRef m_last;
- GoLexer::TokenType m_last_tok;
- llvm::StringMap<uint8_t> m_strings;
- bool m_failed;
-};
-}
-
-#endif
diff --git a/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp b/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
deleted file mode 100644
index 3a10a1dc767a..000000000000
--- a/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
+++ /dev/null
@@ -1,668 +0,0 @@
-//===-- GoUserExpression.cpp ------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// C Includes
-#include <stdio.h>
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-// C++ Includes
-#include <cstdlib>
-#include <memory>
-#include <string>
-#include <vector>
-
-// Other libraries and framework includes
-#include "llvm/ADT/StringMap.h"
-#include "llvm/ADT/StringRef.h"
-
-// Project includes
-#include "GoUserExpression.h"
-
-#include "lldb/Core/Module.h"
-#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/ValueObjectConstResult.h"
-#include "lldb/Core/ValueObjectRegister.h"
-#include "lldb/Expression/DiagnosticManager.h"
-#include "lldb/Expression/ExpressionVariable.h"
-#include "lldb/Symbol/GoASTContext.h"
-#include "lldb/Symbol/SymbolFile.h"
-#include "lldb/Symbol/TypeList.h"
-#include "lldb/Symbol/VariableList.h"
-#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/RegisterContext.h"
-#include "lldb/Target/StackFrame.h"
-#include "lldb/Target/Target.h"
-#include "lldb/Target/ThreadPlan.h"
-#include "lldb/Target/ThreadPlanCallUserExpression.h"
-#include "lldb/Utility/ConstString.h"
-#include "lldb/Utility/DataBufferHeap.h"
-#include "lldb/Utility/DataEncoder.h"
-#include "lldb/Utility/DataExtractor.h"
-#include "lldb/Utility/Log.h"
-#include "lldb/Utility/StreamString.h"
-#include "lldb/lldb-private.h"
-
-#include "Plugins/ExpressionParser/Go/GoAST.h"
-#include "Plugins/ExpressionParser/Go/GoParser.h"
-
-using namespace lldb_private;
-using namespace lldb;
-
-class GoUserExpression::GoInterpreter {
-public:
- GoInterpreter(ExecutionContext &exe_ctx, const char *expr)
- : m_exe_ctx(exe_ctx), m_frame(exe_ctx.GetFrameSP()), m_parser(expr) {
- if (m_frame) {
- const SymbolContext &ctx =
- m_frame->GetSymbolContext(eSymbolContextFunction);
- ConstString fname = ctx.GetFunctionName();
- if (fname.GetLength() > 0) {
- size_t dot = fname.GetStringRef().find('.');
- if (dot != llvm::StringRef::npos)
- m_package = llvm::StringRef(fname.AsCString(), dot);
- }
- }
- }
-
- void set_use_dynamic(DynamicValueType use_dynamic) {
- m_use_dynamic = use_dynamic;
- }
-
- bool Parse();
- lldb::ValueObjectSP Evaluate(ExecutionContext &exe_ctx);
- lldb::ValueObjectSP EvaluateStatement(const GoASTStmt *s);
- lldb::ValueObjectSP EvaluateExpr(const GoASTExpr *e);
-
- ValueObjectSP VisitBadExpr(const GoASTBadExpr *e) {
- m_parser.GetError(m_error);
- return nullptr;
- }
-
- ValueObjectSP VisitParenExpr(const GoASTParenExpr *e);
- ValueObjectSP VisitIdent(const GoASTIdent *e);
- ValueObjectSP VisitStarExpr(const GoASTStarExpr *e);
- ValueObjectSP VisitSelectorExpr(const GoASTSelectorExpr *e);
- ValueObjectSP VisitBasicLit(const GoASTBasicLit *e);
- ValueObjectSP VisitIndexExpr(const GoASTIndexExpr *e);
- ValueObjectSP VisitUnaryExpr(const GoASTUnaryExpr *e);
- ValueObjectSP VisitCallExpr(const GoASTCallExpr *e);
-
- ValueObjectSP VisitTypeAssertExpr(const GoASTTypeAssertExpr *e) {
- return NotImplemented(e);
- }
-
- ValueObjectSP VisitBinaryExpr(const GoASTBinaryExpr *e) {
- return NotImplemented(e);
- }
-
- ValueObjectSP VisitArrayType(const GoASTArrayType *e) {
- return NotImplemented(e);
- }
-
- ValueObjectSP VisitChanType(const GoASTChanType *e) {
- return NotImplemented(e);
- }
-
- ValueObjectSP VisitCompositeLit(const GoASTCompositeLit *e) {
- return NotImplemented(e);
- }
-
- ValueObjectSP VisitEllipsis(const GoASTEllipsis *e) {
- return NotImplemented(e);
- }
-
- ValueObjectSP VisitFuncType(const GoASTFuncType *e) {
- return NotImplemented(e);
- }
-
- ValueObjectSP VisitFuncLit(const GoASTFuncLit *e) {
- return NotImplemented(e);
- }
-
- ValueObjectSP VisitInterfaceType(const GoASTInterfaceType *e) {
- return NotImplemented(e);
- }
-
- ValueObjectSP VisitKeyValueExpr(const GoASTKeyValueExpr *e) {
- return NotImplemented(e);
- }
-
- ValueObjectSP VisitMapType(const GoASTMapType *e) {
- return NotImplemented(e);
- }
-
- ValueObjectSP VisitSliceExpr(const GoASTSliceExpr *e) {
- return NotImplemented(e);
- }
-
- ValueObjectSP VisitStructType(const GoASTStructType *e) {
- return NotImplemented(e);
- }
-
- CompilerType EvaluateType(const GoASTExpr *e);
-
- Status &error() { return m_error; }
-
-private:
- std::nullptr_t NotImplemented(const GoASTExpr *e) {
- m_error.SetErrorStringWithFormat("%s node not implemented",
- e->GetKindName());
- return nullptr;
- }
-
- ExecutionContext m_exe_ctx;
- lldb::StackFrameSP m_frame;
- GoParser m_parser;
- DynamicValueType m_use_dynamic;
- Status m_error;
- llvm::StringRef m_package;
- std::vector<std::unique_ptr<GoASTStmt>> m_statements;
-};
-
-VariableSP FindGlobalVariable(TargetSP target, llvm::Twine name) {
- ConstString fullname(name.str());
- VariableList variable_list;
- if (!target) {
- return nullptr;
- }
- const uint32_t match_count =
- target->GetImages().FindGlobalVariables(fullname, 1, variable_list);
- if (match_count == 1) {
- return variable_list.GetVariableAtIndex(0);
- }
- return nullptr;
-}
-
-CompilerType LookupType(TargetSP target, ConstString name) {
- if (!target)
- return CompilerType();
- SymbolContext sc;
- TypeList type_list;
- llvm::DenseSet<SymbolFile *> searched_symbol_files;
- uint32_t num_matches = target->GetImages().FindTypes(
- sc, name, false, 2, searched_symbol_files, type_list);
- if (num_matches > 0) {
- return type_list.GetTypeAtIndex(0)->GetFullCompilerType();
- }
- return CompilerType();
-}
-
-GoUserExpression::GoUserExpression(ExecutionContextScope &exe_scope,
- llvm::StringRef expr, llvm::StringRef prefix,
- lldb::LanguageType language,
- ResultType desired_type,
- const EvaluateExpressionOptions &options)
- : UserExpression(exe_scope, expr, prefix, language, desired_type, options) {
-}
-
-bool GoUserExpression::Parse(DiagnosticManager &diagnostic_manager,
- ExecutionContext &exe_ctx,
- lldb_private::ExecutionPolicy execution_policy,
- bool keep_result_in_memory,
- bool generate_debug_info) {
- InstallContext(exe_ctx);
- m_interpreter.reset(new GoInterpreter(exe_ctx, GetUserText()));
- if (m_interpreter->Parse())
- return true;
- const char *error_cstr = m_interpreter->error().AsCString();
- if (error_cstr && error_cstr[0])
- diagnostic_manager.PutString(eDiagnosticSeverityError, error_cstr);
- else
- diagnostic_manager.Printf(eDiagnosticSeverityError,
- "expression can't be interpreted or run");
- return false;
-}
-
-lldb::ExpressionResults
-GoUserExpression::DoExecute(DiagnosticManager &diagnostic_manager,
- ExecutionContext &exe_ctx,
- const EvaluateExpressionOptions &options,
- lldb::UserExpressionSP &shared_ptr_to_me,
- lldb::ExpressionVariableSP &result) {
- Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS |
- LIBLLDB_LOG_STEP));
-
- lldb_private::ExecutionPolicy execution_policy = options.GetExecutionPolicy();
- lldb::ExpressionResults execution_results = lldb::eExpressionSetupError;
-
- Process *process = exe_ctx.GetProcessPtr();
- Target *target = exe_ctx.GetTargetPtr();
-
- if (target == nullptr || process == nullptr ||
- process->GetState() != lldb::eStateStopped) {
- if (execution_policy == eExecutionPolicyAlways) {
- if (log)
- log->Printf("== [GoUserExpression::Evaluate] Expression may not run, "
- "but is not constant ==");
-
- diagnostic_manager.PutString(eDiagnosticSeverityError,
- "expression needed to run but couldn't");
-
- return execution_results;
- }
- }
-
- m_interpreter->set_use_dynamic(options.GetUseDynamic());
- ValueObjectSP result_val_sp = m_interpreter->Evaluate(exe_ctx);
- Status err = m_interpreter->error();
- m_interpreter.reset();
-
- if (!result_val_sp) {
- const char *error_cstr = err.AsCString();
- if (error_cstr && error_cstr[0])
- diagnostic_manager.PutString(eDiagnosticSeverityError, error_cstr);
- else
- diagnostic_manager.PutString(eDiagnosticSeverityError,
- "expression can't be interpreted or run");
- return lldb::eExpressionDiscarded;
- }
- result.reset(new ExpressionVariable(ExpressionVariable::eKindGo));
- result->m_live_sp = result->m_frozen_sp = result_val_sp;
- result->m_flags |= ExpressionVariable::EVIsProgramReference;
- PersistentExpressionState *pv =
- target->GetPersistentExpressionStateForLanguage(eLanguageTypeGo);
- if (pv != nullptr) {
- result->SetName(pv->GetNextPersistentVariableName(
- *target, pv->GetPersistentVariablePrefix()));
- pv->AddVariable(result);
- }
- return lldb::eExpressionCompleted;
-}
-
-bool GoUserExpression::GoInterpreter::Parse() {
- for (std::unique_ptr<GoASTStmt> stmt(m_parser.Statement()); stmt;
- stmt.reset(m_parser.Statement())) {
- if (m_parser.Failed())
- break;
- m_statements.emplace_back(std::move(stmt));
- }
- if (m_parser.Failed() || !m_parser.AtEOF())
- m_parser.GetError(m_error);
-
- return m_error.Success();
-}
-
-ValueObjectSP
-GoUserExpression::GoInterpreter::Evaluate(ExecutionContext &exe_ctx) {
- m_exe_ctx = exe_ctx;
- ValueObjectSP result;
- for (const std::unique_ptr<GoASTStmt> &stmt : m_statements) {
- result = EvaluateStatement(stmt.get());
- if (m_error.Fail())
- return nullptr;
- }
- return result;
-}
-
-ValueObjectSP GoUserExpression::GoInterpreter::EvaluateStatement(
- const lldb_private::GoASTStmt *stmt) {
- ValueObjectSP result;
- switch (stmt->GetKind()) {
- case GoASTNode::eBlockStmt: {
- const GoASTBlockStmt *block = llvm::cast<GoASTBlockStmt>(stmt);
- for (size_t i = 0; i < block->NumList(); ++i)
- result = EvaluateStatement(block->GetList(i));
- break;
- }
- case GoASTNode::eBadStmt:
- m_parser.GetError(m_error);
- break;
- case GoASTNode::eExprStmt: {
- const GoASTExprStmt *expr = llvm::cast<GoASTExprStmt>(stmt);
- return EvaluateExpr(expr->GetX());
- }
- default:
- m_error.SetErrorStringWithFormat("%s node not supported",
- stmt->GetKindName());
- }
- return result;
-}
-
-ValueObjectSP GoUserExpression::GoInterpreter::EvaluateExpr(
- const lldb_private::GoASTExpr *e) {
- if (e)
- return e->Visit<ValueObjectSP>(this);
- return ValueObjectSP();
-}
-
-ValueObjectSP GoUserExpression::GoInterpreter::VisitParenExpr(
- const lldb_private::GoASTParenExpr *e) {
- return EvaluateExpr(e->GetX());
-}
-
-ValueObjectSP GoUserExpression::GoInterpreter::VisitIdent(const GoASTIdent *e) {
- ValueObjectSP val;
- if (m_frame) {
- VariableSP var_sp;
- std::string varname = e->GetName().m_value.str();
- if (varname.size() > 1 && varname[0] == '$') {
- RegisterContextSP reg_ctx_sp = m_frame->GetRegisterContext();
- const RegisterInfo *reg =
- reg_ctx_sp->GetRegisterInfoByName(varname.c_str() + 1);
- if (reg) {
- std::string type;
- switch (reg->encoding) {
- case lldb::eEncodingSint:
- type.append("int");
- break;
- case lldb::eEncodingUint:
- type.append("uint");
- break;
- case lldb::eEncodingIEEE754:
- type.append("float");
- break;
- default:
- m_error.SetErrorString("Invalid register encoding");
- return nullptr;
- }
- switch (reg->byte_size) {
- case 8:
- type.append("64");
- break;
- case 4:
- type.append("32");
- break;
- case 2:
- type.append("16");
- break;
- case 1:
- type.append("8");
- break;
- default:
- m_error.SetErrorString("Invalid register size");
- return nullptr;
- }
- ValueObjectSP regVal = ValueObjectRegister::Create(
- m_frame.get(), reg_ctx_sp, reg->kinds[eRegisterKindLLDB]);
- CompilerType goType =
- LookupType(m_frame->CalculateTarget(), ConstString(type));
- if (regVal) {
- regVal = regVal->Cast(goType);
- return regVal;
- }
- }
- m_error.SetErrorString("Invalid register name");
- return nullptr;
- }
- VariableListSP var_list_sp(m_frame->GetInScopeVariableList(false));
- if (var_list_sp) {
- var_sp = var_list_sp->FindVariable(ConstString(varname));
- if (var_sp)
- val = m_frame->GetValueObjectForFrameVariable(var_sp, m_use_dynamic);
- else {
- // When a variable is on the heap instead of the stack, go records a
- // variable '&x' instead of 'x'.
- var_sp = var_list_sp->FindVariable(ConstString("&" + varname));
- if (var_sp) {
- val = m_frame->GetValueObjectForFrameVariable(var_sp, m_use_dynamic);
- if (val)
- val = val->Dereference(m_error);
- if (m_error.Fail())
- return nullptr;
- }
- }
- }
- if (!val) {
- m_error.Clear();
- TargetSP target = m_frame->CalculateTarget();
- if (!target) {
- m_error.SetErrorString("No target");
- return nullptr;
- }
- var_sp =
- FindGlobalVariable(target, m_package + "." + e->GetName().m_value);
- if (var_sp)
- return m_frame->TrackGlobalVariable(var_sp, m_use_dynamic);
- }
- }
- if (!val)
- m_error.SetErrorStringWithFormat("Unknown variable %s",
- e->GetName().m_value.str().c_str());
- return val;
-}
-
-ValueObjectSP
-GoUserExpression::GoInterpreter::VisitStarExpr(const GoASTStarExpr *e) {
- ValueObjectSP target = EvaluateExpr(e->GetX());
- if (!target)
- return nullptr;
- return target->Dereference(m_error);
-}
-
-ValueObjectSP GoUserExpression::GoInterpreter::VisitSelectorExpr(
- const lldb_private::GoASTSelectorExpr *e) {
- ValueObjectSP target = EvaluateExpr(e->GetX());
- if (target) {
- if (target->GetCompilerType().IsPointerType()) {
- target = target->Dereference(m_error);
- if (m_error.Fail())
- return nullptr;
- }
- ConstString field(e->GetSel()->GetName().m_value);
- ValueObjectSP result = target->GetChildMemberWithName(field, true);
- if (!result)
- m_error.SetErrorStringWithFormat("Unknown child %s", field.AsCString());
- return result;
- }
- if (const GoASTIdent *package = llvm::dyn_cast<GoASTIdent>(e->GetX())) {
- if (VariableSP global = FindGlobalVariable(
- m_exe_ctx.GetTargetSP(), package->GetName().m_value + "." +
- e->GetSel()->GetName().m_value)) {
- if (m_frame) {
- m_error.Clear();
- return m_frame->GetValueObjectForFrameVariable(global, m_use_dynamic);
- }
- }
- }
- if (const GoASTBasicLit *packageLit =
- llvm::dyn_cast<GoASTBasicLit>(e->GetX())) {
- if (packageLit->GetValue().m_type == GoLexer::LIT_STRING) {
- std::string value = packageLit->GetValue().m_value.str();
- value = value.substr(1, value.size() - 2);
- if (VariableSP global = FindGlobalVariable(
- m_exe_ctx.GetTargetSP(),
- value + "." + e->GetSel()->GetName().m_value)) {
- if (m_frame) {
- m_error.Clear();
- return m_frame->TrackGlobalVariable(global, m_use_dynamic);
- }
- }
- }
- }
- // EvaluateExpr should have already set m_error.
- return target;
-}
-
-ValueObjectSP GoUserExpression::GoInterpreter::VisitBasicLit(
- const lldb_private::GoASTBasicLit *e) {
- std::string value = e->GetValue().m_value.str();
- if (e->GetValue().m_type != GoLexer::LIT_INTEGER) {
- m_error.SetErrorStringWithFormat("Unsupported literal %s", value.c_str());
- return nullptr;
- }
- errno = 0;
- int64_t intvalue = strtol(value.c_str(), nullptr, 0);
- if (errno != 0) {
- m_error.SetErrorToErrno();
- return nullptr;
- }
- DataBufferSP buf(new DataBufferHeap(sizeof(intvalue), 0));
- TargetSP target = m_exe_ctx.GetTargetSP();
- if (!target) {
- m_error.SetErrorString("No target");
- return nullptr;
- }
- ByteOrder order = target->GetArchitecture().GetByteOrder();
- uint8_t addr_size = target->GetArchitecture().GetAddressByteSize();
- DataEncoder enc(buf, order, addr_size);
- enc.PutU64(0, static_cast<uint64_t>(intvalue));
- DataExtractor data(buf, order, addr_size);
-
- CompilerType type = LookupType(target, ConstString("int64"));
- return ValueObject::CreateValueObjectFromData(llvm::StringRef(), data,
- m_exe_ctx, type);
-}
-
-ValueObjectSP GoUserExpression::GoInterpreter::VisitIndexExpr(
- const lldb_private::GoASTIndexExpr *e) {
- ValueObjectSP target = EvaluateExpr(e->GetX());
- if (!target)
- return nullptr;
- ValueObjectSP index = EvaluateExpr(e->GetIndex());
- if (!index)
- return nullptr;
- bool is_signed;
- if (!index->GetCompilerType().IsIntegerType(is_signed)) {
- m_error.SetErrorString("Unsupported index");
- return nullptr;
- }
- size_t idx;
- if (is_signed)
- idx = index->GetValueAsSigned(0);
- else
- idx = index->GetValueAsUnsigned(0);
- if (GoASTContext::IsGoSlice(target->GetCompilerType())) {
- target = target->GetStaticValue();
- ValueObjectSP cap =
- target->GetChildMemberWithName(ConstString("cap"), true);
- if (cap) {
- uint64_t capval = cap->GetValueAsUnsigned(0);
- if (idx >= capval) {
- m_error.SetErrorStringWithFormat("Invalid index %" PRIu64
- " , cap = %" PRIu64,
- uint64_t(idx), capval);
- return nullptr;
- }
- }
- target = target->GetChildMemberWithName(ConstString("array"), true);
- if (target && m_use_dynamic != eNoDynamicValues) {
- ValueObjectSP dynamic = target->GetDynamicValue(m_use_dynamic);
- if (dynamic)
- target = dynamic;
- }
- if (!target)
- return nullptr;
- return target->GetSyntheticArrayMember(idx, true);
- }
- return target->GetChildAtIndex(idx, true);
-}
-
-ValueObjectSP
-GoUserExpression::GoInterpreter::VisitUnaryExpr(const GoASTUnaryExpr *e) {
- ValueObjectSP x = EvaluateExpr(e->GetX());
- if (!x)
- return nullptr;
- switch (e->GetOp()) {
- case GoLexer::OP_AMP: {
- CompilerType type = x->GetCompilerType().GetPointerType();
- uint64_t address = x->GetAddressOf();
- return ValueObject::CreateValueObjectFromAddress(llvm::StringRef(), address,
- m_exe_ctx, type);
- }
- case GoLexer::OP_PLUS:
- return x;
- default:
- m_error.SetErrorStringWithFormat(
- "Operator %s not supported",
- GoLexer::LookupToken(e->GetOp()).str().c_str());
- return nullptr;
- }
-}
-
-CompilerType GoUserExpression::GoInterpreter::EvaluateType(const GoASTExpr *e) {
- TargetSP target = m_exe_ctx.GetTargetSP();
- if (auto *id = llvm::dyn_cast<GoASTIdent>(e)) {
- CompilerType result =
- LookupType(target, ConstString(id->GetName().m_value));
- if (result.IsValid())
- return result;
- std::string fullname = (m_package + "." + id->GetName().m_value).str();
- result = LookupType(target, ConstString(fullname));
- if (!result)
- m_error.SetErrorStringWithFormat("Unknown type %s", fullname.c_str());
- return result;
- }
- if (auto *sel = llvm::dyn_cast<GoASTSelectorExpr>(e)) {
- std::string package;
- if (auto *pkg_node = llvm::dyn_cast<GoASTIdent>(sel->GetX())) {
- package = pkg_node->GetName().m_value.str();
- } else if (auto *str_node = llvm::dyn_cast<GoASTBasicLit>(sel->GetX())) {
- if (str_node->GetValue().m_type == GoLexer::LIT_STRING) {
- package = str_node->GetValue().m_value.substr(1).str();
- package.resize(package.length() - 1);
- }
- }
- if (package.empty()) {
- m_error.SetErrorStringWithFormat("Invalid %s in type expression",
- sel->GetX()->GetKindName());
- return CompilerType();
- }
- std::string fullname =
- (package + "." + sel->GetSel()->GetName().m_value).str();
- CompilerType result = LookupType(target, ConstString(fullname));
- if (!result)
- m_error.SetErrorStringWithFormat("Unknown type %s", fullname.c_str());
- return result;
- }
- if (auto *star = llvm::dyn_cast<GoASTStarExpr>(e)) {
- CompilerType elem = EvaluateType(star->GetX());
- return elem.GetPointerType();
- }
- if (auto *paren = llvm::dyn_cast<GoASTParenExpr>(e))
- return EvaluateType(paren->GetX());
- if (auto *array = llvm::dyn_cast<GoASTArrayType>(e)) {
- CompilerType elem = EvaluateType(array->GetElt());
- }
-
- m_error.SetErrorStringWithFormat("Invalid %s in type expression",
- e->GetKindName());
- return CompilerType();
-}
-
-ValueObjectSP GoUserExpression::GoInterpreter::VisitCallExpr(
- const lldb_private::GoASTCallExpr *e) {
- ValueObjectSP x = EvaluateExpr(e->GetFun());
- if (x || e->NumArgs() != 1) {
- m_error.SetErrorStringWithFormat("Code execution not supported");
- return nullptr;
- }
- m_error.Clear();
- CompilerType type = EvaluateType(e->GetFun());
- if (!type) {
- return nullptr;
- }
- ValueObjectSP value = EvaluateExpr(e->GetArgs(0));
- if (!value)
- return nullptr;
- // TODO: Handle special conversions
- return value->Cast(type);
-}
-
-GoPersistentExpressionState::GoPersistentExpressionState()
- : PersistentExpressionState(eKindGo) {}
-
-void GoPersistentExpressionState::RemovePersistentVariable(
- lldb::ExpressionVariableSP variable) {
- RemoveVariable(variable);
-
- const char *name = variable->GetName().AsCString();
-
- if (*(name++) != '$')
- return;
- if (*(name++) != 'g')
- return;
- if (*(name++) != 'o')
- return;
-
- if (strtoul(name, nullptr, 0) == m_next_persistent_variable_id - 1)
- m_next_persistent_variable_id--;
-}
diff --git a/source/Plugins/ExpressionParser/Go/GoUserExpression.h b/source/Plugins/ExpressionParser/Go/GoUserExpression.h
deleted file mode 100644
index e2839da9bfdd..000000000000
--- a/source/Plugins/ExpressionParser/Go/GoUserExpression.h
+++ /dev/null
@@ -1,94 +0,0 @@
-//===-- GoUserExpression.h --------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_GoUserExpression_h_
-#define liblldb_GoUserExpression_h_
-
-// C Includes
-// C++ Includes
-#include <memory>
-
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Expression/ExpressionVariable.h"
-#include "lldb/Expression/UserExpression.h"
-#include "lldb/Target/ExecutionContext.h"
-#include "lldb/lldb-forward.h"
-#include "lldb/lldb-private.h"
-
-namespace lldb_private {
-class GoParser;
-
-class GoPersistentExpressionState : public PersistentExpressionState {
-public:
- GoPersistentExpressionState();
-
- llvm::StringRef
- GetPersistentVariablePrefix(bool is_error) const override {
- return "$go";
- }
- void RemovePersistentVariable(lldb::ExpressionVariableSP variable) override;
-
- lldb::addr_t LookupSymbol(const ConstString &name) override {
- return LLDB_INVALID_ADDRESS;
- }
-
- static bool classof(const PersistentExpressionState *pv) {
- return pv->getKind() == PersistentExpressionState::eKindGo;
- }
-
-private:
- uint32_t m_next_persistent_variable_id; ///< The counter used by
- ///GetNextResultName().
-};
-
-//----------------------------------------------------------------------
-/// @class GoUserExpression GoUserExpression.h
-/// "lldb/Expression/GoUserExpression.h" Encapsulates a single expression for
-/// use with Go
-///
-/// LLDB uses expressions for various purposes, notably to call functions
-/// and as a backend for the expr command. GoUserExpression encapsulates the
-/// objects needed to parse and interpret an expression.
-//----------------------------------------------------------------------
-class GoUserExpression : public UserExpression {
-public:
- GoUserExpression(ExecutionContextScope &exe_scope, llvm::StringRef expr,
- llvm::StringRef prefix, lldb::LanguageType language,
- ResultType desired_type,
- const EvaluateExpressionOptions &options);
-
- bool Parse(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
- lldb_private::ExecutionPolicy execution_policy,
- bool keep_result_in_memory, bool generate_debug_info) override;
-
- bool CanInterpret() override { return true; }
- bool FinalizeJITExecution(
- DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
- lldb::ExpressionVariableSP &result,
- lldb::addr_t function_stack_bottom = LLDB_INVALID_ADDRESS,
- lldb::addr_t function_stack_top = LLDB_INVALID_ADDRESS) override {
- return true;
- }
-
-protected:
- lldb::ExpressionResults
- DoExecute(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
- const EvaluateExpressionOptions &options,
- lldb::UserExpressionSP &shared_ptr_to_me,
- lldb::ExpressionVariableSP &result) override;
-
-private:
- class GoInterpreter;
- std::unique_ptr<GoInterpreter> m_interpreter;
-};
-
-} // namespace lldb_private
-
-#endif // liblldb_GoUserExpression_h_
diff --git a/source/Plugins/ExpressionParser/Go/gen_go_ast.py b/source/Plugins/ExpressionParser/Go/gen_go_ast.py
deleted file mode 100644
index 3be0e5f506ee..000000000000
--- a/source/Plugins/ExpressionParser/Go/gen_go_ast.py
+++ /dev/null
@@ -1,464 +0,0 @@
-import StringIO
-
-
-def addNodes():
- addNode("ArrayType", "Expr", "len", "Expr", "elt", "Expr")
- addNode(
- "AssignStmt",
- "Stmt",
- "lhs",
- "[]Expr",
- "rhs",
- "[]Expr",
- "define",
- "bool")
- addNode("BadDecl", "Decl")
- addNode("BadExpr", "Expr")
- addNode("BadStmt", "Stmt")
- addNode("BasicLit", "Expr", "value", "Token")
- addNode("BinaryExpr", "Expr", "x", "Expr", "y", "Expr", "op", "TokenType")
- addNode("BlockStmt", "Stmt", "list", "[]Stmt")
- addNode("Ident", "Expr", "name", "Token")
- addNode("BranchStmt", "Stmt", "label", "Ident", "tok", "TokenType")
- addNode(
- "CallExpr",
- "Expr",
- "fun",
- "Expr",
- "args",
- "[]Expr",
- "ellipsis",
- "bool")
- addNode("CaseClause", "Stmt", "list", "[]Expr", "body", "[]Stmt")
- addNode("ChanType", "Expr", "dir", "ChanDir", "value", "Expr")
- addNode("CommClause", "Stmt", "comm", "Stmt", "body", "[]Stmt")
- addNode("CompositeLit", "Expr", "type", "Expr", "elts", "[]Expr")
- addNode("DeclStmt", "Stmt", "decl", "Decl")
- addNode("DeferStmt", "Stmt", "call", "CallExpr")
- addNode("Ellipsis", "Expr", "elt", "Expr")
- addNode("EmptyStmt", "Stmt")
- addNode("ExprStmt", "Stmt", "x", "Expr")
- addNode(
- "Field",
- "Node",
- "names",
- "[]Ident",
- "type",
- "Expr",
- "tag",
- "BasicLit")
- addNode("FieldList", "Node", "list", "[]Field")
- addNode(
- "ForStmt",
- "Stmt",
- "init",
- "Stmt",
- "cond",
- "Expr",
- "post",
- "Stmt",
- "body",
- "BlockStmt")
- addNode("FuncType", "Expr", "params", "FieldList", "results", "FieldList")
- addNode(
- "FuncDecl",
- "Decl",
- "recv",
- "FieldList",
- "name",
- "Ident",
- "type",
- "FuncType",
- "body",
- "BlockStmt")
- addNode("FuncLit", "Expr", "type", "FuncType", "body", "BlockStmt")
- addNode("GenDecl", "Decl", "tok", "TokenType", "specs", "[]Spec")
- addNode("GoStmt", "Stmt", "call", "CallExpr")
- addNode(
- "IfStmt",
- "Stmt",
- "init",
- "Stmt",
- "cond",
- "Expr",
- "body",
- "BlockStmt",
- "els",
- "Stmt")
- addNode("ImportSpec", "Spec", "name", "Ident", "path", "BasicLit")
- addNode("IncDecStmt", "Stmt", "x", "Expr", "tok", "TokenType")
- addNode("IndexExpr", "Expr", "x", "Expr", "index", "Expr")
- addNode("InterfaceType", "Expr", "methods", "FieldList")
- addNode("KeyValueExpr", "Expr", "key", "Expr", "value", "Expr")
- addNode("LabeledStmt", "Stmt", "label", "Ident", "stmt", "Stmt")
- addNode("MapType", "Expr", "key", "Expr", "value", "Expr")
- addNode("ParenExpr", "Expr", "x", "Expr")
- addNode(
- "RangeStmt",
- "Stmt",
- "key",
- "Expr",
- "value",
- "Expr",
- "define",
- "bool",
- "x",
- "Expr",
- "body",
- "BlockStmt")
- addNode("ReturnStmt", "Stmt", "results", "[]Expr")
- addNode("SelectStmt", "Stmt", "body", "BlockStmt")
- addNode("SelectorExpr", "Expr", "x", "Expr", "sel", "Ident")
- addNode("SendStmt", "Stmt", "chan", "Expr", "value", "Expr")
- addNode(
- "SliceExpr",
- "Expr",
- "x",
- "Expr",
- "low",
- "Expr",
- "high",
- "Expr",
- "max",
- "Expr",
- "slice3",
- "bool")
- addNode("StarExpr", "Expr", "x", "Expr")
- addNode("StructType", "Expr", "fields", "FieldList")
- addNode(
- "SwitchStmt",
- "Stmt",
- "init",
- "Stmt",
- "tag",
- "Expr",
- "body",
- "BlockStmt")
- addNode("TypeAssertExpr", "Expr", "x", "Expr", "type", "Expr")
- addNode("TypeSpec", "Spec", "name", "Ident", "type", "Expr")
- addNode(
- "TypeSwitchStmt",
- "Stmt",
- "init",
- "Stmt",
- "assign",
- "Stmt",
- "body",
- "BlockStmt")
- addNode("UnaryExpr", "Expr", "op", "TokenType", "x", "Expr")
- addNode(
- "ValueSpec",
- "Spec",
- "names",
- "[]Ident",
- "type",
- "Expr",
- "values",
- "[]Expr")
- addParent("Decl", "Node")
- addParent("Expr", "Node")
- addParent("Spec", "Node")
- addParent("Stmt", "Node")
-
-
-class Member(object):
-
- def __init__(self, name, typename):
- self.title = name.title()
- self.sname = name
- self.mname = 'm_' + name
- self.is_list = typename.startswith("[]")
- self.is_value = isValueType(typename)
- if self.is_value:
- self.argtype = typename
- self.mtype = typename
- elif self.is_list:
- self.argtype = 'GoAST' + typename[2:]
- self.mtype = 'std::vector<std::unique_ptr<%s> >' % self.argtype
- else:
- self.argtype = 'GoAST' + typename
- self.mtype = 'std::unique_ptr<%s>' % self.argtype
- self.mname = self.mname + '_up'
-
-
-kinds = {}
-parentClasses = StringIO.StringIO()
-childClasses = StringIO.StringIO()
-walker = StringIO.StringIO()
-
-
-def startClass(name, parent, out):
- out.write("""
-class GoAST%s : public GoAST%s
-{
- public:
-""" % (name, parent))
-
-
-def endClass(name, out):
- out.write("""
- %(name)s(const %(name)s &) = delete;
- const %(name)s &operator=(const %(name)s &) = delete;
-};
-""" % {'name': 'GoAST' + name})
-
-
-def addNode(name, parent, *children):
- startClass(name, parent, childClasses)
- l = kinds.setdefault(parent, [])
- l.append(name)
- children = createMembers(name, children)
- addConstructor(name, parent, children)
- childClasses.write("""
- const char *
- GetKindName() const override
- {
- return "%(name)s";
- }
-
- static bool
- classof(const GoASTNode *n)
- {
- return n->GetKind() == e%(name)s;
- }
- """ % {'name': name})
- addChildren(name, children)
- endClass(name, childClasses)
-
-
-def isValueType(typename):
- if typename[0].islower():
- return True
- if typename[0].isupper():
- return typename.startswith('Token') or typename == 'ChanDir'
- return False
-
-
-def createMembers(name, children):
- l = len(children)
- if (l % 2) != 0:
- raise Exception("Invalid children for %s: %s" % (name, children))
- return [Member(children[i], children[i + 1]) for i in xrange(0, l, 2)]
-
-
-def addConstructor(name, parent, children):
- for c in children:
- if c.is_list:
- children = [x for x in children if x.is_value]
- break
- childClasses.write(' ')
- if len(children) == 1:
- childClasses.write('explicit ')
- childClasses.write('GoAST%s(' % name)
- for i in xrange(len(children)):
- if i > 0:
- childClasses.write(', ')
-
- c = children[i]
- if c.is_value:
- childClasses.write(c.argtype)
- childClasses.write(' ')
- else:
- childClasses.write('%s *' % c.argtype)
- childClasses.write(c.sname)
- childClasses.write(') : GoAST%s(e%s)' % (parent, name))
- for c in children:
- childClasses.write(', ')
- childClasses.write('%(mname)s(%(sname)s)' % c.__dict__)
- childClasses.write(""" {}
- ~GoAST%s() override = default;
-""" % name)
-
-
-def addChildren(name, children):
- if len(children) == 0:
- return
- walker.write("""
- case e%(n)s:
- {
- GoAST%(n)s *n = llvm::cast<GoAST%(n)s>(this);
- (void)n;""" % {'n': name})
- for c in children:
- if c.is_list:
- childClasses.write("""
- size_t
- Num%(title)s() const
- {
- return %(mname)s.size();
- }
- const %(argtype)s *
- Get%(title)s(int i) const
- {
- return %(mname)s[i].get();
- }
- void
- Add%(title)s(%(argtype)s *%(sname)s)
- {
- %(mname)s.push_back(std::unique_ptr<%(argtype)s>(%(sname)s));
- }
-""" % c.__dict__)
- walker.write("""
- for (auto& e : n->%s) { v(e.get()); }""" % c.mname)
- else:
- const = ''
- get = ''
- set = ''
- t = c.argtype
- if isValueType(t):
- set = '%(mname)s = %(sname)s' % c.__dict__
- t = t + ' '
- else:
- t = t + ' *'
- const = 'const '
- get = '.get()'
- set = '%(mname)s.reset(%(sname)s)' % c.__dict__
- walker.write("""
- v(n->%s.get());""" % c.mname)
- childClasses.write("""
- %(const)s%(type)s
- Get%(title)s() const
- {
- return %(mname)s%(get)s;
- }
- void
- Set%(title)s(%(type)s%(sname)s)
- {
- %(set)s;
- }
-""" % {'const': const, 'title': c.title, 'sname': c.sname, 'get': get, 'set': set, 'type': t, 'mname': c.mname})
- childClasses.write('\n private:\n friend class GoASTNode;\n')
- walker.write("""
- return;
- }""")
- for c in children:
- childClasses.write(' %s %s;\n' % (c.mtype, c.mname))
-
-
-def addParent(name, parent):
- startClass(name, parent, parentClasses)
- l = kinds[name]
- minName = l[0]
- maxName = l[-1]
- parentClasses.write(""" template <typename R, typename V> R Visit(V *v) const;
-
- static bool
- classof(const GoASTNode *n)
- {
- return n->GetKind() >= e%s && n->GetKind() <= e%s;
- }
-
- protected:
- explicit GoAST%s(NodeKind kind) : GoASTNode(kind) { }
- private:
-""" % (minName, maxName, name))
- endClass(name, parentClasses)
-
-addNodes()
-
-print """//===-- GoAST.h -------------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// DO NOT EDIT.
-// Generated by gen_go_ast.py
-
-#ifndef liblldb_GoAST_h
-#define liblldb_GoAST_h
-
-#include "lldb/lldb-forward.h"
-#include "lldb/lldb-private.h"
-#include "llvm/Support/Casting.h"
-#include "Plugins/ExpressionParser/Go/GoLexer.h"
-
-namespace lldb_private
-{
-
-class GoASTNode
-{
- public:
- typedef GoLexer::TokenType TokenType;
- typedef GoLexer::Token Token;
- enum ChanDir
- {
- eChanBidir,
- eChanSend,
- eChanRecv,
- };
- enum NodeKind
- {"""
-for l in kinds.itervalues():
- for x in l:
- print " e%s," % x
-print """ };
-
- virtual ~GoASTNode() = default;
-
- NodeKind
- GetKind() const
- {
- return m_kind;
- }
-
- virtual const char *GetKindName() const = 0;
-
- template <typename V> void WalkChildren(V &v);
-
- protected:
- explicit GoASTNode(NodeKind kind) : m_kind(kind) { }
-
- private:
- const NodeKind m_kind;
-
- GoASTNode(const GoASTNode &) = delete;
- const GoASTNode &operator=(const GoASTNode &) = delete;
-};
-"""
-
-
-print parentClasses.getvalue()
-print childClasses.getvalue()
-
-for k, l in kinds.iteritems():
- if k == 'Node':
- continue
- print """
-template <typename R, typename V>
-R GoAST%s::Visit(V* v) const
-{
- switch(GetKind())
- {""" % k
- for subtype in l:
- print """ case e%(n)s:
- return v->Visit%(n)s(llvm::cast<const GoAST%(n)s>(this));""" % {'n': subtype}
-
- print """ default:
- assert(false && "Invalid kind");
- }
-}"""
-
-print """
-template <typename V>
-void GoASTNode::WalkChildren(V &v)
-{
- switch (m_kind)
- {
-"""
-print walker.getvalue()
-print"""
- case eEmptyStmt:
- case eBadDecl:
- case eBadExpr:
- case eBadStmt:
- break;
- }
-}
-
-} // namespace lldb_private
-
-#endif
-"""
diff --git a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
index 86744520ad63..85bc4a61c9d4 100644
--- a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -26,8 +26,7 @@
#include "Utility/ARM_DWARF_Registers.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/Support/MathExtras.h" // for SignExtend32 template function
- // and countTrailingZeros function
+#include "llvm/Support/MathExtras.h"
using namespace lldb;
using namespace lldb_private;
@@ -777,10 +776,7 @@ bool EmulateInstructionARM::WriteBits32UnknownToMemory(addr_t address) {
uint32_t random_data = rand();
const uint32_t addr_byte_size = GetAddressByteSize();
- if (!MemAWrite(context, address, random_data, addr_byte_size))
- return false;
-
- return true;
+ return MemAWrite(context, address, random_data, addr_byte_size);
}
// Write "bits (32) UNKNOWN" to register n. Helper function for many ARM
@@ -850,6 +846,7 @@ uint32_t EmulateInstructionARM::GetFramePointerRegisterNumber() const {
case llvm::Triple::IOS:
case llvm::Triple::TvOS:
case llvm::Triple::WatchOS:
+ // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
is_apple = true;
break;
default:
@@ -3340,10 +3337,7 @@ bool EmulateInstructionARM::EmulateCMNImm(const uint32_t opcode,
EmulateInstruction::Context context;
context.type = EmulateInstruction::eContextImmediate;
context.SetNoArgs();
- if (!WriteFlags(context, res.result, res.carry_out, res.overflow))
- return false;
-
- return true;
+ return WriteFlags(context, res.result, res.carry_out, res.overflow);
}
// Compare Negative (register) adds a register value and an optionally-shifted
@@ -3410,10 +3404,7 @@ bool EmulateInstructionARM::EmulateCMNReg(const uint32_t opcode,
EmulateInstruction::Context context;
context.type = EmulateInstruction::eContextImmediate;
context.SetNoArgs();
- if (!WriteFlags(context, res.result, res.carry_out, res.overflow))
- return false;
-
- return true;
+ return WriteFlags(context, res.result, res.carry_out, res.overflow);
}
// Compare (immediate) subtracts an immediate value from a register value. It
@@ -3463,10 +3454,7 @@ bool EmulateInstructionARM::EmulateCMPImm(const uint32_t opcode,
EmulateInstruction::Context context;
context.type = EmulateInstruction::eContextImmediate;
context.SetNoArgs();
- if (!WriteFlags(context, res.result, res.carry_out, res.overflow))
- return false;
-
- return true;
+ return WriteFlags(context, res.result, res.carry_out, res.overflow);
}
// Compare (register) subtracts an optionally-shifted register value from a
@@ -3542,10 +3530,7 @@ bool EmulateInstructionARM::EmulateCMPReg(const uint32_t opcode,
EmulateInstruction::Context context;
context.type = EmulateInstruction::eContextImmediate;
context.SetNoArgs();
- if (!WriteFlags(context, res.result, res.carry_out, res.overflow))
- return false;
-
- return true;
+ return WriteFlags(context, res.result, res.carry_out, res.overflow);
}
// Arithmetic Shift Right (immediate) shifts a register value right by an
@@ -9245,11 +9230,8 @@ bool EmulateInstructionARM::EmulateRSBImm(const uint32_t opcode,
context.type = EmulateInstruction::eContextImmediate;
context.SetNoArgs();
- if (!WriteCoreRegOptionalFlags(context, res.result, Rd, setflags,
- res.carry_out, res.overflow))
- return false;
-
- return true;
+ return WriteCoreRegOptionalFlags(context, res.result, Rd, setflags,
+ res.carry_out, res.overflow);
}
// Reverse Subtract (register) subtracts a register value from an optionally-
@@ -9326,11 +9308,8 @@ bool EmulateInstructionARM::EmulateRSBReg(const uint32_t opcode,
EmulateInstruction::Context context;
context.type = EmulateInstruction::eContextImmediate;
context.SetNoArgs();
- if (!WriteCoreRegOptionalFlags(context, res.result, Rd, setflags,
- res.carry_out, res.overflow))
- return false;
-
- return true;
+ return WriteCoreRegOptionalFlags(context, res.result, Rd, setflags,
+ res.carry_out, res.overflow);
}
// Reverse Subtract with Carry (immediate) subtracts a register value and the
@@ -9388,11 +9367,8 @@ bool EmulateInstructionARM::EmulateRSCImm(const uint32_t opcode,
context.type = EmulateInstruction::eContextImmediate;
context.SetNoArgs();
- if (!WriteCoreRegOptionalFlags(context, res.result, Rd, setflags,
- res.carry_out, res.overflow))
- return false;
-
- return true;
+ return WriteCoreRegOptionalFlags(context, res.result, Rd, setflags,
+ res.carry_out, res.overflow);
}
// Reverse Subtract with Carry (register) subtracts a register value and the
@@ -9460,11 +9436,8 @@ bool EmulateInstructionARM::EmulateRSCReg(const uint32_t opcode,
EmulateInstruction::Context context;
context.type = EmulateInstruction::eContextImmediate;
context.SetNoArgs();
- if (!WriteCoreRegOptionalFlags(context, res.result, Rd, setflags,
- res.carry_out, res.overflow))
- return false;
-
- return true;
+ return WriteCoreRegOptionalFlags(context, res.result, Rd, setflags,
+ res.carry_out, res.overflow);
}
// Subtract with Carry (immediate) subtracts an immediate value and the value
@@ -9531,11 +9504,8 @@ bool EmulateInstructionARM::EmulateSBCImm(const uint32_t opcode,
context.type = EmulateInstruction::eContextImmediate;
context.SetNoArgs();
- if (!WriteCoreRegOptionalFlags(context, res.result, Rd, setflags,
- res.carry_out, res.overflow))
- return false;
-
- return true;
+ return WriteCoreRegOptionalFlags(context, res.result, Rd, setflags,
+ res.carry_out, res.overflow);
}
// Subtract with Carry (register) subtracts an optionally-shifted register
@@ -9620,11 +9590,8 @@ bool EmulateInstructionARM::EmulateSBCReg(const uint32_t opcode,
EmulateInstruction::Context context;
context.type = EmulateInstruction::eContextImmediate;
context.SetNoArgs();
- if (!WriteCoreRegOptionalFlags(context, res.result, Rd, setflags,
- res.carry_out, res.overflow))
- return false;
-
- return true;
+ return WriteCoreRegOptionalFlags(context, res.result, Rd, setflags,
+ res.carry_out, res.overflow);
}
// This instruction subtracts an immediate value from a register value, and
@@ -9713,11 +9680,8 @@ bool EmulateInstructionARM::EmulateSUBImmThumb(const uint32_t opcode,
context.type = EmulateInstruction::eContextImmediate;
context.SetNoArgs();
- if (!WriteCoreRegOptionalFlags(context, res.result, Rd, setflags,
- res.carry_out, res.overflow))
- return false;
-
- return true;
+ return WriteCoreRegOptionalFlags(context, res.result, Rd, setflags,
+ res.carry_out, res.overflow);
}
// This instruction subtracts an immediate value from a register value, and
@@ -14153,11 +14117,8 @@ bool EmulateInstructionARM::BranchWritePC(const Context &context,
else
target = addr & 0xfffffffe;
- if (!WriteRegisterUnsigned(context, eRegisterKindGeneric,
- LLDB_REGNUM_GENERIC_PC, target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindGeneric,
+ LLDB_REGNUM_GENERIC_PC, target);
}
// As a side effect, BXWritePC sets context.arg2 to eModeARM or eModeThumb by
@@ -14191,11 +14152,8 @@ bool EmulateInstructionARM::BXWritePC(Context &context, uint32_t addr) {
LLDB_REGNUM_GENERIC_FLAGS, m_new_inst_cpsr))
return false;
}
- if (!WriteRegisterUnsigned(context, eRegisterKindGeneric,
- LLDB_REGNUM_GENERIC_PC, target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindGeneric,
+ LLDB_REGNUM_GENERIC_PC, target);
}
// Dispatches to either BXWritePC or BranchWritePC based on architecture
@@ -14408,14 +14366,14 @@ bool EmulateInstructionARM::EvaluateInstruction(uint32_t evaluate_options) {
evaluate_options & eEmulateInstructionOptionIgnoreConditions;
bool success = false;
- if (m_opcode_cpsr == 0 || m_ignore_conditions == false) {
+ if (m_opcode_cpsr == 0 || !m_ignore_conditions) {
m_opcode_cpsr =
ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_cpsr, 0, &success);
}
// Only return false if we are unable to read the CPSR if we care about
// conditions
- if (success == false && m_ignore_conditions == false)
+ if (!success && !m_ignore_conditions)
return false;
uint32_t orig_pc_value = 0;
diff --git a/source/Plugins/Instruction/ARM/EmulationStateARM.cpp b/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
index d1032f56f31c..d770b3bdc52e 100644
--- a/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
+++ b/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
@@ -9,12 +9,12 @@
#include "EmulationStateARM.h"
-#include "lldb/Core/RegisterValue.h"
-#include "lldb/Core/Scalar.h"
#include "lldb/Interpreter/OptionValueArray.h"
#include "lldb/Interpreter/OptionValueDictionary.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StackFrame.h"
+#include "lldb/Utility/RegisterValue.h"
+#include "lldb/Utility/Scalar.h"
#include "Utility/ARM_DWARF_Registers.h"
diff --git a/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp b/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
index 2f484ab5ea97..661a651c56c2 100644
--- a/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
+++ b/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
@@ -13,10 +13,10 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegisterValue.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/RegisterValue.h"
#include "lldb/Utility/Stream.h"
#include "Plugins/Process/Utility/ARMDefines.h"
@@ -41,8 +41,7 @@
#include "Plugins/Process/Utility/RegisterInfos_arm64.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/Support/MathExtras.h" // for SignExtend32 template function
- // and CountTrailingZeros_32 function
+#include "llvm/Support/MathExtras.h"
#include "Plugins/Process/Utility/InstructionUtils.h"
@@ -437,7 +436,7 @@ bool EmulateInstructionARM64::EvaluateInstruction(uint32_t evaluate_options) {
// Only return false if we are unable to read the CPSR if we care about
// conditions
- if (success == false && m_ignore_conditions == false)
+ if (!success && !m_ignore_conditions)
return false;
uint32_t orig_pc_value = 0;
@@ -547,11 +546,8 @@ bool EmulateInstructionARM64::BranchTo(const Context &context, uint32_t N,
} else
return false;
- if (!WriteRegisterUnsigned(context, eRegisterKindGeneric,
- LLDB_REGNUM_GENERIC_PC, addr))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindGeneric,
+ LLDB_REGNUM_GENERIC_PC, addr);
}
bool EmulateInstructionARM64::ConditionHolds(const uint32_t cond) {
@@ -1097,9 +1093,7 @@ bool EmulateInstructionARM64::EmulateB(const uint32_t opcode) {
return false;
}
- if (!BranchTo(context, 64, target))
- return false;
- return true;
+ return BranchTo(context, 64, target);
}
bool EmulateInstructionARM64::EmulateBcond(const uint32_t opcode) {
diff --git a/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h b/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h
index 253bb935bca7..1d1bd74d3f61 100644
--- a/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h
+++ b/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h
@@ -10,10 +10,6 @@
#ifndef EmulateInstructionARM64_h_
#define EmulateInstructionARM64_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "Plugins/Process/Utility/ARMDefines.h"
#include "lldb/Core/EmulateInstruction.h"
#include "lldb/Interpreter/OptionValue.h"
diff --git a/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp b/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
index b65747e12890..7fccb2311026 100644
--- a/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
+++ b/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
@@ -14,12 +14,12 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/Opcode.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegisterValue.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/RegisterValue.h"
#include "lldb/Utility/Stream.h"
#include "llvm-c/Disassembler.h"
#include "llvm/MC/MCAsmInfo.h"
@@ -35,7 +35,7 @@
#include "llvm/ADT/STLExtras.h"
#include "Plugins/Process/Utility/InstructionUtils.h"
-#include "Plugins/Process/Utility/RegisterContext_mips.h" //mips32 has same registers nos as mips64
+#include "Plugins/Process/Utility/RegisterContext_mips.h"
using namespace lldb;
using namespace lldb_private;
@@ -220,10 +220,8 @@ EmulateInstructionMIPS::CreateInstance(const ArchSpec &arch,
}
bool EmulateInstructionMIPS::SetTargetTriple(const ArchSpec &arch) {
- if (arch.GetTriple().getArch() == llvm::Triple::mips ||
- arch.GetTriple().getArch() == llvm::Triple::mipsel)
- return true;
- return false;
+ return arch.GetTriple().getArch() == llvm::Triple::mips ||
+ arch.GetTriple().getArch() == llvm::Triple::mipsel;
}
const char *EmulateInstructionMIPS::GetRegisterName(unsigned reg_num,
@@ -1350,10 +1348,7 @@ bool EmulateInstructionMIPS::Emulate_LW(llvm::MCInst &insn) {
context.type = eContextPopRegisterOffStack;
context.SetAddress(address);
- if (!WriteRegister(context, &reg_info_src, data_src))
- return false;
-
- return true;
+ return WriteRegister(context, &reg_info_src, data_src);
}
return false;
@@ -1450,11 +1445,8 @@ bool EmulateInstructionMIPS::Emulate_LUI(llvm::MCInst &insn) {
context.SetImmediateSigned(imm);
context.type = eContextImmediate;
- if (WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_zero_mips + rt,
- imm))
- return true;
-
- return false;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF,
+ dwarf_zero_mips + rt, imm);
}
bool EmulateInstructionMIPS::Emulate_ADDIUSP(llvm::MCInst &insn) {
@@ -1697,10 +1689,7 @@ bool EmulateInstructionMIPS::Emulate_LWSP(llvm::MCInst &insn) {
context.type = eContextPopRegisterOffStack;
context.SetAddress(base_address);
- if (!WriteRegister(context, &reg_info_src, data_src))
- return false;
-
- return true;
+ return WriteRegister(context, &reg_info_src, data_src);
}
return false;
@@ -1807,11 +1796,8 @@ bool EmulateInstructionMIPS::Emulate_JRADDIUSP(llvm::MCInst &insn) {
context.type = eContextAdjustStackPointer;
// update SP
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_sp_mips,
- result))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_sp_mips,
+ result);
}
static int IsAdd64bitOverflow(int32_t a, int32_t b) {
@@ -1864,11 +1850,8 @@ bool EmulateInstructionMIPS::Emulate_BXX_3ops(llvm::MCInst &insn) {
context.type = eContextRelativeBranchImmediate;
context.SetImmediate(offset);
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target);
}
/*
@@ -1947,11 +1930,8 @@ bool EmulateInstructionMIPS::Emulate_BXX_3ops_C(llvm::MCInst &insn) {
context.type = eContextRelativeBranchImmediate;
context.SetImmediate(current_inst_size + offset);
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target);
}
/*
@@ -2122,11 +2102,8 @@ bool EmulateInstructionMIPS::Emulate_BXX_2ops(llvm::MCInst &insn) {
context.type = eContextRelativeBranchImmediate;
context.SetImmediate(offset);
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target);
}
/*
@@ -2189,11 +2166,8 @@ bool EmulateInstructionMIPS::Emulate_BXX_2ops_C(llvm::MCInst &insn) {
context.type = eContextRelativeBranchImmediate;
context.SetImmediate(current_inst_size + offset);
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target);
}
bool EmulateInstructionMIPS::Emulate_B16_MM(llvm::MCInst &insn) {
@@ -2214,11 +2188,8 @@ bool EmulateInstructionMIPS::Emulate_B16_MM(llvm::MCInst &insn) {
context.type = eContextRelativeBranchImmediate;
context.SetImmediate(current_inst_size + offset);
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target);
}
/*
@@ -2529,11 +2500,8 @@ bool EmulateInstructionMIPS::Emulate_BC(llvm::MCInst &insn) {
Context context;
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target);
}
bool EmulateInstructionMIPS::Emulate_J(llvm::MCInst &insn) {
@@ -2556,10 +2524,7 @@ bool EmulateInstructionMIPS::Emulate_J(llvm::MCInst &insn) {
Context context;
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, pc))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips, pc);
}
bool EmulateInstructionMIPS::Emulate_JAL(llvm::MCInst &insn) {
@@ -2688,11 +2653,8 @@ bool EmulateInstructionMIPS::Emulate_JIC(llvm::MCInst &insn) {
Context context;
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target);
}
bool EmulateInstructionMIPS::Emulate_JR(llvm::MCInst &insn) {
@@ -2713,11 +2675,8 @@ bool EmulateInstructionMIPS::Emulate_JR(llvm::MCInst &insn) {
Context context;
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
- rs_val))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ rs_val);
}
/*
@@ -2758,11 +2717,8 @@ bool EmulateInstructionMIPS::Emulate_FP_branch(llvm::MCInst &insn) {
}
Context context;
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target);
}
bool EmulateInstructionMIPS::Emulate_BC1EQZ(llvm::MCInst &insn) {
@@ -2797,11 +2753,8 @@ bool EmulateInstructionMIPS::Emulate_BC1EQZ(llvm::MCInst &insn) {
Context context;
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target);
}
bool EmulateInstructionMIPS::Emulate_BC1NEZ(llvm::MCInst &insn) {
@@ -2836,11 +2789,8 @@ bool EmulateInstructionMIPS::Emulate_BC1NEZ(llvm::MCInst &insn) {
Context context;
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target);
}
/*
@@ -2898,11 +2848,8 @@ bool EmulateInstructionMIPS::Emulate_3D_branch(llvm::MCInst &insn) {
}
Context context;
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target);
}
bool EmulateInstructionMIPS::Emulate_BNZB(llvm::MCInst &insn) {
@@ -2993,11 +2940,8 @@ bool EmulateInstructionMIPS::Emulate_MSA_Branch_DF(llvm::MCInst &insn,
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target);
}
bool EmulateInstructionMIPS::Emulate_BNZV(llvm::MCInst &insn) {
@@ -3039,11 +2983,8 @@ bool EmulateInstructionMIPS::Emulate_MSA_Branch_V(llvm::MCInst &insn,
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips,
+ target);
}
bool EmulateInstructionMIPS::Emulate_LDST_Imm(llvm::MCInst &insn) {
diff --git a/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp b/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
index 5af12ad141aa..9d178dd97ddf 100644
--- a/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
+++ b/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
@@ -14,12 +14,12 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/Opcode.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegisterValue.h"
#include "lldb/Host/PosixApi.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/RegisterValue.h"
#include "lldb/Utility/Stream.h"
#include "llvm-c/Disassembler.h"
#include "llvm/MC/MCAsmInfo.h"
@@ -207,10 +207,8 @@ EmulateInstructionMIPS64::CreateInstance(const ArchSpec &arch,
}
bool EmulateInstructionMIPS64::SetTargetTriple(const ArchSpec &arch) {
- if (arch.GetTriple().getArch() == llvm::Triple::mips64 ||
- arch.GetTriple().getArch() == llvm::Triple::mips64el)
- return true;
- return false;
+ return arch.GetTriple().getArch() == llvm::Triple::mips64 ||
+ arch.GetTriple().getArch() == llvm::Triple::mips64el;
}
const char *EmulateInstructionMIPS64::GetRegisterName(unsigned reg_num,
@@ -1099,13 +1097,24 @@ bool EmulateInstructionMIPS64::Emulate_DADDiu(llvm::MCInst &insn) {
Context context;
/* read <src> register */
- const int64_t src_opd_val = ReadRegisterUnsigned(
+ const uint64_t src_opd_val = ReadRegisterUnsigned(
eRegisterKindDWARF, dwarf_zero_mips64 + src, 0, &success);
if (!success)
return false;
/* Check if this is daddiu sp, sp, imm16 */
if (dst == dwarf_sp_mips64) {
+ /*
+ * From the MIPS IV spec:
+ *
+ * The term “unsigned” in the instruction name is a misnomer; this
+ * operation is 64-bit modulo arithmetic that does not trap on overflow.
+ * It is appropriate for arithmetic which is not signed, such as address
+ * arithmetic, or integer arithmetic environments that ignore overflow,
+ * such as “C” language arithmetic.
+ *
+ * Assume 2's complement and rely on unsigned overflow here.
+ */
uint64_t result = src_opd_val + imm;
RegisterInfo reg_info_sp;
@@ -1229,10 +1238,7 @@ bool EmulateInstructionMIPS64::Emulate_LD(llvm::MCInst &insn) {
Context context;
context.type = eContextRegisterLoad;
- if (!WriteRegister(context, &reg_info_src, data_src))
- return false;
-
- return true;
+ return WriteRegister(context, &reg_info_src, data_src);
}
return false;
@@ -1251,11 +1257,8 @@ bool EmulateInstructionMIPS64::Emulate_LUI(llvm::MCInst &insn) {
context.SetImmediateSigned(imm);
context.type = eContextImmediate;
- if (WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_zero_mips64 + rt,
- imm))
- return true;
-
- return false;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF,
+ dwarf_zero_mips64 + rt, imm);
}
bool EmulateInstructionMIPS64::Emulate_DSUBU_DADDU(llvm::MCInst &insn) {
@@ -1383,11 +1386,8 @@ bool EmulateInstructionMIPS64::Emulate_BXX_3ops(llvm::MCInst &insn) {
context.type = eContextRelativeBranchImmediate;
context.SetImmediate(offset);
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target);
}
/*
@@ -1622,11 +1622,8 @@ bool EmulateInstructionMIPS64::Emulate_BXX_2ops(llvm::MCInst &insn) {
context.type = eContextRelativeBranchImmediate;
context.SetImmediate(offset);
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target);
}
bool EmulateInstructionMIPS64::Emulate_BC(llvm::MCInst &insn) {
@@ -1648,11 +1645,8 @@ bool EmulateInstructionMIPS64::Emulate_BC(llvm::MCInst &insn) {
Context context;
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target);
}
static int IsAdd64bitOverflow(int64_t a, int64_t b) {
@@ -1736,11 +1730,8 @@ bool EmulateInstructionMIPS64::Emulate_BXX_3ops_C(llvm::MCInst &insn) {
context.type = eContextRelativeBranchImmediate;
context.SetImmediate(current_inst_size + offset);
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target);
}
/*
@@ -1803,11 +1794,8 @@ bool EmulateInstructionMIPS64::Emulate_BXX_2ops_C(llvm::MCInst &insn) {
context.type = eContextRelativeBranchImmediate;
context.SetImmediate(current_inst_size + offset);
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target);
}
bool EmulateInstructionMIPS64::Emulate_J(llvm::MCInst &insn) {
@@ -1830,10 +1818,8 @@ bool EmulateInstructionMIPS64::Emulate_J(llvm::MCInst &insn) {
Context context;
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64, pc))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ pc);
}
bool EmulateInstructionMIPS64::Emulate_JAL(llvm::MCInst &insn) {
@@ -1962,11 +1948,8 @@ bool EmulateInstructionMIPS64::Emulate_JIC(llvm::MCInst &insn) {
Context context;
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target);
}
bool EmulateInstructionMIPS64::Emulate_JR(llvm::MCInst &insn) {
@@ -1987,11 +1970,8 @@ bool EmulateInstructionMIPS64::Emulate_JR(llvm::MCInst &insn) {
Context context;
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
- rs_val))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ rs_val);
}
/*
@@ -2041,11 +2021,8 @@ bool EmulateInstructionMIPS64::Emulate_FP_branch(llvm::MCInst &insn) {
Context context;
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target);
}
bool EmulateInstructionMIPS64::Emulate_BC1EQZ(llvm::MCInst &insn) {
@@ -2080,11 +2057,8 @@ bool EmulateInstructionMIPS64::Emulate_BC1EQZ(llvm::MCInst &insn) {
Context context;
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target);
}
bool EmulateInstructionMIPS64::Emulate_BC1NEZ(llvm::MCInst &insn) {
@@ -2119,11 +2093,8 @@ bool EmulateInstructionMIPS64::Emulate_BC1NEZ(llvm::MCInst &insn) {
Context context;
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target);
}
/*
@@ -2182,11 +2153,8 @@ bool EmulateInstructionMIPS64::Emulate_3D_branch(llvm::MCInst &insn) {
Context context;
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target);
}
bool EmulateInstructionMIPS64::Emulate_BNZB(llvm::MCInst &insn) {
@@ -2277,11 +2245,8 @@ bool EmulateInstructionMIPS64::Emulate_MSA_Branch_DF(llvm::MCInst &insn,
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target);
}
bool EmulateInstructionMIPS64::Emulate_BNZV(llvm::MCInst &insn) {
@@ -2323,11 +2288,8 @@ bool EmulateInstructionMIPS64::Emulate_MSA_Branch_V(llvm::MCInst &insn,
Context context;
context.type = eContextRelativeBranchImmediate;
- if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
- target))
- return false;
-
- return true;
+ return WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_pc_mips64,
+ target);
}
bool EmulateInstructionMIPS64::Emulate_LDST_Imm(llvm::MCInst &insn) {
diff --git a/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h b/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h
index c2433d59830e..e9783633ac7d 100644
--- a/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h
+++ b/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h
@@ -10,10 +10,6 @@
#ifndef EmulateInstructionMIPS64_h_
#define EmulateInstructionMIPS64_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/EmulateInstruction.h"
#include "lldb/Interpreter/OptionValue.h"
#include "lldb/Utility/Status.h"
diff --git a/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h b/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h
index be65de9a5063..e9a1da6dd394 100644
--- a/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h
+++ b/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h
@@ -10,10 +10,6 @@
#ifndef EmulateInstructionPPC64_h_
#define EmulateInstructionPPC64_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Core/EmulateInstruction.h"
#include "lldb/Interpreter/OptionValue.h"
#include "lldb/Utility/Log.h"
diff --git a/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h b/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h
index e9af5a6cdc74..1439f86e586f 100644
--- a/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h
+++ b/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h
@@ -10,10 +10,6 @@
#ifndef liblldb_AddressSanitizerRuntime_h_
#define liblldb_AddressSanitizerRuntime_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Target/InstrumentationRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Utility/StructuredData.h"
diff --git a/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h b/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h
index dc737d22a67a..e6482d394efa 100644
--- a/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h
+++ b/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h
@@ -10,10 +10,6 @@
#ifndef liblldb_ThreadSanitizerRuntime_h_
#define liblldb_ThreadSanitizerRuntime_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "lldb/Target/ABI.h"
#include "lldb/Target/InstrumentationRuntime.h"
#include "lldb/Utility/StructuredData.h"
diff --git a/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp b/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
index 7ef3aecdb89f..3040b8b39052 100644
--- a/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
+++ b/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
@@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
#include "llvm/Support/MathExtras.h"
@@ -59,10 +58,9 @@ template <typename ptr_t> struct jit_descriptor {
namespace {
-PropertyDefinition g_properties[] = {
+static constexpr PropertyDefinition g_properties[] = {
{"enable-jit-breakpoint", OptionValue::eTypeBoolean, true, true, nullptr,
- nullptr, "Enable breakpoint on __jit_debug_register_code."},
- {nullptr, OptionValue::eTypeInvalid, false, 0, nullptr, nullptr, nullptr}};
+ {}, "Enable breakpoint on __jit_debug_register_code."}};
enum { ePropertyEnableJITBreakpoint };
@@ -316,7 +314,7 @@ bool JITLoaderGDB::ReadJITDescriptorImpl(bool all_entries) {
char jit_name[64];
snprintf(jit_name, 64, "JIT(0x%" PRIx64 ")", symbolfile_addr);
module_sp = m_process->ReadModuleFromMemory(
- FileSpec(jit_name, false), symbolfile_addr, symbolfile_size);
+ FileSpec(jit_name), symbolfile_addr, symbolfile_size);
if (module_sp && module_sp->GetObjectFile()) {
// load the symbol table right away
diff --git a/source/Plugins/JITLoader/GDB/JITLoaderGDB.h b/source/Plugins/JITLoader/GDB/JITLoaderGDB.h
index 6269860825db..a22016601293 100644
--- a/source/Plugins/JITLoader/GDB/JITLoaderGDB.h
+++ b/source/Plugins/JITLoader/GDB/JITLoaderGDB.h
@@ -10,12 +10,8 @@
#ifndef liblldb_JITLoaderGDB_h_
#define liblldb_JITLoaderGDB_h_
-// C Includes
-// C++ Includes
#include <map>
-// Other libraries and framework includes
-// Project includes
#include "lldb/Target/JITLoader.h"
#include "lldb/Target/Process.h"
diff --git a/source/Plugins/Language/CMakeLists.txt b/source/Plugins/Language/CMakeLists.txt
index 4b92a8ef866b..7869074566d1 100644
--- a/source/Plugins/Language/CMakeLists.txt
+++ b/source/Plugins/Language/CMakeLists.txt
@@ -1,6 +1,4 @@
+add_subdirectory(ClangCommon)
add_subdirectory(CPlusPlus)
-add_subdirectory(Go)
-add_subdirectory(Java)
add_subdirectory(ObjC)
add_subdirectory(ObjCPlusPlus)
-add_subdirectory(OCaml)
diff --git a/source/Plugins/Language/CPlusPlus/BlockPointer.cpp b/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
index 82b7ac1675fa..40200503a8a7 100644
--- a/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ b/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -7,10 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "BlockPointer.h"
#include "lldb/Core/ValueObject.h"
@@ -89,7 +85,7 @@ public:
size_t CalculateNumChildren() override {
const bool omit_empty_base_classes = false;
- return m_block_struct_type.GetNumChildren(omit_empty_base_classes);
+ return m_block_struct_type.GetNumChildren(omit_empty_base_classes, nullptr);
}
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override {
diff --git a/source/Plugins/Language/CPlusPlus/CMakeLists.txt b/source/Plugins/Language/CPlusPlus/CMakeLists.txt
index 180440a244a4..bc357aa52b84 100644
--- a/source/Plugins/Language/CPlusPlus/CMakeLists.txt
+++ b/source/Plugins/Language/CPlusPlus/CMakeLists.txt
@@ -9,13 +9,16 @@ add_lldb_library(lldbPluginCPlusPlusLanguage PLUGIN
LibCxxInitializerList.cpp
LibCxxList.cpp
LibCxxMap.cpp
+ LibCxxOptional.cpp
LibCxxQueue.cpp
LibCxxTuple.cpp
LibCxxUnorderedMap.cpp
+ LibCxxVariant.cpp
LibCxxVector.cpp
LibStdcpp.cpp
LibStdcppTuple.cpp
LibStdcppUniquePointer.cpp
+ MSVCUndecoratedNameParser.cpp
LINK_LIBS
lldbCore
@@ -24,6 +27,8 @@ add_lldb_library(lldbPluginCPlusPlusLanguage PLUGIN
lldbSymbol
lldbTarget
lldbUtility
+ lldbPluginClangCommon
+
LINK_COMPONENTS
Support
)
diff --git a/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 2c63e6467d4c..982b286d0f05 100644
--- a/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -9,20 +9,17 @@
#include "CPlusPlusLanguage.h"
-// C Includes
#include <cctype>
#include <cstring>
-// C++ Includes
#include <functional>
#include <memory>
#include <mutex>
#include <set>
-// Other libraries and framework includes
#include "llvm/ADT/StringRef.h"
+#include "llvm/Demangle/ItaniumDemangle.h"
-// Project includes
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/UniqueCStringMap.h"
#include "lldb/DataFormatters/CXXFunctionPointer.h"
@@ -30,7 +27,6 @@
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/VectorType.h"
#include "lldb/Utility/ConstString.h"
-#include "lldb/Utility/FastDemangle.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/RegularExpression.h"
@@ -39,7 +35,9 @@
#include "CxxStringTypes.h"
#include "LibCxx.h"
#include "LibCxxAtomic.h"
+#include "LibCxxVariant.h"
#include "LibStdcpp.h"
+#include "MSVCUndecoratedNameParser.h"
using namespace lldb;
using namespace lldb_private;
@@ -143,10 +141,7 @@ static bool IsTrivialBasename(const llvm::StringRef &basename) {
}
// We processed all characters. It is a vaild basename.
- if (idx == basename.size())
- return true;
-
- return false;
+ return idx == basename.size();
}
bool CPlusPlusLanguage::MethodName::TrySimplifiedParse() {
@@ -251,19 +246,23 @@ std::string CPlusPlusLanguage::MethodName::GetScopeQualifiedName() {
bool CPlusPlusLanguage::IsCPPMangledName(const char *name) {
// FIXME!! we should really run through all the known C++ Language plugins
// and ask each one if this is a C++ mangled name
-
+
if (name == nullptr)
return false;
-
- // MSVC style mangling
+
+ // MSVC style mangling
if (name[0] == '?')
return true;
-
+
return (name[0] != '\0' && name[0] == '_' && name[1] == 'Z');
}
bool CPlusPlusLanguage::ExtractContextAndIdentifier(
const char *name, llvm::StringRef &context, llvm::StringRef &identifier) {
+ if (MSVCUndecoratedNameParser::IsMSVCUndecoratedName(name))
+ return MSVCUndecoratedNameParser::ExtractContextAndIdentifier(name, context,
+ identifier);
+
CPlusPlusNameParser parser(name);
if (auto full_name = parser.ParseAsFullName()) {
identifier = full_name.getValue().basename;
@@ -273,53 +272,89 @@ bool CPlusPlusLanguage::ExtractContextAndIdentifier(
return false;
}
-/// Given a mangled function `mangled`, replace all the primitive function type
-/// arguments of `search` with type `replace`.
-static ConstString SubsPrimitiveParmItanium(llvm::StringRef mangled,
- llvm::StringRef search,
- llvm::StringRef replace) {
- Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE);
-
- const size_t max_len =
- mangled.size() + mangled.count(search) * replace.size() + 1;
-
- // Make a temporary buffer to fix up the mangled parameter types and copy the
- // original there
- std::string output_buf;
- output_buf.reserve(max_len);
- output_buf.insert(0, mangled.str());
- ptrdiff_t replaced_offset = 0;
-
- auto swap_parms_hook = [&](const char *parsee) {
- if (!parsee || !*parsee)
- return;
-
- // Check whether we've found a substitutee
- llvm::StringRef s(parsee);
- if (s.startswith(search)) {
- // account for the case where a replacement is of a different length to
- // the original
- replaced_offset += replace.size() - search.size();
-
- ptrdiff_t replace_idx = (mangled.size() - s.size()) + replaced_offset;
- output_buf.erase(replace_idx, search.size());
- output_buf.insert(replace_idx, replace.str());
+namespace {
+class NodeAllocator {
+ llvm::BumpPtrAllocator Alloc;
+
+public:
+ void reset() { Alloc.Reset(); }
+
+ template <typename T, typename... Args> T *makeNode(Args &&... args) {
+ return new (Alloc.Allocate(sizeof(T), alignof(T)))
+ T(std::forward<Args>(args)...);
+ }
+
+ void *allocateNodeArray(size_t sz) {
+ return Alloc.Allocate(sizeof(llvm::itanium_demangle::Node *) * sz,
+ alignof(llvm::itanium_demangle::Node *));
+ }
+};
+
+/// Given a mangled function `Mangled`, replace all the primitive function type
+/// arguments of `Search` with type `Replace`.
+class TypeSubstitutor
+ : public llvm::itanium_demangle::AbstractManglingParser<TypeSubstitutor,
+ NodeAllocator> {
+ /// Input character until which we have constructed the respective output
+ /// already
+ const char *Written;
+
+ llvm::StringRef Search;
+ llvm::StringRef Replace;
+ llvm::SmallString<128> Result;
+
+ /// Whether we have performed any substitutions.
+ bool Substituted;
+
+ void reset(llvm::StringRef Mangled, llvm::StringRef Search,
+ llvm::StringRef Replace) {
+ AbstractManglingParser::reset(Mangled.begin(), Mangled.end());
+ Written = Mangled.begin();
+ this->Search = Search;
+ this->Replace = Replace;
+ Result.clear();
+ Substituted = false;
+ }
+
+ void appendUnchangedInput() {
+ Result += llvm::StringRef(Written, First - Written);
+ Written = First;
+ }
+
+public:
+ TypeSubstitutor() : AbstractManglingParser(nullptr, nullptr) {}
+
+ ConstString substitute(llvm::StringRef Mangled, llvm::StringRef From,
+ llvm::StringRef To) {
+ Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_LANGUAGE);
+
+ reset(Mangled, From, To);
+ if (parse() == nullptr) {
+ LLDB_LOG(log, "Failed to substitute mangling in {0}", Mangled);
+ return ConstString();
}
- };
+ if (!Substituted)
+ return ConstString();
- // FastDemangle will call our hook for each instance of a primitive type,
- // allowing us to perform substitution
- char *const demangled =
- FastDemangle(mangled.str().c_str(), mangled.size(), swap_parms_hook);
+ // Append any trailing unmodified input.
+ appendUnchangedInput();
+ LLDB_LOG(log, "Substituted mangling {0} -> {1}", Mangled, Result);
+ return ConstString(Result);
+ }
- if (log)
- log->Printf("substituted mangling for %s:{%s} %s:{%s}\n",
- mangled.str().c_str(), demangled, output_buf.c_str(),
- FastDemangle(output_buf.c_str()));
- // FastDemangle malloc'd this string.
- free(demangled);
+ llvm::itanium_demangle::Node *parseType() {
+ if (llvm::StringRef(First, numLeft()).startswith(Search)) {
+ // We found a match. Append unmodified input up to this point.
+ appendUnchangedInput();
- return output_buf == mangled ? ConstString() : ConstString(output_buf);
+ // And then perform the replacement.
+ Result += Replace;
+ Written += Search.size();
+ Substituted = true;
+ }
+ return AbstractManglingParser::parseType();
+ }
+};
}
uint32_t CPlusPlusLanguage::FindAlternateFunctionManglings(
@@ -348,23 +383,24 @@ uint32_t CPlusPlusLanguage::FindAlternateFunctionManglings(
alternates.insert(ConstString(fixed_scratch));
}
+ TypeSubstitutor TS;
// `char` is implementation defined as either `signed` or `unsigned`. As a
// result a char parameter has 3 possible manglings: 'c'-char, 'a'-signed
// char, 'h'-unsigned char. If we're looking for symbols with a signed char
// parameter, try finding matches which have the general case 'c'.
if (ConstString char_fixup =
- SubsPrimitiveParmItanium(mangled_name.GetStringRef(), "a", "c"))
+ TS.substitute(mangled_name.GetStringRef(), "a", "c"))
alternates.insert(char_fixup);
// long long parameter mangling 'x', may actually just be a long 'l' argument
if (ConstString long_fixup =
- SubsPrimitiveParmItanium(mangled_name.GetStringRef(), "x", "l"))
+ TS.substitute(mangled_name.GetStringRef(), "x", "l"))
alternates.insert(long_fixup);
// unsigned long long parameter mangling 'y', may actually just be unsigned
// long 'm' argument
if (ConstString ulong_fixup =
- SubsPrimitiveParmItanium(mangled_name.GetStringRef(), "y", "m"))
+ TS.substitute(mangled_name.GetStringRef(), "y", "m"))
alternates.insert(ulong_fixup);
return alternates.size() - start_size;
@@ -385,8 +421,17 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
#ifndef LLDB_DISABLE_PYTHON
lldb::TypeSummaryImplSP std_string_summary_sp(new CXXFunctionSummaryFormat(
- stl_summary_flags, lldb_private::formatters::LibcxxStringSummaryProvider,
+ stl_summary_flags,
+ lldb_private::formatters::LibcxxStringSummaryProviderASCII,
"std::string summary provider"));
+ lldb::TypeSummaryImplSP std_stringu16_summary_sp(new CXXFunctionSummaryFormat(
+ stl_summary_flags,
+ lldb_private::formatters::LibcxxStringSummaryProviderUTF16,
+ "std::u16string summary provider"));
+ lldb::TypeSummaryImplSP std_stringu32_summary_sp(new CXXFunctionSummaryFormat(
+ stl_summary_flags,
+ lldb_private::formatters::LibcxxStringSummaryProviderUTF32,
+ "std::u32string summary provider"));
lldb::TypeSummaryImplSP std_wstring_summary_sp(new CXXFunctionSummaryFormat(
stl_summary_flags, lldb_private::formatters::LibcxxWStringSummaryProvider,
"std::wstring summary provider"));
@@ -400,6 +445,16 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
"std::__1::allocator<char> >"),
std_string_summary_sp);
cpp_category_sp->GetTypeSummariesContainer()->Add(
+ ConstString(
+ "std::__1::basic_string<char16_t, std::__1::char_traits<char16_t>, "
+ "std::__1::allocator<char16_t> >"),
+ std_stringu16_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(
+ ConstString(
+ "std::__1::basic_string<char32_t, std::__1::char_traits<char32_t>, "
+ "std::__1::allocator<char32_t> >"),
+ std_stringu32_summary_sp);
+ cpp_category_sp->GetTypeSummariesContainer()->Add(
ConstString("std::__ndk1::basic_string<char, "
"std::__ndk1::char_traits<char>, "
"std::__ndk1::allocator<char> >"),
@@ -493,6 +548,14 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
"libc++ std::tuple synthetic children",
ConstString("^std::__(ndk)?1::tuple<.*>(( )?&)?$"), stl_synth_flags,
true);
+ AddCXXSynthetic(cpp_category_sp, LibcxxOptionalFrontEndCreator,
+ "libc++ std::optional synthetic children",
+ ConstString("^std::__(ndk)?1::optional<.+>(( )?&)?$"),
+ stl_synth_flags, true);
+ AddCXXSynthetic(cpp_category_sp, LibcxxVariantFrontEndCreator,
+ "libc++ std::variant synthetic children",
+ ConstString("^std::__(ndk)?1::variant<.+>(( )?&)?$"),
+ stl_synth_flags, true);
AddCXXSynthetic(
cpp_category_sp,
lldb_private::formatters::LibcxxAtomicSyntheticFrontEndCreator,
@@ -519,6 +582,11 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
ConstString("^(std::__(ndk)?1::)weak_ptr<.+>(( )?&)?$"), stl_synth_flags,
true);
+ AddCXXSummary(
+ cpp_category_sp, lldb_private::formatters::LibcxxFunctionSummaryProvider,
+ "libc++ std::function summary provider",
+ ConstString("^std::__(ndk)?1::function<.+>$"), stl_summary_flags, true);
+
stl_summary_flags.SetDontShowChildren(false);
stl_summary_flags.SetSkipPointers(false);
AddCXXSummary(cpp_category_sp,
@@ -584,6 +652,16 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
cpp_category_sp, lldb_private::formatters::LibCxxAtomicSummaryProvider,
"libc++ std::atomic summary provider",
ConstString("^std::__(ndk)?1::atomic<.+>$"), stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibcxxOptionalSummaryProvider,
+ "libc++ std::optional summary provider",
+ ConstString("^std::__(ndk)?1::optional<.+>(( )?&)?$"),
+ stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibcxxVariantSummaryProvider,
+ "libc++ std::variant summary provider",
+ ConstString("^std::__(ndk)?1::variant<.+>(( )?&)?$"),
+ stl_summary_flags, true);
stl_summary_flags.SetSkipPointers(true);
@@ -610,11 +688,6 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
"std::map iterator synthetic children",
ConstString("^std::__(ndk)?1::__map_iterator<.+>$"), stl_synth_flags,
true);
-
- AddCXXSynthetic(
- cpp_category_sp, lldb_private::formatters::LibcxxFunctionFrontEndCreator,
- "std::function synthetic value provider",
- ConstString("^std::__(ndk)?1::function<.+>$"), stl_synth_flags, true);
#endif
}
@@ -1002,3 +1075,16 @@ CPlusPlusLanguage::GetHardcodedSynthetics() {
return g_formatters;
}
+
+bool CPlusPlusLanguage::IsSourceFile(llvm::StringRef file_path) const {
+ const auto suffixes = {".cpp", ".cxx", ".c++", ".cc", ".c",
+ ".h", ".hh", ".hpp", ".hxx", ".h++"};
+ for (auto suffix : suffixes) {
+ if (file_path.endswith_lower(suffix))
+ return true;
+ }
+
+ // Check if we're in a STL path (where the files usually have no extension
+ // that we could check for.
+ return file_path.contains("/usr/include/c++/");
+}
diff --git a/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h b/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
index 7380ef321305..3c8ca96e81f6 100644
--- a/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
+++ b/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
@@ -10,15 +10,12 @@
#ifndef liblldb_CPlusPlusLanguage_h_
#define liblldb_CPlusPlusLanguage_h_
-// C Includes
-// C++ Includes
#include <set>
#include <vector>
-// Other libraries and framework includes
#include "llvm/ADT/StringRef.h"
-// Project includes
+#include "Plugins/Language/ClangCommon/ClangHighlighter.h"
#include "lldb/Target/Language.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-private.h"
@@ -26,6 +23,8 @@
namespace lldb_private {
class CPlusPlusLanguage : public Language {
+ ClangHighlighter m_highlighter;
+
public:
class MethodName {
public:
@@ -90,6 +89,10 @@ public:
HardcodedFormatters::HardcodedSyntheticFinder
GetHardcodedSynthetics() override;
+ bool IsSourceFile(llvm::StringRef file_path) const override;
+
+ const Highlighter *GetHighlighter() const override { return &m_highlighter; }
+
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
diff --git a/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h b/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
index fe1d46f32c17..d46a53a7a704 100644
--- a/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
+++ b/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
@@ -10,16 +10,12 @@
#ifndef liblldb_CPlusPlusNameParser_h_
#define liblldb_CPlusPlusNameParser_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
#include "clang/Lex/Lexer.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
-// Project includes
#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-private.h"
diff --git a/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp b/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
index 0f6fb54e8384..24185b314466 100644
--- a/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
+++ b/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
@@ -100,8 +100,11 @@ bool lldb_private::formatters::WCharStringSummaryProvider(
if (!wchar_compiler_type)
return false;
- const uint32_t wchar_size = wchar_compiler_type.GetBitSize(
- nullptr); // Safe to pass NULL for exe_scope here
+ // Safe to pass nullptr for exe_scope here.
+ llvm::Optional<uint64_t> size = wchar_compiler_type.GetBitSize(nullptr);
+ if (!size)
+ return false;
+ const uint32_t wchar_size = *size;
StringPrinter::ReadStringAndDumpToStreamOptions options(valobj);
options.SetLocation(valobj_addr);
@@ -194,8 +197,11 @@ bool lldb_private::formatters::WCharSummaryProvider(
if (!wchar_compiler_type)
return false;
- const uint32_t wchar_size = wchar_compiler_type.GetBitSize(
- nullptr); // Safe to pass NULL for exe_scope here
+ // Safe to pass nullptr for exe_scope here.
+ llvm::Optional<uint64_t> size = wchar_compiler_type.GetBitSize(nullptr);
+ if (!size)
+ return false;
+ const uint32_t wchar_size = *size;
StringPrinter::ReadBufferAndDumpToStreamOptions options(valobj);
options.SetData(data);
diff --git a/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 95e02a473cd7..7e8c06bd4c75 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -9,10 +9,7 @@
#include "LibCxx.h"
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
+#include "llvm/ADT/ScopeExit.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/FormatEntity.h"
#include "lldb/Core/ValueObject.h"
@@ -22,7 +19,9 @@
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/DataFormatters/VectorIterator.h"
#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Target/CPPLanguageRuntime.h"
#include "lldb/Target/ProcessStructReader.h"
+#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Endian.h"
@@ -33,6 +32,76 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
+bool lldb_private::formatters::LibcxxOptionalSummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+ ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
+ if (!valobj_sp)
+ return false;
+
+ // An optional either contains a value or not, the member __engaged_ is
+ // a bool flag, it is true if the optional has a value and false otherwise.
+ ValueObjectSP engaged_sp(
+ valobj_sp->GetChildMemberWithName(ConstString("__engaged_"), true));
+
+ if (!engaged_sp)
+ return false;
+
+ llvm::StringRef engaged_as_cstring(
+ engaged_sp->GetValueAsUnsigned(0) == 1 ? "true" : "false");
+
+ stream.Printf(" Has Value=%s ", engaged_as_cstring.data());
+
+ return true;
+}
+
+bool lldb_private::formatters::LibcxxFunctionSummaryProvider(
+ ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
+
+ ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
+
+ if (!valobj_sp)
+ return false;
+
+ ExecutionContext exe_ctx(valobj_sp->GetExecutionContextRef());
+ Process *process = exe_ctx.GetProcessPtr();
+
+ if (process == nullptr)
+ return false;
+
+ CPPLanguageRuntime *cpp_runtime = process->GetCPPLanguageRuntime();
+
+ if (!cpp_runtime)
+ return false;
+
+ CPPLanguageRuntime::LibCppStdFunctionCallableInfo callable_info =
+ cpp_runtime->FindLibCppStdFunctionCallableInfo(valobj_sp);
+
+ switch (callable_info.callable_case) {
+ case CPPLanguageRuntime::LibCppStdFunctionCallableCase::Invalid:
+ stream.Printf(" __f_ = %" PRIu64, callable_info.member__f_pointer_value);
+ return false;
+ break;
+ case CPPLanguageRuntime::LibCppStdFunctionCallableCase::Lambda:
+ stream.Printf(
+ " Lambda in File %s at Line %u",
+ callable_info.callable_line_entry.file.GetFilename().GetCString(),
+ callable_info.callable_line_entry.line);
+ break;
+ case CPPLanguageRuntime::LibCppStdFunctionCallableCase::CallableObject:
+ stream.Printf(
+ " Function in File %s at Line %u",
+ callable_info.callable_line_entry.file.GetFilename().GetCString(),
+ callable_info.callable_line_entry.line);
+ break;
+ case CPPLanguageRuntime::LibCppStdFunctionCallableCase::FreeOrMemberFunction:
+ stream.Printf(" Function = %s ",
+ callable_info.callable_symbol.GetName().GetCString());
+ break;
+ }
+
+ return true;
+}
+
bool lldb_private::formatters::LibcxxSmartPointerSummaryProvider(
ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
@@ -120,9 +189,9 @@ bool lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() {
if (!valobj_sp)
return false;
-
+
static ConstString g___i_("__i_");
-
+
// this must be a ValueObject* because it is a child of the ValueObject we
// are producing children for it if were a ValueObjectSP, we would end up
// with a loop (iterator -> synthetic -> child -> parent == iterator) and
@@ -156,37 +225,53 @@ bool lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update() {
m_pair_ptr = nullptr;
return false;
}
- CompilerType pair_type(__i_->GetCompilerType().GetTypeTemplateArgument(0));
- std::string name; uint64_t bit_offset_ptr; uint32_t bitfield_bit_size_ptr; bool is_bitfield_ptr;
- pair_type = pair_type.GetFieldAtIndex(0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr);
+ CompilerType pair_type(
+ __i_->GetCompilerType().GetTypeTemplateArgument(0));
+ std::string name;
+ uint64_t bit_offset_ptr;
+ uint32_t bitfield_bit_size_ptr;
+ bool is_bitfield_ptr;
+ pair_type = pair_type.GetFieldAtIndex(
+ 0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr);
if (!pair_type) {
m_pair_ptr = nullptr;
return false;
}
-
+
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());
+ if (addr && addr != LLDB_INVALID_ADDRESS) {
+ ClangASTContext *ast_ctx =
+ llvm::dyn_cast_or_null<ClangASTContext>(pair_type.GetTypeSystem());
if (!ast_ctx)
return false;
- CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(ConstString(), {
- {"ptr0",ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
- {"ptr1",ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
- {"ptr2",ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
- {"cw",ast_ctx->GetBasicType(lldb::eBasicTypeBool)},
- {"payload",pair_type}
- });
- DataBufferSP buffer_sp(new DataBufferHeap(tree_node_type.GetByteSize(nullptr),0));
+ CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(
+ ConstString(),
+ {{"ptr0",
+ ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
+ {"ptr1",
+ ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
+ {"ptr2",
+ ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
+ {"cw", ast_ctx->GetBasicType(lldb::eBasicTypeBool)},
+ {"payload", pair_type}});
+ llvm::Optional<uint64_t> size = tree_node_type.GetByteSize(nullptr);
+ if (!size)
+ return false;
+ DataBufferSP buffer_sp(new DataBufferHeap(*size, 0));
ProcessSP process_sp(target_sp->GetProcessSP());
Status error;
- process_sp->ReadMemory(addr, buffer_sp->GetBytes(), buffer_sp->GetByteSize(), error);
+ process_sp->ReadMemory(addr, buffer_sp->GetBytes(),
+ buffer_sp->GetByteSize(), error);
if (error.Fail())
return false;
- DataExtractor extractor(buffer_sp, process_sp->GetByteOrder(), process_sp->GetAddressByteSize());
- auto pair_sp = CreateValueObjectFromData("pair", extractor, valobj_sp->GetExecutionContextRef(), tree_node_type);
+ DataExtractor extractor(buffer_sp, process_sp->GetByteOrder(),
+ process_sp->GetAddressByteSize());
+ auto pair_sp = CreateValueObjectFromData(
+ "pair", extractor, valobj_sp->GetExecutionContextRef(),
+ tree_node_type);
if (pair_sp)
- m_pair_sp = pair_sp->GetChildAtIndex(4,true);
+ m_pair_sp = pair_sp->GetChildAtIndex(4, true);
}
}
}
@@ -491,6 +576,8 @@ bool lldb_private::formatters::LibcxxWStringSummaryProvider(
->GetScratchClangASTContext()
->GetBasicType(lldb::eBasicTypeWChar)
.GetByteSize(nullptr);
+ if (!wchar_t_size)
+ return false;
options.SetData(extractor);
options.SetStream(&stream);
@@ -499,7 +586,7 @@ bool lldb_private::formatters::LibcxxWStringSummaryProvider(
options.SetSourceSize(size);
options.SetBinaryZeroIsTerminator(false);
- switch (wchar_t_size) {
+ switch (*wchar_t_size) {
case 1:
StringPrinter::ReadBufferAndDumpToStream<
lldb_private::formatters::StringPrinter::StringElementType::UTF8>(
@@ -526,9 +613,10 @@ bool lldb_private::formatters::LibcxxWStringSummaryProvider(
return true;
}
-bool lldb_private::formatters::LibcxxStringSummaryProvider(
- ValueObject &valobj, Stream &stream,
- const TypeSummaryOptions &summary_options) {
+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;
@@ -557,31 +645,37 @@ bool lldb_private::formatters::LibcxxStringSummaryProvider(
options.SetData(extractor);
options.SetStream(&stream);
- options.SetPrefixToken(nullptr);
+
+ if (prefix_token.empty())
+ options.SetPrefixToken(nullptr);
+ else
+ options.SetPrefixToken(prefix_token);
+
options.SetQuote('"');
options.SetSourceSize(size);
options.SetBinaryZeroIsTerminator(false);
- StringPrinter::ReadBufferAndDumpToStream<
- StringPrinter::StringElementType::ASCII>(options);
+ StringPrinter::ReadBufferAndDumpToStream<element_type>(options);
return true;
}
-class LibcxxFunctionFrontEnd : public SyntheticValueProviderFrontEnd {
-public:
- LibcxxFunctionFrontEnd(ValueObject &backend)
- : SyntheticValueProviderFrontEnd(backend) {}
+bool lldb_private::formatters::LibcxxStringSummaryProviderASCII(
+ ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &summary_options) {
+ return LibcxxStringSummaryProvider<StringPrinter::StringElementType::ASCII>(
+ valobj, stream, summary_options);
+}
- lldb::ValueObjectSP GetSyntheticValue() override {
- static ConstString g___f_("__f_");
- return m_backend.GetChildMemberWithName(g___f_, true);
- }
-};
+bool lldb_private::formatters::LibcxxStringSummaryProviderUTF16(
+ ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &summary_options) {
+ return LibcxxStringSummaryProvider<StringPrinter::StringElementType::UTF16>(
+ valobj, stream, summary_options, "u");
+}
-SyntheticChildrenFrontEnd *
-lldb_private::formatters::LibcxxFunctionFrontEndCreator(
- CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
- if (valobj_sp)
- return new LibcxxFunctionFrontEnd(*valobj_sp);
- return nullptr;
+bool lldb_private::formatters::LibcxxStringSummaryProviderUTF32(
+ ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &summary_options) {
+ return LibcxxStringSummaryProvider<StringPrinter::StringElementType::UTF32>(
+ valobj, stream, summary_options, "U");
}
diff --git a/source/Plugins/Language/CPlusPlus/LibCxx.h b/source/Plugins/Language/CPlusPlus/LibCxx.h
index 3f6e0d6e14d7..224a540eda04 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxx.h
+++ b/source/Plugins/Language/CPlusPlus/LibCxx.h
@@ -19,19 +19,35 @@
namespace lldb_private {
namespace formatters {
-bool LibcxxStringSummaryProvider(
+bool LibcxxStringSummaryProviderASCII(
ValueObject &valobj, Stream &stream,
- const TypeSummaryOptions &options); // libc++ std::string
+ const TypeSummaryOptions &summary_options); // libc++ std::string
+
+bool LibcxxStringSummaryProviderUTF16(
+ ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &summary_options); // libc++ std::u16string
+
+bool LibcxxStringSummaryProviderUTF32(
+ ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &summary_options); // libc++ std::u32string
bool LibcxxWStringSummaryProvider(
ValueObject &valobj, Stream &stream,
const TypeSummaryOptions &options); // libc++ std::wstring
+bool LibcxxOptionalSummaryProvider(
+ ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options); // libc++ std::optional<>
+
bool LibcxxSmartPointerSummaryProvider(
ValueObject &valobj, Stream &stream,
const TypeSummaryOptions
&options); // libc++ std::shared_ptr<> and std::weak_ptr<>
+bool LibcxxFunctionSummaryProvider(
+ ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options); // libc++ std::function<>
+
SyntheticChildrenFrontEnd *
LibcxxVectorBoolSyntheticFrontEndCreator(CXXSyntheticChildren *,
lldb::ValueObjectSP);
@@ -124,15 +140,20 @@ SyntheticChildrenFrontEnd *
LibcxxInitializerListSyntheticFrontEndCreator(CXXSyntheticChildren *,
lldb::ValueObjectSP);
-SyntheticChildrenFrontEnd *LibcxxFunctionFrontEndCreator(CXXSyntheticChildren *,
- lldb::ValueObjectSP);
-
SyntheticChildrenFrontEnd *LibcxxQueueFrontEndCreator(CXXSyntheticChildren *,
lldb::ValueObjectSP);
SyntheticChildrenFrontEnd *LibcxxTupleFrontEndCreator(CXXSyntheticChildren *,
lldb::ValueObjectSP);
+SyntheticChildrenFrontEnd *
+LibcxxOptionalFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP valobj_sp);
+
+SyntheticChildrenFrontEnd *
+LibcxxVariantFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP valobj_sp);
+
} // namespace formatters
} // namespace lldb_private
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp b/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
index 0cdb0b26cf3b..489ac4d96072 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
@@ -79,17 +79,24 @@ ValueObjectSP BitsetFrontEnd::GetChildAtIndex(size_t idx) {
CompilerType type;
ValueObjectSP chunk;
// For small bitsets __first_ is not an array, but a plain size_t.
- if (m_first->GetCompilerType().IsArrayType(&type, nullptr, nullptr))
- chunk = m_first->GetChildAtIndex(
- idx / type.GetBitSize(ctx.GetBestExecutionContextScope()), true);
- else {
+ if (m_first->GetCompilerType().IsArrayType(&type, nullptr, nullptr)) {
+ llvm::Optional<uint64_t> bit_size =
+ type.GetBitSize(ctx.GetBestExecutionContextScope());
+ if (!bit_size || *bit_size == 0)
+ return {};
+ chunk = m_first->GetChildAtIndex(idx / *bit_size, true);
+ } else {
type = m_first->GetCompilerType();
chunk = m_first;
}
if (!type || !chunk)
- return ValueObjectSP();
+ return {};
- size_t chunk_idx = idx % type.GetBitSize(ctx.GetBestExecutionContextScope());
+ llvm::Optional<uint64_t> bit_size =
+ type.GetBitSize(ctx.GetBestExecutionContextScope());
+ if (!bit_size || *bit_size == 0)
+ return {};
+ size_t chunk_idx = idx % *bit_size;
uint8_t value = !!(chunk->GetValueAsUnsigned(0) & (uint64_t(1) << chunk_idx));
DataExtractor data(&value, sizeof(value), m_byte_order, m_byte_size);
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp b/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
index 5823f6f3e038..390483d02668 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
@@ -7,10 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "LibCxx.h"
#include "lldb/Core/ValueObject.h"
@@ -98,12 +94,11 @@ bool lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
if (!m_element_type.IsValid())
return false;
- m_element_size = m_element_type.GetByteSize(nullptr);
-
- if (m_element_size > 0)
- m_start =
- m_backend.GetChildMemberWithName(g___begin_, true)
- .get(); // store raw pointers or end up with a circular dependency
+ if (llvm::Optional<uint64_t> size = m_element_type.GetByteSize(nullptr)) {
+ m_element_size = *size;
+ // Store raw pointers or end up with a circular dependency.
+ m_start = m_backend.GetChildMemberWithName(g___begin_, true).get();
+ }
return false;
}
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxList.cpp b/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
index 6066f14b18cc..81606b573cea 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
@@ -7,10 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "LibCxx.h"
#include "lldb/Core/ValueObject.h"
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
index 8f82bdcbfd59..429569d57928 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
@@ -7,10 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "LibCxx.h"
#include "lldb/Core/ValueObject.h"
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp b/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp
new file mode 100644
index 000000000000..762b824f262a
--- /dev/null
+++ b/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp
@@ -0,0 +1,85 @@
+//===-- LibCxxOptional.cpp --------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "LibCxx.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+namespace {
+
+class OptionalFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+ OptionalFrontEnd(ValueObject &valobj) : SyntheticChildrenFrontEnd(valobj) {
+ Update();
+ }
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override {
+ return formatters::ExtractIndexFromString(name.GetCString());
+ }
+
+ bool MightHaveChildren() override { return true; }
+ bool Update() override;
+ size_t CalculateNumChildren() override { return m_size; }
+ ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+private:
+ size_t m_size = 0;
+ ValueObjectSP m_base_sp;
+};
+} // namespace
+
+bool OptionalFrontEnd::Update() {
+ ValueObjectSP engaged_sp(
+ m_backend.GetChildMemberWithName(ConstString("__engaged_"), true));
+
+ if (!engaged_sp)
+ return false;
+
+ // __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);
+
+ return false;
+}
+
+ValueObjectSP OptionalFrontEnd::GetChildAtIndex(size_t idx) {
+ if (idx >= m_size)
+ return ValueObjectSP();
+
+ // __val_ contains the underlying value of an optional if it has one.
+ // Currently because it is part of an anonymous union GetChildMemberWithName()
+ // does not peer through and find it unless we are at the parent itself.
+ // We can obtain the parent through __engaged_.
+ ValueObjectSP val_sp(
+ m_backend.GetChildMemberWithName(ConstString("__engaged_"), true)
+ ->GetParent()
+ ->GetChildAtIndex(0, true)
+ ->GetChildMemberWithName(ConstString("__val_"), true));
+
+ if (!val_sp)
+ return ValueObjectSP();
+
+ CompilerType holder_type = val_sp->GetCompilerType();
+
+ if (!holder_type)
+ return ValueObjectSP();
+
+ return val_sp->Clone(ConstString(llvm::formatv("Value").str()));
+}
+
+SyntheticChildrenFrontEnd *
+formatters::LibcxxOptionalFrontEndCreator(CXXSyntheticChildren *,
+ lldb::ValueObjectSP valobj_sp) {
+ if (valobj_sp)
+ return new OptionalFrontEnd(*valobj_sp);
+ return nullptr;
+}
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
index 0f1c2537d651..51ae8cb3184c 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -7,10 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "LibCxx.h"
#include "lldb/Core/ValueObject.h"
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp b/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
new file mode 100644
index 000000000000..e874616c3251
--- /dev/null
+++ b/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
@@ -0,0 +1,256 @@
+//===-- LibCxxVariant.cpp --------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "LibCxxVariant.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
+
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/ScopeExit.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+// libc++ variant implementation contains two members that we care about both
+// are contained in the __impl member.
+// - __index which tells us which of the variadic template types is the active
+// type for the variant
+// - __data is a variadic union which recursively contains itself as member
+// which refers to the tailing variadic types.
+// - __head which refers to the leading non pack type
+// - __value refers to the actual value contained
+// - __tail which refers to the remaining pack types
+//
+// e.g. given std::variant<int,double,char> v1
+//
+// (lldb) frame var -R v1.__impl.__data
+//(... __union<... 0, int, double, char>) v1.__impl.__data = {
+// ...
+// __head = {
+// __value = ...
+// }
+// __tail = {
+// ...
+// __head = {
+// __value = ...
+// }
+// __tail = {
+// ...
+// __head = {
+// __value = ...
+// ...
+//
+// So given
+// - __index equal to 0 the active value is contained in
+//
+// __data.__head.__value
+//
+// - __index equal to 1 the active value is contained in
+//
+// __data.__tail.__head.__value
+//
+// - __index equal to 2 the active value is contained in
+//
+// __data.__tail.__tail.__head.__value
+//
+
+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 };
+
+LibcxxVariantIndexValidity
+LibcxxVariantGetIndexValidity(ValueObjectSP &impl_sp) {
+ ValueObjectSP index_sp(
+ impl_sp->GetChildMemberWithName(ConstString("__index"), true));
+
+ if (!index_sp)
+ return LibcxxVariantIndexValidity::INVALID;
+
+ int64_t index_value = index_sp->GetValueAsSigned(0);
+
+ if (index_value == -1)
+ return LibcxxVariantIndexValidity::NPOS;
+
+ return LibcxxVariantIndexValidity::VALID;
+}
+
+llvm::Optional<uint64_t> LibcxxVariantIndexValue(ValueObjectSP &impl_sp) {
+ ValueObjectSP index_sp(
+ impl_sp->GetChildMemberWithName(ConstString("__index"), true));
+
+ if (!index_sp)
+ return {};
+
+ return {index_sp->GetValueAsUnsigned(0)};
+}
+
+ValueObjectSP LibcxxVariantGetNthHead(ValueObjectSP &impl_sp, uint64_t index) {
+ ValueObjectSP data_sp(
+ impl_sp->GetChildMemberWithName(ConstString("__data"), true));
+
+ if (!data_sp)
+ return ValueObjectSP{};
+
+ ValueObjectSP current_level = data_sp;
+ for (uint64_t n = index; n != 0; --n) {
+ ValueObjectSP tail_sp(
+ current_level->GetChildMemberWithName(ConstString("__tail"), true));
+
+ if (!tail_sp)
+ return ValueObjectSP{};
+
+ current_level = tail_sp;
+ }
+
+ return current_level->GetChildMemberWithName(ConstString("__head"), true);
+}
+} // namespace
+
+namespace lldb_private {
+namespace formatters {
+bool LibcxxVariantSummaryProvider(ValueObject &valobj, Stream &stream,
+ const TypeSummaryOptions &options) {
+ ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
+ if (!valobj_sp)
+ return false;
+
+ ValueObjectSP impl_sp(
+ valobj_sp->GetChildMemberWithName(ConstString("__impl"), true));
+
+ if (!impl_sp)
+ return false;
+
+ LibcxxVariantIndexValidity validity = LibcxxVariantGetIndexValidity(impl_sp);
+
+ if (validity == LibcxxVariantIndexValidity::INVALID)
+ return false;
+
+ if (validity == LibcxxVariantIndexValidity::NPOS) {
+ stream.Printf(" No Value");
+ return true;
+ }
+
+ auto optional_index_value = LibcxxVariantIndexValue(impl_sp);
+
+ if (!optional_index_value)
+ return false;
+
+ uint64_t index_value = *optional_index_value;
+
+ ValueObjectSP nth_head = LibcxxVariantGetNthHead(impl_sp, index_value);
+
+ if (!nth_head)
+ return false;
+
+ CompilerType head_type = nth_head->GetCompilerType();
+
+ if (!head_type)
+ return false;
+
+ CompilerType template_type = head_type.GetTypeTemplateArgument(1);
+
+ if (!template_type)
+ return false;
+
+ stream.Printf(" Active Type = %s ", template_type.GetTypeName().GetCString());
+
+ return true;
+}
+} // namespace formatters
+} // namespace lldb_private
+
+namespace {
+class VariantFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+ VariantFrontEnd(ValueObject &valobj) : SyntheticChildrenFrontEnd(valobj) {
+ Update();
+ }
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override {
+ return formatters::ExtractIndexFromString(name.GetCString());
+ }
+
+ bool MightHaveChildren() override { return true; }
+ bool Update() override;
+ size_t CalculateNumChildren() override { return m_size; }
+ ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+private:
+ size_t m_size = 0;
+ ValueObjectSP m_base_sp;
+};
+} // namespace
+
+bool VariantFrontEnd::Update() {