aboutsummaryrefslogtreecommitdiff
path: root/source/Plugins
diff options
context:
space:
mode:
Diffstat (limited to 'source/Plugins')
-rw-r--r--source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp4
-rw-r--r--source/Plugins/ABI/MacOSX-arm/CMakeLists.txt10
-rw-r--r--source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp6
-rw-r--r--source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h2
-rw-r--r--source/Plugins/ABI/MacOSX-arm64/CMakeLists.txt9
-rw-r--r--source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp4
-rw-r--r--source/Plugins/ABI/MacOSX-i386/CMakeLists.txt9
-rw-r--r--source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp4
-rw-r--r--source/Plugins/ABI/SysV-arm/CMakeLists.txt10
-rw-r--r--source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp8
-rw-r--r--source/Plugins/ABI/SysV-arm64/CMakeLists.txt9
-rw-r--r--source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp8
-rw-r--r--source/Plugins/ABI/SysV-hexagon/CMakeLists.txt9
-rw-r--r--source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp8
-rw-r--r--source/Plugins/ABI/SysV-i386/CMakeLists.txt9
-rw-r--r--source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp8
-rw-r--r--source/Plugins/ABI/SysV-mips/CMakeLists.txt9
-rw-r--r--source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp8
-rw-r--r--source/Plugins/ABI/SysV-mips64/CMakeLists.txt9
-rw-r--r--source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp8
-rw-r--r--source/Plugins/ABI/SysV-ppc/CMakeLists.txt9
-rw-r--r--source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp8
-rw-r--r--source/Plugins/ABI/SysV-ppc64/CMakeLists.txt9
-rw-r--r--source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp8
-rw-r--r--source/Plugins/ABI/SysV-s390x/CMakeLists.txt9
-rw-r--r--source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp8
-rw-r--r--source/Plugins/ABI/SysV-x86_64/CMakeLists.txt9
-rw-r--r--source/Plugins/Disassembler/llvm/CMakeLists.txt13
-rw-r--r--source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp8
-rw-r--r--source/Plugins/DynamicLoader/Darwin-Kernel/CMakeLists.txt12
-rw-r--r--source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp13
-rw-r--r--source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h4
-rw-r--r--source/Plugins/DynamicLoader/Hexagon-DYLD/CMakeLists.txt8
-rw-r--r--source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp2
-rw-r--r--source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp4
-rw-r--r--source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt13
-rw-r--r--source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp10
-rw-r--r--source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h4
-rw-r--r--source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp8
-rw-r--r--source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h4
-rw-r--r--source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp6
-rw-r--r--source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h4
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp6
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/CMakeLists.txt12
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp9
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h2
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp7
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h3
-rw-r--r--source/Plugins/DynamicLoader/Static/CMakeLists.txt9
-rw-r--r--source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h4
-rw-r--r--source/Plugins/DynamicLoader/Windows-DYLD/CMakeLists.txt8
-rw-r--r--source/Plugins/ExpressionParser/Clang/ASTDumper.cpp2
-rw-r--r--source/Plugins/ExpressionParser/Clang/ASTDumper.h2
-rw-r--r--source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp2
-rw-r--r--source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp2
-rw-r--r--source/Plugins/ExpressionParser/Clang/CMakeLists.txt28
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp3
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp6
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp27
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h2
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp6
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h2
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp4
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp14
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp6
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp8
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp6
-rw-r--r--source/Plugins/ExpressionParser/Clang/IRForTarget.cpp26
-rw-r--r--source/Plugins/ExpressionParser/Clang/IRForTarget.h8
-rw-r--r--source/Plugins/ExpressionParser/Go/CMakeLists.txt10
-rw-r--r--source/Plugins/ExpressionParser/Go/GoParser.cpp2
-rw-r--r--source/Plugins/ExpressionParser/Go/GoUserExpression.cpp12
-rw-r--r--source/Plugins/Instruction/ARM/CMakeLists.txt12
-rw-r--r--source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp561
-rw-r--r--source/Plugins/Instruction/ARM/EmulateInstructionARM.h4
-rw-r--r--source/Plugins/Instruction/ARM/EmulationStateARM.cpp13
-rw-r--r--source/Plugins/Instruction/ARM64/CMakeLists.txt10
-rw-r--r--source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp5
-rw-r--r--source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h2
-rw-r--r--source/Plugins/Instruction/MIPS/CMakeLists.txt17
-rw-r--r--source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp10
-rw-r--r--source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h2
-rw-r--r--source/Plugins/Instruction/MIPS64/CMakeLists.txt17
-rw-r--r--source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp10
-rw-r--r--source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h2
-rw-r--r--source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp4
-rw-r--r--source/Plugins/InstrumentationRuntime/AddressSanitizer/CMakeLists.txt12
-rw-r--r--source/Plugins/InstrumentationRuntime/ThreadSanitizer/CMakeLists.txt11
-rw-r--r--source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp90
-rw-r--r--source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.h3
-rw-r--r--source/Plugins/JITLoader/GDB/CMakeLists.txt12
-rw-r--r--source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp8
-rw-r--r--source/Plugins/Language/CPlusPlus/CMakeLists.txt13
-rw-r--r--source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp224
-rw-r--r--source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h21
-rw-r--r--source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp630
-rw-r--r--source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h179
-rw-r--r--source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp10
-rw-r--r--source/Plugins/Language/CPlusPlus/CxxStringTypes.h2
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxx.cpp159
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxx.h26
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxAtomic.h2
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp2
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxList.cpp8
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxMap.cpp13
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp8
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxVector.cpp146
-rw-r--r--source/Plugins/Language/CPlusPlus/LibStdcpp.cpp8
-rw-r--r--source/Plugins/Language/CPlusPlus/LibStdcpp.h2
-rw-r--r--source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp6
-rw-r--r--source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp31
-rw-r--r--source/Plugins/Language/Go/CMakeLists.txt11
-rw-r--r--source/Plugins/Language/Go/GoFormatterFunctions.h2
-rw-r--r--source/Plugins/Language/Go/GoLanguage.cpp11
-rw-r--r--source/Plugins/Language/Go/GoLanguage.h2
-rw-r--r--source/Plugins/Language/Java/CMakeLists.txt10
-rw-r--r--source/Plugins/Language/Java/JavaLanguage.cpp7
-rw-r--r--source/Plugins/Language/Java/JavaLanguage.h2
-rw-r--r--source/Plugins/Language/OCaml/CMakeLists.txt10
-rw-r--r--source/Plugins/Language/OCaml/OCamlLanguage.cpp2
-rw-r--r--source/Plugins/Language/OCaml/OCamlLanguage.h2
-rw-r--r--source/Plugins/Language/ObjC/CF.cpp8
-rw-r--r--source/Plugins/Language/ObjC/CF.h2
-rw-r--r--source/Plugins/Language/ObjC/CMakeLists.txt13
-rw-r--r--source/Plugins/Language/ObjC/Cocoa.cpp11
-rw-r--r--source/Plugins/Language/ObjC/Cocoa.h2
-rw-r--r--source/Plugins/Language/ObjC/CoreMedia.cpp3
-rw-r--r--source/Plugins/Language/ObjC/CoreMedia.h2
-rw-r--r--source/Plugins/Language/ObjC/NSArray.cpp8
-rw-r--r--source/Plugins/Language/ObjC/NSDictionary.cpp8
-rw-r--r--source/Plugins/Language/ObjC/NSDictionary.h4
-rw-r--r--source/Plugins/Language/ObjC/NSError.cpp11
-rw-r--r--source/Plugins/Language/ObjC/NSException.cpp11
-rw-r--r--source/Plugins/Language/ObjC/NSSet.cpp8
-rw-r--r--source/Plugins/Language/ObjC/NSSet.h4
-rw-r--r--source/Plugins/Language/ObjC/NSString.cpp10
-rw-r--r--source/Plugins/Language/ObjC/NSString.h2
-rw-r--r--source/Plugins/Language/ObjC/ObjCLanguage.cpp10
-rw-r--r--source/Plugins/Language/ObjC/ObjCLanguage.h2
-rw-r--r--source/Plugins/Language/ObjCPlusPlus/CMakeLists.txt6
-rw-r--r--source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp2
-rw-r--r--source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt9
-rw-r--r--source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp6
-rw-r--r--source/Plugins/LanguageRuntime/Go/CMakeLists.txt10
-rw-r--r--source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.cpp6
-rw-r--r--source/Plugins/LanguageRuntime/Java/CMakeLists.txt9
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp39
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp2
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp8
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp13
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp36
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp6
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp2
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt16
-rw-r--r--source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt18
-rw-r--r--source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp2
-rw-r--r--source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp26
-rw-r--r--source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp7
-rw-r--r--source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp19
-rw-r--r--source/Plugins/MemoryHistory/asan/CMakeLists.txt8
-rw-r--r--source/Plugins/ObjectContainer/BSD-Archive/CMakeLists.txt9
-rw-r--r--source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp194
-rw-r--r--source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h6
-rw-r--r--source/Plugins/ObjectContainer/Universal-Mach-O/CMakeLists.txt9
-rw-r--r--source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp4
-rw-r--r--source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h2
-rw-r--r--source/Plugins/ObjectFile/ELF/CMakeLists.txt10
-rw-r--r--source/Plugins/ObjectFile/ELF/ELFHeader.cpp47
-rw-r--r--source/Plugins/ObjectFile/ELF/ELFHeader.h32
-rw-r--r--source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp179
-rw-r--r--source/Plugins/ObjectFile/ELF/ObjectFileELF.h4
-rw-r--r--source/Plugins/ObjectFile/JIT/CMakeLists.txt10
-rw-r--r--source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp12
-rw-r--r--source/Plugins/ObjectFile/Mach-O/CMakeLists.txt12
-rw-r--r--source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp266
-rw-r--r--source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h7
-rw-r--r--source/Plugins/ObjectFile/PECOFF/CMakeLists.txt10
-rw-r--r--source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp47
-rw-r--r--source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp2
-rw-r--r--source/Plugins/OperatingSystem/Go/CMakeLists.txt9
-rw-r--r--source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp6
-rw-r--r--source/Plugins/OperatingSystem/Python/CMakeLists.txt9
-rw-r--r--source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp4
-rw-r--r--source/Plugins/Platform/Android/AdbClient.cpp28
-rw-r--r--source/Plugins/Platform/Android/AdbClient.h2
-rw-r--r--source/Plugins/Platform/Android/CMakeLists.txt10
-rw-r--r--source/Plugins/Platform/Android/PlatformAndroid.cpp9
-rw-r--r--source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp6
-rw-r--r--source/Plugins/Platform/CMakeLists.txt2
-rw-r--r--source/Plugins/Platform/FreeBSD/CMakeLists.txt8
-rw-r--r--source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp441
-rw-r--r--source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h93
-rw-r--r--source/Plugins/Platform/Kalimba/CMakeLists.txt7
-rw-r--r--source/Plugins/Platform/Kalimba/PlatformKalimba.cpp116
-rw-r--r--source/Plugins/Platform/Kalimba/PlatformKalimba.h9
-rw-r--r--source/Plugins/Platform/Linux/CMakeLists.txt10
-rw-r--r--source/Plugins/Platform/Linux/PlatformLinux.cpp358
-rw-r--r--source/Plugins/Platform/Linux/PlatformLinux.h20
-rw-r--r--source/Plugins/Platform/MacOSX/CMakeLists.txt17
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp11
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h2
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp14
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp12
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformDarwin.cpp215
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformDarwin.h16
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp49
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h21
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp14
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp44
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h6
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp44
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h6
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp57
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h6
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp14
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.h4
-rw-r--r--source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm2
-rw-r--r--source/Plugins/Platform/NetBSD/CMakeLists.txt8
-rw-r--r--source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp661
-rw-r--r--source/Plugins/Platform/NetBSD/PlatformNetBSD.h100
-rw-r--r--source/Plugins/Platform/OpenBSD/CMakeLists.txt9
-rw-r--r--source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp223
-rw-r--r--source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h66
-rw-r--r--source/Plugins/Platform/POSIX/CMakeLists.txt9
-rw-r--r--source/Plugins/Platform/POSIX/PlatformPOSIX.cpp199
-rw-r--r--source/Plugins/Platform/POSIX/PlatformPOSIX.h14
-rw-r--r--source/Plugins/Platform/Windows/CMakeLists.txt8
-rw-r--r--source/Plugins/Platform/Windows/PlatformWindows.cpp2
-rw-r--r--source/Plugins/Platform/gdb-server/CMakeLists.txt9
-rw-r--r--source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp12
-rw-r--r--source/Plugins/Process/CMakeLists.txt5
-rw-r--r--source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp8
-rw-r--r--source/Plugins/Process/Darwin/MachException.cpp6
-rw-r--r--source/Plugins/Process/Darwin/NativeProcessDarwin.cpp10
-rw-r--r--source/Plugins/Process/Darwin/NativeProcessDarwin.h2
-rw-r--r--source/Plugins/Process/Darwin/NativeThreadDarwin.cpp2
-rw-r--r--source/Plugins/Process/Darwin/NativeThreadListDarwin.cpp6
-rw-r--r--source/Plugins/Process/FreeBSD/CMakeLists.txt14
-rw-r--r--source/Plugins/Process/FreeBSD/FreeBSDThread.cpp56
-rw-r--r--source/Plugins/Process/FreeBSD/POSIXStopInfo.h10
-rw-r--r--source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp264
-rw-r--r--source/Plugins/Process/FreeBSD/ProcessFreeBSD.h32
-rw-r--r--source/Plugins/Process/FreeBSD/ProcessMonitor.cpp24
-rw-r--r--source/Plugins/Process/FreeBSD/ProcessMonitor.h2
-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_mips64.h3
-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/CMakeLists.txt14
-rw-r--r--source/Plugins/Process/Linux/NativeProcessLinux.cpp1059
-rw-r--r--source/Plugins/Process/Linux/NativeProcessLinux.h10
-rw-r--r--source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp10
-rw-r--r--source/Plugins/Process/Linux/NativeRegisterContextLinux.h2
-rw-r--r--source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp270
-rw-r--r--source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h7
-rw-r--r--source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp239
-rw-r--r--source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h7
-rw-r--r--source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp260
-rw-r--r--source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp6
-rwxr-xr-xsource/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp6
-rw-r--r--source/Plugins/Process/Linux/NativeThreadLinux.cpp119
-rw-r--r--source/Plugins/Process/Linux/NativeThreadLinux.h14
-rw-r--r--source/Plugins/Process/Linux/ProcFileReader.cpp103
-rw-r--r--source/Plugins/Process/Linux/ProcFileReader.h37
-rw-r--r--source/Plugins/Process/Linux/SingleStepCheck.cpp128
-rw-r--r--source/Plugins/Process/Linux/SingleStepCheck.h51
-rw-r--r--source/Plugins/Process/MacOSX-Kernel/CMakeLists.txt14
-rw-r--r--source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp199
-rw-r--r--source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp17
-rw-r--r--source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h8
-rw-r--r--source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp197
-rw-r--r--source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h28
-rw-r--r--source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp14
-rw-r--r--source/Plugins/Process/NetBSD/CMakeLists.txt21
-rw-r--r--source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp1018
-rw-r--r--source/Plugins/Process/NetBSD/NativeProcessNetBSD.h141
-rw-r--r--source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp92
-rw-r--r--source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h65
-rw-r--r--source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp483
-rw-r--r--source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h72
-rw-r--r--source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp159
-rw-r--r--source/Plugins/Process/NetBSD/NativeThreadNetBSD.h73
-rw-r--r--source/Plugins/Process/POSIX/CMakeLists.txt8
-rw-r--r--source/Plugins/Process/POSIX/CrashReason.cpp6
-rw-r--r--source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp193
-rw-r--r--source/Plugins/Process/POSIX/ProcessPOSIXLog.h78
-rw-r--r--source/Plugins/Process/Utility/CMakeLists.txt21
-rw-r--r--source/Plugins/Process/Utility/DynamicRegisterInfo.cpp3
-rw-r--r--source/Plugins/Process/Utility/DynamicRegisterInfo.h2
-rw-r--r--source/Plugins/Process/Utility/HistoryThread.cpp2
-rw-r--r--source/Plugins/Process/Utility/HistoryThread.h2
-rw-r--r--source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp43
-rw-r--r--source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h41
-rw-r--r--source/Plugins/Process/Utility/NetBSDSignals.cpp34
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp8
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp8
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp8
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp8
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDummy.cpp4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextFreeBSD_arm.cpp97
-rw-r--r--source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp35
-rw-r--r--source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextHistory.cpp4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLLDB.cpp28
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLLDB.h2
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_arm.h62
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp86
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_mips.h4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp97
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_mips64.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp6
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMemory.cpp4
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMemory.h2
-rw-r--r--source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp285
-rw-r--r--source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp80
-rw-r--r--source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.h26
-rw-r--r--source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp107
-rw-r--r--source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h31
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp6
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h2
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp6
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h2
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp111
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h15
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp6
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h2
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp6
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h2
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp8
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h2
-rw-r--r--source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp2
-rw-r--r--source/Plugins/Process/Utility/RegisterInfoInterface.h1
-rw-r--r--source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.cpp (renamed from source/Plugins/Process/Utility/RegisterContextLinux_arm.cpp)38
-rw-r--r--source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.h (renamed from source/Plugins/Process/Utility/RegisterContextFreeBSD_arm.h)12
-rw-r--r--source/Plugins/Process/Utility/StopInfoMachException.cpp2
-rw-r--r--source/Plugins/Process/Utility/UnwindLLDB.cpp2
-rw-r--r--source/Plugins/Process/Utility/UnwindLLDB.h2
-rw-r--r--source/Plugins/Process/Windows/Common/CMakeLists.txt13
-rw-r--r--source/Plugins/Process/Windows/Common/DebuggerThread.cpp195
-rw-r--r--source/Plugins/Process/Windows/Common/ProcessWindows.cpp337
-rw-r--r--source/Plugins/Process/Windows/Common/ProcessWindows.h2
-rw-r--r--source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp153
-rw-r--r--source/Plugins/Process/Windows/Common/ProcessWindowsLog.h65
-rw-r--r--source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp14
-rw-r--r--source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp4
-rw-r--r--source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp2
-rw-r--r--source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp48
-rw-r--r--source/Plugins/Process/elf-core/CMakeLists.txt11
-rw-r--r--source/Plugins/Process/elf-core/ProcessElfCore.cpp102
-rw-r--r--source/Plugins/Process/elf-core/ProcessElfCore.h4
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h4
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h4
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp22
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h6
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp2
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h2
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp2
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h2
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp2
-rw-r--r--source/Plugins/Process/elf-core/ThreadElfCore.cpp131
-rw-r--r--source/Plugins/Process/elf-core/ThreadElfCore.h41
-rw-r--r--source/Plugins/Process/gdb-remote/CMakeLists.txt28
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp55
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp133
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h6
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp66
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp180
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h4
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp34
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp7
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h4
-rw-r--r--source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp153
-rw-r--r--source/Plugins/Process/gdb-remote/ProcessGDBRemote.h12
-rw-r--r--source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp221
-rw-r--r--source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h19
-rw-r--r--source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp18
-rw-r--r--source/Plugins/Process/mach-core/CMakeLists.txt15
-rw-r--r--source/Plugins/Process/mach-core/ProcessMachCore.cpp69
-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/minidump/CMakeLists.txt11
-rw-r--r--source/Plugins/Process/minidump/MinidumpParser.h4
-rw-r--r--source/Plugins/Process/minidump/MinidumpTypes.h2
-rw-r--r--source/Plugins/Process/minidump/ProcessMinidump.cpp32
-rw-r--r--source/Plugins/Process/minidump/ProcessMinidump.h4
-rw-r--r--source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp2
-rw-r--r--source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp2
-rw-r--r--source/Plugins/Process/minidump/ThreadMinidump.cpp4
-rw-r--r--source/Plugins/ScriptInterpreter/None/CMakeLists.txt6
-rw-r--r--source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp10
-rw-r--r--source/Plugins/ScriptInterpreter/Python/CMakeLists.txt12
-rw-r--r--source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp2
-rw-r--r--source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h5
-rw-r--r--source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp53
-rw-r--r--source/Plugins/StructuredData/DarwinLog/CMakeLists.txt11
-rw-r--r--source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp9
-rw-r--r--source/Plugins/SymbolFile/DWARF/CMakeLists.txt18
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp4
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp4
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp22
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp2
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h4
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp2
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp2
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp4
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp8
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h2
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp47
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp2
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.cpp2
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp2
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp2
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.cpp4
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.h3
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp10
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h2
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp2
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp19
-rw-r--r--source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h2
-rw-r--r--source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp210
-rw-r--r--source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h47
-rw-r--r--source/Plugins/SymbolFile/DWARF/NameToDIE.cpp8
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp22
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h8
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp2
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h1
-rw-r--r--source/Plugins/SymbolFile/PDB/CMakeLists.txt15
-rw-r--r--source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp118
-rw-r--r--source/Plugins/SymbolFile/PDB/SymbolFilePDB.h2
-rw-r--r--source/Plugins/SymbolFile/Symtab/CMakeLists.txt6
-rw-r--r--source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp3
-rw-r--r--source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h1
-rw-r--r--source/Plugins/SymbolVendor/ELF/CMakeLists.txt7
-rw-r--r--source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp2
-rw-r--r--source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt7
-rw-r--r--source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp2
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp6
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h2
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp6
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h2
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp6
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h2
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp6
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h2
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/CMakeLists.txt12
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp12
-rw-r--r--source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h6
-rw-r--r--source/Plugins/UnwindAssembly/InstEmulation/CMakeLists.txt7
-rw-r--r--source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp14
-rw-r--r--source/Plugins/UnwindAssembly/x86/CMakeLists.txt12
-rw-r--r--source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp4
-rw-r--r--source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp9
-rw-r--r--source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h2
455 files changed, 10241 insertions, 7096 deletions
diff --git a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
index 969c7d3c071e..dc1c8dcf4ab0 100644
--- a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
+++ b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
@@ -18,8 +18,6 @@
#include "llvm/ADT/Triple.h"
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegisterValue.h"
@@ -31,6 +29,8 @@
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
#include "Plugins/Process/Utility/ARMDefines.h"
#include "Utility/ARM_DWARF_Registers.h"
diff --git a/source/Plugins/ABI/MacOSX-arm/CMakeLists.txt b/source/Plugins/ABI/MacOSX-arm/CMakeLists.txt
index ea8b011b1984..b41814f3237b 100644
--- a/source/Plugins/ABI/MacOSX-arm/CMakeLists.txt
+++ b/source/Plugins/ABI/MacOSX-arm/CMakeLists.txt
@@ -1,3 +1,11 @@
-add_lldb_library(lldbPluginABIMacOSX_arm
+add_lldb_library(lldbPluginABIMacOSX_arm PLUGIN
ABIMacOSX_arm.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
+ lldbTarget
+ lldbPluginProcessUtility
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
index ee27a7e8d9b3..c5e53361bf99 100644
--- a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
+++ b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
@@ -17,9 +17,6 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Triple.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegisterValue.h"
@@ -32,6 +29,9 @@
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
#include "Utility/ARM64_DWARF_Registers.h"
diff --git a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h
index e0978116a730..93a548a79682 100644
--- a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h
+++ b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h
@@ -14,8 +14,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
#include "lldb/Target/ABI.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-private.h"
class ABIMacOSX_arm64 : public lldb_private::ABI {
diff --git a/source/Plugins/ABI/MacOSX-arm64/CMakeLists.txt b/source/Plugins/ABI/MacOSX-arm64/CMakeLists.txt
index 498bb7218637..f769d63bcdac 100644
--- a/source/Plugins/ABI/MacOSX-arm64/CMakeLists.txt
+++ b/source/Plugins/ABI/MacOSX-arm64/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginABIMacOSX_arm64
+add_lldb_library(lldbPluginABIMacOSX_arm64 PLUGIN
ABIMacOSX_arm64.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
index 6eead6f35e3b..bbaec25b37b8 100644
--- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
+++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
@@ -18,8 +18,6 @@
#include "llvm/ADT/Triple.h"
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegisterValue.h"
@@ -30,6 +28,8 @@
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/ABI/MacOSX-i386/CMakeLists.txt b/source/Plugins/ABI/MacOSX-i386/CMakeLists.txt
index f6a543a66da7..21f153d36e08 100644
--- a/source/Plugins/ABI/MacOSX-i386/CMakeLists.txt
+++ b/source/Plugins/ABI/MacOSX-i386/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginABIMacOSX_i386
+add_lldb_library(lldbPluginABIMacOSX_i386 PLUGIN
ABIMacOSX_i386.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp b/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
index ebd0d17cf8ab..3df225cc895d 100644
--- a/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
+++ b/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
@@ -18,8 +18,6 @@
#include "llvm/ADT/Triple.h"
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegisterValue.h"
@@ -31,6 +29,8 @@
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
#include "Plugins/Process/Utility/ARMDefines.h"
#include "Utility/ARM_DWARF_Registers.h"
diff --git a/source/Plugins/ABI/SysV-arm/CMakeLists.txt b/source/Plugins/ABI/SysV-arm/CMakeLists.txt
index c25ce5a1c633..c5979046d36c 100644
--- a/source/Plugins/ABI/SysV-arm/CMakeLists.txt
+++ b/source/Plugins/ABI/SysV-arm/CMakeLists.txt
@@ -1,3 +1,11 @@
-add_lldb_library(lldbPluginABISysV_arm
+add_lldb_library(lldbPluginABISysV_arm PLUGIN
ABISysV_arm.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
+ lldbTarget
+ lldbPluginProcessUtility
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
index 5e2179212be9..04df0065d7bc 100644
--- a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
+++ b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
@@ -18,9 +18,6 @@
#include "llvm/ADT/Triple.h"
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegisterValue.h"
@@ -32,6 +29,9 @@
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
#include "Utility/ARM64_DWARF_Registers.h"
@@ -1697,7 +1697,7 @@ bool ABISysV_arm64::PrepareTrivialCall(Thread &thread, addr_t sp,
if (log) {
StreamString s;
- s.Printf("ABISysV_x86_64::PrepareTrivialCall (tid = 0x%" PRIx64
+ s.Printf("ABISysV_arm64::PrepareTrivialCall (tid = 0x%" PRIx64
", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64
", return_addr = 0x%" PRIx64,
thread.GetID(), (uint64_t)sp, (uint64_t)func_addr,
diff --git a/source/Plugins/ABI/SysV-arm64/CMakeLists.txt b/source/Plugins/ABI/SysV-arm64/CMakeLists.txt
index 0ddb37043ace..077b394823c6 100644
--- a/source/Plugins/ABI/SysV-arm64/CMakeLists.txt
+++ b/source/Plugins/ABI/SysV-arm64/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginABISysV_arm64
+add_lldb_library(lldbPluginABISysV_arm64 PLUGIN
ABISysV_arm64.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
index 649f19b0b831..0b024dbac07d 100644
--- a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
+++ b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
@@ -16,10 +16,6 @@
#include "llvm/IR/DerivedTypes.h"
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegisterValue.h"
@@ -33,6 +29,10 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/ABI/SysV-hexagon/CMakeLists.txt b/source/Plugins/ABI/SysV-hexagon/CMakeLists.txt
index b8fbb0744719..a857fff12399 100644
--- a/source/Plugins/ABI/SysV-hexagon/CMakeLists.txt
+++ b/source/Plugins/ABI/SysV-hexagon/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginABISysV_hexagon
+add_lldb_library(lldbPluginABISysV_hexagon PLUGIN
ABISysV_hexagon.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp b/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
index 701db184dfce..aee102c16ba1 100644
--- a/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
+++ b/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
@@ -16,10 +16,6 @@
#include "llvm/ADT/Triple.h"
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegisterValue.h"
@@ -33,6 +29,10 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/ABI/SysV-i386/CMakeLists.txt b/source/Plugins/ABI/SysV-i386/CMakeLists.txt
index 3528f01ad75e..598b3d03c0f3 100644
--- a/source/Plugins/ABI/SysV-i386/CMakeLists.txt
+++ b/source/Plugins/ABI/SysV-i386/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginABISysV_i386
+add_lldb_library(lldbPluginABISysV_i386 PLUGIN
ABISysV_i386.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp b/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
index b97fffe3efa3..69725e30b063 100644
--- a/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
+++ b/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
@@ -16,10 +16,6 @@
#include "llvm/ADT/Triple.h"
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegisterValue.h"
@@ -33,6 +29,10 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/ABI/SysV-mips/CMakeLists.txt b/source/Plugins/ABI/SysV-mips/CMakeLists.txt
index 0db3e5c1c7e0..a3266a75ae73 100644
--- a/source/Plugins/ABI/SysV-mips/CMakeLists.txt
+++ b/source/Plugins/ABI/SysV-mips/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginABISysV_mips
+add_lldb_library(lldbPluginABISysV_mips PLUGIN
ABISysV_mips.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
index bb83dec5d9df..bbcf2e575825 100644
--- a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
+++ b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
@@ -16,10 +16,6 @@
#include "llvm/ADT/Triple.h"
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegisterValue.h"
@@ -33,6 +29,10 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/ABI/SysV-mips64/CMakeLists.txt b/source/Plugins/ABI/SysV-mips64/CMakeLists.txt
index 099464821edd..5eddfb539f05 100644
--- a/source/Plugins/ABI/SysV-mips64/CMakeLists.txt
+++ b/source/Plugins/ABI/SysV-mips64/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginABISysV_mips64
+add_lldb_library(lldbPluginABISysV_mips64 PLUGIN
ABISysV_mips64.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
index 3e563c2b5d9c..2dff0d203611 100644
--- a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
+++ b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
@@ -16,10 +16,6 @@
#include "llvm/ADT/Triple.h"
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegisterValue.h"
@@ -33,6 +29,10 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/ABI/SysV-ppc/CMakeLists.txt b/source/Plugins/ABI/SysV-ppc/CMakeLists.txt
index a7784195f771..63bfc4a96cdf 100644
--- a/source/Plugins/ABI/SysV-ppc/CMakeLists.txt
+++ b/source/Plugins/ABI/SysV-ppc/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginABISysV_ppc
+add_lldb_library(lldbPluginABISysV_ppc PLUGIN
ABISysV_ppc.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
index 4ffcba377345..59430caa6e37 100644
--- a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
+++ b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
@@ -16,10 +16,6 @@
#include "llvm/ADT/Triple.h"
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegisterValue.h"
@@ -33,6 +29,10 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/ABI/SysV-ppc64/CMakeLists.txt b/source/Plugins/ABI/SysV-ppc64/CMakeLists.txt
index 7a33d2922047..b31182dd0f78 100644
--- a/source/Plugins/ABI/SysV-ppc64/CMakeLists.txt
+++ b/source/Plugins/ABI/SysV-ppc64/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginABISysV_ppc64
+add_lldb_library(lldbPluginABISysV_ppc64 PLUGIN
ABISysV_ppc64.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
index 7e6506bb1f44..a899b24cea5c 100644
--- a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
+++ b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
@@ -16,10 +16,6 @@
#include "llvm/ADT/Triple.h"
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegisterValue.h"
@@ -33,6 +29,10 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/ABI/SysV-s390x/CMakeLists.txt b/source/Plugins/ABI/SysV-s390x/CMakeLists.txt
index c3992db023e6..f670f0157a6b 100644
--- a/source/Plugins/ABI/SysV-s390x/CMakeLists.txt
+++ b/source/Plugins/ABI/SysV-s390x/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginABISysV_s390x
+add_lldb_library(lldbPluginABISysV_s390x PLUGIN
ABISysV_s390x.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
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 2019db2bfd17..42bb9d057e61 100644
--- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
+++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
@@ -16,10 +16,6 @@
#include "llvm/ADT/Triple.h"
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegisterValue.h"
@@ -33,6 +29,10 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/ABI/SysV-x86_64/CMakeLists.txt b/source/Plugins/ABI/SysV-x86_64/CMakeLists.txt
index a2b62d7240fd..17644d74ac2f 100644
--- a/source/Plugins/ABI/SysV-x86_64/CMakeLists.txt
+++ b/source/Plugins/ABI/SysV-x86_64/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginABISysV_x86_64
+add_lldb_library(lldbPluginABISysV_x86_64 PLUGIN
ABISysV_x86_64.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/Disassembler/llvm/CMakeLists.txt b/source/Plugins/Disassembler/llvm/CMakeLists.txt
index ada81dc55e97..a25a436d498e 100644
--- a/source/Plugins/Disassembler/llvm/CMakeLists.txt
+++ b/source/Plugins/Disassembler/llvm/CMakeLists.txt
@@ -1,3 +1,14 @@
-add_lldb_library(lldbPluginDisassemblerLLVM
+add_lldb_library(lldbPluginDisassemblerLLVM PLUGIN
DisassemblerLLVMC.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ ${LLVM_TARGETS_TO_BUILD}
+ MC
+ MCDisassembler
+ RuntimeDyld
+ Support
)
diff --git a/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp b/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
index b7415b42c60e..e144ef18b413 100644
--- a/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
+++ b/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
@@ -31,10 +31,7 @@
#include "DisassemblerLLVMC.h"
#include "lldb/Core/Address.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
@@ -42,8 +39,11 @@
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
-#include "lldb/Core/RegularExpression.h"
+#include "lldb/Utility/RegularExpression.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/DynamicLoader/Darwin-Kernel/CMakeLists.txt b/source/Plugins/DynamicLoader/Darwin-Kernel/CMakeLists.txt
index 02752b78a4c7..ffc797b7475b 100644
--- a/source/Plugins/DynamicLoader/Darwin-Kernel/CMakeLists.txt
+++ b/source/Plugins/DynamicLoader/Darwin-Kernel/CMakeLists.txt
@@ -1,3 +1,13 @@
-add_lldb_library(lldbPluginDynamicLoaderDarwinKernel
+add_lldb_library(lldbPluginDynamicLoaderDarwinKernel PLUGIN
DynamicLoaderDarwinKernel.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbHost
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ lldbPluginPlatformMacOSX
)
diff --git a/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index b7010303bcaa..80f3f6857fd4 100644
--- a/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ b/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -12,10 +12,7 @@
#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
-#include "lldb/Core/DataBuffer.h"
-#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
@@ -25,11 +22,15 @@
#include "lldb/Host/Symbols.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/OperatingSystem.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanRunToAddress.h"
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Log.h"
#include "DynamicLoaderDarwinKernel.h"
@@ -1026,6 +1027,12 @@ void DynamicLoaderDarwinKernel::LoadKernelModuleIfNeeded() {
m_kernel.LoadImageAtFileAddress(m_process);
}
}
+
+ // The operating system plugin gets loaded and initialized in
+ // LoadImageUsingMemoryModule when we discover the kernel dSYM. For a
+ // core file in particular, that's the wrong place to do this, since
+ // we haven't fixed up the section addresses yet. So let's redo it here.
+ LoadOperatingSystemPlugin(false);
if (m_kernel.IsLoaded() && m_kernel.GetModule()) {
static ConstString kext_summary_symbol("gLoadedKextSummaries");
diff --git a/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h b/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
index 695a4eaf881a..7ca9bada1a1f 100644
--- a/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
+++ b/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
@@ -18,10 +18,10 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/UUID.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
class DynamicLoaderDarwinKernel : public lldb_private::DynamicLoader {
public:
diff --git a/source/Plugins/DynamicLoader/Hexagon-DYLD/CMakeLists.txt b/source/Plugins/DynamicLoader/Hexagon-DYLD/CMakeLists.txt
index af15f284118f..c590457d0a54 100644
--- a/source/Plugins/DynamicLoader/Hexagon-DYLD/CMakeLists.txt
+++ b/source/Plugins/DynamicLoader/Hexagon-DYLD/CMakeLists.txt
@@ -1,4 +1,10 @@
-add_lldb_library(lldbPluginDynamicLoaderHexagonDYLD
+add_lldb_library(lldbPluginDynamicLoaderHexagonDYLD PLUGIN
HexagonDYLDRendezvous.cpp
DynamicLoaderHexagonDYLD.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbSymbol
+ lldbTarget
)
diff --git a/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp b/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
index 3c64b2ffed3c..25bf6e9a7296 100644
--- a/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
+++ b/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
@@ -11,7 +11,6 @@
// C++ Includes
// Other libraries and framework includes
#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
@@ -21,6 +20,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanRunToAddress.h"
+#include "lldb/Utility/Log.h"
#include "DynamicLoaderHexagonDYLD.h"
diff --git a/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp b/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
index da0edc870f86..f22644aec107 100644
--- a/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
+++ b/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
@@ -11,13 +11,13 @@
// C++ Includes
// Other libraries and framework includes
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/Process.h"
diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt b/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt
index 7dc3e98e6a57..515c82dcaca9 100644
--- a/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt
+++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/CMakeLists.txt
@@ -1,5 +1,16 @@
-add_lldb_library(lldbPluginDynamicLoaderMacOSXDYLD
+add_lldb_library(lldbPluginDynamicLoaderMacOSXDYLD PLUGIN
DynamicLoaderMacOSXDYLD.cpp
DynamicLoaderMacOS.cpp
DynamicLoaderDarwin.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbExpression
+ lldbHost
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index bd0e772f7783..4ffd216e98a7 100644
--- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -10,10 +10,7 @@
#include "DynamicLoaderDarwin.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
-#include "lldb/Core/DataBuffer.h"
-#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
@@ -32,6 +29,9 @@
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanCallFunction.h"
#include "lldb/Target/ThreadPlanRunToAddress.h"
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Log.h"
//#define ENABLE_DEBUG_PRINTF // COMMENT THIS LINE OUT PRIOR TO CHECKIN
#ifdef ENABLE_DEBUG_PRINTF
@@ -542,6 +542,10 @@ void DynamicLoaderDarwin::UpdateSpecialBinariesFromNewImageInfos(
dyld_idx = i;
}
}
+ else {
+ // catch-all for any other environment -- trust that dyld is actually dyld
+ dyld_idx = i;
+ }
} else if (image_infos[i].header.filetype == llvm::MachO::MH_EXECUTE) {
exe_idx = i;
}
diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
index 2daa58de0cf6..fdfe45b663c1 100644
--- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
+++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
@@ -19,11 +19,11 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/StructuredData.h"
-#include "lldb/Core/UUID.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/SafeMachO.h"
+#include "lldb/Utility/UUID.h"
#include "llvm/ADT/Triple.h"
diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
index 7b027de783ed..20260ee5b5c3 100644
--- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
+++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp
@@ -9,7 +9,6 @@
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
@@ -21,6 +20,7 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/Log.h"
#include "DynamicLoaderDarwin.h"
#include "DynamicLoaderMacOS.h"
@@ -139,6 +139,7 @@ bool DynamicLoaderMacOS::DidSetNotificationBreakpoint() {
void DynamicLoaderMacOS::ClearNotificationBreakpoint() {
if (LLDB_BREAK_ID_IS_VALID(m_break_id)) {
m_process->GetTarget().RemoveBreakpointByID(m_break_id);
+ m_break_id = LLDB_INVALID_BREAK_ID;
}
}
@@ -151,6 +152,11 @@ void DynamicLoaderMacOS::ClearNotificationBreakpoint() {
void DynamicLoaderMacOS::DoInitialImageFetch() {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
+ // Remove any binaries we pre-loaded in the Target before launching/attaching.
+ // If the same binaries are present in the process, we'll get them from the
+ // shared module cache, we won't need to re-load them from disk.
+ UnloadAllImages();
+
StructuredData::ObjectSP all_image_info_json_sp(
m_process->GetLoadedDynamicLibrariesInfos());
ImageInfo::collection image_infos;
diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h
index 93273b13bb73..60c4beed383b 100644
--- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h
+++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h
@@ -26,11 +26,11 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/StructuredData.h"
-#include "lldb/Core/UUID.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/SafeMachO.h"
+#include "lldb/Utility/UUID.h"
#include "DynamicLoaderDarwin.h"
diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index 9c5f1bce3bd3..46742c1f9b5e 100644
--- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -8,10 +8,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/Breakpoint/StoppointCallbackContext.h"
-#include "lldb/Core/DataBuffer.h"
-#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
@@ -27,6 +24,9 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanRunToAddress.h"
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Log.h"
#include "DynamicLoaderDarwin.h"
#include "DynamicLoaderMacOSXDYLD.h"
diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
index 25ccf702e965..d5f1b51e508a 100644
--- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
+++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
@@ -29,11 +29,11 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/StructuredData.h"
-#include "lldb/Core/UUID.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/SafeMachO.h"
+#include "lldb/Utility/UUID.h"
#include "DynamicLoaderDarwin.h"
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp b/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp
index ec655c6f9b32..d385b78e0ec4 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp
@@ -14,10 +14,10 @@
// C++ Includes
// Other libraries and framework includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Log.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Log.h"
#if defined(__linux__) || defined(__FreeBSD__)
#include "Plugins/Process/elf-core/ProcessElfCore.h"
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/CMakeLists.txt b/source/Plugins/DynamicLoader/POSIX-DYLD/CMakeLists.txt
index b302997794a0..409ba92a0e19 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/CMakeLists.txt
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/CMakeLists.txt
@@ -1,5 +1,15 @@
-add_lldb_library(lldbPluginDynamicLoaderPosixDYLD
+add_lldb_library(lldbPluginDynamicLoaderPosixDYLD PLUGIN
AuxVector.cpp
DYLDRendezvous.cpp
DynamicLoaderPOSIXDYLD.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbHost
+ lldbSymbol
+ lldbTarget
+ lldbPluginProcessElfCore
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
index 136bf6561a21..c4917c08fa90 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -11,8 +11,6 @@
// C++ Includes
// Other libraries and framework includes
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Symbol.h"
@@ -20,6 +18,8 @@
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
#include "llvm/Support/Path.h"
@@ -379,12 +379,13 @@ bool DYLDRendezvous::RemoveSOEntries() {
}
bool DYLDRendezvous::SOEntryIsMainExecutable(const SOEntry &entry) {
- // On Linux the executable is indicated by an empty path in the entry. On
- // FreeBSD and on Android it is the full path to the executable.
+ // On some systes the executable is indicated by an empty path in the entry.
+ // On others it is the full path to the executable.
auto triple = m_process->GetTarget().GetArchitecture().GetTriple();
switch (triple.getOS()) {
case llvm::Triple::FreeBSD:
+ case llvm::Triple::NetBSD:
return entry.file_spec == m_exe_file_spec;
case llvm::Triple::Linux:
if (triple.isAndroid())
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
index 55b8bd7fb49e..295ae55e1b85 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
@@ -16,7 +16,7 @@
#include <string>
// Other libraries and framework includes
-#include "lldb/Host/FileSpec.h"
+#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 fc225eebe605..c809d2c77834 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -15,7 +15,6 @@
// Other libraries and framework includes
#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
@@ -27,6 +26,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanRunToAddress.h"
+#include "lldb/Utility/Log.h"
// C++ Includes
// C Includes
@@ -63,8 +63,9 @@ DynamicLoader *DynamicLoaderPOSIXDYLD::CreateInstance(Process *process,
if (!create) {
const llvm::Triple &triple_ref =
process->GetTarget().GetArchitecture().GetTriple();
- if (triple_ref.getOS() == llvm::Triple::Linux ||
- triple_ref.getOS() == llvm::Triple::FreeBSD)
+ if (triple_ref.getOS() == llvm::Triple::FreeBSD ||
+ triple_ref.getOS() == llvm::Triple::Linux ||
+ triple_ref.getOS() == llvm::Triple::NetBSD)
create = true;
}
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
index 1e8333fb099a..8e4be1d4a06a 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
@@ -12,6 +12,9 @@
// C Includes
// C++ Includes
+#include <map>
+#include <memory>
+
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/StoppointCallbackContext.h"
diff --git a/source/Plugins/DynamicLoader/Static/CMakeLists.txt b/source/Plugins/DynamicLoader/Static/CMakeLists.txt
index 274f6bac3697..be54a3053470 100644
--- a/source/Plugins/DynamicLoader/Static/CMakeLists.txt
+++ b/source/Plugins/DynamicLoader/Static/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginDynamicLoaderStatic
+add_lldb_library(lldbPluginDynamicLoaderStatic PLUGIN
DynamicLoaderStatic.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbSymbol
+ lldbTarget
+ lldbUtility
)
diff --git a/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h b/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h
index c6122edf50cf..413ad80a2fd9 100644
--- a/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h
+++ b/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h
@@ -14,10 +14,10 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/UUID.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
class DynamicLoaderStatic : public lldb_private::DynamicLoader {
public:
diff --git a/source/Plugins/DynamicLoader/Windows-DYLD/CMakeLists.txt b/source/Plugins/DynamicLoader/Windows-DYLD/CMakeLists.txt
index ee768057bcd5..7557ada51466 100644
--- a/source/Plugins/DynamicLoader/Windows-DYLD/CMakeLists.txt
+++ b/source/Plugins/DynamicLoader/Windows-DYLD/CMakeLists.txt
@@ -1,3 +1,9 @@
-add_lldb_library(lldbPluginDynamicLoaderWindowsDYLD
+add_lldb_library(lldbPluginDynamicLoaderWindowsDYLD PLUGIN
DynamicLoaderWindowsDYLD.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp b/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp
index c74f1474e7be..0d619e4174e0 100644
--- a/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp
@@ -9,10 +9,10 @@
#include "ASTDumper.h"
-#include "lldb/Core/Log.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Utility/Log.h"
#include "llvm/Support/raw_ostream.h"
diff --git a/source/Plugins/ExpressionParser/Clang/ASTDumper.h b/source/Plugins/ExpressionParser/Clang/ASTDumper.h
index 9a72fb64e537..58ba19739e5b 100644
--- a/source/Plugins/ExpressionParser/Clang/ASTDumper.h
+++ b/source/Plugins/ExpressionParser/Clang/ASTDumper.h
@@ -13,7 +13,7 @@
#include "clang/AST/DeclVisitor.h"
#include "clang/AST/TypeVisitor.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/Stream.h"
#include "llvm/ADT/DenseSet.h"
namespace lldb_private {
diff --git a/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp b/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
index f60587ed2fff..9e6a2f3acafe 100644
--- a/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -11,11 +11,11 @@
#include "ClangPersistentVariables.h"
-#include "lldb/Core/Log.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ClangASTImporter.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
#include "stdlib.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
diff --git a/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp b/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp
index 7bb784e8f9ad..2faeecdf724e 100644
--- a/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp
@@ -9,7 +9,7 @@
#include "ASTStructExtractor.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Utility/Log.h"
#include "stdlib.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
diff --git a/source/Plugins/ExpressionParser/Clang/CMakeLists.txt b/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
index 64559d20bb4e..a780e7d597b1 100644
--- a/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
+++ b/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
@@ -2,7 +2,7 @@ if(NOT LLDB_BUILT_STANDALONE)
set(tablegen_deps intrinsics_gen)
endif()
-add_lldb_library(lldbPluginExpressionParserClang
+add_lldb_library(lldbPluginExpressionParserClang PLUGIN
ASTDumper.cpp
ASTResultSynthesizer.cpp
ASTStructExtractor.cpp
@@ -19,4 +19,30 @@ add_lldb_library(lldbPluginExpressionParserClang
DEPENDS
${tablegen_deps}
+
+ LINK_LIBS
+ clangAST
+ clangCodeGen
+ clangEdit
+ clangFrontend
+ clangLex
+ clangParse
+ clangRewrite
+ clangRewriteFrontend
+ clangSema
+ clangSerialization
+ lldbCore
+ lldbExpression
+ lldbHost
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ lldbPluginCPlusPlusLanguage
+ LINK_COMPONENTS
+ Core
+ ExecutionEngine
+ ipo
+ MCJIT
+ Support
)
diff --git a/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index 0f08dd330e90..3c3a2cd9c3fc 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -12,7 +12,6 @@
#include "ASTDumper.h"
#include "ClangModulesDeclVendor.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Symbol/ClangASTContext.h"
@@ -24,6 +23,7 @@
#include "lldb/Symbol/TaggedASTType.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/RecordLayout.h"
@@ -139,6 +139,7 @@ bool ClangASTSource::FindExternalVisibleDeclsByName(
case DeclarationName::CXXConstructorName:
case DeclarationName::CXXDestructorName:
case DeclarationName::CXXConversionFunctionName:
+ case DeclarationName::CXXDeductionGuideName:
SetNoExternalVisibleDeclsForName(decl_ctx, clang_decl_name);
return false;
}
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index c1470c5aeb28..70c77e9cde33 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -15,15 +15,12 @@
#include "ClangPersistentVariables.h"
#include "lldb/Core/Address.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.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"
-#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/CompilerDecl.h"
@@ -45,6 +42,9 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
#include "lldb/lldb-private.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index a75e60ff63c1..6c923ced1ec2 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -35,7 +35,6 @@
#include "clang/Rewrite/Core/Rewriter.h"
#include "clang/Rewrite/Frontend/FrontendActions.h"
#include "clang/Sema/SemaConsumer.h"
-#include "clang/StaticAnalyzer/Frontend/FrontendActions.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
@@ -68,15 +67,10 @@
#include "IRForTarget.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Disassembler.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Expression/IRDynamicChecks.h"
#include "lldb/Expression/IRExecutionUnit.h"
#include "lldb/Expression/IRInterpreter.h"
@@ -90,7 +84,12 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadPlanCallFunction.h"
+#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/StringList.h"
using namespace clang;
using namespace llvm;
@@ -340,16 +339,16 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope,
lang_rt->GetOverrideExprOptions(m_compiler->getTargetOpts());
if (overridden_target_opts)
- if (log) {
- log->Debug(
- "Using overridden target options for the expression evaluation");
+ if (log && log->GetVerbose()) {
+ LLDB_LOGV(
+ log, "Using overridden target options for the expression evaluation");
auto opts = m_compiler->getTargetOpts();
- log->Debug("Triple: '%s'", opts.Triple.c_str());
- log->Debug("CPU: '%s'", opts.CPU.c_str());
- log->Debug("FPMath: '%s'", opts.FPMath.c_str());
- log->Debug("ABI: '%s'", opts.ABI.c_str());
- log->Debug("LinkerVersion: '%s'", opts.LinkerVersion.c_str());
+ LLDB_LOGV(log, "Triple: '{0}'", opts.Triple);
+ LLDB_LOGV(log, "CPU: '{0}'", opts.CPU);
+ LLDB_LOGV(log, "FPMath: '{0}'", opts.FPMath);
+ LLDB_LOGV(log, "ABI: '{0}'", opts.ABI);
+ LLDB_LOGV(log, "LinkerVersion: '{0}'", opts.LinkerVersion);
StringList::LogDump(log, opts.FeaturesAsWritten, "FeaturesAsWritten");
StringList::LogDump(log, opts.Features, "Features");
StringList::LogDump(log, opts.Reciprocals, "Reciprocals");
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
index 3f01156c6ded..f0203f36e59b 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
@@ -12,9 +12,9 @@
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/ClangForward.h"
-#include "lldb/Core/Error.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/ExpressionParser.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-public.h"
#include <string>
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp b/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
index 44594ccebfa3..624cbf2a1a4f 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
@@ -9,13 +9,13 @@
#include "ClangExpressionVariable.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Stream.h"
#include "clang/AST/ASTContext.h"
using namespace lldb_private;
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h b/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
index c894506a227b..baa80d7ba0d4 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
@@ -25,10 +25,10 @@
// Project includes
#include "lldb/Core/ClangForward.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/Value.h"
#include "lldb/Expression/ExpressionVariable.h"
#include "lldb/Symbol/TaggedASTType.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-public.h"
namespace llvm {
diff --git a/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp b/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
index 8151993717de..a26ceda82d5f 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
@@ -26,8 +26,6 @@
#include "llvm/IR/Module.h"
// Project includes
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/State.h"
#include "lldb/Core/ValueObject.h"
@@ -44,6 +42,8 @@
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/ThreadPlanCallFunction.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Log.h"
using namespace lldb_private;
diff --git a/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index 64b303c4f735..696bdf7e030d 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -20,19 +20,21 @@
#include "clang/Parse/Parser.h"
#include "clang/Sema/Lookup.h"
#include "clang/Serialization/ASTReader.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
+#include "llvm/Support/Threading.h"
// Project includes
#include "ClangModulesDeclVendor.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb_private;
@@ -143,9 +145,9 @@ void StoringDiagnosticConsumer::DumpDiagnostics(Stream &error_stream) {
static FileSpec GetResourceDir() {
static FileSpec g_cached_resource_dir;
- static std::once_flag g_once_flag;
+ static llvm::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
+ llvm::call_once(g_once_flag, []() {
HostInfo::GetLLDBPath(lldb::ePathTypeClangDir, g_cached_resource_dir);
});
@@ -605,7 +607,7 @@ ClangModulesDeclVendor::Create(Target &target) {
{
FileSpec clang_resource_dir = GetResourceDir();
- if (clang_resource_dir.IsDirectory()) {
+ if (llvm::sys::fs::is_directory(clang_resource_dir.GetPath())) {
compiler_invocation_arguments.push_back("-resource-dir");
compiler_invocation_arguments.push_back(clang_resource_dir.GetPath());
}
diff --git a/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp b/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
index 4d30956177da..8ebf78409a03 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
@@ -9,10 +9,10 @@
#include "ClangPersistentVariables.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Value.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
#include "clang/AST/Decl.h"
diff --git a/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
index 5abad71b84a7..95d81db12801 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -25,12 +25,9 @@
#include "ClangModulesDeclVendor.h"
#include "ClangPersistentVariables.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Expression/ExpressionSourceCode.h"
#include "lldb/Expression/IRExecutionUnit.h"
@@ -51,6 +48,9 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/ThreadPlanCallUserExpression.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
@@ -609,7 +609,7 @@ bool ClangUserExpression::AddArguments(ExecutionContext &exe_ctx,
if (!object_ptr_error.Success()) {
exe_ctx.GetTargetRef().GetDebugger().GetAsyncOutputStream()->Printf(
- "warning: `%s' is not accessible (subsituting 0)\n",
+ "warning: `%s' is not accessible (substituting 0)\n",
object_name.AsCString());
object_ptr = 0;
}
diff --git a/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp b/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
index 73d37516ff77..a54ab4a2267a 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
@@ -19,16 +19,16 @@
// C++ Includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Expression/ExpressionSourceCode.h"
#include "lldb/Expression/IRExecutionUnit.h"
#include "lldb/Host/Host.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb_private;
diff --git a/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index 356e2e7eba24..68a214ee4683 100644
--- a/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -25,18 +25,18 @@
#include "clang/AST/ASTContext.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Scalar.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/dwarf.h"
#include "lldb/Expression/IRExecutionUnit.h"
#include "lldb/Expression/IRInterpreter.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
#include <map>
@@ -512,11 +512,9 @@ bool IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str,
break;
default:
encoding_flags = 0x0600; /* fall back to 0x0600, kCFStringEncodingASCII */
- if (log) {
- log->Format("Encountered an Objective-C constant string with unusual "
+ LLDB_LOG(log, "Encountered an Objective-C constant string with unusual "
"element size {0}",
- string_array->getElementByteSize());
- }
+ string_array->getElementByteSize());
}
Constant *encoding_arg = ConstantInt::get(i32_ty, encoding_flags, false);
Constant *isExternal_arg =
@@ -1855,9 +1853,9 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) {
if (!m_decl_map->GetStructInfo(num_elements, size, alignment))
return false;
- Function::arg_iterator iter(llvm_function.getArgumentList().begin());
+ Function::arg_iterator iter(llvm_function.arg_begin());
- if (iter == llvm_function.getArgumentList().end()) {
+ if (iter == llvm_function.arg_end()) {
m_error_stream.Printf("Internal error [IRForTarget]: Wrapper takes no "
"arguments (should take at least a struct pointer)");
@@ -1869,7 +1867,7 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) {
if (argument->getName().equals("this")) {
++iter;
- if (iter == llvm_function.getArgumentList().end()) {
+ if (iter == llvm_function.arg_end()) {
m_error_stream.Printf("Internal error [IRForTarget]: Wrapper takes only "
"'this' argument (should take a struct pointer "
"too)");
@@ -1881,7 +1879,7 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) {
} else if (argument->getName().equals("self")) {
++iter;
- if (iter == llvm_function.getArgumentList().end()) {
+ if (iter == llvm_function.arg_end()) {
m_error_stream.Printf("Internal error [IRForTarget]: Wrapper takes only "
"'self' argument (should take '_cmd' and a struct "
"pointer too)");
@@ -1899,7 +1897,7 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) {
++iter;
- if (iter == llvm_function.getArgumentList().end()) {
+ if (iter == llvm_function.arg_end()) {
m_error_stream.Printf("Internal error [IRForTarget]: Wrapper takes only "
"'self' and '_cmd' arguments (should take a struct "
"pointer too)");
diff --git a/source/Plugins/ExpressionParser/Clang/IRForTarget.h b/source/Plugins/ExpressionParser/Clang/IRForTarget.h
index 20b1d1a13226..eb52730f3a87 100644
--- a/source/Plugins/ExpressionParser/Clang/IRForTarget.h
+++ b/source/Plugins/ExpressionParser/Clang/IRForTarget.h
@@ -11,11 +11,11 @@
#ifndef liblldb_IRForTarget_h_
#define liblldb_IRForTarget_h_
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Symbol/TaggedASTType.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StreamString.h"
#include "lldb/lldb-public.h"
#include "llvm/Pass.h"
diff --git a/source/Plugins/ExpressionParser/Go/CMakeLists.txt b/source/Plugins/ExpressionParser/Go/CMakeLists.txt
index f59f51e76489..3d552aafa0d7 100644
--- a/source/Plugins/ExpressionParser/Go/CMakeLists.txt
+++ b/source/Plugins/ExpressionParser/Go/CMakeLists.txt
@@ -1,5 +1,13 @@
-add_lldb_library(lldbPluginExpressionParserGo
+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/GoParser.cpp b/source/Plugins/ExpressionParser/Go/GoParser.cpp
index 327b9df43db3..0bae4a4574d9 100644
--- a/source/Plugins/ExpressionParser/Go/GoParser.cpp
+++ b/source/Plugins/ExpressionParser/Go/GoParser.cpp
@@ -12,7 +12,7 @@
#include "GoParser.h"
#include "Plugins/ExpressionParser/Go/GoAST.h"
-#include "lldb/Core/Error.h"
+#include "lldb/Utility/Error.h"
#include "llvm/ADT/SmallString.h"
using namespace lldb_private;
diff --git a/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp b/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
index a448da683e36..50d45a1ad1e7 100644
--- a/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
+++ b/source/Plugins/ExpressionParser/Go/GoUserExpression.cpp
@@ -26,14 +26,8 @@
// Project includes
#include "GoUserExpression.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataEncoder.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectRegister.h"
#include "lldb/Expression/DiagnosticManager.h"
@@ -49,6 +43,12 @@
#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"
diff --git a/source/Plugins/Instruction/ARM/CMakeLists.txt b/source/Plugins/Instruction/ARM/CMakeLists.txt
index dc547a57306b..24f803db3d0e 100644
--- a/source/Plugins/Instruction/ARM/CMakeLists.txt
+++ b/source/Plugins/Instruction/ARM/CMakeLists.txt
@@ -1,4 +1,14 @@
-add_lldb_library(lldbPluginInstructionARM
+add_lldb_library(lldbPluginInstructionARM PLUGIN
EmulateInstructionARM.cpp
EmulationStateARM.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbPluginProcessUtility
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
index 99caca99074b..d0ef688f0773 100644
--- a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -13,13 +13,13 @@
#include "EmulationStateARM.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Host/PosixApi.h"
#include "lldb/Interpreter/OptionValueArray.h"
#include "lldb/Interpreter/OptionValueDictionary.h"
#include "lldb/Symbol/UnwindPlan.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Stream.h"
#include "Plugins/Process/Utility/ARMDefines.h"
#include "Plugins/Process/Utility/ARMUtils.h"
@@ -44,6 +44,563 @@ using namespace lldb_private;
//
//----------------------------------------------------------------------
+static bool GetARMDWARFRegisterInfo(unsigned reg_num, RegisterInfo &reg_info) {
+ ::memset(&reg_info, 0, sizeof(RegisterInfo));
+ ::memset(reg_info.kinds, LLDB_INVALID_REGNUM, sizeof(reg_info.kinds));
+
+ if (reg_num >= dwarf_q0 && reg_num <= dwarf_q15) {
+ reg_info.byte_size = 16;
+ reg_info.format = eFormatVectorOfUInt8;
+ reg_info.encoding = eEncodingVector;
+ }
+
+ if (reg_num >= dwarf_d0 && reg_num <= dwarf_d31) {
+ reg_info.byte_size = 8;
+ reg_info.format = eFormatFloat;
+ reg_info.encoding = eEncodingIEEE754;
+ } else if (reg_num >= dwarf_s0 && reg_num <= dwarf_s31) {
+ reg_info.byte_size = 4;
+ reg_info.format = eFormatFloat;
+ reg_info.encoding = eEncodingIEEE754;
+ } else if (reg_num >= dwarf_f0 && reg_num <= dwarf_f7) {
+ reg_info.byte_size = 12;
+ reg_info.format = eFormatFloat;
+ reg_info.encoding = eEncodingIEEE754;
+ } else {
+ reg_info.byte_size = 4;
+ reg_info.format = eFormatHex;
+ reg_info.encoding = eEncodingUint;
+ }
+
+ reg_info.kinds[eRegisterKindDWARF] = reg_num;
+
+ switch (reg_num) {
+ case dwarf_r0:
+ reg_info.name = "r0";
+ break;
+ case dwarf_r1:
+ reg_info.name = "r1";
+ break;
+ case dwarf_r2:
+ reg_info.name = "r2";
+ break;
+ case dwarf_r3:
+ reg_info.name = "r3";
+ break;
+ case dwarf_r4:
+ reg_info.name = "r4";
+ break;
+ case dwarf_r5:
+ reg_info.name = "r5";
+ break;
+ case dwarf_r6:
+ reg_info.name = "r6";
+ break;
+ case dwarf_r7:
+ reg_info.name = "r7";
+ reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FP;
+ break;
+ case dwarf_r8:
+ reg_info.name = "r8";
+ break;
+ case dwarf_r9:
+ reg_info.name = "r9";
+ break;
+ case dwarf_r10:
+ reg_info.name = "r10";
+ break;
+ case dwarf_r11:
+ reg_info.name = "r11";
+ break;
+ case dwarf_r12:
+ reg_info.name = "r12";
+ break;
+ case dwarf_sp:
+ reg_info.name = "sp";
+ reg_info.alt_name = "r13";
+ reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_SP;
+ break;
+ case dwarf_lr:
+ reg_info.name = "lr";
+ reg_info.alt_name = "r14";
+ reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_RA;
+ break;
+ case dwarf_pc:
+ reg_info.name = "pc";
+ reg_info.alt_name = "r15";
+ reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC;
+ break;
+ case dwarf_cpsr:
+ reg_info.name = "cpsr";
+ reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS;
+ break;
+
+ case dwarf_s0:
+ reg_info.name = "s0";
+ break;
+ case dwarf_s1:
+ reg_info.name = "s1";
+ break;
+ case dwarf_s2:
+ reg_info.name = "s2";
+ break;
+ case dwarf_s3:
+ reg_info.name = "s3";
+ break;
+ case dwarf_s4:
+ reg_info.name = "s4";
+ break;
+ case dwarf_s5:
+ reg_info.name = "s5";
+ break;
+ case dwarf_s6:
+ reg_info.name = "s6";
+ break;
+ case dwarf_s7:
+ reg_info.name = "s7";
+ break;
+ case dwarf_s8:
+ reg_info.name = "s8";
+ break;
+ case dwarf_s9:
+ reg_info.name = "s9";
+ break;
+ case dwarf_s10:
+ reg_info.name = "s10";
+ break;
+ case dwarf_s11:
+ reg_info.name = "s11";
+ break;
+ case dwarf_s12:
+ reg_info.name = "s12";
+ break;
+ case dwarf_s13:
+ reg_info.name = "s13";
+ break;
+ case dwarf_s14:
+ reg_info.name = "s14";
+ break;
+ case dwarf_s15:
+ reg_info.name = "s15";
+ break;
+ case dwarf_s16:
+ reg_info.name = "s16";
+ break;
+ case dwarf_s17:
+ reg_info.name = "s17";
+ break;
+ case dwarf_s18:
+ reg_info.name = "s18";
+ break;
+ case dwarf_s19:
+ reg_info.name = "s19";
+ break;
+ case dwarf_s20:
+ reg_info.name = "s20";
+ break;
+ case dwarf_s21:
+ reg_info.name = "s21";
+ break;
+ case dwarf_s22:
+ reg_info.name = "s22";
+ break;
+ case dwarf_s23:
+ reg_info.name = "s23";
+ break;
+ case dwarf_s24:
+ reg_info.name = "s24";
+ break;
+ case dwarf_s25:
+ reg_info.name = "s25";
+ break;
+ case dwarf_s26:
+ reg_info.name = "s26";
+ break;
+ case dwarf_s27:
+ reg_info.name = "s27";
+ break;
+ case dwarf_s28:
+ reg_info.name = "s28";
+ break;
+ case dwarf_s29:
+ reg_info.name = "s29";
+ break;
+ case dwarf_s30:
+ reg_info.name = "s30";
+ break;
+ case dwarf_s31:
+ reg_info.name = "s31";
+ break;
+
+ // FPA Registers 0-7
+ case dwarf_f0:
+ reg_info.name = "f0";
+ break;
+ case dwarf_f1:
+ reg_info.name = "f1";
+ break;
+ case dwarf_f2:
+ reg_info.name = "f2";
+ break;
+ case dwarf_f3:
+ reg_info.name = "f3";
+ break;
+ case dwarf_f4:
+ reg_info.name = "f4";
+ break;
+ case dwarf_f5:
+ reg_info.name = "f5";
+ break;
+ case dwarf_f6:
+ reg_info.name = "f6";
+ break;
+ case dwarf_f7:
+ reg_info.name = "f7";
+ break;
+
+ // Intel wireless MMX general purpose registers 0 - 7
+ // XScale accumulator register 0 - 7 (they do overlap with wCGR0 - wCGR7)
+ case dwarf_wCGR0:
+ reg_info.name = "wCGR0/ACC0";
+ break;
+ case dwarf_wCGR1:
+ reg_info.name = "wCGR1/ACC1";
+ break;
+ case dwarf_wCGR2:
+ reg_info.name = "wCGR2/ACC2";
+ break;
+ case dwarf_wCGR3:
+ reg_info.name = "wCGR3/ACC3";
+ break;
+ case dwarf_wCGR4:
+ reg_info.name = "wCGR4/ACC4";
+ break;
+ case dwarf_wCGR5:
+ reg_info.name = "wCGR5/ACC5";
+ break;
+ case dwarf_wCGR6:
+ reg_info.name = "wCGR6/ACC6";
+ break;
+ case dwarf_wCGR7:
+ reg_info.name = "wCGR7/ACC7";
+ break;
+
+ // Intel wireless MMX data registers 0 - 15
+ case dwarf_wR0:
+ reg_info.name = "wR0";
+ break;
+ case dwarf_wR1:
+ reg_info.name = "wR1";
+ break;
+ case dwarf_wR2:
+ reg_info.name = "wR2";
+ break;
+ case dwarf_wR3:
+ reg_info.name = "wR3";
+ break;
+ case dwarf_wR4:
+ reg_info.name = "wR4";
+ break;
+ case dwarf_wR5:
+ reg_info.name = "wR5";
+ break;
+ case dwarf_wR6:
+ reg_info.name = "wR6";
+ break;
+ case dwarf_wR7:
+ reg_info.name = "wR7";
+ break;
+ case dwarf_wR8:
+ reg_info.name = "wR8";
+ break;
+ case dwarf_wR9:
+ reg_info.name = "wR9";
+ break;
+ case dwarf_wR10:
+ reg_info.name = "wR10";
+ break;
+ case dwarf_wR11:
+ reg_info.name = "wR11";
+ break;
+ case dwarf_wR12:
+ reg_info.name = "wR12";
+ break;
+ case dwarf_wR13:
+ reg_info.name = "wR13";
+ break;
+ case dwarf_wR14:
+ reg_info.name = "wR14";
+ break;
+ case dwarf_wR15:
+ reg_info.name = "wR15";
+ break;
+
+ case dwarf_spsr:
+ reg_info.name = "spsr";
+ break;
+ case dwarf_spsr_fiq:
+ reg_info.name = "spsr_fiq";
+ break;
+ case dwarf_spsr_irq:
+ reg_info.name = "spsr_irq";
+ break;
+ case dwarf_spsr_abt:
+ reg_info.name = "spsr_abt";
+ break;
+ case dwarf_spsr_und:
+ reg_info.name = "spsr_und";
+ break;
+ case dwarf_spsr_svc:
+ reg_info.name = "spsr_svc";
+ break;
+
+ case dwarf_r8_usr:
+ reg_info.name = "r8_usr";
+ break;
+ case dwarf_r9_usr:
+ reg_info.name = "r9_usr";
+ break;
+ case dwarf_r10_usr:
+ reg_info.name = "r10_usr";
+ break;
+ case dwarf_r11_usr:
+ reg_info.name = "r11_usr";
+ break;
+ case dwarf_r12_usr:
+ reg_info.name = "r12_usr";
+ break;
+ case dwarf_r13_usr:
+ reg_info.name = "r13_usr";
+ break;
+ case dwarf_r14_usr:
+ reg_info.name = "r14_usr";
+ break;
+ case dwarf_r8_fiq:
+ reg_info.name = "r8_fiq";
+ break;
+ case dwarf_r9_fiq:
+ reg_info.name = "r9_fiq";
+ break;
+ case dwarf_r10_fiq:
+ reg_info.name = "r10_fiq";
+ break;
+ case dwarf_r11_fiq:
+ reg_info.name = "r11_fiq";
+ break;
+ case dwarf_r12_fiq:
+ reg_info.name = "r12_fiq";
+ break;
+ case dwarf_r13_fiq:
+ reg_info.name = "r13_fiq";
+ break;
+ case dwarf_r14_fiq:
+ reg_info.name = "r14_fiq";
+ break;
+ case dwarf_r13_irq:
+ reg_info.name = "r13_irq";
+ break;
+ case dwarf_r14_irq:
+ reg_info.name = "r14_irq";
+ break;
+ case dwarf_r13_abt:
+ reg_info.name = "r13_abt";
+ break;
+ case dwarf_r14_abt:
+ reg_info.name = "r14_abt";
+ break;
+ case dwarf_r13_und:
+ reg_info.name = "r13_und";
+ break;
+ case dwarf_r14_und:
+ reg_info.name = "r14_und";
+ break;
+ case dwarf_r13_svc:
+ reg_info.name = "r13_svc";
+ break;
+ case dwarf_r14_svc:
+ reg_info.name = "r14_svc";
+ break;
+
+ // Intel wireless MMX control register in co-processor 0 - 7
+ case dwarf_wC0:
+ reg_info.name = "wC0";
+ break;
+ case dwarf_wC1:
+ reg_info.name = "wC1";
+ break;
+ case dwarf_wC2:
+ reg_info.name = "wC2";
+ break;
+ case dwarf_wC3:
+ reg_info.name = "wC3";
+ break;
+ case dwarf_wC4:
+ reg_info.name = "wC4";
+ break;
+ case dwarf_wC5:
+ reg_info.name = "wC5";
+ break;
+ case dwarf_wC6:
+ reg_info.name = "wC6";
+ break;
+ case dwarf_wC7:
+ reg_info.name = "wC7";
+ break;
+
+ // VFP-v3/Neon
+ case dwarf_d0:
+ reg_info.name = "d0";
+ break;
+ case dwarf_d1:
+ reg_info.name = "d1";
+ break;
+ case dwarf_d2:
+ reg_info.name = "d2";
+ break;
+ case dwarf_d3:
+ reg_info.name = "d3";
+ break;
+ case dwarf_d4:
+ reg_info.name = "d4";
+ break;
+ case dwarf_d5:
+ reg_info.name = "d5";
+ break;
+ case dwarf_d6:
+ reg_info.name = "d6";
+ break;
+ case dwarf_d7:
+ reg_info.name = "d7";
+ break;
+ case dwarf_d8:
+ reg_info.name = "d8";
+ break;
+ case dwarf_d9:
+ reg_info.name = "d9";
+ break;
+ case dwarf_d10:
+ reg_info.name = "d10";
+ break;
+ case dwarf_d11:
+ reg_info.name = "d11";
+ break;
+ case dwarf_d12:
+ reg_info.name = "d12";
+ break;
+ case dwarf_d13:
+ reg_info.name = "d13";
+ break;
+ case dwarf_d14:
+ reg_info.name = "d14";
+ break;
+ case dwarf_d15:
+ reg_info.name = "d15";
+ break;
+ case dwarf_d16:
+ reg_info.name = "d16";
+ break;
+ case dwarf_d17:
+ reg_info.name = "d17";
+ break;
+ case dwarf_d18:
+ reg_info.name = "d18";
+ break;
+ case dwarf_d19:
+ reg_info.name = "d19";
+ break;
+ case dwarf_d20:
+ reg_info.name = "d20";
+ break;
+ case dwarf_d21:
+ reg_info.name = "d21";
+ break;
+ case dwarf_d22:
+ reg_info.name = "d22";
+ break;
+ case dwarf_d23:
+ reg_info.name = "d23";
+ break;
+ case dwarf_d24:
+ reg_info.name = "d24";
+ break;
+ case dwarf_d25:
+ reg_info.name = "d25";
+ break;
+ case dwarf_d26:
+ reg_info.name = "d26";
+ break;
+ case dwarf_d27:
+ reg_info.name = "d27";
+ break;
+ case dwarf_d28:
+ reg_info.name = "d28";
+ break;
+ case dwarf_d29:
+ reg_info.name = "d29";
+ break;
+ case dwarf_d30:
+ reg_info.name = "d30";
+ break;
+ case dwarf_d31:
+ reg_info.name = "d31";
+ break;
+
+ // NEON 128-bit vector registers (overlays the d registers)
+ case dwarf_q0:
+ reg_info.name = "q0";
+ break;
+ case dwarf_q1:
+ reg_info.name = "q1";
+ break;
+ case dwarf_q2:
+ reg_info.name = "q2";
+ break;
+ case dwarf_q3:
+ reg_info.name = "q3";
+ break;
+ case dwarf_q4:
+ reg_info.name = "q4";
+ break;
+ case dwarf_q5:
+ reg_info.name = "q5";
+ break;
+ case dwarf_q6:
+ reg_info.name = "q6";
+ break;
+ case dwarf_q7:
+ reg_info.name = "q7";
+ break;
+ case dwarf_q8:
+ reg_info.name = "q8";
+ break;
+ case dwarf_q9:
+ reg_info.name = "q9";
+ break;
+ case dwarf_q10:
+ reg_info.name = "q10";
+ break;
+ case dwarf_q11:
+ reg_info.name = "q11";
+ break;
+ case dwarf_q12:
+ reg_info.name = "q12";
+ break;
+ case dwarf_q13:
+ reg_info.name = "q13";
+ break;
+ case dwarf_q14:
+ reg_info.name = "q14";
+ break;
+ case dwarf_q15:
+ reg_info.name = "q15";
+ break;
+
+ default:
+ return false;
+ }
+ return true;
+}
+
// A8.6.50
// Valid return values are {1, 2, 3, 4}, with 0 signifying an error condition.
static uint32_t CountITSize(uint32_t ITMask) {
diff --git a/source/Plugins/Instruction/ARM/EmulateInstructionARM.h b/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
index 1bfc4cb398fb..40a31169ecd8 100644
--- a/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
+++ b/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
@@ -11,9 +11,9 @@
#define lldb_EmulateInstructionARM_h_
#include "Plugins/Process/Utility/ARMDefines.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/EmulateInstruction.h"
-#include "lldb/Core/Error.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
namespace lldb_private {
diff --git a/source/Plugins/Instruction/ARM/EmulationStateARM.cpp b/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
index 9ceeb76c6f5e..5e90965c1881 100644
--- a/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
+++ b/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
@@ -66,7 +66,7 @@ bool EmulationStateARM::LoadPseudoRegistersFromFrame(StackFrame &frame) {
bool EmulationStateARM::StorePseudoRegisterValue(uint32_t reg_num,
uint64_t value) {
- if ((dwarf_r0 <= reg_num) && (reg_num <= dwarf_cpsr))
+ if (reg_num <= dwarf_cpsr)
m_gpr[reg_num - dwarf_r0] = (uint32_t)value;
else if ((dwarf_s0 <= reg_num) && (reg_num <= dwarf_s31)) {
uint32_t idx = reg_num - dwarf_s0;
@@ -89,7 +89,7 @@ uint64_t EmulationStateARM::ReadPseudoRegisterValue(uint32_t reg_num,
uint64_t value = 0;
success = true;
- if ((dwarf_r0 <= reg_num) && (reg_num <= dwarf_cpsr))
+ if (reg_num <= dwarf_cpsr)
value = m_gpr[reg_num - dwarf_r0];
else if ((dwarf_s0 <= reg_num) && (reg_num <= dwarf_s31)) {
uint32_t idx = reg_num - dwarf_s0;
@@ -192,15 +192,18 @@ size_t EmulationStateARM::WritePseudoMemory(
EmulationStateARM *pseudo_state = (EmulationStateARM *)baton;
if (length <= 4) {
- uint32_t value = *((const uint32_t *)dst);
+ uint32_t value;
+ memcpy (&value, dst, sizeof (uint32_t));
if (endian::InlHostByteOrder() == lldb::eByteOrderBig)
value = llvm::ByteSwap_32(value);
pseudo_state->StoreToPseudoAddress(addr, value);
return length;
} else if (length == 8) {
- uint32_t value1 = ((const uint32_t *)dst)[0];
- uint32_t value2 = ((const uint32_t *)dst)[1];
+ uint32_t value1;
+ uint32_t value2;
+ memcpy (&value1, dst, sizeof (uint32_t));
+ memcpy (&value2, (uint8_t *) dst + sizeof (uint32_t), sizeof (uint32_t));
if (endian::InlHostByteOrder() == lldb::eByteOrderBig) {
value1 = llvm::ByteSwap_32(value1);
value2 = llvm::ByteSwap_32(value2);
diff --git a/source/Plugins/Instruction/ARM64/CMakeLists.txt b/source/Plugins/Instruction/ARM64/CMakeLists.txt
index 9f8ee0848984..effe0e3bfe66 100644
--- a/source/Plugins/Instruction/ARM64/CMakeLists.txt
+++ b/source/Plugins/Instruction/ARM64/CMakeLists.txt
@@ -1,3 +1,11 @@
-add_lldb_library(lldbPluginInstructionARM64
+add_lldb_library(lldbPluginInstructionARM64 PLUGIN
EmulateInstructionARM64.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbInterpreter
+ lldbSymbol
+ lldbPluginProcessUtility
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp b/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
index 43f23097c0d9..655fada3a4b3 100644
--- a/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
+++ b/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
@@ -13,10 +13,11 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Core/RegisterValue.h"
#include "lldb/Symbol/UnwindPlan.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Stream.h"
#include "Plugins/Process/Utility/ARMDefines.h"
#include "Plugins/Process/Utility/ARMUtils.h"
diff --git a/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h b/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h
index 1da330497b33..475410ab2d13 100644
--- a/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h
+++ b/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h
@@ -16,8 +16,8 @@
// Project includes
#include "Plugins/Process/Utility/ARMDefines.h"
#include "lldb/Core/EmulateInstruction.h"
-#include "lldb/Core/Error.h"
#include "lldb/Interpreter/OptionValue.h"
+#include "lldb/Utility/Error.h"
class EmulateInstructionARM64 : public lldb_private::EmulateInstruction {
public:
diff --git a/source/Plugins/Instruction/MIPS/CMakeLists.txt b/source/Plugins/Instruction/MIPS/CMakeLists.txt
index dc6707336939..b2fe0ee8813f 100644
--- a/source/Plugins/Instruction/MIPS/CMakeLists.txt
+++ b/source/Plugins/Instruction/MIPS/CMakeLists.txt
@@ -1,3 +1,18 @@
-add_lldb_library(lldbPluginInstructionMIPS
+if(Mips IN_LIST LLVM_TARGETS_TO_BUILD)
+ set(mips_target Mips)
+endif()
+
+add_lldb_library(lldbPluginInstructionMIPS PLUGIN
EmulateInstructionMIPS.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbPluginProcessUtility
+ LINK_COMPONENTS
+ MC
+ Support
+ ${mips_target}
)
diff --git a/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp b/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
index 8cc34c171c72..aa7c6e5d1fe0 100644
--- a/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
+++ b/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
@@ -1,5 +1,4 @@
-//===-- EmulateInstructionMIPS.cpp -------------------------------*- C++
-//-*-===//
+//===-- EmulateInstructionMIPS.cpp -------------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,13 +13,14 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Opcode.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Core/RegisterValue.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Stream.h"
#include "llvm-c/Disassembler.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
diff --git a/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h b/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h
index 82c6a0a31e81..0375056f87c7 100644
--- a/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h
+++ b/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h
@@ -22,8 +22,8 @@ class MCInst;
}
#include "lldb/Core/EmulateInstruction.h"
-#include "lldb/Core/Error.h"
#include "lldb/Interpreter/OptionValue.h"
+#include "lldb/Utility/Error.h"
class EmulateInstructionMIPS : public lldb_private::EmulateInstruction {
public:
diff --git a/source/Plugins/Instruction/MIPS64/CMakeLists.txt b/source/Plugins/Instruction/MIPS64/CMakeLists.txt
index 25c919c4edb6..ddb964bf50a5 100644
--- a/source/Plugins/Instruction/MIPS64/CMakeLists.txt
+++ b/source/Plugins/Instruction/MIPS64/CMakeLists.txt
@@ -1,3 +1,18 @@
-add_lldb_library(lldbPluginInstructionMIPS64
+if(Mips IN_LIST LLVM_TARGETS_TO_BUILD)
+ set(mips_target Mips)
+endif()
+
+add_lldb_library(lldbPluginInstructionMIPS64 PLUGIN
EmulateInstructionMIPS64.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbInterpreter
+ lldbSymbol
+ lldbPluginProcessUtility
+ LINK_COMPONENTS
+ MC
+ Support
+ ${mips_target}
)
diff --git a/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp b/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
index c054760be8a0..4c90a1901da7 100644
--- a/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
+++ b/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
@@ -1,5 +1,4 @@
-//===-- EmulateInstructionMIPS64.cpp -------------------------------*- C++
-//-*-===//
+//===-- EmulateInstructionMIPS64.cpp -----------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,13 +13,14 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Opcode.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Core/RegisterValue.h"
#include "lldb/Host/PosixApi.h"
#include "lldb/Symbol/UnwindPlan.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Stream.h"
#include "llvm-c/Disassembler.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
diff --git a/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h b/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h
index 5543615efade..1e5be516d130 100644
--- a/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h
+++ b/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h
@@ -15,8 +15,8 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/EmulateInstruction.h"
-#include "lldb/Core/Error.h"
#include "lldb/Interpreter/OptionValue.h"
+#include "lldb/Utility/Error.h"
namespace llvm {
class MCDisassembler;
diff --git a/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp b/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
index db626b066152..96370528f260 100644
--- a/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
+++ b/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
@@ -14,8 +14,6 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegularExpression.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Expression/UserExpression.h"
@@ -25,6 +23,8 @@
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/Stream.h"
#include "llvm/ADT/StringSwitch.h"
diff --git a/source/Plugins/InstrumentationRuntime/AddressSanitizer/CMakeLists.txt b/source/Plugins/InstrumentationRuntime/AddressSanitizer/CMakeLists.txt
index 77e7d15caa7c..1adfc6ba5322 100644
--- a/source/Plugins/InstrumentationRuntime/AddressSanitizer/CMakeLists.txt
+++ b/source/Plugins/InstrumentationRuntime/AddressSanitizer/CMakeLists.txt
@@ -1,3 +1,13 @@
-add_lldb_library(lldbPluginInstrumentationRuntimeAddressSanitizer
+add_lldb_library(lldbPluginInstrumentationRuntimeAddressSanitizer PLUGIN
AddressSanitizerRuntime.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbExpression
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/InstrumentationRuntime/ThreadSanitizer/CMakeLists.txt b/source/Plugins/InstrumentationRuntime/ThreadSanitizer/CMakeLists.txt
index 6ef79433d67a..db7c4a2518a1 100644
--- a/source/Plugins/InstrumentationRuntime/ThreadSanitizer/CMakeLists.txt
+++ b/source/Plugins/InstrumentationRuntime/ThreadSanitizer/CMakeLists.txt
@@ -1,3 +1,12 @@
-add_lldb_library(lldbPluginInstrumentationRuntimeThreadSanitizer
+add_lldb_library(lldbPluginInstrumentationRuntimeThreadSanitizer PLUGIN
ThreadSanitizerRuntime.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbExpression
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbPluginProcessUtility
)
diff --git a/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp b/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
index d8a46e5d4550..cbc77ebe9987 100644
--- a/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
+++ b/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
@@ -15,8 +15,6 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginInterface.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegularExpression.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Expression/UserExpression.h"
@@ -30,6 +28,8 @@
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
@@ -85,6 +85,10 @@ extern "C"
int *running, const char **name, int *parent_tid,
void **trace, unsigned long trace_size);
int __tsan_get_report_unique_tid(void *report, unsigned long idx, int *tid);
+
+ // TODO: dlsym won't work on Windows.
+ void *dlsym(void* handle, const char* symbol);
+ int (*ptr__tsan_get_report_loc_object_type)(void *report, unsigned long idx, const char **object_type);
}
const int REPORT_TRACE_SIZE = 128;
@@ -125,6 +129,7 @@ struct data {
int fd;
int suppressable;
void *trace[REPORT_TRACE_SIZE];
+ const char *object_type;
} locs[REPORT_ARRAY_SIZE];
int mutex_count;
@@ -158,6 +163,8 @@ struct data {
const char *thread_sanitizer_retrieve_report_data_command = R"(
data t = {0};
+ptr__tsan_get_report_loc_object_type = (typeof(ptr__tsan_get_report_loc_object_type))(void *)dlsym((void*)-2 /*RTLD_DEFAULT*/, "__tsan_get_report_loc_object_type");
+
t.report = __tsan_get_current_report();
__tsan_get_report_data(t.report, &t.description, &t.report_count, &t.stack_count, &t.mop_count, &t.loc_count, &t.mutex_count, &t.thread_count, &t.unique_tid_count, t.sleep_trace, REPORT_TRACE_SIZE);
@@ -177,6 +184,8 @@ if (t.loc_count > REPORT_ARRAY_SIZE) t.loc_count = REPORT_ARRAY_SIZE;
for (int i = 0; i < t.loc_count; i++) {
t.locs[i].idx = i;
__tsan_get_report_loc(t.report, i, &t.locs[i].type, &t.locs[i].addr, &t.locs[i].start, &t.locs[i].size, &t.locs[i].tid, &t.locs[i].fd, &t.locs[i].suppressable, t.locs[i].trace, REPORT_TRACE_SIZE);
+ if (ptr__tsan_get_report_loc_object_type)
+ ptr__tsan_get_report_loc_object_type(t.report, i, &t.locs[i].object_type);
}
if (t.mutex_count > REPORT_ARRAY_SIZE) t.mutex_count = REPORT_ARRAY_SIZE;
@@ -409,6 +418,8 @@ ThreadSanitizerRuntime::RetrieveReportData(ExecutionContextRef exe_ctx_ref) {
o->GetValueForExpressionPath(".suppressable")
->GetValueAsUnsigned(0));
dict->AddItem("trace", StructuredData::ObjectSP(CreateStackTrace(o)));
+ dict->AddStringItem("object_type",
+ RetrieveString(o, process_sp, ".object_type"));
});
dict->AddItem("locs", StructuredData::ObjectSP(locs));
@@ -511,6 +522,10 @@ ThreadSanitizerRuntime::FormatDescription(StructuredData::ObjectSP report) {
return "Overwrite of errno in a signal handler";
} else if (description == "lock-order-inversion") {
return "Lock order inversion (potential deadlock)";
+ } else if (description == "external-race") {
+ return "Race on a library object";
+ } else if (description == "swift-access-race") {
+ return "Swift access race";
}
// for unknown report codes just show the code
@@ -568,27 +583,31 @@ static void GetSymbolDeclarationFromAddress(ProcessSP process_sp, addr_t addr,
}
addr_t ThreadSanitizerRuntime::GetFirstNonInternalFramePc(
- StructuredData::ObjectSP trace) {
+ StructuredData::ObjectSP trace, bool skip_one_frame) {
ProcessSP process_sp = GetProcessSP();
ModuleSP runtime_module_sp = GetRuntimeModuleSP();
- addr_t result = 0;
- trace->GetAsArray()->ForEach([process_sp, runtime_module_sp,
- &result](StructuredData::Object *o) -> bool {
- addr_t addr = o->GetIntegerValue();
+ StructuredData::Array *trace_array = trace->GetAsArray();
+ for (int i = 0; i < trace_array->GetSize(); i++) {
+ if (skip_one_frame && i == 0)
+ continue;
+
+ addr_t addr;
+ if (!trace_array->GetItemAtIndexAsInteger(i, addr))
+ continue;
+
lldb_private::Address so_addr;
if (!process_sp->GetTarget().GetSectionLoadList().ResolveLoadAddress(
addr, so_addr))
- return true;
+ continue;
if (so_addr.GetModule() == runtime_module_sp)
- return true;
+ continue;
- result = addr;
- return false;
- });
+ return addr;
+ }
- return result;
+ return 0;
}
std::string
@@ -599,6 +618,10 @@ ThreadSanitizerRuntime::GenerateSummary(StructuredData::ObjectSP report) {
->GetValueForKey("description")
->GetAsString()
->GetValue();
+ bool skip_one_frame =
+ report->GetObjectForDotSeparatedPath("issue_type")->GetStringValue() ==
+ "external-race";
+
addr_t pc = 0;
if (report->GetAsDictionary()
->GetValueForKey("mops")
@@ -609,7 +632,8 @@ ThreadSanitizerRuntime::GenerateSummary(StructuredData::ObjectSP report) {
->GetAsArray()
->GetItemAtIndex(0)
->GetAsDictionary()
- ->GetValueForKey("trace"));
+ ->GetValueForKey("trace"),
+ skip_one_frame);
if (report->GetAsDictionary()
->GetValueForKey("stacks")
@@ -620,7 +644,8 @@ ThreadSanitizerRuntime::GenerateSummary(StructuredData::ObjectSP report) {
->GetAsArray()
->GetItemAtIndex(0)
->GetAsDictionary()
- ->GetValueForKey("trace"));
+ ->GetValueForKey("trace"),
+ skip_one_frame);
if (pc != 0) {
summary = summary + " in " + GetSymbolNameFromAddress(process_sp, pc);
@@ -634,6 +659,13 @@ ThreadSanitizerRuntime::GenerateSummary(StructuredData::ObjectSP report) {
->GetValueForKey("locs")
->GetAsArray()
->GetItemAtIndex(0);
+ std::string object_type = loc->GetAsDictionary()
+ ->GetValueForKey("object_type")
+ ->GetAsString()
+ ->GetValue();
+ if (!object_type.empty()) {
+ summary = "Race on " + object_type + " object";
+ }
addr_t addr = loc->GetAsDictionary()
->GetValueForKey("address")
->GetAsInteger()
@@ -726,8 +758,17 @@ std::string ThreadSanitizerRuntime::GetLocationDescription(
->GetValueForKey("size")
->GetAsInteger()
->GetValue();
- result =
- Sprintf("Location is a %ld-byte heap object at 0x%llx", size, addr);
+ std::string object_type = loc->GetAsDictionary()
+ ->GetValueForKey("object_type")
+ ->GetAsString()
+ ->GetValue();
+ if (!object_type.empty()) {
+ result = Sprintf("Location is a %ld-byte %s object at 0x%llx", size,
+ object_type.c_str(), addr);
+ } else {
+ result =
+ Sprintf("Location is a %ld-byte heap object at 0x%llx", size, addr);
+ }
} else if (type == "stack") {
int tid = loc->GetAsDictionary()
->GetValueForKey("thread_id")
@@ -920,9 +961,18 @@ static std::string GenerateThreadName(const std::string &path,
addr_string = "";
}
- result = Sprintf("%s%s of size %d%s by thread %d",
- is_atomic ? "atomic " : "", is_write ? "write" : "read",
- size, addr_string.c_str(), thread_id);
+ if (main_info->GetObjectForDotSeparatedPath("issue_type")
+ ->GetStringValue() == "external-race") {
+ result = Sprintf("%s access by thread %d",
+ is_write ? "mutating" : "read-only", thread_id);
+ } else if (main_info->GetObjectForDotSeparatedPath("issue_type")
+ ->GetStringValue() == "swift-access-race") {
+ result = Sprintf("modifying access by thread %d", thread_id);
+ } else {
+ result = Sprintf("%s%s of size %d%s by thread %d",
+ is_atomic ? "atomic " : "", is_write ? "write" : "read",
+ size, addr_string.c_str(), thread_id);
+ }
}
if (path == "threads") {
diff --git a/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.h b/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.h
index 9b07ca64e32b..2a10582b65d2 100644
--- a/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.h
+++ b/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.h
@@ -77,7 +77,8 @@ private:
std::string &global_name,
std::string &filename, uint32_t &line);
- lldb::addr_t GetFirstNonInternalFramePc(StructuredData::ObjectSP trace);
+ lldb::addr_t GetFirstNonInternalFramePc(StructuredData::ObjectSP trace,
+ bool skip_one_frame = false);
};
} // namespace lldb_private
diff --git a/source/Plugins/JITLoader/GDB/CMakeLists.txt b/source/Plugins/JITLoader/GDB/CMakeLists.txt
index bcf714dca593..25e8d1ee231f 100644
--- a/source/Plugins/JITLoader/GDB/CMakeLists.txt
+++ b/source/Plugins/JITLoader/GDB/CMakeLists.txt
@@ -1,6 +1,16 @@
include_directories(.)
-add_lldb_library(lldbPluginJITLoaderGDB
+add_lldb_library(lldbPluginJITLoaderGDB PLUGIN
JITLoaderGDB.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp b/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
index bbb445a1fbc4..b97d67a0bb42 100644
--- a/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
+++ b/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
@@ -12,20 +12,22 @@
#include "llvm/Support/MathExtras.h"
#include "lldb/Breakpoint/Breakpoint.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Interpreter/OptionValueProperties.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
#include "JITLoaderGDB.h"
diff --git a/source/Plugins/Language/CPlusPlus/CMakeLists.txt b/source/Plugins/Language/CPlusPlus/CMakeLists.txt
index 5e105aa19b6b..8f769c499987 100644
--- a/source/Plugins/Language/CPlusPlus/CMakeLists.txt
+++ b/source/Plugins/Language/CPlusPlus/CMakeLists.txt
@@ -1,6 +1,7 @@
-add_lldb_library(lldbPluginCPlusPlusLanguage
+add_lldb_library(lldbPluginCPlusPlusLanguage PLUGIN
BlockPointer.cpp
CPlusPlusLanguage.cpp
+ CPlusPlusNameParser.cpp
CxxStringTypes.cpp
LibCxx.cpp
LibCxxAtomic.cpp
@@ -12,4 +13,14 @@ add_lldb_library(lldbPluginCPlusPlusLanguage
LibStdcpp.cpp
LibStdcppTuple.cpp
LibStdcppUniquePointer.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbDataFormatters
+ lldbHost
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index b5527edacd13..fe42a5ed9214 100644
--- a/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -23,18 +23,19 @@
#include "llvm/ADT/StringRef.h"
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/FastDemangle.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/UniqueCStringMap.h"
#include "lldb/DataFormatters/CXXFunctionPointer.h"
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/VectorType.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/FastDemangle.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegularExpression.h"
#include "BlockPointer.h"
+#include "CPlusPlusNameParser.h"
#include "CxxStringTypes.h"
#include "LibCxx.h"
#include "LibCxxAtomic.h"
@@ -84,15 +85,14 @@ void CPlusPlusLanguage::MethodName::Clear() {
m_context = llvm::StringRef();
m_arguments = llvm::StringRef();
m_qualifiers = llvm::StringRef();
- m_type = eTypeInvalid;
m_parsed = false;
m_parse_error = false;
}
-bool ReverseFindMatchingChars(const llvm::StringRef &s,
- const llvm::StringRef &left_right_chars,
- size_t &left_pos, size_t &right_pos,
- size_t pos = llvm::StringRef::npos) {
+static bool ReverseFindMatchingChars(const llvm::StringRef &s,
+ const llvm::StringRef &left_right_chars,
+ size_t &left_pos, size_t &right_pos,
+ size_t pos = llvm::StringRef::npos) {
assert(left_right_chars.size() == 2);
left_pos = llvm::StringRef::npos;
const char left_char = left_right_chars[0];
@@ -118,10 +118,9 @@ bool ReverseFindMatchingChars(const llvm::StringRef &s,
return false;
}
-static bool IsValidBasename(const llvm::StringRef &basename) {
- // Check that the basename matches with the following regular expression or is
- // an operator name:
- // "^~?([A-Za-z_][A-Za-z_0-9]*)(<.*>)?$"
+static bool IsTrivialBasename(const llvm::StringRef &basename) {
+ // Check that the basename matches with the following regular expression
+ // "^~?([A-Za-z_][A-Za-z_0-9]*)$"
// We are using a hand written implementation because it is significantly more
// efficient then
// using the general purpose regular expression library.
@@ -148,100 +147,69 @@ static bool IsValidBasename(const llvm::StringRef &basename) {
if (idx == basename.size())
return true;
- // Check for basename with template arguments
- // TODO: Improve the quality of the validation with validating the template
- // arguments
- if (basename[idx] == '<' && basename.back() == '>')
- return true;
+ return false;
+}
- // Check if the basename is a vaild C++ operator name
- if (!basename.startswith("operator"))
- return false;
+bool CPlusPlusLanguage::MethodName::TrySimplifiedParse() {
+ // This method tries to parse simple method definitions
+ // which are presumably most comman in user programs.
+ // Definitions that can be parsed by this function don't have return types
+ // and templates in the name.
+ // A::B::C::fun(std::vector<T> &) const
+ size_t arg_start, arg_end;
+ llvm::StringRef full(m_full.GetCString());
+ llvm::StringRef parens("()", 2);
+ if (ReverseFindMatchingChars(full, parens, arg_start, arg_end)) {
+ m_arguments = full.substr(arg_start, arg_end - arg_start + 1);
+ if (arg_end + 1 < full.size())
+ m_qualifiers = full.substr(arg_end + 1).ltrim();
- static RegularExpression g_operator_regex(
- llvm::StringRef("^(operator)( "
- "?)([A-Za-z_][A-Za-z_0-9]*|\\(\\)|"
- "\\[\\]|[\\^<>=!\\/"
- "*+-]+)(<.*>)?(\\[\\])?$"));
- std::string basename_str(basename.str());
- return g_operator_regex.Execute(basename_str, nullptr);
+ if (arg_start == 0)
+ return false;
+ size_t basename_end = arg_start;
+ size_t context_start = 0;
+ size_t context_end = full.rfind(':', basename_end);
+ if (context_end == llvm::StringRef::npos)
+ m_basename = full.substr(0, basename_end);
+ else {
+ if (context_start < context_end)
+ m_context = full.substr(context_start, context_end - 1 - context_start);
+ const size_t basename_begin = context_end + 1;
+ m_basename = full.substr(basename_begin, basename_end - basename_begin);
+ }
+
+ if (IsTrivialBasename(m_basename)) {
+ return true;
+ } else {
+ // The C++ basename doesn't match our regular expressions so this can't
+ // be a valid C++ method, clear everything out and indicate an error
+ m_context = llvm::StringRef();
+ m_basename = llvm::StringRef();
+ m_arguments = llvm::StringRef();
+ m_qualifiers = llvm::StringRef();
+ return false;
+ }
+ }
+ return false;
}
void CPlusPlusLanguage::MethodName::Parse() {
if (!m_parsed && m_full) {
- // ConstString mangled;
- // m_full.GetMangledCounterpart(mangled);
- // printf ("\n parsing = '%s'\n", m_full.GetCString());
- // if (mangled)
- // printf (" mangled = '%s'\n", mangled.GetCString());
- m_parse_error = false;
- m_parsed = true;
- llvm::StringRef full(m_full.GetCString());
-
- size_t arg_start, arg_end;
- llvm::StringRef parens("()", 2);
- if (ReverseFindMatchingChars(full, parens, arg_start, arg_end)) {
- m_arguments = full.substr(arg_start, arg_end - arg_start + 1);
- if (arg_end + 1 < full.size())
- m_qualifiers = full.substr(arg_end + 1);
- if (arg_start > 0) {
- size_t basename_end = arg_start;
- size_t context_start = 0;
- size_t context_end = llvm::StringRef::npos;
- if (basename_end > 0 && full[basename_end - 1] == '>') {
- // TODO: handle template junk...
- // Templated function
- size_t template_start, template_end;
- llvm::StringRef lt_gt("<>", 2);
- if (ReverseFindMatchingChars(full, lt_gt, template_start,
- template_end, basename_end)) {
- // Check for templated functions that include return type like:
- // 'void foo<Int>()'
- context_start = full.rfind(' ', template_start);
- if (context_start == llvm::StringRef::npos)
- context_start = 0;
- else
- ++context_start;
-
- context_end = full.rfind(':', template_start);
- if (context_end == llvm::StringRef::npos ||
- context_end < context_start)
- context_end = context_start;
- } else {
- context_end = full.rfind(':', basename_end);
- }
- } else if (context_end == llvm::StringRef::npos) {
- context_end = full.rfind(':', basename_end);
- }
-
- if (context_end == llvm::StringRef::npos)
- m_basename = full.substr(0, basename_end);
- else {
- if (context_start < context_end)
- m_context =
- full.substr(context_start, context_end - 1 - context_start);
- const size_t basename_begin = context_end + 1;
- m_basename =
- full.substr(basename_begin, basename_end - basename_begin);
- }
- m_type = eTypeUnknownMethod;
+ if (TrySimplifiedParse()) {
+ m_parse_error = false;
+ } else {
+ CPlusPlusNameParser parser(m_full.GetStringRef());
+ if (auto function = parser.ParseAsFunctionDefinition()) {
+ m_basename = function.getValue().name.basename;
+ m_context = function.getValue().name.context;
+ m_arguments = function.getValue().arguments;
+ m_qualifiers = function.getValue().qualifiers;
+ m_parse_error = false;
} else {
m_parse_error = true;
- return;
}
-
- if (!IsValidBasename(m_basename)) {
- // The C++ basename doesn't match our regular expressions so this can't
- // be a valid C++ method, clear everything out and indicate an error
- m_context = llvm::StringRef();
- m_basename = llvm::StringRef();
- m_arguments = llvm::StringRef();
- m_qualifiers = llvm::StringRef();
- m_parse_error = true;
- }
- } else {
- m_parse_error = true;
}
+ m_parsed = true;
}
}
@@ -272,14 +240,13 @@ llvm::StringRef CPlusPlusLanguage::MethodName::GetQualifiers() {
std::string CPlusPlusLanguage::MethodName::GetScopeQualifiedName() {
if (!m_parsed)
Parse();
- if (m_basename.empty() || m_context.empty())
- return std::string();
+ if (m_context.empty())
+ return m_basename;
std::string res;
res += m_context;
res += "::";
res += m_basename;
-
return res;
}
@@ -295,13 +262,10 @@ bool CPlusPlusLanguage::IsCPPMangledName(const char *name) {
bool CPlusPlusLanguage::ExtractContextAndIdentifier(
const char *name, llvm::StringRef &context, llvm::StringRef &identifier) {
- static RegularExpression g_basename_regex(llvm::StringRef(
- "^(([A-Za-z_][A-Za-z_0-9]*::)*)(~?[A-Za-z_~][A-Za-z_0-9]*)$"));
- RegularExpression::Match match(4);
- if (g_basename_regex.Execute(llvm::StringRef::withNullAsEmpty(name),
- &match)) {
- match.GetMatchAtIndex(name, 1, context);
- match.GetMatchAtIndex(name, 3, identifier);
+ CPlusPlusNameParser parser(name);
+ if (auto full_name = parser.ParseAsFullName()) {
+ identifier = full_name.getValue().basename;
+ context = full_name.getValue().context;
return true;
}
return false;
@@ -596,13 +560,6 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
AddCXXSynthetic(
cpp_category_sp,
- lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator,
- "libc++ std::vector<bool> synthetic children",
- ConstString(
- "^std::__(ndk)?1::vector<bool, std::__(ndk)?1::allocator<bool> >$"),
- stl_synth_flags, true);
- AddCXXSynthetic(
- cpp_category_sp,
lldb_private::formatters::LibcxxStdVectorSyntheticFrontEndCreator,
"libc++ std::vector synthetic children",
ConstString("^std::__(ndk)?1::vector<.+>(( )?&)?$"), stl_synth_flags,
@@ -620,19 +577,6 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
true);
AddCXXSynthetic(
cpp_category_sp,
- lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator,
- "libc++ std::vector<bool> synthetic children",
- ConstString("std::__(ndk)?1::vector<std::__(ndk)?1::allocator<bool> >"),
- stl_synth_flags);
- AddCXXSynthetic(
- cpp_category_sp,
- lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator,
- "libc++ std::vector<bool> synthetic children",
- ConstString(
- "std::__(ndk)?1::vector<bool, std::__(ndk)?1::allocator<bool> >"),
- stl_synth_flags);
- AddCXXSynthetic(
- cpp_category_sp,
lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
"libc++ std::set synthetic children",
ConstString("^std::__(ndk)?1::set<.+> >(( )?&)?$"), stl_synth_flags,
@@ -689,12 +633,6 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
stl_summary_flags.SetDontShowChildren(false);
stl_summary_flags.SetSkipPointers(false);
- AddCXXSummary(
- cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider,
- "libc++ std::vector<bool> summary provider",
- ConstString(
- "std::__(ndk)?1::vector<bool, std::__(ndk)?1::allocator<bool> >"),
- stl_summary_flags, true);
AddCXXSummary(cpp_category_sp,
lldb_private::formatters::LibcxxContainerSummaryProvider,
"libc++ std::vector summary provider",
@@ -759,12 +697,6 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
"std::vector iterator synthetic children",
ConstString("^std::__(ndk)?1::__wrap_iter<.+>$"), stl_synth_flags, true);
- AddCXXSummary(
- cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider,
- "libc++ std::vector<bool> summary provider",
- ConstString(
- "std::__(ndk)?1::vector<bool, std::__(ndk)?1::allocator<bool> >"),
- stl_summary_flags);
AddCXXSynthetic(
cpp_category_sp,
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEndCreator,
@@ -775,7 +707,7 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
AddCXXSynthetic(
cpp_category_sp, lldb_private::formatters::LibcxxFunctionFrontEndCreator,
"std::function synthetic value provider",
- ConstString("^std::__1::function<.+>$"), stl_synth_flags, true);
+ ConstString("^std::__(ndk)?1::function<.+>$"), stl_synth_flags, true);
#endif
}
@@ -1036,10 +968,10 @@ std::unique_ptr<Language::TypeScavenger> CPlusPlusLanguage::GetTypeScavenger() {
}
lldb::TypeCategoryImplSP CPlusPlusLanguage::GetFormatters() {
- static std::once_flag g_initialize;
+ static llvm::once_flag g_initialize;
static TypeCategoryImplSP g_category;
- std::call_once(g_initialize, [this]() -> void {
+ llvm::call_once(g_initialize, [this]() -> void {
DataVisualization::Categories::GetCategory(GetPluginName(), g_category);
if (g_category) {
LoadLibCxxFormatters(g_category);
@@ -1052,11 +984,11 @@ lldb::TypeCategoryImplSP CPlusPlusLanguage::GetFormatters() {
HardcodedFormatters::HardcodedSummaryFinder
CPlusPlusLanguage::GetHardcodedSummaries() {
- static std::once_flag g_initialize;
+ static llvm::once_flag g_initialize;
static ConstString g_vectortypes("VectorTypes");
static HardcodedFormatters::HardcodedSummaryFinder g_formatters;
- std::call_once(g_initialize, []() -> void {
+ llvm::call_once(g_initialize, []() -> void {
g_formatters.push_back(
[](lldb_private::ValueObject &valobj, lldb::DynamicValueType,
FormatManager &) -> TypeSummaryImpl::SharedPointer {
@@ -1116,11 +1048,11 @@ CPlusPlusLanguage::GetHardcodedSummaries() {
HardcodedFormatters::HardcodedSyntheticFinder
CPlusPlusLanguage::GetHardcodedSynthetics() {
- static std::once_flag g_initialize;
+ static llvm::once_flag g_initialize;
static ConstString g_vectortypes("VectorTypes");
static HardcodedFormatters::HardcodedSyntheticFinder g_formatters;
- std::call_once(g_initialize, []() -> void {
+ llvm::call_once(g_initialize, []() -> void {
g_formatters.push_back([](lldb_private::ValueObject &valobj,
lldb::DynamicValueType,
FormatManager &
diff --git a/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h b/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
index be5cbae57de2..056cced2808a 100644
--- a/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
+++ b/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
@@ -19,8 +19,8 @@
#include "llvm/ADT/StringRef.h"
// Project includes
-#include "lldb/Core/ConstString.h"
#include "lldb/Target/Language.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
@@ -29,20 +29,13 @@ class CPlusPlusLanguage : public Language {
public:
class MethodName {
public:
- enum Type {
- eTypeInvalid,
- eTypeUnknownMethod,
- eTypeClassMethod,
- eTypeInstanceMethod
- };
-
MethodName()
: m_full(), m_basename(), m_context(), m_arguments(), m_qualifiers(),
- m_type(eTypeInvalid), m_parsed(false), m_parse_error(false) {}
+ m_parsed(false), m_parse_error(false) {}
MethodName(const ConstString &s)
: m_full(s), m_basename(), m_context(), m_arguments(), m_qualifiers(),
- m_type(eTypeInvalid), m_parsed(false), m_parse_error(false) {}
+ m_parsed(false), m_parse_error(false) {}
void Clear();
@@ -51,13 +44,9 @@ public:
Parse();
if (m_parse_error)
return false;
- if (m_type == eTypeInvalid)
- return false;
return (bool)m_full;
}
- Type GetType() const { return m_type; }
-
const ConstString &GetFullName() const { return m_full; }
std::string GetScopeQualifiedName();
@@ -72,6 +61,7 @@ public:
protected:
void Parse();
+ bool TrySimplifiedParse();
ConstString m_full; // Full name:
// "lldb::SBTarget::GetBreakpointAtIndex(unsigned int)
@@ -80,7 +70,6 @@ public:
llvm::StringRef m_context; // Decl context: "lldb::SBTarget"
llvm::StringRef m_arguments; // Arguments: "(unsigned int)"
llvm::StringRef m_qualifiers; // Qualifiers: "const"
- Type m_type;
bool m_parsed;
bool m_parse_error;
};
@@ -121,7 +110,7 @@ public:
// If the name is a lone C identifier (e.g. C) or a qualified C identifier
// (e.g. A::B::C) it will return true,
// and identifier will be the identifier (C and C respectively) and the
- // context will be "" and "A::B::" respectively.
+ // context will be "" and "A::B" respectively.
// If the name fails the heuristic matching for a qualified or unqualified
// C/C++ identifier, then it will return false
// and identifier and context will be unchanged.
diff --git a/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp b/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
new file mode 100644
index 000000000000..5f0596cc9ad2
--- /dev/null
+++ b/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
@@ -0,0 +1,630 @@
+//===-- CPlusPlusNameParser.cpp ---------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "CPlusPlusNameParser.h"
+
+#include "clang/Basic/IdentifierTable.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/Support/Threading.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using llvm::Optional;
+using llvm::None;
+using ParsedFunction = lldb_private::CPlusPlusNameParser::ParsedFunction;
+using ParsedName = lldb_private::CPlusPlusNameParser::ParsedName;
+namespace tok = clang::tok;
+
+Optional<ParsedFunction> CPlusPlusNameParser::ParseAsFunctionDefinition() {
+ m_next_token_index = 0;
+ Optional<ParsedFunction> result(None);
+
+ // Try to parse the name as function without a return type specified
+ // e.g. main(int, char*[])
+ {
+ Bookmark start_position = SetBookmark();
+ result = ParseFunctionImpl(false);
+ if (result && !HasMoreTokens())
+ return result;
+ }
+
+ // Try to parse the name as function with function pointer return type
+ // e.g. void (*get_func(const char*))()
+ result = ParseFuncPtr(true);
+ if (result)
+ return result;
+
+ // Finally try to parse the name as a function with non-function return type
+ // e.g. int main(int, char*[])
+ result = ParseFunctionImpl(true);
+ if (HasMoreTokens())
+ return None;
+ return result;
+}
+
+Optional<ParsedName> CPlusPlusNameParser::ParseAsFullName() {
+ m_next_token_index = 0;
+ Optional<ParsedNameRanges> name_ranges = ParseFullNameImpl();
+ if (!name_ranges)
+ return None;
+ if (HasMoreTokens())
+ return None;
+ ParsedName result;
+ result.basename = GetTextForRange(name_ranges.getValue().basename_range);
+ result.context = GetTextForRange(name_ranges.getValue().context_range);
+ return result;
+}
+
+bool CPlusPlusNameParser::HasMoreTokens() {
+ return m_next_token_index < m_tokens.size();
+}
+
+void CPlusPlusNameParser::Advance() { ++m_next_token_index; }
+
+void CPlusPlusNameParser::TakeBack() { --m_next_token_index; }
+
+bool CPlusPlusNameParser::ConsumeToken(tok::TokenKind kind) {
+ if (!HasMoreTokens())
+ return false;
+
+ if (!Peek().is(kind))
+ return false;
+
+ Advance();
+ return true;
+}
+
+template <typename... Ts> bool CPlusPlusNameParser::ConsumeToken(Ts... kinds) {
+ if (!HasMoreTokens())
+ return false;
+
+ if (!Peek().isOneOf(kinds...))
+ return false;
+
+ Advance();
+ return true;
+}
+
+CPlusPlusNameParser::Bookmark CPlusPlusNameParser::SetBookmark() {
+ return Bookmark(m_next_token_index);
+}
+
+size_t CPlusPlusNameParser::GetCurrentPosition() { return m_next_token_index; }
+
+clang::Token &CPlusPlusNameParser::Peek() {
+ assert(HasMoreTokens());
+ return m_tokens[m_next_token_index];
+}
+
+Optional<ParsedFunction>
+CPlusPlusNameParser::ParseFunctionImpl(bool expect_return_type) {
+ Bookmark start_position = SetBookmark();
+ if (expect_return_type) {
+ // Consume return type if it's expected.
+ if (!ConsumeTypename())
+ return None;
+ }
+
+ auto maybe_name = ParseFullNameImpl();
+ if (!maybe_name) {
+ return None;
+ }
+
+ size_t argument_start = GetCurrentPosition();
+ if (!ConsumeArguments()) {
+ return None;
+ }
+
+ size_t qualifiers_start = GetCurrentPosition();
+ SkipFunctionQualifiers();
+ size_t end_position = GetCurrentPosition();
+
+ ParsedFunction result;
+ result.name.basename = GetTextForRange(maybe_name.getValue().basename_range);
+ result.name.context = GetTextForRange(maybe_name.getValue().context_range);
+ result.arguments = GetTextForRange(Range(argument_start, qualifiers_start));
+ result.qualifiers = GetTextForRange(Range(qualifiers_start, end_position));
+ start_position.Remove();
+ return result;
+}
+
+Optional<ParsedFunction>
+CPlusPlusNameParser::ParseFuncPtr(bool expect_return_type) {
+ Bookmark start_position = SetBookmark();
+ if (expect_return_type) {
+ // Consume return type.
+ if (!ConsumeTypename())
+ return None;
+ }
+
+ if (!ConsumeToken(tok::l_paren))
+ return None;
+ if (!ConsumePtrsAndRefs())
+ return None;
+
+ {
+ Bookmark before_inner_function_pos = SetBookmark();
+ auto maybe_inner_function_name = ParseFunctionImpl(false);
+ if (maybe_inner_function_name)
+ if (ConsumeToken(tok::r_paren))
+ if (ConsumeArguments()) {
+ SkipFunctionQualifiers();
+ start_position.Remove();
+ before_inner_function_pos.Remove();
+ return maybe_inner_function_name;
+ }
+ }
+
+ auto maybe_inner_function_ptr_name = ParseFuncPtr(false);
+ if (maybe_inner_function_ptr_name)
+ if (ConsumeToken(tok::r_paren))
+ if (ConsumeArguments()) {
+ SkipFunctionQualifiers();
+ start_position.Remove();
+ return maybe_inner_function_ptr_name;
+ }
+ return None;
+}
+
+bool CPlusPlusNameParser::ConsumeArguments() {
+ return ConsumeBrackets(tok::l_paren, tok::r_paren);
+}
+
+bool CPlusPlusNameParser::ConsumeTemplateArgs() {
+ Bookmark start_position = SetBookmark();
+ if (!HasMoreTokens() || Peek().getKind() != tok::less)
+ return false;
+ Advance();
+
+ // Consuming template arguments is a bit trickier than consuming function
+ // arguments, because '<' '>' brackets are not always trivially balanced.
+ // In some rare cases tokens '<' and '>' can appear inside template arguments
+ // as arithmetic or shift operators not as template brackets.
+ // Examples: std::enable_if<(10u)<(64), bool>
+ // f<A<operator<(X,Y)::Subclass>>
+ // Good thing that compiler makes sure that really ambiguous cases of
+ // '>' usage should be enclosed within '()' brackets.
+ int template_counter = 1;
+ bool can_open_template = false;
+ while (HasMoreTokens() && template_counter > 0) {
+ tok::TokenKind kind = Peek().getKind();
+ switch (kind) {
+ case tok::greatergreater:
+ template_counter -= 2;
+ can_open_template = false;
+ Advance();
+ break;
+ case tok::greater:
+ --template_counter;
+ can_open_template = false;
+ Advance();
+ break;
+ case tok::less:
+ // '<' is an attempt to open a subteamplte
+ // check if parser is at the point where it's actually possible,
+ // otherwise it's just a part of an expression like 'sizeof(T)<(10)'.
+ // No need to do the same for '>' because compiler actually makes sure
+ // that '>' always surrounded by brackets to avoid ambiguity.
+ if (can_open_template)
+ ++template_counter;
+ can_open_template = false;
+ Advance();
+ break;
+ case tok::kw_operator: // C++ operator overloading.
+ if (!ConsumeOperator())
+ return false;
+ can_open_template = true;
+ break;
+ case tok::raw_identifier:
+ can_open_template = true;
+ Advance();
+ break;
+ case tok::l_square:
+ if (!ConsumeBrackets(tok::l_square, tok::r_square))
+ return false;
+ can_open_template = false;
+ break;
+ case tok::l_paren:
+ if (!ConsumeArguments())
+ return false;
+ can_open_template = false;
+ break;
+ default:
+ can_open_template = false;
+ Advance();
+ break;
+ }
+ }
+
+ assert(template_counter >= 0);
+ if (template_counter > 0) {
+ return false;
+ }
+ start_position.Remove();
+ return true;
+}
+
+bool CPlusPlusNameParser::ConsumeAnonymousNamespace() {
+ Bookmark start_position = SetBookmark();
+ if (!ConsumeToken(tok::l_paren)) {
+ return false;
+ }
+ constexpr llvm::StringLiteral g_anonymous("anonymous");
+ if (HasMoreTokens() && Peek().is(tok::raw_identifier) &&
+ Peek().getRawIdentifier() == g_anonymous) {
+ Advance();
+ } else {
+ return false;
+ }
+
+ if (!ConsumeToken(tok::kw_namespace)) {
+ return false;
+ }
+
+ if (!ConsumeToken(tok::r_paren)) {
+ return false;
+ }
+ start_position.Remove();
+ return true;
+}
+
+bool CPlusPlusNameParser::ConsumeBrackets(tok::TokenKind left,
+ tok::TokenKind right) {
+ Bookmark start_position = SetBookmark();
+ if (!HasMoreTokens() || Peek().getKind() != left)
+ return false;
+ Advance();
+
+ int counter = 1;
+ while (HasMoreTokens() && counter > 0) {
+ tok::TokenKind kind = Peek().getKind();
+ if (kind == right)
+ --counter;
+ else if (kind == left)
+ ++counter;
+ Advance();
+ }
+
+ assert(counter >= 0);
+ if (counter > 0) {
+ return false;
+ }
+ start_position.Remove();
+ return true;
+}
+
+bool CPlusPlusNameParser::ConsumeOperator() {
+ Bookmark start_position = SetBookmark();
+ if (!ConsumeToken(tok::kw_operator))
+ return false;
+
+ if (!HasMoreTokens()) {
+ return false;
+ }
+
+ const auto &token = Peek();
+ switch (token.getKind()) {
+ case tok::kw_new:
+ case tok::kw_delete:
+ // This is 'new' or 'delete' operators.
+ Advance();
+ // Check for array new/delete.
+ if (HasMoreTokens() && Peek().is(tok::l_square)) {
+ // Consume the '[' and ']'.
+ if (!ConsumeBrackets(tok::l_square, tok::r_square))
+ return false;
+ }
+ break;
+
+#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
+ case tok::Token: \
+ Advance(); \
+ break;
+#define OVERLOADED_OPERATOR_MULTI(Name, Spelling, Unary, Binary, MemberOnly)
+#include "clang/Basic/OperatorKinds.def"
+#undef OVERLOADED_OPERATOR
+#undef OVERLOADED_OPERATOR_MULTI
+
+ case tok::l_paren:
+ // Call operator consume '(' ... ')'.
+ if (ConsumeBrackets(tok::l_paren, tok::r_paren))
+ break;
+ return false;
+
+ case tok::l_square:
+ // This is a [] operator.
+ // Consume the '[' and ']'.
+ if (ConsumeBrackets(tok::l_square, tok::r_square))
+ break;
+ return false;
+
+ default:
+ // This might be a cast operator.
+ if (ConsumeTypename())
+ break;
+ return false;
+ }
+ start_position.Remove();
+ return true;
+}
+
+void CPlusPlusNameParser::SkipTypeQualifiers() {
+ while (ConsumeToken(tok::kw_const, tok::kw_volatile))
+ ;
+}
+
+void CPlusPlusNameParser::SkipFunctionQualifiers() {
+ while (ConsumeToken(tok::kw_const, tok::kw_volatile, tok::amp, tok::ampamp))
+ ;
+}
+
+bool CPlusPlusNameParser::ConsumeBuiltinType() {
+ bool result = false;
+ bool continue_parsing = true;
+ // Built-in types can be made of a few keywords
+ // like 'unsigned long long int'. This function
+ // consumes all built-in type keywords without
+ // checking if they make sense like 'unsigned char void'.
+ while (continue_parsing && HasMoreTokens()) {
+ switch (Peek().getKind()) {
+ case tok::kw_short:
+ case tok::kw_long:
+ case tok::kw___int64:
+ case tok::kw___int128:
+ case tok::kw_signed:
+ case tok::kw_unsigned:
+ case tok::kw_void:
+ case tok::kw_char:
+ case tok::kw_int:
+ case tok::kw_half:
+ case tok::kw_float:
+ case tok::kw_double:
+ case tok::kw___float128:
+ case tok::kw_wchar_t:
+ case tok::kw_bool:
+ case tok::kw_char16_t:
+ case tok::kw_char32_t:
+ result = true;
+ Advance();
+ break;
+ default:
+ continue_parsing = false;
+ break;
+ }
+ }
+ return result;
+}
+
+void CPlusPlusNameParser::SkipPtrsAndRefs() {
+ // Ignoring result.
+ ConsumePtrsAndRefs();
+}
+
+bool CPlusPlusNameParser::ConsumePtrsAndRefs() {
+ bool found = false;
+ SkipTypeQualifiers();
+ while (ConsumeToken(tok::star, tok::amp, tok::ampamp, tok::kw_const,
+ tok::kw_volatile)) {
+ found = true;
+ SkipTypeQualifiers();
+ }
+ return found;
+}
+
+bool CPlusPlusNameParser::ConsumeDecltype() {
+ Bookmark start_position = SetBookmark();
+ if (!ConsumeToken(tok::kw_decltype))
+ return false;
+
+ if (!ConsumeArguments())
+ return false;
+
+ start_position.Remove();
+ return true;
+}
+
+bool CPlusPlusNameParser::ConsumeTypename() {
+ Bookmark start_position = SetBookmark();
+ SkipTypeQualifiers();
+ if (!ConsumeBuiltinType() && !ConsumeDecltype()) {
+ if (!ParseFullNameImpl())
+ return false;
+ }
+ SkipPtrsAndRefs();
+ start_position.Remove();
+ return true;
+}
+
+Optional<CPlusPlusNameParser::ParsedNameRanges>
+CPlusPlusNameParser::ParseFullNameImpl() {
+ // Name parsing state machine.
+ enum class State {
+ Beginning, // start of the name
+ AfterTwoColons, // right after ::
+ AfterIdentifier, // right after alphanumerical identifier ([a-z0-9_]+)
+ AfterTemplate, // right after template brackets (<something>)
+ AfterOperator, // right after name of C++ operator
+ };
+
+ Bookmark start_position = SetBookmark();
+ State state = State::Beginning;
+ bool continue_parsing = true;
+ Optional<size_t> last_coloncolon_position = None;
+
+ while (continue_parsing && HasMoreTokens()) {
+ const auto &token = Peek();
+ switch (token.getKind()) {
+ case tok::raw_identifier: // Just a name.
+ if (state != State::Beginning && state != State::AfterTwoColons) {
+ continue_parsing = false;
+ break;
+ }
+ Advance();
+ state = State::AfterIdentifier;
+ break;
+ case tok::l_paren: {
+ if (state == State::Beginning || state == State::AfterTwoColons) {
+ // (anonymous namespace)
+ if (ConsumeAnonymousNamespace()) {
+ state = State::AfterIdentifier;
+ break;
+ }
+ }
+
+ // Type declared inside a function 'func()::Type'
+ if (state != State::AfterIdentifier && state != State::AfterTemplate &&
+ state != State::AfterOperator) {
+ continue_parsing = false;
+ break;
+ }
+ Bookmark l_paren_position = SetBookmark();
+ // Consume the '(' ... ') [const]'.
+ if (!ConsumeArguments()) {
+ continue_parsing = false;
+ break;
+ }
+ SkipFunctionQualifiers();
+
+ // Consume '::'
+ size_t coloncolon_position = GetCurrentPosition();
+ if (!ConsumeToken(tok::coloncolon)) {
+ continue_parsing = false;
+ break;
+ }
+ l_paren_position.Remove();
+ last_coloncolon_position = coloncolon_position;
+ state = State::AfterTwoColons;
+ break;
+ }
+ case tok::coloncolon: // Type nesting delimiter.
+ if (state != State::Beginning && state != State::AfterIdentifier &&
+ state != State::AfterTemplate) {
+ continue_parsing = false;
+ break;
+ }
+ last_coloncolon_position = GetCurrentPosition();
+ Advance();
+ state = State::AfterTwoColons;
+ break;
+ case tok::less: // Template brackets.
+ if (state != State::AfterIdentifier && state != State::AfterOperator) {
+ continue_parsing = false;
+ break;
+ }
+ if (!ConsumeTemplateArgs()) {
+ continue_parsing = false;
+ break;
+ }
+ state = State::AfterTemplate;
+ break;
+ case tok::kw_operator: // C++ operator overloading.
+ if (state != State::Beginning && state != State::AfterTwoColons) {
+ continue_parsing = false;
+ break;
+ }
+ if (!ConsumeOperator()) {
+ continue_parsing = false;
+ break;
+ }
+ state = State::AfterOperator;
+ break;
+ case tok::tilde: // Destructor.
+ if (state != State::Beginning && state != State::AfterTwoColons) {
+ continue_parsing = false;
+ break;
+ }
+ Advance();
+ if (ConsumeToken(tok::raw_identifier)) {
+ state = State::AfterIdentifier;
+ } else {
+ TakeBack();
+ continue_parsing = false;
+ }
+ break;
+ default:
+ continue_parsing = false;
+ break;
+ }
+ }
+
+ if (state == State::AfterIdentifier || state == State::AfterOperator ||
+ state == State::AfterTemplate) {
+ ParsedNameRanges result;
+ if (last_coloncolon_position) {
+ result.context_range = Range(start_position.GetSavedPosition(),
+ last_coloncolon_position.getValue());
+ result.basename_range =
+ Range(last_coloncolon_position.getValue() + 1, GetCurrentPosition());
+ } else {
+ result.basename_range =
+ Range(start_position.GetSavedPosition(), GetCurrentPosition());
+ }
+ start_position.Remove();
+ return result;
+ } else {
+ return None;
+ }
+}
+
+llvm::StringRef CPlusPlusNameParser::GetTextForRange(const Range &range) {
+ if (range.empty())
+ return llvm::StringRef();
+ assert(range.begin_index < range.end_index);
+ assert(range.begin_index < m_tokens.size());
+ assert(range.end_index <= m_tokens.size());
+ clang::Token &first_token = m_tokens[range.begin_index];
+ clang::Token &last_token = m_tokens[range.end_index - 1];
+ clang::SourceLocation start_loc = first_token.getLocation();
+ clang::SourceLocation end_loc = last_token.getLocation();
+ unsigned start_pos = start_loc.getRawEncoding();
+ unsigned end_pos = end_loc.getRawEncoding() + last_token.getLength();
+ return m_text.take_front(end_pos).drop_front(start_pos);
+}
+
+static const clang::LangOptions &GetLangOptions() {
+ static clang::LangOptions g_options;
+ static llvm::once_flag g_once_flag;
+ llvm::call_once(g_once_flag, []() {
+ g_options.LineComment = true;
+ g_options.C99 = true;
+ g_options.C11 = true;
+ g_options.CPlusPlus = true;
+ g_options.CPlusPlus11 = true;
+ g_options.CPlusPlus14 = true;
+ g_options.CPlusPlus1z = true;
+ });
+ return g_options;
+}
+
+static const llvm::StringMap<tok::TokenKind> &GetKeywordsMap() {
+ static llvm::StringMap<tok::TokenKind> g_map{
+#define KEYWORD(Name, Flags) {llvm::StringRef(#Name), tok::kw_##Name},
+#include "clang/Basic/TokenKinds.def"
+#undef KEYWORD
+ };
+ return g_map;
+}
+
+void CPlusPlusNameParser::ExtractTokens() {
+ clang::Lexer lexer(clang::SourceLocation(), GetLangOptions(), m_text.data(),
+ m_text.data(), m_text.data() + m_text.size());
+ const auto &kw_map = GetKeywordsMap();
+ clang::Token token;
+ for (lexer.LexFromRawLexer(token); !token.is(clang::tok::eof);
+ lexer.LexFromRawLexer(token)) {
+ if (token.is(clang::tok::raw_identifier)) {
+ auto it = kw_map.find(token.getRawIdentifier());
+ if (it != kw_map.end()) {
+ token.setKind(it->getValue());
+ }
+ }
+
+ m_tokens.push_back(token);
+ }
+}
diff --git a/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h b/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
new file mode 100644
index 000000000000..f936fb787c94
--- /dev/null
+++ b/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
@@ -0,0 +1,179 @@
+//===-- CPlusPlusNameParser.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_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"
+
+namespace lldb_private {
+
+// Helps to validate and obtain various parts of C++ definitions.
+class CPlusPlusNameParser {
+public:
+ CPlusPlusNameParser(llvm::StringRef text) : m_text(text) { ExtractTokens(); }
+
+ struct ParsedName {
+ llvm::StringRef basename;
+ llvm::StringRef context;
+ };
+
+ struct ParsedFunction {
+ ParsedName name;
+ llvm::StringRef arguments;
+ llvm::StringRef qualifiers;
+ };
+
+ // Treats given text as a function definition and parses it.
+ // Function definition might or might not have a return type and this should
+ // change parsing result.
+ // Examples:
+ // main(int, chat const*)
+ // T fun(int, bool)
+ // std::vector<int>::push_back(int)
+ // int& map<int, pair<short, int>>::operator[](short) const
+ // int (*get_function(const chat *))()
+ llvm::Optional<ParsedFunction> ParseAsFunctionDefinition();
+
+ // Treats given text as a potentially nested name of C++ entity (function,
+ // class, field) and parses it.
+ // Examples:
+ // main
+ // fun
+ // std::vector<int>::push_back
+ // map<int, pair<short, int>>::operator[]
+ // func<C>(int, C&)::nested_class::method
+ llvm::Optional<ParsedName> ParseAsFullName();
+
+private:
+ // A C++ definition to parse.
+ llvm::StringRef m_text;
+ // Tokens extracted from m_text.
+ llvm::SmallVector<clang::Token, 30> m_tokens;
+ // Index of the next token to look at from m_tokens.
+ size_t m_next_token_index = 0;
+
+ // Range of tokens saved in m_next_token_index.
+ struct Range {
+ size_t begin_index = 0;
+ size_t end_index = 0;
+
+ Range() {}
+ Range(size_t begin, size_t end) : begin_index(begin), end_index(end) {
+ assert(end >= begin);
+ }
+
+ size_t size() const { return end_index - begin_index; }
+
+ bool empty() const { return size() == 0; }
+ };
+
+ struct ParsedNameRanges {
+ Range basename_range;
+ Range context_range;
+ };
+
+ // Bookmark automatically restores parsing position (m_next_token_index)
+ // when destructed unless it's manually removed with Remove().
+ class Bookmark {
+ public:
+ Bookmark(size_t &position)
+ : m_position(position), m_position_value(position) {}
+ Bookmark(const Bookmark &) = delete;
+ Bookmark(Bookmark &&b)
+ : m_position(b.m_position), m_position_value(b.m_position_value),
+ m_restore(b.m_restore) {
+ b.Remove();
+ }
+ Bookmark &operator=(Bookmark &&) = delete;
+ Bookmark &operator=(const Bookmark &) = delete;
+
+ void Remove() { m_restore = false; }
+ size_t GetSavedPosition() { return m_position_value; }
+ ~Bookmark() {
+ if (m_restore) {
+ m_position = m_position_value;
+ }
+ }
+
+ private:
+ size_t &m_position;
+ size_t m_position_value;
+ bool m_restore = true;
+ };
+
+ bool HasMoreTokens();
+ void Advance();
+ void TakeBack();
+ bool ConsumeToken(clang::tok::TokenKind kind);
+ template <typename... Ts> bool ConsumeToken(Ts... kinds);
+ Bookmark SetBookmark();
+ size_t GetCurrentPosition();
+ clang::Token &Peek();
+ bool ConsumeBrackets(clang::tok::TokenKind left, clang::tok::TokenKind right);
+
+ llvm::Optional<ParsedFunction> ParseFunctionImpl(bool expect_return_type);
+
+ // Parses functions returning function pointers 'string (*f(int x))(float y)'
+ llvm::Optional<ParsedFunction> ParseFuncPtr(bool expect_return_type);
+
+ // Consumes function arguments enclosed within '(' ... ')'
+ bool ConsumeArguments();
+
+ // Consumes template arguments enclosed within '<' ... '>'
+ bool ConsumeTemplateArgs();
+
+ // Consumes '(anonymous namespace)'
+ bool ConsumeAnonymousNamespace();
+
+ // Consumes operator declaration like 'operator *' or 'operator delete []'
+ bool ConsumeOperator();
+
+ // Skips 'const' and 'volatile'
+ void SkipTypeQualifiers();
+
+ // Skips 'const', 'volatile', '&', '&&' in the end of the function.
+ void SkipFunctionQualifiers();
+
+ // Consumes built-in types like 'int' or 'unsigned long long int'
+ bool ConsumeBuiltinType();
+
+ // Consumes types defined via decltype keyword.
+ bool ConsumeDecltype();
+
+ // Skips 'const' and 'volatile'
+ void SkipPtrsAndRefs();
+
+ // Consumes things like 'const * const &'
+ bool ConsumePtrsAndRefs();
+
+ // Consumes full type name like 'Namespace::Class<int>::Method()::InnerClass'
+ bool ConsumeTypename();
+
+ llvm::Optional<ParsedNameRanges> ParseFullNameImpl();
+ llvm::StringRef GetTextForRange(const Range &range);
+
+ // Populate m_tokens by calling clang lexer on m_text.
+ void ExtractTokens();
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_CPlusPlusNameParser_h_
diff --git a/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp b/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
index 346ea0bbd519..b69b69530428 100644
--- a/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
+++ b/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
@@ -11,21 +11,21 @@
#include "llvm/Support/ConvertUTF.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/DataFormatters/TypeSummary.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Host/Time.h"
#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
-#include "lldb/Utility/ProcessStructReader.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
#include <algorithm>
diff --git a/source/Plugins/Language/CPlusPlus/CxxStringTypes.h b/source/Plugins/Language/CPlusPlus/CxxStringTypes.h
index 0bee3bd3b0f2..8e2ec44dc71c 100644
--- a/source/Plugins/Language/CPlusPlus/CxxStringTypes.h
+++ b/source/Plugins/Language/CPlusPlus/CxxStringTypes.h
@@ -11,9 +11,9 @@
#ifndef liblldb_CxxStringTypes_h_
#define liblldb_CxxStringTypes_h_
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/Utility/Stream.h"
namespace lldb_private {
namespace formatters {
diff --git a/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 82441a69b1d4..72d99671612c 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -13,21 +13,21 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/FormatEntity.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/DataFormatters/VectorIterator.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/Target.h"
-#include "lldb/Utility/ProcessStructReader.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
@@ -76,155 +76,6 @@ bool lldb_private::formatters::LibcxxSmartPointerSummaryProvider(
return true;
}
-lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
- LibcxxVectorBoolSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
- : SyntheticChildrenFrontEnd(*valobj_sp), m_bool_type(), m_exe_ctx_ref(),
- m_count(0), m_base_data_address(0), m_children() {
- if (valobj_sp) {
- Update();
- m_bool_type =
- valobj_sp->GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeBool);
- }
-}
-
-size_t lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
- CalculateNumChildren() {
- return m_count;
-}
-
-lldb::ValueObjectSP
-lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::GetChildAtIndex(
- size_t idx) {
- auto iter = m_children.find(idx), end = m_children.end();
- if (iter != end)
- return iter->second;
- if (idx >= m_count)
- return ValueObjectSP();
- if (m_base_data_address == 0 || m_count == 0)
- return ValueObjectSP();
- if (!m_bool_type)
- return ValueObjectSP();
- size_t byte_idx = (idx >> 3); // divide by 8 to get byte index
- size_t bit_index = (idx & 7); // efficient idx % 8 for bit index
- lldb::addr_t byte_location = m_base_data_address + byte_idx;
- ProcessSP process_sp(m_exe_ctx_ref.GetProcessSP());
- if (!process_sp)
- return ValueObjectSP();
- uint8_t byte = 0;
- uint8_t mask = 0;
- Error err;
- size_t bytes_read = process_sp->ReadMemory(byte_location, &byte, 1, err);
- if (err.Fail() || bytes_read == 0)
- return ValueObjectSP();
- switch (bit_index) {
- case 0:
- mask = 1;
- break;
- case 1:
- mask = 2;
- break;
- case 2:
- mask = 4;
- break;
- case 3:
- mask = 8;
- break;
- case 4:
- mask = 16;
- break;
- case 5:
- mask = 32;
- break;
- case 6:
- mask = 64;
- break;
- case 7:
- mask = 128;
- break;
- default:
- return ValueObjectSP();
- }
- bool bit_set = ((byte & mask) != 0);
- DataBufferSP buffer_sp(
- new DataBufferHeap(m_bool_type.GetByteSize(nullptr), 0));
- if (bit_set && buffer_sp && buffer_sp->GetBytes())
- *(buffer_sp->GetBytes()) =
- 1; // regardless of endianness, anything non-zero is true
- StreamString name;
- name.Printf("[%" PRIu64 "]", (uint64_t)idx);
- ValueObjectSP retval_sp(CreateValueObjectFromData(
- name.GetString(), DataExtractor(buffer_sp, process_sp->GetByteOrder(),
- process_sp->GetAddressByteSize()),
- m_exe_ctx_ref, m_bool_type));
- if (retval_sp)
- m_children[idx] = retval_sp;
- return retval_sp;
-}
-
-/*(std::__1::vector<std::__1::allocator<bool> >) vBool = {
- __begin_ = 0x00000001001000e0
- __size_ = 56
- __cap_alloc_ = {
- std::__1::__libcpp_compressed_pair_imp<unsigned long,
- std::__1::allocator<unsigned long> > = {
- __first_ = 1
- }
- }
- }*/
-
-bool lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::Update() {
- m_children.clear();
- ValueObjectSP valobj_sp = m_backend.GetSP();
- if (!valobj_sp)
- return false;
- m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
- ValueObjectSP size_sp(
- valobj_sp->GetChildMemberWithName(ConstString("__size_"), true));
- if (!size_sp)
- return false;
- m_count = size_sp->GetValueAsUnsigned(0);
- if (!m_count)
- return true;
- ValueObjectSP begin_sp(
- valobj_sp->GetChildMemberWithName(ConstString("__begin_"), true));
- if (!begin_sp) {
- m_count = 0;
- return false;
- }
- m_base_data_address = begin_sp->GetValueAsUnsigned(0);
- if (!m_base_data_address) {
- m_count = 0;
- return false;
- }
- return false;
-}
-
-bool lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
- MightHaveChildren() {
- return true;
-}
-
-size_t lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
- GetIndexOfChildWithName(const ConstString &name) {
- if (!m_count || !m_base_data_address)
- return UINT32_MAX;
- const char *item_name = name.GetCString();
- uint32_t idx = ExtractIndexFromString(item_name);
- if (idx < UINT32_MAX && idx >= CalculateNumChildren())
- return UINT32_MAX;
- return idx;
-}
-
-lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
- ~LibcxxVectorBoolSyntheticFrontEnd() = default;
-
-SyntheticChildrenFrontEnd *
-lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEndCreator(
- CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
- return (valobj_sp ? new LibcxxVectorBoolSyntheticFrontEnd(valobj_sp)
- : nullptr);
-}
-
/*
(lldb) fr var ibeg --raw --ptr-depth 1
(std::__1::__map_iterator<std::__1::__tree_iterator<std::__1::pair<int,
diff --git a/source/Plugins/Language/CPlusPlus/LibCxx.h b/source/Plugins/Language/CPlusPlus/LibCxx.h
index a8638513376c..7610212b4245 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxx.h
+++ b/source/Plugins/Language/CPlusPlus/LibCxx.h
@@ -11,10 +11,10 @@
#ifndef liblldb_LibCxx_h_
#define liblldb_LibCxx_h_
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
+#include "lldb/Utility/Stream.h"
namespace lldb_private {
namespace formatters {
@@ -32,30 +32,6 @@ bool LibcxxSmartPointerSummaryProvider(
const TypeSummaryOptions
&options); // libc++ std::shared_ptr<> and std::weak_ptr<>
-class LibcxxVectorBoolSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
-public:
- LibcxxVectorBoolSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
-
- size_t CalculateNumChildren() override;
-
- lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
-
- bool Update() override;
-
- bool MightHaveChildren() override;
-
- size_t GetIndexOfChildWithName(const ConstString &name) override;
-
- ~LibcxxVectorBoolSyntheticFrontEnd() override;
-
-private:
- CompilerType m_bool_type;
- ExecutionContextRef m_exe_ctx_ref;
- uint64_t m_count;
- lldb::addr_t m_base_data_address;
- std::map<size_t, lldb::ValueObjectSP> m_children;
-};
-
SyntheticChildrenFrontEnd *
LibcxxVectorBoolSyntheticFrontEndCreator(CXXSyntheticChildren *,
lldb::ValueObjectSP);
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h b/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h
index e2cc01150a2e..a9d948bf189c 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h
+++ b/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h
@@ -11,10 +11,10 @@
#ifndef liblldb_LibCxxAtomic_h_
#define liblldb_LibCxxAtomic_h_
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
+#include "lldb/Utility/Stream.h"
namespace lldb_private {
namespace formatters {
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp b/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
index b7aa70c0d2e7..4e839532afb7 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
@@ -13,9 +13,9 @@
// Project includes
#include "LibCxx.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/Utility/ConstString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxList.cpp b/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
index 16bd631a6c2f..4ad3df3d6038 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
@@ -13,15 +13,15 @@
// Project includes
#include "LibCxx.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
index 759a7008d3f3..50d4510ec5f9 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
@@ -13,15 +13,15 @@
// Project includes
#include "LibCxx.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
@@ -406,7 +406,7 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex(
case 1: {
auto child0_sp = potential_child_sp->GetChildAtIndex(0, true);
if (child0_sp && child0_sp->GetName() == g___cc)
- potential_child_sp = child0_sp;
+ potential_child_sp = child0_sp->Clone(ConstString(name.GetString()));
break;
}
case 2: {
@@ -414,11 +414,10 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex(
auto child1_sp = potential_child_sp->GetChildAtIndex(1, true);
if (child0_sp && child0_sp->GetName() == g___cc && child1_sp &&
child1_sp->GetName() == g___nc)
- potential_child_sp = child0_sp;
+ potential_child_sp = child0_sp->Clone(ConstString(name.GetString()));
break;
}
}
- potential_child_sp->SetName(ConstString(name.GetString()));
}
m_iterators[idx] = iterator;
return potential_child_sp;
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
index 5fe4b3a9fc9e..c3566b7c6bfb 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -13,15 +13,15 @@
// Project includes
#include "LibCxx.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp b/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
index b5c9b6d0f11e..2843201e2ed9 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
@@ -13,9 +13,9 @@
// Project includes
#include "LibCxx.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/Utility/ConstString.h"
using namespace lldb;
using namespace lldb_private;
@@ -45,6 +45,29 @@ private:
CompilerType m_element_type;
uint32_t m_element_size;
};
+
+class LibcxxVectorBoolSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
+public:
+ LibcxxVectorBoolSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
+
+ size_t CalculateNumChildren() override;
+
+ lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
+
+ bool Update() override;
+
+ bool MightHaveChildren() override { return true; }
+
+ size_t GetIndexOfChildWithName(const ConstString &name) override;
+
+private:
+ CompilerType m_bool_type;
+ ExecutionContextRef m_exe_ctx_ref;
+ uint64_t m_count;
+ lldb::addr_t m_base_data_address;
+ std::map<size_t, lldb::ValueObjectSP> m_children;
+};
+
} // namespace formatters
} // namespace lldb_private
@@ -133,9 +156,126 @@ size_t lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::
return ExtractIndexFromString(name.GetCString());
}
+lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
+ LibcxxVectorBoolSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
+ : SyntheticChildrenFrontEnd(*valobj_sp), m_bool_type(), m_exe_ctx_ref(),
+ m_count(0), m_base_data_address(0), m_children() {
+ if (valobj_sp) {
+ Update();
+ m_bool_type =
+ valobj_sp->GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeBool);
+ }
+}
+
+size_t lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
+ CalculateNumChildren() {
+ return m_count;
+}
+
+lldb::ValueObjectSP
+lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::GetChildAtIndex(
+ size_t idx) {
+ auto iter = m_children.find(idx), end = m_children.end();
+ if (iter != end)
+ return iter->second;
+ if (idx >= m_count)
+ return ValueObjectSP();
+ if (m_base_data_address == 0 || m_count == 0)
+ return ValueObjectSP();
+ if (!m_bool_type)
+ return ValueObjectSP();
+ size_t byte_idx = (idx >> 3); // divide by 8 to get byte index
+ size_t bit_index = (idx & 7); // efficient idx % 8 for bit index
+ lldb::addr_t byte_location = m_base_data_address + byte_idx;
+ ProcessSP process_sp(m_exe_ctx_ref.GetProcessSP());
+ if (!process_sp)
+ return ValueObjectSP();
+ uint8_t byte = 0;
+ uint8_t mask = 0;
+ Error err;
+ size_t bytes_read = process_sp->ReadMemory(byte_location, &byte, 1, err);
+ if (err.Fail() || bytes_read == 0)
+ return ValueObjectSP();
+ mask = 1 << bit_index;
+ bool bit_set = ((byte & mask) != 0);
+ DataBufferSP buffer_sp(
+ new DataBufferHeap(m_bool_type.GetByteSize(nullptr), 0));
+ if (bit_set && buffer_sp && buffer_sp->GetBytes()) {
+ // regardless of endianness, anything non-zero is true
+ *(buffer_sp->GetBytes()) = 1;
+ }
+ StreamString name;
+ name.Printf("[%" PRIu64 "]", (uint64_t)idx);
+ ValueObjectSP retval_sp(CreateValueObjectFromData(
+ name.GetString(),
+ DataExtractor(buffer_sp, process_sp->GetByteOrder(),
+ process_sp->GetAddressByteSize()),
+ m_exe_ctx_ref, m_bool_type));
+ if (retval_sp)
+ m_children[idx] = retval_sp;
+ return retval_sp;
+}
+
+/*(std::__1::vector<std::__1::allocator<bool> >) vBool = {
+ __begin_ = 0x00000001001000e0
+ __size_ = 56
+ __cap_alloc_ = {
+ std::__1::__libcpp_compressed_pair_imp<unsigned long,
+ std::__1::allocator<unsigned long> > = {
+ __first_ = 1
+ }
+ }
+ }*/
+
+bool lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::Update() {
+ m_children.clear();
+ ValueObjectSP valobj_sp = m_backend.GetSP();
+ if (!valobj_sp)
+ return false;
+ m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
+ ValueObjectSP size_sp(
+ valobj_sp->GetChildMemberWithName(ConstString("__size_"), true));
+ if (!size_sp)
+ return false;
+ m_count = size_sp->GetValueAsUnsigned(0);
+ if (!m_count)
+ return true;
+ ValueObjectSP begin_sp(
+ valobj_sp->GetChildMemberWithName(ConstString("__begin_"), true));
+ if (!begin_sp) {
+ m_count = 0;
+ return false;
+ }
+ m_base_data_address = begin_sp->GetValueAsUnsigned(0);
+ if (!m_base_data_address) {
+ m_count = 0;
+ return false;
+ }
+ return false;
+}
+
+size_t lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
+ GetIndexOfChildWithName(const ConstString &name) {
+ if (!m_count || !m_base_data_address)
+ return UINT32_MAX;
+ const char *item_name = name.GetCString();
+ uint32_t idx = ExtractIndexFromString(item_name);
+ if (idx < UINT32_MAX && idx >= CalculateNumChildren())
+ return UINT32_MAX;
+ return idx;
+}
+
lldb_private::SyntheticChildrenFrontEnd *
lldb_private::formatters::LibcxxStdVectorSyntheticFrontEndCreator(
CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
- return (valobj_sp ? new LibcxxStdVectorSyntheticFrontEnd(valobj_sp)
- : nullptr);
+ if (!valobj_sp)
+ return nullptr;
+ CompilerType type = valobj_sp->GetCompilerType();
+ if (!type.IsValid() || type.GetNumTemplateArguments() == 0)
+ return nullptr;
+ TemplateArgumentKind kind;
+ CompilerType arg_type = type.GetTemplateArgument(0, kind);
+ if (arg_type.GetTypeName() == ConstString("bool"))
+ return new LibcxxVectorBoolSyntheticFrontEnd(valobj_sp);
+ return new LibcxxStdVectorSyntheticFrontEnd(valobj_sp);
}
diff --git a/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
index f931a8d6a046..a4633db8157e 100644
--- a/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
@@ -13,16 +13,16 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/DataFormatters/VectorIterator.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/Language/CPlusPlus/LibStdcpp.h b/source/Plugins/Language/CPlusPlus/LibStdcpp.h
index 72e169f50395..1400477dcd0d 100644
--- a/source/Plugins/Language/CPlusPlus/LibStdcpp.h
+++ b/source/Plugins/Language/CPlusPlus/LibStdcpp.h
@@ -10,10 +10,10 @@
#ifndef liblldb_LibStdCpp_h_
#define liblldb_LibStdCpp_h_
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
+#include "lldb/Utility/Stream.h"
namespace lldb_private {
namespace formatters {
diff --git a/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp b/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
index c4a6e3d227b0..943af6ee81e4 100644
--- a/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
@@ -9,10 +9,10 @@
#include "LibStdcpp.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
+#include "lldb/Utility/ConstString.h"
#include <memory>
#include <vector>
@@ -73,9 +73,7 @@ bool LibStdcppTupleSyntheticFrontEnd::Update() {
if (value_sp) {
StreamString name;
name.Printf("[%zd]", m_members.size());
- value_sp->SetName(ConstString(name.GetString()));
-
- m_members.push_back(value_sp);
+ m_members.push_back(value_sp->Clone(ConstString(name.GetString())));
}
}
}
diff --git a/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp b/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
index 4eb3b95afb4e..7693961cae17 100644
--- a/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
@@ -9,10 +9,10 @@
#include "LibStdcpp.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
+#include "lldb/Utility/ConstString.h"
#include <memory>
#include <vector>
@@ -70,19 +70,19 @@ bool LibStdcppUniquePtrSyntheticFrontEnd::Update() {
std::unique_ptr<SyntheticChildrenFrontEnd> tuple_frontend(
LibStdcppTupleSyntheticFrontEndCreator(nullptr, tuple_sp));
- m_ptr_obj = tuple_frontend->GetChildAtIndex(0);
- if (m_ptr_obj)
- m_ptr_obj->SetName(ConstString("pointer"));
+ ValueObjectSP ptr_obj = tuple_frontend->GetChildAtIndex(0);
+ if (ptr_obj)
+ m_ptr_obj = ptr_obj->Clone(ConstString("pointer"));
- m_del_obj = tuple_frontend->GetChildAtIndex(1);
- if (m_del_obj)
- m_del_obj->SetName(ConstString("deleter"));
+ ValueObjectSP del_obj = tuple_frontend->GetChildAtIndex(1);
+ if (del_obj)
+ m_del_obj = del_obj->Clone(ConstString("deleter"));
if (m_ptr_obj) {
Error error;
- m_obj_obj = m_ptr_obj->Dereference(error);
+ ValueObjectSP obj_obj = m_ptr_obj->Dereference(error);
if (error.Success()) {
- m_obj_obj->SetName(ConstString("object"));
+ m_obj_obj = obj_obj->Clone(ConstString("object"));
}
}
@@ -94,29 +94,28 @@ bool LibStdcppUniquePtrSyntheticFrontEnd::MightHaveChildren() { return true; }
lldb::ValueObjectSP
LibStdcppUniquePtrSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
if (idx == 0)
- return m_obj_obj;
+ return m_ptr_obj;
if (idx == 1)
return m_del_obj;
if (idx == 2)
- return m_ptr_obj;
+ return m_obj_obj;
return lldb::ValueObjectSP();
}
size_t LibStdcppUniquePtrSyntheticFrontEnd::CalculateNumChildren() {
if (m_del_obj)
return 2;
- if (m_ptr_obj && m_ptr_obj->GetValueAsUnsigned(0) != 0)
- return 1;
- return 0;
+ return 1;
}
size_t LibStdcppUniquePtrSyntheticFrontEnd::GetIndexOfChildWithName(
const ConstString &name) {
- if (name == ConstString("obj") || name == ConstString("object"))
+ if (name == ConstString("ptr") || name == ConstString("pointer"))
return 0;
if (name == ConstString("del") || name == ConstString("deleter"))
return 1;
- if (name == ConstString("ptr") || name == ConstString("pointer"))
+ if (name == ConstString("obj") || name == ConstString("object") ||
+ name == ConstString("$$dereference$$"))
return 2;
return UINT32_MAX;
}
diff --git a/source/Plugins/Language/Go/CMakeLists.txt b/source/Plugins/Language/Go/CMakeLists.txt
index f3a9c12b7523..793e417a618a 100644
--- a/source/Plugins/Language/Go/CMakeLists.txt
+++ b/source/Plugins/Language/Go/CMakeLists.txt
@@ -1,4 +1,13 @@
-add_lldb_library(lldbPluginGoLanguage
+add_lldb_library(lldbPluginGoLanguage PLUGIN
GoLanguage.cpp
GoFormatterFunctions.cpp
+
+ LINK_LIBS
+ clangAST
+ lldbCore
+ lldbDataFormatters
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/Language/Go/GoFormatterFunctions.h b/source/Plugins/Language/Go/GoFormatterFunctions.h
index 596eb2ae71f6..1bf1892d6669 100644
--- a/source/Plugins/Language/Go/GoFormatterFunctions.h
+++ b/source/Plugins/Language/Go/GoFormatterFunctions.h
@@ -21,12 +21,12 @@
// Project includes
#include "lldb/lldb-forward.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/DataFormatters/FormatClasses.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/ConstString.h"
namespace lldb_private {
namespace formatters {
diff --git a/source/Plugins/Language/Go/GoLanguage.cpp b/source/Plugins/Language/Go/GoLanguage.cpp
index 85c41d1fe917..66b4530abc76 100644
--- a/source/Plugins/Language/Go/GoLanguage.cpp
+++ b/source/Plugins/Language/Go/GoLanguage.cpp
@@ -15,14 +15,15 @@
// Other libraries and framework includes
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Threading.h"
// Project includes
#include "GoLanguage.h"
#include "Plugins/Language/Go/GoFormatterFunctions.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Symbol/GoASTContext.h"
+#include "lldb/Utility/ConstString.h"
using namespace lldb;
using namespace lldb_private;
@@ -62,10 +63,10 @@ Language *GoLanguage::CreateInstance(lldb::LanguageType language) {
HardcodedFormatters::HardcodedSummaryFinder
GoLanguage::GetHardcodedSummaries() {
- static std::once_flag g_initialize;
+ static llvm::once_flag g_initialize;
static HardcodedFormatters::HardcodedSummaryFinder g_formatters;
- std::call_once(g_initialize, []() -> void {
+ llvm::call_once(g_initialize, []() -> void {
g_formatters.push_back(
[](lldb_private::ValueObject &valobj, lldb::DynamicValueType,
FormatManager &) -> TypeSummaryImpl::SharedPointer {
@@ -104,10 +105,10 @@ GoLanguage::GetHardcodedSummaries() {
HardcodedFormatters::HardcodedSyntheticFinder
GoLanguage::GetHardcodedSynthetics() {
- static std::once_flag g_initialize;
+ static llvm::once_flag g_initialize;
static HardcodedFormatters::HardcodedSyntheticFinder g_formatters;
- std::call_once(g_initialize, []() -> void {
+ llvm::call_once(g_initialize, []() -> void {
g_formatters.push_back(
[](lldb_private::ValueObject &valobj, lldb::DynamicValueType,
FormatManager &fmt_mgr) -> SyntheticChildren::SharedPointer {
diff --git a/source/Plugins/Language/Go/GoLanguage.h b/source/Plugins/Language/Go/GoLanguage.h
index 4dc8ed0745c4..ebec1d7205fa 100644
--- a/source/Plugins/Language/Go/GoLanguage.h
+++ b/source/Plugins/Language/Go/GoLanguage.h
@@ -18,8 +18,8 @@
#include "llvm/ADT/StringRef.h"
// Project includes
-#include "lldb/Core/ConstString.h"
#include "lldb/Target/Language.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/source/Plugins/Language/Java/CMakeLists.txt b/source/Plugins/Language/Java/CMakeLists.txt
index 80f7b08e7b65..f0cbcd8d3f59 100644
--- a/source/Plugins/Language/Java/CMakeLists.txt
+++ b/source/Plugins/Language/Java/CMakeLists.txt
@@ -1,4 +1,12 @@
-add_lldb_library(lldbPluginJavaLanguage
+add_lldb_library(lldbPluginJavaLanguage PLUGIN
JavaFormatterFunctions.cpp
JavaLanguage.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbDataFormatters
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/Language/Java/JavaLanguage.cpp b/source/Plugins/Language/Java/JavaLanguage.cpp
index f58b51f53e76..b17862f0b6a2 100644
--- a/source/Plugins/Language/Java/JavaLanguage.cpp
+++ b/source/Plugins/Language/Java/JavaLanguage.cpp
@@ -15,15 +15,16 @@
// Other libraries and framework includes
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Threading.h"
// Project includes
#include "JavaFormatterFunctions.h"
#include "JavaLanguage.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Symbol/JavaASTContext.h"
+#include "lldb/Utility/ConstString.h"
using namespace lldb;
using namespace lldb_private;
@@ -64,10 +65,10 @@ bool JavaLanguage::IsNilReference(ValueObject &valobj) {
}
lldb::TypeCategoryImplSP JavaLanguage::GetFormatters() {
- static std::once_flag g_initialize;
+ static llvm::once_flag g_initialize;
static TypeCategoryImplSP g_category;
- std::call_once(g_initialize, [this]() -> void {
+ llvm::call_once(g_initialize, [this]() -> void {
DataVisualization::Categories::GetCategory(GetPluginName(), g_category);
if (g_category) {
llvm::StringRef array_regexp("^.*\\[\\]&?$");
diff --git a/source/Plugins/Language/Java/JavaLanguage.h b/source/Plugins/Language/Java/JavaLanguage.h
index 6cf27ab5ffa4..5b652502a3d1 100644
--- a/source/Plugins/Language/Java/JavaLanguage.h
+++ b/source/Plugins/Language/Java/JavaLanguage.h
@@ -18,8 +18,8 @@
#include "llvm/ADT/StringRef.h"
// Project includes
-#include "lldb/Core/ConstString.h"
#include "lldb/Target/Language.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/source/Plugins/Language/OCaml/CMakeLists.txt b/source/Plugins/Language/OCaml/CMakeLists.txt
index e969618d5e0c..e779ae2acd08 100644
--- a/source/Plugins/Language/OCaml/CMakeLists.txt
+++ b/source/Plugins/Language/OCaml/CMakeLists.txt
@@ -1,4 +1,12 @@
-add_lldb_library(lldbPluginOCamlLanguage
+add_lldb_library(lldbPluginOCamlLanguage PLUGIN
OCamlLanguage.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbDataFormatters
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/Language/OCaml/OCamlLanguage.cpp b/source/Plugins/Language/OCaml/OCamlLanguage.cpp
index ef9f2b567929..ec24a36fe8f3 100644
--- a/source/Plugins/Language/OCaml/OCamlLanguage.cpp
+++ b/source/Plugins/Language/OCaml/OCamlLanguage.cpp
@@ -19,11 +19,11 @@
// Project includes
#include "OCamlLanguage.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Symbol/OCamlASTContext.h"
+#include "lldb/Utility/ConstString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/Language/OCaml/OCamlLanguage.h b/source/Plugins/Language/OCaml/OCamlLanguage.h
index f7dc6398eafe..21837fe5add4 100644
--- a/source/Plugins/Language/OCaml/OCamlLanguage.h
+++ b/source/Plugins/Language/OCaml/OCamlLanguage.h
@@ -19,8 +19,8 @@
#include "llvm/ADT/StringRef.h"
// Project includes
-#include "lldb/Core/ConstString.h"
#include "lldb/Target/Language.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/source/Plugins/Language/ObjC/CF.cpp b/source/Plugins/Language/ObjC/CF.cpp
index f67db465f72c..a75c034afa9f 100644
--- a/source/Plugins/Language/ObjC/CF.cpp
+++ b/source/Plugins/Language/ObjC/CF.cpp
@@ -10,18 +10,18 @@
#include "CF.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/Language/ObjC/CF.h b/source/Plugins/Language/ObjC/CF.h
index ea47267db939..6945f9e8c9b1 100644
--- a/source/Plugins/Language/ObjC/CF.h
+++ b/source/Plugins/Language/ObjC/CF.h
@@ -10,9 +10,9 @@
#ifndef liblldb_CF_h_
#define liblldb_CF_h_
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/Utility/Stream.h"
namespace lldb_private {
namespace formatters {
diff --git a/source/Plugins/Language/ObjC/CMakeLists.txt b/source/Plugins/Language/ObjC/CMakeLists.txt
index 5c480a1aed11..7cc93c7b0558 100644
--- a/source/Plugins/Language/ObjC/CMakeLists.txt
+++ b/source/Plugins/Language/ObjC/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_lldb_library(lldbPluginObjCLanguage
+add_lldb_library(lldbPluginObjCLanguage PLUGIN
ObjCLanguage.cpp
CF.cpp
Cocoa.cpp
@@ -10,4 +10,15 @@ add_lldb_library(lldbPluginObjCLanguage
NSIndexPath.cpp
NSSet.cpp
NSString.cpp
+
+ LINK_LIBS
+ clangAST
+ lldbCore
+ lldbDataFormatters
+ lldbExpression
+ lldbHost
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ lldbPluginAppleObjCRuntime
)
diff --git a/source/Plugins/Language/ObjC/Cocoa.cpp b/source/Plugins/Language/ObjC/Cocoa.cpp
index b2ad8c375833..0fc690606d16 100644
--- a/source/Plugins/Language/ObjC/Cocoa.cpp
+++ b/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -13,22 +13,23 @@
// Project includes
#include "Cocoa.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/Mangled.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/StringPrinter.h"
#include "lldb/DataFormatters/TypeSummary.h"
-#include "lldb/Host/Endian.h"
+#include "lldb/Host/Time.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/Target.h"
-#include "lldb/Utility/ProcessStructReader.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
diff --git a/source/Plugins/Language/ObjC/Cocoa.h b/source/Plugins/Language/ObjC/Cocoa.h
index 491a1196e63d..10ff3bce3b98 100644
--- a/source/Plugins/Language/ObjC/Cocoa.h
+++ b/source/Plugins/Language/ObjC/Cocoa.h
@@ -11,11 +11,11 @@
#ifndef liblldb_Cocoa_h_
#define liblldb_Cocoa_h_
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Utility/Stream.h"
namespace lldb_private {
namespace formatters {
diff --git a/source/Plugins/Language/ObjC/CoreMedia.cpp b/source/Plugins/Language/ObjC/CoreMedia.cpp
index dacbf78755e0..cbc38c907953 100644
--- a/source/Plugins/Language/ObjC/CoreMedia.cpp
+++ b/source/Plugins/Language/ObjC/CoreMedia.cpp
@@ -10,7 +10,8 @@
#include "CoreMedia.h"
-#include "lldb/Core/Flags.h"
+#include "lldb/Utility/Flags.h"
+
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/Target.h"
#include <inttypes.h>
diff --git a/source/Plugins/Language/ObjC/CoreMedia.h b/source/Plugins/Language/ObjC/CoreMedia.h
index 20de792fc96c..98561efbf7ed 100644
--- a/source/Plugins/Language/ObjC/CoreMedia.h
+++ b/source/Plugins/Language/ObjC/CoreMedia.h
@@ -11,9 +11,9 @@
#ifndef liblldb_CoreMedia_h_
#define liblldb_CoreMedia_h_
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/Utility/Stream.h"
namespace lldb_private {
namespace formatters {
diff --git a/source/Plugins/Language/ObjC/NSArray.cpp b/source/Plugins/Language/ObjC/NSArray.cpp
index 6ab6d537bb21..79773fdf1d15 100644
--- a/source/Plugins/Language/ObjC/NSArray.cpp
+++ b/source/Plugins/Language/ObjC/NSArray.cpp
@@ -16,18 +16,18 @@
#include "Cocoa.h"
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Expression/FunctionCaller.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/Language/ObjC/NSDictionary.cpp b/source/Plugins/Language/ObjC/NSDictionary.cpp
index 5cc52c820b65..672cc1a26f4e 100644
--- a/source/Plugins/Language/ObjC/NSDictionary.cpp
+++ b/source/Plugins/Language/ObjC/NSDictionary.cpp
@@ -17,18 +17,18 @@
// Project includes
#include "NSDictionary.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/Language/ObjC/NSDictionary.h b/source/Plugins/Language/ObjC/NSDictionary.h
index 10318a5bf621..6ec9a8eebe13 100644
--- a/source/Plugins/Language/ObjC/NSDictionary.h
+++ b/source/Plugins/Language/ObjC/NSDictionary.h
@@ -11,11 +11,11 @@
#ifndef liblldb_NSDictionary_h_
#define liblldb_NSDictionary_h_
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Stream.h"
#include <map>
#include <memory>
diff --git a/source/Plugins/Language/ObjC/NSError.cpp b/source/Plugins/Language/ObjC/NSError.cpp
index bad22b13a005..e8044d3b0013 100644
--- a/source/Plugins/Language/ObjC/NSError.cpp
+++ b/source/Plugins/Language/ObjC/NSError.cpp
@@ -15,18 +15,17 @@
// Project includes
#include "Cocoa.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/Target.h"
-
-#include "lldb/Utility/ProcessStructReader.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
#include "Plugins/Language/ObjC/NSString.h"
diff --git a/source/Plugins/Language/ObjC/NSException.cpp b/source/Plugins/Language/ObjC/NSException.cpp
index 1609048d432c..aa86e207783d 100644
--- a/source/Plugins/Language/ObjC/NSException.cpp
+++ b/source/Plugins/Language/ObjC/NSException.cpp
@@ -15,18 +15,17 @@
// Project includes
#include "Cocoa.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/Target.h"
-
-#include "lldb/Utility/ProcessStructReader.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
#include "Plugins/Language/ObjC/NSString.h"
diff --git a/source/Plugins/Language/ObjC/NSSet.cpp b/source/Plugins/Language/ObjC/NSSet.cpp
index 9757c5877782..adefba902b61 100644
--- a/source/Plugins/Language/ObjC/NSSet.cpp
+++ b/source/Plugins/Language/ObjC/NSSet.cpp
@@ -13,17 +13,17 @@
// Project includes
#include "NSSet.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/Language/ObjC/NSSet.h b/source/Plugins/Language/ObjC/NSSet.h
index dbc5dfa7e659..00451be6c7f3 100644
--- a/source/Plugins/Language/ObjC/NSSet.h
+++ b/source/Plugins/Language/ObjC/NSSet.h
@@ -11,11 +11,11 @@
#ifndef liblldb_NSSet_h_
#define liblldb_NSSet_h_
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Stream.h"
namespace lldb_private {
namespace formatters {
diff --git a/source/Plugins/Language/ObjC/NSString.cpp b/source/Plugins/Language/ObjC/NSString.cpp
index 4f1addccecaa..d0258be8211e 100644
--- a/source/Plugins/Language/ObjC/NSString.cpp
+++ b/source/Plugins/Language/ObjC/NSString.cpp
@@ -10,18 +10,18 @@
#include "NSString.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/StringPrinter.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
+#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/Target.h"
-#include "lldb/Utility/ProcessStructReader.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/Language/ObjC/NSString.h b/source/Plugins/Language/ObjC/NSString.h
index df8480ad6cd8..3a923c2be6ac 100644
--- a/source/Plugins/Language/ObjC/NSString.h
+++ b/source/Plugins/Language/ObjC/NSString.h
@@ -11,10 +11,10 @@
#ifndef liblldb_NSString_h_
#define liblldb_NSString_h_
-#include "lldb/Core/Stream.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Utility/Stream.h"
namespace lldb_private {
namespace formatters {
diff --git a/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/source/Plugins/Language/ObjC/ObjCLanguage.cpp
index 6e59a8be3fea..193c5864d01f 100644
--- a/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ b/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -15,9 +15,7 @@
// Project includes
#include "ObjCLanguage.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
@@ -25,6 +23,10 @@
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/StreamString.h"
+
+#include "llvm/Support/Threading.h"
#include "CF.h"
#include "Cocoa.h"
@@ -857,10 +859,10 @@ static void LoadCoreMediaFormatters(TypeCategoryImplSP objc_category_sp) {
}
lldb::TypeCategoryImplSP ObjCLanguage::GetFormatters() {
- static std::once_flag g_initialize;
+ static llvm::once_flag g_initialize;
static TypeCategoryImplSP g_category;
- std::call_once(g_initialize, [this]() -> void {
+ llvm::call_once(g_initialize, [this]() -> void {
DataVisualization::Categories::GetCategory(GetPluginName(), g_category);
if (g_category) {
LoadCoreMediaFormatters(g_category);
diff --git a/source/Plugins/Language/ObjC/ObjCLanguage.h b/source/Plugins/Language/ObjC/ObjCLanguage.h
index b458b58998b6..9782c5da0d67 100644
--- a/source/Plugins/Language/ObjC/ObjCLanguage.h
+++ b/source/Plugins/Language/ObjC/ObjCLanguage.h
@@ -17,8 +17,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
#include "lldb/Target/Language.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/source/Plugins/Language/ObjCPlusPlus/CMakeLists.txt b/source/Plugins/Language/ObjCPlusPlus/CMakeLists.txt
index ef80af74107b..75df9794d75d 100644
--- a/source/Plugins/Language/ObjCPlusPlus/CMakeLists.txt
+++ b/source/Plugins/Language/ObjCPlusPlus/CMakeLists.txt
@@ -1,3 +1,7 @@
-add_lldb_library(lldbPluginObjCPlusPlusLanguage
+add_lldb_library(lldbPluginObjCPlusPlusLanguage PLUGIN
ObjCPlusPlusLanguage.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbTarget
)
diff --git a/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp b/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
index cb73eef54682..bfc22c9ee650 100644
--- a/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
+++ b/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
@@ -10,8 +10,8 @@
#include "ObjCPlusPlusLanguage.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/PluginManager.h"
+#include "lldb/Utility/ConstString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt b/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt
index d25215d0a613..14d1f46caebb 100644
--- a/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt
+++ b/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginCXXItaniumABI
+add_lldb_library(lldbPluginCXXItaniumABI PLUGIN
ItaniumABILanguageRuntime.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
)
diff --git a/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp b/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
index ddfbd864e92c..e308747378d3 100644
--- a/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
+++ b/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
@@ -11,9 +11,6 @@
#include "ItaniumABILanguageRuntime.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Mangled.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
@@ -33,6 +30,9 @@
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
#include <vector>
diff --git a/source/Plugins/LanguageRuntime/Go/CMakeLists.txt b/source/Plugins/LanguageRuntime/Go/CMakeLists.txt
index 7c9166a94cbe..16756d5c985a 100644
--- a/source/Plugins/LanguageRuntime/Go/CMakeLists.txt
+++ b/source/Plugins/LanguageRuntime/Go/CMakeLists.txt
@@ -1,5 +1,13 @@
set(LLVM_NO_RTTI 1)
-add_lldb_library(lldbPluginLanguageRuntimeGo
+add_lldb_library(lldbPluginLanguageRuntimeGo PLUGIN
GoLanguageRuntime.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.cpp b/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.cpp
index 1450835298e6..c52fc1e121d8 100644
--- a/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.cpp
+++ b/source/Plugins/LanguageRuntime/Go/GoLanguageRuntime.cpp
@@ -11,9 +11,6 @@
#include "GoLanguageRuntime.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Scalar.h"
@@ -29,6 +26,9 @@
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
#include "llvm/ADT/Twine.h"
#include <vector>
diff --git a/source/Plugins/LanguageRuntime/Java/CMakeLists.txt b/source/Plugins/LanguageRuntime/Java/CMakeLists.txt
index 4cfd71c2e242..ec87718752e7 100644
--- a/source/Plugins/LanguageRuntime/Java/CMakeLists.txt
+++ b/source/Plugins/LanguageRuntime/Java/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginLanguageRuntimeJava
+add_lldb_library(lldbPluginLanguageRuntimeJava PLUGIN
JavaLanguageRuntime.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
index 131f31f69a9f..6b5e6b1eb764 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
@@ -10,8 +10,8 @@
#include "AppleObjCClassDescriptorV2.h"
-#include "lldb/Core/Log.h"
#include "lldb/Expression/FunctionCaller.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
@@ -501,10 +501,8 @@ void ClassDescriptorV2::iVarsStorage::fill(AppleObjCRuntimeV2 &runtime,
if (m_filled)
return;
std::lock_guard<std::recursive_mutex> guard(m_mutex);
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES | LIBLLDB_LOG_VERBOSE));
- if (log)
- log->Printf("[ClassDescriptorV2::iVarsStorage::fill] class_name = %s",
- descriptor.GetClassName().AsCString("<unknown"));
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES));
+ LLDB_LOGV(log, "class_name = {0}", descriptor.GetClassName());
m_filled = true;
ObjCLanguageRuntime::EncodingToTypeSP encoding_to_type_sp(
runtime.GetEncodingToType());
@@ -519,19 +517,15 @@ void ClassDescriptorV2::iVarsStorage::fill(AppleObjCRuntimeV2 &runtime,
uint64_t size) -> bool {
const bool for_expression = false;
const bool stop_loop = false;
- if (log)
- log->Printf("[ClassDescriptorV2::iVarsStorage::fill] name = %s, encoding "
- "= %s, offset_ptr = %" PRIx64 ", size = %" PRIu64,
- name, type, offset_ptr, size);
+ LLDB_LOGV(log, "name = {0}, encoding = {1}, offset_ptr = {2:x}, size = {3}",
+ name, type, offset_ptr, size);
CompilerType ivar_type =
encoding_to_type_sp->RealizeType(type, for_expression);
if (ivar_type) {
- if (log)
- log->Printf("[ClassDescriptorV2::iVarsStorage::fill] name = %s, "
- "encoding = %s, offset_ptr = %" PRIx64 ", size = %" PRIu64
- " , type_size = %" PRIu64,
- name, type, offset_ptr, size,
- ivar_type.GetByteSize(nullptr));
+ LLDB_LOGV(log,
+ "name = {0}, encoding = {1}, offset_ptr = {2:x}, size = "
+ "{3}, type_size = {4}",
+ name, type, offset_ptr, size, ivar_type.GetByteSize(nullptr));
Scalar offset_scalar;
Error error;
const int offset_ptr_size = 4;
@@ -539,18 +533,13 @@ void ClassDescriptorV2::iVarsStorage::fill(AppleObjCRuntimeV2 &runtime,
size_t read = process->ReadScalarIntegerFromMemory(
offset_ptr, offset_ptr_size, is_signed, offset_scalar, error);
if (error.Success() && 4 == read) {
- if (log)
- log->Printf(
- "[ClassDescriptorV2::iVarsStorage::fill] offset_ptr = %" PRIx64
- " --> %" PRIu32,
- offset_ptr, offset_scalar.SInt());
+ LLDB_LOGV(log, "offset_ptr = {0:x} --> {1}", offset_ptr,
+ offset_scalar.SInt());
m_ivars.push_back(
{ConstString(name), ivar_type, size, offset_scalar.SInt()});
- } else if (log)
- log->Printf(
- "[ClassDescriptorV2::iVarsStorage::fill] offset_ptr = %" PRIx64
- " --> read fail, read = %zu",
- offset_ptr, read);
+ } else
+ LLDB_LOGV(log, "offset_ptr = {0:x} --> read fail, read = %{1}",
+ offset_ptr, read);
}
return stop_loop;
});
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
index 922d192c333c..07b4ae5e0add 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
@@ -10,13 +10,13 @@
#include "AppleObjCDeclVendor.h"
#include "Plugins/ExpressionParser/Clang/ASTDumper.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h"
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index 4a90f5c16633..6b27009a0727 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -14,15 +14,11 @@
#include "clang/AST/Type.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
@@ -34,6 +30,10 @@
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
#include <vector>
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
index 13bd245a33b4..2c92b922b9df 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
@@ -15,13 +15,9 @@
#include "clang/AST/Type.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Scalar.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/UtilityFunction.h"
#include "lldb/Symbol/ClangASTContext.h"
@@ -31,6 +27,10 @@
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
#include <vector>
@@ -127,7 +127,7 @@ struct BufStruct {
UtilityFunction *AppleObjCRuntimeV1::CreateObjectChecker(const char *name) {
std::unique_ptr<BufStruct> buf(new BufStruct);
- assert(snprintf(&buf->contents[0], sizeof(buf->contents),
+ int strformatsize = snprintf(&buf->contents[0], sizeof(buf->contents),
"struct __objc_class "
" \n"
"{ "
@@ -169,7 +169,8 @@ UtilityFunction *AppleObjCRuntimeV1::CreateObjectChecker(const char *name) {
" \n"
"} "
" \n",
- name) < (int)sizeof(buf->contents));
+ name);
+ assert(strformatsize < (int)sizeof(buf->contents));
Error error;
return GetTargetRef().GetUtilityFunctionForLanguage(
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index e9958a5ef759..42c5fe9248f6 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -20,26 +20,21 @@
// Project includes
#include "lldb/Core/ClangForward.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/Core/ClangForward.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/UtilityFunction.h"
-#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandObject.h"
#include "lldb/Interpreter/CommandObjectMultiword.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -55,6 +50,11 @@
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StreamString.h"
#include "AppleObjCClassDescriptorV2.h"
#include "AppleObjCDeclVendor.h"
@@ -600,14 +600,12 @@ protected:
}
iterator->second->Describe(
nullptr,
- [objc_runtime, &std_out](const char *name,
- const char *type) -> bool {
+ [&std_out](const char *name, const char *type) -> bool {
std_out.Printf(" instance method name = %s type = %s\n",
name, type);
return false;
},
- [objc_runtime, &std_out](const char *name,
- const char *type) -> bool {
+ [&std_out](const char *name, const char *type) -> bool {
std_out.Printf(" class method name = %s type = %s\n", name,
type);
return false;
@@ -895,6 +893,7 @@ UtilityFunction *AppleObjCRuntimeV2::CreateObjectChecker(const char *name) {
}
assert(len < (int)sizeof(check_function_code));
+ UNUSED_IF_ASSERT_DISABLED(len);
Error error;
return GetTargetRef().GetUtilityFunctionForLanguage(
@@ -1396,8 +1395,13 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic(
arguments.GetValueAtIndex(0)->GetScalar() = hash_table.GetTableLoadAddress();
arguments.GetValueAtIndex(1)->GetScalar() = class_infos_addr;
arguments.GetValueAtIndex(2)->GetScalar() = class_infos_byte_size;
- arguments.GetValueAtIndex(3)->GetScalar() =
- (GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES) == nullptr ? 0 : 1);
+
+ // Only dump the runtime classes from the expression evaluation if the
+ // log is verbose:
+ Log *type_log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES);
+ bool dump_log = type_log && type_log->GetVerbose();
+
+ arguments.GetValueAtIndex(3)->GetScalar() = dump_log ? 1 : 0;
bool success = false;
@@ -1640,8 +1644,12 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() {
arguments.GetValueAtIndex(0)->GetScalar() = objc_opt_ptr;
arguments.GetValueAtIndex(1)->GetScalar() = class_infos_addr;
arguments.GetValueAtIndex(2)->GetScalar() = class_infos_byte_size;
- arguments.GetValueAtIndex(3)->GetScalar() =
- (GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES) == nullptr ? 0 : 1);
+ // Only dump the runtime classes from the expression evaluation if the
+ // log is verbose:
+ Log *type_log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES);
+ bool dump_log = type_log && type_log->GetVerbose();
+
+ arguments.GetValueAtIndex(3)->GetScalar() = dump_log ? 1 : 0;
bool success = false;
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
index 1dc20c11567e..8ce65b07684f 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
@@ -17,9 +17,7 @@
#include "AppleThreadPlanStepThroughObjCTrampoline.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/Value.h"
@@ -27,7 +25,6 @@
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/UserExpression.h"
#include "lldb/Expression/UtilityFunction.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ABI.h"
@@ -38,6 +35,9 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanRunToAddress.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
#include "llvm/ADT/STLExtras.h"
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
index e49269532329..a295d1b4ce76 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
@@ -14,7 +14,6 @@
// Project includes
#include "AppleThreadPlanStepThroughObjCTrampoline.h"
#include "AppleObjCTrampolineHandler.h"
-#include "lldb/Core/Log.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/UtilityFunction.h"
@@ -24,6 +23,7 @@
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanRunToAddress.h"
#include "lldb/Target/ThreadPlanStepOut.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt
index 13fde3d181fa..18f3ae1c5b1e 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_lldb_library(lldbPluginAppleObjCRuntime
+add_lldb_library(lldbPluginAppleObjCRuntime PLUGIN
AppleObjCRuntime.cpp
AppleObjCRuntimeV1.cpp
AppleObjCRuntimeV2.cpp
@@ -7,4 +7,18 @@ add_lldb_library(lldbPluginAppleObjCRuntime
AppleThreadPlanStepThroughObjCTrampoline.cpp
AppleObjCClassDescriptorV2.cpp
AppleObjCTypeEncodingParser.cpp
+
+ LINK_LIBS
+ clangAST
+ lldbBreakpoint
+ lldbCore
+ lldbExpression
+ lldbHost
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ lldbPluginExpressionParserClang
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt
index cd08f14137dc..1a6c49946134 100644
--- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt
+++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt
@@ -3,7 +3,7 @@ if(NOT LLDB_BUILT_STANDALONE)
endif()
-add_lldb_library(lldbPluginRenderScriptRuntime
+add_lldb_library(lldbPluginRenderScriptRuntime PLUGIN
RenderScriptRuntime.cpp
RenderScriptExpressionOpts.cpp
RenderScriptx86ABIFixups.cpp
@@ -11,4 +11,20 @@ add_lldb_library(lldbPluginRenderScriptRuntime
DEPENDS
${tablegen_deps}
+
+ LINK_LIBS
+ clangBasic
+ lldbBreakpoint
+ lldbCore
+ lldbDataFormatters
+ lldbExpression
+ lldbHost
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Core
+ IRReader
+ Support
+ Target
)
diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
index b05618634868..654ac9abfcab 100644
--- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
+++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
@@ -25,9 +25,9 @@
#include "clang/Basic/TargetOptions.h"
// Project includes
-#include "lldb/Core/Log.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
#include "RenderScriptExpressionOpts.h"
#include "RenderScriptRuntime.h"
diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
index ae907ac8dfbb..638112b9ebde 100644
--- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -17,15 +17,14 @@
#include "RenderScriptScriptGroup.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Core/DumpDataExtractor.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegularExpression.h"
+#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/DataFormatters/DumpValueObjectOptions.h"
#include "lldb/Expression/UserExpression.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -41,6 +40,11 @@
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataBufferLLVM.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegularExpression.h"
using namespace lldb;
using namespace lldb_private;
@@ -2535,7 +2539,7 @@ bool RenderScriptRuntime::LoadAllocation(Stream &strm, const uint32_t alloc_id,
}
// Read file into data buffer
- DataBufferSP data_sp(file.ReadFileContents());
+ auto data_sp = DataBufferLLVM::CreateFromPath(file.GetPath());
// Cast start of buffer to FileHeader and use pointer to read metadata
void *file_buf = data_sp->GetBytes();
@@ -3073,7 +3077,7 @@ bool RSModuleDescriptor::ParseRSInfo() {
const addr_t size = info_sym->GetByteSize();
const FileSpec fs = m_module->GetFileSpec();
- const DataBufferSP buffer = fs.ReadFileContents(addr, size);
+ auto buffer = DataBufferLLVM::CreateSliceFromPath(fs.GetPath(), size, addr);
if (!buffer)
return false;
@@ -3128,9 +3132,8 @@ bool RSModuleDescriptor::ParseRSInfo() {
// in numeric fields at the moment
uint64_t n_lines;
if (val.getAsInteger(10, n_lines)) {
- if (log)
- log->Debug("Failed to parse non-numeric '.rs.info' section %s",
- line->str().c_str());
+ LLDB_LOGV(log, "Failed to parse non-numeric '.rs.info' section {0}",
+ line->str());
continue;
}
if (info_lines.end() - (line + 1) < (ptrdiff_t)n_lines)
@@ -3410,8 +3413,9 @@ bool RenderScriptRuntime::DumpAllocation(Stream &strm, StackFrame *frame_ptr,
// Print the results to our stream.
expr_result->Dump(strm, expr_options);
} else {
- alloc_data.Dump(&strm, offset, format, data_size - padding, 1, 1,
- LLDB_INVALID_ADDRESS, 0, 0);
+ DumpDataExtractor(alloc_data, &strm, offset, format,
+ data_size - padding, 1, 1, LLDB_INVALID_ADDRESS, 0,
+ 0);
}
offset += data_size;
}
diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp
index a8202dd08814..9ca8fb4444c0 100644
--- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp
+++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp
@@ -8,12 +8,8 @@
//===----------------------------------------------------------------------===//
#include "lldb/Breakpoint/StoppointCallbackContext.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandObjectMultiword.h"
@@ -24,6 +20,9 @@
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
#include "RenderScriptRuntime.h"
#include "RenderScriptScriptGroup.h"
diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
index aaca04582676..3ceda5ff67e9 100644
--- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
+++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
@@ -24,8 +24,8 @@
#include "llvm/Pass.h"
// Project includes
-#include "lldb/Core/Log.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/Log.h"
using namespace lldb_private;
namespace {
@@ -182,8 +182,10 @@ bool fixupX86StructRetCalls(llvm::Module &module) {
// we pass a pointer to this allocation as the StructRet param, and then
// copy its
// value into the lldb return value
+ const llvm::DataLayout &DL = module.getDataLayout();
llvm::AllocaInst *return_value_alloc = new llvm::AllocaInst(
- func->getReturnType(), "var_vector_return_alloc", call_inst);
+ func->getReturnType(), DL.getAllocaAddrSpace(), "var_vector_return_alloc",
+ call_inst);
// use the new allocation as the new first argument
new_call_args.emplace(new_call_args.begin(),
llvm::cast<llvm::Value>(return_value_alloc));
@@ -194,7 +196,8 @@ bool fixupX86StructRetCalls(llvm::Module &module) {
llvm::Instruction::BitCast, func, new_func_ptr_type);
// create an allocation for a new function pointer
llvm::AllocaInst *new_func_ptr =
- new llvm::AllocaInst(new_func_ptr_type, "new_func_ptr", call_inst);
+ new llvm::AllocaInst(new_func_ptr_type, DL.getAllocaAddrSpace(),
+ "new_func_ptr", call_inst);
// store the new_func_cast to the newly allocated space
(new llvm::StoreInst(new_func_cast, new_func_ptr, call_inst))
->setName("new_func_ptr_load_cast");
@@ -248,7 +251,7 @@ bool fixupRSAllocationStructByValCalls(llvm::Module &module) {
rs_functions.insert(call_inst->getCalledFunction());
// get the function attributes
- llvm::AttributeSet call_attribs = call_inst->getAttributes();
+ llvm::AttributeList call_attribs = call_inst->getAttributes();
// iterate over the argument attributes
for (size_t i = 1; i <= call_attribs.getNumSlots(); ++i) {
@@ -261,16 +264,12 @@ bool fixupRSAllocationStructByValCalls(llvm::Module &module) {
}
}
- llvm::AttributeSet attr_byval =
- llvm::AttributeSet::get(module.getContext(), 1u, llvm::Attribute::ByVal);
-
// for all called function decls
for (auto func : rs_functions) {
// inspect all of the arguments in the call
- llvm::SymbolTableList<llvm::Argument> &arg_list = func->getArgumentList();
- for (auto &arg : arg_list) {
+ for (auto &arg : func->args()) {
if (arg.hasByValAttr()) {
- arg.removeAttr(attr_byval);
+ arg.removeAttr(llvm::Attribute::ByVal);
changed = true;
}
}
diff --git a/source/Plugins/MemoryHistory/asan/CMakeLists.txt b/source/Plugins/MemoryHistory/asan/CMakeLists.txt
index 8bfe95e3680e..08deb75aabb1 100644
--- a/source/Plugins/MemoryHistory/asan/CMakeLists.txt
+++ b/source/Plugins/MemoryHistory/asan/CMakeLists.txt
@@ -1,3 +1,9 @@
-add_lldb_library(lldbPluginMemoryHistoryASan
+add_lldb_library(lldbPluginMemoryHistoryASan PLUGIN
MemoryHistoryASan.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbExpression
+ lldbTarget
+ lldbPluginProcessUtility
)
diff --git a/source/Plugins/ObjectContainer/BSD-Archive/CMakeLists.txt b/source/Plugins/ObjectContainer/BSD-Archive/CMakeLists.txt
index 68ebe885e3e9..acc13d31ca25 100644
--- a/source/Plugins/ObjectContainer/BSD-Archive/CMakeLists.txt
+++ b/source/Plugins/ObjectContainer/BSD-Archive/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginObjectContainerBSDArchive
+add_lldb_library(lldbPluginObjectContainerBSDArchive PLUGIN
ObjectContainerBSDArchive.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbSymbol
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
index 5bca1de89fbd..b74da3300170 100644
--- a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
+++ b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
@@ -28,14 +28,16 @@ typedef struct ar_hdr {
#endif
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataBuffer.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/Timer.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Utility/DataBufferLLVM.h"
+#include "lldb/Utility/Stream.h"
+
+#include "llvm/Support/MemoryBuffer.h"
using namespace lldb;
using namespace lldb_private;
@@ -290,62 +292,65 @@ ObjectContainer *ObjectContainerBSDArchive::CreateInstance(
lldb::offset_t data_offset, const FileSpec *file,
lldb::offset_t file_offset, lldb::offset_t length) {
ConstString object_name(module_sp->GetObjectName());
- if (object_name) {
- if (data_sp) {
- // We have data, which means this is the first 512 bytes of the file
- // Check to see if the magic bytes match and if they do, read the entire
- // table of contents for the archive and cache it
- DataExtractor data;
- data.SetData(data_sp, data_offset, length);
- if (file && data_sp && ObjectContainerBSDArchive::MagicBytesMatch(data)) {
- Timer scoped_timer(
- LLVM_PRETTY_FUNCTION,
- "ObjectContainerBSDArchive::CreateInstance (module = %s, file = "
- "%p, file_offset = 0x%8.8" PRIx64 ", file_size = 0x%8.8" PRIx64 ")",
- module_sp->GetFileSpec().GetPath().c_str(),
- static_cast<const void *>(file), static_cast<uint64_t>(file_offset),
- static_cast<uint64_t>(length));
+ if (!object_name)
+ return nullptr;
- // Map the entire .a file to be sure that we don't lose any data if the
- // file
- // gets updated by a new build while this .a file is being used for
- // debugging
- DataBufferSP archive_data_sp(
- file->MemoryMapFileContentsIfLocal(file_offset, length));
- lldb::offset_t archive_data_offset = 0;
+ if (data_sp) {
+ // We have data, which means this is the first 512 bytes of the file
+ // Check to see if the magic bytes match and if they do, read the entire
+ // table of contents for the archive and cache it
+ DataExtractor data;
+ data.SetData(data_sp, data_offset, length);
+ if (file && data_sp && ObjectContainerBSDArchive::MagicBytesMatch(data)) {
+ Timer scoped_timer(
+ LLVM_PRETTY_FUNCTION,
+ "ObjectContainerBSDArchive::CreateInstance (module = %s, file = "
+ "%p, file_offset = 0x%8.8" PRIx64 ", file_size = 0x%8.8" PRIx64 ")",
+ module_sp->GetFileSpec().GetPath().c_str(),
+ static_cast<const void *>(file), static_cast<uint64_t>(file_offset),
+ static_cast<uint64_t>(length));
- Archive::shared_ptr archive_sp(Archive::FindCachedArchive(
- *file, module_sp->GetArchitecture(),
- module_sp->GetModificationTime(), file_offset));
- std::unique_ptr<ObjectContainerBSDArchive> container_ap(
- new ObjectContainerBSDArchive(module_sp, archive_data_sp,
- archive_data_offset, file,
- file_offset, length));
+ // Map the entire .a file to be sure that we don't lose any data if the
+ // file gets updated by a new build while this .a file is being used for
+ // debugging
+ DataBufferSP archive_data_sp =
+ DataBufferLLVM::CreateSliceFromPath(file->GetPath(), length, file_offset);
+ if (!archive_data_sp)
+ return nullptr;
+
+ lldb::offset_t archive_data_offset = 0;
- if (container_ap.get()) {
- if (archive_sp) {
- // We already have this archive in our cache, use it
- container_ap->SetArchive(archive_sp);
- return container_ap.release();
- } else if (container_ap->ParseHeader())
- return container_ap.release();
- }
- }
- } else {
- // No data, just check for a cached archive
Archive::shared_ptr archive_sp(Archive::FindCachedArchive(
*file, module_sp->GetArchitecture(), module_sp->GetModificationTime(),
file_offset));
- if (archive_sp) {
- std::unique_ptr<ObjectContainerBSDArchive> container_ap(
- new ObjectContainerBSDArchive(module_sp, data_sp, data_offset, file,
- file_offset, length));
+ std::unique_ptr<ObjectContainerBSDArchive> container_ap(
+ new ObjectContainerBSDArchive(module_sp, archive_data_sp,
+ archive_data_offset, file, file_offset,
+ length));
- if (container_ap.get()) {
+ if (container_ap.get()) {
+ if (archive_sp) {
// We already have this archive in our cache, use it
container_ap->SetArchive(archive_sp);
return container_ap.release();
- }
+ } else if (container_ap->ParseHeader())
+ return container_ap.release();
+ }
+ }
+ } else {
+ // No data, just check for a cached archive
+ Archive::shared_ptr archive_sp(Archive::FindCachedArchive(
+ *file, module_sp->GetArchitecture(), module_sp->GetModificationTime(),
+ file_offset));
+ if (archive_sp) {
+ std::unique_ptr<ObjectContainerBSDArchive> container_ap(
+ new ObjectContainerBSDArchive(module_sp, data_sp, data_offset, file,
+ file_offset, length));
+
+ if (container_ap.get()) {
+ // We already have this archive in our cache, use it
+ container_ap->SetArchive(archive_sp);
+ return container_ap.release();
}
}
}
@@ -453,63 +458,64 @@ size_t ObjectContainerBSDArchive::GetModuleSpecifications(
// table of contents for the archive and cache it
DataExtractor data;
data.SetData(data_sp, data_offset, data_sp->GetByteSize());
- if (file && data_sp && ObjectContainerBSDArchive::MagicBytesMatch(data)) {
- const size_t initial_count = specs.GetSize();
- llvm::sys::TimePoint<> file_mod_time =
- FileSystem::GetModificationTime(file);
- Archive::shared_ptr archive_sp(Archive::FindCachedArchive(
- file, ArchSpec(), file_mod_time, file_offset));
- bool set_archive_arch = false;
- if (!archive_sp) {
- set_archive_arch = true;
- DataBufferSP data_sp(
- file.MemoryMapFileContentsIfLocal(file_offset, file_size));
+ if (!file || !data_sp || !ObjectContainerBSDArchive::MagicBytesMatch(data))
+ return 0;
+
+ const size_t initial_count = specs.GetSize();
+ llvm::sys::TimePoint<> file_mod_time = FileSystem::GetModificationTime(file);
+ Archive::shared_ptr archive_sp(
+ Archive::FindCachedArchive(file, ArchSpec(), file_mod_time, file_offset));
+ bool set_archive_arch = false;
+ if (!archive_sp) {
+ set_archive_arch = true;
+ data_sp =
+ DataBufferLLVM::CreateSliceFromPath(file.GetPath(), file_size, file_offset);
+ if (data_sp) {
data.SetData(data_sp, 0, data_sp->GetByteSize());
archive_sp = Archive::ParseAndCacheArchiveForFile(
file, ArchSpec(), file_mod_time, file_offset, data);
}
+ }
- if (archive_sp) {
- const size_t num_objects = archive_sp->GetNumObjects();
- for (size_t idx = 0; idx < num_objects; ++idx) {
- const Object *object = archive_sp->GetObjectAtIndex(idx);
- if (object) {
- const lldb::offset_t object_file_offset =
- file_offset + object->ar_file_offset;
- if (object->ar_file_offset < file_size &&
- file_size > object_file_offset) {
- if (ObjectFile::GetModuleSpecifications(
- file, object_file_offset, file_size - object_file_offset,
- specs)) {
- ModuleSpec &spec =
- specs.GetModuleSpecRefAtIndex(specs.GetSize() - 1);
- llvm::sys::TimePoint<> object_mod_time(
- std::chrono::seconds(object->ar_date));
- spec.GetObjectName() = object->ar_name;
- spec.SetObjectOffset(object_file_offset);
- spec.SetObjectSize(file_size - object_file_offset);
- spec.GetObjectModificationTime() = object_mod_time;
- }
+ if (archive_sp) {
+ const size_t num_objects = archive_sp->GetNumObjects();
+ for (size_t idx = 0; idx < num_objects; ++idx) {
+ const Object *object = archive_sp->GetObjectAtIndex(idx);
+ if (object) {
+ const lldb::offset_t object_file_offset =
+ file_offset + object->ar_file_offset;
+ if (object->ar_file_offset < file_size &&
+ file_size > object_file_offset) {
+ if (ObjectFile::GetModuleSpecifications(
+ file, object_file_offset, file_size - object_file_offset,
+ specs)) {
+ ModuleSpec &spec =
+ specs.GetModuleSpecRefAtIndex(specs.GetSize() - 1);
+ llvm::sys::TimePoint<> object_mod_time(
+ std::chrono::seconds(object->ar_date));
+ spec.GetObjectName() = object->ar_name;
+ spec.SetObjectOffset(object_file_offset);
+ spec.SetObjectSize(file_size - object_file_offset);
+ spec.GetObjectModificationTime() = object_mod_time;
}
}
}
}
- const size_t end_count = specs.GetSize();
- size_t num_specs_added = end_count - initial_count;
- if (set_archive_arch && num_specs_added > 0) {
- // The archive was created but we didn't have an architecture
- // so we need to set it
- for (size_t i = initial_count; i < end_count; ++i) {
- ModuleSpec module_spec;
- if (specs.GetModuleSpecAtIndex(i, module_spec)) {
- if (module_spec.GetArchitecture().IsValid()) {
- archive_sp->SetArchitecture(module_spec.GetArchitecture());
- break;
- }
+ }
+ const size_t end_count = specs.GetSize();
+ size_t num_specs_added = end_count - initial_count;
+ if (set_archive_arch && num_specs_added > 0) {
+ // The archive was created but we didn't have an architecture
+ // so we need to set it
+ for (size_t i = initial_count; i < end_count; ++i) {
+ ModuleSpec module_spec;
+ if (specs.GetModuleSpecAtIndex(i, module_spec)) {
+ if (module_spec.GetArchitecture().IsValid()) {
+ archive_sp->SetArchitecture(module_spec.GetArchitecture());
+ break;
}
}
}
- return num_specs_added;
}
- return 0;
+ return num_specs_added;
}
diff --git a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
index de0f24e3bfcc..0e10d47f2ce4 100644
--- a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
+++ b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
@@ -12,16 +12,18 @@
// Project includes
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/UniqueCStringMap.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Symbol/ObjectContainer.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/FileSpec.h"
// Other libraries and framework includes
#include "llvm/Support/Chrono.h"
// C Includes
// C++ Includes
+#include <map>
+#include <memory>
#include <mutex>
class ObjectContainerBSDArchive : public lldb_private::ObjectContainer {
diff --git a/source/Plugins/ObjectContainer/Universal-Mach-O/CMakeLists.txt b/source/Plugins/ObjectContainer/Universal-Mach-O/CMakeLists.txt
index b4553868bf94..9f173cf4c004 100644
--- a/source/Plugins/ObjectContainer/Universal-Mach-O/CMakeLists.txt
+++ b/source/Plugins/ObjectContainer/Universal-Mach-O/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginObjectContainerMachOArchive
+add_lldb_library(lldbPluginObjectContainerMachOArchive PLUGIN
ObjectContainerUniversalMachO.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbSymbol
+ lldbTarget
+ lldbUtility
)
diff --git a/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp b/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
index a412254e1eb0..31eb17873f3e 100644
--- a/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
+++ b/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
@@ -9,13 +9,13 @@
#include "ObjectContainerUniversalMachO.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataBuffer.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h b/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h
index 36542559e082..d3c0a080a6f9 100644
--- a/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h
+++ b/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h
@@ -14,8 +14,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Host/FileSpec.h"
#include "lldb/Symbol/ObjectContainer.h"
+#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/SafeMachO.h"
class ObjectContainerUniversalMachO : public lldb_private::ObjectContainer {
diff --git a/source/Plugins/ObjectFile/ELF/CMakeLists.txt b/source/Plugins/ObjectFile/ELF/CMakeLists.txt
index 69ec80c62bf0..a941b8d55848 100644
--- a/source/Plugins/ObjectFile/ELF/CMakeLists.txt
+++ b/source/Plugins/ObjectFile/ELF/CMakeLists.txt
@@ -1,4 +1,12 @@
-add_lldb_library(lldbPluginObjectFileELF
+add_lldb_library(lldbPluginObjectFileELF PLUGIN
ELFHeader.cpp
ObjectFileELF.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/ObjectFile/ELF/ELFHeader.cpp b/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
index a3e82390d262..39ea49208700 100644
--- a/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
+++ b/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
@@ -9,9 +9,9 @@
#include <cstring>
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Stream.h"
#include "ELFHeader.h"
@@ -81,6 +81,39 @@ ByteOrder ELFHeader::GetByteOrder() const {
return eByteOrderInvalid;
}
+bool ELFHeader::HasHeaderExtension() const {
+ bool result = false;
+
+ // Check if any of these values looks like sentinel.
+ result |= e_phnum_hdr == 0xFFFF; // PN_XNUM
+ result |= e_shnum_hdr == SHN_UNDEF;
+ result |= e_shstrndx_hdr == SHN_XINDEX;
+
+ // If header extension is present, the section offset cannot be null.
+ result &= e_shoff != 0;
+
+ // Done.
+ return result;
+}
+
+void ELFHeader::ParseHeaderExtension(lldb_private::DataExtractor &data) {
+ // Extract section #0 header.
+ ELFSectionHeader section_zero;
+ lldb::offset_t offset = 0;
+ lldb_private::DataExtractor sh_data(data, e_shoff, e_shentsize);
+ bool ok = section_zero.Parse(sh_data, &offset);
+
+ // If we succeeded, fix the header.
+ if (ok) {
+ if (e_phnum_hdr == 0xFFFF) // PN_XNUM
+ e_phnum = section_zero.sh_info;
+ if (e_shnum_hdr == SHN_UNDEF)
+ e_shnum = section_zero.sh_size;
+ if (e_shstrndx_hdr == SHN_XINDEX)
+ e_shstrndx = section_zero.sh_link;
+ }
+}
+
bool ELFHeader::Parse(lldb_private::DataExtractor &data,
lldb::offset_t *offset) {
// Read e_ident. This provides byte order and address size info.
@@ -112,6 +145,16 @@ bool ELFHeader::Parse(lldb_private::DataExtractor &data,
if (data.GetU16(offset, &e_ehsize, 6) == NULL)
return false;
+ // Initialize e_phnum, e_shnum, and e_shstrndx with the values
+ // read from the header.
+ e_phnum = e_phnum_hdr;
+ e_shnum = e_shnum_hdr;
+ e_shstrndx = e_shstrndx_hdr;
+
+ // See if we have extended header in section #0.
+ if (HasHeaderExtension())
+ ParseHeaderExtension(data);
+
return true;
}
diff --git a/source/Plugins/ObjectFile/ELF/ELFHeader.h b/source/Plugins/ObjectFile/ELF/ELFHeader.h
index 71b200f1c16b..e6738a1ecb2b 100644
--- a/source/Plugins/ObjectFile/ELF/ELFHeader.h
+++ b/source/Plugins/ObjectFile/ELF/ELFHeader.h
@@ -24,6 +24,7 @@
#include "llvm/Support/ELF.h"
#include "lldb/lldb-enumerations.h"
+#include "lldb/lldb-types.h"
namespace lldb_private {
class DataExtractor;
@@ -65,10 +66,17 @@ struct ELFHeader {
elf_half e_machine; ///< Target architecture.
elf_half e_ehsize; ///< Byte size of the ELF header.
elf_half e_phentsize; ///< Size of a program header table entry.
- elf_half e_phnum; ///< Number of program header entries.
+ elf_half e_phnum_hdr; ///< Number of program header entries.
elf_half e_shentsize; ///< Size of a section header table entry.
- elf_half e_shnum; ///< Number of section header entries.
- elf_half e_shstrndx; ///< String table section index.
+ elf_half e_shnum_hdr; ///< Number of section header entries.
+ elf_half e_shstrndx_hdr; ///< String table section index.
+
+ // In some cases these numbers do not fit in 16 bits and they are
+ // stored outside of the header in section #0. Here are the actual
+ // values.
+ elf_word e_phnum; ///< Number of program header entries.
+ elf_word e_shnum; ///< Number of section header entries.
+ elf_word e_shstrndx; ///< String table section index.
ELFHeader();
@@ -102,6 +110,14 @@ struct ELFHeader {
unsigned GetRelocationJumpSlotType() const;
//--------------------------------------------------------------------------
+ /// Check if there should be header extension in section header #0
+ ///
+ /// @return
+ /// True if parsing the ELFHeader requires reading header extension
+ /// and false otherwise.
+ bool HasHeaderExtension() const;
+
+ //--------------------------------------------------------------------------
/// Parse an ELFHeader entry starting at position \p offset and
/// update the data extractor with the address size and byte order
/// attributes as defined by the header.
@@ -137,6 +153,16 @@ struct ELFHeader {
/// The number of bytes forming an address in the ELF file (either 4 or
/// 8), else zero if the address size could not be determined.
static unsigned AddressSizeInBytes(const uint8_t *magic);
+
+private:
+
+ //--------------------------------------------------------------------------
+ /// Parse an ELFHeader header extension entry. This method is called
+ /// by Parse().
+ ///
+ /// @param[in] data
+ /// The DataExtractor to read from.
+ void ParseHeaderExtension(lldb_private::DataExtractor &data);
};
//------------------------------------------------------------------------------
diff --git a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index eb983154618b..6e2001b21630 100644
--- a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -14,25 +14,26 @@
#include <unordered_map>
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataBuffer.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/FileSpecList.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/Timer.h"
#include "lldb/Symbol/DWARFCallFrameInfo.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferLLVM.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/ARMBuildAttributes.h"
#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/MipsABIFlags.h"
#define CASE_AND_STREAM(s, def, width) \
@@ -51,6 +52,7 @@ namespace {
const char *const LLDB_NT_OWNER_FREEBSD = "FreeBSD";
const char *const LLDB_NT_OWNER_GNU = "GNU";
const char *const LLDB_NT_OWNER_NETBSD = "NetBSD";
+const char *const LLDB_NT_OWNER_OPENBSD = "OpenBSD";
const char *const LLDB_NT_OWNER_CSR = "csr";
const char *const LLDB_NT_OWNER_ANDROID = "Android";
const char *const LLDB_NT_OWNER_CORE = "CORE";
@@ -286,10 +288,26 @@ static uint32_t kalimbaVariantFromElfFlags(const elf::elf_word e_flags) {
return kal_arch_variant;
}
-static uint32_t mipsVariantFromElfFlags(const elf::elf_word e_flags,
- uint32_t endian) {
- const uint32_t mips_arch = e_flags & llvm::ELF::EF_MIPS_ARCH;
+static uint32_t mipsVariantFromElfFlags (const elf::ELFHeader &header) {
+ const uint32_t mips_arch = header.e_flags & llvm::ELF::EF_MIPS_ARCH;
+ uint32_t endian = header.e_ident[EI_DATA];
uint32_t arch_variant = ArchSpec::eMIPSSubType_unknown;
+ uint32_t fileclass = header.e_ident[EI_CLASS];
+
+ // If there aren't any elf flags available (e.g core elf file) then return default
+ // 32 or 64 bit arch (without any architecture revision) based on object file's class.
+ if (header.e_type == ET_CORE) {
+ switch (fileclass) {
+ case llvm::ELF::ELFCLASS32:
+ return (endian == ELFDATA2LSB) ? ArchSpec::eMIPSSubType_mips32el
+ : ArchSpec::eMIPSSubType_mips32;
+ case llvm::ELF::ELFCLASS64:
+ return (endian == ELFDATA2LSB) ? ArchSpec::eMIPSSubType_mips64el
+ : ArchSpec::eMIPSSubType_mips64;
+ default:
+ return arch_variant;
+ }
+ }
switch (mips_arch) {
case llvm::ELF::EF_MIPS_ARCH_1:
@@ -324,7 +342,7 @@ static uint32_t mipsVariantFromElfFlags(const elf::elf_word e_flags,
static uint32_t subTypeFromElfHeader(const elf::ELFHeader &header) {
if (header.e_machine == llvm::ELF::EM_MIPS)
- return mipsVariantFromElfFlags(header.e_flags, header.e_ident[EI_DATA]);
+ return mipsVariantFromElfFlags(header);
return llvm::ELF::EM_CSR_KALIMBA == header.e_machine
? kalimbaVariantFromElfFlags(header.e_flags)
@@ -386,31 +404,42 @@ ObjectFile *ObjectFileELF::CreateInstance(const lldb::ModuleSP &module_sp,
lldb::offset_t file_offset,
lldb::offset_t length) {
if (!data_sp) {
- data_sp = file->MemoryMapFileContentsIfLocal(file_offset, length);
+ data_sp =
+ DataBufferLLVM::CreateSliceFromPath(file->GetPath(), length, file_offset);
+ if (!data_sp)
+ return nullptr;
data_offset = 0;
}
- if (data_sp &&
- data_sp->GetByteSize() > (llvm::ELF::EI_NIDENT + data_offset)) {
- const uint8_t *magic = data_sp->GetBytes() + data_offset;
- if (ELFHeader::MagicBytesMatch(magic)) {
- // Update the data to contain the entire file if it doesn't already
- if (data_sp->GetByteSize() < length) {
- data_sp = file->MemoryMapFileContentsIfLocal(file_offset, length);
- data_offset = 0;
- magic = data_sp->GetBytes();
- }
- unsigned address_size = ELFHeader::AddressSizeInBytes(magic);
- if (address_size == 4 || address_size == 8) {
- std::unique_ptr<ObjectFileELF> objfile_ap(new ObjectFileELF(
- module_sp, data_sp, data_offset, file, file_offset, length));
- ArchSpec spec;
- if (objfile_ap->GetArchitecture(spec) &&
- objfile_ap->SetModulesArchitecture(spec))
- return objfile_ap.release();
- }
- }
+ assert(data_sp);
+
+ if (data_sp->GetByteSize() <= (llvm::ELF::EI_NIDENT + data_offset))
+ return nullptr;
+
+ const uint8_t *magic = data_sp->GetBytes() + data_offset;
+ if (!ELFHeader::MagicBytesMatch(magic))
+ return nullptr;
+
+ // Update the data to contain the entire file if it doesn't already
+ if (data_sp->GetByteSize() < length) {
+ data_sp =
+ DataBufferLLVM::CreateSliceFromPath(file->GetPath(), length, file_offset);
+ if (!data_sp)
+ return nullptr;
+ data_offset = 0;
+ magic = data_sp->GetBytes();
}
+
+ unsigned address_size = ELFHeader::AddressSizeInBytes(magic);
+ if (address_size == 4 || address_size == 8) {
+ std::unique_ptr<ObjectFileELF> objfile_ap(new ObjectFileELF(
+ module_sp, data_sp, data_offset, file, file_offset, length));
+ ArchSpec spec;
+ if (objfile_ap->GetArchitecture(spec) &&
+ objfile_ap->SetModulesArchitecture(spec))
+ return objfile_ap.release();
+ }
+
return NULL;
}
@@ -610,7 +639,8 @@ size_t ObjectFileELF::GetModuleSpecifications(
DataExtractor data;
data.SetData(data_sp);
elf::ELFHeader header;
- if (header.Parse(data, &data_offset)) {
+ lldb::offset_t header_offset = data_offset;
+ if (header.Parse(data, &header_offset)) {
if (data_sp) {
ModuleSpec spec(file);
@@ -632,6 +662,7 @@ size_t ObjectFileELF::GetModuleSpecifications(
// SetArchitecture should have set the vendor to unknown
vendor = spec.GetArchitecture().GetTriple().getVendor();
assert(vendor == llvm::Triple::UnknownVendor);
+ UNUSED_IF_ASSERT_DISABLED(vendor);
//
// Validate it is ok to remove GetOsFromOSABI
@@ -644,15 +675,31 @@ size_t ObjectFileELF::GetModuleSpecifications(
__FUNCTION__, file.GetPath().c_str());
}
+ // In case there is header extension in the section #0, the header
+ // we parsed above could have sentinel values for e_phnum, e_shnum,
+ // and e_shstrndx. In this case we need to reparse the header
+ // with a bigger data source to get the actual values.
+ size_t section_header_end = header.e_shoff + header.e_shentsize;
+ if (header.HasHeaderExtension() &&
+ section_header_end > data_sp->GetByteSize()) {
+ data_sp = DataBufferLLVM::CreateSliceFromPath(
+ file.GetPath(), section_header_end, file_offset);
+ if (data_sp) {
+ data.SetData(data_sp);
+ lldb::offset_t header_offset = data_offset;
+ header.Parse(data, &header_offset);
+ }
+ }
+
// Try to get the UUID from the section list. Usually that's at the
- // end, so
- // map the file in if we don't have it already.
- size_t section_header_end =
+ // end, so map the file in if we don't have it already.
+ section_header_end =
header.e_shoff + header.e_shnum * header.e_shentsize;
if (section_header_end > data_sp->GetByteSize()) {
- data_sp = file.MemoryMapFileContentsIfLocal(file_offset,
- section_header_end);
- data.SetData(data_sp);
+ data_sp = DataBufferLLVM::CreateSliceFromPath(
+ file.GetPath(), section_header_end, file_offset);
+ if (data_sp)
+ data.SetData(data_sp);
}
uint32_t gnu_debuglink_crc = 0;
@@ -687,17 +734,17 @@ size_t ObjectFileELF::GetModuleSpecifications(
(file.GetByteSize() - file_offset) / 1024);
// For core files - which usually don't happen to have a
- // gnu_debuglink,
- // and are pretty bulky - calculating whole contents crc32 would
- // be too much of luxury.
- // Thus we will need to fallback to something simpler.
+ // gnu_debuglink, and are pretty bulky - calculating whole
+ // contents crc32 would be too much of luxury. Thus we will need
+ // to fallback to something simpler.
if (header.e_type == llvm::ELF::ET_CORE) {
size_t program_headers_end =
header.e_phoff + header.e_phnum * header.e_phentsize;
if (program_headers_end > data_sp->GetByteSize()) {
- data_sp = file.MemoryMapFileContentsIfLocal(
- file_offset, program_headers_end);
- data.SetData(data_sp);
+ data_sp = DataBufferLLVM::CreateSliceFromPath(
+ file.GetPath(), program_headers_end, file_offset);
+ if (data_sp)
+ data.SetData(data_sp);
}
ProgramHeaderColl program_headers;
GetProgramHeaderInfo(program_headers, set_data, header);
@@ -710,20 +757,23 @@ size_t ObjectFileELF::GetModuleSpecifications(
}
if (segment_data_end > data_sp->GetByteSize()) {
- data_sp = file.MemoryMapFileContentsIfLocal(file_offset,
- segment_data_end);
- data.SetData(data_sp);
+ data_sp = DataBufferLLVM::CreateSliceFromPath(
+ file.GetPath(), segment_data_end, file_offset);
+ if (data_sp)
+ data.SetData(data_sp);
}
core_notes_crc =
CalculateELFNotesSegmentsCRC32(program_headers, data);
} else {
// Need to map entire file into memory to calculate the crc.
- data_sp =
- file.MemoryMapFileContentsIfLocal(file_offset, SIZE_MAX);
- data.SetData(data_sp);
- gnu_debuglink_crc = calc_gnu_debuglink_crc32(
- data.GetDataStart(), data.GetByteSize());
+ data_sp = DataBufferLLVM::CreateSliceFromPath(file.GetPath(), -1,
+ file_offset);
+ if (data_sp) {
+ data.SetData(data_sp);
+ gnu_debuglink_crc = calc_gnu_debuglink_crc32(
+ data.GetDataStart(), data.GetByteSize());
+ }
}
}
if (gnu_debuglink_crc) {
@@ -799,7 +849,7 @@ bool ObjectFileELF::SetLoadAddress(Target &target, lldb::addr_t value,
if (section_list) {
if (!value_is_offset) {
bool found_offset = false;
- for (size_t i = 0, count = GetProgramHeaderCount(); i < count; ++i) {
+ for (size_t i = 1, count = GetProgramHeaderCount(); i <= count; ++i) {
const elf::ELFProgramHeader *header = GetProgramHeaderByIndex(i);
if (header == nullptr)
continue;
@@ -1315,6 +1365,10 @@ ObjectFileELF::RefineModuleDetailsFromNote(lldb_private::DataExtractor &data,
}
break;
}
+ if (arch_spec.IsMIPS() &&
+ arch_spec.GetTriple().getOS() == llvm::Triple::OSType::UnknownOS)
+ // The note.n_name == LLDB_NT_OWNER_GNU is valid for Linux platform
+ arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux);
}
// Process NetBSD ELF notes.
else if ((note.n_name == LLDB_NT_OWNER_NETBSD) &&
@@ -1336,6 +1390,12 @@ ObjectFileELF::RefineModuleDetailsFromNote(lldb_private::DataExtractor &data,
"ObjectFileELF::%s detected NetBSD, min version constant %" PRIu32,
__FUNCTION__, version_info);
}
+ // Process OpenBSD ELF notes.
+ else if (note.n_name == LLDB_NT_OWNER_OPENBSD) {
+ // Set the elf OS version to OpenBSD. Also clear the vendor.
+ arch_spec.GetTriple().setOS(llvm::Triple::OSType::OpenBSD);
+ arch_spec.GetTriple().setVendor(llvm::Triple::VendorType::UnknownVendor);
+ }
// Process CSR kalimba notes
else if ((note.n_type == LLDB_NT_GNU_ABI_TAG) &&
(note.n_name == LLDB_NT_OWNER_CSR)) {
@@ -1410,6 +1470,12 @@ ObjectFileELF::RefineModuleDetailsFromNote(lldb_private::DataExtractor &data,
break;
}
}
+ if (arch_spec.IsMIPS() &&
+ arch_spec.GetTriple().getOS() == llvm::Triple::OSType::UnknownOS)
+ // In case of MIPSR6, the LLDB_NT_OWNER_GNU note is missing
+ // for some cases (e.g. compile with -nostdlib)
+ // Hence set OS to Linux
+ arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux);
}
}
@@ -1524,6 +1590,7 @@ size_t ObjectFileELF::GetSectionHeaderInfo(SectionHeaderColl &section_headers,
GetOsFromOSABI(header.e_ident[EI_OSABI], ostype);
spec_ostype = arch_spec.GetTriple().getOS();
assert(spec_ostype == ostype);
+ UNUSED_IF_ASSERT_DISABLED(spec_ostype);
}
if (arch_spec.GetMachine() == llvm::Triple::mips ||
@@ -3065,10 +3132,10 @@ void ObjectFileELF::DumpELFHeader(Stream *s, const ELFHeader &header) {
s->Printf("e_flags = 0x%8.8x\n", header.e_flags);
s->Printf("e_ehsize = 0x%4.4x\n", header.e_ehsize);
s->Printf("e_phentsize = 0x%4.4x\n", header.e_phentsize);
- s->Printf("e_phnum = 0x%4.4x\n", header.e_phnum);
+ s->Printf("e_phnum = 0x%8.8x\n", header.e_phnum);
s->Printf("e_shentsize = 0x%4.4x\n", header.e_shentsize);
- s->Printf("e_shnum = 0x%4.4x\n", header.e_shnum);
- s->Printf("e_shstrndx = 0x%4.4x\n", header.e_shstrndx);
+ s->Printf("e_shnum = 0x%8.8x\n", header.e_shnum);
+ s->Printf("e_shstrndx = 0x%8.8x\n", header.e_shstrndx);
}
//----------------------------------------------------------------------
@@ -3315,7 +3382,7 @@ bool ObjectFileELF::GetArchitecture(ArchSpec &arch) {
// headers
// that might shed more light on the architecture
if (ParseProgramHeaders()) {
- for (size_t i = 0, count = GetProgramHeaderCount(); i < count; ++i) {
+ for (size_t i = 1, count = GetProgramHeaderCount(); i <= count; ++i) {
const elf::ELFProgramHeader *header = GetProgramHeaderByIndex(i);
if (header && header->p_type == PT_NOTE && header->p_offset != 0 &&
header->p_filesz > 0) {
diff --git a/source/Plugins/ObjectFile/ELF/ObjectFileELF.h b/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
index 4ce5648cfed5..98bd9abb1932 100644
--- a/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ b/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -20,9 +20,9 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/UUID.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
#include "lldb/lldb-private.h"
#include "ELFHeader.h"
diff --git a/source/Plugins/ObjectFile/JIT/CMakeLists.txt b/source/Plugins/ObjectFile/JIT/CMakeLists.txt
index 979724bac5ad..fd575532db4c 100644
--- a/source/Plugins/ObjectFile/JIT/CMakeLists.txt
+++ b/source/Plugins/ObjectFile/JIT/CMakeLists.txt
@@ -1,3 +1,11 @@
-add_lldb_library(lldbPluginObjectFileJIT
+add_lldb_library(lldbPluginObjectFileJIT PLUGIN
ObjectFileJIT.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp b/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
index b5b5e38e1f6f..055a8219f154 100644
--- a/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
+++ b/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
@@ -12,27 +12,27 @@
#include "ObjectFileJIT.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataBuffer.h"
-#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/FileSpecList.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RangeMap.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
-#include "lldb/Core/UUID.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/UUID.h"
#ifndef __APPLE__
#include "Utility/UuidCompatibility.h"
diff --git a/source/Plugins/ObjectFile/Mach-O/CMakeLists.txt b/source/Plugins/ObjectFile/Mach-O/CMakeLists.txt
index 45d45860b9e5..d39b93768ae7 100644
--- a/source/Plugins/ObjectFile/Mach-O/CMakeLists.txt
+++ b/source/Plugins/ObjectFile/Mach-O/CMakeLists.txt
@@ -1,3 +1,13 @@
-add_lldb_library(lldbPluginObjectFileMachO
+add_lldb_library(lldbPluginObjectFileMachO PLUGIN
ObjectFileMachO.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ lldbPluginProcessUtility
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 9ef4e9c3c9b1..84ecfdc67bee 100644
--- a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -18,21 +18,16 @@
#include "Plugins/Process/Utility/RegisterContextDarwin_i386.h"
#include "Plugins/Process/Utility/RegisterContextDarwin_x86_64.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataBuffer.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/FileSpecList.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RangeMap.h"
+#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
-#include "lldb/Core/UUID.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Symbol/DWARFCallFrameInfo.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -44,9 +39,17 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadList.h"
+#include "lldb/Utility/DataBufferLLVM.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/UUID.h"
#include "lldb/Utility/SafeMachO.h"
+#include "llvm/Support/MemoryBuffer.h"
+
#include "ObjectFileMachO.h"
#if defined(__APPLE__) && \
@@ -57,6 +60,8 @@
#ifndef __APPLE__
#include "Utility/UuidCompatibility.h"
+#else
+#include <uuid/uuid.h>
#endif
#define THUMB_ADDRESS_BIT_MASK 0xfffffffffffffffeull
@@ -857,22 +862,30 @@ ObjectFile *ObjectFileMachO::CreateInstance(const lldb::ModuleSP &module_sp,
lldb::offset_t file_offset,
lldb::offset_t length) {
if (!data_sp) {
- data_sp = file->MemoryMapFileContentsIfLocal(file_offset, length);
+ data_sp =
+ DataBufferLLVM::CreateSliceFromPath(file->GetPath(), length, file_offset);
+ if (!data_sp)
+ return nullptr;
data_offset = 0;
}
- if (ObjectFileMachO::MagicBytesMatch(data_sp, data_offset, length)) {
- // Update the data to contain the entire file if it doesn't already
- if (data_sp->GetByteSize() < length) {
- data_sp = file->MemoryMapFileContentsIfLocal(file_offset, length);
- data_offset = 0;
- }
- std::unique_ptr<ObjectFile> objfile_ap(new ObjectFileMachO(
- module_sp, data_sp, data_offset, file, file_offset, length));
- if (objfile_ap.get() && objfile_ap->ParseHeader())
- return objfile_ap.release();
+ if (!ObjectFileMachO::MagicBytesMatch(data_sp, data_offset, length))
+ return nullptr;
+
+ // Update the data to contain the entire file if it doesn't already
+ if (data_sp->GetByteSize() < length) {
+ data_sp =
+ DataBufferLLVM::CreateSliceFromPath(file->GetPath(), length, file_offset);
+ if (!data_sp)
+ return nullptr;
+ data_offset = 0;
}
- return NULL;
+ auto objfile_ap = llvm::make_unique<ObjectFileMachO>(
+ module_sp, data_sp, data_offset, file, file_offset, length);
+ if (!objfile_ap || !objfile_ap->ParseHeader())
+ return nullptr;
+
+ return objfile_ap.release();
}
ObjectFile *ObjectFileMachO::CreateMemoryInstance(
@@ -901,7 +914,8 @@ size_t ObjectFileMachO::GetModuleSpecifications(
size_t header_and_load_cmds =
header.sizeofcmds + MachHeaderSizeFromMagic(header.magic);
if (header_and_load_cmds >= data_sp->GetByteSize()) {
- data_sp = file.ReadFileContents(file_offset, header_and_load_cmds);
+ data_sp = DataBufferLLVM::CreateSliceFromPath(
+ file.GetPath(), header_and_load_cmds, file_offset);
data.SetData(data_sp);
data_offset = MachHeaderSizeFromMagic(header.magic);
}
@@ -1113,8 +1127,8 @@ bool ObjectFileMachO::ParseHeader() {
ReadMemory(process_sp, m_memory_addr, header_and_lc_size);
} else {
// Read in all only the load command data from the file on disk
- data_sp =
- m_file.ReadFileContents(m_file_offset, header_and_lc_size);
+ data_sp = DataBufferLLVM::CreateSliceFromPath(
+ m_file.GetPath(), header_and_lc_size, m_file_offset);
if (data_sp->GetByteSize() != header_and_lc_size)
return false;
}
@@ -2085,22 +2099,23 @@ UUID ObjectFileMachO::GetSharedCacheUUID(FileSpec dyld_shared_cache,
const ByteOrder byte_order,
const uint32_t addr_byte_size) {
UUID dsc_uuid;
- DataBufferSP dsc_data_sp = dyld_shared_cache.MemoryMapFileContentsIfLocal(
- 0, sizeof(struct lldb_copy_dyld_cache_header_v1));
- if (dsc_data_sp) {
- DataExtractor dsc_header_data(dsc_data_sp, byte_order, addr_byte_size);
+ DataBufferSP DscData = DataBufferLLVM::CreateSliceFromPath(
+ dyld_shared_cache.GetPath(),
+ sizeof(struct lldb_copy_dyld_cache_header_v1), 0);
+ if (!DscData)
+ return dsc_uuid;
+ DataExtractor dsc_header_data(DscData, byte_order, addr_byte_size);
- char version_str[7];
- lldb::offset_t offset = 0;
- memcpy(version_str, dsc_header_data.GetData(&offset, 6), 6);
- version_str[6] = '\0';
- if (strcmp(version_str, "dyld_v") == 0) {
- offset = offsetof(struct lldb_copy_dyld_cache_header_v1, uuid);
- uint8_t uuid_bytes[sizeof(uuid_t)];
- memcpy(uuid_bytes, dsc_header_data.GetData(&offset, sizeof(uuid_t)),
- sizeof(uuid_t));
- dsc_uuid.SetBytes(uuid_bytes);
- }
+ char version_str[7];
+ lldb::offset_t offset = 0;
+ memcpy(version_str, dsc_header_data.GetData(&offset, 6), 6);
+ version_str[6] = '\0';
+ if (strcmp(version_str, "dyld_v") == 0) {
+ offset = offsetof(struct lldb_copy_dyld_cache_header_v1, uuid);
+ uint8_t uuid_bytes[sizeof(uuid_t)];
+ memcpy(uuid_bytes, dsc_header_data.GetData(&offset, sizeof(uuid_t)),
+ sizeof(uuid_t));
+ dsc_uuid.SetBytes(uuid_bytes);
}
return dsc_uuid;
}
@@ -2692,8 +2707,9 @@ size_t ObjectFileMachO::ParseSymtab() {
// Process the dyld shared cache header to find the unmapped symbols
- DataBufferSP dsc_data_sp = dsc_filespec.MemoryMapFileContentsIfLocal(
- 0, sizeof(struct lldb_copy_dyld_cache_header_v1));
+ DataBufferSP dsc_data_sp = DataBufferLLVM::CreateSliceFromPath(
+ dsc_filespec.GetPath(), sizeof(struct lldb_copy_dyld_cache_header_v1),
+ 0);
if (!dsc_uuid.IsValid()) {
dsc_uuid = GetSharedCacheUUID(dsc_filespec, byte_order, addr_byte_size);
}
@@ -2726,9 +2742,11 @@ size_t ObjectFileMachO::ParseSymtab() {
mappingOffset >= sizeof(struct lldb_copy_dyld_cache_header_v1)) {
DataBufferSP dsc_mapping_info_data_sp =
- dsc_filespec.MemoryMapFileContentsIfLocal(
- mappingOffset,
- sizeof(struct lldb_copy_dyld_cache_mapping_info));
+ DataBufferLLVM::CreateSliceFromPath(
+ dsc_filespec.GetPath(),
+ sizeof(struct lldb_copy_dyld_cache_mapping_info),
+ mappingOffset);
+
DataExtractor dsc_mapping_info_data(dsc_mapping_info_data_sp,
byte_order, addr_byte_size);
offset = 0;
@@ -2750,9 +2768,12 @@ size_t ObjectFileMachO::ParseSymtab() {
if (localSymbolsOffset && localSymbolsSize) {
// Map the local symbols
- if (DataBufferSP dsc_local_symbols_data_sp =
- dsc_filespec.MemoryMapFileContentsIfLocal(
- localSymbolsOffset, localSymbolsSize)) {
+ DataBufferSP dsc_local_symbols_data_sp =
+ DataBufferLLVM::CreateSliceFromPath(dsc_filespec.GetPath(),
+ localSymbolsSize,
+ localSymbolsOffset);
+
+ if (dsc_local_symbols_data_sp) {
DataExtractor dsc_local_symbols_data(dsc_local_symbols_data_sp,
byte_order, addr_byte_size);
@@ -5034,6 +5055,7 @@ uint32_t ObjectFileMachO::GetDependentModules(FileSpecList &files) {
lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
std::vector<std::string> rpath_paths;
std::vector<std::string> rpath_relative_paths;
+ std::vector<std::string> at_exec_relative_paths;
const bool resolve_path = false; // Don't resolve the dependent file paths
// since they may not reside on this system
uint32_t i;
@@ -5059,6 +5081,10 @@ uint32_t ObjectFileMachO::GetDependentModules(FileSpecList &files) {
if (path[0] == '@') {
if (strncmp(path, "@rpath", strlen("@rpath")) == 0)
rpath_relative_paths.push_back(path + strlen("@rpath"));
+ else if (strncmp(path, "@executable_path",
+ strlen("@executable_path")) == 0)
+ at_exec_relative_paths.push_back(path
+ + strlen("@executable_path"));
} else {
FileSpec file_spec(path, resolve_path);
if (files.AppendIfUnique(file_spec))
@@ -5074,10 +5100,11 @@ uint32_t ObjectFileMachO::GetDependentModules(FileSpecList &files) {
offset = cmd_offset + load_cmd.cmdsize;
}
+ FileSpec this_file_spec(m_file);
+ this_file_spec.ResolvePath();
+
if (!rpath_paths.empty()) {
// Fixup all LC_RPATH values to be absolute paths
- FileSpec this_file_spec(m_file);
- this_file_spec.ResolvePath();
std::string loader_path("@loader_path");
std::string executable_path("@executable_path");
for (auto &rpath : rpath_paths) {
@@ -5107,6 +5134,23 @@ uint32_t ObjectFileMachO::GetDependentModules(FileSpecList &files) {
}
}
}
+
+ // We may have @executable_paths but no RPATHS. Figure those out here.
+ // Only do this if this object file is the executable. We have no way to
+ // get back to the actual executable otherwise, so we won't get the right
+ // path.
+ if (!at_exec_relative_paths.empty() && CalculateType() == eTypeExecutable) {
+ FileSpec exec_dir = this_file_spec.CopyByRemovingLastPathComponent();
+ for (const auto &at_exec_relative_path : at_exec_relative_paths) {
+ FileSpec file_spec =
+ exec_dir.CopyByAppendingPathComponent(at_exec_relative_path);
+ file_spec = file_spec.GetNormalizedPath();
+ if (file_spec.Exists() && files.AppendIfUnique(file_spec)) {
+ count++;
+ break;
+ }
+ }
+ }
}
return count;
}
@@ -5312,6 +5356,136 @@ uint32_t ObjectFileMachO::GetNumThreadContexts() {
return m_thread_context_offsets.GetSize();
}
+std::string ObjectFileMachO::GetIdentifierString() {
+ std::string result;
+ ModuleSP module_sp(GetModule());
+ if (module_sp) {
+ std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
+
+ // First, look over the load commands for an LC_NOTE load command
+ // with data_owner string "kern ver str" & use that if found.
+ lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
+ for (uint32_t i = 0; i < m_header.ncmds; ++i) {
+ const uint32_t cmd_offset = offset;
+ load_command lc;
+ if (m_data.GetU32(&offset, &lc.cmd, 2) == NULL)
+ break;
+ if (lc.cmd == LC_NOTE)
+ {
+ char data_owner[17];
+ m_data.CopyData (offset, 16, data_owner);
+ data_owner[16] = '\0';
+ offset += 16;
+ uint64_t fileoff = m_data.GetU64_unchecked (&offset);
+ uint64_t size = m_data.GetU64_unchecked (&offset);
+
+ // "kern ver str" has a uint32_t version and then a
+ // nul terminated c-string.
+ if (strcmp ("kern ver str", data_owner) == 0)
+ {
+ offset = fileoff;
+ uint32_t version;
+ if (m_data.GetU32 (&offset, &version, 1) != nullptr)
+ {
+ if (version == 1)
+ {
+ uint32_t strsize = size - sizeof (uint32_t);
+ char *buf = (char*) malloc (strsize);
+ if (buf)
+ {
+ m_data.CopyData (offset, strsize, buf);
+ buf[strsize - 1] = '\0';
+ result = buf;
+ if (buf)
+ free (buf);
+ return result;
+ }
+ }
+ }
+ }
+ }
+ offset = cmd_offset + lc.cmdsize;
+ }
+
+ // Second, make a pass over the load commands looking for an
+ // obsolete LC_IDENT load command.
+ offset = MachHeaderSizeFromMagic(m_header.magic);
+ for (uint32_t i = 0; i < m_header.ncmds; ++i) {
+ const uint32_t cmd_offset = offset;
+ struct ident_command ident_command;
+ if (m_data.GetU32(&offset, &ident_command, 2) == NULL)
+ break;
+ if (ident_command.cmd == LC_IDENT && ident_command.cmdsize != 0) {
+ char *buf = (char *) malloc (ident_command.cmdsize);
+ if (buf != nullptr
+ && m_data.CopyData (offset, ident_command.cmdsize, buf) == ident_command.cmdsize) {
+ buf[ident_command.cmdsize - 1] = '\0';
+ result = buf;
+ }
+ if (buf)
+ free (buf);
+ }
+ offset = cmd_offset + ident_command.cmdsize;
+ }
+
+ }
+ return result;
+}
+
+bool ObjectFileMachO::GetCorefileMainBinaryInfo (addr_t &address, UUID &uuid) {
+ address = LLDB_INVALID_ADDRESS;
+ uuid.Clear();
+ ModuleSP module_sp(GetModule());
+ if (module_sp) {
+ std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
+ lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
+ for (uint32_t i = 0; i < m_header.ncmds; ++i) {
+ const uint32_t cmd_offset = offset;
+ load_command lc;
+ if (m_data.GetU32(&offset, &lc.cmd, 2) == NULL)
+ break;
+ if (lc.cmd == LC_NOTE)
+ {
+ char data_owner[17];
+ memset (data_owner, 0, sizeof (data_owner));
+ m_data.CopyData (offset, 16, data_owner);
+ offset += 16;
+ uint64_t fileoff = m_data.GetU64_unchecked (&offset);
+ uint64_t size = m_data.GetU64_unchecked (&offset);
+
+ // "main bin spec" (main binary specification) data payload is formatted:
+ // uint32_t version [currently 1]
+ // uint32_t type [0 == unspecified, 1 == kernel, 2 == user process]
+ // uint64_t address [ UINT64_MAX if address not specified ]
+ // uuid_t uuid [ all zero's if uuid not specified ]
+ // uint32_t log2_pagesize [ process page size in log base 2, e.g. 4k pages are 12. 0 for unspecified ]
+
+ if (strcmp ("main bin spec", data_owner) == 0 && size >= 32)
+ {
+ offset = fileoff;
+ uint32_t version;
+ if (m_data.GetU32 (&offset, &version, 1) != nullptr && version == 1)
+ {
+ uint32_t type = 0;
+ uuid_t raw_uuid;
+ memset (raw_uuid, 0, sizeof (uuid_t));
+
+ if (m_data.GetU32 (&offset, &type, 1)
+ && m_data.GetU64 (&offset, &address, 1)
+ && m_data.CopyData (offset, sizeof (uuid_t), raw_uuid) != 0
+ && uuid.SetBytes (raw_uuid, sizeof (uuid_t)))
+ {
+ return true;
+ }
+ }
+ }
+ }
+ offset = cmd_offset + lc.cmdsize;
+ }
+ }
+ return false;
+}
+
lldb::RegisterContextSP
ObjectFileMachO::GetThreadContextAtIndex(uint32_t idx,
lldb_private::Thread &thread) {
diff --git a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
index cac176fe2ca6..96379a4db411 100644
--- a/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
+++ b/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
@@ -17,9 +17,10 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/FileSpecList.h"
#include "lldb/Core/RangeMap.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/SafeMachO.h"
+#include "lldb/Utility/UUID.h"
//----------------------------------------------------------------------
// This class needs to be hidden as eventually belongs in a plugin that
@@ -111,6 +112,10 @@ public:
uint32_t GetNumThreadContexts() override;
+ std::string GetIdentifierString() override;
+
+ bool GetCorefileMainBinaryInfo (lldb::addr_t &address, lldb_private::UUID &uuid) override;
+
lldb::RegisterContextSP
GetThreadContextAtIndex(uint32_t idx, lldb_private::Thread &thread) override;
diff --git a/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt b/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
index 5c7c488f362f..1e8fb85c72c9 100644
--- a/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
+++ b/source/Plugins/ObjectFile/PECOFF/CMakeLists.txt
@@ -1,4 +1,12 @@
-add_lldb_library(lldbPluginObjectFilePECOFF
+add_lldb_library(lldbPluginObjectFilePECOFF PLUGIN
ObjectFilePECOFF.cpp
WindowsMiniDump.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbSymbol
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index f0647e02158b..c89383a7b7ba 100644
--- a/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -13,22 +13,24 @@
#include "llvm/Support/COFF.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataBuffer.h"
-#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/FileSpecList.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
-#include "lldb/Core/UUID.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataBufferLLVM.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/UUID.h"
+
+#include "llvm/Support/MemoryBuffer.h"
#define IMAGE_DOS_SIGNATURE 0x5A4D // MZ
#define IMAGE_NT_SIGNATURE 0x00004550 // PE00
@@ -65,20 +67,30 @@ ObjectFile *ObjectFilePECOFF::CreateInstance(const lldb::ModuleSP &module_sp,
lldb::offset_t file_offset,
lldb::offset_t length) {
if (!data_sp) {
- data_sp = file->MemoryMapFileContentsIfLocal(file_offset, length);
+ data_sp =
+ DataBufferLLVM::CreateSliceFromPath(file->GetPath(), length, file_offset);
+ if (!data_sp)
+ return nullptr;
data_offset = 0;
}
- if (ObjectFilePECOFF::MagicBytesMatch(data_sp)) {
- // Update the data to contain the entire file if it doesn't already
- if (data_sp->GetByteSize() < length)
- data_sp = file->MemoryMapFileContentsIfLocal(file_offset, length);
- std::unique_ptr<ObjectFile> objfile_ap(new ObjectFilePECOFF(
- module_sp, data_sp, data_offset, file, file_offset, length));
- if (objfile_ap.get() && objfile_ap->ParseHeader())
- return objfile_ap.release();
+ if (!ObjectFilePECOFF::MagicBytesMatch(data_sp))
+ return nullptr;
+
+ // Update the data to contain the entire file if it doesn't already
+ if (data_sp->GetByteSize() < length) {
+ data_sp =
+ DataBufferLLVM::CreateSliceFromPath(file->GetPath(), length, file_offset);
+ if (!data_sp)
+ return nullptr;
}
- return NULL;
+
+ auto objfile_ap = llvm::make_unique<ObjectFilePECOFF>(
+ module_sp, data_sp, data_offset, file, file_offset, length);
+ if (!objfile_ap || !objfile_ap->ParseHeader())
+ return nullptr;
+
+ return objfile_ap.release();
}
ObjectFile *ObjectFilePECOFF::CreateMemoryInstance(
@@ -418,7 +430,10 @@ bool ObjectFilePECOFF::ParseCOFFOptionalHeader(lldb::offset_t *offset_ptr) {
DataExtractor ObjectFilePECOFF::ReadImageData(uint32_t offset, size_t size) {
if (m_file) {
- DataBufferSP buffer_sp(m_file.ReadFileContents(offset, size));
+ // A bit of a hack, but we intend to write to this buffer, so we can't
+ // mmap it.
+ auto buffer_sp =
+ DataBufferLLVM::CreateSliceFromPath(m_file.GetPath(), size, offset, true);
return DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize());
}
ProcessSP process_sp(m_process_wp.lock());
diff --git a/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp b/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
index 3fd6cdc5c9a7..094e258a7a03 100644
--- a/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
+++ b/source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp
@@ -11,7 +11,7 @@
// collisions with WinAPI preprocessor macros.
#include "WindowsMiniDump.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/FileSpec.h"
#include "llvm/Support/ConvertUTF.h"
#ifdef _WIN32
diff --git a/source/Plugins/OperatingSystem/Go/CMakeLists.txt b/source/Plugins/OperatingSystem/Go/CMakeLists.txt
index 1ca82c462069..27e952a84dfc 100644
--- a/source/Plugins/OperatingSystem/Go/CMakeLists.txt
+++ b/source/Plugins/OperatingSystem/Go/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginOSGo
+add_lldb_library(lldbPluginOSGo PLUGIN
OperatingSystemGo.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbPluginProcessUtility
)
diff --git a/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp b/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp
index c5a3ddee4843..1a0c32729865 100644
--- a/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp
+++ b/source/Plugins/OperatingSystem/Go/OperatingSystemGo.cpp
@@ -18,13 +18,11 @@
#include "Plugins/Process/Utility/DynamicRegisterInfo.h"
#include "Plugins/Process/Utility/RegisterContextMemory.h"
#include "Plugins/Process/Utility/ThreadMemory.h"
-#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/OptionGroupBoolean.h"
@@ -40,6 +38,8 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadList.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
@@ -319,7 +319,7 @@ bool OperatingSystemGo::UpdateThreadList(ThreadList &old_thread_list,
for (uint64_t i = 0; i < allglen; ++i) {
goroutines.push_back(CreateGoroutineAtIndex(i, err));
if (err.Fail()) {
- err.PutToLog(log, "OperatingSystemGo::UpdateThreadList");
+ LLDB_LOG(log, "error: {0}", err);
return new_thread_list.GetSize(false) > 0;
}
}
diff --git a/source/Plugins/OperatingSystem/Python/CMakeLists.txt b/source/Plugins/OperatingSystem/Python/CMakeLists.txt
index 7188e6f67ba0..e8b0f31d3736 100644
--- a/source/Plugins/OperatingSystem/Python/CMakeLists.txt
+++ b/source/Plugins/OperatingSystem/Python/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginOSPython
+add_lldb_library(lldbPluginOSPython PLUGIN
OperatingSystemPython.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbPluginProcessUtility
)
diff --git a/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp b/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
index 69826a0f638c..dbbb55e474f8 100644
--- a/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
+++ b/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
@@ -18,12 +18,10 @@
#include "Plugins/Process/Utility/RegisterContextMemory.h"
#include "Plugins/Process/Utility/ThreadMemory.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegisterValue.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -35,6 +33,8 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadList.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/Platform/Android/AdbClient.cpp b/source/Plugins/Platform/Android/AdbClient.cpp
index eb684ad0fbc0..2060bd1de735 100644
--- a/source/Plugins/Platform/Android/AdbClient.cpp
+++ b/source/Plugins/Platform/Android/AdbClient.cpp
@@ -15,15 +15,16 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FileUtilities.h"
-#include "lldb/Core/DataBuffer.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataEncoder.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/PosixApi.h"
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataEncoder.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/Timeout.h"
#include <limits.h>
@@ -402,13 +403,14 @@ Error AdbClient::ShellToFile(const char *command, milliseconds timeout,
return error;
const auto output_filename = output_file_spec.GetPath();
- std::ofstream dst(output_filename, std::ios::out | std::ios::binary);
- if (!dst.is_open())
+ std::error_code EC;
+ llvm::raw_fd_ostream dst(output_filename, EC, llvm::sys::fs::F_None);
+ if (EC)
return Error("Unable to open local file %s", output_filename.c_str());
dst.write(&output_buffer[0], output_buffer.size());
dst.close();
- if (!dst)
+ if (dst.has_error())
return Error("Failed to write file %s", output_filename.c_str());
return Error();
}
@@ -428,8 +430,9 @@ Error AdbClient::SyncService::internalPullFile(const FileSpec &remote_file,
const auto local_file_path = local_file.GetPath();
llvm::FileRemover local_file_remover(local_file_path);
- std::ofstream dst(local_file_path, std::ios::out | std::ios::binary);
- if (!dst.is_open())
+ std::error_code EC;
+ llvm::raw_fd_ostream dst(local_file_path, EC, llvm::sys::fs::F_None);
+ if (EC)
return Error("Unable to open local file %s", local_file_path.c_str());
const auto remote_file_path = remote_file.GetPath(false);
@@ -447,6 +450,9 @@ Error AdbClient::SyncService::internalPullFile(const FileSpec &remote_file,
if (!eof)
dst.write(&chunk[0], chunk.size());
}
+ dst.close();
+ if (dst.has_error())
+ return Error("Failed to write file %s", local_file_path.c_str());
local_file_remover.releaseFile();
return error;
diff --git a/source/Plugins/Platform/Android/AdbClient.h b/source/Plugins/Platform/Android/AdbClient.h
index 169a0b5a4e3e..9e8726c93b61 100644
--- a/source/Plugins/Platform/Android/AdbClient.h
+++ b/source/Plugins/Platform/Android/AdbClient.h
@@ -10,7 +10,7 @@
#ifndef liblldb_AdbClient_h_
#define liblldb_AdbClient_h_
-#include "lldb/Core/Error.h"
+#include "lldb/Utility/Error.h"
#include <chrono>
#include <functional>
#include <list>
diff --git a/source/Plugins/Platform/Android/CMakeLists.txt b/source/Plugins/Platform/Android/CMakeLists.txt
index e831a33a4b6d..5abb51a0b94a 100644
--- a/source/Plugins/Platform/Android/CMakeLists.txt
+++ b/source/Plugins/Platform/Android/CMakeLists.txt
@@ -1,5 +1,13 @@
-add_lldb_library(lldbPluginPlatformAndroid
+add_lldb_library(lldbPluginPlatformAndroid PLUGIN
AdbClient.cpp
PlatformAndroid.cpp
PlatformAndroidRemoteGDBServer.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbPluginPlatformLinux
+ lldbPluginPlatformGDB
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/Platform/Android/PlatformAndroid.cpp b/source/Plugins/Platform/Android/PlatformAndroid.cpp
index 64a320f8c3fc..ad3918d4e202 100644
--- a/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ b/source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -7,11 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-#include "Utility/UriParser.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Scalar.h"
@@ -19,6 +14,8 @@
#include "lldb/Core/ValueObject.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/StringConvert.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/UriParser.h"
// Project includes
#include "AdbClient.h"
@@ -336,7 +333,7 @@ Error PlatformAndroid::DownloadSymbolFile(const lldb::ModuleSP &module_sp,
// Create file remover for the temporary directory created on the device
std::unique_ptr<std::string, std::function<void(std::string *)>>
- tmpdir_remover(&tmpdir, [this, &adb](std::string *s) {
+ tmpdir_remover(&tmpdir, [&adb](std::string *s) {
StreamString command;
command.Printf("rm -rf %s", s->c_str());
Error error = adb.Shell(command.GetData(), seconds(5), nullptr);
diff --git a/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp b/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
index cabb3ffb1c15..0c5e478d470e 100644
--- a/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
+++ b/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
@@ -8,13 +8,13 @@
//===----------------------------------------------------------------------===//
// Other libraries and framework includes
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/common/TCPSocket.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/UriParser.h"
#include "PlatformAndroidRemoteGDBServer.h"
-#include "Utility/UriParser.h"
#include <sstream>
diff --git a/source/Plugins/Platform/CMakeLists.txt b/source/Plugins/Platform/CMakeLists.txt
index 2e3a3f7c1b2e..ddb71212ce48 100644
--- a/source/Plugins/Platform/CMakeLists.txt
+++ b/source/Plugins/Platform/CMakeLists.txt
@@ -4,6 +4,8 @@
add_subdirectory(FreeBSD)
#elseif (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
add_subdirectory(NetBSD)
+#elseif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
+ add_subdirectory(OpenBSD)
#elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_subdirectory(MacOSX)
#elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
diff --git a/source/Plugins/Platform/FreeBSD/CMakeLists.txt b/source/Plugins/Platform/FreeBSD/CMakeLists.txt
index 57153969c3b4..1c27e1b7adaa 100644
--- a/source/Plugins/Platform/FreeBSD/CMakeLists.txt
+++ b/source/Plugins/Platform/FreeBSD/CMakeLists.txt
@@ -1,3 +1,9 @@
-add_lldb_library(lldbPluginPlatformFreeBSD
+add_lldb_library(lldbPluginPlatformFreeBSD PLUGIN
PlatformFreeBSD.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbHost
+ lldbTarget
)
diff --git a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
index 9ea97a5f70ba..2a150b5d452b 100644
--- a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
+++ b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
@@ -22,22 +22,34 @@
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/BreakpointSite.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Module.h"
-#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Host/Host.h"
+#include "lldb/Core/State.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+
+// Define these constants from FreeBSD mman.h for use when targeting
+// remote FreeBSD systems even when host has different values.
+#define MAP_PRIVATE 0x0002
+#define MAP_ANON 0x1000
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::platform_freebsd;
+static uint32_t g_initialize_count = 0;
+
+//------------------------------------------------------------------
+
PlatformSP PlatformFreeBSD::CreateInstance(bool force, const ArchSpec *arch) {
- // The only time we create an instance is when we are creating a remote
- // freebsd platform
- const bool is_host = false;
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force,
+ arch ? arch->GetArchitectureName() : "<null>",
+ arch ? arch->GetTriple().getTriple() : "<null>");
bool create = force;
if (create == false && arch && arch->IsValid()) {
@@ -47,7 +59,7 @@ PlatformSP PlatformFreeBSD::CreateInstance(bool force, const ArchSpec *arch) {
create = true;
break;
-#if defined(__FreeBSD__) || defined(__OpenBSD__)
+#if defined(__FreeBSD__)
// Only accept "unknown" for the OS if the host is BSD and
// it "unknown" wasn't specified (it was just returned because it
// was NOT specified)
@@ -59,8 +71,10 @@ PlatformSP PlatformFreeBSD::CreateInstance(bool force, const ArchSpec *arch) {
break;
}
}
- if (create)
- return PlatformSP(new PlatformFreeBSD(is_host));
+ LLDB_LOG(log, "create = {0}", create);
+ if (create) {
+ return PlatformSP(new PlatformFreeBSD(false));
+ }
return PlatformSP();
}
@@ -74,369 +88,51 @@ ConstString PlatformFreeBSD::GetPluginNameStatic(bool is_host) {
}
}
-const char *PlatformFreeBSD::GetDescriptionStatic(bool is_host) {
+const char *PlatformFreeBSD::GetPluginDescriptionStatic(bool is_host) {
if (is_host)
return "Local FreeBSD user platform plug-in.";
else
return "Remote FreeBSD user platform plug-in.";
}
-static uint32_t g_initialize_count = 0;
+ConstString PlatformFreeBSD::GetPluginName() {
+ return GetPluginNameStatic(IsHost());
+}
void PlatformFreeBSD::Initialize() {
Platform::Initialize();
if (g_initialize_count++ == 0) {
#if defined(__FreeBSD__)
- // Force a host flag to true for the default platform object.
PlatformSP default_platform_sp(new PlatformFreeBSD(true));
default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
Platform::SetHostPlatform(default_platform_sp);
#endif
- PluginManager::RegisterPlugin(PlatformFreeBSD::GetPluginNameStatic(false),
- PlatformFreeBSD::GetDescriptionStatic(false),
- PlatformFreeBSD::CreateInstance);
+ PluginManager::RegisterPlugin(
+ PlatformFreeBSD::GetPluginNameStatic(false),
+ PlatformFreeBSD::GetPluginDescriptionStatic(false),
+ PlatformFreeBSD::CreateInstance, nullptr);
}
}
void PlatformFreeBSD::Terminate() {
- if (g_initialize_count > 0 && --g_initialize_count == 0)
- PluginManager::UnregisterPlugin(PlatformFreeBSD::CreateInstance);
-
- Platform::Terminate();
-}
-
-bool PlatformFreeBSD::GetModuleSpec(const FileSpec &module_file_spec,
- const ArchSpec &arch,
- ModuleSpec &module_spec) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetModuleSpec(module_file_spec, arch,
- module_spec);
-
- return Platform::GetModuleSpec(module_file_spec, arch, module_spec);
-}
-
-Error PlatformFreeBSD::RunShellCommand(const char *command,
- const FileSpec &working_dir,
- int *status_ptr, int *signo_ptr,
- std::string *command_output,
- uint32_t timeout_sec) {
- if (IsHost())
- return Host::RunShellCommand(command, working_dir, status_ptr, signo_ptr,
- command_output, timeout_sec);
- else {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->RunShellCommand(command, working_dir,
- status_ptr, signo_ptr,
- command_output, timeout_sec);
- else
- return Error("unable to run a remote command without a platform");
- }
-}
-
-Error PlatformFreeBSD::ResolveExecutable(
- const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr) {
- Error error;
- // Nothing special to do here, just use the actual file and architecture
-
- char exe_path[PATH_MAX];
- ModuleSpec resolved_module_spec(module_spec);
-
- if (IsHost()) {
- // If we have "ls" as the module_spec's file, resolve the executable
- // location based on
- // the current path variables
- if (!resolved_module_spec.GetFileSpec().Exists()) {
- module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
- resolved_module_spec.GetFileSpec().SetFile(exe_path, true);
- }
-
- if (!resolved_module_spec.GetFileSpec().Exists())
- resolved_module_spec.GetFileSpec().ResolveExecutableLocation();
-
- if (resolved_module_spec.GetFileSpec().Exists())
- error.Clear();
- else {
- error.SetErrorStringWithFormat(
- "unable to find executable for '%s'",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- } else {
- if (m_remote_platform_sp) {
- error =
- GetCachedExecutable(resolved_module_spec, exe_module_sp,
- module_search_paths_ptr, *m_remote_platform_sp);
- } else {
- // We may connect to a process and use the provided executable (Don't use
- // local $PATH).
-
- // Resolve any executable within a bundle on MacOSX
- Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
-
- if (resolved_module_spec.GetFileSpec().Exists()) {
- error.Clear();
- } else {
- error.SetErrorStringWithFormat(
- "the platform is not currently connected, and '%s' doesn't exist "
- "in the system root.",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- }
-
- if (error.Success()) {
- if (resolved_module_spec.GetArchitecture().IsValid()) {
- error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
- module_search_paths_ptr, NULL, NULL);
-
- if (!exe_module_sp || exe_module_sp->GetObjectFile() == NULL) {
- exe_module_sp.reset();
- error.SetErrorStringWithFormat(
- "'%s' doesn't contain the architecture %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
- } else {
- // No valid architecture was specified, ask the platform for
- // the architectures that we should be using (in the correct order)
- // and see if we can find a match that way
- StreamString arch_names;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
- idx, resolved_module_spec.GetArchitecture());
- ++idx) {
- error =
- ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
- module_search_paths_ptr, NULL, NULL);
- // Did we find an executable using one of the
- if (error.Success()) {
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- break;
- else
- error.SetErrorToGenericError();
- }
-
- if (idx > 0)
- arch_names.PutCString(", ");
- arch_names.PutCString(
- resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
-
- if (error.Fail() || !exe_module_sp) {
- if (resolved_module_spec.GetFileSpec().Readable()) {
- error.SetErrorStringWithFormat(
- "'%s' doesn't contain any '%s' platform architectures: %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- GetPluginName().GetCString(), arch_names.GetData());
- } else {
- error.SetErrorStringWithFormat(
- "'%s' is not readable",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
+ if (g_initialize_count > 0) {
+ if (--g_initialize_count == 0) {
+ PluginManager::UnregisterPlugin(PlatformFreeBSD::CreateInstance);
}
}
- return error;
-}
-
-// From PlatformMacOSX only
-Error PlatformFreeBSD::GetFileWithUUID(const FileSpec &platform_file,
- const UUID *uuid_ptr,
- FileSpec &local_file) {
- if (IsRemote()) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr,
- local_file);
- }
-
- // Default to the local case
- local_file = platform_file;
- return Error();
+ PlatformPOSIX::Terminate();
}
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
PlatformFreeBSD::PlatformFreeBSD(bool is_host)
- : Platform(is_host), m_remote_platform_sp() {}
-
-//------------------------------------------------------------------
-/// Destructor.
-///
-/// The destructor is virtual since this class is designed to be
-/// inherited from by the plug-in instance.
-//------------------------------------------------------------------
-PlatformFreeBSD::~PlatformFreeBSD() {}
-
-// TODO:VK: inherit PlatformPOSIX
+ : PlatformPOSIX(is_host) // This is the local host platform
+{}
-bool PlatformFreeBSD::GetRemoteOSVersion() {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetOSVersion(
- m_major_os_version, m_minor_os_version, m_update_os_version);
- return false;
-}
-
-bool PlatformFreeBSD::GetRemoteOSBuildString(std::string &s) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteOSBuildString(s);
- s.clear();
- return false;
-}
-
-bool PlatformFreeBSD::GetRemoteOSKernelDescription(std::string &s) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteOSKernelDescription(s);
- s.clear();
- return false;
-}
-
-// Remote Platform subclasses need to override this function
-ArchSpec PlatformFreeBSD::GetRemoteSystemArchitecture() {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteSystemArchitecture();
- return ArchSpec();
-}
-
-const char *PlatformFreeBSD::GetHostname() {
- if (IsHost())
- return Platform::GetHostname();
-
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetHostname();
- return NULL;
-}
-
-bool PlatformFreeBSD::IsConnected() const {
- if (IsHost())
- return true;
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->IsConnected();
- return false;
-}
-
-Error PlatformFreeBSD::ConnectRemote(Args &args) {
- Error error;
- if (IsHost()) {
- error.SetErrorStringWithFormat(
- "can't connect to the host platform '%s', always connected",
- GetPluginName().GetCString());
- } else {
- if (!m_remote_platform_sp)
- m_remote_platform_sp =
- Platform::Create(ConstString("remote-gdb-server"), error);
-
- if (m_remote_platform_sp) {
- if (error.Success()) {
- if (m_remote_platform_sp) {
- error = m_remote_platform_sp->ConnectRemote(args);
- } else {
- error.SetErrorString(
- "\"platform connect\" takes a single argument: <connect-url>");
- }
- }
- } else
- error.SetErrorString("failed to create a 'remote-gdb-server' platform");
-
- if (error.Fail())
- m_remote_platform_sp.reset();
- }
-
- return error;
-}
-
-Error PlatformFreeBSD::DisconnectRemote() {
- Error error;
-
- if (IsHost()) {
- error.SetErrorStringWithFormat(
- "can't disconnect from the host platform '%s', always connected",
- GetPluginName().GetCString());
- } else {
- if (m_remote_platform_sp)
- error = m_remote_platform_sp->DisconnectRemote();
- else
- error.SetErrorString("the platform is not currently connected");
- }
- return error;
-}
-
-bool PlatformFreeBSD::GetProcessInfo(lldb::pid_t pid,
- ProcessInstanceInfo &process_info) {
- bool success = false;
- if (IsHost()) {
- success = Platform::GetProcessInfo(pid, process_info);
- } else if (m_remote_platform_sp) {
- success = m_remote_platform_sp->GetProcessInfo(pid, process_info);
- }
- return success;
-}
-
-uint32_t
-PlatformFreeBSD::FindProcesses(const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos) {
- uint32_t match_count = 0;
- if (IsHost()) {
- // Let the base class figure out the host details
- match_count = Platform::FindProcesses(match_info, process_infos);
- } else {
- // If we are remote, we can only return results if we are connected
- if (m_remote_platform_sp)
- match_count =
- m_remote_platform_sp->FindProcesses(match_info, process_infos);
- }
- return match_count;
-}
-
-const char *PlatformFreeBSD::GetUserName(uint32_t uid) {
- // Check the cache in Platform in case we have already looked this uid up
- const char *user_name = Platform::GetUserName(uid);
- if (user_name)
- return user_name;
-
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetUserName(uid);
- return NULL;
-}
-
-const char *PlatformFreeBSD::GetGroupName(uint32_t gid) {
- const char *group_name = Platform::GetGroupName(gid);
- if (group_name)
- return group_name;
-
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetGroupName(gid);
- return NULL;
-}
-
-Error PlatformFreeBSD::GetSharedModule(
- const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr) {
- Error error;
- module_sp.reset();
-
- if (IsRemote()) {
- // If we have a remote platform always, let it try and locate
- // the shared module first.
- if (m_remote_platform_sp) {
- error = m_remote_platform_sp->GetSharedModule(
- module_spec, process, module_sp, module_search_paths_ptr,
- old_module_sp_ptr, did_create_ptr);
- }
- }
-
- if (!module_sp) {
- // Fall back to the local platform and find the file locally
- error = Platform::GetSharedModule(module_spec, process, module_sp,
- module_search_paths_ptr,
- old_module_sp_ptr, did_create_ptr);
- }
- if (module_sp)
- module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
- return error;
-}
+PlatformFreeBSD::~PlatformFreeBSD() = default;
bool PlatformFreeBSD::GetSupportedArchitectureAtIndex(uint32_t idx,
ArchSpec &arch) {
@@ -507,26 +203,23 @@ bool PlatformFreeBSD::GetSupportedArchitectureAtIndex(uint32_t idx,
}
void PlatformFreeBSD::GetStatus(Stream &strm) {
-#ifndef LLDB_DISABLE_POSIX
- struct utsname un;
-
- strm << " Host: ";
+ Platform::GetStatus(strm);
- ::memset(&un, 0, sizeof(utsname));
- if (uname(&un) == -1)
- strm << "FreeBSD" << '\n';
+#ifndef LLDB_DISABLE_POSIX
+ // Display local kernel information only when we are running in host mode.
+ // Otherwise, we would end up printing non-FreeBSD information (when running
+ // on Mac OS for example).
+ if (IsHost()) {
+ struct utsname un;
- strm << un.sysname << ' ' << un.release;
- if (un.nodename[0] != '\0')
- strm << " (" << un.nodename << ')';
- strm << '\n';
+ if (uname(&un))
+ return;
- // Dump a common information about the platform status.
- strm << "Host: " << un.sysname << ' ' << un.release << ' ' << un.version
- << '\n';
+ strm.Printf(" Kernel: %s\n", un.sysname);
+ strm.Printf(" Release: %s\n", un.release);
+ strm.Printf(" Version: %s\n", un.version);
+ }
#endif
-
- Platform::GetStatus(strm);
}
size_t
@@ -549,6 +242,12 @@ PlatformFreeBSD::GetSoftwareBreakpointTrapOpcode(Target &target,
// FreeBSD kernel as of 10.x, does not support thumb breakpoints
return 0;
}
+
+ static const uint8_t g_arm_breakpoint_opcode[] = {0xFE, 0xDE, 0xFF, 0xE7};
+ size_t trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
+ assert(bp_site);
+ if (bp_site->SetTrapOpcode(g_arm_breakpoint_opcode, trap_opcode_size))
+ return trap_opcode_size;
}
LLVM_FALLTHROUGH;
default:
@@ -556,10 +255,6 @@ PlatformFreeBSD::GetSoftwareBreakpointTrapOpcode(Target &target,
}
}
-void PlatformFreeBSD::CalculateTrapHandlerSymbolNames() {
- m_trap_handlers.push_back(ConstString("_sigtramp"));
-}
-
Error PlatformFreeBSD::LaunchProcess(ProcessLaunchInfo &launch_info) {
Error error;
if (IsHost()) {
@@ -609,3 +304,23 @@ lldb::ProcessSP PlatformFreeBSD::Attach(ProcessAttachInfo &attach_info,
}
return process_sp;
}
+
+// FreeBSD processes cannot yet be launched by spawning and attaching.
+bool PlatformFreeBSD::CanDebugProcess() {
+ return false;
+}
+
+void PlatformFreeBSD::CalculateTrapHandlerSymbolNames() {
+ m_trap_handlers.push_back(ConstString("_sigtramp"));
+}
+
+uint64_t PlatformFreeBSD::ConvertMmapFlagsToPlatform(const ArchSpec &arch,
+ unsigned flags) {
+ uint64_t flags_platform = 0;
+
+ if (flags & eMmapFlagsPrivate)
+ flags_platform |= MAP_PRIVATE;
+ if (flags & eMmapFlagsAnon)
+ flags_platform |= MAP_ANON;
+ return flags_platform;
+}
diff --git a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
index f0ebfbcae701..c8ac7b29f3a2 100644
--- a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
+++ b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
@@ -10,116 +10,59 @@
#ifndef liblldb_PlatformFreeBSD_h_
#define liblldb_PlatformFreeBSD_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Target/Platform.h"
+#include "Plugins/Platform/POSIX/PlatformPOSIX.h"
namespace lldb_private {
namespace platform_freebsd {
-class PlatformFreeBSD : public Platform {
+class PlatformFreeBSD : public PlatformPOSIX {
public:
PlatformFreeBSD(bool is_host);
~PlatformFreeBSD() override;
- //------------------------------------------------------------
- // Class functions
- //------------------------------------------------------------
- static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch);
-
static void Initialize();
static void Terminate();
- static ConstString GetPluginNameStatic(bool is_host);
-
- static const char *GetDescriptionStatic(bool is_host);
-
//------------------------------------------------------------
// lldb_private::PluginInterface functions
//------------------------------------------------------------
- ConstString GetPluginName() override { return GetPluginNameStatic(IsHost()); }
+ static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch);
- uint32_t GetPluginVersion() override { return 1; }
+ static ConstString GetPluginNameStatic(bool is_host);
- const char *GetDescription() override {
- return GetDescriptionStatic(IsHost());
- }
+ static const char *GetPluginDescriptionStatic(bool is_host);
+
+ ConstString GetPluginName() override;
+
+ uint32_t GetPluginVersion() override { return 1; }
//------------------------------------------------------------
// lldb_private::Platform functions
//------------------------------------------------------------
- bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch,
- ModuleSpec &module_spec) override;
+ const char *GetDescription() override {
+ return GetPluginDescriptionStatic(IsHost());
+ }
- Error RunShellCommand(const char *command, const FileSpec &working_dir,
- int *status_ptr, int *signo_ptr,
- std::string *command_output,
- uint32_t timeout_sec) override;
+ void GetStatus(Stream &strm) override;
+
+ bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override;
- Error ResolveExecutable(const ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr) override;
+ bool CanDebugProcess() override;
size_t GetSoftwareBreakpointTrapOpcode(Target &target,
BreakpointSite *bp_site) override;
- bool GetRemoteOSVersion() override;
-
- bool GetRemoteOSBuildString(std::string &s) override;
-
- bool GetRemoteOSKernelDescription(std::string &s) override;
-
- // Remote Platform subclasses need to override this function
- ArchSpec GetRemoteSystemArchitecture() override;
-
- bool IsConnected() const override;
-
- Error ConnectRemote(Args &args) override;
-
- Error DisconnectRemote() override;
-
- const char *GetHostname() override;
-
- const char *GetUserName(uint32_t uid) override;
-
- const char *GetGroupName(uint32_t gid) override;
-
- bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) override;
-
- uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos) override;
-
Error LaunchProcess(ProcessLaunchInfo &launch_info) override;
lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger,
Target *target, Error &error) override;
- // FreeBSD processes can not be launched by spawning and attaching.
- bool CanDebugProcess() override { return false; }
-
- // Only on PlatformMacOSX:
- Error GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid,
- FileSpec &local_file) override;
-
- Error GetSharedModule(const ModuleSpec &module_spec, Process *process,
- lldb::ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr,
- lldb::ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr) override;
-
- bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override;
-
- void GetStatus(Stream &strm) override;
-
void CalculateTrapHandlerSymbolNames() override;
-protected:
- lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a
- // remote freebsd OS
+ uint64_t ConvertMmapFlagsToPlatform(const ArchSpec &arch,
+ unsigned flags) override;
private:
DISALLOW_COPY_AND_ASSIGN(PlatformFreeBSD);
diff --git a/source/Plugins/Platform/Kalimba/CMakeLists.txt b/source/Plugins/Platform/Kalimba/CMakeLists.txt
index df0bf9761a00..02f1827f9a48 100644
--- a/source/Plugins/Platform/Kalimba/CMakeLists.txt
+++ b/source/Plugins/Platform/Kalimba/CMakeLists.txt
@@ -1,3 +1,8 @@
-add_lldb_library(lldbPluginPlatformKalimba
+add_lldb_library(lldbPluginPlatformKalimba PLUGIN
PlatformKalimba.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbTarget
)
diff --git a/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp b/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp
index ac3fe6eafd52..08a3a6aa6c26 100644
--- a/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp
+++ b/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp
@@ -15,16 +15,16 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
@@ -84,104 +84,6 @@ void PlatformKalimba::Terminate() {
Platform::Terminate();
}
-Error PlatformKalimba::ResolveExecutable(
- const ModuleSpec &ms, lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr) {
- Error error;
- char exe_path[PATH_MAX];
- ModuleSpec resolved_module_spec(ms);
-
- if (!resolved_module_spec.GetFileSpec().Exists()) {
- resolved_module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
- error.SetErrorStringWithFormat("unable to find executable for '%s'",
- exe_path);
- }
-
- if (error.Success()) {
- if (resolved_module_spec.GetArchitecture().IsValid()) {
- error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
- NULL, NULL, NULL);
- if (error.Fail()) {
- // If we failed, it may be because the vendor and os aren't known. If
- // that is the
- // case, try setting them to the host architecture and give it another
- // try.
- llvm::Triple &module_triple =
- resolved_module_spec.GetArchitecture().GetTriple();
- bool is_vendor_specified =
- (module_triple.getVendor() != llvm::Triple::UnknownVendor);
- bool is_os_specified =
- (module_triple.getOS() != llvm::Triple::UnknownOS);
- if (!is_vendor_specified || !is_os_specified) {
- const llvm::Triple &host_triple =
- HostInfo::GetArchitecture(HostInfo::eArchKindDefault).GetTriple();
-
- if (!is_vendor_specified)
- module_triple.setVendorName(host_triple.getVendorName());
- if (!is_os_specified)
- module_triple.setOSName(host_triple.getOSName());
-
- error = ModuleList::GetSharedModule(resolved_module_spec,
- exe_module_sp, NULL, NULL, NULL);
- }
- }
-
- // TODO find out why exe_module_sp might be NULL
- if (!exe_module_sp || exe_module_sp->GetObjectFile() == NULL) {
- exe_module_sp.reset();
- error.SetErrorStringWithFormat(
- "'%s' doesn't contain the architecture %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
- } else {
- // No valid architecture was specified, ask the platform for
- // the architectures that we should be using (in the correct order)
- // and see if we can find a match that way
- StreamString arch_names;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
- idx, resolved_module_spec.GetArchitecture());
- ++idx) {
- error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
- NULL, NULL, NULL);
- // Did we find an executable using one of the
- if (error.Success()) {
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- break;
- else
- error.SetErrorToGenericError();
- }
-
- if (idx > 0)
- arch_names.PutCString(", ");
- arch_names.PutCString(
- resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
-
- if (error.Fail() || !exe_module_sp) {
- if (resolved_module_spec.GetFileSpec().Readable()) {
- error.SetErrorStringWithFormat(
- "'%s' doesn't contain any '%s' platform architectures: %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- GetPluginName().GetCString(), arch_names.GetData());
- } else {
- error.SetErrorStringWithFormat(
- "'%s' is not readable",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- }
- }
-
- return error;
-}
-
-Error PlatformKalimba::GetFileWithUUID(const FileSpec & /*platform_file*/,
- const UUID * /*uuid_ptr*/,
- FileSpec & /*local_file*/) {
- return Error();
-}
-
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
@@ -197,18 +99,6 @@ PlatformKalimba::PlatformKalimba(bool is_host)
//------------------------------------------------------------------
PlatformKalimba::~PlatformKalimba() {}
-bool PlatformKalimba::GetProcessInfo(lldb::pid_t pid,
- ProcessInstanceInfo &process_info) {
- bool success = false;
- if (IsHost()) {
- success = false;
- } else {
- if (m_remote_platform_sp)
- success = m_remote_platform_sp->GetProcessInfo(pid, process_info);
- }
- return success;
-}
-
bool PlatformKalimba::GetSupportedArchitectureAtIndex(uint32_t idx,
ArchSpec &arch) {
if (idx == 0) {
diff --git a/source/Plugins/Platform/Kalimba/PlatformKalimba.h b/source/Plugins/Platform/Kalimba/PlatformKalimba.h
index 76e6d41e8716..0c94ec9ec8f7 100644
--- a/source/Plugins/Platform/Kalimba/PlatformKalimba.h
+++ b/source/Plugins/Platform/Kalimba/PlatformKalimba.h
@@ -45,21 +45,12 @@ public:
//------------------------------------------------------------
// lldb_private::Platform functions
//------------------------------------------------------------
- Error ResolveExecutable(const lldb_private::ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr) override;
-
const char *GetDescription() override {
return GetPluginDescriptionStatic(IsHost());
}
void GetStatus(Stream &strm) override;
- Error GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid,
- FileSpec &local_file) override;
-
- bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) override;
-
bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override;
size_t GetSoftwareBreakpointTrapOpcode(Target &target,
diff --git a/source/Plugins/Platform/Linux/CMakeLists.txt b/source/Plugins/Platform/Linux/CMakeLists.txt
index 4a9eb1460e38..bad039d0ad50 100644
--- a/source/Plugins/Platform/Linux/CMakeLists.txt
+++ b/source/Plugins/Platform/Linux/CMakeLists.txt
@@ -1,3 +1,11 @@
-add_lldb_library(lldbPluginPlatformLinux
+add_lldb_library(lldbPluginPlatformLinux PLUGIN
PlatformLinux.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbHost
+ lldbInterpreter
+ lldbTarget
+ lldbPluginPlatformPOSIX
)
diff --git a/source/Plugins/Platform/Linux/PlatformLinux.cpp b/source/Plugins/Platform/Linux/PlatformLinux.cpp
index 036c0f1be835..4dd5398fcfa3 100644
--- a/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ b/source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -19,22 +19,16 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Module.h"
-#include "lldb/Core/ModuleList.h"
-#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/State.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/HostInfo.h"
-#include "lldb/Interpreter/OptionValueProperties.h"
-#include "lldb/Interpreter/Property.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
// Define these constants from Linux mman.h for use when targeting
// remote linux systems even when host has different values.
@@ -48,79 +42,12 @@ using namespace lldb_private::platform_linux;
static uint32_t g_initialize_count = 0;
//------------------------------------------------------------------
-/// Code to handle the PlatformLinux settings
-//------------------------------------------------------------------
-
-namespace {
-class PlatformLinuxProperties : public Properties {
-public:
- PlatformLinuxProperties();
-
- ~PlatformLinuxProperties() override = default;
-
- static ConstString &GetSettingName();
-
-private:
- static const PropertyDefinition *GetStaticPropertyDefinitions();
-};
-
-typedef std::shared_ptr<PlatformLinuxProperties> PlatformLinuxPropertiesSP;
-
-} // anonymous namespace
-
-PlatformLinuxProperties::PlatformLinuxProperties() : Properties() {
- m_collection_sp.reset(new OptionValueProperties(GetSettingName()));
- m_collection_sp->Initialize(GetStaticPropertyDefinitions());
-}
-
-ConstString &PlatformLinuxProperties::GetSettingName() {
- static ConstString g_setting_name("linux");
- return g_setting_name;
-}
-
-const PropertyDefinition *
-PlatformLinuxProperties::GetStaticPropertyDefinitions() {
- static PropertyDefinition g_properties[] = {
- {NULL, OptionValue::eTypeInvalid, false, 0, NULL, NULL, NULL}};
-
- return g_properties;
-}
-
-static const PlatformLinuxPropertiesSP &GetGlobalProperties() {
- static PlatformLinuxPropertiesSP g_settings_sp;
- if (!g_settings_sp)
- g_settings_sp.reset(new PlatformLinuxProperties());
- return g_settings_sp;
-}
-
-void PlatformLinux::DebuggerInitialize(Debugger &debugger) {
- if (!PluginManager::GetSettingForPlatformPlugin(
- debugger, PlatformLinuxProperties::GetSettingName())) {
- const bool is_global_setting = true;
- PluginManager::CreateSettingForPlatformPlugin(
- debugger, GetGlobalProperties()->GetValueProperties(),
- ConstString("Properties for the PlatformLinux plug-in."),
- is_global_setting);
- }
-}
-
-//------------------------------------------------------------------
PlatformSP PlatformLinux::CreateInstance(bool force, const ArchSpec *arch) {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
- if (log) {
- const char *arch_name;
- if (arch && arch->GetArchitectureName())
- arch_name = arch->GetArchitectureName();
- else
- arch_name = "<null>";
-
- const char *triple_cstr =
- arch ? arch->GetTriple().getTriple().c_str() : "<null>";
-
- log->Printf("PlatformLinux::%s(force=%s, arch={%s,%s})", __FUNCTION__,
- force ? "true" : "false", arch_name, triple_cstr);
- }
+ LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force,
+ arch ? arch->GetArchitectureName() : "<null>",
+ arch ? arch->GetTriple().getTriple() : "<null>");
bool create = force;
if (create == false && arch && arch->IsValid()) {
@@ -143,18 +70,10 @@ PlatformSP PlatformLinux::CreateInstance(bool force, const ArchSpec *arch) {
}
}
+ LLDB_LOG(log, "create = {0}", create);
if (create) {
- if (log)
- log->Printf("PlatformLinux::%s() creating remote-linux platform",
- __FUNCTION__);
return PlatformSP(new PlatformLinux(false));
}
-
- if (log)
- log->Printf(
- "PlatformLinux::%s() aborting creation of remote-linux platform",
- __FUNCTION__);
-
return PlatformSP();
}
@@ -191,7 +110,7 @@ void PlatformLinux::Initialize() {
PluginManager::RegisterPlugin(
PlatformLinux::GetPluginNameStatic(false),
PlatformLinux::GetPluginDescriptionStatic(false),
- PlatformLinux::CreateInstance, PlatformLinux::DebuggerInitialize);
+ PlatformLinux::CreateInstance, nullptr);
}
}
@@ -205,145 +124,6 @@ void PlatformLinux::Terminate() {
PlatformPOSIX::Terminate();
}
-Error PlatformLinux::ResolveExecutable(
- const ModuleSpec &ms, lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr) {
- Error error;
- // Nothing special to do here, just use the actual file and architecture
-
- char exe_path[PATH_MAX];
- ModuleSpec resolved_module_spec(ms);
-
- if (IsHost()) {
- // If we have "ls" as the exe_file, resolve the executable location based on
- // the current path variables
- if (!resolved_module_spec.GetFileSpec().Exists()) {
- resolved_module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
- resolved_module_spec.GetFileSpec().SetFile(exe_path, true);
- }
-
- if (!resolved_module_spec.GetFileSpec().Exists())
- resolved_module_spec.GetFileSpec().ResolveExecutableLocation();
-
- if (resolved_module_spec.GetFileSpec().Exists())
- error.Clear();
- else {
- error.SetErrorStringWithFormat(
- "unable to find executable for '%s'",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- } else {
- if (m_remote_platform_sp) {
- error =
- GetCachedExecutable(resolved_module_spec, exe_module_sp,
- module_search_paths_ptr, *m_remote_platform_sp);
- } else {
- // We may connect to a process and use the provided executable (Don't use
- // local $PATH).
-
- if (resolved_module_spec.GetFileSpec().Exists())
- error.Clear();
- else
- error.SetErrorStringWithFormat("the platform is not currently "
- "connected, and '%s' doesn't exist in "
- "the system root.",
- exe_path);
- }
- }
-
- if (error.Success()) {
- if (resolved_module_spec.GetArchitecture().IsValid()) {
- error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
- NULL, NULL, NULL);
- if (error.Fail()) {
- // If we failed, it may be because the vendor and os aren't known. If
- // that is the
- // case, try setting them to the host architecture and give it another
- // try.
- llvm::Triple &module_triple =
- resolved_module_spec.GetArchitecture().GetTriple();
- bool is_vendor_specified =
- (module_triple.getVendor() != llvm::Triple::UnknownVendor);
- bool is_os_specified =
- (module_triple.getOS() != llvm::Triple::UnknownOS);
- if (!is_vendor_specified || !is_os_specified) {
- const llvm::Triple &host_triple =
- HostInfo::GetArchitecture(HostInfo::eArchKindDefault).GetTriple();
-
- if (!is_vendor_specified)
- module_triple.setVendorName(host_triple.getVendorName());
- if (!is_os_specified)
- module_triple.setOSName(host_triple.getOSName());
-
- error = ModuleList::GetSharedModule(resolved_module_spec,
- exe_module_sp, NULL, NULL, NULL);
- }
- }
-
- // TODO find out why exe_module_sp might be NULL
- if (!exe_module_sp || exe_module_sp->GetObjectFile() == NULL) {
- exe_module_sp.reset();
- error.SetErrorStringWithFormat(
- "'%s' doesn't contain the architecture %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
- } else {
- // No valid architecture was specified, ask the platform for
- // the architectures that we should be using (in the correct order)
- // and see if we can find a match that way
- StreamString arch_names;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
- idx, resolved_module_spec.GetArchitecture());
- ++idx) {
- error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
- NULL, NULL, NULL);
- // Did we find an executable using one of the
- if (error.Success()) {
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- break;
- else
- error.SetErrorToGenericError();
- }
-
- if (idx > 0)
- arch_names.PutCString(", ");
- arch_names.PutCString(
- resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
-
- if (error.Fail() || !exe_module_sp) {
- if (resolved_module_spec.GetFileSpec().Readable()) {
- error.SetErrorStringWithFormat(
- "'%s' doesn't contain any '%s' platform architectures: %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- GetPluginName().GetCString(), arch_names.GetData());
- } else {
- error.SetErrorStringWithFormat(
- "'%s' is not readable",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- }
- }
-
- return error;
-}
-
-Error PlatformLinux::GetFileWithUUID(const FileSpec &platform_file,
- const UUID *uuid_ptr,
- FileSpec &local_file) {
- if (IsRemote()) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr,
- local_file);
- }
-
- // Default to the local case
- local_file = platform_file;
- return Error();
-}
-
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
@@ -351,42 +131,8 @@ PlatformLinux::PlatformLinux(bool is_host)
: PlatformPOSIX(is_host) // This is the local host platform
{}
-//------------------------------------------------------------------
-/// Destructor.
-///
-/// The destructor is virtual since this class is designed to be
-/// inherited from by the plug-in instance.
-//------------------------------------------------------------------
PlatformLinux::~PlatformLinux() = default;
-bool PlatformLinux::GetProcessInfo(lldb::pid_t pid,
- ProcessInstanceInfo &process_info) {
- bool success = false;
- if (IsHost()) {
- success = Platform::GetProcessInfo(pid, process_info);
- } else {
- if (m_remote_platform_sp)
- success = m_remote_platform_sp->GetProcessInfo(pid, process_info);
- }
- return success;
-}
-
-uint32_t
-PlatformLinux::FindProcesses(const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos) {
- uint32_t match_count = 0;
- if (IsHost()) {
- // Let the base class figure out the host details
- match_count = Platform::FindProcesses(match_info, process_infos);
- } else {
- // If we are remote, we can only return results if we are connected
- if (m_remote_platform_sp)
- match_count =
- m_remote_platform_sp->FindProcesses(match_info, process_infos);
- }
- return match_count;
-}
-
bool PlatformLinux::GetSupportedArchitectureAtIndex(uint32_t idx,
ArchSpec &arch) {
if (IsHost()) {
@@ -526,19 +272,15 @@ bool PlatformLinux::CanDebugProcess() {
}
// For local debugging, Linux will override the debug logic to use llgs-launch
-// rather than
-// lldb-launch, llgs-attach. This differs from current lldb-launch,
-// debugserver-attach
-// approach on MacOSX.
+// rather than lldb-launch, llgs-attach. This differs from current lldb-launch,
+// debugserver-attach approach on MacOSX.
lldb::ProcessSP
PlatformLinux::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
Target *target, // Can be NULL, if NULL create a new
// target, else use existing one
Error &error) {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
- if (log)
- log->Printf("PlatformLinux::%s entered (target %p)", __FUNCTION__,
- static_cast<void *>(target));
+ LLDB_LOG(log, "target {0}", target);
// If we're a remote host, use standard behavior from parent class.
if (!IsHost())
@@ -561,61 +303,42 @@ PlatformLinux::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
// Ensure we have a target.
if (target == nullptr) {
- if (log)
- log->Printf("PlatformLinux::%s creating new target", __FUNCTION__);
-
+ LLDB_LOG(log, "creating new target");
TargetSP new_target_sp;
error = debugger.GetTargetList().CreateTarget(debugger, "", "", false,
nullptr, new_target_sp);
if (error.Fail()) {
- if (log)
- log->Printf("PlatformLinux::%s failed to create new target: %s",
- __FUNCTION__, error.AsCString());
+ LLDB_LOG(log, "failed to create new target: {0}", error);
return process_sp;
}
target = new_target_sp.get();
if (!target) {
error.SetErrorString("CreateTarget() returned nullptr");
- if (log)
- log->Printf("PlatformLinux::%s failed: %s", __FUNCTION__,
- error.AsCString());
+ LLDB_LOG(log, "error: {0}", error);
return process_sp;
}
- } else {
- if (log)
- log->Printf("PlatformLinux::%s using provided target", __FUNCTION__);
}
// Mark target as currently selected target.
debugger.GetTargetList().SetSelectedTarget(target);
// Now create the gdb-remote process.
- if (log)
- log->Printf(
- "PlatformLinux::%s having target create process with gdb-remote plugin",
- __FUNCTION__);
+ LLDB_LOG(log, "having target create process with gdb-remote plugin");
process_sp = target->CreateProcess(
launch_info.GetListenerForProcess(debugger), "gdb-remote", nullptr);
if (!process_sp) {
error.SetErrorString("CreateProcess() failed for gdb-remote process");
- if (log)
- log->Printf("PlatformLinux::%s failed: %s", __FUNCTION__,
- error.AsCString());
+ LLDB_LOG(log, "error: {0}", error);
return process_sp;
- } else {
- if (log)
- log->Printf("PlatformLinux::%s successfully created process",
- __FUNCTION__);
}
+ LLDB_LOG(log, "successfully created process");
// Adjust launch for a hijacker.
ListenerSP listener_sp;
if (!launch_info.GetHijackListener()) {
- if (log)
- log->Printf("PlatformLinux::%s setting up hijacker", __FUNCTION__);
-
+ LLDB_LOG(log, "setting up hijacker");
listener_sp =
Listener::MakeListener("lldb.PlatformLinux.DebugProcess.hijack");
launch_info.SetHijackListener(listener_sp);
@@ -624,16 +347,13 @@ PlatformLinux::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
// Log file actions.
if (log) {
- log->Printf(
- "PlatformLinux::%s launching process with the following file actions:",
- __FUNCTION__);
-
+ LLDB_LOG(log, "launching process with the following file actions:");
StreamString stream;
size_t i = 0;
const FileAction *file_action;
while ((file_action = launch_info.GetFileActionAtIndex(i++)) != nullptr) {
file_action->Dump(stream);
- log->PutCString(stream.GetData());
+ LLDB_LOG(log, "{0}", stream.GetData());
stream.Clear();
}
}
@@ -646,16 +366,7 @@ PlatformLinux::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
const StateType state = process_sp->WaitForProcessToStop(
llvm::None, NULL, false, listener_sp);
- if (state == eStateStopped) {
- if (log)
- log->Printf("PlatformLinux::%s pid %" PRIu64 " state %s\n",
- __FUNCTION__, process_sp->GetID(), StateAsCString(state));
- } else {
- if (log)
- log->Printf("PlatformLinux::%s pid %" PRIu64
- " state is not stopped - %s\n",
- __FUNCTION__, process_sp->GetID(), StateAsCString(state));
- }
+ LLDB_LOG(log, "pid {0} state {0}", process_sp->GetID(), state);
}
// Hook up process PTY if we have one (which we should for local debugging
@@ -663,20 +374,11 @@ PlatformLinux::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
int pty_fd = launch_info.GetPTY().ReleaseMasterFileDescriptor();
if (pty_fd != lldb_utility::PseudoTerminal::invalid_fd) {
process_sp->SetSTDIOFileDescriptor(pty_fd);
- if (log)
- log->Printf("PlatformLinux::%s pid %" PRIu64
- " hooked up STDIO pty to process",
- __FUNCTION__, process_sp->GetID());
- } else {
- if (log)
- log->Printf("PlatformLinux::%s pid %" PRIu64
- " not using process STDIO pty",
- __FUNCTION__, process_sp->GetID());
- }
+ LLDB_LOG(log, "hooked up STDIO pty to process");
+ } else
+ LLDB_LOG(log, "not using process STDIO pty");
} else {
- if (log)
- log->Printf("PlatformLinux::%s process launch failed: %s", __FUNCTION__,
- error.AsCString());
+ LLDB_LOG(log, "process launch failed: {0}", error);
// FIXME figure out appropriate cleanup here. Do we delete the target? Do
// we delete the process? Does our caller do that?
}
@@ -707,11 +409,3 @@ uint64_t PlatformLinux::ConvertMmapFlagsToPlatform(const ArchSpec &arch,
return flags_platform;
}
-ConstString PlatformLinux::GetFullNameForDylib(ConstString basename) {
- if (basename.IsEmpty())
- return basename;
-
- StreamString stream;
- stream.Printf("lib%s.so", basename.GetCString());
- return ConstString(stream.GetString());
-}
diff --git a/source/Plugins/Platform/Linux/PlatformLinux.h b/source/Plugins/Platform/Linux/PlatformLinux.h
index f98c3e988cd1..f1386d1e4fe5 100644
--- a/source/Plugins/Platform/Linux/PlatformLinux.h
+++ b/source/Plugins/Platform/Linux/PlatformLinux.h
@@ -10,10 +10,6 @@
#ifndef liblldb_PlatformLinux_h_
#define liblldb_PlatformLinux_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
#include "Plugins/Platform/POSIX/PlatformPOSIX.h"
namespace lldb_private {
@@ -25,8 +21,6 @@ public:
~PlatformLinux() override;
- static void DebuggerInitialize(Debugger &debugger);
-
static void Initialize();
static void Terminate();
@@ -47,24 +41,12 @@ public:
//------------------------------------------------------------
// lldb_private::Platform functions
//------------------------------------------------------------
- Error ResolveExecutable(const ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr) override;
-
const char *GetDescription() override {
return GetPluginDescriptionStatic(IsHost());
}
void GetStatus(Stream &strm) override;
- Error GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid,
- FileSpec &local_file) override;
-
- bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) override;
-
- uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos) override;
-
bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override;
int32_t GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) override;
@@ -80,8 +62,6 @@ public:
uint64_t ConvertMmapFlagsToPlatform(const ArchSpec &arch,
unsigned flags) override;
- ConstString GetFullNameForDylib(ConstString basename) override;
-
private:
DISALLOW_COPY_AND_ASSIGN(PlatformLinux);
};
diff --git a/source/Plugins/Platform/MacOSX/CMakeLists.txt b/source/Plugins/Platform/MacOSX/CMakeLists.txt
index 02566ab3db06..449db7cd0612 100644
--- a/source/Plugins/Platform/MacOSX/CMakeLists.txt
+++ b/source/Plugins/Platform/MacOSX/CMakeLists.txt
@@ -24,4 +24,19 @@ else()
${PLUGIN_PLATFORM_MACOSX_DARWIN_ONLY_SOURCES})
endif()
-add_lldb_library(lldbPluginPlatformMacOSX ${PLUGIN_PLATFORM_MACOSX_SOURCES})
+add_lldb_library(lldbPluginPlatformMacOSX PLUGIN
+ ${PLUGIN_PLATFORM_MACOSX_SOURCES}
+
+ LINK_LIBS
+ clangBasic
+ lldbBreakpoint
+ lldbCore
+ lldbHost
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ lldbPluginPlatformPOSIX
+ LINK_COMPONENTS
+ Support
+ )
diff --git a/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp b/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
index e6da63e8af6a..478d482eb024 100644
--- a/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
@@ -19,11 +19,12 @@
#include <thread>
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Error.h"
-#include "lldb/Core/StreamString.h"
+#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/Error.h"
#include "lldb/Utility/LLDBAssert.h"
-#include "lldb/Utility/PseudoTerminal.h"
+#include "lldb/Utility/StreamString.h"
+#include "llvm/Support/Threading.h"
using namespace lldb;
using namespace lldb_private;
@@ -242,8 +243,8 @@ FileSpec PlatformAppleSimulator::GetCoreSimulatorPath() {
void PlatformAppleSimulator::LoadCoreSimulator() {
#if defined(__APPLE__)
- static std::once_flag g_load_core_sim_flag;
- std::call_once(g_load_core_sim_flag, [this] {
+ static llvm::once_flag g_load_core_sim_flag;
+ llvm::call_once(g_load_core_sim_flag, [this] {
const std::string core_sim_path(GetCoreSimulatorPath().GetPath());
if (core_sim_path.size())
dlopen(core_sim_path.c_str(), RTLD_LAZY);
diff --git a/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h b/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
index 04bc28842c39..34f2ba2d9bfb 100644
--- a/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
+++ b/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
@@ -18,7 +18,7 @@
// Project includes
#include "PlatformDarwin.h"
#include "PlatformiOSSimulatorCoreSimulatorSupport.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/FileSpec.h"
#include "llvm/ADT/Optional.h"
diff --git a/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp b/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
index 968ce5f9767b..38fe412c8574 100644
--- a/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
@@ -15,18 +15,20 @@
// Project includes
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+
+#include "llvm/Support/FileSystem.h"
using namespace lldb;
using namespace lldb_private;
@@ -246,9 +248,9 @@ Error PlatformAppleTVSimulator::ResolveExecutable(
}
static FileSpec::EnumerateDirectoryResult
-EnumerateDirectoryCallback(void *baton, FileSpec::FileType file_type,
+EnumerateDirectoryCallback(void *baton, llvm::sys::fs::file_type ft,
const FileSpec &file_spec) {
- if (file_type == FileSpec::eFileTypeDirectory) {
+ if (ft == llvm::sys::fs::file_type::directory_file) {
const char *filename = file_spec.GetFilename().GetCString();
if (filename &&
strncmp(filename, "AppleTVSimulator", strlen("AppleTVSimulator")) ==
diff --git a/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp b/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
index 291f58607597..1ffdc1ab7c8e 100644
--- a/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
@@ -15,18 +15,18 @@
// Project includes
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
@@ -248,9 +248,9 @@ Error PlatformAppleWatchSimulator::ResolveExecutable(
}
static FileSpec::EnumerateDirectoryResult
-EnumerateDirectoryCallback(void *baton, FileSpec::FileType file_type,
+EnumerateDirectoryCallback(void *baton, llvm::sys::fs::file_type ft,
const FileSpec &file_spec) {
- if (file_type == FileSpec::eFileTypeDirectory) {
+ if (ft == llvm::sys::fs::file_type::directory_file) {
const char *filename = file_spec.GetFilename().GetCString();
if (filename &&
strncmp(filename, "AppleWatchSimulator",
diff --git a/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 184912046706..7c90f87189a7 100644
--- a/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -22,15 +22,11 @@
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/BreakpointSite.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/Timer.h"
-#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
-#include "lldb/Host/StringConvert.h"
#include "lldb/Host/Symbols.h"
#include "lldb/Host/XML.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -39,7 +35,12 @@
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferLLVM.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Threading.h"
#if defined(__APPLE__)
#include <TargetConditionals.h> // for TARGET_OS_TV, TARGET_OS_WATCH
@@ -194,127 +195,20 @@ FileSpecList PlatformDarwin::LocateExecutableScriptingResources(
return file_list;
}
-Error PlatformDarwin::ResolveExecutable(
- const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr) {
- Error error;
- // Nothing special to do here, just use the actual file and architecture
-
- char exe_path[PATH_MAX];
- ModuleSpec resolved_module_spec(module_spec);
-
- if (IsHost()) {
- // If we have "ls" as the exe_file, resolve the executable loation based on
- // the current path variables
- if (!resolved_module_spec.GetFileSpec().Exists()) {
- module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
- resolved_module_spec.GetFileSpec().SetFile(exe_path, true);
- }
-
- if (!resolved_module_spec.GetFileSpec().Exists())
- resolved_module_spec.GetFileSpec().ResolveExecutableLocation();
-
- // Resolve any executable within a bundle on MacOSX
- Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
-
- if (resolved_module_spec.GetFileSpec().Exists())
- error.Clear();
- else {
- const uint32_t permissions =
- resolved_module_spec.GetFileSpec().GetPermissions();
- if (permissions && (permissions & eFilePermissionsEveryoneR) == 0)
- error.SetErrorStringWithFormat(
- "executable '%s' is not readable",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
- else
- error.SetErrorStringWithFormat(
- "unable to find executable for '%s'",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- } else {
- if (m_remote_platform_sp) {
- error =
- GetCachedExecutable(resolved_module_spec, exe_module_sp,
- module_search_paths_ptr, *m_remote_platform_sp);
- } else {
- // We may connect to a process and use the provided executable (Don't use
- // local $PATH).
-
- // Resolve any executable within a bundle on MacOSX
- Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
-
- if (resolved_module_spec.GetFileSpec().Exists())
- error.Clear();
- else
- error.SetErrorStringWithFormat(
- "the platform is not currently connected, and '%s' doesn't exist "
- "in the system root.",
- resolved_module_spec.GetFileSpec().GetFilename().AsCString(""));
- }
- }
-
- if (error.Success()) {
- if (resolved_module_spec.GetArchitecture().IsValid()) {
- error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
- module_search_paths_ptr, NULL, NULL);
-
- if (error.Fail() || exe_module_sp.get() == NULL ||
- exe_module_sp->GetObjectFile() == NULL) {
- exe_module_sp.reset();
- error.SetErrorStringWithFormat(
- "'%s' doesn't contain the architecture %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
- } else {
- // No valid architecture was specified, ask the platform for
- // the architectures that we should be using (in the correct order)
- // and see if we can find a match that way
- StreamString arch_names;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
- idx, resolved_module_spec.GetArchitecture());
- ++idx) {
- error = GetSharedModule(resolved_module_spec, NULL, exe_module_sp,
- module_search_paths_ptr, NULL, NULL);
- // Did we find an executable using one of the
- if (error.Success()) {
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- break;
- else
- error.SetErrorToGenericError();
- }
-
- if (idx > 0)
- arch_names.PutCString(", ");
- arch_names.PutCString(
- resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
-
- if (error.Fail() || !exe_module_sp) {
- if (resolved_module_spec.GetFileSpec().Readable()) {
- error.SetErrorStringWithFormat(
- "'%s' doesn't contain any '%s' platform architectures: %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- GetPluginName().GetCString(), arch_names.GetData());
- } else {
- error.SetErrorStringWithFormat(
- "'%s' is not readable",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- }
- }
-
- return error;
-}
-
Error PlatformDarwin::ResolveSymbolFile(Target &target,
const ModuleSpec &sym_spec,
FileSpec &sym_file) {
Error error;
sym_file = sym_spec.GetSymbolFileSpec();
- if (sym_file.Exists()) {
- if (sym_file.GetFileType() == FileSpec::eFileTypeDirectory) {
+
+ llvm::sys::fs::file_status st;
+ if (status(sym_file.GetPath(), st, false)) {
+ error.SetErrorString("Could not stat file!");
+ return error;
+ }
+
+ if (exists(st)) {
+ if (is_directory(st)) {
sym_file = Symbols::FindSymbolFileInBundle(
sym_file, sym_spec.GetUUIDPtr(), sym_spec.GetArchitecturePtr());
}
@@ -329,8 +223,7 @@ static lldb_private::Error
MakeCacheFolderForFile(const FileSpec &module_cache_spec) {
FileSpec module_cache_folder =
module_cache_spec.CopyByRemovingLastPathComponent();
- return FileSystem::MakeDirectory(module_cache_folder,
- eFilePermissionsDirectoryDefault);
+ return llvm::sys::fs::create_directory(module_cache_folder.GetPath());
}
static lldb_private::Error
@@ -402,11 +295,14 @@ lldb_private::Error PlatformDarwin::GetSharedModuleWithLocalCache(
// get the local and remote MD5 and compare
if (m_remote_platform_sp) {
// when going over the *slow* GDB remote transfer mechanism we first
- // check
- // the hashes of the files - and only do the actual transfer if they
- // differ
+ // check the hashes of the files - and only do the actual transfer if
+ // they differ
uint64_t high_local, high_remote, low_local, low_remote;
- FileSystem::CalculateMD5(module_cache_spec, low_local, high_local);
+ auto MD5 = llvm::sys::fs::md5_contents(module_cache_spec.GetPath());
+ if (!MD5)
+ return Error(MD5.getError());
+ std::tie(high_local, low_local) = MD5->words();
+
m_remote_platform_sp->CalculateMD5(module_spec.GetFileSpec(),
low_remote, high_remote);
if (low_local != low_remote || high_local != high_remote) {
@@ -603,34 +499,6 @@ PlatformDarwin::GetSoftwareBreakpointTrapOpcode(Target &target,
return 0;
}
-bool PlatformDarwin::GetProcessInfo(lldb::pid_t pid,
- ProcessInstanceInfo &process_info) {
- bool success = false;
- if (IsHost()) {
- success = Platform::GetProcessInfo(pid, process_info);
- } else {
- if (m_remote_platform_sp)
- success = m_remote_platform_sp->GetProcessInfo(pid, process_info);
- }
- return success;
-}
-
-uint32_t
-PlatformDarwin::FindProcesses(const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos) {
- uint32_t match_count = 0;
- if (IsHost()) {
- // Let the base class figure out the host details
- match_count = Platform::FindProcesses(match_info, process_infos);
- } else {
- // If we are remote, we can only return results if we are connected
- if (m_remote_platform_sp)
- match_count =
- m_remote_platform_sp->FindProcesses(match_info, process_infos);
- }
- return match_count;
-}
-
bool PlatformDarwin::ModuleIsExcludedForUnconstrainedSearches(
lldb_private::Target &target, const lldb::ModuleSP &module_sp) {
if (!module_sp)
@@ -1295,13 +1163,16 @@ const char *PlatformDarwin::GetDeveloperDirectory() {
xcode_dir_path.append(xcode_select_prefix_dir);
xcode_dir_path.append("/usr/share/xcode-select/xcode_dir_path");
temp_file_spec.SetFile(xcode_dir_path, false);
- size_t bytes_read = temp_file_spec.ReadFileContents(
- 0, developer_dir_path, sizeof(developer_dir_path), NULL);
- if (bytes_read > 0) {
- developer_dir_path[bytes_read] = '\0';
- while (developer_dir_path[bytes_read - 1] == '\r' ||
- developer_dir_path[bytes_read - 1] == '\n')
- developer_dir_path[--bytes_read] = '\0';
+ auto dir_buffer =
+ DataBufferLLVM::CreateFromPath(temp_file_spec.GetPath(), true);
+ if (dir_buffer && dir_buffer->GetByteSize() > 0) {
+ llvm::StringRef path_ref(dir_buffer->GetChars());
+ // Trim tailing newlines and make sure there is enough room for a null
+ // terminator.
+ path_ref =
+ path_ref.rtrim("\r\n").take_front(sizeof(developer_dir_path) - 1);
+ ::memcpy(developer_dir_path, path_ref.data(), path_ref.size());
+ developer_dir_path[path_ref.size()] = '\0';
developer_dir_path_valid = true;
}
}
@@ -1331,7 +1202,7 @@ const char *PlatformDarwin::GetDeveloperDirectory() {
developer_dir_path[i] = '\0';
FileSpec devel_dir(developer_dir_path, false);
- if (devel_dir.Exists() && devel_dir.IsDirectory()) {
+ if (llvm::sys::fs::is_directory(devel_dir.GetPath())) {
developer_dir_path_valid = true;
}
}
@@ -1452,8 +1323,8 @@ static FileSpec CheckPathForXcode(const FileSpec &fspec) {
static FileSpec GetXcodeContentsPath() {
static FileSpec g_xcode_filespec;
- static std::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
+ static llvm::once_flag g_once_flag;
+ llvm::call_once(g_once_flag, []() {
FileSpec fspec;
@@ -1576,9 +1447,8 @@ bool PlatformDarwin::SDKSupportsModules(SDKType desired_type,
return false;
}
-FileSpec::EnumerateDirectoryResult
-PlatformDarwin::DirectoryEnumerator(void *baton, FileSpec::FileType file_type,
- const FileSpec &spec) {
+FileSpec::EnumerateDirectoryResult PlatformDarwin::DirectoryEnumerator(
+ void *baton, llvm::sys::fs::file_type file_type, const FileSpec &spec) {
SDKEnumeratorInfo *enumerator_info = static_cast<SDKEnumeratorInfo *>(baton);
if (SDKSupportsModules(enumerator_info->sdk_type, spec)) {
@@ -1593,8 +1463,9 @@ FileSpec PlatformDarwin::FindSDKInXcodeForModules(SDKType sdk_type,
const FileSpec &sdks_spec) {
// Look inside Xcode for the required installed iOS SDK version
- if (!sdks_spec.IsDirectory())
+ if (!llvm::sys::fs::is_directory(sdks_spec.GetPath())) {
return FileSpec();
+ }
const bool find_directories = true;
const bool find_files = false;
@@ -1608,7 +1479,7 @@ FileSpec PlatformDarwin::FindSDKInXcodeForModules(SDKType sdk_type,
find_files, find_other, DirectoryEnumerator,
&enumerator_info);
- if (enumerator_info.found_path.IsDirectory())
+ if (llvm::sys::fs::is_directory(enumerator_info.found_path.GetPath()))
return enumerator_info.found_path;
else
return FileSpec();
@@ -1767,7 +1638,7 @@ void PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
sysroot_spec = GetSDKDirectoryForModules(sdk_type);
}
- if (sysroot_spec.IsDirectory()) {
+ if (llvm::sys::fs::is_directory(sysroot_spec.GetPath())) {
options.push_back("-isysroot");
options.push_back(sysroot_spec.GetPath());
}
@@ -1835,8 +1706,8 @@ lldb_private::FileSpec PlatformDarwin::LocateExecutable(const char *basename) {
// Find the global list of directories that we will search for
// executables once so we don't keep doing the work over and over.
- static std::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
+ static llvm::once_flag g_once_flag;
+ llvm::call_once(g_once_flag, []() {
// When locating executables, trust the DEVELOPER_DIR first if it is set
FileSpec xcode_contents_dir = GetXcodeContentsPath();
diff --git a/source/Plugins/Platform/MacOSX/PlatformDarwin.h b/source/Plugins/Platform/MacOSX/PlatformDarwin.h
index 2abff92fa906..9430c269c27e 100644
--- a/source/Plugins/Platform/MacOSX/PlatformDarwin.h
+++ b/source/Plugins/Platform/MacOSX/PlatformDarwin.h
@@ -16,8 +16,9 @@
// Other libraries and framework includes
// Project includes
#include "Plugins/Platform/POSIX/PlatformPOSIX.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/FileSpec.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FileSystem.h"
#include <string>
#include <tuple>
@@ -31,10 +32,6 @@ public:
//------------------------------------------------------------
// lldb_private::Platform functions
//------------------------------------------------------------
- lldb_private::Error ResolveExecutable(
- const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
- const lldb_private::FileSpecList *module_search_paths_ptr) override;
-
lldb_private::Error
ResolveSymbolFile(lldb_private::Target &target,
const lldb_private::ModuleSpec &sym_spec,
@@ -55,16 +52,9 @@ public:
lldb_private::Target &target,
lldb_private::BreakpointSite *bp_site) override;
- bool GetProcessInfo(lldb::pid_t pid,
- lldb_private::ProcessInstanceInfo &proc_info) override;
-
lldb::BreakpointSP
SetThreadCreationBreakpoint(lldb_private::Target &target) override;
- uint32_t
- FindProcesses(const lldb_private::ProcessInstanceInfoMatch &match_info,
- lldb_private::ProcessInstanceInfoList &process_infos) override;
-
bool ModuleIsExcludedForUnconstrainedSearches(
lldb_private::Target &target, const lldb::ModuleSP &module_sp) override;
@@ -123,7 +113,7 @@ protected:
};
static lldb_private::FileSpec::EnumerateDirectoryResult
- DirectoryEnumerator(void *baton, lldb_private::FileSpec::FileType file_type,
+ DirectoryEnumerator(void *baton, llvm::sys::fs::file_type file_type,
const lldb_private::FileSpec &spec);
static lldb_private::FileSpec
diff --git a/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp b/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
index f4fd9c694000..7116dca65911 100644
--- a/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
@@ -19,14 +19,10 @@
// Project includes
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Interpreter/OptionValueFileSpecList.h"
#include "lldb/Interpreter/OptionValueProperties.h"
@@ -35,6 +31,12 @@
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+
+#include "llvm/Support/FileSystem.h"
#include <CoreFoundation/CoreFoundation.h>
@@ -381,7 +383,7 @@ void PlatformDarwinKernel::CollectKextAndKernelDirectories() {
// Add simple directory /Applications/Xcode.app/Contents/Developer/../Symbols
FileSpec possible_dir(developer_dir + "/../Symbols", true);
- if (possible_dir.Exists() && possible_dir.IsDirectory())
+ if (llvm::sys::fs::is_directory(possible_dir.GetPath()))
m_search_directories.push_back(possible_dir);
// Add simple directory of the current working directory
@@ -396,7 +398,7 @@ void PlatformDarwinKernel::GetUserSpecifiedDirectoriesToSearch() {
for (uint32_t i = 0; i < user_dirs_count; i++) {
FileSpec dir = user_dirs.GetFileSpecAtIndex(i);
dir.ResolvePath();
- if (dir.Exists() && dir.IsDirectory()) {
+ if (llvm::sys::fs::is_directory(dir.GetPath())) {
m_search_directories.push_back(dir);
}
}
@@ -412,7 +414,7 @@ void PlatformDarwinKernel::AddRootSubdirsToSearchPaths(
nullptr};
for (int i = 0; subdirs[i] != nullptr; i++) {
FileSpec testdir(dir + subdirs[i], true);
- if (testdir.Exists() && testdir.IsDirectory())
+ if (llvm::sys::fs::is_directory(testdir.GetPath()))
thisp->m_search_directories.push_back(testdir);
}
@@ -435,12 +437,12 @@ void PlatformDarwinKernel::AddSDKSubdirsToSearchPaths(const std::string &dir) {
// Helper function to find *.sdk and *.kdk directories in a given directory.
FileSpec::EnumerateDirectoryResult
PlatformDarwinKernel::FindKDKandSDKDirectoriesInDirectory(
- void *baton, FileSpec::FileType file_type, const FileSpec &file_spec) {
+ void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec) {
static ConstString g_sdk_suffix = ConstString("sdk");
static ConstString g_kdk_suffix = ConstString("kdk");
PlatformDarwinKernel *thisp = (PlatformDarwinKernel *)baton;
- if (file_type == FileSpec::eFileTypeDirectory &&
+ if (ft == llvm::sys::fs::file_type::directory_file &&
(file_spec.GetFileNameExtension() == g_sdk_suffix ||
file_spec.GetFileNameExtension() == g_kdk_suffix)) {
AddRootSubdirsToSearchPaths(thisp, file_spec.GetPath());
@@ -486,20 +488,19 @@ void PlatformDarwinKernel::SearchForKextsAndKernelsRecursively() {
FileSpec::EnumerateDirectoryResult
PlatformDarwinKernel::GetKernelsAndKextsInDirectoryWithRecursion(
- void *baton, FileSpec::FileType file_type, const FileSpec &file_spec) {
- return GetKernelsAndKextsInDirectoryHelper(baton, file_type, file_spec, true);
+ void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec) {
+ return GetKernelsAndKextsInDirectoryHelper(baton, ft, file_spec, true);
}
FileSpec::EnumerateDirectoryResult
PlatformDarwinKernel::GetKernelsAndKextsInDirectoryNoRecursion(
- void *baton, FileSpec::FileType file_type, const FileSpec &file_spec) {
- return GetKernelsAndKextsInDirectoryHelper(baton, file_type, file_spec,
- false);
+ void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec) {
+ return GetKernelsAndKextsInDirectoryHelper(baton, ft, file_spec, false);
}
FileSpec::EnumerateDirectoryResult
PlatformDarwinKernel::GetKernelsAndKextsInDirectoryHelper(
- void *baton, FileSpec::FileType file_type, const FileSpec &file_spec,
+ void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec,
bool recurse) {
static ConstString g_kext_suffix = ConstString("kext");
static ConstString g_dsym_suffix = ConstString("dSYM");
@@ -512,8 +513,8 @@ PlatformDarwinKernel::GetKernelsAndKextsInDirectoryHelper(
file_spec.GetPath().c_str());
PlatformDarwinKernel *thisp = (PlatformDarwinKernel *)baton;
- if (file_type == FileSpec::eFileTypeRegular ||
- file_type == FileSpec::eFileTypeSymbolicLink) {
+ if (ft == llvm::sys::fs::file_type::regular_file ||
+ ft == llvm::sys::fs::file_type::symlink_file) {
ConstString filename = file_spec.GetFilename();
if ((strncmp(filename.GetCString(), "kernel", 6) == 0 ||
strncmp(filename.GetCString(), "mach", 4) == 0) &&
@@ -524,17 +525,17 @@ PlatformDarwinKernel::GetKernelsAndKextsInDirectoryHelper(
thisp->m_kernel_binaries_without_dsyms.push_back(file_spec);
return FileSpec::eEnumerateDirectoryResultNext;
}
- } else if (file_type == FileSpec::eFileTypeDirectory &&
+ } else if (ft == llvm::sys::fs::file_type::directory_file &&
file_spec_extension == g_kext_suffix) {
AddKextToMap(thisp, file_spec);
// Look to see if there is a PlugIns subdir with more kexts
FileSpec contents_plugins(file_spec.GetPath() + "/Contents/PlugIns", false);
std::string search_here_too;
- if (contents_plugins.Exists() && contents_plugins.IsDirectory()) {
+ if (llvm::sys::fs::is_directory(contents_plugins.GetPath())) {
search_here_too = contents_plugins.GetPath();
} else {
FileSpec plugins(file_spec.GetPath() + "/PlugIns", false);
- if (plugins.Exists() && plugins.IsDirectory()) {
+ if (llvm::sys::fs::is_directory(plugins.GetPath())) {
search_here_too = plugins.GetPath();
}
}
@@ -591,7 +592,7 @@ bool PlatformDarwinKernel::KextHasdSYMSibling(
std::string filename = dsym_fspec.GetFilename().AsCString();
filename += ".dSYM";
dsym_fspec.GetFilename() = ConstString(filename);
- if (dsym_fspec.Exists() && dsym_fspec.IsDirectory()) {
+ if (llvm::sys::fs::is_directory(dsym_fspec.GetPath())) {
return true;
}
// Should probably get the CFBundleExecutable here or call
@@ -605,7 +606,7 @@ bool PlatformDarwinKernel::KextHasdSYMSibling(
deep_bundle_str += executable_name.AsCString();
deep_bundle_str += ".dSYM";
dsym_fspec.SetFile(deep_bundle_str, true);
- if (dsym_fspec.Exists() && dsym_fspec.IsDirectory()) {
+ if (llvm::sys::fs::is_directory(dsym_fspec.GetPath())) {
return true;
}
@@ -615,7 +616,7 @@ bool PlatformDarwinKernel::KextHasdSYMSibling(
shallow_bundle_str += executable_name.AsCString();
shallow_bundle_str += ".dSYM";
dsym_fspec.SetFile(shallow_bundle_str, true);
- if (dsym_fspec.Exists() && dsym_fspec.IsDirectory()) {
+ if (llvm::sys::fs::is_directory(dsym_fspec.GetPath())) {
return true;
}
return false;
@@ -629,7 +630,7 @@ bool PlatformDarwinKernel::KernelHasdSYMSibling(const FileSpec &kernel_binary) {
std::string filename = kernel_binary.GetFilename().AsCString();
filename += ".dSYM";
kernel_dsym.GetFilename() = ConstString(filename);
- if (kernel_dsym.Exists() && kernel_dsym.IsDirectory()) {
+ if (llvm::sys::fs::is_directory(kernel_dsym.GetPath())) {
return true;
}
return false;
diff --git a/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h b/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
index 2010c4860309..6ee5916e613a 100644
--- a/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
+++ b/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
@@ -10,7 +10,7 @@
#ifndef liblldb_PlatformDarwinKernel_h_
#define liblldb_PlatformDarwinKernel_h_
-#include "lldb/Core/ConstString.h"
+#include "lldb/Utility/ConstString.h"
#if defined(__APPLE__) // This Plugin uses the Mac-specific
// source/Host/macosx/cfcpp utilities
@@ -18,7 +18,9 @@
// C Includes
// C++ Includes
// Other libraries and framework includes
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/FileSpec.h"
+
+#include "llvm/Support/FileSystem.h"
// Project includes
#include "PlatformDarwin.h"
@@ -105,26 +107,25 @@ protected:
void AddSDKSubdirsToSearchPaths(const std::string &dir);
static lldb_private::FileSpec::EnumerateDirectoryResult
- FindKDKandSDKDirectoriesInDirectory(
- void *baton, lldb_private::FileSpec::FileType file_type,
- const lldb_private::FileSpec &file_spec);
+ FindKDKandSDKDirectoriesInDirectory(void *baton, llvm::sys::fs::file_type ft,
+ const lldb_private::FileSpec &file_spec);
void SearchForKextsAndKernelsRecursively();
static lldb_private::FileSpec::EnumerateDirectoryResult
GetKernelsAndKextsInDirectoryWithRecursion(
- void *baton, lldb_private::FileSpec::FileType file_type,
+ void *baton, llvm::sys::fs::file_type ft,
const lldb_private::FileSpec &file_spec);
static lldb_private::FileSpec::EnumerateDirectoryResult
GetKernelsAndKextsInDirectoryNoRecursion(
- void *baton, lldb_private::FileSpec::FileType file_type,
+ void *baton, llvm::sys::fs::file_type ft,
const lldb_private::FileSpec &file_spec);
static lldb_private::FileSpec::EnumerateDirectoryResult
- GetKernelsAndKextsInDirectoryHelper(
- void *baton, lldb_private::FileSpec::FileType file_type,
- const lldb_private::FileSpec &file_spec, bool recurse);
+ GetKernelsAndKextsInDirectoryHelper(void *baton, llvm::sys::fs::file_type ft,
+ const lldb_private::FileSpec &file_spec,
+ bool recurse);
static void AddKextToMap(PlatformDarwinKernel *thisp,
const lldb_private::FileSpec &file_spec);
diff --git a/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp b/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
index 0e7df95b5337..11d0457a783e 100644
--- a/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
@@ -17,21 +17,20 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/FileSpec.h"
-#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
@@ -279,8 +278,7 @@ PlatformMacOSX::GetFileWithUUID(const lldb_private::FileSpec &platform_file,
FileSpec module_cache_folder =
module_cache_spec.CopyByRemovingLastPathComponent();
// try to make the local directory first
- Error err = FileSystem::MakeDirectory(module_cache_folder,
- eFilePermissionsDirectoryDefault);
+ Error err(llvm::sys::fs::create_directory(module_cache_folder.GetPath()));
if (err.Fail())
return err;
err = GetFile(platform_file, module_cache_spec);
diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
index 47b1c8f07dfa..05d1bd49dafe 100644
--- a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
@@ -18,17 +18,17 @@
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
@@ -250,7 +250,7 @@ Error PlatformRemoteAppleTV::ResolveExecutable(
FileSpec::EnumerateDirectoryResult
PlatformRemoteAppleTV::GetContainedFilesIntoVectorOfStringsCallback(
- void *baton, FileSpec::FileType file_type, const FileSpec &file_spec) {
+ void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec) {
((PlatformRemoteAppleTV::SDKDirectoryInfoCollection *)baton)
->push_back(PlatformRemoteAppleTV::SDKDirectoryInfo(file_spec));
return FileSpec::eEnumerateDirectoryResultNext;
@@ -497,18 +497,15 @@ const char *PlatformRemoteAppleTV::GetDeviceSupportDirectoryForOSVersion() {
uint32_t
PlatformRemoteAppleTV::FindFileInAllSDKs(const char *platform_file_path,
FileSpecList &file_list) {
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST |
- LIBLLDB_LOG_VERBOSE);
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (platform_file_path && platform_file_path[0] &&
UpdateSDKDirectoryInfosIfNeeded()) {
const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
lldb_private::FileSpec local_file;
// First try for an exact match of major, minor and update
for (uint32_t sdk_idx = 0; sdk_idx < num_sdk_infos; ++sdk_idx) {
- if (log) {
- log->Printf("Searching for %s in sdk path %s", platform_file_path,
- m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
- }
+ LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file_path,
+ m_sdk_directory_infos[sdk_idx].directory);
if (GetFileInSDK(platform_file_path, sdk_idx, local_file)) {
file_list.Append(local_file);
}
@@ -619,8 +616,7 @@ Error PlatformRemoteAppleTV::GetSharedModule(
// then we attempt to get a shared module for the right architecture
// with the right UUID.
const FileSpec &platform_file = module_spec.GetFileSpec();
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST |
- LIBLLDB_LOG_VERBOSE);
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
Error error;
char platform_file_path[PATH_MAX];
@@ -637,12 +633,8 @@ Error PlatformRemoteAppleTV::GetSharedModule(
// using the OS build.
const uint32_t connected_sdk_idx = GetConnectedSDKIndex();
if (connected_sdk_idx < num_sdk_infos) {
- if (log) {
- log->Printf("Searching for %s in sdk path %s", platform_file_path,
- m_sdk_directory_infos[connected_sdk_idx]
- .directory.GetPath()
- .c_str());
- }
+ LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file,
+ m_sdk_directory_infos[connected_sdk_idx].directory);
if (GetFileInSDK(platform_file_path, connected_sdk_idx,
platform_module_spec.GetFileSpec())) {
module_sp.reset();
@@ -658,12 +650,8 @@ Error PlatformRemoteAppleTV::GetSharedModule(
// Try the last SDK index if it is set as most files from an SDK
// will tend to be valid in that same SDK.
if (m_last_module_sdk_idx < num_sdk_infos) {
- if (log) {
- log->Printf("Searching for %s in sdk path %s", platform_file_path,
- m_sdk_directory_infos[m_last_module_sdk_idx]
- .directory.GetPath()
- .c_str());
- }
+ LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file_path,
+ m_sdk_directory_infos[m_last_module_sdk_idx].directory);
if (GetFileInSDK(platform_file_path, m_last_module_sdk_idx,
platform_module_spec.GetFileSpec())) {
module_sp.reset();
@@ -682,10 +670,8 @@ Error PlatformRemoteAppleTV::GetSharedModule(
// it above
continue;
}
- if (log) {
- log->Printf("Searching for %s in sdk path %s", platform_file_path,
- m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
- }
+ LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file_path,
+ m_sdk_directory_infos[sdk_idx].directory);
if (GetFileInSDK(platform_file_path, sdk_idx,
platform_module_spec.GetFileSpec())) {
// printf ("sdk[%u]: '%s'\n", sdk_idx, local_file.GetPath().c_str());
diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h
index 388ea578d06b..beae827edba4 100644
--- a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h
+++ b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h
@@ -16,7 +16,9 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/FileSpec.h"
+
+#include "llvm/Support/FileSystem.h"
#include "PlatformDarwin.h"
@@ -116,7 +118,7 @@ protected:
static lldb_private::FileSpec::EnumerateDirectoryResult
GetContainedFilesIntoVectorOfStringsCallback(
- void *baton, lldb_private::FileSpec::FileType file_type,
+ void *baton, llvm::sys::fs::file_type ft,
const lldb_private::FileSpec &file_spec);
uint32_t FindFileInAllSDKs(const char *platform_file_path,
diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
index f12fcab3b713..139364a82b98 100644
--- a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
@@ -18,17 +18,17 @@
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
@@ -260,7 +260,7 @@ Error PlatformRemoteAppleWatch::ResolveExecutable(
FileSpec::EnumerateDirectoryResult
PlatformRemoteAppleWatch::GetContainedFilesIntoVectorOfStringsCallback(
- void *baton, FileSpec::FileType file_type, const FileSpec &file_spec) {
+ void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec) {
((PlatformRemoteAppleWatch::SDKDirectoryInfoCollection *)baton)
->push_back(PlatformRemoteAppleWatch::SDKDirectoryInfo(file_spec));
return FileSpec::eEnumerateDirectoryResultNext;
@@ -511,18 +511,15 @@ const char *PlatformRemoteAppleWatch::GetDeviceSupportDirectoryForOSVersion() {
uint32_t
PlatformRemoteAppleWatch::FindFileInAllSDKs(const char *platform_file_path,
FileSpecList &file_list) {
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST |
- LIBLLDB_LOG_VERBOSE);
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (platform_file_path && platform_file_path[0] &&
UpdateSDKDirectoryInfosIfNeeded()) {
const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
lldb_private::FileSpec local_file;
// First try for an exact match of major, minor and update
for (uint32_t sdk_idx = 0; sdk_idx < num_sdk_infos; ++sdk_idx) {
- if (log) {
- log->Printf("Searching for %s in sdk path %s", platform_file_path,
- m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
- }
+ LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file_path,
+ m_sdk_directory_infos[sdk_idx].directory);
if (GetFileInSDK(platform_file_path, sdk_idx, local_file)) {
file_list.Append(local_file);
}
@@ -633,8 +630,7 @@ Error PlatformRemoteAppleWatch::GetSharedModule(
// then we attempt to get a shared module for the right architecture
// with the right UUID.
const FileSpec &platform_file = module_spec.GetFileSpec();
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST |
- LIBLLDB_LOG_VERBOSE);
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
Error error;
char platform_file_path[PATH_MAX];
@@ -651,12 +647,8 @@ Error PlatformRemoteAppleWatch::GetSharedModule(
// using the OS build.
const uint32_t connected_sdk_idx = GetConnectedSDKIndex();
if (connected_sdk_idx < num_sdk_infos) {
- if (log) {
- log->Printf("Searching for %s in sdk path %s", platform_file_path,
- m_sdk_directory_infos[connected_sdk_idx]
- .directory.GetPath()
- .c_str());
- }
+ LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file,
+ m_sdk_directory_infos[connected_sdk_idx].directory);
if (GetFileInSDK(platform_file_path, connected_sdk_idx,
platform_module_spec.GetFileSpec())) {
module_sp.reset();
@@ -672,12 +664,8 @@ Error PlatformRemoteAppleWatch::GetSharedModule(
// Try the last SDK index if it is set as most files from an SDK
// will tend to be valid in that same SDK.
if (m_last_module_sdk_idx < num_sdk_infos) {
- if (log) {
- log->Printf("Searching for %s in sdk path %s", platform_file_path,
- m_sdk_directory_infos[m_last_module_sdk_idx]
- .directory.GetPath()
- .c_str());
- }
+ LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file,
+ m_sdk_directory_infos[m_last_module_sdk_idx].directory);
if (GetFileInSDK(platform_file_path, m_last_module_sdk_idx,
platform_module_spec.GetFileSpec())) {
module_sp.reset();
@@ -696,10 +684,8 @@ Error PlatformRemoteAppleWatch::GetSharedModule(
// it above
continue;
}
- if (log) {
- log->Printf("Searching for %s in sdk path %s", platform_file_path,
- m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
- }
+ LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file,
+ m_sdk_directory_infos[sdk_idx].directory);
if (GetFileInSDK(platform_file_path, sdk_idx,
platform_module_spec.GetFileSpec())) {
// printf ("sdk[%u]: '%s'\n", sdk_idx, local_file.GetPath().c_str());
diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h
index 0b388af329a5..d6c91140171b 100644
--- a/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h
+++ b/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h
@@ -17,10 +17,12 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/FileSpec.h"
#include "PlatformDarwin.h"
+#include "llvm/Support/FileSystem.h"
+
class PlatformRemoteAppleWatch : public PlatformDarwin {
public:
PlatformRemoteAppleWatch();
@@ -118,7 +120,7 @@ protected:
static lldb_private::FileSpec::EnumerateDirectoryResult
GetContainedFilesIntoVectorOfStringsCallback(
- void *baton, lldb_private::FileSpec::FileType file_type,
+ void *baton, llvm::sys::fs::file_type ft,
const lldb_private::FileSpec &file_spec);
uint32_t FindFileInAllSDKs(const char *platform_file_path,
diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp b/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
index cf4f88d90107..9d47b2464a27 100644
--- a/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
@@ -15,17 +15,17 @@
// Project includes
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
@@ -255,7 +255,7 @@ Error PlatformRemoteiOS::ResolveExecutable(
FileSpec::EnumerateDirectoryResult
PlatformRemoteiOS::GetContainedFilesIntoVectorOfStringsCallback(
- void *baton, FileSpec::FileType file_type, const FileSpec &file_spec) {
+ void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec) {
((PlatformRemoteiOS::SDKDirectoryInfoCollection *)baton)
->push_back(PlatformRemoteiOS::SDKDirectoryInfo(file_spec));
return FileSpec::eEnumerateDirectoryResultNext;
@@ -481,18 +481,15 @@ const char *PlatformRemoteiOS::GetDeviceSupportDirectoryForOSVersion() {
uint32_t PlatformRemoteiOS::FindFileInAllSDKs(const char *platform_file_path,
FileSpecList &file_list) {
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST |
- LIBLLDB_LOG_VERBOSE);
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (platform_file_path && platform_file_path[0] &&
UpdateSDKDirectoryInfosIfNeeded()) {
const uint32_t num_sdk_infos = m_sdk_directory_infos.size();
lldb_private::FileSpec local_file;
// First try for an exact match of major, minor and update
for (uint32_t sdk_idx = 0; sdk_idx < num_sdk_infos; ++sdk_idx) {
- if (log) {
- log->Printf("Searching for %s in sdk path %s", platform_file_path,
- m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
- }
+ LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file_path,
+ m_sdk_directory_infos[sdk_idx].directory);
if (GetFileInSDK(platform_file_path, sdk_idx, local_file)) {
file_list.Append(local_file);
}
@@ -605,8 +602,7 @@ Error PlatformRemoteiOS::GetSharedModule(
// then we attempt to get a shared module for the right architecture
// with the right UUID.
const FileSpec &platform_file = module_spec.GetFileSpec();
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST |
- LIBLLDB_LOG_VERBOSE);
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
Error error;
char platform_file_path[PATH_MAX];
@@ -623,12 +619,8 @@ Error PlatformRemoteiOS::GetSharedModule(
// using the OS build.
const uint32_t connected_sdk_idx = GetConnectedSDKIndex();
if (connected_sdk_idx < num_sdk_infos) {
- if (log) {
- log->Printf("Searching for %s in sdk path %s", platform_file_path,
- m_sdk_directory_infos[connected_sdk_idx]
- .directory.GetPath()
- .c_str());
- }
+ LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file,
+ m_sdk_directory_infos[connected_sdk_idx].directory);
if (GetFileInSDK(platform_file_path, connected_sdk_idx,
platform_module_spec.GetFileSpec())) {
module_sp.reset();
@@ -644,12 +636,8 @@ Error PlatformRemoteiOS::GetSharedModule(
// Try the last SDK index if it is set as most files from an SDK
// will tend to be valid in that same SDK.
if (m_last_module_sdk_idx < num_sdk_infos) {
- if (log) {
- log->Printf("Searching for %s in sdk path %s", platform_file_path,
- m_sdk_directory_infos[m_last_module_sdk_idx]
- .directory.GetPath()
- .c_str());
- }
+ LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file,
+ m_sdk_directory_infos[m_last_module_sdk_idx].directory);
if (GetFileInSDK(platform_file_path, m_last_module_sdk_idx,
platform_module_spec.GetFileSpec())) {
module_sp.reset();
@@ -670,11 +658,8 @@ Error PlatformRemoteiOS::GetSharedModule(
GetSDKIndexBySDKDirectoryInfo(current_sdk_info);
if (current_sdk_idx < num_sdk_infos &&
current_sdk_idx != m_last_module_sdk_idx) {
- if (log) {
- log->Printf(
- "Searching for %s in sdk path %s", platform_file_path,
- m_sdk_directory_infos[current_sdk_idx].directory.GetPath().c_str());
- }
+ LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file,
+ m_sdk_directory_infos[current_sdk_idx].directory);
if (GetFileInSDK(platform_file_path, current_sdk_idx,
platform_module_spec.GetFileSpec())) {
module_sp.reset();
@@ -694,10 +679,8 @@ Error PlatformRemoteiOS::GetSharedModule(
// it above
continue;
}
- if (log) {
- log->Printf("Searching for %s in sdk path %s", platform_file_path,
- m_sdk_directory_infos[sdk_idx].directory.GetPath().c_str());
- }
+ LLDB_LOGV(log, "Searching for {0} in sdk path {1}", platform_file,
+ m_sdk_directory_infos[sdk_idx].directory);
if (GetFileInSDK(platform_file_path, sdk_idx,
platform_module_spec.GetFileSpec())) {
// printf ("sdk[%u]: '%s'\n", sdk_idx, local_file.GetPath().c_str());
@@ -749,10 +732,8 @@ Error PlatformRemoteiOS::GetSharedModule(
size_t num_module_search_paths = module_search_paths_ptr->GetSize();
for (size_t i = 0; i < num_module_search_paths; ++i) {
- Log *log_verbose = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST |
- LIBLLDB_LOG_VERBOSE);
- if (log_verbose)
- log_verbose->Printf ("PlatformRemoteiOS::GetSharedModule searching for binary in search-path %s", module_search_paths_ptr->GetFileSpecAtIndex(i).GetPath().c_str());
+ LLDB_LOGV(log, "searching for binary in search-path {0}",
+ module_search_paths_ptr->GetFileSpecAtIndex(i));
// Create a new FileSpec with this module_search_paths_ptr
// plus just the filename ("UIFoundation"), then the parent
// dir plus filename ("UIFoundation.framework/UIFoundation")
diff --git a/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h b/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
index 4d88a9e4103a..ccdce9874762 100644
--- a/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
+++ b/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
@@ -17,7 +17,9 @@
// Other libraries and framework includes
// Project includes
#include "PlatformDarwin.h"
-#include "lldb/Host/FileSpec.h"
+#include "lldb/Utility/FileSpec.h"
+
+#include "llvm/Support/FileSystem.h"
class PlatformRemoteiOS : public PlatformDarwin {
public:
@@ -114,7 +116,7 @@ protected:
static lldb_private::FileSpec::EnumerateDirectoryResult
GetContainedFilesIntoVectorOfStringsCallback(
- void *baton, lldb_private::FileSpec::FileType file_type,
+ void *baton, llvm::sys::fs::file_type ft,
const lldb_private::FileSpec &file_spec);
uint32_t FindFileInAllSDKs(const char *platform_file_path,
diff --git a/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp b/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
index b4ce0830598b..9a082c701f02 100644
--- a/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
+++ b/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
@@ -16,18 +16,20 @@
// Project includes
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+
+#include "llvm/Support/FileSystem.h"
using namespace lldb;
using namespace lldb_private;
@@ -252,9 +254,9 @@ Error PlatformiOSSimulator::ResolveExecutable(
}
static FileSpec::EnumerateDirectoryResult
-EnumerateDirectoryCallback(void *baton, FileSpec::FileType file_type,
+EnumerateDirectoryCallback(void *baton, llvm::sys::fs::file_type ft,
const FileSpec &file_spec) {
- if (file_type == FileSpec::eFileTypeDirectory) {
+ if (ft == llvm::sys::fs::file_type::directory_file) {
const char *filename = file_spec.GetFilename().GetCString();
if (filename &&
strncmp(filename, "iPhoneSimulator", strlen("iPhoneSimulator")) == 0) {
diff --git a/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.h b/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.h
index c132dc6fa433..2a2a6f73a0e1 100644
--- a/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.h
+++ b/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.h
@@ -24,10 +24,10 @@
typedef void *id;
#endif
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Target/ProcessLaunchInfo.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
#include "llvm/ADT/Optional.h"
diff --git a/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm b/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm
index 233c548eb37b..de92aa0de7aa 100644
--- a/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm
+++ b/source/Plugins/Platform/MacOSX/PlatformiOSSimulatorCoreSimulatorSupport.mm
@@ -16,8 +16,8 @@
#include <CoreFoundation/CoreFoundation.h>
#include <Foundation/Foundation.h>
// Project includes
+#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Target/FileAction.h"
-#include "lldb/Utility/PseudoTerminal.h"
#include "llvm/ADT/StringRef.h"
diff --git a/source/Plugins/Platform/NetBSD/CMakeLists.txt b/source/Plugins/Platform/NetBSD/CMakeLists.txt
index c70b419b98b4..5e63f1098067 100644
--- a/source/Plugins/Platform/NetBSD/CMakeLists.txt
+++ b/source/Plugins/Platform/NetBSD/CMakeLists.txt
@@ -1,3 +1,9 @@
-add_lldb_library(lldbPluginPlatformNetBSD
+add_lldb_library(lldbPluginPlatformNetBSD PLUGIN
PlatformNetBSD.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbHost
+ lldbTarget
)
diff --git a/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp b/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
index bc4bfd32aad7..409f12deefca 100644
--- a/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
+++ b/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
@@ -19,25 +19,45 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Breakpoint/BreakpointLocation.h"
-#include "lldb/Breakpoint/BreakpointSite.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Module.h"
-#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Host/Host.h"
+#include "lldb/Core/State.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+
+// Define these constants from NetBSD mman.h for use when targeting
+// remote netbsd systems even when host has different values.
+#define MAP_PRIVATE 0x0002
+#define MAP_ANON 0x1000
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::platform_netbsd;
+static uint32_t g_initialize_count = 0;
+
+//------------------------------------------------------------------
+
PlatformSP PlatformNetBSD::CreateInstance(bool force, const ArchSpec *arch) {
- // The only time we create an instance is when we are creating a remote
- // netbsd platform
- const bool is_host = false;
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log) {
+ const char *arch_name;
+ if (arch && arch->GetArchitectureName())
+ arch_name = arch->GetArchitectureName();
+ else
+ arch_name = "<null>";
+
+ const char *triple_cstr =
+ arch ? arch->GetTriple().getTriple().c_str() : "<null>";
+
+ log->Printf("PlatformNetBSD::%s(force=%s, arch={%s,%s})", __FUNCTION__,
+ force ? "true" : "false", arch_name, triple_cstr);
+ }
bool create = force;
if (create == false && arch && arch->IsValid()) {
@@ -51,8 +71,19 @@ PlatformSP PlatformNetBSD::CreateInstance(bool force, const ArchSpec *arch) {
break;
}
}
- if (create)
- return PlatformSP(new PlatformNetBSD(is_host));
+
+ if (create) {
+ if (log)
+ log->Printf("PlatformNetBSD::%s() creating remote-netbsd platform",
+ __FUNCTION__);
+ return PlatformSP(new PlatformNetBSD(false));
+ }
+
+ if (log)
+ log->Printf(
+ "PlatformNetBSD::%s() aborting creation of remote-netbsd platform",
+ __FUNCTION__);
+
return PlatformSP();
}
@@ -66,359 +97,51 @@ ConstString PlatformNetBSD::GetPluginNameStatic(bool is_host) {
}
}
-const char *PlatformNetBSD::GetDescriptionStatic(bool is_host) {
+const char *PlatformNetBSD::GetPluginDescriptionStatic(bool is_host) {
if (is_host)
return "Local NetBSD user platform plug-in.";
else
return "Remote NetBSD user platform plug-in.";
}
-static uint32_t g_initialize_count = 0;
+ConstString PlatformNetBSD::GetPluginName() {
+ return GetPluginNameStatic(IsHost());
+}
void PlatformNetBSD::Initialize() {
- Platform::Initialize();
+ PlatformPOSIX::Initialize();
if (g_initialize_count++ == 0) {
#if defined(__NetBSD__)
- // Force a host flag to true for the default platform object.
PlatformSP default_platform_sp(new PlatformNetBSD(true));
default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
Platform::SetHostPlatform(default_platform_sp);
#endif
- PluginManager::RegisterPlugin(PlatformNetBSD::GetPluginNameStatic(false),
- PlatformNetBSD::GetDescriptionStatic(false),
- PlatformNetBSD::CreateInstance);
+ PluginManager::RegisterPlugin(
+ PlatformNetBSD::GetPluginNameStatic(false),
+ PlatformNetBSD::GetPluginDescriptionStatic(false),
+ PlatformNetBSD::CreateInstance, nullptr);
}
}
void PlatformNetBSD::Terminate() {
- if (g_initialize_count > 0 && --g_initialize_count == 0)
- PluginManager::UnregisterPlugin(PlatformNetBSD::CreateInstance);
-
- Platform::Terminate();
-}
-
-bool PlatformNetBSD::GetModuleSpec(const FileSpec &module_file_spec,
- const ArchSpec &arch,
- ModuleSpec &module_spec) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetModuleSpec(module_file_spec, arch,
- module_spec);
-
- return Platform::GetModuleSpec(module_file_spec, arch, module_spec);
-}
-
-Error PlatformNetBSD::RunShellCommand(const char *command,
- const FileSpec &working_dir,
- int *status_ptr, int *signo_ptr,
- std::string *command_output,
- uint32_t timeout_sec) {
- if (IsHost())
- return Host::RunShellCommand(command, working_dir, status_ptr, signo_ptr,
- command_output, timeout_sec);
- else {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->RunShellCommand(command, working_dir,
- status_ptr, signo_ptr,
- command_output, timeout_sec);
- else
- return Error("unable to run a remote command without a platform");
- }
-}
-
-Error PlatformNetBSD::ResolveExecutable(
- const ModuleSpec &module_spec, lldb::ModuleSP &exe_module_sp,
- const FileSpecList *module_search_paths_ptr) {
- Error error;
- // Nothing special to do here, just use the actual file and architecture
-
- char exe_path[PATH_MAX];
- ModuleSpec resolved_module_spec(module_spec);
-
- if (IsHost()) {
- // If we have "ls" as the module_spec's file, resolve the executable
- // location based on
- // the current path variables
- if (!resolved_module_spec.GetFileSpec().Exists()) {
- module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
- resolved_module_spec.GetFileSpec().SetFile(exe_path, true);
- }
-
- if (!resolved_module_spec.GetFileSpec().Exists())
- resolved_module_spec.GetFileSpec().ResolveExecutableLocation();
-
- if (resolved_module_spec.GetFileSpec().Exists())
- error.Clear();
- else {
- error.SetErrorStringWithFormat(
- "unable to find executable for '%s'",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- } else {
- if (m_remote_platform_sp) {
- error =
- GetCachedExecutable(resolved_module_spec, exe_module_sp,
- module_search_paths_ptr, *m_remote_platform_sp);
- } else {
- // We may connect to a process and use the provided executable (Don't use
- // local $PATH).
-
- // Resolve any executable within a bundle on MacOSX
- Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
-
- if (resolved_module_spec.GetFileSpec().Exists()) {
- error.Clear();
- } else {
- error.SetErrorStringWithFormat(
- "the platform is not currently connected, and '%s' doesn't exist "
- "in the system root.",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
- }
-
- if (error.Success()) {
- if (resolved_module_spec.GetArchitecture().IsValid()) {
- error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
- module_search_paths_ptr, NULL, NULL);
-
- if (!exe_module_sp || exe_module_sp->GetObjectFile() == NULL) {
- exe_module_sp.reset();
- error.SetErrorStringWithFormat(
- "'%s' doesn't contain the architecture %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
- } else {
- // No valid architecture was specified, ask the platform for
- // the architectures that we should be using (in the correct order)
- // and see if we can find a match that way
- StreamString arch_names;
- for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
- idx, resolved_module_spec.GetArchitecture());
- ++idx) {
- error =
- ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
- module_search_paths_ptr, NULL, NULL);
- // Did we find an executable using one of the
- if (error.Success()) {
- if (exe_module_sp && exe_module_sp->GetObjectFile())
- break;
- else
- error.SetErrorToGenericError();
- }
-
- if (idx > 0)
- arch_names.PutCString(", ");
- arch_names.PutCString(
- resolved_module_spec.GetArchitecture().GetArchitectureName());
- }
-
- if (error.Fail() || !exe_module_sp) {
- if (resolved_module_spec.GetFileSpec().Readable()) {
- error.SetErrorStringWithFormat(
- "'%s' doesn't contain any '%s' platform architectures: %s",
- resolved_module_spec.GetFileSpec().GetPath().c_str(),
- GetPluginName().GetCString(), arch_names.GetData());
- } else {
- error.SetErrorStringWithFormat(
- "'%s' is not readable",
- resolved_module_spec.GetFileSpec().GetPath().c_str());
- }
- }
+ if (g_initialize_count > 0) {
+ if (--g_initialize_count == 0) {
+ PluginManager::UnregisterPlugin(PlatformNetBSD::CreateInstance);
}
}
- return error;
-}
-
-// From PlatformMacOSX only
-Error PlatformNetBSD::GetFileWithUUID(const FileSpec &platform_file,
- const UUID *uuid_ptr,
- FileSpec &local_file) {
- if (IsRemote()) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr,
- local_file);
- }
-
- // Default to the local case
- local_file = platform_file;
- return Error();
+ PlatformPOSIX::Terminate();
}
//------------------------------------------------------------------
/// Default Constructor
//------------------------------------------------------------------
PlatformNetBSD::PlatformNetBSD(bool is_host)
- : Platform(is_host), m_remote_platform_sp() {}
-
-bool PlatformNetBSD::GetRemoteOSVersion() {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetOSVersion(
- m_major_os_version, m_minor_os_version, m_update_os_version);
- return false;
-}
-
-bool PlatformNetBSD::GetRemoteOSBuildString(std::string &s) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteOSBuildString(s);
- s.clear();
- return false;
-}
-
-bool PlatformNetBSD::GetRemoteOSKernelDescription(std::string &s) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteOSKernelDescription(s);
- s.clear();
- return false;
-}
-
-// Remote Platform subclasses need to override this function
-ArchSpec PlatformNetBSD::GetRemoteSystemArchitecture() {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteSystemArchitecture();
- return ArchSpec();
-}
-
-const char *PlatformNetBSD::GetHostname() {
- if (IsHost())
- return Platform::GetHostname();
-
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetHostname();
- return NULL;
-}
-
-bool PlatformNetBSD::IsConnected() const {
- if (IsHost())
- return true;
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->IsConnected();
- return false;
-}
-
-Error PlatformNetBSD::ConnectRemote(Args &args) {
- Error error;
- if (IsHost()) {
- error.SetErrorStringWithFormat(
- "can't connect to the host platform '%s', always connected",
- GetPluginName().GetCString());
- } else {
- if (!m_remote_platform_sp)
- m_remote_platform_sp =
- Platform::Create(ConstString("remote-gdb-server"), error);
-
- if (m_remote_platform_sp) {
- if (error.Success()) {
- if (m_remote_platform_sp) {
- error = m_remote_platform_sp->ConnectRemote(args);
- } else {
- error.SetErrorString(
- "\"platform connect\" takes a single argument: <connect-url>");
- }
- }
- } else
- error.SetErrorString("failed to create a 'remote-gdb-server' platform");
-
- if (error.Fail())
- m_remote_platform_sp.reset();
- }
-
- return error;
-}
-
-Error PlatformNetBSD::DisconnectRemote() {
- Error error;
-
- if (IsHost()) {
- error.SetErrorStringWithFormat(
- "can't disconnect from the host platform '%s', always connected",
- GetPluginName().GetCString());
- } else {
- if (m_remote_platform_sp)
- error = m_remote_platform_sp->DisconnectRemote();
- else
- error.SetErrorString("the platform is not currently connected");
- }
- return error;
-}
-
-bool PlatformNetBSD::GetProcessInfo(lldb::pid_t pid,
- ProcessInstanceInfo &process_info) {
- bool success = false;
- if (IsHost()) {
- success = Platform::GetProcessInfo(pid, process_info);
- } else if (m_remote_platform_sp) {
- success = m_remote_platform_sp->GetProcessInfo(pid, process_info);
- }
- return success;
-}
-
-uint32_t
-PlatformNetBSD::FindProcesses(const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos) {
- uint32_t match_count = 0;
- if (IsHost()) {
- // Let the base class figure out the host details
- match_count = Platform::FindProcesses(match_info, process_infos);
- } else {
- // If we are remote, we can only return results if we are connected
- if (m_remote_platform_sp)
- match_count =
- m_remote_platform_sp->FindProcesses(match_info, process_infos);
- }
- return match_count;
-}
-
-const char *PlatformNetBSD::GetUserName(uint32_t uid) {
- // Check the cache in Platform in case we have already looked this uid up
- const char *user_name = Platform::GetUserName(uid);
- if (user_name)
- return user_name;
-
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetUserName(uid);
- return NULL;
-}
-
-const char *PlatformNetBSD::GetGroupName(uint32_t gid) {
- const char *group_name = Platform::GetGroupName(gid);
- if (group_name)
- return group_name;
-
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetGroupName(gid);
- return NULL;
-}
-
-Error PlatformNetBSD::GetSharedModule(
- const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr) {
- Error error;
- module_sp.reset();
+ : PlatformPOSIX(is_host) // This is the local host platform
+{}
- if (IsRemote()) {
- // If we have a remote platform always, let it try and locate
- // the shared module first.
- if (m_remote_platform_sp) {
- error = m_remote_platform_sp->GetSharedModule(
- module_spec, process, module_sp, module_search_paths_ptr,
- old_module_sp_ptr, did_create_ptr);
- }
- }
-
- if (!module_sp) {
- // Fall back to the local platform and find the file locally
- error = Platform::GetSharedModule(module_spec, process, module_sp,
- module_search_paths_ptr,
- old_module_sp_ptr, did_create_ptr);
- }
- if (module_sp)
- module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
- return error;
-}
+PlatformNetBSD::~PlatformNetBSD() = default;
bool PlatformNetBSD::GetSupportedArchitectureAtIndex(uint32_t idx,
ArchSpec &arch) {
@@ -471,79 +194,239 @@ bool PlatformNetBSD::GetSupportedArchitectureAtIndex(uint32_t idx,
}
void PlatformNetBSD::GetStatus(Stream &strm) {
-#ifndef LLDB_DISABLE_POSIX
- struct ::utsname un;
+ Platform::GetStatus(strm);
- strm << " Host: ";
+#ifndef LLDB_DISABLE_POSIX
+ // Display local kernel information only when we are running in host mode.
+ // Otherwise, we would end up printing non-NetBSD information (when running
+ // on Mac OS for example).
+ if (IsHost()) {
+ struct utsname un;
- ::memset(&un, 0, sizeof(utsname));
- if (::uname(&un) == -1) {
- strm << "NetBSD" << '\n';
- } else {
- strm << un.sysname << ' ' << un.release;
- if (un.nodename[0] != '\0')
- strm << " (" << un.nodename << ')';
- strm << '\n';
+ if (uname(&un))
+ return;
- // Dump a common information about the platform status.
- strm << "Host: " << un.sysname << ' ' << un.release << ' ' << un.version
- << '\n';
+ strm.Printf(" Kernel: %s\n", un.sysname);
+ strm.Printf(" Release: %s\n", un.release);
+ strm.Printf(" Version: %s\n", un.version);
}
#endif
-
- Platform::GetStatus(strm);
}
-void PlatformNetBSD::CalculateTrapHandlerSymbolNames() {
- m_trap_handlers.push_back(ConstString("_sigtramp"));
+int32_t
+PlatformNetBSD::GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) {
+ int32_t resume_count = 0;
+
+ // Always resume past the initial stop when we use eLaunchFlagDebug
+ if (launch_info.GetFlags().Test(eLaunchFlagDebug)) {
+ // Resume past the stop for the final exec into the true inferior.
+ ++resume_count;
+ }
+
+ // If we're not launching a shell, we're done.
+ const FileSpec &shell = launch_info.GetShell();
+ if (!shell)
+ return resume_count;
+
+ std::string shell_string = shell.GetPath();
+ // We're in a shell, so for sure we have to resume past the shell exec.
+ ++resume_count;
+
+ // Figure out what shell we're planning on using.
+ const char *shell_name = strrchr(shell_string.c_str(), '/');
+ if (shell_name == NULL)
+ shell_name = shell_string.c_str();
+ else
+ shell_name++;
+
+ if (strcmp(shell_name, "csh") == 0 || strcmp(shell_name, "tcsh") == 0 ||
+ strcmp(shell_name, "zsh") == 0 || strcmp(shell_name, "sh") == 0) {
+ // These shells seem to re-exec themselves. Add another resume.
+ ++resume_count;
+ }
+
+ return resume_count;
}
-Error PlatformNetBSD::LaunchProcess(ProcessLaunchInfo &launch_info) {
- Error error;
+bool PlatformNetBSD::CanDebugProcess() {
if (IsHost()) {
- error = Platform::LaunchProcess(launch_info);
+ return true;
} else {
- if (m_remote_platform_sp)
- error = m_remote_platform_sp->LaunchProcess(launch_info);
- else
- error.SetErrorString("the platform is not currently connected");
+ // If we're connected, we can debug.
+ return IsConnected();
}
- return error;
}
-lldb::ProcessSP PlatformNetBSD::Attach(ProcessAttachInfo &attach_info,
- Debugger &debugger, Target *target,
- Error &error) {
- lldb::ProcessSP process_sp;
- if (IsHost()) {
- if (target == NULL) {
- TargetSP new_target_sp;
- ArchSpec emptyArchSpec;
+// For local debugging, NetBSD will override the debug logic to use llgs-launch
+// rather than
+// lldb-launch, llgs-attach. This differs from current lldb-launch,
+// debugserver-attach
+// approach on MacOSX.
+lldb::ProcessSP
+PlatformNetBSD::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
+ Target *target, // Can be NULL, if NULL create a new
+ // target, else use existing one
+ Error &error) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ if (log)
+ log->Printf("PlatformNetBSD::%s entered (target %p)", __FUNCTION__,
+ static_cast<void *>(target));
+
+ // If we're a remote host, use standard behavior from parent class.
+ if (!IsHost())
+ return PlatformPOSIX::DebugProcess(launch_info, debugger, target, error);
- error = debugger.GetTargetList().CreateTarget(debugger, "", emptyArchSpec,
- false, m_remote_platform_sp,
- new_target_sp);
- target = new_target_sp.get();
- } else
- error.Clear();
+ //
+ // For local debugging, we'll insist on having ProcessGDBRemote create the
+ // process.
+ //
- if (target && error.Success()) {
- debugger.GetTargetList().SetSelectedTarget(target);
- // The netbsd always currently uses the GDB remote debugger plug-in
- // so even when debugging locally we are debugging remotely!
- // Just like the darwin plugin.
- process_sp = target->CreateProcess(
- attach_info.GetListenerForProcess(debugger), "gdb-remote", NULL);
+ ProcessSP process_sp;
+
+ // Make sure we stop at the entry point
+ launch_info.GetFlags().Set(eLaunchFlagDebug);
+
+ // We always launch the process we are going to debug in a separate process
+ // group, since then we can handle ^C interrupts ourselves w/o having to worry
+ // about the target getting them as well.
+ launch_info.SetLaunchInSeparateProcessGroup(true);
+
+ // Ensure we have a target.
+ if (target == nullptr) {
+ if (log)
+ log->Printf("PlatformNetBSD::%s creating new target", __FUNCTION__);
+
+ TargetSP new_target_sp;
+ error = debugger.GetTargetList().CreateTarget(debugger, "", "", false,
+ nullptr, new_target_sp);
+ if (error.Fail()) {
+ if (log)
+ log->Printf("PlatformNetBSD::%s failed to create new target: %s",
+ __FUNCTION__, error.AsCString());
+ return process_sp;
+ }
- if (process_sp)
- error = process_sp->Attach(attach_info);
+ target = new_target_sp.get();
+ if (!target) {
+ error.SetErrorString("CreateTarget() returned nullptr");
+ if (log)
+ log->Printf("PlatformNetBSD::%s failed: %s", __FUNCTION__,
+ error.AsCString());
+ return process_sp;
}
} else {
- if (m_remote_platform_sp)
- process_sp =
- m_remote_platform_sp->Attach(attach_info, debugger, target, error);
- else
- error.SetErrorString("the platform is not currently connected");
+ if (log)
+ log->Printf("PlatformNetBSD::%s using provided target", __FUNCTION__);
+ }
+
+ // Mark target as currently selected target.
+ debugger.GetTargetList().SetSelectedTarget(target);
+
+ // Now create the gdb-remote process.
+ if (log)
+ log->Printf(
+ "PlatformNetBSD::%s having target create process with gdb-remote plugin",
+ __FUNCTION__);
+ process_sp = target->CreateProcess(
+ launch_info.GetListenerForProcess(debugger), "gdb-remote", nullptr);
+
+ if (!process_sp) {
+ error.SetErrorString("CreateProcess() failed for gdb-remote process");
+ if (log)
+ log->Printf("PlatformNetBSD::%s failed: %s", __FUNCTION__,
+ error.AsCString());
+ return process_sp;
+ } else {
+ if (log)
+ log->Printf("PlatformNetBSD::%s successfully created process",
+ __FUNCTION__);
+ }
+
+ // Adjust launch for a hijacker.
+ ListenerSP listener_sp;
+ if (!launch_info.GetHijackListener()) {
+ if (log)
+ log->Printf("PlatformNetBSD::%s setting up hijacker", __FUNCTION__);
+
+ listener_sp =
+ Listener::MakeListener("lldb.PlatformNetBSD.DebugProcess.hijack");
+ launch_info.SetHijackListener(listener_sp);
+ process_sp->HijackProcessEvents(listener_sp);
+ }
+
+ // Log file actions.
+ if (log) {
+ log->Printf(
+ "PlatformNetBSD::%s launching process with the following file actions:",
+ __FUNCTION__);
+
+ StreamString stream;
+ size_t i = 0;
+ const FileAction *file_action;
+ while ((file_action = launch_info.GetFileActionAtIndex(i++)) != nullptr) {
+ file_action->Dump(stream);
+ log->PutCString(stream.GetData());
+ stream.Clear();
+ }
+ }
+
+ // Do the launch.
+ error = process_sp->Launch(launch_info);
+ if (error.Success()) {
+ // Handle the hijacking of process events.
+ if (listener_sp) {
+ const StateType state = process_sp->WaitForProcessToStop(
+ llvm::None, NULL, false, listener_sp);
+
+ if (state == eStateStopped) {
+ if (log)
+ log->Printf("PlatformNetBSD::%s pid %" PRIu64 " state %s\n",
+ __FUNCTION__, process_sp->GetID(), StateAsCString(state));
+ } else {
+ if (log)
+ log->Printf("PlatformNetBSD::%s pid %" PRIu64
+ " state is not stopped - %s\n",
+ __FUNCTION__, process_sp->GetID(), StateAsCString(state));
+ }
+ }
+
+ // Hook up process PTY if we have one (which we should for local debugging
+ // with llgs).
+ int pty_fd = launch_info.GetPTY().ReleaseMasterFileDescriptor();
+ if (pty_fd != lldb_utility::PseudoTerminal::invalid_fd) {
+ process_sp->SetSTDIOFileDescriptor(pty_fd);
+ if (log)
+ log->Printf("PlatformNetBSD::%s pid %" PRIu64
+ " hooked up STDIO pty to process",
+ __FUNCTION__, process_sp->GetID());
+ } else {
+ if (log)
+ log->Printf("PlatformNetBSD::%s pid %" PRIu64
+ " not using process STDIO pty",
+ __FUNCTION__, process_sp->GetID());
+ }
+ } else {
+ if (log)
+ log->Printf("PlatformNetBSD::%s process launch failed: %s", __FUNCTION__,
+ error.AsCString());
+ // FIXME figure out appropriate cleanup here. Do we delete the target? Do
+ // we delete the process? Does our caller do that?
}
+
return process_sp;
}
+
+void PlatformNetBSD::CalculateTrapHandlerSymbolNames() {
+ m_trap_handlers.push_back(ConstString("_sigtramp"));
+}
+
+uint64_t PlatformNetBSD::ConvertMmapFlagsToPlatform(const ArchSpec &arch,
+ unsigned flags) {
+ uint64_t flags_platform = 0;
+
+ if (flags & eMmapFlagsPrivate)
+ flags_platform |= MAP_PRIVATE;
+ if (flags & eMmapFlagsAnon)
+ flags_platform |= MAP_ANON;
+ return flags_platform;
+}
diff --git a/source/Plugins/Platform/NetBSD/PlatformNetBSD.h b/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
index ddca5eb5be3e..500c61dab970 100644
--- a/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
+++ b/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
@@ -10,113 +10,57 @@
#ifndef liblldb_PlatformNetBSD_h_
#define liblldb_PlatformNetBSD_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Target/Platform.h"
+#include "Plugins/Platform/POSIX/PlatformPOSIX.h"
namespace lldb_private {
namespace platform_netbsd {
-class PlatformNetBSD : public Platform {
+class PlatformNetBSD : public PlatformPOSIX {
public:
PlatformNetBSD(bool is_host);
- ~PlatformNetBSD() override = default;
-
- //------------------------------------------------------------
- // Class functions
- //------------------------------------------------------------
- static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch);
+ ~PlatformNetBSD() override;
static void Initialize();
static void Terminate();
- static ConstString GetPluginNameStatic(bool is_host);
-
- static const char *GetDescriptionStatic(bool is_host);
-
//------------------------------------------------------------
// lldb_private::PluginInterface functions
//------------------------------------------------------------
- ConstString GetPluginName() override { return GetPluginNameStatic(IsHost()); }
+ static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch);
- uint32_t GetPluginVersion() override { return 1; }
+ static ConstString GetPluginNameStatic(bool is_host);
- const char *GetDescription() override {
- return GetDescriptionStatic(IsHost());
- }
+ static const char *GetPluginDescriptionStatic(bool is_host);
+
+ ConstString GetPluginName() override;
+
+ uint32_t GetPluginVersion() override { return 1; }
//------------------------------------------------------------
// lldb_private::Platform functions
//------------------------------------------------------------
- bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch,
- ModuleSpec &module_spec) override;
-
- Error RunShellCommand(const char *command, const FileSpec &working_dir,
- int *status_ptr, int *signo_ptr,
- std::string *command_output,
- uint32_t timeout_sec) override;
-
- Error ResolveExecutable(const ModuleSpec &module_spec,
- lldb::ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr) override;
-
- bool GetRemoteOSVersion() override;
-
- bool GetRemoteOSBuildString(std::string &s) override;
-
- bool GetRemoteOSKernelDescription(std::string &s) override;
-
- // Remote Platform subclasses need to override this function
- ArchSpec GetRemoteSystemArchitecture() override;
-
- bool IsConnected() const override;
-
- Error ConnectRemote(Args &args) override;
-
- Error DisconnectRemote() override;
-
- const char *GetHostname() override;
-
- const char *GetUserName(uint32_t uid) override;
-
- const char *GetGroupName(uint32_t gid) override;
-
- bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) override;
-
- uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos) override;
-
- Error LaunchProcess(ProcessLaunchInfo &launch_info) override;
-
- lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger,
- Target *target, Error &error) override;
+ const char *GetDescription() override {
+ return GetPluginDescriptionStatic(IsHost());
+ }
- // NetBSD processes can not be launched by spawning and attaching.
- bool CanDebugProcess() override { return false; }
+ void GetStatus(Stream &strm) override;
- // Only on PlatformMacOSX:
- Error GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid,
- FileSpec &local_file) override;
+ bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override;
- Error GetSharedModule(const ModuleSpec &module_spec, Process *process,
- lldb::ModuleSP &module_sp,
- const FileSpecList *module_search_paths_ptr,
- lldb::ModuleSP *old_module_sp_ptr,
- bool *did_create_ptr) override;
+ int32_t GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) override;
- bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override;
+ bool CanDebugProcess() override;
- void GetStatus(Stream &strm) override;
+ lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info,
+ Debugger &debugger, Target *target,
+ Error &error) override;
void CalculateTrapHandlerSymbolNames() override;
-protected:
- lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a
- // remote netbsd OS
+ uint64_t ConvertMmapFlagsToPlatform(const ArchSpec &arch,
+ unsigned flags) override;
private:
DISALLOW_COPY_AND_ASSIGN(PlatformNetBSD);
diff --git a/source/Plugins/Platform/OpenBSD/CMakeLists.txt b/source/Plugins/Platform/OpenBSD/CMakeLists.txt
new file mode 100644
index 000000000000..8d49e7c4f196
--- /dev/null
+++ b/source/Plugins/Platform/OpenBSD/CMakeLists.txt
@@ -0,0 +1,9 @@
+add_lldb_library(lldbPluginPlatformOpenBSD PLUGIN
+ PlatformOpenBSD.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbHost
+ lldbTarget
+ )
diff --git a/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp b/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
new file mode 100644
index 000000000000..e3816d0276b2
--- /dev/null
+++ b/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
@@ -0,0 +1,223 @@
+//===-- PlatformOpenBSD.cpp -------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "PlatformOpenBSD.h"
+#include "lldb/Host/Config.h"
+
+// C Includes
+#include <stdio.h>
+#ifndef LLDB_DISABLE_POSIX
+#include <sys/utsname.h>
+#endif
+
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/State.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+
+// Define these constants from OpenBSD mman.h for use when targeting
+// remote openbsd systems even when host has different values.
+#define MAP_PRIVATE 0x0002
+#define MAP_ANON 0x1000
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::platform_openbsd;
+
+static uint32_t g_initialize_count = 0;
+
+//------------------------------------------------------------------
+
+PlatformSP PlatformOpenBSD::CreateInstance(bool force, const ArchSpec *arch) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
+ LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force,
+ arch ? arch->GetArchitectureName() : "<null>",
+ arch ? arch->GetTriple().getTriple() : "<null>");
+
+ bool create = force;
+ if (create == false && arch && arch->IsValid()) {
+ const llvm::Triple &triple = arch->GetTriple();
+ switch (triple.getOS()) {
+ case llvm::Triple::OpenBSD:
+ create = true;
+ break;
+
+#if defined(__OpenBSD__)
+ // Only accept "unknown" for the OS if the host is BSD and
+ // it "unknown" wasn't specified (it was just returned because it
+ // was NOT specified)
+ case llvm::Triple::OSType::UnknownOS:
+ create = !arch->TripleOSWasSpecified();
+ break;
+#endif
+ default:
+ break;
+ }
+ }
+ LLDB_LOG(log, "create = {0}", create);
+ if (create) {
+ return PlatformSP(new PlatformOpenBSD(false));
+ }
+ return PlatformSP();
+}
+
+ConstString PlatformOpenBSD::GetPluginNameStatic(bool is_host) {
+ if (is_host) {
+ static ConstString g_host_name(Platform::GetHostPlatformName());
+ return g_host_name;
+ } else {
+ static ConstString g_remote_name("remote-openbsd");
+ return g_remote_name;
+ }
+}
+
+const char *PlatformOpenBSD::GetPluginDescriptionStatic(bool is_host) {
+ if (is_host)
+ return "Local OpenBSD user platform plug-in.";
+ else
+ return "Remote OpenBSD user platform plug-in.";
+}
+
+ConstString PlatformOpenBSD::GetPluginName() {
+ return GetPluginNameStatic(IsHost());
+}
+
+void PlatformOpenBSD::Initialize() {
+ Platform::Initialize();
+
+ if (g_initialize_count++ == 0) {
+#if defined(__OpenBSD__)
+ PlatformSP default_platform_sp(new PlatformOpenBSD(true));
+ default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
+ Platform::SetHostPlatform(default_platform_sp);
+#endif
+ PluginManager::RegisterPlugin(
+ PlatformOpenBSD::GetPluginNameStatic(false),
+ PlatformOpenBSD::GetPluginDescriptionStatic(false),
+ PlatformOpenBSD::CreateInstance, nullptr);
+ }
+}
+
+void PlatformOpenBSD::Terminate() {
+ if (g_initialize_count > 0) {
+ if (--g_initialize_count == 0) {
+ PluginManager::UnregisterPlugin(PlatformOpenBSD::CreateInstance);
+ }
+ }
+
+ PlatformPOSIX::Terminate();
+}
+
+//------------------------------------------------------------------
+/// Default Constructor
+//------------------------------------------------------------------
+PlatformOpenBSD::PlatformOpenBSD(bool is_host)
+ : PlatformPOSIX(is_host) // This is the local host platform
+{}
+
+PlatformOpenBSD::~PlatformOpenBSD() = default;
+
+bool PlatformOpenBSD::GetSupportedArchitectureAtIndex(uint32_t idx,
+ ArchSpec &arch) {
+ if (IsHost()) {
+ ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
+ if (hostArch.GetTriple().isOSOpenBSD()) {
+ if (idx == 0) {
+ arch = hostArch;
+ return arch.IsValid();
+ }
+ }
+ } else {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetSupportedArchitectureAtIndex(idx, arch);
+
+ llvm::Triple triple;
+ // Set the OS to OpenBSD
+ triple.setOS(llvm::Triple::OpenBSD);
+ // Set the architecture
+ switch (idx) {
+ case 0:
+ triple.setArchName("x86_64");
+ break;
+ case 1:
+ triple.setArchName("i386");
+ break;
+ case 2:
+ triple.setArchName("aarch64");
+ break;
+ case 3:
+ triple.setArchName("arm");
+ break;
+ default:
+ return false;
+ }
+ // Leave the vendor as "llvm::Triple:UnknownVendor" and don't specify the
+ // vendor by
+ // calling triple.SetVendorName("unknown") so that it is a "unspecified
+ // unknown".
+ // This means when someone calls triple.GetVendorName() it will return an
+ // empty string
+ // which indicates that the vendor can be set when two architectures are
+ // merged
+
+ // Now set the triple into "arch" and return true
+ arch.SetTriple(triple);
+ return true;
+ }
+ return false;
+}
+
+void PlatformOpenBSD::GetStatus(Stream &strm) {
+ Platform::GetStatus(strm);
+
+#ifndef LLDB_DISABLE_POSIX
+ // Display local kernel information only when we are running in host mode.
+ // Otherwise, we would end up printing non-OpenBSD information (when running
+ // on Mac OS for example).
+ if (IsHost()) {
+ struct utsname un;
+
+ if (uname(&un))
+ return;
+
+ strm.Printf(" Kernel: %s\n", un.sysname);
+ strm.Printf(" Release: %s\n", un.release);
+ strm.Printf(" Version: %s\n", un.version);
+ }
+#endif
+}
+
+// OpenBSD processes cannot yet be launched by spawning and attaching.
+bool PlatformOpenBSD::CanDebugProcess() {
+ return false;
+}
+
+void PlatformOpenBSD::CalculateTrapHandlerSymbolNames() {
+ m_trap_handlers.push_back(ConstString("_sigtramp"));
+}
+
+uint64_t PlatformOpenBSD::ConvertMmapFlagsToPlatform(const ArchSpec &arch,
+ unsigned flags) {
+ uint64_t flags_platform = 0;
+
+ if (flags & eMmapFlagsPrivate)
+ flags_platform |= MAP_PRIVATE;
+ if (flags & eMmapFlagsAnon)
+ flags_platform |= MAP_ANON;
+ return flags_platform;
+}
diff --git a/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h b/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
new file mode 100644
index 000000000000..55f6451e236e
--- /dev/null
+++ b/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
@@ -0,0 +1,66 @@
+//===-- PlatformOpenBSD.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_PlatformOpenBSD_h_
+#define liblldb_PlatformOpenBSD_h_
+
+#include "Plugins/Platform/POSIX/PlatformPOSIX.h"
+
+namespace lldb_private {
+namespace platform_openbsd {
+
+class PlatformOpenBSD : public PlatformPOSIX {
+public:
+ PlatformOpenBSD(bool is_host);
+
+ ~PlatformOpenBSD() override;
+
+ static void Initialize();
+
+ static void Terminate();
+
+ //------------------------------------------------------------
+ // lldb_private::PluginInterface functions
+ //------------------------------------------------------------
+ static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch);
+
+ static ConstString GetPluginNameStatic(bool is_host);
+
+ static const char *GetPluginDescriptionStatic(bool is_host);
+
+ ConstString GetPluginName() override;
+
+ uint32_t GetPluginVersion() override { return 1; }
+
+ //------------------------------------------------------------
+ // lldb_private::Platform functions
+ //------------------------------------------------------------
+ const char *GetDescription() override {
+ return GetPluginDescriptionStatic(IsHost());
+ }
+
+ void GetStatus(Stream &strm) override;
+
+ bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override;
+
+ bool CanDebugProcess() override;
+
+ void CalculateTrapHandlerSymbolNames() override;
+
+ uint64_t ConvertMmapFlagsToPlatform(const ArchSpec &arch,
+ unsigned flags) override;
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(PlatformOpenBSD);
+};
+
+} // namespace platform_openbsd
+} // namespace lldb_private
+
+#endif // liblldb_PlatformOpenBSD_h_
diff --git a/source/Plugins/Platform/POSIX/CMakeLists.txt b/source/Plugins/Platform/POSIX/CMakeLists.txt
index c23e68155c2b..749407d63d5c 100644
--- a/source/Plugins/Platform/POSIX/CMakeLists.txt
+++ b/source/Plugins/Platform/POSIX/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginPlatformPOSIX
+add_lldb_library(lldbPluginPlatformPOSIX PLUGIN
PlatformPOSIX.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbExpression
+ lldbHost
+ lldbInterpreter
+ lldbTarget
)
diff --git a/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index e51029c3630b..0032c804987c 100644
--- a/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -14,23 +14,25 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/StreamString.h"
+#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Expression/UserExpression.h"
#include "lldb/Host/File.h"
#include "lldb/Host/FileCache.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
+#include "lldb/Host/HostInfo.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/ProcessLaunchInfo.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
@@ -111,6 +113,175 @@ lldb_private::Error PlatformPOSIX::RunShellCommand(
}
}
+Error PlatformPOSIX::ResolveExecutable(const ModuleSpec &module_spec,
+ lldb::ModuleSP &exe_module_sp,
+ const FileSpecList *module_search_paths_ptr) {
+ Error error;
+ // Nothing special to do here, just use the actual file and architecture
+
+ char exe_path[PATH_MAX];
+ ModuleSpec resolved_module_spec(module_spec);
+
+ if (IsHost()) {
+ // If we have "ls" as the exe_file, resolve the executable location based on
+ // the current path variables
+ if (!resolved_module_spec.GetFileSpec().Exists()) {
+ resolved_module_spec.GetFileSpec().GetPath(exe_path, sizeof(exe_path));
+ resolved_module_spec.GetFileSpec().SetFile(exe_path, true);
+ }
+
+ if (!resolved_module_spec.GetFileSpec().Exists())
+ resolved_module_spec.GetFileSpec().ResolveExecutableLocation();
+
+ // Resolve any executable within a bundle on MacOSX
+ Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
+
+ if (resolved_module_spec.GetFileSpec().Exists())
+ error.Clear();
+ else {
+ const uint32_t permissions =
+ resolved_module_spec.GetFileSpec().GetPermissions();
+ if (permissions && (permissions & eFilePermissionsEveryoneR) == 0)
+ error.SetErrorStringWithFormat(
+ "executable '%s' is not readable",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ else
+ error.SetErrorStringWithFormat(
+ "unable to find executable for '%s'",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+ } else {
+ if (m_remote_platform_sp) {
+ error =
+ GetCachedExecutable(resolved_module_spec, exe_module_sp,
+ module_search_paths_ptr, *m_remote_platform_sp);
+ } else {
+ // We may connect to a process and use the provided executable (Don't use
+ // local $PATH).
+
+ // Resolve any executable within a bundle on MacOSX
+ Host::ResolveExecutableInBundle(resolved_module_spec.GetFileSpec());
+
+ if (resolved_module_spec.GetFileSpec().Exists())
+ error.Clear();
+ else
+ error.SetErrorStringWithFormat("the platform is not currently "
+ "connected, and '%s' doesn't exist in "
+ "the system root.",
+ exe_path);
+ }
+ }
+
+ if (error.Success()) {
+ if (resolved_module_spec.GetArchitecture().IsValid()) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ module_search_paths_ptr, nullptr, nullptr);
+ if (error.Fail()) {
+ // If we failed, it may be because the vendor and os aren't known. If
+ // that is the case, try setting them to the host architecture and give
+ // it another try.
+ llvm::Triple &module_triple =
+ resolved_module_spec.GetArchitecture().GetTriple();
+ bool is_vendor_specified =
+ (module_triple.getVendor() != llvm::Triple::UnknownVendor);
+ bool is_os_specified =
+ (module_triple.getOS() != llvm::Triple::UnknownOS);
+ if (!is_vendor_specified || !is_os_specified) {
+ const llvm::Triple &host_triple =
+ HostInfo::GetArchitecture(HostInfo::eArchKindDefault).GetTriple();
+
+ if (!is_vendor_specified)
+ module_triple.setVendorName(host_triple.getVendorName());
+ if (!is_os_specified)
+ module_triple.setOSName(host_triple.getOSName());
+
+ error = ModuleList::GetSharedModule(resolved_module_spec,
+ exe_module_sp, module_search_paths_ptr, nullptr, nullptr);
+ }
+ }
+
+ // TODO find out why exe_module_sp might be NULL
+ if (error.Fail() || !exe_module_sp || !exe_module_sp->GetObjectFile()) {
+ exe_module_sp.reset();
+ error.SetErrorStringWithFormat(
+ "'%s' doesn't contain the architecture %s",
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ resolved_module_spec.GetArchitecture().GetArchitectureName());
+ }
+ } else {
+ // No valid architecture was specified, ask the platform for
+ // the architectures that we should be using (in the correct order)
+ // and see if we can find a match that way
+ StreamString arch_names;
+ for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
+ idx, resolved_module_spec.GetArchitecture());
+ ++idx) {
+ error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
+ module_search_paths_ptr, nullptr, nullptr);
+ // Did we find an executable using one of the
+ if (error.Success()) {
+ if (exe_module_sp && exe_module_sp->GetObjectFile())
+ break;
+ else
+ error.SetErrorToGenericError();
+ }
+
+ if (idx > 0)
+ arch_names.PutCString(", ");
+ arch_names.PutCString(
+ resolved_module_spec.GetArchitecture().GetArchitectureName());
+ }
+
+ if (error.Fail() || !exe_module_sp) {
+ if (resolved_module_spec.GetFileSpec().Readable()) {
+ error.SetErrorStringWithFormat(
+ "'%s' doesn't contain any '%s' platform architectures: %s",
+ resolved_module_spec.GetFileSpec().GetPath().c_str(),
+ GetPluginName().GetCString(), arch_names.GetData());
+ } else {
+ error.SetErrorStringWithFormat(
+ "'%s' is not readable",
+ resolved_module_spec.GetFileSpec().GetPath().c_str());
+ }
+ }
+ }
+ }
+
+ return error;
+}
+
+Error PlatformPOSIX::GetFileWithUUID(const FileSpec &platform_file,
+ const UUID *uuid_ptr,
+ FileSpec &local_file) {
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr,
+ local_file);
+
+ // Default to the local case
+ local_file = platform_file;
+ return Error();
+}
+
+bool PlatformPOSIX::GetProcessInfo(lldb::pid_t pid,
+ ProcessInstanceInfo &process_info) {
+ if (IsHost())
+ return Platform::GetProcessInfo(pid, process_info);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetProcessInfo(pid, process_info);
+ return false;
+}
+
+uint32_t
+PlatformPOSIX::FindProcesses(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) {
+ if (IsHost())
+ return Platform::FindProcesses(match_info, process_infos);
+ if (m_remote_platform_sp)
+ return
+ m_remote_platform_sp->FindProcesses(match_info, process_infos);
+ return 0;
+}
+
Error PlatformPOSIX::MakeDirectory(const FileSpec &file_spec,
uint32_t file_permissions) {
if (m_remote_platform_sp)
@@ -264,9 +435,12 @@ PlatformPOSIX::PutFile(const lldb_private::FileSpec &source,
}
lldb::user_id_t PlatformPOSIX::GetFileSize(const FileSpec &file_spec) {
- if (IsHost())
- return FileSystem::GetFileSize(file_spec);
- else if (m_remote_platform_sp)
+ if (IsHost()) {
+ uint64_t Size;
+ if (llvm::sys::fs::file_size(file_spec.GetPath(), Size))
+ return 0;
+ return Size;
+ } else if (m_remote_platform_sp)
return m_remote_platform_sp->GetFileSize(file_spec);
else
return Platform::GetFileSize(file_spec);
@@ -292,7 +466,7 @@ bool PlatformPOSIX::GetFileExists(const FileSpec &file_spec) {
Error PlatformPOSIX::Unlink(const FileSpec &file_spec) {
if (IsHost())
- return FileSystem::Unlink(file_spec);
+ return llvm::sys::fs::remove(file_spec.GetPath());
else if (m_remote_platform_sp)
return m_remote_platform_sp->Unlink(file_spec);
else
@@ -864,3 +1038,12 @@ size_t PlatformPOSIX::ConnectToWaitingProcesses(Debugger &debugger,
return m_remote_platform_sp->ConnectToWaitingProcesses(debugger, error);
return Platform::ConnectToWaitingProcesses(debugger, error);
}
+
+ConstString PlatformPOSIX::GetFullNameForDylib(ConstString basename) {
+ if (basename.IsEmpty())
+ return basename;
+
+ StreamString stream;
+ stream.Printf("lib%s.so", basename.GetCString());
+ return ConstString(stream.GetString());
+}
diff --git a/source/Plugins/Platform/POSIX/PlatformPOSIX.h b/source/Plugins/Platform/POSIX/PlatformPOSIX.h
index 93213b295ca1..6c5c62797a6e 100644
--- a/source/Plugins/Platform/POSIX/PlatformPOSIX.h
+++ b/source/Plugins/Platform/POSIX/PlatformPOSIX.h
@@ -101,6 +101,18 @@ public:
uint32_t timeout_sec)
override; // Timeout in seconds to wait for shell program to finish
+ lldb_private::Error ResolveExecutable(const lldb_private::ModuleSpec &module_spec,
+ lldb::ModuleSP &module_sp,
+ const lldb_private::FileSpecList *module_search_paths_ptr) override;
+
+ lldb_private::Error GetFileWithUUID(const lldb_private::FileSpec &platform_file, const lldb_private::UUID *uuid,
+ lldb_private::FileSpec &local_file) override;
+
+ bool GetProcessInfo(lldb::pid_t pid, lldb_private::ProcessInstanceInfo &proc_info) override;
+
+ uint32_t FindProcesses(const lldb_private::ProcessInstanceInfoMatch &match_info,
+ lldb_private::ProcessInstanceInfoList &process_infos) override;
+
lldb_private::Error MakeDirectory(const lldb_private::FileSpec &file_spec,
uint32_t mode) override;
@@ -165,6 +177,8 @@ public:
size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
lldb_private::Error &error) override;
+ lldb_private::ConstString GetFullNameForDylib(lldb_private::ConstString basename) override;
+
protected:
std::unique_ptr<lldb_private::OptionGroupPlatformRSync>
m_option_group_platform_rsync;
diff --git a/source/Plugins/Platform/Windows/CMakeLists.txt b/source/Plugins/Platform/Windows/CMakeLists.txt
index 09fbc11d33f2..49a197cdaff3 100644
--- a/source/Plugins/Platform/Windows/CMakeLists.txt
+++ b/source/Plugins/Platform/Windows/CMakeLists.txt
@@ -1,3 +1,9 @@
-add_lldb_library(lldbPluginPlatformWindows
+add_lldb_library(lldbPluginPlatformWindows PLUGIN
PlatformWindows.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbHost
+ lldbTarget
)
diff --git a/source/Plugins/Platform/Windows/PlatformWindows.cpp b/source/Plugins/Platform/Windows/PlatformWindows.cpp
index 290d8eab792f..f57842ee6e51 100644
--- a/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ b/source/Plugins/Platform/Windows/PlatformWindows.cpp
@@ -22,12 +22,12 @@
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/BreakpointSite.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/Error.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/Platform/gdb-server/CMakeLists.txt b/source/Plugins/Platform/gdb-server/CMakeLists.txt
index b0b669e5b8b7..2e3302590b44 100644
--- a/source/Plugins/Platform/gdb-server/CMakeLists.txt
+++ b/source/Plugins/Platform/gdb-server/CMakeLists.txt
@@ -1,3 +1,10 @@
-add_lldb_library(lldbPluginPlatformGDB
+add_lldb_library(lldbPluginPlatformGDB PLUGIN
PlatformRemoteGDBServer.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbHost
+ lldbTarget
+ lldbPluginProcessUtility
)
diff --git a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index 43f7a53d0f7c..218c62860114 100644
--- a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -15,23 +15,21 @@
// Project includes
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
-#include "lldb/Host/StringConvert.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
-
-#include "Utility/UriParser.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/UriParser.h"
#include "Plugins/Process/Utility/GDBRemoteSignals.h"
diff --git a/source/Plugins/Process/CMakeLists.txt b/source/Plugins/Process/CMakeLists.txt
index defa493088b6..62abd75a43b6 100644
--- a/source/Plugins/Process/CMakeLists.txt
+++ b/source/Plugins/Process/CMakeLists.txt
@@ -1,18 +1,19 @@
-if (CMAKE_SYSTEM_NAME MATCHES "Linux")
+if (CMAKE_SYSTEM_NAME MATCHES "Linux|Android")
add_subdirectory(Linux)
add_subdirectory(POSIX)
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_subdirectory(FreeBSD)
add_subdirectory(POSIX)
elseif (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
+ add_subdirectory(NetBSD)
add_subdirectory(POSIX)
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
add_subdirectory(Windows/Common)
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_subdirectory(MacOSX-Kernel)
+ add_subdirectory(mach-core)
endif()
add_subdirectory(gdb-remote)
add_subdirectory(Utility)
-add_subdirectory(mach-core)
add_subdirectory(elf-core)
add_subdirectory(minidump)
diff --git a/source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp b/source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp
index 63b1ae6da968..feb7a11584f8 100644
--- a/source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp
+++ b/source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp
@@ -30,11 +30,11 @@
// LLDB includes
#include "lldb/lldb-enumerations.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/StreamString.h"
+#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Target/ProcessLaunchInfo.h"
-#include "lldb/Utility/PseudoTerminal.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
#include "CFBundle.h"
#include "CFString.h"
diff --git a/source/Plugins/Process/Darwin/MachException.cpp b/source/Plugins/Process/Darwin/MachException.cpp
index 81706441494a..5a97a4b01be3 100644
--- a/source/Plugins/Process/Darwin/MachException.cpp
+++ b/source/Plugins/Process/Darwin/MachException.cpp
@@ -22,11 +22,11 @@
#include <mutex>
// LLDB includes
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Target/UnixSignals.h"
+#include "lldb/Utility/Error.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp b/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp
index e56375ebaa49..65ab12fe1adf 100644
--- a/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp
+++ b/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp
@@ -19,11 +19,11 @@
// C++ includes
// LLDB includes
-#include "lldb/Core/Log.h"
#include "lldb/Core/State.h"
-#include "lldb/Core/StreamString.h"
+#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Target/ProcessLaunchInfo.h"
-#include "lldb/Utility/PseudoTerminal.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
#include "CFBundle.h"
#include "CFString.h"
@@ -31,6 +31,8 @@
#include "MachException.h"
+#include "llvm/Support/FileSystem.h"
+
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::process_darwin;
@@ -63,7 +65,7 @@ Error NativeProcessProtocol::Launch(
FileSpec working_dir(launch_info.GetWorkingDirectory());
if (working_dir &&
(!working_dir.ResolvePath() ||
- working_dir.GetFileType() != FileSpec::eFileTypeDirectory)) {
+ !llvm::sys::fs::is_directory(working_dir.GetPath())) {
error.SetErrorStringWithFormat("No such file or directory: %s",
working_dir.GetCString());
return error;
diff --git a/source/Plugins/Process/Darwin/NativeProcessDarwin.h b/source/Plugins/Process/Darwin/NativeProcessDarwin.h
index 69c1b8d9e4cc..01fdd64b1273 100644
--- a/source/Plugins/Process/Darwin/NativeProcessDarwin.h
+++ b/source/Plugins/Process/Darwin/NativeProcessDarwin.h
@@ -24,11 +24,11 @@
// Other libraries and framework includes
#include "lldb/Core/ArchSpec.h"
#include "lldb/Host/Debug.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Host/Pipe.h"
#include "lldb/Host/common/NativeProcessProtocol.h"
#include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Utility/FileSpec.h"
#include "lldb/lldb-types.h"
#include "LaunchFlavor.h"
diff --git a/source/Plugins/Process/Darwin/NativeThreadDarwin.cpp b/source/Plugins/Process/Darwin/NativeThreadDarwin.cpp
index 5e7f9ae7e6f9..b04f9053136b 100644
--- a/source/Plugins/Process/Darwin/NativeThreadDarwin.cpp
+++ b/source/Plugins/Process/Darwin/NativeThreadDarwin.cpp
@@ -13,7 +13,7 @@
#include <libproc.h>
// LLDB includes
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/Stream.h"
#include "NativeProcessDarwin.h"
diff --git a/source/Plugins/Process/Darwin/NativeThreadListDarwin.cpp b/source/Plugins/Process/Darwin/NativeThreadListDarwin.cpp
index aa9b04157658..fa06fb8b2a5f 100644
--- a/source/Plugins/Process/Darwin/NativeThreadListDarwin.cpp
+++ b/source/Plugins/Process/Darwin/NativeThreadListDarwin.cpp
@@ -20,9 +20,9 @@
#include <sys/sysctl.h>
// LLDB includes
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
#include "lldb/lldb-enumerations.h"
#include "NativeProcessDarwin.h"
diff --git a/source/Plugins/Process/FreeBSD/CMakeLists.txt b/source/Plugins/Process/FreeBSD/CMakeLists.txt
index c0e3374fef89..63855992d708 100644
--- a/source/Plugins/Process/FreeBSD/CMakeLists.txt
+++ b/source/Plugins/Process/FreeBSD/CMakeLists.txt
@@ -2,7 +2,7 @@ include_directories(.)
include_directories(../POSIX)
include_directories(../Utility)
-add_lldb_library(lldbPluginProcessFreeBSD
+add_lldb_library(lldbPluginProcessFreeBSD PLUGIN
ProcessFreeBSD.cpp
FreeBSDThread.cpp
ProcessMonitor.cpp
@@ -13,4 +13,16 @@ add_lldb_library(lldbPluginProcessFreeBSD
RegisterContextPOSIXProcessMonitor_powerpc.cpp
RegisterContextPOSIXProcessMonitor_x86.cpp
RegisterContextPOSIXProcessMonitor_mips64.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbHost
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ lldbPluginProcessUtility
+ lldbPluginProcessPOSIX
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp b/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp
index 0b09296cb7fd..bd8e5abe2255 100644
--- a/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp
+++ b/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp
@@ -9,6 +9,12 @@
// C Includes
#include <errno.h>
+#include <pthread.h>
+#include <pthread_np.h>
+#include <stdlib.h>
+#include <sys/sysctl.h>
+#include <sys/types.h>
+#include <sys/user.h>
// C++ Includes
// Other libraries and framework includes
@@ -18,16 +24,16 @@
// Project includes
#include "FreeBSDThread.h"
#include "POSIXStopInfo.h"
-#include "Plugins/Process/Utility/RegisterContextFreeBSD_arm.h"
+#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
#include "Plugins/Process/Utility/RegisterContextFreeBSD_i386.h"
#include "Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h"
#include "Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h"
#include "Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h"
+#include "Plugins/Process/Utility/RegisterInfoPOSIX_arm.h"
#include "Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h"
#include "Plugins/Process/Utility/UnwindLLDB.h"
#include "ProcessFreeBSD.h"
#include "ProcessMonitor.h"
-#include "ProcessPOSIXLog.h"
#include "RegisterContextPOSIXProcessMonitor_arm.h"
#include "RegisterContextPOSIXProcessMonitor_arm64.h"
#include "RegisterContextPOSIXProcessMonitor_mips64.h"
@@ -53,8 +59,7 @@ FreeBSDThread::FreeBSDThread(Process &process, lldb::tid_t tid)
: Thread(process, tid), m_frame_ap(), m_breakpoint(),
m_thread_name_valid(false), m_thread_name(), m_posix_thread(NULL) {
Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD));
- if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
- log->Printf("FreeBSDThread::%s (tid = %" PRIi64 ")", __FUNCTION__, tid);
+ LLDB_LOGV(log, "tid = {0}", tid);
// Set the current watchpoints for this thread.
Target &target = GetProcess()->GetTarget();
@@ -114,9 +119,41 @@ void FreeBSDThread::SetName(const char *name) {
const char *FreeBSDThread::GetName() {
if (!m_thread_name_valid) {
- llvm::SmallString<32> thread_name;
- HostNativeThread::GetName(GetID(), thread_name);
- m_thread_name = thread_name.c_str();
+ m_thread_name.clear();
+ int pid = GetProcess()->GetID();
+
+ struct kinfo_proc *kp = nullptr, *nkp;
+ size_t len = 0;
+ int error;
+ int ctl[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID | KERN_PROC_INC_THREAD,
+ pid};
+
+ while (1) {
+ error = sysctl(ctl, 4, kp, &len, nullptr, 0);
+ if (kp == nullptr || (error != 0 && errno == ENOMEM)) {
+ // Add extra space in case threads are added before next call.
+ len += sizeof(*kp) + len / 10;
+ nkp = (struct kinfo_proc *)realloc(kp, len);
+ if (nkp == nullptr) {
+ free(kp);
+ return nullptr;
+ }
+ kp = nkp;
+ continue;
+ }
+ if (error != 0)
+ len = 0;
+ break;
+ }
+
+ for (size_t i = 0; i < len / sizeof(*kp); i++) {
+ if (kp[i].ki_tid == (lwpid_t)GetID()) {
+ m_thread_name.append(kp[i].ki_tdname,
+ kp[i].ki_tdname + strlen(kp[i].ki_tdname));
+ break;
+ }
+ }
+ free(kp);
m_thread_name_valid = true;
}
@@ -138,7 +175,7 @@ lldb::RegisterContextSP FreeBSDThread::GetRegisterContext() {
reg_interface = new RegisterInfoPOSIX_arm64(target_arch);
break;
case llvm::Triple::arm:
- reg_interface = new RegisterContextFreeBSD_arm(target_arch);
+ reg_interface = new RegisterInfoPOSIX_arm(target_arch);
break;
case llvm::Triple::ppc:
#ifndef __powerpc64__
@@ -215,8 +252,7 @@ FreeBSDThread::CreateRegisterContextForFrame(lldb_private::StackFrame *frame) {
uint32_t concrete_frame_idx = 0;
Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD));
- if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
- log->Printf("FreeBSDThread::%s ()", __FUNCTION__);
+ LLDB_LOGV(log, "called");
if (frame)
concrete_frame_idx = frame->GetConcreteFrameIndex();
diff --git a/source/Plugins/Process/FreeBSD/POSIXStopInfo.h b/source/Plugins/Process/FreeBSD/POSIXStopInfo.h
index 1ee16dd5f8f4..e51fc08d74cc 100644
--- a/source/Plugins/Process/FreeBSD/POSIXStopInfo.h
+++ b/source/Plugins/Process/FreeBSD/POSIXStopInfo.h
@@ -10,15 +10,9 @@
#ifndef liblldb_POSIXStopInfo_H_
#define liblldb_POSIXStopInfo_H_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
-// Project includes
-#include "lldb/Target/StopInfo.h"
-
-#include "CrashReason.h"
#include "FreeBSDThread.h"
-
+#include "Plugins/Process/POSIX/CrashReason.h"
+#include "lldb/Target/StopInfo.h"
#include <string>
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
index 82e45a5d5fc1..93d294fd040a 100644
--- a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
+++ b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
@@ -10,12 +10,21 @@
// C Includes
#include <errno.h>
+#include <pthread.h>
+#include <pthread_np.h>
+#include <stdlib.h>
+#include <sys/sysctl.h>
+#include <sys/types.h>
+#include <sys/user.h>
+#include <machine/elf.h>
// C++ Includes
#include <mutex>
+#include <unordered_map>
// Other libraries and framework includes
#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/State.h"
#include "lldb/Host/Host.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -23,11 +32,11 @@
#include "lldb/Target/Target.h"
#include "FreeBSDThread.h"
+#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
#include "Plugins/Process/Utility/FreeBSDSignals.h"
#include "Plugins/Process/Utility/InferiorCallPOSIX.h"
#include "ProcessFreeBSD.h"
#include "ProcessMonitor.h"
-#include "ProcessPOSIXLog.h"
// Other libraries and framework includes
#include "lldb/Breakpoint/BreakpointLocation.h"
@@ -36,15 +45,19 @@
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/State.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/FileSpec.h"
#include "lldb/Host/posix/Fcntl.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Threading.h"
+
using namespace lldb;
using namespace lldb_private;
@@ -70,12 +83,11 @@ ProcessFreeBSD::CreateInstance(lldb::TargetSP target_sp,
}
void ProcessFreeBSD::Initialize() {
- static std::once_flag g_once_flag;
+ static llvm::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
+ llvm::call_once(g_once_flag, []() {
PluginManager::RegisterPlugin(GetPluginNameStatic(),
GetPluginDescriptionStatic(), CreateInstance);
- ProcessPOSIXLog::Initialize(GetPluginNameStatic());
});
}
@@ -122,6 +134,7 @@ Error ProcessFreeBSD::DoResume() {
std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex());
bool do_step = false;
+ bool software_single_step = !SupportHardwareSingleStepping();
for (tid_collection::const_iterator t_pos = m_run_tids.begin(),
t_end = m_run_tids.end();
@@ -133,6 +146,11 @@ Error ProcessFreeBSD::DoResume() {
t_pos != t_end; ++t_pos) {
m_monitor->ThreadSuspend(*t_pos, false);
do_step = true;
+ if (software_single_step) {
+ Error error = SetupSoftwareSingleStepping(*t_pos);
+ if (error.Fail())
+ return error;
+ }
}
for (tid_collection::const_iterator t_pos = m_suspend_tids.begin(),
t_end = m_suspend_tids.end();
@@ -145,7 +163,7 @@ Error ProcessFreeBSD::DoResume() {
if (log)
log->Printf("process %" PRIu64 " resuming (%s)", GetID(),
do_step ? "step" : "continue");
- if (do_step)
+ if (do_step && !software_single_step)
m_monitor->SingleStep(GetID(), m_resume_signo);
else
m_monitor->Resume(GetID(), m_resume_signo);
@@ -281,8 +299,7 @@ Error ProcessFreeBSD::DoAttachToProcessWithID(
assert(m_monitor == NULL);
Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
- if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
- log->Printf("ProcessFreeBSD::%s(pid = %" PRIi64 ")", __FUNCTION__, GetID());
+ LLDB_LOGV(log, "pid = {0}", GetID());
m_monitor = new ProcessMonitor(this, pid, error);
@@ -354,9 +371,9 @@ Error ProcessFreeBSD::DoLaunch(Module *module, ProcessLaunchInfo &launch_info) {
assert(m_monitor == NULL);
FileSpec working_dir = launch_info.GetWorkingDirectory();
- if (working_dir &&
- (!working_dir.ResolvePath() ||
- working_dir.GetFileType() != FileSpec::eFileTypeDirectory)) {
+ namespace fs = llvm::sys::fs;
+ if (working_dir && (!working_dir.ResolvePath() ||
+ !fs::is_directory(working_dir.GetPath()))) {
error.SetErrorStringWithFormat("No such file or directory: %s",
working_dir.GetCString());
return error;
@@ -528,9 +545,7 @@ ProcessFreeBSD::CreateNewFreeBSDThread(lldb_private::Process &process,
void ProcessFreeBSD::RefreshStateAfterStop() {
Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
- if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
- log->Printf("ProcessFreeBSD::%s(), message_queue size = %d", __FUNCTION__,
- (int)m_message_queue.size());
+ LLDB_LOGV(log, "message_queue size = {0}", m_message_queue.size());
std::lock_guard<std::recursive_mutex> guard(m_message_mutex);
@@ -542,10 +557,8 @@ void ProcessFreeBSD::RefreshStateAfterStop() {
// Resolve the thread this message corresponds to and pass it along.
lldb::tid_t tid = message.GetTID();
- if (log)
- log->Printf(
- "ProcessFreeBSD::%s(), message_queue size = %d, pid = %" PRIi64,
- __FUNCTION__, (int)m_message_queue.size(), tid);
+ LLDB_LOGV(log, " message_queue size = {0}, pid = {1}",
+ m_message_queue.size(), tid);
m_thread_list.RefreshStateAfterStop();
@@ -557,10 +570,7 @@ void ProcessFreeBSD::RefreshStateAfterStop() {
if (message.GetKind() == ProcessMessage::eExitMessage) {
// FIXME: We should tell the user about this, but the limbo message is
// probably better for that.
- if (log)
- log->Printf("ProcessFreeBSD::%s() removing thread, tid = %" PRIi64,
- __FUNCTION__, tid);
-
+ LLDB_LOG(log, "removing thread, tid = {0}", tid);
std::lock_guard<std::recursive_mutex> guard(m_thread_list.GetMutex());
ThreadSP thread_sp = m_thread_list.RemoveThreadByID(tid, false);
@@ -903,13 +913,207 @@ bool ProcessFreeBSD::IsAThreadRunning() {
const DataBufferSP ProcessFreeBSD::GetAuxvData() {
// If we're the local platform, we can ask the host for auxv data.
PlatformSP platform_sp = GetTarget().GetPlatform();
- if (platform_sp && platform_sp->IsHost())
- return lldb_private::Host::GetAuxvData(this);
+ assert(platform_sp && platform_sp->IsHost());
+
+ int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_AUXV, (int)m_process->GetID()};
+ size_t auxv_size = AT_COUNT * sizeof(Elf_Auxinfo);
+ DataBufferSP buf_sp(new DataBufferHeap(auxv_size, 0));
+
+ if (::sysctl(mib, 4, buf_sp->GetBytes(), &auxv_size, NULL, 0) != 0) {
+ perror("sysctl failed on auxv");
+ buf_sp.reset();
+ }
+
+ return buf_sp;
+}
+
+struct EmulatorBaton {
+ ProcessFreeBSD *m_process;
+ RegisterContext *m_reg_context;
+
+ // eRegisterKindDWARF -> RegisterValue
+ std::unordered_map<uint32_t, RegisterValue> m_register_values;
+
+ EmulatorBaton(ProcessFreeBSD *process, RegisterContext *reg_context)
+ : m_process(process), m_reg_context(reg_context) {}
+};
+
+static size_t ReadMemoryCallback(EmulateInstruction *instruction, void *baton,
+ const EmulateInstruction::Context &context,
+ lldb::addr_t addr, void *dst, size_t length) {
+ EmulatorBaton *emulator_baton = static_cast<EmulatorBaton *>(baton);
+
+ Error error;
+ size_t bytes_read =
+ emulator_baton->m_process->DoReadMemory(addr, dst, length, error);
+ if (!error.Success())
+ bytes_read = 0;
+ return bytes_read;
+}
- // Somewhat unexpected - the process is not running locally or we don't have a
- // platform.
- assert(
- false &&
- "no platform or not the host - how did we get here with ProcessFreeBSD?");
- return DataBufferSP();
+static bool ReadRegisterCallback(EmulateInstruction *instruction, void *baton,
+ const RegisterInfo *reg_info,
+ RegisterValue &reg_value) {
+ EmulatorBaton *emulator_baton = static_cast<EmulatorBaton *>(baton);
+
+ auto it = emulator_baton->m_register_values.find(
+ reg_info->kinds[eRegisterKindDWARF]);
+ if (it != emulator_baton->m_register_values.end()) {
+ reg_value = it->second;
+ return true;
+ }
+
+ // The emulator only fills in the dwarf register numbers (and in some cases
+ // the generic register numbers). Get the full register info from the
+ // register context based on the dwarf register numbers.
+ const RegisterInfo *full_reg_info =
+ emulator_baton->m_reg_context->GetRegisterInfo(
+ eRegisterKindDWARF, reg_info->kinds[eRegisterKindDWARF]);
+
+ bool error =
+ emulator_baton->m_reg_context->ReadRegister(full_reg_info, reg_value);
+ return error;
+}
+
+static bool WriteRegisterCallback(EmulateInstruction *instruction, void *baton,
+ const EmulateInstruction::Context &context,
+ const RegisterInfo *reg_info,
+ const RegisterValue &reg_value) {
+ EmulatorBaton *emulator_baton = static_cast<EmulatorBaton *>(baton);
+ emulator_baton->m_register_values[reg_info->kinds[eRegisterKindDWARF]] =
+ reg_value;
+ return true;
+}
+
+static size_t WriteMemoryCallback(EmulateInstruction *instruction, void *baton,
+ const EmulateInstruction::Context &context,
+ lldb::addr_t addr, const void *dst,
+ size_t length) {
+ return length;
+}
+
+bool ProcessFreeBSD::SingleStepBreakpointHit(
+ void *baton, lldb_private::StoppointCallbackContext *context,
+ lldb::user_id_t break_id, lldb::user_id_t break_loc_id) {
+ return false;
+}
+
+Error ProcessFreeBSD::SetSoftwareSingleStepBreakpoint(lldb::tid_t tid,
+ lldb::addr_t addr) {
+ Error error;
+
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+ if (log) {
+ log->Printf("ProcessFreeBSD::%s addr = 0x%" PRIx64, __FUNCTION__, addr);
+ log->Printf("SoftwareBreakpoint::%s addr = 0x%" PRIx64, __FUNCTION__, addr);
+ }
+
+ // Validate the address.
+ if (addr == LLDB_INVALID_ADDRESS)
+ return Error("ProcessFreeBSD::%s invalid load address specified.",
+ __FUNCTION__);
+
+ Breakpoint *const sw_step_break =
+ m_process->GetTarget().CreateBreakpoint(addr, true, false).get();
+ sw_step_break->SetCallback(SingleStepBreakpointHit, this, true);
+ sw_step_break->SetBreakpointKind("software-signle-step");
+
+ if (log)
+ log->Printf("ProcessFreeBSD::%s addr = 0x%" PRIx64 " -- SUCCESS",
+ __FUNCTION__, addr);
+
+ m_threads_stepping_with_breakpoint.insert({tid, sw_step_break->GetID()});
+ return Error();
+}
+
+bool ProcessFreeBSD::IsSoftwareStepBreakpoint(lldb::tid_t tid) {
+ ThreadSP thread = GetThreadList().FindThreadByID(tid);
+ if (!thread)
+ return false;
+
+ assert(thread->GetRegisterContext());
+ lldb::addr_t stop_pc = thread->GetRegisterContext()->GetPC();
+
+ const auto &iter = m_threads_stepping_with_breakpoint.find(tid);
+ if (iter == m_threads_stepping_with_breakpoint.end())
+ return false;
+
+ lldb::break_id_t bp_id = iter->second;
+ BreakpointSP bp = GetTarget().GetBreakpointByID(bp_id);
+ if (!bp)
+ return false;
+
+ BreakpointLocationSP bp_loc = bp->FindLocationByAddress(stop_pc);
+ if (!bp_loc)
+ return false;
+
+ GetTarget().RemoveBreakpointByID(bp_id);
+ m_threads_stepping_with_breakpoint.erase(tid);
+ return true;
+}
+
+bool ProcessFreeBSD::SupportHardwareSingleStepping() const {
+ lldb_private::ArchSpec arch = GetTarget().GetArchitecture();
+ if (arch.GetMachine() == llvm::Triple::arm ||
+ arch.GetMachine() == llvm::Triple::mips64 ||
+ arch.GetMachine() == llvm::Triple::mips64el ||
+ arch.GetMachine() == llvm::Triple::mips ||
+ arch.GetMachine() == llvm::Triple::mipsel)
+ return false;
+ return true;
+}
+
+Error ProcessFreeBSD::SetupSoftwareSingleStepping(lldb::tid_t tid) {
+ std::unique_ptr<EmulateInstruction> emulator_ap(
+ EmulateInstruction::FindPlugin(GetTarget().GetArchitecture(),
+ eInstructionTypePCModifying, nullptr));
+
+ if (emulator_ap == nullptr)
+ return Error("Instruction emulator not found!");
+
+ FreeBSDThread *thread = static_cast<FreeBSDThread *>(
+ m_thread_list.FindThreadByID(tid, false).get());
+ if (thread == NULL)
+ return Error("Thread not found not found!");
+
+ lldb::RegisterContextSP register_context_sp = thread->GetRegisterContext();
+
+ EmulatorBaton baton(this, register_context_sp.get());
+ emulator_ap->SetBaton(&baton);
+ emulator_ap->SetReadMemCallback(&ReadMemoryCallback);
+ emulator_ap->SetReadRegCallback(&ReadRegisterCallback);
+ emulator_ap->SetWriteMemCallback(&WriteMemoryCallback);
+ emulator_ap->SetWriteRegCallback(&WriteRegisterCallback);
+
+ if (!emulator_ap->ReadInstruction())
+ return Error("Read instruction failed!");
+
+ bool emulation_result =
+ emulator_ap->EvaluateInstruction(eEmulateInstructionOptionAutoAdvancePC);
+ const RegisterInfo *reg_info_pc = register_context_sp->GetRegisterInfo(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
+ auto pc_it =
+ baton.m_register_values.find(reg_info_pc->kinds[eRegisterKindDWARF]);
+
+ lldb::addr_t next_pc;
+ if (emulation_result) {
+ assert(pc_it != baton.m_register_values.end() &&
+ "Emulation was successful but PC wasn't updated");
+ next_pc = pc_it->second.GetAsUInt64();
+ } else if (pc_it == baton.m_register_values.end()) {
+ // Emulate instruction failed and it haven't changed PC. Advance PC
+ // with the size of the current opcode because the emulation of all
+ // PC modifying instruction should be successful. The failure most
+ // likely caused by a not supported instruction which don't modify PC.
+ next_pc =
+ register_context_sp->GetPC() + emulator_ap->GetOpcode().GetByteSize();
+ } else {
+ // The instruction emulation failed after it modified the PC. It is an
+ // unknown error where we can't continue because the next instruction is
+ // modifying the PC but we don't know how.
+ return Error("Instruction emulation failed unexpectedly");
+ }
+
+ SetSoftwareSingleStepBreakpoint(tid, next_pc);
+ return Error();
}
diff --git a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
index cd38989f973c..063eb6f68123 100644
--- a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
+++ b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
@@ -11,19 +11,13 @@
#ifndef liblldb_ProcessFreeBSD_H_
#define liblldb_ProcessFreeBSD_H_
-// C Includes
-
-// C++ Includes
+#include "Plugins/Process/POSIX/ProcessMessage.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/ThreadList.h"
#include <mutex>
#include <queue>
#include <set>
-// Other libraries and framework includes
-#include "ProcessFreeBSD.h"
-#include "ProcessMessage.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Target/ThreadList.h"
-
class ProcessMonitor;
class FreeBSDThread;
@@ -171,7 +165,25 @@ public:
virtual FreeBSDThread *CreateNewFreeBSDThread(lldb_private::Process &process,
lldb::tid_t tid);
+ static bool SingleStepBreakpointHit(
+ void *baton, lldb_private::StoppointCallbackContext *context,
+ lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
+
+ lldb_private::Error SetupSoftwareSingleStepping(lldb::tid_t tid);
+
+ lldb_private::Error SetSoftwareSingleStepBreakpoint(lldb::tid_t tid,
+ lldb::addr_t addr);
+
+ bool IsSoftwareStepBreakpoint(lldb::tid_t tid);
+
+ bool SupportHardwareSingleStepping() const;
+
+ typedef std::vector<lldb::tid_t> tid_collection;
+ tid_collection &GetStepTids() { return m_step_tids; }
+
protected:
+ static const size_t MAX_TRAP_OPCODE_SIZE = 8;
+
/// Target byte order.
lldb::ByteOrder m_byte_order;
@@ -207,10 +219,10 @@ protected:
friend class FreeBSDThread;
- typedef std::vector<lldb::tid_t> tid_collection;
tid_collection m_suspend_tids;
tid_collection m_run_tids;
tid_collection m_step_tids;
+ std::map<lldb::tid_t, lldb::break_id_t> m_threads_stepping_with_breakpoint;
int m_resume_signo;
};
diff --git a/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp b/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
index afc649de3b65..68ab41651162 100644
--- a/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
+++ b/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
@@ -21,21 +21,21 @@
// C++ Includes
// Other libraries and framework includes
-#include "lldb/Core/Error.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Host/Host.h"
+#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/UnixSignals.h"
-#include "lldb/Utility/PseudoTerminal.h"
+#include "lldb/Utility/Error.h"
#include "FreeBSDThread.h"
#include "Plugins/Process/POSIX/CrashReason.h"
+#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
#include "ProcessFreeBSD.h"
#include "ProcessMonitor.h"
-#include "ProcessPOSIXLog.h"
extern "C" {
extern char **environ;
@@ -1141,11 +1141,19 @@ ProcessMessage ProcessMonitor::MonitorSIGTRAP(ProcessMonitor *monitor,
case SI_KERNEL:
case TRAP_BRKPT:
- if (log)
- log->Printf(
- "ProcessMonitor::%s() received breakpoint event, tid = %" PRIu64,
- __FUNCTION__, tid);
- message = ProcessMessage::Break(tid);
+ if (monitor->m_process->IsSoftwareStepBreakpoint(tid)) {
+ if (log)
+ log->Printf("ProcessMonitor::%s() received sw single step breakpoint "
+ "event, tid = %" PRIu64,
+ __FUNCTION__, tid);
+ message = ProcessMessage::Trace(tid);
+ } else {
+ if (log)
+ log->Printf(
+ "ProcessMonitor::%s() received breakpoint event, tid = %" PRIu64,
+ __FUNCTION__, tid);
+ message = ProcessMessage::Break(tid);
+ }
break;
}
diff --git a/source/Plugins/Process/FreeBSD/ProcessMonitor.h b/source/Plugins/Process/FreeBSD/ProcessMonitor.h
index 4c2594e9da6a..58629189b7b8 100644
--- a/source/Plugins/Process/FreeBSD/ProcessMonitor.h
+++ b/source/Plugins/Process/FreeBSD/ProcessMonitor.h
@@ -18,8 +18,8 @@
#include <mutex>
// Other libraries and framework includes
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/HostThread.h"
+#include "lldb/Utility/FileSpec.h"
#include "lldb/lldb-types.h"
namespace lldb_private {
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp
index f8d5f2edd3a3..14171d614c9e 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp
@@ -7,9 +7,9 @@
//
//===---------------------------------------------------------------------===//
-#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
#include "ProcessFreeBSD.h"
#include "ProcessMonitor.h"
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp
index 98a213a370fe..8a8eb0520cca 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp
@@ -7,9 +7,9 @@
//
//===---------------------------------------------------------------------===//
-#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
#include "Plugins/Process/Utility/RegisterContextPOSIX_arm64.h"
#include "ProcessFreeBSD.h"
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp
index 020636eb0a6b..ab50a5db3f3e 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp
@@ -7,9 +7,9 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
#include "Plugins/Process/Utility/RegisterContextPOSIX_mips64.h"
#include "ProcessFreeBSD.h"
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h
index 2f75e6058fbc..6f57b0d9cd65 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h
@@ -11,6 +11,7 @@
#define liblldb_RegisterContextPOSIXProcessMonitor_mips64_H_
#include "Plugins/Process/Utility/RegisterContextPOSIX_mips64.h"
+#include "Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h"
#include "RegisterContextPOSIX.h"
class RegisterContextPOSIXProcessMonitor_mips64
@@ -72,6 +73,8 @@ protected:
uint32_t NumSupportedHardwareWatchpoints();
private:
+ uint64_t
+ m_gpr_mips64[k_num_gpr_registers_mips64]; // general purpose registers.
ProcessMonitor &GetMonitor();
};
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp
index e7b01fa8634a..70eec945ce8d 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp
@@ -7,9 +7,9 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
#include "ProcessFreeBSD.h"
#include "ProcessMonitor.h"
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp
index 976b190b2355..036306058ff8 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp
@@ -7,9 +7,9 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
#include "Plugins/Process/FreeBSD/ProcessFreeBSD.h"
#include "Plugins/Process/FreeBSD/ProcessMonitor.h"
diff --git a/source/Plugins/Process/Linux/CMakeLists.txt b/source/Plugins/Process/Linux/CMakeLists.txt
index 8291fef467e3..8a46d730caff 100644
--- a/source/Plugins/Process/Linux/CMakeLists.txt
+++ b/source/Plugins/Process/Linux/CMakeLists.txt
@@ -2,7 +2,7 @@ include_directories(.)
include_directories(../POSIX)
include_directories(../Utility)
-add_lldb_library(lldbPluginProcessLinux
+add_lldb_library(lldbPluginProcessLinux PLUGIN
NativeProcessLinux.cpp
NativeRegisterContextLinux.cpp
NativeRegisterContextLinux_arm.cpp
@@ -11,6 +11,16 @@ add_lldb_library(lldbPluginProcessLinux
NativeRegisterContextLinux_mips64.cpp
NativeRegisterContextLinux_s390x.cpp
NativeThreadLinux.cpp
- ProcFileReader.cpp
SingleStepCheck.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ lldbPluginProcessPOSIX
+ lldbPluginProcessUtility
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index fb84729dd5f4..914d690ad88c 100644
--- a/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -24,43 +24,40 @@
// Other libraries and framework includes
#include "lldb/Core/EmulateInstruction.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/State.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostProcess.h"
+#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Host/common/NativeBreakpoint.h"
#include "lldb/Host/common/NativeRegisterContext.h"
-#include "lldb/Host/linux/ProcessLauncherLinux.h"
+#include "lldb/Host/linux/Ptrace.h"
+#include "lldb/Host/linux/Uio.h"
+#include "lldb/Host/posix/ProcessLauncherPosixFork.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/ProcessLaunchInfo.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/Error.h"
#include "lldb/Utility/LLDBAssert.h"
-#include "lldb/Utility/PseudoTerminal.h"
#include "lldb/Utility/StringExtractor.h"
#include "NativeThreadLinux.h"
#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
-#include "ProcFileReader.h"
#include "Procfs.h"
-// System includes - They have to be included after framework includes because
-// they define some
-// macros which collide with variable names in other modules
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Threading.h"
+
#include <linux/unistd.h>
#include <sys/socket.h>
-
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/user.h>
#include <sys/wait.h>
-#include "lldb/Host/linux/Ptrace.h"
-#include "lldb/Host/linux/Uio.h"
-
// Support hardware breakpoints in case it has not been defined
#ifndef TRAP_HWBKPT
#define TRAP_HWBKPT 4
@@ -75,10 +72,10 @@ using namespace llvm;
static bool ProcessVmReadvSupported() {
static bool is_supported;
- static std::once_flag flag;
+ static llvm::once_flag flag;
- std::call_once(flag, [] {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+ llvm::call_once(flag, [] {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
uint32_t source = 0x47424742;
uint32_t dest = 0;
@@ -92,16 +89,15 @@ static bool ProcessVmReadvSupported() {
// value from our own process.
ssize_t res = process_vm_readv(getpid(), &local, 1, &remote, 1, 0);
is_supported = (res == sizeof(source) && source == dest);
- if (log) {
- if (is_supported)
- log->Printf("%s: Detected kernel support for process_vm_readv syscall. "
- "Fast memory reads enabled.",
- __FUNCTION__);
- else
- log->Printf("%s: syscall process_vm_readv failed (error: %s). Fast "
- "memory reads disabled.",
- __FUNCTION__, strerror(errno));
- }
+ if (is_supported)
+ LLDB_LOG(log,
+ "Detected kernel support for process_vm_readv syscall. "
+ "Fast memory reads enabled.");
+ else
+ LLDB_LOG(log,
+ "syscall process_vm_readv failed (error: {0}). Fast memory "
+ "reads disabled.",
+ strerror(errno));
});
return is_supported;
@@ -109,33 +105,29 @@ static bool ProcessVmReadvSupported() {
namespace {
void MaybeLogLaunchInfo(const ProcessLaunchInfo &info) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
if (!log)
return;
if (const FileAction *action = info.GetFileActionForFD(STDIN_FILENO))
- log->Printf("%s: setting STDIN to '%s'", __FUNCTION__,
- action->GetFileSpec().GetCString());
+ LLDB_LOG(log, "setting STDIN to '{0}'", action->GetFileSpec());
else
- log->Printf("%s leaving STDIN as is", __FUNCTION__);
+ LLDB_LOG(log, "leaving STDIN as is");
if (const FileAction *action = info.GetFileActionForFD(STDOUT_FILENO))
- log->Printf("%s setting STDOUT to '%s'", __FUNCTION__,
- action->GetFileSpec().GetCString());
+ LLDB_LOG(log, "setting STDOUT to '{0}'", action->GetFileSpec());
else
- log->Printf("%s leaving STDOUT as is", __FUNCTION__);
+ LLDB_LOG(log, "leaving STDOUT as is");
if (const FileAction *action = info.GetFileActionForFD(STDERR_FILENO))
- log->Printf("%s setting STDERR to '%s'", __FUNCTION__,
- action->GetFileSpec().GetCString());
+ LLDB_LOG(log, "setting STDERR to '{0}'", action->GetFileSpec());
else
- log->Printf("%s leaving STDERR as is", __FUNCTION__);
+ LLDB_LOG(log, "leaving STDERR as is");
int i = 0;
for (const char **args = info.GetArguments().GetConstArgumentVector(); *args;
++args, ++i)
- log->Printf("%s arg %d: \"%s\"", __FUNCTION__, i,
- *args ? *args : "nullptr");
+ LLDB_LOG(log, "arg {0}: '{1}'", i, *args);
}
void DisplayBytes(StreamString &s, void *bytes, uint32_t count) {
@@ -148,50 +140,49 @@ void DisplayBytes(StreamString &s, void *bytes, uint32_t count) {
}
void PtraceDisplayBytes(int &req, void *data, size_t data_size) {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE));
+ if (!log)
+ return;
StreamString buf;
- Log *verbose_log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(
- POSIX_LOG_PTRACE | POSIX_LOG_VERBOSE));
- if (verbose_log) {
- switch (req) {
- case PTRACE_POKETEXT: {
- DisplayBytes(buf, &data, 8);
- verbose_log->Printf("PTRACE_POKETEXT %s", buf.GetData());
- break;
- }
- case PTRACE_POKEDATA: {
- DisplayBytes(buf, &data, 8);
- verbose_log->Printf("PTRACE_POKEDATA %s", buf.GetData());
- break;
- }
- case PTRACE_POKEUSER: {
- DisplayBytes(buf, &data, 8);
- verbose_log->Printf("PTRACE_POKEUSER %s", buf.GetData());
- break;
- }
- case PTRACE_SETREGS: {
- DisplayBytes(buf, data, data_size);
- verbose_log->Printf("PTRACE_SETREGS %s", buf.GetData());
- break;
- }
- case PTRACE_SETFPREGS: {
- DisplayBytes(buf, data, data_size);
- verbose_log->Printf("PTRACE_SETFPREGS %s", buf.GetData());
- break;
- }
- case PTRACE_SETSIGINFO: {
- DisplayBytes(buf, data, sizeof(siginfo_t));
- verbose_log->Printf("PTRACE_SETSIGINFO %s", buf.GetData());
- break;
- }
- case PTRACE_SETREGSET: {
- // Extract iov_base from data, which is a pointer to the struct IOVEC
- DisplayBytes(buf, *(void **)data, data_size);
- verbose_log->Printf("PTRACE_SETREGSET %s", buf.GetData());
- break;
- }
- default: {}
- }
+ switch (req) {
+ case PTRACE_POKETEXT: {
+ DisplayBytes(buf, &data, 8);
+ LLDB_LOGV(log, "PTRACE_POKETEXT {0}", buf.GetData());
+ break;
+ }
+ case PTRACE_POKEDATA: {
+ DisplayBytes(buf, &data, 8);
+ LLDB_LOGV(log, "PTRACE_POKEDATA {0}", buf.GetData());
+ break;
+ }
+ case PTRACE_POKEUSER: {
+ DisplayBytes(buf, &data, 8);
+ LLDB_LOGV(log, "PTRACE_POKEUSER {0}", buf.GetData());
+ break;
+ }
+ case PTRACE_SETREGS: {
+ DisplayBytes(buf, data, data_size);
+ LLDB_LOGV(log, "PTRACE_SETREGS {0}", buf.GetData());
+ break;
+ }
+ case PTRACE_SETFPREGS: {
+ DisplayBytes(buf, data, data_size);
+ LLDB_LOGV(log, "PTRACE_SETFPREGS {0}", buf.GetData());
+ break;
+ }
+ case PTRACE_SETSIGINFO: {
+ DisplayBytes(buf, data, sizeof(siginfo_t));
+ LLDB_LOGV(log, "PTRACE_SETSIGINFO {0}", buf.GetData());
+ break;
+ }
+ case PTRACE_SETREGSET: {
+ // Extract iov_base from data, which is a pointer to the struct IOVEC
+ DisplayBytes(buf, *(void **)data, data_size);
+ LLDB_LOGV(log, "PTRACE_SETREGSET {0}", buf.GetData());
+ break;
+ }
+ default: {}
}
}
@@ -227,15 +218,14 @@ Error NativeProcessProtocol::Launch(
ProcessLaunchInfo &launch_info,
NativeProcessProtocol::NativeDelegate &native_delegate, MainLoop &mainloop,
NativeProcessProtocolSP &native_process_sp) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
Error error;
// Verify the working directory is valid if one was specified.
FileSpec working_dir{launch_info.GetWorkingDirectory()};
- if (working_dir &&
- (!working_dir.ResolvePath() ||
- working_dir.GetFileType() != FileSpec::eFileTypeDirectory)) {
+ if (working_dir && (!working_dir.ResolvePath() ||
+ !llvm::sys::fs::is_directory(working_dir.GetPath()))) {
error.SetErrorStringWithFormat("No such file or directory: %s",
working_dir.GetCString());
return error;
@@ -255,9 +245,7 @@ Error NativeProcessProtocol::Launch(
if (error.Fail()) {
native_process_sp.reset();
- if (log)
- log->Printf("NativeProcessLinux::%s failed to launch process: %s",
- __FUNCTION__, error.AsCString());
+ LLDB_LOG(log, "failed to launch process: {0}", error);
return error;
}
@@ -269,9 +257,8 @@ Error NativeProcessProtocol::Launch(
Error NativeProcessProtocol::Attach(
lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate,
MainLoop &mainloop, NativeProcessProtocolSP &native_process_sp) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
- log->Printf("NativeProcessLinux::%s(pid = %" PRIi64 ")", __FUNCTION__, pid);
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+ LLDB_LOG(log, "pid = {0:x}", pid);
// Retrieve the architecture for the running process.
ArchSpec process_arch;
@@ -306,10 +293,8 @@ NativeProcessLinux::NativeProcessLinux()
void NativeProcessLinux::AttachToInferior(MainLoop &mainloop, lldb::pid_t pid,
Error &error) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("NativeProcessLinux::%s (pid = %" PRIi64 ")", __FUNCTION__,
- pid);
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+ LLDB_LOG(log, "pid = {0:x}", pid);
m_sigchld_handle = mainloop.RegisterSignal(
SIGCHLD, [this](MainLoopBase &) { SigchldHandler(); }, error);
@@ -321,11 +306,8 @@ void NativeProcessLinux::AttachToInferior(MainLoop &mainloop, lldb::pid_t pid,
return;
// Set the architecture to the exe architecture.
- if (log)
- log->Printf("NativeProcessLinux::%s (pid = %" PRIi64
- ") detected architecture %s",
- __FUNCTION__, pid, m_arch.GetArchitectureName());
-
+ LLDB_LOG(log, "pid = {0:x}, detected architecture {1}", pid,
+ m_arch.GetArchitectureName());
m_pid = pid;
SetState(eStateAttaching);
@@ -345,20 +327,18 @@ Error NativeProcessLinux::LaunchInferior(MainLoop &mainloop,
MaybeLogLaunchInfo(launch_info);
::pid_t pid =
- ProcessLauncherLinux().LaunchProcess(launch_info, error).GetProcessId();
+ ProcessLauncherPosixFork().LaunchProcess(launch_info, error).GetProcessId();
if (error.Fail())
return error;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
// Wait for the child process to trap on its call to execve.
::pid_t wpid;
int status;
if ((wpid = waitpid(pid, &status, 0)) < 0) {
error.SetErrorToErrno();
- if (log)
- log->Printf("NativeProcessLinux::%s waitpid for inferior failed with %s",
- __FUNCTION__, error.AsCString());
+ LLDB_LOG(log, "waitpid for inferior failed with %s", error);
// Mark the inferior as invalid.
// FIXME this could really use a new state - eStateLaunchFailure. For now,
@@ -370,16 +350,10 @@ Error NativeProcessLinux::LaunchInferior(MainLoop &mainloop,
assert(WIFSTOPPED(status) && (wpid == static_cast<::pid_t>(pid)) &&
"Could not sync with inferior process.");
- if (log)
- log->Printf("NativeProcessLinux::%s inferior started, now in stopped state",
- __FUNCTION__);
-
+ LLDB_LOG(log, "inferior started, now in stopped state");
error = SetDefaultPtraceOpts(pid);
if (error.Fail()) {
- if (log)
- log->Printf("NativeProcessLinux::%s inferior failed to set default "
- "ptrace options: %s",
- __FUNCTION__, error.AsCString());
+ LLDB_LOG(log, "failed to set default ptrace options: {0}", error);
// Mark the inferior as invalid.
// FIXME this could really use a new state - eStateLaunchFailure. For now,
@@ -398,10 +372,10 @@ Error NativeProcessLinux::LaunchInferior(MainLoop &mainloop,
if (m_terminal_fd != -1) {
error = EnsureFDFlags(m_terminal_fd, O_NONBLOCK);
if (error.Fail()) {
- if (log)
- log->Printf("NativeProcessLinux::%s inferior EnsureFDFlags failed for "
- "ensuring terminal O_NONBLOCK setting: %s",
- __FUNCTION__, error.AsCString());
+ LLDB_LOG(log,
+ "inferior EnsureFDFlags failed for ensuring terminal "
+ "O_NONBLOCK setting: {0}",
+ error);
// Mark the inferior as invalid.
// FIXME this could really use a new state - eStateLaunchFailure. For
@@ -412,10 +386,7 @@ Error NativeProcessLinux::LaunchInferior(MainLoop &mainloop,
}
}
- if (log)
- log->Printf("NativeProcessLinux::%s() adding pid = %" PRIu64, __FUNCTION__,
- uint64_t(pid));
-
+ LLDB_LOG(log, "adding pid = {0}", pid);
ResolveProcessArchitecture(m_pid, m_arch);
NativeThreadLinuxSP thread_sp = AddThread(pid);
assert(thread_sp && "AddThread() returned a nullptr thread");
@@ -426,19 +397,13 @@ Error NativeProcessLinux::LaunchInferior(MainLoop &mainloop,
SetCurrentThreadID(thread_sp->GetID());
SetState(StateType::eStateStopped);
- if (log) {
- if (error.Success())
- log->Printf("NativeProcessLinux::%s inferior launching succeeded",
- __FUNCTION__);
- else
- log->Printf("NativeProcessLinux::%s inferior launching failed: %s",
- __FUNCTION__, error.AsCString());
- }
+ if (error.Fail())
+ LLDB_LOG(log, "inferior launching failed {0}", error);
return error;
}
::pid_t NativeProcessLinux::Attach(lldb::pid_t pid, Error &error) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
// Use a map to keep track of the threads which we have attached/need to
// attach.
@@ -487,10 +452,7 @@ Error NativeProcessLinux::LaunchInferior(MainLoop &mainloop,
if (error.Fail())
return -1;
- if (log)
- log->Printf("NativeProcessLinux::%s() adding tid = %" PRIu64,
- __FUNCTION__, tid);
-
+ LLDB_LOG(log, "adding tid = {0}", tid);
it->second = true;
// Create the thread, mark it as stopped.
@@ -578,11 +540,8 @@ void NativeProcessLinux::MonitorCallback(lldb::pid_t pid, bool exited,
// Handle when the thread exits.
if (exited) {
- if (log)
- log->Printf(
- "NativeProcessLinux::%s() got exit signal(%d) , tid = %" PRIu64
- " (%s main thread)",
- __FUNCTION__, signal, pid, is_main_thread ? "is" : "is not");
+ LLDB_LOG(log, "got exit signal({0}) , tid = {1} ({2} main thread)", signal,
+ pid, is_main_thread ? "is" : "is not");
// This is a thread that exited. Ensure we're not tracking it anymore.
const bool thread_found = StopTrackingThread(pid);
@@ -596,41 +555,32 @@ void NativeProcessLinux::MonitorCallback(lldb::pid_t pid, bool exited,
const bool already_notified = (GetState() == StateType::eStateExited) ||
(GetState() == StateType::eStateCrashed);
if (!already_notified) {
- if (log)
- log->Printf("NativeProcessLinux::%s() tid = %" PRIu64
- " handling main thread exit (%s), expected exit state "
- "already set but state was %s instead, setting exit "
- "state now",
- __FUNCTION__, pid,
- thread_found ? "stopped tracking thread metadata"
- : "thread metadata not found",
- StateAsCString(GetState()));
+ LLDB_LOG(
+ log,
+ "tid = {0} handling main thread exit ({1}), expected exit state "
+ "already set but state was {2} instead, setting exit state now",
+ pid,
+ thread_found ? "stopped tracking thread metadata"
+ : "thread metadata not found",
+ GetState());
// The main thread exited. We're done monitoring. Report to delegate.
SetExitStatus(convert_pid_status_to_exit_type(status),
convert_pid_status_to_return_code(status), nullptr, true);
// Notify delegate that our process has exited.
SetState(StateType::eStateExited, true);
- } else {
- if (log)
- log->Printf("NativeProcessLinux::%s() tid = %" PRIu64
- " main thread now exited (%s)",
- __FUNCTION__, pid,
- thread_found ? "stopped tracking thread metadata"
- : "thread metadata not found");
- }
+ } else
+ LLDB_LOG(log, "tid = {0} main thread now exited (%s)", pid,
+ thread_found ? "stopped tracking thread metadata"
+ : "thread metadata not found");
} else {
// Do we want to report to the delegate in this case? I think not. If
- // this was an orderly
- // thread exit, we would already have received the SIGTRAP |
- // (PTRACE_EVENT_EXIT << 8) signal,
- // and we would have done an all-stop then.
- if (log)
- log->Printf("NativeProcessLinux::%s() tid = %" PRIu64
- " handling non-main thread exit (%s)",
- __FUNCTION__, pid,
- thread_found ? "stopped tracking thread metadata"
- : "thread metadata not found");
+ // this was an orderly thread exit, we would already have received the
+ // SIGTRAP | (PTRACE_EVENT_EXIT << 8) signal, and we would have done an
+ // all-stop then.
+ LLDB_LOG(log, "tid = {0} handling non-main thread exit (%s)", pid,
+ thread_found ? "stopped tracking thread metadata"
+ : "thread metadata not found");
}
return;
}
@@ -641,28 +591,20 @@ void NativeProcessLinux::MonitorCallback(lldb::pid_t pid, bool exited,
if (!thread_sp) {
// Normally, the only situation when we cannot find the thread is if we have
- // just
- // received a new thread notification. This is indicated by GetSignalInfo()
- // returning
- // si_code == SI_USER and si_pid == 0
- if (log)
- log->Printf("NativeProcessLinux::%s received notification about an "
- "unknown tid %" PRIu64 ".",
- __FUNCTION__, pid);
+ // just received a new thread notification. This is indicated by
+ // GetSignalInfo() returning si_code == SI_USER and si_pid == 0
+ LLDB_LOG(log, "received notification about an unknown tid {0}.", pid);
if (info_err.Fail()) {
- if (log)
- log->Printf("NativeProcessLinux::%s (tid %" PRIu64
- ") GetSignalInfo failed (%s). Ingoring this notification.",
- __FUNCTION__, pid, info_err.AsCString());
+ LLDB_LOG(log,
+ "(tid {0}) GetSignalInfo failed ({1}). "
+ "Ingoring this notification.",
+ pid, info_err);
return;
}
- if (log && (info.si_code != SI_USER || info.si_pid != 0))
- log->Printf("NativeProcessLinux::%s (tid %" PRIu64
- ") unexpected signal info (si_code: %d, si_pid: %d). "
- "Treating as a new thread notification anyway.",
- __FUNCTION__, pid, info.si_code, info.si_pid);
+ LLDB_LOG(log, "tid {0}, si_code: {1}, si_pid: {2}", pid, info.si_code,
+ info.si_pid);
auto thread_sp = AddThread(pid);
// Resume the newly created thread.
@@ -682,49 +624,35 @@ void NativeProcessLinux::MonitorCallback(lldb::pid_t pid, bool exited,
if (info_err.GetError() == EINVAL) {
// This is a group stop reception for this tid.
// We can reach here if we reinject SIGSTOP, SIGSTP, SIGTTIN or SIGTTOU
- // into the
- // tracee, triggering the group-stop mechanism. Normally receiving these
- // would stop
- // the process, pending a SIGCONT. Simulating this state in a debugger is
- // hard and is
- // generally not needed (one use case is debugging background task being
- // managed by a
- // shell). For general use, it is sufficient to stop the process in a
- // signal-delivery
+ // into the tracee, triggering the group-stop mechanism. Normally
+ // receiving these would stop the process, pending a SIGCONT. Simulating
+ // this state in a debugger is hard and is generally not needed (one use
+ // case is debugging background task being managed by a shell). For
+ // general use, it is sufficient to stop the process in a signal-delivery
// stop which happens before the group stop. This done by MonitorSignal
- // and works
- // correctly for all signals.
- if (log)
- log->Printf(
- "NativeProcessLinux::%s received a group stop for pid %" PRIu64
- " tid %" PRIu64 ". Transparent handling of group stops not "
- "supported, resuming the thread.",
- __FUNCTION__, GetID(), pid);
+ // and works correctly for all signals.
+ LLDB_LOG(log,
+ "received a group stop for pid {0} tid {1}. Transparent "
+ "handling of group stops not supported, resuming the "
+ "thread.",
+ GetID(), pid);
ResumeThread(*thread_sp, thread_sp->GetState(),
LLDB_INVALID_SIGNAL_NUMBER);
} else {
// ptrace(GETSIGINFO) failed (but not due to group-stop).
// A return value of ESRCH means the thread/process is no longer on the
- // system,
- // so it was killed somehow outside of our control. Either way, we can't
- // do anything
- // with it anymore.
+ // system, so it was killed somehow outside of our control. Either way,
+ // we can't do anything with it anymore.
// Stop tracking the metadata for the thread since it's entirely off the
// system now.
const bool thread_found = StopTrackingThread(pid);
- if (log)
- log->Printf(
- "NativeProcessLinux::%s GetSignalInfo failed: %s, tid = %" PRIu64
- ", signal = %d, status = %d (%s, %s, %s)",
- __FUNCTION__, info_err.AsCString(), pid, signal, status,
- info_err.GetError() == ESRCH ? "thread/process killed"
- : "unknown reason",
- is_main_thread ? "is main thread" : "is not main thread",
- thread_found ? "thread metadata removed"
- : "thread metadata not found");
+ LLDB_LOG(log,
+ "GetSignalInfo failed: {0}, tid = {1}, signal = {2}, "
+ "status = {3}, main_thread = {4}, thread_found: {5}",
+ info_err, pid, signal, status, is_main_thread, thread_found);
if (is_main_thread) {
// Notify the delegate - our process is not available but appears to
@@ -736,19 +664,18 @@ void NativeProcessLinux::MonitorCallback(lldb::pid_t pid, bool exited,
} else {
// This thread was pulled out from underneath us. Anything to do here?
// Do we want to do an all stop?
- if (log)
- log->Printf("NativeProcessLinux::%s pid %" PRIu64 " tid %" PRIu64
- " non-main thread exit occurred, didn't tell delegate "
- "anything since thread disappeared out from underneath "
- "us",
- __FUNCTION__, GetID(), pid);
+ LLDB_LOG(log,
+ "pid {0} tid {1} non-main thread exit occurred, didn't "
+ "tell delegate anything since thread disappeared out "
+ "from underneath us",
+ GetID(), pid);
}
}
}
}
void NativeProcessLinux::WaitForNewThread(::pid_t tid) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
NativeThreadLinuxSP new_thread_sp = GetThreadByID(tid);
@@ -763,65 +690,34 @@ void NativeProcessLinux::WaitForNewThread(::pid_t tid) {
int status = -1;
::pid_t wait_pid;
do {
- if (log)
- log->Printf("NativeProcessLinux::%s() received thread creation event for "
- "tid %" PRIu32
- ". tid not tracked yet, waiting for thread to appear...",
- __FUNCTION__, tid);
+ LLDB_LOG(log,
+ "received thread creation event for tid {0}. tid not tracked "
+ "yet, waiting for thread to appear...",
+ tid);
wait_pid = waitpid(tid, &status, __WALL);
} while (wait_pid == -1 && errno == EINTR);
// Since we are waiting on a specific tid, this must be the creation event.
- // But let's do
- // some checks just in case.
+ // But let's do some checks just in case.
if (wait_pid != tid) {
- if (log)
- log->Printf(
- "NativeProcessLinux::%s() waiting for tid %" PRIu32
- " failed. Assuming the thread has disappeared in the meantime",
- __FUNCTION__, tid);
+ LLDB_LOG(log,
+ "waiting for tid {0} failed. Assuming the thread has "
+ "disappeared in the meantime",
+ tid);
// The only way I know of this could happen is if the whole process was
// SIGKILLed in the mean time. In any case, we can't do anything about that
// now.
return;
}
if (WIFEXITED(status)) {
- if (log)
- log->Printf("NativeProcessLinux::%s() waiting for tid %" PRIu32
- " returned an 'exited' event. Not tracking the thread.",
- __FUNCTION__, tid);
+ LLDB_LOG(log,
+ "waiting for tid {0} returned an 'exited' event. Not "
+ "tracking the thread.",
+ tid);
// Also a very improbable event.
return;
}
- siginfo_t info;
- Error error = GetSignalInfo(tid, &info);
- if (error.Fail()) {
- if (log)
- log->Printf(
- "NativeProcessLinux::%s() GetSignalInfo for tid %" PRIu32
- " failed. Assuming the thread has disappeared in the meantime.",
- __FUNCTION__, tid);
- return;
- }
-
- if (((info.si_pid != 0) || (info.si_code != SI_USER)) && log) {
- // We should be getting a thread creation signal here, but we received
- // something
- // else. There isn't much we can do about it now, so we will just log that.
- // Since the
- // thread is alive and we are receiving events from it, we shall pretend
- // that it was
- // created properly.
- log->Printf("NativeProcessLinux::%s() GetSignalInfo for tid %" PRIu32
- " received unexpected signal with code %d from pid %d.",
- __FUNCTION__, tid, info.si_code, info.si_pid);
- }
-
- if (log)
- log->Printf("NativeProcessLinux::%s() pid = %" PRIu64
- ": tracking new thread tid %" PRIu32,
- __FUNCTION__, GetID(), tid);
-
+ LLDB_LOG(log, "pid = {0}: tracking new thread tid {1}", GetID(), tid);
new_thread_sp = AddThread(tid);
ResumeThread(*new_thread_sp, eStateRunning, LLDB_INVALID_SIGNAL_NUMBER);
ThreadWasCreated(*new_thread_sp);
@@ -829,7 +725,7 @@ void NativeProcessLinux::WaitForNewThread(::pid_t tid) {
void NativeProcessLinux::MonitorSIGTRAP(const siginfo_t &info,
NativeThreadLinux &thread) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
const bool is_main_thread = (thread.GetID() == GetID());
assert(info.si_signo == SIGTRAP && "Unexpected child signal!");
@@ -852,11 +748,10 @@ void NativeProcessLinux::MonitorSIGTRAP(const siginfo_t &info,
unsigned long event_message = 0;
if (GetEventMessage(thread.GetID(), &event_message).Fail()) {
- if (log)
- log->Printf("NativeProcessLinux::%s() pid %" PRIu64
- " received thread creation event but GetEventMessage "
- "failed so we don't know the new tid",
- __FUNCTION__, thread.GetID());
+ LLDB_LOG(log,
+ "pid {0} received thread creation event but "
+ "GetEventMessage failed so we don't know the new tid",
+ thread.GetID());
} else
WaitForNewThread(event_message);
@@ -866,35 +761,24 @@ void NativeProcessLinux::MonitorSIGTRAP(const siginfo_t &info,
case (SIGTRAP | (PTRACE_EVENT_EXEC << 8)): {
NativeThreadLinuxSP main_thread_sp;
- if (log)
- log->Printf("NativeProcessLinux::%s() received exec event, code = %d",
- __FUNCTION__, info.si_code ^ SIGTRAP);
+ LLDB_LOG(log, "received exec event, code = {0}", info.si_code ^ SIGTRAP);
// Exec clears any pending notifications.
m_pending_notification_tid = LLDB_INVALID_THREAD_ID;
// Remove all but the main thread here. Linux fork creates a new process
// which only copies the main thread.
- if (log)
- log->Printf("NativeProcessLinux::%s exec received, stop tracking all but "
- "main thread",
- __FUNCTION__);
+ LLDB_LOG(log, "exec received, stop tracking all but main thread");
for (auto thread_sp : m_threads) {
const bool is_main_thread = thread_sp && thread_sp->GetID() == GetID();
if (is_main_thread) {
main_thread_sp = std::static_pointer_cast<NativeThreadLinux>(thread_sp);
- if (log)
- log->Printf(
- "NativeProcessLinux::%s found main thread with tid %" PRIu64
- ", keeping",
- __FUNCTION__, main_thread_sp->GetID());
+ LLDB_LOG(log, "found main thread with tid {0}, keeping",
+ main_thread_sp->GetID());
} else {
- if (log)
- log->Printf(
- "NativeProcessLinux::%s discarding non-main-thread tid %" PRIu64
- " due to exec",
- __FUNCTION__, thread_sp->GetID());
+ LLDB_LOG(log, "discarding non-main-thread tid {0} due to exec",
+ thread_sp->GetID());
}
}
@@ -906,11 +790,10 @@ void NativeProcessLinux::MonitorSIGTRAP(const siginfo_t &info,
main_thread_sp->SetStoppedByExec();
} else {
SetCurrentThreadID(LLDB_INVALID_THREAD_ID);
- if (log)
- log->Printf("NativeProcessLinux::%s pid %" PRIu64
- "no main thread found, discarded all threads, we're in a "
- "no-thread state!",
- __FUNCTION__, GetID());
+ LLDB_LOG(log,
+ "pid {0} no main thread found, discarded all threads, "
+ "we're in a no-thread state!",
+ GetID());
}
// Tell coordinator about about the "new" (since exec) stopped main thread.
@@ -941,13 +824,11 @@ void NativeProcessLinux::MonitorSIGTRAP(const siginfo_t &info,
if (GetEventMessage(thread.GetID(), &data).Fail())
data = -1;
- if (log) {
- log->Printf("NativeProcessLinux::%s() received PTRACE_EVENT_EXIT, data = "
- "%lx (WIFEXITED=%s,WIFSIGNALED=%s), pid = %" PRIu64 " (%s)",
- __FUNCTION__, data, WIFEXITED(data) ? "true" : "false",
- WIFSIGNALED(data) ? "true" : "false", thread.GetID(),
- is_main_thread ? "is main thread" : "not main thread");
- }
+ LLDB_LOG(log,
+ "received PTRACE_EVENT_EXIT, data = {0:x}, WIFEXITED={1}, "
+ "WIFSIGNALED={2}, pid = {3}, main_thread = {4}",
+ data, WIFEXITED(data), WIFSIGNALED(data), thread.GetID(),
+ is_main_thread);
if (is_main_thread) {
SetExitStatus(convert_pid_status_to_exit_type(data),
@@ -978,16 +859,29 @@ void NativeProcessLinux::MonitorSIGTRAP(const siginfo_t &info,
uint32_t wp_index;
Error error = thread.GetRegisterContext()->GetWatchpointHitIndex(
wp_index, (uintptr_t)info.si_addr);
- if (error.Fail() && log)
- log->Printf("NativeProcessLinux::%s() "
- "received error while checking for watchpoint hits, "
- "pid = %" PRIu64 " error = %s",
- __FUNCTION__, thread.GetID(), error.AsCString());
+ if (error.Fail())
+ LLDB_LOG(log,
+ "received error while checking for watchpoint hits, pid = "
+ "{0}, error = {1}",
+ thread.GetID(), error);
if (wp_index != LLDB_INVALID_INDEX32) {
MonitorWatchpoint(thread, wp_index);
break;
}
+ // If a breakpoint was hit, report it
+ uint32_t bp_index;
+ error = thread.GetRegisterContext()->GetHardwareBreakHitIndex(
+ bp_index, (uintptr_t)info.si_addr);
+ if (error.Fail())
+ LLDB_LOG(log, "received error while checking for hardware "
+ "breakpoint hits, pid = {0}, error = {1}",
+ thread.GetID(), error);
+ if (bp_index != LLDB_INVALID_INDEX32) {
+ MonitorBreakpoint(thread);
+ break;
+ }
+
// Otherwise, report step over
MonitorTrace(thread);
break;
@@ -1002,11 +896,11 @@ void NativeProcessLinux::MonitorSIGTRAP(const siginfo_t &info,
uint32_t wp_index;
Error error = thread.GetRegisterContext()->GetWatchpointHitIndex(
wp_index, LLDB_INVALID_ADDRESS);
- if (error.Fail() && log)
- log->Printf("NativeProcessLinux::%s() "
- "received error while checking for watchpoint hits, "
- "pid = %" PRIu64 " error = %s",
- __FUNCTION__, thread.GetID(), error.AsCString());
+ if (error.Fail())
+ LLDB_LOG(log,
+ "received error while checking for watchpoint hits, pid = "
+ "{0}, error = {1}",
+ thread.GetID(), error);
if (wp_index != LLDB_INVALID_INDEX32) {
MonitorWatchpoint(thread, wp_index);
break;
@@ -1020,31 +914,28 @@ void NativeProcessLinux::MonitorSIGTRAP(const siginfo_t &info,
case SIGTRAP:
case (SIGTRAP | 0x80):
- if (log)
- log->Printf("NativeProcessLinux::%s() received unknown SIGTRAP system "
- "call stop event, pid %" PRIu64 "tid %" PRIu64 ", resuming",
- __FUNCTION__, GetID(), thread.GetID());
+ LLDB_LOG(
+ log,
+ "received unknown SIGTRAP stop event ({0}, pid {1} tid {2}, resuming",
+ info.si_code, GetID(), thread.GetID());
// Ignore these signals until we know more about them.
ResumeThread(thread, thread.GetState(), LLDB_INVALID_SIGNAL_NUMBER);
break;
default:
- assert(false && "Unexpected SIGTRAP code!");
- if (log)
- log->Printf("NativeProcessLinux::%s() pid %" PRIu64 "tid %" PRIu64
- " received unhandled SIGTRAP code: 0x%d",
- __FUNCTION__, GetID(), thread.GetID(), info.si_code);
+ LLDB_LOG(
+ log,
+ "received unknown SIGTRAP stop event ({0}, pid {1} tid {2}, resuming",
+ info.si_code, GetID(), thread.GetID());
+ llvm_unreachable("Unexpected SIGTRAP code!");
break;
}
}
void NativeProcessLinux::MonitorTrace(NativeThreadLinux &thread) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("NativeProcessLinux::%s() received trace event, pid = %" PRIu64
- " (single stepping)",
- __FUNCTION__, thread.GetID());
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+ LLDB_LOG(log, "received trace event, pid = {0}", thread.GetID());
// This thread is currently stopped.
thread.SetStoppedByTrace();
@@ -1055,18 +946,13 @@ void NativeProcessLinux::MonitorTrace(NativeThreadLinux &thread) {
void NativeProcessLinux::MonitorBreakpoint(NativeThreadLinux &thread) {
Log *log(
GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_BREAKPOINTS));
- if (log)
- log->Printf(
- "NativeProcessLinux::%s() received breakpoint event, pid = %" PRIu64,
- __FUNCTION__, thread.GetID());
+ LLDB_LOG(log, "received breakpoint event, pid = {0}", thread.GetID());
// Mark the thread as stopped at breakpoint.
thread.SetStoppedByBreakpoint();
Error error = FixupBreakpointPCAsNeeded(thread);
if (error.Fail())
- if (log)
- log->Printf("NativeProcessLinux::%s() pid = %" PRIu64 " fixup: %s",
- __FUNCTION__, thread.GetID(), error.AsCString());
+ LLDB_LOG(log, "pid = {0} fixup: {1}", thread.GetID(), error);
if (m_threads_stepping_with_breakpoint.find(thread.GetID()) !=
m_threads_stepping_with_breakpoint.end())
@@ -1079,10 +965,8 @@ void NativeProcessLinux::MonitorWatchpoint(NativeThreadLinux &thread,
uint32_t wp_index) {
Log *log(
GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_WATCHPOINTS));
- if (log)
- log->Printf("NativeProcessLinux::%s() received watchpoint event, "
- "pid = %" PRIu64 ", wp_index = %" PRIu32,
- __FUNCTION__, thread.GetID(), wp_index);
+ LLDB_LOG(log, "received watchpoint event, pid = {0}, wp_index = {1}",
+ thread.GetID(), wp_index);
// Mark the thread as stopped at watchpoint.
// The address is at (lldb::addr_t)info->si_addr if we need it.
@@ -1098,7 +982,7 @@ void NativeProcessLinux::MonitorSignal(const siginfo_t &info,
const int signo = info.si_signo;
const bool is_from_llgs = info.si_pid == getpid();
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
// POSIX says that process behaviour is undefined after it ignores a SIGFPE,
// SIGILL, SIGSEGV, or SIGBUS *unless* that signal was generated by a
@@ -1110,47 +994,33 @@ void NativeProcessLinux::MonitorSignal(const siginfo_t &info,
// Similarly, ACK signals generated by this monitor.
// Handle the signal.
- if (info.si_code == SI_TKILL || info.si_code == SI_USER) {
- if (log)
- log->Printf("NativeProcessLinux::%s() received signal %s (%d) with code "
- "%s, (siginfo pid = %d (%s), waitpid pid = %" PRIu64 ")",
- __FUNCTION__, Host::GetSignalAsCString(signo), signo,
- (info.si_code == SI_TKILL ? "SI_TKILL" : "SI_USER"),
- info.si_pid, is_from_llgs ? "from llgs" : "not from llgs",
- thread.GetID());
- }
+ LLDB_LOG(log,
+ "received signal {0} ({1}) with code {2}, (siginfo pid = {3}, "
+ "waitpid pid = {4})",
+ Host::GetSignalAsCString(signo), signo, info.si_code,
+ thread.GetID());
// Check for thread stop notification.
if (is_from_llgs && (info.si_code == SI_TKILL) && (signo == SIGSTOP)) {
// This is a tgkill()-based stop.
- if (log)
- log->Printf("NativeProcessLinux::%s() pid %" PRIu64 " tid %" PRIu64
- ", thread stopped",
- __FUNCTION__, GetID(), thread.GetID());
+ LLDB_LOG(log, "pid {0} tid {1}, thread stopped", GetID(), thread.GetID());
// Check that we're not already marked with a stop reason.
// Note this thread really shouldn't already be marked as stopped - if we
- // were, that would imply that
- // the kernel signaled us with the thread stopping which we handled and
- // marked as stopped,
- // and that, without an intervening resume, we received another stop. It is
- // more likely
- // that we are missing the marking of a run state somewhere if we find that
- // the thread was
- // marked as stopped.
+ // were, that would imply that the kernel signaled us with the thread
+ // stopping which we handled and marked as stopped, and that, without an
+ // intervening resume, we received another stop. It is more likely that we
+ // are missing the marking of a run state somewhere if we find that the
+ // thread was marked as stopped.
const StateType thread_state = thread.GetState();
if (!StateIsStoppedState(thread_state, false)) {
// An inferior thread has stopped because of a SIGSTOP we have sent it.
// Generally, these are not important stops and we don't want to report
- // them as
- // they are just used to stop other threads when one thread (the one with
- // the
- // *real* stop reason) hits a breakpoint (watchpoint, etc...). However, in
- // the
- // case of an asynchronous Interrupt(), this *is* the real stop reason, so
- // we
- // leave the signal intact if this is the thread that was chosen as the
- // triggering thread.
+ // them as they are just used to stop other threads when one thread (the
+ // one with the *real* stop reason) hits a breakpoint (watchpoint,
+ // etc...). However, in the case of an asynchronous Interrupt(), this *is*
+ // the real stop reason, so we leave the signal intact if this is the
+ // thread that was chosen as the triggering thread.
if (m_pending_notification_tid != LLDB_INVALID_THREAD_ID) {
if (m_pending_notification_tid == thread.GetID())
thread.SetStoppedBySignal(SIGSTOP, &info);
@@ -1163,30 +1033,15 @@ void NativeProcessLinux::MonitorSignal(const siginfo_t &info,
// We can end up here if stop was initiated by LLGS but by this time a
// thread stop has occurred - maybe initiated by another event.
Error error = ResumeThread(thread, thread.GetState(), 0);
- if (error.Fail() && log) {
- log->Printf(
- "NativeProcessLinux::%s failed to resume thread tid %" PRIu64
- ": %s",
- __FUNCTION__, thread.GetID(), error.AsCString());
- }
+ if (error.Fail())
+ LLDB_LOG(log, "failed to resume thread {0}: {1}", thread.GetID(),
+ error);
}
} else {
- if (log) {
- // Retrieve the signal name if the thread was stopped by a signal.
- int stop_signo = 0;
- const bool stopped_by_signal = thread.IsStopped(&stop_signo);
- const char *signal_name = stopped_by_signal
- ? Host::GetSignalAsCString(stop_signo)
- : "<not stopped by signal>";
- if (!signal_name)
- signal_name = "<no-signal-name>";
-
- log->Printf("NativeProcessLinux::%s() pid %" PRIu64 " tid %" PRIu64
- ", thread was already marked as a stopped state (state=%s, "
- "signal=%d (%s)), leaving stop signal as is",
- __FUNCTION__, GetID(), thread.GetID(),
- StateAsCString(thread_state), stop_signo, signal_name);
- }
+ LLDB_LOG(log,
+ "pid {0} tid {1}, thread was already marked as a stopped "
+ "state (state={2}), leaving stop signal as is",
+ GetID(), thread.GetID(), thread_state);
SignalIfAllThreadsStopped();
}
@@ -1194,11 +1049,15 @@ void NativeProcessLinux::MonitorSignal(const siginfo_t &info,
return;
}
- if (log)
- log->Printf("NativeProcessLinux::%s() received signal %s", __FUNCTION__,
- Host::GetSignalAsCString(signo));
+ // Check if debugger should stop at this signal or just ignore it
+ // and resume the inferior.
+ if (m_signals_to_ignore.find(signo) != m_signals_to_ignore.end()) {
+ ResumeThread(thread, thread.GetState(), signo);
+ return;
+ }
// This thread is stopped.
+ LLDB_LOG(log, "received signal {0}", Host::GetSignalAsCString(signo));
thread.SetStoppedBySignal(signo, &info);
// Send a stop to the debugger after we get all other threads to stop.
@@ -1383,10 +1242,8 @@ bool NativeProcessLinux::SupportHardwareSingleStepping() const {
}
Error NativeProcessLinux::Resume(const ResumeActionList &resume_actions) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD));
- if (log)
- log->Printf("NativeProcessLinux::%s called: pid %" PRIu64, __FUNCTION__,
- GetID());
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+ LLDB_LOG(log, "pid {0}", GetID());
bool software_single_step = !SupportHardwareSingleStepping();
@@ -1415,20 +1272,13 @@ Error NativeProcessLinux::Resume(const ResumeActionList &resume_actions) {
resume_actions.GetActionForThread(thread_sp->GetID(), true);
if (action == nullptr) {
- if (log)
- log->Printf(
- "NativeProcessLinux::%s no action specified for pid %" PRIu64
- " tid %" PRIu64,
- __FUNCTION__, GetID(), thread_sp->GetID());
+ LLDB_LOG(log, "no action specified for pid {0} tid {1}", GetID(),
+ thread_sp->GetID());
continue;
}
- if (log) {
- log->Printf("NativeProcessLinux::%s processing resume action state %s "
- "for pid %" PRIu64 " tid %" PRIu64,
- __FUNCTION__, StateAsCString(action->state), GetID(),
- thread_sp->GetID());
- }
+ LLDB_LOG(log, "processing resume action state {0} for pid {1} tid {2}",
+ action->state, GetID(), thread_sp->GetID());
switch (action->state) {
case eStateRunning:
@@ -1442,7 +1292,7 @@ Error NativeProcessLinux::Resume(const ResumeActionList &resume_actions) {
case eStateSuspended:
case eStateStopped:
- lldbassert(0 && "Unexpected state");
+ llvm_unreachable("Unexpected state");
default:
return Error("NativeProcessLinux::%s (): unexpected state %s specified "
@@ -1487,11 +1337,9 @@ Error NativeProcessLinux::Detach() {
Error NativeProcessLinux::Signal(int signo) {
Error error;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf(
- "NativeProcessLinux::%s: sending signal %d (%s) to pid %" PRIu64,
- __FUNCTION__, signo, Host::GetSignalAsCString(signo), GetID());
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+ LLDB_LOG(log, "sending signal {0} ({1}) to pid {1}", signo,
+ Host::GetSignalAsCString(signo), GetID());
if (kill(GetID(), signo))
error.SetErrorToErrno();
@@ -1502,16 +1350,12 @@ Error NativeProcessLinux::Signal(int signo) {
Error NativeProcessLinux::Interrupt() {
// Pick a running thread (or if none, a not-dead stopped thread) as
// the chosen thread that will be the stop-reason thread.
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
NativeThreadProtocolSP running_thread_sp;
NativeThreadProtocolSP stopped_thread_sp;
- if (log)
- log->Printf(
- "NativeProcessLinux::%s selecting running thread for interrupt target",
- __FUNCTION__);
-
+ LLDB_LOG(log, "selecting running thread for interrupt target");
for (auto thread_sp : m_threads) {
// The thread shouldn't be null but lets just cover that here.
if (!thread_sp)
@@ -1533,9 +1377,7 @@ Error NativeProcessLinux::Interrupt() {
if (!running_thread_sp && !stopped_thread_sp) {
Error error("found no running/stepping or live stopped threads as target "
"for interrupt");
- if (log)
- log->Printf("NativeProcessLinux::%s skipping due to error: %s",
- __FUNCTION__, error.AsCString());
+ LLDB_LOG(log, "skipping due to error: {0}", error);
return error;
}
@@ -1543,12 +1385,9 @@ Error NativeProcessLinux::Interrupt() {
NativeThreadProtocolSP deferred_signal_thread_sp =
running_thread_sp ? running_thread_sp : stopped_thread_sp;
- if (log)
- log->Printf("NativeProcessLinux::%s pid %" PRIu64 " %s tid %" PRIu64
- " chosen for interrupt target",
- __FUNCTION__, GetID(),
- running_thread_sp ? "running" : "stopped",
- deferred_signal_thread_sp->GetID());
+ LLDB_LOG(log, "pid {0} {1} tid {2} chosen for interrupt target", GetID(),
+ running_thread_sp ? "running" : "stopped",
+ deferred_signal_thread_sp->GetID());
StopRunningThreads(deferred_signal_thread_sp->GetID());
@@ -1556,10 +1395,8 @@ Error NativeProcessLinux::Interrupt() {
}
Error NativeProcessLinux::Kill() {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("NativeProcessLinux::%s called for PID %" PRIu64, __FUNCTION__,
- GetID());
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+ LLDB_LOG(log, "pid {0}", GetID());
Error error;
@@ -1570,10 +1407,8 @@ Error NativeProcessLinux::Kill() {
case StateType::eStateDetached:
case StateType::eStateUnloaded:
// Nothing to do - the process is already dead.
- if (log)
- log->Printf("NativeProcessLinux::%s ignored for PID %" PRIu64
- " due to current state: %s",
- __FUNCTION__, GetID(), StateAsCString(m_state));
+ LLDB_LOG(log, "ignored for PID {0} due to current state: {1}", GetID(),
+ m_state);
return error;
case StateType::eStateConnected:
@@ -1596,11 +1431,11 @@ Error NativeProcessLinux::Kill() {
}
static Error
-ParseMemoryRegionInfoFromProcMapsLine(const std::string &maps_line,
+ParseMemoryRegionInfoFromProcMapsLine(llvm::StringRef &maps_line,
MemoryRegionInfo &memory_region_info) {
memory_region_info.Clear();
- StringExtractor line_extractor(maps_line.c_str());
+ StringExtractor line_extractor(maps_line);
// Format: {address_start_hex}-{address_end_hex} perms offset dev inode
// pathname
@@ -1712,6 +1547,7 @@ Error NativeProcessLinux::GetMemoryRegionInfo(lldb::addr_t load_addr,
assert((proc_entry_info.GetRange().GetRangeBase() >= prev_base_address) &&
"descending /proc/pid/maps entries detected, unexpected");
prev_base_address = proc_entry_info.GetRange().GetRangeBase();
+ UNUSED_IF_ASSERT_DISABLED(prev_base_address);
// If the target address comes before this entry, indicate distance to next
// region.
@@ -1750,60 +1586,50 @@ Error NativeProcessLinux::GetMemoryRegionInfo(lldb::addr_t load_addr,
}
Error NativeProcessLinux::PopulateMemoryRegionCache() {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
// If our cache is empty, pull the latest. There should always be at least
// one memory region if memory region handling is supported.
if (!m_mem_region_cache.empty()) {
- if (log)
- log->Printf("NativeProcessLinux::%s reusing %" PRIu64
- " cached memory region entries",
- __FUNCTION__,
- static_cast<uint64_t>(m_mem_region_cache.size()));
+ LLDB_LOG(log, "reusing {0} cached memory region entries",
+ m_mem_region_cache.size());
return Error();
}
- Error error = ProcFileReader::ProcessLineByLine(
- GetID(), "maps", [&](const std::string &line) -> bool {
- MemoryRegionInfo info;
- const Error parse_error =
- ParseMemoryRegionInfoFromProcMapsLine(line, info);
- if (parse_error.Success()) {
- m_mem_region_cache.emplace_back(
- info, FileSpec(info.GetName().GetCString(), true));
- return true;
- } else {
- if (log)
- log->Printf("NativeProcessLinux::%s failed to parse proc maps "
- "line '%s': %s",
- __FUNCTION__, line.c_str(), parse_error.AsCString());
- return false;
- }
- });
-
- // If we had an error, we'll mark unsupported.
- if (error.Fail()) {
+ auto BufferOrError = getProcFile(GetID(), "maps");
+ if (!BufferOrError) {
m_supports_mem_region = LazyBool::eLazyBoolNo;
- return error;
- } else if (m_mem_region_cache.empty()) {
+ return BufferOrError.getError();
+ }
+ StringRef Rest = BufferOrError.get()->getBuffer();
+ while (! Rest.empty()) {
+ StringRef Line;
+ std::tie(Line, Rest) = Rest.split('\n');
+ MemoryRegionInfo info;
+ const Error parse_error = ParseMemoryRegionInfoFromProcMapsLine(Line, info);
+ if (parse_error.Fail()) {
+ LLDB_LOG(log, "failed to parse proc maps line '{0}': {1}", Line,
+ parse_error);
+ m_supports_mem_region = LazyBool::eLazyBoolNo;
+ return parse_error;
+ }
+ m_mem_region_cache.emplace_back(
+ info, FileSpec(info.GetName().GetCString(), true));
+ }
+
+ if (m_mem_region_cache.empty()) {
// No entries after attempting to read them. This shouldn't happen if
// /proc/{pid}/maps is supported. Assume we don't support map entries
// via procfs.
- if (log)
- log->Printf("NativeProcessLinux::%s failed to find any procfs maps "
- "entries, assuming no support for memory region metadata "
- "retrieval",
- __FUNCTION__);
m_supports_mem_region = LazyBool::eLazyBoolNo;
- error.SetErrorString("not supported");
- return error;
+ LLDB_LOG(log,
+ "failed to find any procfs maps entries, assuming no support "
+ "for memory region metadata retrieval");
+ return Error("not supported");
}
- if (log)
- log->Printf("NativeProcessLinux::%s read %" PRIu64
- " memory region entries from /proc/%" PRIu64 "/maps",
- __FUNCTION__, static_cast<uint64_t>(m_mem_region_cache.size()),
- GetID());
+ LLDB_LOG(log, "read {0} memory region entries from /proc/{1}/maps",
+ m_mem_region_cache.size(), GetID());
// We support memory retrieval, remember that.
m_supports_mem_region = LazyBool::eLazyBoolYes;
@@ -1811,15 +1637,10 @@ Error NativeProcessLinux::PopulateMemoryRegionCache() {
}
void NativeProcessLinux::DoStopIDBumped(uint32_t newBumpId) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("NativeProcessLinux::%s(newBumpId=%" PRIu32 ") called",
- __FUNCTION__, newBumpId);
-
- if (log)
- log->Printf("NativeProcessLinux::%s clearing %" PRIu64
- " entries from the cache",
- __FUNCTION__, static_cast<uint64_t>(m_mem_region_cache.size()));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+ LLDB_LOG(log, "newBumpId={0}", newBumpId);
+ LLDB_LOG(log, "clearing {0} entries from memory region cache",
+ m_mem_region_cache.size());
m_mem_region_cache.clear();
}
@@ -1917,11 +1738,18 @@ Error NativeProcessLinux::GetSoftwareBreakpointPCOffset(
Error NativeProcessLinux::SetBreakpoint(lldb::addr_t addr, uint32_t size,
bool hardware) {
if (hardware)
- return Error("NativeProcessLinux does not support hardware breakpoints");
+ return SetHardwareBreakpoint(addr, size);
else
return SetSoftwareBreakpoint(addr, size);
}
+Error NativeProcessLinux::RemoveBreakpoint(lldb::addr_t addr, bool hardware) {
+ if (hardware)
+ return RemoveHardwareBreakpoint(addr);
+ else
+ return NativeProcessProtocol::RemoveBreakpoint(addr);
+}
+
Error NativeProcessLinux::GetSoftwareBreakpointTrapOpcode(
size_t trap_opcode_size_hint, size_t &actual_opcode_size,
const uint8_t *&trap_opcode_bytes) {
@@ -2154,40 +1982,30 @@ Error NativeProcessLinux::ReadMemory(lldb::addr_t addr, void *buf, size_t size,
bytes_read = process_vm_readv(pid, &local_iov, 1, &remote_iov, 1, 0);
const bool success = bytes_read == size;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
- if (log)
- log->Printf("NativeProcessLinux::%s using process_vm_readv to read %zd "
- "bytes from inferior address 0x%" PRIx64 ": %s",
- __FUNCTION__, size, addr,
- success ? "Success" : strerror(errno));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+ LLDB_LOG(log,
+ "using process_vm_readv to read {0} bytes from inferior "
+ "address {1:x}: {2}",
+ size, addr, success ? "Success" : strerror(errno));
if (success)
return Error();
- // else
- // the call failed for some reason, let's retry the read using ptrace
- // api.
+ // else the call failed for some reason, let's retry the read using ptrace
+ // api.
}
unsigned char *dst = static_cast<unsigned char *>(buf);
size_t remainder;
long data;
- Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_ALL));
- if (log)
- ProcessPOSIXLog::IncNestLevel();
- if (log && ProcessPOSIXLog::AtTopNestLevel() &&
- log->GetMask().Test(POSIX_LOG_MEMORY))
- log->Printf("NativeProcessLinux::%s(%p, %p, %zd, _)", __FUNCTION__,
- (void *)addr, buf, size);
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_MEMORY));
+ LLDB_LOG(log, "addr = {0}, buf = {1}, size = {2}", addr, buf, size);
for (bytes_read = 0; bytes_read < size; bytes_read += remainder) {
Error error = NativeProcessLinux::PtraceWrapper(
PTRACE_PEEKDATA, GetID(), (void *)addr, nullptr, 0, &data);
- if (error.Fail()) {
- if (log)
- ProcessPOSIXLog::DecNestLevel();
+ if (error.Fail())
return error;
- }
remainder = size - bytes_read;
remainder = remainder > k_ptrace_word_size ? k_ptrace_word_size : remainder;
@@ -2195,24 +2013,10 @@ Error NativeProcessLinux::ReadMemory(lldb::addr_t addr, void *buf, size_t size,
// Copy the data into our buffer
memcpy(dst, &data, remainder);
- if (log && ProcessPOSIXLog::AtTopNestLevel() &&
- (log->GetMask().Test(POSIX_LOG_MEMORY_DATA_LONG) ||
- (log->GetMask().Test(POSIX_LOG_MEMORY_DATA_SHORT) &&
- size <= POSIX_LOG_MEMORY_SHORT_BYTES))) {
- uintptr_t print_dst = 0;
- // Format bytes from data by moving into print_dst for log output
- for (unsigned i = 0; i < remainder; ++i)
- print_dst |= (((data >> i * 8) & 0xFF) << i * 8);
- log->Printf("NativeProcessLinux::%s() [0x%" PRIx64 "]:0x%" PRIx64
- " (0x%" PRIx64 ")",
- __FUNCTION__, addr, uint64_t(print_dst), uint64_t(data));
- }
+ LLDB_LOG(log, "[{0:x}]:{1:x}", addr, data);
addr += k_ptrace_word_size;
dst += k_ptrace_word_size;
}
-
- if (log)
- ProcessPOSIXLog::DecNestLevel();
return Error();
}
@@ -2231,13 +2035,8 @@ Error NativeProcessLinux::WriteMemory(lldb::addr_t addr, const void *buf,
size_t remainder;
Error error;
- Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_ALL));
- if (log)
- ProcessPOSIXLog::IncNestLevel();
- if (log && ProcessPOSIXLog::AtTopNestLevel() &&
- log->GetMask().Test(POSIX_LOG_MEMORY))
- log->Printf("NativeProcessLinux::%s(0x%" PRIx64 ", %p, %zu)", __FUNCTION__,
- addr, buf, size);
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_MEMORY));
+ LLDB_LOG(log, "addr = {0}, buf = {1}, size = {2}", addr, buf, size);
for (bytes_written = 0; bytes_written < size; bytes_written += remainder) {
remainder = size - bytes_written;
@@ -2247,54 +2046,32 @@ Error NativeProcessLinux::WriteMemory(lldb::addr_t addr, const void *buf,
unsigned long data = 0;
memcpy(&data, src, k_ptrace_word_size);
- if (log && ProcessPOSIXLog::AtTopNestLevel() &&
- (log->GetMask().Test(POSIX_LOG_MEMORY_DATA_LONG) ||
- (log->GetMask().Test(POSIX_LOG_MEMORY_DATA_SHORT) &&
- size <= POSIX_LOG_MEMORY_SHORT_BYTES)))
- log->Printf("NativeProcessLinux::%s() [%p]:0x%lx (0x%lx)", __FUNCTION__,
- (void *)addr, *(const unsigned long *)src, data);
-
+ LLDB_LOG(log, "[{0:x}]:{1:x}", addr, data);
error = NativeProcessLinux::PtraceWrapper(PTRACE_POKEDATA, GetID(),
(void *)addr, (void *)data);
- if (error.Fail()) {
- if (log)
- ProcessPOSIXLog::DecNestLevel();
+ if (error.Fail())
return error;
- }
} else {
unsigned char buff[8];
size_t bytes_read;
error = ReadMemory(addr, buff, k_ptrace_word_size, bytes_read);
- if (error.Fail()) {
- if (log)
- ProcessPOSIXLog::DecNestLevel();
+ if (error.Fail())
return error;
- }
memcpy(buff, src, remainder);
size_t bytes_written_rec;
error = WriteMemory(addr, buff, k_ptrace_word_size, bytes_written_rec);
- if (error.Fail()) {
- if (log)
- ProcessPOSIXLog::DecNestLevel();
+ if (error.Fail())
return error;
- }
- if (log && ProcessPOSIXLog::AtTopNestLevel() &&
- (log->GetMask().Test(POSIX_LOG_MEMORY_DATA_LONG) ||
- (log->GetMask().Test(POSIX_LOG_MEMORY_DATA_SHORT) &&
- size <= POSIX_LOG_MEMORY_SHORT_BYTES)))
- log->Printf("NativeProcessLinux::%s() [%p]:0x%lx (0x%lx)", __FUNCTION__,
- (void *)addr, *(const unsigned long *)src,
- *(unsigned long *)buff);
+ LLDB_LOG(log, "[{0:x}]:{1:x} ({2:x})", addr, *(const unsigned long *)src,
+ *(unsigned long *)buff);
}
addr += k_ptrace_word_size;
src += k_ptrace_word_size;
}
- if (log)
- ProcessPOSIXLog::DecNestLevel();
return error;
}
@@ -2328,14 +2105,10 @@ bool NativeProcessLinux::HasThreadNoLock(lldb::tid_t thread_id) {
}
bool NativeProcessLinux::StopTrackingThread(lldb::tid_t thread_id) {
- Log *const log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD);
-
- if (log)
- log->Printf("NativeProcessLinux::%s (tid: %" PRIu64 ")", __FUNCTION__,
- thread_id);
+ Log *const log = ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD);
+ LLDB_LOG(log, "tid: {0})", thread_id);
bool found = false;
-
for (auto it = m_threads.begin(); it != m_threads.end(); ++it) {
if (*it && ((*it)->GetID() == thread_id)) {
m_threads.erase(it);
@@ -2345,18 +2118,12 @@ bool NativeProcessLinux::StopTrackingThread(lldb::tid_t thread_id) {
}
SignalIfAllThreadsStopped();
-
return found;
}
NativeThreadLinuxSP NativeProcessLinux::AddThread(lldb::tid_t thread_id) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
-
- if (log) {
- log->Printf("NativeProcessLinux::%s pid %" PRIu64
- " adding thread with tid %" PRIu64,
- __FUNCTION__, GetID(), thread_id);
- }
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD));
+ LLDB_LOG(log, "pid {0} adding thread with tid {1}", GetID(), thread_id);
assert(!HasThreadNoLock(thread_id) &&
"attempted to add a thread by id that already exists");
@@ -2371,7 +2138,7 @@ NativeThreadLinuxSP NativeProcessLinux::AddThread(lldb::tid_t thread_id) {
}
Error NativeProcessLinux::FixupBreakpointPCAsNeeded(NativeThreadLinux &thread) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS));
Error error;
@@ -2380,24 +2147,17 @@ Error NativeProcessLinux::FixupBreakpointPCAsNeeded(NativeThreadLinux &thread) {
NativeRegisterContextSP context_sp = thread.GetRegisterContext();
if (!context_sp) {
error.SetErrorString("cannot get a NativeRegisterContext for the thread");
- if (log)
- log->Printf("NativeProcessLinux::%s failed: %s", __FUNCTION__,
- error.AsCString());
+ LLDB_LOG(log, "failed: {0}", error);
return error;
}
uint32_t breakpoint_size = 0;
error = GetSoftwareBreakpointPCOffset(breakpoint_size);
if (error.Fail()) {
- if (log)
- log->Printf("NativeProcessLinux::%s GetBreakpointSize() failed: %s",
- __FUNCTION__, error.AsCString());
+ LLDB_LOG(log, "GetBreakpointSize() failed: {0}", error);
return error;
- } else {
- if (log)
- log->Printf("NativeProcessLinux::%s breakpoint size: %" PRIu32,
- __FUNCTION__, breakpoint_size);
- }
+ } else
+ LLDB_LOG(log, "breakpoint size: {0}", breakpoint_size);
// First try probing for a breakpoint at a software breakpoint location: PC -
// breakpoint size.
@@ -2415,21 +2175,19 @@ Error NativeProcessLinux::FixupBreakpointPCAsNeeded(NativeThreadLinux &thread) {
error = m_breakpoint_list.GetBreakpoint(breakpoint_addr, breakpoint_sp);
if (!error.Success() || !breakpoint_sp) {
// We didn't find one at a software probe location. Nothing to do.
- if (log)
- log->Printf(
- "NativeProcessLinux::%s pid %" PRIu64
- " no lldb breakpoint found at current pc with adjustment: 0x%" PRIx64,
- __FUNCTION__, GetID(), breakpoint_addr);
+ LLDB_LOG(log,
+ "pid {0} no lldb breakpoint found at current pc with "
+ "adjustment: {1}",
+ GetID(), breakpoint_addr);
return Error();
}
// If the breakpoint is not a software breakpoint, nothing to do.
if (!breakpoint_sp->IsSoftwareBreakpoint()) {
- if (log)
- log->Printf("NativeProcessLinux::%s pid %" PRIu64
- " breakpoint found at 0x%" PRIx64
- ", not software, nothing to adjust",
- __FUNCTION__, GetID(), breakpoint_addr);
+ LLDB_LOG(
+ log,
+ "pid {0} breakpoint found at {1:x}, not software, nothing to adjust",
+ GetID(), breakpoint_addr);
return Error();
}
@@ -2440,28 +2198,21 @@ Error NativeProcessLinux::FixupBreakpointPCAsNeeded(NativeThreadLinux &thread) {
// Sanity check.
if (breakpoint_size == 0) {
// Nothing to do! How did we get here?
- if (log)
- log->Printf(
- "NativeProcessLinux::%s pid %" PRIu64
- " breakpoint found at 0x%" PRIx64
- ", it is software, but the size is zero, nothing to do (unexpected)",
- __FUNCTION__, GetID(), breakpoint_addr);
+ LLDB_LOG(log,
+ "pid {0} breakpoint found at {1:x}, it is software, but the "
+ "size is zero, nothing to do (unexpected)",
+ GetID(), breakpoint_addr);
return Error();
}
// Change the program counter.
- if (log)
- log->Printf("NativeProcessLinux::%s pid %" PRIu64 " tid %" PRIu64
- ": changing PC from 0x%" PRIx64 " to 0x%" PRIx64,
- __FUNCTION__, GetID(), thread.GetID(), initial_pc_addr,
- breakpoint_addr);
+ LLDB_LOG(log, "pid {0} tid {1}: changing PC from {2:x} to {3:x}", GetID(),
+ thread.GetID(), initial_pc_addr, breakpoint_addr);
error = context_sp->SetPC(breakpoint_addr);
if (error.Fail()) {
- if (log)
- log->Printf("NativeProcessLinux::%s pid %" PRIu64 " tid %" PRIu64
- ": failed to set PC: %s",
- __FUNCTION__, GetID(), thread.GetID(), error.AsCString());
+ LLDB_LOG(log, "pid {0} tid {1}: failed to set PC: {2}", GetID(),
+ thread.GetID(), error);
return error;
}
@@ -2511,11 +2262,8 @@ NativeThreadLinuxSP NativeProcessLinux::GetThreadByID(lldb::tid_t tid) {
Error NativeProcessLinux::ResumeThread(NativeThreadLinux &thread,
lldb::StateType state, int signo) {
- Log *const log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD);
-
- if (log)
- log->Printf("NativeProcessLinux::%s (tid: %" PRIu64 ")", __FUNCTION__,
- thread.GetID());
+ Log *const log = ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD);
+ LLDB_LOG(log, "tid: {0}", thread.GetID());
// Before we do the resume below, first check if we have a pending
// stop notification that is currently waiting for
@@ -2523,12 +2271,12 @@ Error NativeProcessLinux::ResumeThread(NativeThreadLinux &thread,
// we're ostensibly waiting for threads to stop before we send out the
// pending notification, and here we are resuming one before we send
// out the pending stop notification.
- if (m_pending_notification_tid != LLDB_INVALID_THREAD_ID && log) {
- log->Printf("NativeProcessLinux::%s about to resume tid %" PRIu64
- " per explicit request but we have a pending stop notification "
- "(tid %" PRIu64 ") that is actively waiting for this thread to "
- "stop. Valid sequence of events?",
- __FUNCTION__, thread.GetID(), m_pending_notification_tid);
+ if (m_pending_notification_tid != LLDB_INVALID_THREAD_ID) {
+ LLDB_LOG(log,
+ "about to resume tid {0} per explicit request but we have a "
+ "pending stop notification (tid {1}) that is actively "
+ "waiting for this thread to stop. Valid sequence of events?",
+ thread.GetID(), m_pending_notification_tid);
}
// Request a resume. We expect this to be synchronous and the system
@@ -2547,9 +2295,7 @@ Error NativeProcessLinux::ResumeThread(NativeThreadLinux &thread,
return step_result;
}
default:
- if (log)
- log->Printf("NativeProcessLinux::%s Unhandled state %s.", __FUNCTION__,
- StateAsCString(state));
+ LLDB_LOG(log, "Unhandled state {0}.", state);
llvm_unreachable("Unhandled state for resume");
}
}
@@ -2557,13 +2303,9 @@ Error NativeProcessLinux::ResumeThread(NativeThreadLinux &thread,
//===----------------------------------------------------------------------===//
void NativeProcessLinux::StopRunningThreads(const lldb::tid_t triggering_tid) {
- Log *const log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD);
-
- if (log) {
- log->Printf("NativeProcessLinux::%s about to process event: "
- "(triggering_tid: %" PRIu64 ")",
- __FUNCTION__, triggering_tid);
- }
+ Log *const log = ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD);
+ LLDB_LOG(log, "about to process event: (triggering_tid: {0})",
+ triggering_tid);
m_pending_notification_tid = triggering_tid;
@@ -2575,10 +2317,7 @@ void NativeProcessLinux::StopRunningThreads(const lldb::tid_t triggering_tid) {
}
SignalIfAllThreadsStopped();
-
- if (log) {
- log->Printf("NativeProcessLinux::%s event processing done", __FUNCTION__);
- }
+ LLDB_LOG(log, "event processing done");
}
void NativeProcessLinux::SignalIfAllThreadsStopped() {
@@ -2599,10 +2338,8 @@ void NativeProcessLinux::SignalIfAllThreadsStopped() {
for (const auto &thread_info : m_threads_stepping_with_breakpoint) {
Error error = RemoveBreakpoint(thread_info.second);
if (error.Fail())
- if (log)
- log->Printf("NativeProcessLinux::%s() pid = %" PRIu64
- " remove stepping breakpoint: %s",
- __FUNCTION__, thread_info.first, error.AsCString());
+ LLDB_LOG(log, "pid = {0} remove stepping breakpoint: {1}",
+ thread_info.first, error);
}
m_threads_stepping_with_breakpoint.clear();
@@ -2613,11 +2350,8 @@ void NativeProcessLinux::SignalIfAllThreadsStopped() {
}
void NativeProcessLinux::ThreadWasCreated(NativeThreadLinux &thread) {
- Log *const log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD);
-
- if (log)
- log->Printf("NativeProcessLinux::%s (tid: %" PRIu64 ")", __FUNCTION__,
- thread.GetID());
+ Log *const log = ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD);
+ LLDB_LOG(log, "tid: {0}", thread.GetID());
if (m_pending_notification_tid != LLDB_INVALID_THREAD_ID &&
StateIsRunningState(thread.GetState())) {
@@ -2629,7 +2363,7 @@ void NativeProcessLinux::ThreadWasCreated(NativeThreadLinux &thread) {
}
void NativeProcessLinux::SigchldHandler() {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
// Process all pending waitpid notifications.
while (true) {
int status = -1;
@@ -2643,10 +2377,7 @@ void NativeProcessLinux::SigchldHandler() {
continue;
Error error(errno, eErrorTypePOSIX);
- if (log)
- log->Printf("NativeProcessLinux::%s waitpid (-1, &status, __WALL | "
- "__WNOTHREAD | WNOHANG) failed: %s",
- __FUNCTION__, error.AsCString());
+ LLDB_LOG(log, "waitpid (-1, &status, _) failed: {0}", error);
break;
}
@@ -2671,13 +2402,10 @@ void NativeProcessLinux::SigchldHandler() {
} else
status_cstr = "(\?\?\?)";
- if (log)
- log->Printf("NativeProcessLinux::%s: waitpid (-1, &status, __WALL | "
- "__WNOTHREAD | WNOHANG)"
- "=> pid = %" PRIi32
- ", status = 0x%8.8x (%s), signal = %i, exit_state = %i",
- __FUNCTION__, wait_pid, status, status_cstr, signal,
- exit_status);
+ LLDB_LOG(log,
+ "waitpid (-1, &status, _) => pid = {0}, status = {1:x} "
+ "({2}), signal = {3}, exit_state = {4}",
+ wait_pid, status, status_cstr, signal, exit_status);
MonitorCallback(wait_pid, exited, signal, exit_status);
}
@@ -2710,32 +2438,13 @@ Error NativeProcessLinux::PtraceWrapper(int req, lldb::pid_t pid, void *addr,
if (result)
*result = ret;
- if (log)
- log->Printf("ptrace(%d, %" PRIu64 ", %p, %p, %zu)=%lX", req, pid, addr,
- data, data_size, ret);
+ LLDB_LOG(log, "ptrace({0}, {1}, {2}, {3}, {4})={5:x}", req, pid, addr, data,
+ data_size, ret);
PtraceDisplayBytes(req, data, data_size);
- if (log && error.GetError() != 0) {
- const char *str;
- switch (error.GetError()) {
- case ESRCH:
- str = "ESRCH";
- break;
- case EINVAL:
- str = "EINVAL";
- break;
- case EBUSY:
- str = "EBUSY";
- break;
- case EPERM:
- str = "EPERM";
- break;
- default:
- str = error.AsCString();
- }
- log->Printf("ptrace() failed; errno=%d (%s)", error.GetError(), str);
- }
+ if (error.Fail())
+ LLDB_LOG(log, "ptrace() failed: {0}", error);
return error;
}
diff --git a/source/Plugins/Process/Linux/NativeProcessLinux.h b/source/Plugins/Process/Linux/NativeProcessLinux.h
index 5f51a6bc138e..e4809d082b50 100644
--- a/source/Plugins/Process/Linux/NativeProcessLinux.h
+++ b/source/Plugins/Process/Linux/NativeProcessLinux.h
@@ -16,9 +16,10 @@
// Other libraries and framework includes
#include "lldb/Core/ArchSpec.h"
#include "lldb/Host/Debug.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/HostThread.h"
+#include "lldb/Host/linux/Support.h"
#include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Utility/FileSpec.h"
#include "lldb/lldb-types.h"
#include "NativeThreadLinux.h"
@@ -86,6 +87,8 @@ public:
Error SetBreakpoint(lldb::addr_t addr, uint32_t size, bool hardware) override;
+ Error RemoveBreakpoint(lldb::addr_t addr, bool hardware = false) override;
+
void DoStopIDBumped(uint32_t newBumpId) override;
Error GetLoadedModuleFileSpec(const char *module_path,
@@ -96,6 +99,11 @@ public:
NativeThreadLinuxSP GetThreadByID(lldb::tid_t id);
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+ GetAuxvData() const override {
+ return getProcFile(GetID(), "auxv");
+ }
+
// ---------------------------------------------------------------------
// Interface used by NativeRegisterContext-derived classes.
// ---------------------------------------------------------------------
diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
index 580d2f952ad1..be256e972215 100644
--- a/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
+++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
@@ -171,10 +171,7 @@ Error NativeRegisterContextLinux::DoReadRegisterValue(uint32_t offset,
// First cast to an unsigned of the same size to avoid sign extension.
value.SetUInt(static_cast<unsigned long>(data), size);
- if (log)
- log->Printf("NativeRegisterContextLinux::%s() reg %s: 0x%lx", __FUNCTION__,
- reg_name, data);
-
+ LLDB_LOG(log, "{0}: {1:x}", reg_name, data);
return error;
}
@@ -183,10 +180,7 @@ Error NativeRegisterContextLinux::DoWriteRegisterValue(
Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_REGISTERS));
void *buf = reinterpret_cast<void *>(value.GetAsUInt64());
-
- if (log)
- log->Printf("NativeRegisterContextLinux::%s() reg %s: %p", __FUNCTION__,
- reg_name, buf);
+ LLDB_LOG(log, "{0}: {1}", reg_name, buf);
return NativeProcessLinux::PtraceWrapper(
PTRACE_POKEUSER, m_thread.GetID(), reinterpret_cast<void *>(offset), buf);
diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux.h b/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
index a16c65b64a07..4dfc5365f357 100644
--- a/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
+++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
@@ -10,10 +10,10 @@
#ifndef lldb_NativeRegisterContextLinux_h
#define lldb_NativeRegisterContextLinux_h
-#include "lldb/Host/common/NativeRegisterContextRegisterInfo.h"
#include "lldb/Host/common/NativeThreadProtocol.h"
#include "Plugins/Process/Linux/NativeProcessLinux.h"
+#include "Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h"
namespace lldb_private {
namespace process_linux {
diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
index 9e857139cfca..2dd23ad75a03 100644
--- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
+++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
@@ -11,13 +11,14 @@
#include "NativeRegisterContextLinux_arm.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/RegisterValue.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
#include "Plugins/Process/Linux/Procfs.h"
-#include "Plugins/Process/Utility/RegisterContextLinux_arm.h"
+#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
+#include "Plugins/Process/Utility/RegisterInfoPOSIX_arm.h"
#include <elf.h>
#include <sys/socket.h>
@@ -108,7 +109,7 @@ NativeRegisterContextLinux_arm::NativeRegisterContextLinux_arm(
const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
uint32_t concrete_frame_idx)
: NativeRegisterContextLinux(native_thread, concrete_frame_idx,
- new RegisterContextLinux_arm(target_arch)) {
+ new RegisterInfoPOSIX_arm(target_arch)) {
switch (target_arch.GetMachine()) {
case llvm::Triple::arm:
m_reg_info.num_registers = k_num_registers_arm;
@@ -129,6 +130,7 @@ NativeRegisterContextLinux_arm::NativeRegisterContextLinux_arm(
::memset(&m_fpr, 0, sizeof(m_fpr));
::memset(&m_gpr_arm, 0, sizeof(m_gpr_arm));
::memset(&m_hwp_regs, 0, sizeof(m_hwp_regs));
+ ::memset(&m_hbr_regs, 0, sizeof(m_hbr_regs));
// 16 is just a maximum value, query hardware for actual watchpoint count
m_max_hwp_supported = 16;
@@ -353,10 +355,8 @@ bool NativeRegisterContextLinux_arm::IsFPR(unsigned reg) const {
return (m_reg_info.first_fpr <= reg && reg <= m_reg_info.last_fpr);
}
-uint32_t
-NativeRegisterContextLinux_arm::SetHardwareBreakpoint(lldb::addr_t addr,
- size_t size) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+uint32_t NativeRegisterContextLinux_arm::NumSupportedHardwareBreakpoints() {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS));
if (log)
log->Printf("NativeRegisterContextLinux_arm::%s()", __FUNCTION__);
@@ -367,77 +367,78 @@ NativeRegisterContextLinux_arm::SetHardwareBreakpoint(lldb::addr_t addr,
error = ReadHardwareDebugInfo();
if (error.Fail())
- return LLDB_INVALID_INDEX32;
+ return 0;
- uint32_t control_value = 0, bp_index = 0;
+ LLDB_LOG(log, "{0}", m_max_hbp_supported);
+ return m_max_hbp_supported;
+}
- // Check if size has a valid hardware breakpoint length.
- // Thumb instructions are 2-bytes but we have no way here to determine
- // if target address is a thumb or arm instruction.
- // TODO: Add support for setting thumb mode hardware breakpoints
- if (size != 4 && size != 2)
- return LLDB_INVALID_INDEX32;
+uint32_t
+NativeRegisterContextLinux_arm::SetHardwareBreakpoint(lldb::addr_t addr,
+ size_t size) {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS));
+ LLDB_LOG(log, "addr: {0:x}, size: {1:x}", addr, size);
- // Setup control value
- // Make the byte_mask into a valid Byte Address Select mask
- control_value = 0xfu << 5;
+ // Read hardware breakpoint and watchpoint information.
+ Error error = ReadHardwareDebugInfo();
- // Enable this breakpoint and make it stop in privileged or user mode;
- control_value |= 7;
+ if (error.Fail())
+ return LLDB_INVALID_INDEX32;
- // Make sure bits 1:0 are clear in our address
- // This should be different once we support thumb here.
- addr &= ~((lldb::addr_t)3);
+ uint32_t control_value = 0, bp_index = 0;
- // Iterate over stored hardware breakpoints
- // Find a free bp_index or update reference count if duplicate.
- bp_index = LLDB_INVALID_INDEX32;
+ // Setup address and control values.
+ // Use size to get a hint of arm vs thumb modes.
+ switch (size) {
+ case 2:
+ control_value = (0x3 << 5) | 7;
+ addr &= ~1;
+ break;
+ case 4:
+ control_value = (0xfu << 5) | 7;
+ addr &= ~3;
+ break;
+ default:
+ return LLDB_INVALID_INDEX32;
+ }
+ // Iterate over stored breakpoints and find a free bp_index
+ bp_index = LLDB_INVALID_INDEX32;
for (uint32_t i = 0; i < m_max_hbp_supported; i++) {
if ((m_hbr_regs[i].control & 1) == 0) {
bp_index = i; // Mark last free slot
- } else if (m_hbr_regs[i].address == addr &&
- m_hbr_regs[i].control == control_value) {
- bp_index = i; // Mark duplicate index
- break; // Stop searching here
+ } else if (m_hbr_regs[i].address == addr) {
+ return LLDB_INVALID_INDEX32; // We do not support duplicate breakpoints.
}
}
if (bp_index == LLDB_INVALID_INDEX32)
return LLDB_INVALID_INDEX32;
- // Add new or update existing breakpoint
- if ((m_hbr_regs[bp_index].control & 1) == 0) {
- m_hbr_regs[bp_index].address = addr;
- m_hbr_regs[bp_index].control = control_value;
- m_hbr_regs[bp_index].refcount = 1;
+ // Update breakpoint in local cache
+ m_hbr_regs[bp_index].real_addr = addr;
+ m_hbr_regs[bp_index].address = addr;
+ m_hbr_regs[bp_index].control = control_value;
- // PTRACE call to set corresponding hardware breakpoint register.
- error = WriteHardwareDebugRegs(eDREGTypeBREAK, bp_index);
+ // PTRACE call to set corresponding hardware breakpoint register.
+ error = WriteHardwareDebugRegs(eDREGTypeBREAK, bp_index);
- if (error.Fail()) {
- m_hbr_regs[bp_index].address = 0;
- m_hbr_regs[bp_index].control &= ~1;
- m_hbr_regs[bp_index].refcount = 0;
+ if (error.Fail()) {
+ m_hbr_regs[bp_index].address = 0;
+ m_hbr_regs[bp_index].control &= ~1;
- return LLDB_INVALID_INDEX32;
- }
- } else
- m_hbr_regs[bp_index].refcount++;
+ return LLDB_INVALID_INDEX32;
+ }
return bp_index;
}
bool NativeRegisterContextLinux_arm::ClearHardwareBreakpoint(uint32_t hw_idx) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-
- if (log)
- log->Printf("NativeRegisterContextLinux_arm::%s()", __FUNCTION__);
-
- Error error;
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS));
+ LLDB_LOG(log, "hw_idx: {0}", hw_idx);
// Read hardware breakpoint and watchpoint information.
- error = ReadHardwareDebugInfo();
+ Error error = ReadHardwareDebugInfo();
if (error.Fail())
return false;
@@ -445,39 +446,50 @@ bool NativeRegisterContextLinux_arm::ClearHardwareBreakpoint(uint32_t hw_idx) {
if (hw_idx >= m_max_hbp_supported)
return false;
- // Update reference count if multiple references.
- if (m_hbr_regs[hw_idx].refcount > 1) {
- m_hbr_regs[hw_idx].refcount--;
- return true;
- } else if (m_hbr_regs[hw_idx].refcount == 1) {
- // Create a backup we can revert to in case of failure.
- lldb::addr_t tempAddr = m_hbr_regs[hw_idx].address;
- uint32_t tempControl = m_hbr_regs[hw_idx].control;
- uint32_t tempRefCount = m_hbr_regs[hw_idx].refcount;
+ // Create a backup we can revert to in case of failure.
+ lldb::addr_t tempAddr = m_hbr_regs[hw_idx].address;
+ uint32_t tempControl = m_hbr_regs[hw_idx].control;
- m_hbr_regs[hw_idx].control &= ~1;
- m_hbr_regs[hw_idx].address = 0;
- m_hbr_regs[hw_idx].refcount = 0;
+ m_hbr_regs[hw_idx].control &= ~1;
+ m_hbr_regs[hw_idx].address = 0;
- // PTRACE call to clear corresponding hardware breakpoint register.
- WriteHardwareDebugRegs(eDREGTypeBREAK, hw_idx);
+ // PTRACE call to clear corresponding hardware breakpoint register.
+ error = WriteHardwareDebugRegs(eDREGTypeBREAK, hw_idx);
- if (error.Fail()) {
- m_hbr_regs[hw_idx].control = tempControl;
- m_hbr_regs[hw_idx].address = tempAddr;
- m_hbr_regs[hw_idx].refcount = tempRefCount;
+ if (error.Fail()) {
+ m_hbr_regs[hw_idx].control = tempControl;
+ m_hbr_regs[hw_idx].address = tempAddr;
- return false;
- }
+ return false;
+ }
- return true;
+ return true;
+}
+
+Error NativeRegisterContextLinux_arm::GetHardwareBreakHitIndex(
+ uint32_t &bp_index, lldb::addr_t trap_addr) {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS));
+
+ if (log)
+ log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
+
+ lldb::addr_t break_addr;
+
+ for (bp_index = 0; bp_index < m_max_hbp_supported; ++bp_index) {
+ break_addr = m_hbr_regs[bp_index].address;
+
+ if ((m_hbr_regs[bp_index].control & 0x1) && (trap_addr == break_addr)) {
+ m_hbr_regs[bp_index].hit_addr = trap_addr;
+ return Error();
+ }
}
- return false;
+ bp_index = LLDB_INVALID_INDEX32;
+ return Error();
}
-uint32_t NativeRegisterContextLinux_arm::NumSupportedHardwareWatchpoints() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+Error NativeRegisterContextLinux_arm::ClearAllHardwareBreakpoints() {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS));
if (log)
log->Printf("NativeRegisterContextLinux_arm::%s()", __FUNCTION__);
@@ -488,22 +500,57 @@ uint32_t NativeRegisterContextLinux_arm::NumSupportedHardwareWatchpoints() {
error = ReadHardwareDebugInfo();
if (error.Fail())
+ return error;
+
+ lldb::addr_t tempAddr = 0;
+ uint32_t tempControl = 0;
+
+ for (uint32_t i = 0; i < m_max_hbp_supported; i++) {
+ if (m_hbr_regs[i].control & 0x01) {
+ // Create a backup we can revert to in case of failure.
+ tempAddr = m_hbr_regs[i].address;
+ tempControl = m_hbr_regs[i].control;
+
+ // Clear breakpoints in local cache
+ m_hbr_regs[i].control &= ~1;
+ m_hbr_regs[i].address = 0;
+
+ // Ptrace call to update hardware debug registers
+ error = WriteHardwareDebugRegs(eDREGTypeBREAK, i);
+
+ if (error.Fail()) {
+ m_hbr_regs[i].control = tempControl;
+ m_hbr_regs[i].address = tempAddr;
+
+ return error;
+ }
+ }
+ }
+
+ return Error();
+}
+
+uint32_t NativeRegisterContextLinux_arm::NumSupportedHardwareWatchpoints() {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
+
+ // Read hardware breakpoint and watchpoint information.
+ Error error = ReadHardwareDebugInfo();
+
+ if (error.Fail())
return 0;
+ LLDB_LOG(log, "{0}", m_max_hwp_supported);
return m_max_hwp_supported;
}
uint32_t NativeRegisterContextLinux_arm::SetHardwareWatchpoint(
lldb::addr_t addr, size_t size, uint32_t watch_flags) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-
- if (log)
- log->Printf("NativeRegisterContextLinux_arm::%s()", __FUNCTION__);
-
- Error error;
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
+ LLDB_LOG(log, "addr: {0:x}, size: {1:x} watch_flags: {2:x}", addr, size,
+ watch_flags);
// Read hardware breakpoint and watchpoint information.
- error = ReadHardwareDebugInfo();
+ Error error = ReadHardwareDebugInfo();
if (error.Fail())
return LLDB_INVALID_INDEX32;
@@ -603,15 +650,11 @@ uint32_t NativeRegisterContextLinux_arm::SetHardwareWatchpoint(
bool NativeRegisterContextLinux_arm::ClearHardwareWatchpoint(
uint32_t wp_index) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-
- if (log)
- log->Printf("NativeRegisterContextLinux_arm::%s()", __FUNCTION__);
-
- Error error;
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
+ LLDB_LOG(log, "wp_index: {0}", wp_index);
// Read hardware breakpoint and watchpoint information.
- error = ReadHardwareDebugInfo();
+ Error error = ReadHardwareDebugInfo();
if (error.Fail())
return false;
@@ -641,15 +684,8 @@ bool NativeRegisterContextLinux_arm::ClearHardwareWatchpoint(
}
Error NativeRegisterContextLinux_arm::ClearAllHardwareWatchpoints() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-
- if (log)
- log->Printf("NativeRegisterContextLinux_arm::%s()", __FUNCTION__);
-
- Error error;
-
// Read hardware breakpoint and watchpoint information.
- error = ReadHardwareDebugInfo();
+ Error error = ReadHardwareDebugInfo();
if (error.Fail())
return error;
@@ -683,10 +719,8 @@ Error NativeRegisterContextLinux_arm::ClearAllHardwareWatchpoints() {
}
uint32_t NativeRegisterContextLinux_arm::GetWatchpointSize(uint32_t wp_index) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-
- if (log)
- log->Printf("NativeRegisterContextLinux_arm::%s()", __FUNCTION__);
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
+ LLDB_LOG(log, "wp_index: {0}", wp_index);
switch ((m_hwp_regs[wp_index].control >> 5) & 0x0f) {
case 0x01:
@@ -702,10 +736,8 @@ uint32_t NativeRegisterContextLinux_arm::GetWatchpointSize(uint32_t wp_index) {
}
}
bool NativeRegisterContextLinux_arm::WatchpointIsEnabled(uint32_t wp_index) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-
- if (log)
- log->Printf("NativeRegisterContextLinux_arm::%s()", __FUNCTION__);
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
+ LLDB_LOG(log, "wp_index: {0}", wp_index);
if ((m_hwp_regs[wp_index].control & 0x1) == 0x1)
return true;
@@ -715,10 +747,8 @@ bool NativeRegisterContextLinux_arm::WatchpointIsEnabled(uint32_t wp_index) {
Error NativeRegisterContextLinux_arm::GetWatchpointHitIndex(
uint32_t &wp_index, lldb::addr_t trap_addr) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-
- if (log)
- log->Printf("NativeRegisterContextLinux_arm::%s()", __FUNCTION__);
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
+ LLDB_LOG(log, "wp_index: {0}, trap_addr: {1:x}", wp_index, trap_addr);
uint32_t watch_size;
lldb::addr_t watch_addr;
@@ -740,10 +770,8 @@ Error NativeRegisterContextLinux_arm::GetWatchpointHitIndex(
lldb::addr_t
NativeRegisterContextLinux_arm::GetWatchpointAddress(uint32_t wp_index) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-
- if (log)
- log->Printf("NativeRegisterContextLinux_arm::%s()", __FUNCTION__);
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
+ LLDB_LOG(log, "wp_index: {0}", wp_index);
if (wp_index >= m_max_hwp_supported)
return LLDB_INVALID_ADDRESS;
@@ -756,10 +784,8 @@ NativeRegisterContextLinux_arm::GetWatchpointAddress(uint32_t wp_index) {
lldb::addr_t
NativeRegisterContextLinux_arm::GetWatchpointHitAddress(uint32_t wp_index) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-
- if (log)
- log->Printf("NativeRegisterContextLinux_arm::%s()", __FUNCTION__);
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
+ LLDB_LOG(log, "wp_index: {0}", wp_index);
if (wp_index >= m_max_hwp_supported)
return LLDB_INVALID_ADDRESS;
@@ -817,8 +843,8 @@ Error NativeRegisterContextLinux_arm::WriteHardwareDebugRegs(int hwbType,
(PTRACE_TYPE_ARG3)(intptr_t) - ((hwb_index << 1) + 2), ctrl_buf,
sizeof(unsigned int));
} else {
- addr_buf = &m_hwp_regs[hwb_index].address;
- ctrl_buf = &m_hwp_regs[hwb_index].control;
+ addr_buf = &m_hbr_regs[hwb_index].address;
+ ctrl_buf = &m_hbr_regs[hwb_index].control;
error = NativeProcessLinux::PtraceWrapper(
PTRACE_SETHBPREGS, m_thread.GetID(),
diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h
index f979811216dc..824ac88ad9ef 100644
--- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h
+++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h
@@ -46,10 +46,17 @@ public:
// Hardware breakpoints/watchpoint mangement functions
//------------------------------------------------------------------
+ uint32_t NumSupportedHardwareBreakpoints() override;
+
uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
bool ClearHardwareBreakpoint(uint32_t hw_idx) override;
+ Error ClearAllHardwareBreakpoints() override;
+
+ Error GetHardwareBreakHitIndex(uint32_t &bp_index,
+ lldb::addr_t trap_addr) override;
+
uint32_t NumSupportedHardwareWatchpoints() override;
uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size,
diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
index 786778e25a24..f3715147fa3e 100644
--- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
+++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
@@ -16,11 +16,11 @@
// C++ Includes
// Other libraries and framework includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Host/common/NativeProcessProtocol.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
#include "Plugins/Process/Linux/NativeProcessLinux.h"
#include "Plugins/Process/Linux/Procfs.h"
@@ -116,7 +116,6 @@ NativeRegisterContextLinux *
NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(
const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
uint32_t concrete_frame_idx) {
- Log *log = ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_REGISTERS);
switch (target_arch.GetMachine()) {
case llvm::Triple::arm:
return new NativeRegisterContextLinux_arm(target_arch, native_thread,
@@ -125,12 +124,7 @@ NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(
return new NativeRegisterContextLinux_arm64(target_arch, native_thread,
concrete_frame_idx);
default:
- if (log)
- log->Printf("NativeRegisterContextLinux::%s() have no register context "
- "for architecture: %s\n",
- __FUNCTION__,
- target_arch.GetTriple().getArchName().str().c_str());
- return nullptr;
+ llvm_unreachable("have no register context for architecture");
}
}
@@ -152,13 +146,14 @@ NativeRegisterContextLinux_arm64::NativeRegisterContextLinux_arm64(
m_reg_info.gpr_flags = gpr_cpsr_arm64;
break;
default:
- assert(false && "Unhandled target architecture.");
+ llvm_unreachable("Unhandled target architecture.");
break;
}
::memset(&m_fpr, 0, sizeof(m_fpr));
::memset(&m_gpr_arm64, 0, sizeof(m_gpr_arm64));
::memset(&m_hwp_regs, 0, sizeof(m_hwp_regs));
+ ::memset(&m_hbr_regs, 0, sizeof(m_hbr_regs));
// 16 is just a maximum value, query hardware for actual watchpoint count
m_max_hwp_supported = 16;
@@ -366,10 +361,8 @@ bool NativeRegisterContextLinux_arm64::IsFPR(unsigned reg) const {
return (m_reg_info.first_fpr <= reg && reg <= m_reg_info.last_fpr);
}
-uint32_t
-NativeRegisterContextLinux_arm64::SetHardwareBreakpoint(lldb::addr_t addr,
- size_t size) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+uint32_t NativeRegisterContextLinux_arm64::NumSupportedHardwareBreakpoints() {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS));
if (log)
log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
@@ -380,6 +373,21 @@ NativeRegisterContextLinux_arm64::SetHardwareBreakpoint(lldb::addr_t addr,
error = ReadHardwareDebugInfo();
if (error.Fail())
+ return 0;
+
+ return m_max_hbp_supported;
+}
+
+uint32_t
+NativeRegisterContextLinux_arm64::SetHardwareBreakpoint(lldb::addr_t addr,
+ size_t size) {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS));
+ LLDB_LOG(log, "addr: {0:x}, size: {1:x}", addr, size);
+
+ // Read hardware breakpoint and watchpoint information.
+ Error error = ReadHardwareDebugInfo();
+
+ if (error.Fail())
return LLDB_INVALID_INDEX32;
uint32_t control_value = 0, bp_index = 0;
@@ -398,55 +406,44 @@ NativeRegisterContextLinux_arm64::SetHardwareBreakpoint(lldb::addr_t addr,
control_value |= ((1 << size) - 1) << 5;
control_value |= (2 << 1) | 1;
- // Iterate over stored hardware breakpoints
- // Find a free bp_index or update reference count if duplicate.
+ // Iterate over stored breakpoints and find a free bp_index
bp_index = LLDB_INVALID_INDEX32;
for (uint32_t i = 0; i < m_max_hbp_supported; i++) {
if ((m_hbr_regs[i].control & 1) == 0) {
bp_index = i; // Mark last free slot
- } else if (m_hbr_regs[i].address == addr &&
- m_hbr_regs[i].control == control_value) {
- bp_index = i; // Mark duplicate index
- break; // Stop searching here
+ } else if (m_hbr_regs[i].address == addr) {
+ return LLDB_INVALID_INDEX32; // We do not support duplicate breakpoints.
}
}
if (bp_index == LLDB_INVALID_INDEX32)
return LLDB_INVALID_INDEX32;
- // Add new or update existing breakpoint
- if ((m_hbr_regs[bp_index].control & 1) == 0) {
- m_hbr_regs[bp_index].address = addr;
- m_hbr_regs[bp_index].control = control_value;
- m_hbr_regs[bp_index].refcount = 1;
+ // Update breakpoint in local cache
+ m_hbr_regs[bp_index].real_addr = addr;
+ m_hbr_regs[bp_index].address = addr;
+ m_hbr_regs[bp_index].control = control_value;
- // PTRACE call to set corresponding hardware breakpoint register.
- error = WriteHardwareDebugRegs(eDREGTypeBREAK);
+ // PTRACE call to set corresponding hardware breakpoint register.
+ error = WriteHardwareDebugRegs(eDREGTypeBREAK);
- if (error.Fail()) {
- m_hbr_regs[bp_index].address = 0;
- m_hbr_regs[bp_index].control &= ~1;
- m_hbr_regs[bp_index].refcount = 0;
+ if (error.Fail()) {
+ m_hbr_regs[bp_index].address = 0;
+ m_hbr_regs[bp_index].control &= ~1;
- return LLDB_INVALID_INDEX32;
- }
- } else
- m_hbr_regs[bp_index].refcount++;
+ return LLDB_INVALID_INDEX32;
+ }
return bp_index;
}
bool NativeRegisterContextLinux_arm64::ClearHardwareBreakpoint(
uint32_t hw_idx) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-
- if (log)
- log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
-
- Error error;
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS));
+ LLDB_LOG(log, "hw_idx: {0}", hw_idx);
// Read hardware breakpoint and watchpoint information.
- error = ReadHardwareDebugInfo();
+ Error error = ReadHardwareDebugInfo();
if (error.Fail())
return false;
@@ -454,39 +451,50 @@ bool NativeRegisterContextLinux_arm64::ClearHardwareBreakpoint(
if (hw_idx >= m_max_hbp_supported)
return false;
- // Update reference count if multiple references.
- if (m_hbr_regs[hw_idx].refcount > 1) {
- m_hbr_regs[hw_idx].refcount--;
- return true;
- } else if (m_hbr_regs[hw_idx].refcount == 1) {
- // Create a backup we can revert to in case of failure.
- lldb::addr_t tempAddr = m_hbr_regs[hw_idx].address;
- uint32_t tempControl = m_hbr_regs[hw_idx].control;
- uint32_t tempRefCount = m_hbr_regs[hw_idx].refcount;
+ // Create a backup we can revert to in case of failure.
+ lldb::addr_t tempAddr = m_hbr_regs[hw_idx].address;
+ uint32_t tempControl = m_hbr_regs[hw_idx].control;
- m_hbr_regs[hw_idx].control &= ~1;
- m_hbr_regs[hw_idx].address = 0;
- m_hbr_regs[hw_idx].refcount = 0;
+ m_hbr_regs[hw_idx].control &= ~1;
+ m_hbr_regs[hw_idx].address = 0;
- // PTRACE call to clear corresponding hardware breakpoint register.
- WriteHardwareDebugRegs(eDREGTypeBREAK);
+ // PTRACE call to clear corresponding hardware breakpoint register.
+ error = WriteHardwareDebugRegs(eDREGTypeBREAK);
- if (error.Fail()) {
- m_hbr_regs[hw_idx].control = tempControl;
- m_hbr_regs[hw_idx].address = tempAddr;
- m_hbr_regs[hw_idx].refcount = tempRefCount;
+ if (error.Fail()) {
+ m_hbr_regs[hw_idx].control = tempControl;
+ m_hbr_regs[hw_idx].address = tempAddr;
- return false;
- }
+ return false;
+ }
- return true;
+ return true;
+}
+
+Error NativeRegisterContextLinux_arm64::GetHardwareBreakHitIndex(
+ uint32_t &bp_index, lldb::addr_t trap_addr) {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS));
+
+ if (log)
+ log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
+
+ lldb::addr_t break_addr;
+
+ for (bp_index = 0; bp_index < m_max_hbp_supported; ++bp_index) {
+ break_addr = m_hbr_regs[bp_index].address;
+
+ if ((m_hbr_regs[bp_index].control & 0x1) && (trap_addr == break_addr)) {
+ m_hbr_regs[bp_index].hit_addr = trap_addr;
+ return Error();
+ }
}
- return false;
+ bp_index = LLDB_INVALID_INDEX32;
+ return Error();
}
-uint32_t NativeRegisterContextLinux_arm64::NumSupportedHardwareWatchpoints() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+Error NativeRegisterContextLinux_arm64::ClearAllHardwareBreakpoints() {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS));
if (log)
log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
@@ -497,22 +505,57 @@ uint32_t NativeRegisterContextLinux_arm64::NumSupportedHardwareWatchpoints() {
error = ReadHardwareDebugInfo();
if (error.Fail())
+ return error;
+
+ lldb::addr_t tempAddr = 0;
+ uint32_t tempControl = 0;
+
+ for (uint32_t i = 0; i < m_max_hbp_supported; i++) {
+ if (m_hbr_regs[i].control & 0x01) {
+ // Create a backup we can revert to in case of failure.
+ tempAddr = m_hbr_regs[i].address;
+ tempControl = m_hbr_regs[i].control;
+
+ // Clear watchpoints in local cache
+ m_hbr_regs[i].control &= ~1;
+ m_hbr_regs[i].address = 0;
+
+ // Ptrace call to update hardware debug registers
+ error = WriteHardwareDebugRegs(eDREGTypeBREAK);
+
+ if (error.Fail()) {
+ m_hbr_regs[i].control = tempControl;
+ m_hbr_regs[i].address = tempAddr;
+
+ return error;
+ }
+ }
+ }
+
+ return Error();
+}
+
+uint32_t NativeRegisterContextLinux_arm64::NumSupportedHardwareWatchpoints() {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
+
+ // Read hardware breakpoint and watchpoint information.
+ Error error = ReadHardwareDebugInfo();
+
+ if (error.Fail())
return 0;
+ LLDB_LOG(log, "{0}", m_max_hwp_supported);
return m_max_hwp_supported;
}
uint32_t NativeRegisterContextLinux_arm64::SetHardwareWatchpoint(
lldb::addr_t addr, size_t size, uint32_t watch_flags) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-
- if (log)
- log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
-
- Error error;
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
+ LLDB_LOG(log, "addr: {0:x}, size: {1:x} watch_flags: {2:x}", addr, size,
+ watch_flags);
// Read hardware breakpoint and watchpoint information.
- error = ReadHardwareDebugInfo();
+ Error error = ReadHardwareDebugInfo();
if (error.Fail())
return LLDB_INVALID_INDEX32;
@@ -595,15 +638,11 @@ uint32_t NativeRegisterContextLinux_arm64::SetHardwareWatchpoint(
bool NativeRegisterContextLinux_arm64::ClearHardwareWatchpoint(
uint32_t wp_index) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-
- if (log)
- log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
-
- Error error;
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
+ LLDB_LOG(log, "wp_index: {0}", wp_index);
// Read hardware breakpoint and watchpoint information.
- error = ReadHardwareDebugInfo();
+ Error error = ReadHardwareDebugInfo();
if (error.Fail())
return false;
@@ -633,15 +672,8 @@ bool NativeRegisterContextLinux_arm64::ClearHardwareWatchpoint(
}
Error NativeRegisterContextLinux_arm64::ClearAllHardwareWatchpoints() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-
- if (log)
- log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
-
- Error error;
-
// Read hardware breakpoint and watchpoint information.
- error = ReadHardwareDebugInfo();
+ Error error = ReadHardwareDebugInfo();
if (error.Fail())
return error;
@@ -676,10 +708,9 @@ Error NativeRegisterContextLinux_arm64::ClearAllHardwareWatchpoints() {
uint32_t
NativeRegisterContextLinux_arm64::GetWatchpointSize(uint32_t wp_index) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
+ LLDB_LOG(log, "wp_index: {0}", wp_index);
- if (log)
- log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
switch ((m_hwp_regs[wp_index].control >> 5) & 0xff) {
case 0x01:
return 1;
@@ -694,10 +725,8 @@ NativeRegisterContextLinux_arm64::GetWatchpointSize(uint32_t wp_index) {
}
}
bool NativeRegisterContextLinux_arm64::WatchpointIsEnabled(uint32_t wp_index) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-
- if (log)
- log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
+ LLDB_LOG(log, "wp_index: {0}", wp_index);
if ((m_hwp_regs[wp_index].control & 0x1) == 0x1)
return true;
@@ -707,10 +736,8 @@ bool NativeRegisterContextLinux_arm64::WatchpointIsEnabled(uint32_t wp_index) {
Error NativeRegisterContextLinux_arm64::GetWatchpointHitIndex(
uint32_t &wp_index, lldb::addr_t trap_addr) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-
- if (log)
- log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
+ LLDB_LOG(log, "wp_index: {0}, trap_addr: {1:x}", wp_index, trap_addr);
uint32_t watch_size;
lldb::addr_t watch_addr;
@@ -732,10 +759,8 @@ Error NativeRegisterContextLinux_arm64::GetWatchpointHitIndex(
lldb::addr_t
NativeRegisterContextLinux_arm64::GetWatchpointAddress(uint32_t wp_index) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-
- if (log)
- log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
+ LLDB_LOG(log, "wp_index: {0}", wp_index);
if (wp_index >= m_max_hwp_supported)
return LLDB_INVALID_ADDRESS;
@@ -748,10 +773,8 @@ NativeRegisterContextLinux_arm64::GetWatchpointAddress(uint32_t wp_index) {
lldb::addr_t
NativeRegisterContextLinux_arm64::GetWatchpointHitAddress(uint32_t wp_index) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
-
- if (log)
- log->Printf("NativeRegisterContextLinux_arm64::%s()", __FUNCTION__);
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
+ LLDB_LOG(log, "wp_index: {0}", wp_index);
if (wp_index >= m_max_hwp_supported)
return LLDB_INVALID_ADDRESS;
diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
index c46c375acfe7..4ffbd97ee33a 100644
--- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
+++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
@@ -46,10 +46,17 @@ public:
// Hardware breakpoints/watchpoint mangement functions
//------------------------------------------------------------------
+ uint32_t NumSupportedHardwareBreakpoints() override;
+
uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
bool ClearHardwareBreakpoint(uint32_t hw_idx) override;
+ Error ClearAllHardwareBreakpoints() override;
+
+ Error GetHardwareBreakHitIndex(uint32_t &bp_index,
+ lldb::addr_t trap_addr) override;
+
uint32_t NumSupportedHardwareWatchpoints() override;
uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size,
diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
index c050a2ec0cc6..7c5c42477170 100644
--- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
+++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
@@ -17,16 +17,17 @@
// Other libraries and framework includes
#include "Plugins/Process/Linux/NativeProcessLinux.h"
#include "Plugins/Process/Linux/Procfs.h"
+#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
#include "Plugins/Process/Utility/RegisterContextLinux_mips.h"
#include "Plugins/Process/Utility/RegisterContextLinux_mips64.h"
-#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/EmulateInstruction.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Error.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-private-enumerations.h"
#define NT_MIPS_MSA 0x600
@@ -71,157 +72,14 @@ struct pt_watch_regs {
#define IRW (I | R | W)
+#ifndef PTRACE_GETREGSET
+#define PTRACE_GETREGSET 0x4204
+#endif
struct pt_watch_regs default_watch_regs;
using namespace lldb_private;
using namespace lldb_private::process_linux;
-// ----------------------------------------------------------------------------
-// Private namespace.
-// ----------------------------------------------------------------------------
-
-namespace {
-// mips general purpose registers.
-const uint32_t g_gp_regnums_mips[] = {
- gpr_zero_mips, gpr_r1_mips, gpr_r2_mips, gpr_r3_mips,
- gpr_r4_mips, gpr_r5_mips, gpr_r6_mips, gpr_r7_mips,
- gpr_r8_mips, gpr_r9_mips, gpr_r10_mips, gpr_r11_mips,
- gpr_r12_mips, gpr_r13_mips, gpr_r14_mips, gpr_r15_mips,
- gpr_r16_mips, gpr_r17_mips, gpr_r18_mips, gpr_r19_mips,
- gpr_r20_mips, gpr_r21_mips, gpr_r22_mips, gpr_r23_mips,
- gpr_r24_mips, gpr_r25_mips, gpr_r26_mips, gpr_r27_mips,
- gpr_gp_mips, gpr_sp_mips, gpr_r30_mips, gpr_ra_mips,
- gpr_sr_mips, gpr_mullo_mips, gpr_mulhi_mips, gpr_badvaddr_mips,
- gpr_cause_mips, gpr_pc_mips, gpr_config5_mips,
- LLDB_INVALID_REGNUM // register sets need to end with this flag
-};
-
-static_assert((sizeof(g_gp_regnums_mips) / sizeof(g_gp_regnums_mips[0])) - 1 ==
- k_num_gpr_registers_mips,
- "g_gp_regnums_mips has wrong number of register infos");
-
-// mips floating point registers.
-const uint32_t g_fp_regnums_mips[] = {
- fpr_f0_mips, fpr_f1_mips, fpr_f2_mips, fpr_f3_mips,
- fpr_f4_mips, fpr_f5_mips, fpr_f6_mips, fpr_f7_mips,
- fpr_f8_mips, fpr_f9_mips, fpr_f10_mips, fpr_f11_mips,
- fpr_f12_mips, fpr_f13_mips, fpr_f14_mips, fpr_f15_mips,
- fpr_f16_mips, fpr_f17_mips, fpr_f18_mips, fpr_f19_mips,
- fpr_f20_mips, fpr_f21_mips, fpr_f22_mips, fpr_f23_mips,
- fpr_f24_mips, fpr_f25_mips, fpr_f26_mips, fpr_f27_mips,
- fpr_f28_mips, fpr_f29_mips, fpr_f30_mips, fpr_f31_mips,
- fpr_fcsr_mips, fpr_fir_mips, fpr_config5_mips,
- LLDB_INVALID_REGNUM // register sets need to end with this flag
-};
-
-static_assert((sizeof(g_fp_regnums_mips) / sizeof(g_fp_regnums_mips[0])) - 1 ==
- k_num_fpr_registers_mips,
- "g_fp_regnums_mips has wrong number of register infos");
-
-// mips MSA registers.
-const uint32_t g_msa_regnums_mips[] = {
- msa_w0_mips, msa_w1_mips, msa_w2_mips, msa_w3_mips,
- msa_w4_mips, msa_w5_mips, msa_w6_mips, msa_w7_mips,
- msa_w8_mips, msa_w9_mips, msa_w10_mips, msa_w11_mips,
- msa_w12_mips, msa_w13_mips, msa_w14_mips, msa_w15_mips,
- msa_w16_mips, msa_w17_mips, msa_w18_mips, msa_w19_mips,
- msa_w20_mips, msa_w21_mips, msa_w22_mips, msa_w23_mips,
- msa_w24_mips, msa_w25_mips, msa_w26_mips, msa_w27_mips,
- msa_w28_mips, msa_w29_mips, msa_w30_mips, msa_w31_mips,
- msa_fcsr_mips, msa_fir_mips, msa_mcsr_mips, msa_mir_mips,
- msa_config5_mips,
- LLDB_INVALID_REGNUM // register sets need to end with this flag
-};
-
-static_assert((sizeof(g_msa_regnums_mips) / sizeof(g_msa_regnums_mips[0])) -
- 1 ==
- k_num_msa_registers_mips,
- "g_msa_regnums_mips has wrong number of register infos");
-
-// mips64 general purpose registers.
-const uint32_t g_gp_regnums_mips64[] = {
- gpr_zero_mips64, gpr_r1_mips64, gpr_r2_mips64,
- gpr_r3_mips64, gpr_r4_mips64, gpr_r5_mips64,
- gpr_r6_mips64, gpr_r7_mips64, gpr_r8_mips64,
- gpr_r9_mips64, gpr_r10_mips64, gpr_r11_mips64,
- gpr_r12_mips64, gpr_r13_mips64, gpr_r14_mips64,
- gpr_r15_mips64, gpr_r16_mips64, gpr_r17_mips64,
- gpr_r18_mips64, gpr_r19_mips64, gpr_r20_mips64,
- gpr_r21_mips64, gpr_r22_mips64, gpr_r23_mips64,
- gpr_r24_mips64, gpr_r25_mips64, gpr_r26_mips64,
- gpr_r27_mips64, gpr_gp_mips64, gpr_sp_mips64,
- gpr_r30_mips64, gpr_ra_mips64, gpr_sr_mips64,
- gpr_mullo_mips64, gpr_mulhi_mips64, gpr_badvaddr_mips64,
- gpr_cause_mips64, gpr_pc_mips64, gpr_config5_mips64,
- LLDB_INVALID_REGNUM // register sets need to end with this flag
-};
-
-static_assert((sizeof(g_gp_regnums_mips64) / sizeof(g_gp_regnums_mips64[0])) -
- 1 ==
- k_num_gpr_registers_mips64,
- "g_gp_regnums_mips64 has wrong number of register infos");
-
-// mips64 floating point registers.
-const uint32_t g_fp_regnums_mips64[] = {
- fpr_f0_mips64, fpr_f1_mips64, fpr_f2_mips64, fpr_f3_mips64,
- fpr_f4_mips64, fpr_f5_mips64, fpr_f6_mips64, fpr_f7_mips64,
- fpr_f8_mips64, fpr_f9_mips64, fpr_f10_mips64, fpr_f11_mips64,
- fpr_f12_mips64, fpr_f13_mips64, fpr_f14_mips64, fpr_f15_mips64,
- fpr_f16_mips64, fpr_f17_mips64, fpr_f18_mips64, fpr_f19_mips64,
- fpr_f20_mips64, fpr_f21_mips64, fpr_f22_mips64, fpr_f23_mips64,
- fpr_f24_mips64, fpr_f25_mips64, fpr_f26_mips64, fpr_f27_mips64,
- fpr_f28_mips64, fpr_f29_mips64, fpr_f30_mips64, fpr_f31_mips64,
- fpr_fcsr_mips64, fpr_fir_mips64, fpr_config5_mips64,
- LLDB_INVALID_REGNUM // register sets need to end with this flag
-};
-
-static_assert((sizeof(g_fp_regnums_mips64) / sizeof(g_fp_regnums_mips64[0])) -
- 1 ==
- k_num_fpr_registers_mips64,
- "g_fp_regnums_mips64 has wrong number of register infos");
-
-// mips64 MSA registers.
-const uint32_t g_msa_regnums_mips64[] = {
- msa_w0_mips64, msa_w1_mips64, msa_w2_mips64, msa_w3_mips64,
- msa_w4_mips64, msa_w5_mips64, msa_w6_mips64, msa_w7_mips64,
- msa_w8_mips64, msa_w9_mips64, msa_w10_mips64, msa_w11_mips64,
- msa_w12_mips64, msa_w13_mips64, msa_w14_mips64, msa_w15_mips64,
- msa_w16_mips64, msa_w17_mips64, msa_w18_mips64, msa_w19_mips64,
- msa_w20_mips64, msa_w21_mips64, msa_w22_mips64, msa_w23_mips64,
- msa_w24_mips64, msa_w25_mips64, msa_w26_mips64, msa_w27_mips64,
- msa_w28_mips64, msa_w29_mips64, msa_w30_mips64, msa_w31_mips64,
- msa_fcsr_mips64, msa_fir_mips64, msa_mcsr_mips64, msa_mir_mips64,
- msa_config5_mips64,
- LLDB_INVALID_REGNUM // register sets need to end with this flag
-};
-
-static_assert((sizeof(g_msa_regnums_mips64) / sizeof(g_msa_regnums_mips64[0])) -
- 1 ==
- k_num_msa_registers_mips64,
- "g_msa_regnums_mips64 has wrong number of register infos");
-
-// Number of register sets provided by this context.
-enum { k_num_register_sets = 3 };
-
-// Register sets for mips.
-static const RegisterSet g_reg_sets_mips[k_num_register_sets] = {
- {"General Purpose Registers", "gpr", k_num_gpr_registers_mips,
- g_gp_regnums_mips},
- {"Floating Point Registers", "fpu", k_num_fpr_registers_mips,
- g_fp_regnums_mips},
- {"MSA Registers", "msa", k_num_msa_registers_mips, g_msa_regnums_mips}};
-
-// Register sets for mips64.
-static const RegisterSet g_reg_sets_mips64[k_num_register_sets] = {
- {"General Purpose Registers", "gpr", k_num_gpr_registers_mips64,
- g_gp_regnums_mips64},
- {"Floating Point Registers", "fpu", k_num_fpr_registers_mips64,
- g_fp_regnums_mips64},
- {"MSA Registers", "msa", k_num_msa_registers_mips64, g_msa_regnums_mips64},
-};
-
-} // end of anonymous namespace
-
NativeRegisterContextLinux *
NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(
const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
@@ -240,15 +98,12 @@ NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(
static RegisterInfoInterface *
CreateRegisterInfoInterface(const ArchSpec &target_arch) {
- if (HostInfo::GetArchitecture().GetAddressByteSize() == 4) {
+ if ((target_arch.GetMachine() == llvm::Triple::mips) ||
+ (target_arch.GetMachine() == llvm::Triple::mipsel)) {
// 32-bit hosts run with a RegisterContextLinux_mips context.
return new RegisterContextLinux_mips(
target_arch, NativeRegisterContextLinux_mips64::IsMSAAvailable());
} else {
- assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) &&
- "Register setting path assumes this is a 64-bit host");
- // mips64 hosts know how to work with 64-bit and 32-bit EXEs using the
- // mips64 register context.
return new RegisterContextLinux_mips64(
target_arch, NativeRegisterContextLinux_mips64::IsMSAAvailable());
}
@@ -303,7 +158,22 @@ NativeRegisterContextLinux_mips64::NativeRegisterContextLinux_mips64(
}
uint32_t NativeRegisterContextLinux_mips64::GetRegisterSetCount() const {
- return k_num_register_sets;
+ switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) {
+ case llvm::Triple::mips64:
+ case llvm::Triple::mips64el: {
+ const auto context = static_cast<const RegisterContextLinux_mips64 &>
+ (GetRegisterInfoInterface());
+ return context.GetRegisterSetCount();
+ }
+ case llvm::Triple::mips:
+ case llvm::Triple::mipsel: {
+ const auto context = static_cast<const RegisterContextLinux_mips &>
+ (GetRegisterInfoInterface());
+ return context.GetRegisterSetCount();
+ }
+ default:
+ llvm_unreachable("Unhandled target architecture.");
+ }
}
lldb::addr_t NativeRegisterContextLinux_mips64::GetPCfromBreakpointLocation(
@@ -311,12 +181,8 @@ lldb::addr_t NativeRegisterContextLinux_mips64::GetPCfromBreakpointLocation(
Error error;
RegisterValue pc_value;
lldb::addr_t pc = fail_value;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
-
- if (log)
- log->Printf("NativeRegisterContextLinux_mips64::%s Reading PC from "
- "breakpoint location",
- __FUNCTION__);
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS));
+ LLDB_LOG(log, "Reading PC from breakpoint location");
// PC register is at index 34 of the register array
const RegisterInfo *const pc_info_p = GetRegisterInfoAtIndex(gpr_pc_mips64);
@@ -333,11 +199,7 @@ lldb::addr_t NativeRegisterContextLinux_mips64::GetPCfromBreakpointLocation(
ReadRegister(cause_info_p, cause_value);
uint64_t cause = cause_value.GetAsUInt64();
-
- if (log)
- log->Printf("NativeRegisterContextLinux_mips64::%s PC 0x%" PRIx64
- " Cause 0x%" PRIx64,
- __FUNCTION__, pc, cause);
+ LLDB_LOG(log, "PC {0:x} cause {1:x}", pc, cause);
/*
* The breakpoint might be in a delay slot. In this case PC points
@@ -352,10 +214,7 @@ lldb::addr_t NativeRegisterContextLinux_mips64::GetPCfromBreakpointLocation(
pc = pc + branch_delay;
pc_value.SetUInt64(pc);
WriteRegister(pc_info_p, pc_value);
-
- if (log)
- log->Printf("NativeRegisterContextLinux_mips64::%s New PC 0x%" PRIx64,
- __FUNCTION__, pc);
+ LLDB_LOG(log, "New PC {0:x}", pc);
}
}
@@ -364,22 +223,25 @@ lldb::addr_t NativeRegisterContextLinux_mips64::GetPCfromBreakpointLocation(
const RegisterSet *
NativeRegisterContextLinux_mips64::GetRegisterSet(uint32_t set_index) const {
- if (set_index >= k_num_register_sets)
+ if (set_index >= GetRegisterSetCount())
return nullptr;
switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) {
case llvm::Triple::mips64:
- case llvm::Triple::mips64el:
- return &g_reg_sets_mips64[set_index];
+ case llvm::Triple::mips64el: {
+ const auto context = static_cast<const RegisterContextLinux_mips64 &>
+ (GetRegisterInfoInterface());
+ return context.GetRegisterSet(set_index);
+ }
case llvm::Triple::mips:
- case llvm::Triple::mipsel:
- return &g_reg_sets_mips[set_index];
+ case llvm::Triple::mipsel: {
+ const auto context = static_cast<const RegisterContextLinux_mips &>
+ (GetRegisterInfoInterface());
+ return context.GetRegisterSet(set_index);
+ }
default:
- assert(false && "Unhandled target architecture.");
- return nullptr;
+ llvm_unreachable("Unhandled target architecture.");
}
-
- return nullptr;
}
lldb_private::Error
@@ -727,70 +589,64 @@ bool NativeRegisterContextLinux_mips64::IsFPR(uint32_t reg_index) const {
}
static uint32_t GetWatchHi(struct pt_watch_regs *regs, uint32_t index) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
if (regs->style == pt_watch_style_mips32)
return regs->mips32.watchhi[index];
else if (regs->style == pt_watch_style_mips64)
return regs->mips64.watchhi[index];
- if (log)
- log->Printf("Invalid watch register style");
+ LLDB_LOG(log, "Invalid watch register style");
return 0;
}
static void SetWatchHi(struct pt_watch_regs *regs, uint32_t index,
uint16_t value) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
if (regs->style == pt_watch_style_mips32)
regs->mips32.watchhi[index] = value;
else if (regs->style == pt_watch_style_mips64)
regs->mips64.watchhi[index] = value;
- if (log)
- log->Printf("Invalid watch register style");
+ LLDB_LOG(log, "Invalid watch register style");
return;
}
static lldb::addr_t GetWatchLo(struct pt_watch_regs *regs, uint32_t index) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
if (regs->style == pt_watch_style_mips32)
return regs->mips32.watchlo[index];
else if (regs->style == pt_watch_style_mips64)
return regs->mips64.watchlo[index];
- if (log)
- log->Printf("Invalid watch register style");
+ LLDB_LOG(log, "Invalid watch register style");
return LLDB_INVALID_ADDRESS;
}
static void SetWatchLo(struct pt_watch_regs *regs, uint32_t index,
uint64_t value) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
if (regs->style == pt_watch_style_mips32)
regs->mips32.watchlo[index] = (uint32_t)value;
else if (regs->style == pt_watch_style_mips64)
regs->mips64.watchlo[index] = value;
- if (log)
- log->Printf("Invalid watch register style");
- return;
+ else
+ LLDB_LOG(log, "Invalid watch register style");
}
static uint32_t GetIRWMask(struct pt_watch_regs *regs, uint32_t index) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
if (regs->style == pt_watch_style_mips32)
return regs->mips32.watch_masks[index] & IRW;
else if (regs->style == pt_watch_style_mips64)
return regs->mips64.watch_masks[index] & IRW;
- if (log)
- log->Printf("Invalid watch register style");
+ LLDB_LOG(log, "Invalid watch register style");
return 0;
}
static uint32_t GetRegMask(struct pt_watch_regs *regs, uint32_t index) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
if (regs->style == pt_watch_style_mips32)
return regs->mips32.watch_masks[index] & ~IRW;
else if (regs->style == pt_watch_style_mips64)
return regs->mips64.watch_masks[index] & ~IRW;
- if (log)
- log->Printf("Invalid watch register style");
+ LLDB_LOG(log, "Invalid watch register style");
return 0;
}
@@ -1114,7 +970,7 @@ NativeRegisterContextLinux_mips64::GetWatchpointHitAddress(uint32_t wp_index) {
}
uint32_t NativeRegisterContextLinux_mips64::NumSupportedHardwareWatchpoints() {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_WATCHPOINTS));
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_WATCHPOINTS));
struct pt_watch_regs regs;
static int num_valid = 0;
if (!num_valid) {
@@ -1128,12 +984,8 @@ uint32_t NativeRegisterContextLinux_mips64::NumSupportedHardwareWatchpoints() {
case pt_watch_style_mips64:
num_valid = regs.mips64.num_valid;
return num_valid;
- default:
- if (log)
- log->Printf("NativeRegisterContextLinux_mips64::%s Error: Unrecognized "
- "watch register style",
- __FUNCTION__);
}
+ LLDB_LOG(log, "Invalid watch register style");
return 0;
}
return num_valid;
diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp
index 7ec4dc551fac..3e782d39f72e 100644
--- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp
+++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp
@@ -11,11 +11,11 @@
#include "NativeRegisterContextLinux_s390x.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
#include "Plugins/Process/Utility/RegisterContextLinux_s390x.h"
diff --git a/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp b/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
index 2bd819b456ab..dd35705a8ae8 100755
--- a/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
+++ b/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
@@ -11,11 +11,11 @@
#include "NativeRegisterContextLinux_x86_64.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
#include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
#include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
diff --git a/source/Plugins/Process/Linux/NativeThreadLinux.cpp b/source/Plugins/Process/Linux/NativeThreadLinux.cpp
index d18d3c16d2c9..04b6fe6d71e9 100644
--- a/source/Plugins/Process/Linux/NativeThreadLinux.cpp
+++ b/source/Plugins/Process/Linux/NativeThreadLinux.cpp
@@ -16,11 +16,12 @@
#include "NativeRegisterContextLinux.h"
#include "SingleStepCheck.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/State.h"
#include "lldb/Host/HostNativeThread.h"
#include "lldb/Host/linux/Ptrace.h"
+#include "lldb/Host/linux/Support.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
#include "lldb/lldb-enumerations.h"
#include "llvm/ADT/SmallString.h"
@@ -90,15 +91,12 @@ NativeThreadLinux::NativeThreadLinux(NativeProcessLinux *process,
m_stop_info(), m_reg_context_sp(), m_stop_description() {}
std::string NativeThreadLinux::GetName() {
- NativeProcessProtocolSP process_sp = m_process_wp.lock();
- if (!process_sp)
- return "<unknown: no process>";
+ NativeProcessLinux &process = GetProcess();
- // const NativeProcessLinux *const process =
- // reinterpret_cast<NativeProcessLinux*> (process_sp->get ());
- llvm::SmallString<32> thread_name;
- HostNativeThread::GetName(GetID(), thread_name);
- return thread_name.c_str();
+ auto BufferOrError = getProcFile(process.GetID(), GetID(), "comm");
+ if (!BufferOrError)
+ return "";
+ return BufferOrError.get()->getBuffer().rtrim('\n');
}
lldb::StateType NativeThreadLinux::GetState() { return m_state; }
@@ -190,6 +188,38 @@ Error NativeThreadLinux::RemoveWatchpoint(lldb::addr_t addr) {
return Error("Clearing hardware watchpoint failed.");
}
+Error NativeThreadLinux::SetHardwareBreakpoint(lldb::addr_t addr, size_t size) {
+ if (m_state == eStateLaunching)
+ return Error();
+
+ Error error = RemoveHardwareBreakpoint(addr);
+ if (error.Fail())
+ return error;
+
+ NativeRegisterContextSP reg_ctx = GetRegisterContext();
+ uint32_t bp_index = reg_ctx->SetHardwareBreakpoint(addr, size);
+
+ if (bp_index == LLDB_INVALID_INDEX32)
+ return Error("Setting hardware breakpoint failed.");
+
+ m_hw_break_index_map.insert({addr, bp_index});
+ return Error();
+}
+
+Error NativeThreadLinux::RemoveHardwareBreakpoint(lldb::addr_t addr) {
+ auto bp = m_hw_break_index_map.find(addr);
+ if (bp == m_hw_break_index_map.end())
+ return Error();
+
+ uint32_t bp_index = bp->second;
+ if (GetRegisterContext()->ClearHardwareBreakpoint(bp_index)) {
+ m_hw_break_index_map.erase(bp);
+ return Error();
+ }
+
+ return Error("Clearing hardware breakpoint failed.");
+}
+
Error NativeThreadLinux::Resume(uint32_t signo) {
const StateType new_state = StateType::eStateRunning;
MaybeLogStateChange(new_state);
@@ -211,6 +241,18 @@ Error NativeThreadLinux::Resume(uint32_t signo) {
}
}
+ // Set all active hardware breakpoint on all threads.
+ if (m_hw_break_index_map.empty()) {
+ NativeProcessLinux &process = GetProcess();
+
+ const auto &hw_breakpoint_map = process.GetHardwareBreakpointMap();
+ GetRegisterContext()->ClearAllHardwareBreakpoints();
+ for (const auto &pair : hw_breakpoint_map) {
+ const auto &bp = pair.second;
+ SetHardwareBreakpoint(bp.m_addr, bp.m_size);
+ }
+ }
+
intptr_t data = 0;
if (signo != LLDB_INVALID_SIGNAL_NUMBER)
@@ -220,63 +262,18 @@ Error NativeThreadLinux::Resume(uint32_t signo) {
reinterpret_cast<void *>(data));
}
-void NativeThreadLinux::MaybePrepareSingleStepWorkaround() {
- if (!SingleStepWorkaroundNeeded())
- return;
-
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
-
- if (sched_getaffinity(static_cast<::pid_t>(m_tid), sizeof m_original_cpu_set,
- &m_original_cpu_set) != 0) {
- // This should really not fail. But, just in case...
- if (log) {
- Error error(errno, eErrorTypePOSIX);
- log->Printf(
- "NativeThreadLinux::%s Unable to get cpu affinity for thread %" PRIx64
- ": %s",
- __FUNCTION__, m_tid, error.AsCString());
- }
- return;
- }
-
- cpu_set_t set;
- CPU_ZERO(&set);
- CPU_SET(0, &set);
- if (sched_setaffinity(static_cast<::pid_t>(m_tid), sizeof set, &set) != 0 &&
- log) {
- // This may fail in very locked down systems, if the thread is not allowed
- // to run on
- // cpu 0. If that happens, only thing we can do is it log it and continue...
- Error error(errno, eErrorTypePOSIX);
- log->Printf(
- "NativeThreadLinux::%s Unable to set cpu affinity for thread %" PRIx64
- ": %s",
- __FUNCTION__, m_tid, error.AsCString());
- }
-}
-
-void NativeThreadLinux::MaybeCleanupSingleStepWorkaround() {
- if (!SingleStepWorkaroundNeeded())
- return;
-
- if (sched_setaffinity(static_cast<::pid_t>(m_tid), sizeof m_original_cpu_set,
- &m_original_cpu_set) != 0) {
- Error error(errno, eErrorTypePOSIX);
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
- log->Printf(
- "NativeThreadLinux::%s Unable to reset cpu affinity for thread %" PRIx64
- ": %s",
- __FUNCTION__, m_tid, error.AsCString());
- }
-}
-
Error NativeThreadLinux::SingleStep(uint32_t signo) {
const StateType new_state = StateType::eStateStepping;
MaybeLogStateChange(new_state);
m_state = new_state;
m_stop_info.reason = StopReason::eStopReasonNone;
- MaybePrepareSingleStepWorkaround();
+ if(!m_step_workaround) {
+ // If we already hava a workaround inplace, don't reset it. Otherwise, the
+ // destructor of the existing instance will run after the new instance has
+ // fetched the cpu mask, and the thread will end up with the wrong mask.
+ m_step_workaround = SingleStepWorkaround::Get(m_tid);
+ }
intptr_t data = 0;
if (signo != LLDB_INVALID_SIGNAL_NUMBER)
@@ -338,7 +335,7 @@ bool NativeThreadLinux::IsStopped(int *signo) {
void NativeThreadLinux::SetStopped() {
if (m_state == StateType::eStateStepping)
- MaybeCleanupSingleStepWorkaround();
+ m_step_workaround.reset();
const StateType new_state = StateType::eStateStopped;
MaybeLogStateChange(new_state);
diff --git a/source/Plugins/Process/Linux/NativeThreadLinux.h b/source/Plugins/Process/Linux/NativeThreadLinux.h
index f170bb1e8508..42697497c0af 100644
--- a/source/Plugins/Process/Linux/NativeThreadLinux.h
+++ b/source/Plugins/Process/Linux/NativeThreadLinux.h
@@ -10,11 +10,10 @@
#ifndef liblldb_NativeThreadLinux_H_
#define liblldb_NativeThreadLinux_H_
+#include "SingleStepCheck.h"
#include "lldb/Host/common/NativeThreadProtocol.h"
#include "lldb/lldb-private-forward.h"
-#include <sched.h>
-
#include <map>
#include <memory>
#include <string>
@@ -47,6 +46,10 @@ public:
Error RemoveWatchpoint(lldb::addr_t addr) override;
+ Error SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
+
+ Error RemoveHardwareBreakpoint(lldb::addr_t addr) override;
+
private:
// ---------------------------------------------------------------------
// Interface for friend classes
@@ -94,10 +97,6 @@ private:
void SetStopped();
- inline void MaybePrepareSingleStepWorkaround();
-
- inline void MaybeCleanupSingleStepWorkaround();
-
// ---------------------------------------------------------------------
// Member Variables
// ---------------------------------------------------------------------
@@ -107,7 +106,8 @@ private:
std::string m_stop_description;
using WatchpointIndexMap = std::map<lldb::addr_t, uint32_t>;
WatchpointIndexMap m_watchpoint_index_map;
- cpu_set_t m_original_cpu_set; // For single-step workaround.
+ WatchpointIndexMap m_hw_break_index_map;
+ std::unique_ptr<SingleStepWorkaround> m_step_workaround;
};
typedef std::shared_ptr<NativeThreadLinux> NativeThreadLinuxSP;
diff --git a/source/Plugins/Process/Linux/ProcFileReader.cpp b/source/Plugins/Process/Linux/ProcFileReader.cpp
deleted file mode 100644
index a1bb7a6e09d5..000000000000
--- a/source/Plugins/Process/Linux/ProcFileReader.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-//===-- ProcFileReader.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/Process/Linux/ProcFileReader.h"
-
-// C Headers
-#include <fcntl.h>
-#include <inttypes.h>
-#include <limits.h>
-#include <stdio.h>
-#include <sys/stat.h>
-
-// C++ Headers
-#include <fstream>
-
-// LLDB Headers
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
-
-using namespace lldb_private;
-using namespace lldb_private::process_linux;
-
-lldb::DataBufferSP ProcFileReader::ReadIntoDataBuffer(lldb::pid_t pid,
- const char *name) {
- int fd;
- char path[PATH_MAX];
-
- // Make sure we've got a nil terminated buffer for all the folks calling
- // GetBytes() directly off our returned DataBufferSP if we hit an error.
- lldb::DataBufferSP buf_sp(new DataBufferHeap(1, 0));
-
- // Ideally, we would simply create a FileSpec and call ReadFileContents.
- // However, files in procfs have zero size (since they are, in general,
- // dynamically generated by the kernel) which is incompatible with the
- // current ReadFileContents implementation. Therefore we simply stream the
- // data into a DataBuffer ourselves.
- if (snprintf(path, PATH_MAX, "/proc/%" PRIu64 "/%s", pid, name) > 0) {
- if ((fd = open(path, O_RDONLY, 0)) >= 0) {
- size_t bytes_read = 0;
- std::unique_ptr<DataBufferHeap> buf_ap(new DataBufferHeap(1024, 0));
-
- for (;;) {
- size_t avail = buf_ap->GetByteSize() - bytes_read;
- ssize_t status = read(fd, buf_ap->GetBytes() + bytes_read, avail);
-
- if (status < 0)
- break;
-
- if (status == 0) {
- buf_ap->SetByteSize(bytes_read);
- buf_sp.reset(buf_ap.release());
- break;
- }
-
- bytes_read += status;
-
- if (avail - status == 0)
- buf_ap->SetByteSize(2 * buf_ap->GetByteSize());
- }
-
- close(fd);
- }
- }
-
- return buf_sp;
-}
-
-Error ProcFileReader::ProcessLineByLine(
- lldb::pid_t pid, const char *name,
- std::function<bool(const std::string &line)> line_parser) {
- Error error;
-
- // Try to open the /proc/{pid}/maps entry.
- char filename[PATH_MAX];
- snprintf(filename, sizeof(filename), "/proc/%" PRIu64 "/%s", pid, name);
- filename[sizeof(filename) - 1] = '\0';
-
- std::ifstream proc_file(filename);
- if (proc_file.fail()) {
- error.SetErrorStringWithFormat("failed to open file '%s'", filename);
- return error;
- }
-
- // Read the file line by line, processing until either end of file or when the
- // line_parser returns false.
- std::string line;
- bool should_continue = true;
-
- while (should_continue && std::getline(proc_file, line)) {
- // Pass the line over to the line_parser for processing. If the line_parser
- // returns false, we
- // stop processing.
- should_continue = line_parser(line);
- }
-
- return error;
-}
diff --git a/source/Plugins/Process/Linux/ProcFileReader.h b/source/Plugins/Process/Linux/ProcFileReader.h
deleted file mode 100644
index dcdb3553d8c3..000000000000
--- a/source/Plugins/Process/Linux/ProcFileReader.h
+++ /dev/null
@@ -1,37 +0,0 @@
-//===-- ProcFileReader.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_ProcFileReader_h_
-#define liblldb_ProcFileReader_h_
-
-#include <functional>
-
-#include "lldb/lldb-forward.h"
-#include "lldb/lldb-types.h"
-
-namespace lldb_private {
-namespace process_linux {
-
-class ProcFileReader {
-public:
- static lldb::DataBufferSP ReadIntoDataBuffer(lldb::pid_t pid,
- const char *name);
-
- /// Parse the /proc/{@a pid}/{@a name} file line by line, passing each line to
- /// line_parser, until
- /// either end of file or until line_parser returns false.
- static Error
- ProcessLineByLine(lldb::pid_t pid, const char *name,
- std::function<bool(const std::string &line)> line_parser);
-};
-
-} // namespace process_linux
-} // namespace lldb_private
-
-#endif // #ifndef liblldb_ProcFileReader_h_
diff --git a/source/Plugins/Process/Linux/SingleStepCheck.cpp b/source/Plugins/Process/Linux/SingleStepCheck.cpp
index b23c1bd245d5..4e979bd45532 100644
--- a/source/Plugins/Process/Linux/SingleStepCheck.cpp
+++ b/source/Plugins/Process/Linux/SingleStepCheck.cpp
@@ -18,10 +18,12 @@
#include "llvm/Support/Compiler.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
+#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
#include "lldb/Host/linux/Ptrace.h"
+#include "lldb/Utility/Error.h"
+using namespace lldb;
+using namespace lldb_private;
using namespace lldb_private::process_linux;
#if defined(__arm64__) || defined(__aarch64__)
@@ -32,16 +34,14 @@ void LLVM_ATTRIBUTE_NORETURN Child() {
_exit(1);
// We just do an endless loop SIGSTOPPING ourselves until killed. The tracer
- // will fiddle with our cpu
- // affinities and monitor the behaviour.
+ // will fiddle with our cpu affinities and monitor the behaviour.
for (;;) {
raise(SIGSTOP);
// Generate a bunch of instructions here, so that a single-step does not
- // land in the
- // raise() accidentally. If single-stepping works, we will be spinning in
- // this loop. If
- // it doesn't, we'll land in the raise() call above.
+ // land in the raise() accidentally. If single-stepping works, we will be
+ // spinning in this loop. If it doesn't, we'll land in the raise() call
+ // above.
for (volatile unsigned i = 0; i < CPU_SETSIZE; ++i)
;
}
@@ -57,25 +57,16 @@ struct ChildDeleter {
}
};
-} // end anonymous namespace
-
-bool impl::SingleStepWorkaroundNeeded() {
+bool WorkaroundNeeded() {
// We shall spawn a child, and use it to verify the debug capabilities of the
- // cpu. We shall
- // iterate through the cpus, bind the child to each one in turn, and verify
- // that
- // single-stepping works on that cpu. A workaround is needed if we find at
- // least one broken
- // cpu.
+ // cpu. We shall iterate through the cpus, bind the child to each one in turn,
+ // and verify that single-stepping works on that cpu. A workaround is needed
+ // if we find at least one broken cpu.
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_THREAD));
- Error error;
+ Log *log = ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD);
::pid_t child_pid = fork();
if (child_pid == -1) {
- if (log) {
- error.SetErrorToErrno();
- log->Printf("%s failed to fork(): %s", __FUNCTION__, error.AsCString());
- }
+ LLDB_LOG(log, "failed to fork(): {0}", Error(errno, eErrorTypePOSIX));
return false;
}
if (child_pid == 0)
@@ -85,22 +76,16 @@ bool impl::SingleStepWorkaroundNeeded() {
cpu_set_t available_cpus;
if (sched_getaffinity(child_pid, sizeof available_cpus, &available_cpus) ==
-1) {
- if (log) {
- error.SetErrorToErrno();
- log->Printf("%s failed to get available cpus: %s", __FUNCTION__,
- error.AsCString());
- }
+ LLDB_LOG(log, "failed to get available cpus: {0}",
+ Error(errno, eErrorTypePOSIX));
return false;
}
int status;
::pid_t wpid = waitpid(child_pid, &status, __WALL);
if (wpid != child_pid || !WIFSTOPPED(status)) {
- if (log) {
- error.SetErrorToErrno();
- log->Printf("%s waitpid() failed (status = %x): %s", __FUNCTION__, status,
- error.AsCString());
- }
+ LLDB_LOG(log, "waitpid() failed (status = {0:x}): {1}", status,
+ Error(errno, eErrorTypePOSIX));
return false;
}
@@ -113,46 +98,37 @@ bool impl::SingleStepWorkaroundNeeded() {
CPU_ZERO(&cpus);
CPU_SET(cpu, &cpus);
if (sched_setaffinity(child_pid, sizeof cpus, &cpus) == -1) {
- if (log) {
- error.SetErrorToErrno();
- log->Printf("%s failed to switch to cpu %u: %s", __FUNCTION__, cpu,
- error.AsCString());
- }
+ LLDB_LOG(log, "failed to switch to cpu {0}: {1}", cpu,
+ Error(errno, eErrorTypePOSIX));
continue;
}
int status;
- error = NativeProcessLinux::PtraceWrapper(PTRACE_SINGLESTEP, child_pid);
+ Error error =
+ NativeProcessLinux::PtraceWrapper(PTRACE_SINGLESTEP, child_pid);
if (error.Fail()) {
- if (log)
- log->Printf("%s single step failed: %s", __FUNCTION__,
- error.AsCString());
+ LLDB_LOG(log, "single step failed: {0}", error);
break;
}
wpid = waitpid(child_pid, &status, __WALL);
if (wpid != child_pid || !WIFSTOPPED(status)) {
- if (log) {
- error.SetErrorToErrno();
- log->Printf("%s waitpid() failed (status = %x): %s", __FUNCTION__,
- status, error.AsCString());
- }
+ LLDB_LOG(log, "waitpid() failed (status = {0:x}): {1}", status,
+ Error(errno, eErrorTypePOSIX));
break;
}
if (WSTOPSIG(status) != SIGTRAP) {
- if (log)
- log->Printf("%s single stepping on cpu %d failed with status %x",
- __FUNCTION__, cpu, status);
+ LLDB_LOG(log, "single stepping on cpu {0} failed with status {1:x}", cpu,
+ status);
break;
}
}
// cpu is either the index of the first broken cpu, or CPU_SETSIZE.
if (cpu == 0) {
- if (log)
- log->Printf("%s SINGLE STEPPING ON FIRST CPU IS NOT WORKING. DEBUGGING "
- "LIKELY TO BE UNRELIABLE.",
- __FUNCTION__);
+ LLDB_LOG(log,
+ "SINGLE STEPPING ON FIRST CPU IS NOT WORKING. DEBUGGING "
+ "LIKELY TO BE UNRELIABLE.");
// No point in trying to fiddle with the affinities, just give it our best
// shot and see how it goes.
return false;
@@ -161,6 +137,46 @@ bool impl::SingleStepWorkaroundNeeded() {
return cpu != CPU_SETSIZE;
}
-#else // !arm64
-bool impl::SingleStepWorkaroundNeeded() { return false; }
+} // end anonymous namespace
+
+std::unique_ptr<SingleStepWorkaround> SingleStepWorkaround::Get(::pid_t tid) {
+ Log *log = ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD);
+
+ static bool workaround_needed = WorkaroundNeeded();
+ if (!workaround_needed) {
+ LLDB_LOG(log, "workaround for thread {0} not needed", tid);
+ return nullptr;
+ }
+
+ cpu_set_t original_set;
+ if (sched_getaffinity(tid, sizeof original_set, &original_set) != 0) {
+ // This should really not fail. But, just in case...
+ LLDB_LOG(log, "Unable to get cpu affinity for thread {0}: {1}", tid,
+ Error(errno, eErrorTypePOSIX));
+ return nullptr;
+ }
+
+ cpu_set_t set;
+ CPU_ZERO(&set);
+ CPU_SET(0, &set);
+ if (sched_setaffinity(tid, sizeof set, &set) != 0) {
+ // This may fail in very locked down systems, if the thread is not allowed
+ // to run on cpu 0. If that happens, only thing we can do is it log it and
+ // continue...
+ LLDB_LOG(log, "Unable to set cpu affinity for thread {0}: {1}", tid,
+ Error(errno, eErrorTypePOSIX));
+ }
+
+ LLDB_LOG(log, "workaround for thread {0} prepared", tid);
+ return llvm::make_unique<SingleStepWorkaround>(tid, original_set);
+}
+
+SingleStepWorkaround::~SingleStepWorkaround() {
+ Log *log = ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD);
+ LLDB_LOG(log, "Removing workaround");
+ if (sched_setaffinity(m_tid, sizeof m_original_set, &m_original_set) != 0) {
+ LLDB_LOG(log, "Unable to reset cpu affinity for thread {0}: {1}", m_tid,
+ Error(errno, eErrorTypePOSIX));
+ }
+}
#endif
diff --git a/source/Plugins/Process/Linux/SingleStepCheck.h b/source/Plugins/Process/Linux/SingleStepCheck.h
index 6e3310da840b..afeda7310349 100644
--- a/source/Plugins/Process/Linux/SingleStepCheck.h
+++ b/source/Plugins/Process/Linux/SingleStepCheck.h
@@ -10,30 +10,47 @@
#ifndef liblldb_SingleStepCheck_H_
#define liblldb_SingleStepCheck_H_
+#include <memory>
+#include <sched.h>
+#include <sys/types.h>
+
namespace lldb_private {
namespace process_linux {
-namespace impl {
-extern bool SingleStepWorkaroundNeeded();
-}
-
// arm64 linux had a bug which prevented single-stepping and watchpoints from
-// working on non-boot
-// cpus, due to them being incorrectly initialized after coming out of suspend.
-// This issue is
-// particularly affecting android M, which uses suspend ("doze mode") quite
-// aggressively. This
-// code detects that situation and makes single-stepping work by doing all the
-// step operations on
+// working on non-boot cpus, due to them being incorrectly initialized after
+// coming out of suspend. This issue is particularly affecting android M, which
+// uses suspend ("doze mode") quite aggressively. This code detects that
+// situation and makes single-stepping work by doing all the step operations on
// the boot cpu.
//
// The underlying issue has been fixed in android N and linux 4.4. This code can
-// be removed once
-// these systems become obsolete.
-inline bool SingleStepWorkaroundNeeded() {
- static bool value = impl::SingleStepWorkaroundNeeded();
- return value;
-}
+// be removed once these systems become obsolete.
+
+#if defined(__arm64__) || defined(__aarch64__)
+class SingleStepWorkaround {
+ ::pid_t m_tid;
+ cpu_set_t m_original_set;
+
+ SingleStepWorkaround(const SingleStepWorkaround &) = delete;
+ void operator=(const SingleStepWorkaround &) = delete;
+
+public:
+ SingleStepWorkaround(::pid_t tid, cpu_set_t original_set)
+ : m_tid(tid), m_original_set(original_set) {}
+ ~SingleStepWorkaround();
+
+ static std::unique_ptr<SingleStepWorkaround> Get(::pid_t tid);
+};
+#else
+class SingleStepWorkaround {
+public:
+ static std::unique_ptr<SingleStepWorkaround> Get(::pid_t tid) {
+ return nullptr;
+ }
+};
+#endif
+
} // end namespace process_linux
} // end namespace lldb_private
diff --git a/source/Plugins/Process/MacOSX-Kernel/CMakeLists.txt b/source/Plugins/Process/MacOSX-Kernel/CMakeLists.txt
index 681b7405e2b8..bed0e3b7ab37 100644
--- a/source/Plugins/Process/MacOSX-Kernel/CMakeLists.txt
+++ b/source/Plugins/Process/MacOSX-Kernel/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_lldb_library(lldbPluginProcessMacOSXKernel
+add_lldb_library(lldbPluginProcessMacOSXKernel PLUGIN
CommunicationKDP.cpp
ProcessKDP.cpp
ProcessKDPLog.cpp
@@ -7,4 +7,16 @@ add_lldb_library(lldbPluginProcessMacOSXKernel
RegisterContextKDP_i386.cpp
RegisterContextKDP_x86_64.cpp
ThreadKDP.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbHost
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ lldbPluginDynamicLoaderDarwinKernel
+ lldbPluginDynamicLoaderStatic
+ lldbPluginProcessUtility
)
diff --git a/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp b/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
index 43e4617feafc..da0ed9aa0c6a 100644
--- a/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
+++ b/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
@@ -17,14 +17,15 @@
// C++ Includes
// Other libraries and framework includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Core/DumpDataExtractor.h"
#include "lldb/Core/State.h"
-#include "lldb/Core/UUID.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/UUID.h"
// Project includes
#include "ProcessKDPLog.h"
@@ -200,8 +201,7 @@ size_t CommunicationKDP::WaitForPacketWithTimeoutMicroSecondsNoLock(
uint8_t buffer[8192];
Error error;
- Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PACKETS |
- KDP_LOG_VERBOSE));
+ Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_PACKETS));
// Check for a packet from our cache first without trying any reading...
if (CheckForPacket(NULL, 0, packet))
@@ -216,12 +216,12 @@ size_t CommunicationKDP::WaitForPacketWithTimeoutMicroSecondsNoLock(
: std::chrono::microseconds(timeout_usec),
status, &error);
- if (log)
- log->Printf("%s: Read (buffer, (sizeof(buffer), timeout_usec = 0x%x, "
- "status = %s, error = %s) => bytes_read = %" PRIu64,
- LLVM_PRETTY_FUNCTION, timeout_usec,
+ LLDB_LOGV(log,
+ "Read (buffer, sizeof(buffer), timeout_usec = 0x{0:x}, "
+ "status = {1}, error = {2}) => bytes_read = {4}",
+ timeout_usec,
Communication::ConnectionStatusAsCString(status),
- error.AsCString(), (uint64_t)bytes_read);
+ error, bytes_read);
if (bytes_read > 0) {
if (CheckForPacket(buffer, bytes_read, packet))
@@ -260,8 +260,7 @@ bool CommunicationKDP::CheckForPacket(const uint8_t *src, size_t src_len,
if (src && src_len > 0) {
if (log && log->GetVerbose()) {
PacketStreamType log_strm;
- DataExtractor::DumpHexBytes(&log_strm, src, src_len, UINT32_MAX,
- LLDB_INVALID_ADDRESS);
+ DumpHexBytes(&log_strm, src, src_len, UINT32_MAX, LLDB_INVALID_ADDRESS);
log->Printf("CommunicationKDP::%s adding %u bytes: %s", __FUNCTION__,
(uint32_t)src_len, log_strm.GetData());
}
@@ -860,15 +859,17 @@ void CommunicationKDP::DumpPacket(Stream &s, const DataExtractor &packet) {
const uint32_t count = packet.GetByteSize() - offset;
s.Printf(" (error = 0x%8.8x:\n", error);
if (count > 0)
- packet.Dump(&s, // Stream to dump to
- offset, // Offset within "packet"
- eFormatBytesWithASCII, // Format to use
- 1, // Size of each item in bytes
- count, // Number of items
- 16, // Number per line
- m_last_read_memory_addr, // Don't show addresses before
- // each line
- 0, 0); // No bitfields
+ DumpDataExtractor(packet,
+ &s, // Stream to dump to
+ offset, // Offset within "packet"
+ eFormatBytesWithASCII, // Format to use
+ 1, // Size of each item
+ // in bytes
+ count, // Number of items
+ 16, // Number per line
+ m_last_read_memory_addr, // Don't show addresses
+ // before each line
+ 0, 0); // No bitfields
} break;
case KDP_READREGS: {
@@ -876,15 +877,19 @@ void CommunicationKDP::DumpPacket(Stream &s, const DataExtractor &packet) {
const uint32_t count = packet.GetByteSize() - offset;
s.Printf(" (error = 0x%8.8x regs:\n", error);
if (count > 0)
- packet.Dump(
- &s, // Stream to dump to
- offset, // Offset within "packet"
- eFormatHex, // Format to use
- m_addr_byte_size, // Size of each item in bytes
- count / m_addr_byte_size, // Number of items
- 16 / m_addr_byte_size, // Number per line
- LLDB_INVALID_ADDRESS, // Don't show addresses before each line
- 0, 0); // No bitfields
+ DumpDataExtractor(packet,
+ &s, // Stream to dump to
+ offset, // Offset within "packet"
+ eFormatHex, // Format to use
+ m_addr_byte_size, // Size of each item
+ // in bytes
+ count / m_addr_byte_size, // Number of items
+ 16 / m_addr_byte_size, // Number per line
+ LLDB_INVALID_ADDRESS,
+ // Don't
+ // show addresses before
+ // each line
+ 0, 0); // No bitfields
} break;
case KDP_KERNELVERSION: {
@@ -907,29 +912,32 @@ void CommunicationKDP::DumpPacket(Stream &s, const DataExtractor &packet) {
const uint32_t count = packet.GetByteSize() - offset;
s.Printf(" (error = 0x%8.8x io:\n", error);
if (count > 0)
- packet.Dump(
- &s, // Stream to dump to
- offset, // Offset within "packet"
- eFormatHex, // Format to use
- 1, // Size of each item in bytes
- count, // Number of items
- 16, // Number per line
- LLDB_INVALID_ADDRESS, // Don't show addresses before each line
- 0, 0); // No bitfields
+ DumpDataExtractor(packet,
+ &s, // Stream to dump to
+ offset, // Offset within "packet"
+ eFormatHex, // Format to use
+ 1, // Size of each item in bytes
+ count, // Number of items
+ 16, // Number per line
+ LLDB_INVALID_ADDRESS, // Don't show addresses
+ // before each line
+ 0, 0); // No bitfields
} break;
case KDP_DUMPINFO: {
const uint32_t count = packet.GetByteSize() - offset;
s.Printf(" (count = %u, bytes = \n", count);
if (count > 0)
- packet.Dump(
- &s, // Stream to dump to
- offset, // Offset within "packet"
- eFormatHex, // Format to use
- 1, // Size of each item in bytes
- count, // Number of items
- 16, // Number per line
- LLDB_INVALID_ADDRESS, // Don't show addresses before each line
- 0, 0); // No bitfields
+ DumpDataExtractor(packet,
+ &s, // Stream to dump to
+ offset, // Offset within "packet"
+ eFormatHex, // Format to use
+ 1, // Size of each item in
+ // bytes
+ count, // Number of items
+ 16, // Number per line
+ LLDB_INVALID_ADDRESS, // Don't show addresses
+ // before each line
+ 0, 0); // No bitfields
} break;
@@ -977,8 +985,7 @@ void CommunicationKDP::DumpPacket(Stream &s, const DataExtractor &packet) {
const uint32_t size = packet.GetU32(&offset);
s.Printf(" (addr = 0x%8.8x, size = %u, bytes = \n", addr, size);
if (size > 0)
- DataExtractor::DumpHexBytes(&s, packet.GetData(&offset, size), size,
- 32, addr);
+ DumpHexBytes(&s, packet.GetData(&offset, size), size, 32, addr);
} break;
case KDP_READMEM64: {
@@ -1003,8 +1010,7 @@ void CommunicationKDP::DumpPacket(Stream &s, const DataExtractor &packet) {
s.Printf(" (addr = 0x%16.16" PRIx64 ", size = %u, bytes = \n", addr,
size);
if (size > 0)
- DataExtractor::DumpHexBytes(&s, packet.GetData(&offset, size), size,
- 32, addr);
+ DumpHexBytes(&s, packet.GetData(&offset, size), size, 32, addr);
} break;
case KDP_WRITEPHYSMEM64: {
@@ -1014,8 +1020,7 @@ void CommunicationKDP::DumpPacket(Stream &s, const DataExtractor &packet) {
s.Printf(" (addr = 0x%16.16llx, size = %u, lcpu = %u, bytes = \n",
addr, size, lcpu);
if (size > 0)
- DataExtractor::DumpHexBytes(&s, packet.GetData(&offset, size), size,
- 32, addr);
+ DumpHexBytes(&s, packet.GetData(&offset, size), size, 32, addr);
} break;
case KDP_READREGS: {
@@ -1030,15 +1035,18 @@ void CommunicationKDP::DumpPacket(Stream &s, const DataExtractor &packet) {
const uint32_t nbytes = packet.GetByteSize() - offset;
s.Printf(" (cpu = %u, flavor = %u, regs = \n", cpu, flavor);
if (nbytes > 0)
- packet.Dump(
- &s, // Stream to dump to
- offset, // Offset within "packet"
- eFormatHex, // Format to use
- m_addr_byte_size, // Size of each item in bytes
- nbytes / m_addr_byte_size, // Number of items
- 16 / m_addr_byte_size, // Number per line
- LLDB_INVALID_ADDRESS, // Don't show addresses before each line
- 0, 0); // No bitfields
+ DumpDataExtractor(packet,
+ &s, // Stream to dump to
+ offset, // Offset within
+ // "packet"
+ eFormatHex, // Format to use
+ m_addr_byte_size, // Size of each item in
+ // bytes
+ nbytes / m_addr_byte_size, // Number of items
+ 16 / m_addr_byte_size, // Number per line
+ LLDB_INVALID_ADDRESS, // Don't show addresses
+ // before each line
+ 0, 0); // No bitfields
} break;
case KDP_BREAKPOINT_SET:
@@ -1133,15 +1141,17 @@ void CommunicationKDP::DumpPacket(Stream &s, const DataExtractor &packet) {
s.Printf(" (address=0x%8.8x, lcpu=0x%4.4x, nbytes=0x%8.8x)", lcpu,
address, nbytes);
if (nbytes > 0)
- packet.Dump(
- &s, // Stream to dump to
- offset, // Offset within "packet"
- eFormatHex, // Format to use
- 1, // Size of each item in bytes
- nbytes, // Number of items
- 16, // Number per line
- LLDB_INVALID_ADDRESS, // Don't show addresses before each line
- 0, 0); // No bitfields
+ DumpDataExtractor(packet,
+ &s, // Stream to dump to
+ offset, // Offset within "packet"
+ eFormatHex, // Format to use
+ 1, // Size of each item in
+ // bytes
+ nbytes, // Number of items
+ 16, // Number per line
+ LLDB_INVALID_ADDRESS, // Don't show addresses
+ // before each line
+ 0, 0); // No bitfields
} break;
case KDP_READIOPORT: {
@@ -1159,22 +1169,24 @@ void CommunicationKDP::DumpPacket(Stream &s, const DataExtractor &packet) {
s.Printf(" (lcpu = %u, addr = 0x%4.4x, nbytes = %u, bytes = \n", lcpu,
address, nbytes);
if (nbytes > 0)
- packet.Dump(
- &s, // Stream to dump to
- offset, // Offset within "packet"
- eFormatHex, // Format to use
- 1, // Size of each item in bytes
- nbytes, // Number of items
- 16, // Number per line
- LLDB_INVALID_ADDRESS, // Don't show addresses before each line
- 0, 0); // No bitfields
+ DumpDataExtractor(packet,
+ &s, // Stream to dump to
+ offset, // Offset within "packet"
+ eFormatHex, // Format to use
+ 1, // Size of each item in
+ // bytes
+ nbytes, // Number of items
+ 16, // Number per line
+ LLDB_INVALID_ADDRESS, // Don't show addresses
+ // before each line
+ 0, 0); // No bitfields
} break;
case KDP_DUMPINFO: {
const uint32_t count = packet.GetByteSize() - offset;
s.Printf(" (count = %u, bytes = \n", count);
if (count > 0)
- packet.Dump(
+ DumpDataExtractor(packet,
&s, // Stream to dump to
offset, // Offset within "packet"
eFormatHex, // Format to use
@@ -1195,14 +1207,17 @@ void CommunicationKDP::DumpPacket(Stream &s, const DataExtractor &packet) {
if (error_desc) {
s.PutCString(error_desc);
- packet.Dump(&s, // Stream to dump to
- 0, // Offset into "packet"
- eFormatBytes, // Dump as hex bytes
- 1, // Size of each item is 1 for single bytes
- packet.GetByteSize(), // Number of bytes
- UINT32_MAX, // Num bytes per line
- LLDB_INVALID_ADDRESS, // Base address
- 0, 0); // Bitfield info set to not do anything bitfield related
+ DumpDataExtractor(packet,
+ &s, // Stream to dump to
+ 0, // Offset into "packet"
+ eFormatBytes, // Dump as hex bytes
+ 1, // Size of each item is 1 for
+ // single bytes
+ packet.GetByteSize(), // Number of bytes
+ UINT32_MAX, // Num bytes per line
+ LLDB_INVALID_ADDRESS, // Base address
+ 0, 0); // Bitfield info set to not do
+ // anything bitfield related
}
}
diff --git a/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index a757bba70d16..6b2e675afaea 100644
--- a/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -20,7 +20,7 @@
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/State.h"
-#include "lldb/Core/UUID.h"
+#include "lldb/Utility/UUID.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/Symbols.h"
@@ -39,6 +39,8 @@
#include "lldb/Target/Thread.h"
#include "lldb/Utility/StringExtractor.h"
+#include "llvm/Support/Threading.h"
+
#define USEC_PER_SEC 1000000
// Project includes
@@ -516,8 +518,7 @@ bool ProcessKDP::UpdateThreadList(ThreadList &old_thread_list,
ThreadList &new_thread_list) {
// locker will keep a mutex locked until it goes out of scope
Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_THREAD));
- if (log && log->GetMask().Test(KDP_LOG_VERBOSE))
- log->Printf("ProcessKDP::%s (pid = %" PRIu64 ")", __FUNCTION__, GetID());
+ LLDB_LOGV(log, "pid = {0}", GetID());
// Even though there is a CPU mask, it doesn't mean we can see each CPU
// individually, there is really only one. Lets call this thread 1.
@@ -718,18 +719,14 @@ Error ProcessKDP::DoSignal(int signo) {
}
void ProcessKDP::Initialize() {
- static std::once_flag g_once_flag;
+ static llvm::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
+ llvm::call_once(g_once_flag, []() {
PluginManager::RegisterPlugin(GetPluginNameStatic(),
GetPluginDescriptionStatic(), CreateInstance,
DebuggerInitialize);
- Log::Callbacks log_callbacks = {ProcessKDPLog::DisableLog,
- ProcessKDPLog::EnableLog,
- ProcessKDPLog::ListLogCategories};
-
- Log::RegisterLogChannel(ProcessKDP::GetPluginNameStatic(), log_callbacks);
+ ProcessKDPLog::Initialize();
});
}
diff --git a/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h b/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
index fa5d2bd27feb..8f1033b9fd36 100644
--- a/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
+++ b/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
@@ -19,14 +19,14 @@
// Other libraries and framework includes
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Broadcaster.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Core/ThreadSafeValue.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/StringList.h"
#include "CommunicationKDP.h"
diff --git a/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp b/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp
index 479f09aa8981..ffab3e5e23c7 100644
--- a/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp
+++ b/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.cpp
@@ -9,184 +9,27 @@
#include "ProcessKDPLog.h"
-#include "lldb/Core/StreamFile.h"
-#include "lldb/Interpreter/Args.h"
-
-#include "ProcessKDP.h"
-
-using namespace lldb;
using namespace lldb_private;
-// We want to avoid global constructors where code needs to be run so here we
-// control access to our static g_log_sp by hiding it in a singleton function
-// that will construct the static g_log_sp the first time this function is
-// called.
-static bool g_log_enabled = false;
-static Log *g_log = NULL;
-static Log *GetLog() {
- if (!g_log_enabled)
- return NULL;
- return g_log;
-}
-
-Log *ProcessKDPLog::GetLogIfAllCategoriesSet(uint32_t mask) {
- Log *log(GetLog());
- if (log && mask) {
- uint32_t log_mask = log->GetMask().Get();
- if ((log_mask & mask) != mask)
- return NULL;
- }
- return log;
-}
-
-void ProcessKDPLog::DisableLog(const char **categories, Stream *feedback_strm) {
- Log *log(GetLog());
- if (log) {
- uint32_t flag_bits = 0;
-
- if (categories[0] != NULL) {
- flag_bits = log->GetMask().Get();
- for (size_t i = 0; categories[i] != NULL; ++i) {
- const char *arg = categories[i];
-
- if (::strcasecmp(arg, "all") == 0)
- flag_bits &= ~KDP_LOG_ALL;
- else if (::strcasecmp(arg, "async") == 0)
- flag_bits &= ~KDP_LOG_ASYNC;
- else if (::strncasecmp(arg, "break", 5) == 0)
- flag_bits &= ~KDP_LOG_BREAKPOINTS;
- else if (::strncasecmp(arg, "comm", 4) == 0)
- flag_bits &= ~KDP_LOG_COMM;
- else if (::strcasecmp(arg, "default") == 0)
- flag_bits &= ~KDP_LOG_DEFAULT;
- else if (::strcasecmp(arg, "packets") == 0)
- flag_bits &= ~KDP_LOG_PACKETS;
- else if (::strcasecmp(arg, "memory") == 0)
- flag_bits &= ~KDP_LOG_MEMORY;
- else if (::strcasecmp(arg, "data-short") == 0)
- flag_bits &= ~KDP_LOG_MEMORY_DATA_SHORT;
- else if (::strcasecmp(arg, "data-long") == 0)
- flag_bits &= ~KDP_LOG_MEMORY_DATA_LONG;
- else if (::strcasecmp(arg, "process") == 0)
- flag_bits &= ~KDP_LOG_PROCESS;
- else if (::strcasecmp(arg, "step") == 0)
- flag_bits &= ~KDP_LOG_STEP;
- else if (::strcasecmp(arg, "thread") == 0)
- flag_bits &= ~KDP_LOG_THREAD;
- else if (::strcasecmp(arg, "verbose") == 0)
- flag_bits &= ~KDP_LOG_VERBOSE;
- else if (::strncasecmp(arg, "watch", 5) == 0)
- flag_bits &= ~KDP_LOG_WATCHPOINTS;
- else {
- feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
- ListLogCategories(feedback_strm);
- }
- }
- }
-
- log->GetMask().Reset(flag_bits);
- if (flag_bits == 0)
- g_log_enabled = false;
- }
-
- return;
-}
-
-Log *ProcessKDPLog::EnableLog(StreamSP &log_stream_sp, uint32_t log_options,
- const char **categories, Stream *feedback_strm) {
- // Try see if there already is a log - that way we can reuse its settings.
- // We could reuse the log in toto, but we don't know that the stream is the
- // same.
- uint32_t flag_bits = 0;
- if (g_log)
- flag_bits = g_log->GetMask().Get();
-
- // Now make a new log with this stream if one was provided
- if (log_stream_sp) {
- if (g_log)
- g_log->SetStream(log_stream_sp);
- else
- g_log = new Log(log_stream_sp);
- }
-
- if (g_log) {
- bool got_unknown_category = false;
- for (size_t i = 0; categories[i] != NULL; ++i) {
- const char *arg = categories[i];
-
- if (::strcasecmp(arg, "all") == 0)
- flag_bits |= KDP_LOG_ALL;
- else if (::strcasecmp(arg, "async") == 0)
- flag_bits |= KDP_LOG_ASYNC;
- else if (::strncasecmp(arg, "break", 5) == 0)
- flag_bits |= KDP_LOG_BREAKPOINTS;
- else if (::strncasecmp(arg, "comm", 4) == 0)
- flag_bits |= KDP_LOG_COMM;
- else if (::strcasecmp(arg, "default") == 0)
- flag_bits |= KDP_LOG_DEFAULT;
- else if (::strcasecmp(arg, "packets") == 0)
- flag_bits |= KDP_LOG_PACKETS;
- else if (::strcasecmp(arg, "memory") == 0)
- flag_bits |= KDP_LOG_MEMORY;
- else if (::strcasecmp(arg, "data-short") == 0)
- flag_bits |= KDP_LOG_MEMORY_DATA_SHORT;
- else if (::strcasecmp(arg, "data-long") == 0)
- flag_bits |= KDP_LOG_MEMORY_DATA_LONG;
- else if (::strcasecmp(arg, "process") == 0)
- flag_bits |= KDP_LOG_PROCESS;
- else if (::strcasecmp(arg, "step") == 0)
- flag_bits |= KDP_LOG_STEP;
- else if (::strcasecmp(arg, "thread") == 0)
- flag_bits |= KDP_LOG_THREAD;
- else if (::strcasecmp(arg, "verbose") == 0)
- flag_bits |= KDP_LOG_VERBOSE;
- else if (::strncasecmp(arg, "watch", 5) == 0)
- flag_bits |= KDP_LOG_WATCHPOINTS;
- else {
- feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
- if (got_unknown_category == false) {
- got_unknown_category = true;
- ListLogCategories(feedback_strm);
- }
- }
- }
- if (flag_bits == 0)
- flag_bits = KDP_LOG_DEFAULT;
- g_log->GetMask().Reset(flag_bits);
- g_log->GetOptions().Reset(log_options);
- }
- g_log_enabled = true;
- return g_log;
-}
+static constexpr Log::Category g_categories[] = {
+ {{"async"}, {"log asynchronous activity"}, KDP_LOG_ASYNC},
+ {{"break"}, {"log breakpoints"}, KDP_LOG_BREAKPOINTS},
+ {{"comm"}, {"log communication activity"}, KDP_LOG_COMM},
+ {{"data-long"},
+ {"log memory bytes for memory reads and writes for all transactions"},
+ KDP_LOG_MEMORY_DATA_LONG},
+ {{"data-short"},
+ {"log memory bytes for memory reads and writes for short transactions "
+ "only"},
+ KDP_LOG_MEMORY_DATA_SHORT},
+ {{"memory"}, {"log memory reads and writes"}, KDP_LOG_MEMORY},
+ {{"packets"}, {"log gdb remote packets"}, KDP_LOG_PACKETS},
+ {{"process"}, {"log process events and activities"}, KDP_LOG_PROCESS},
+ {{"step"}, {"log step related activities"}, KDP_LOG_STEP},
+ {{"thread"}, {"log thread events and activities"}, KDP_LOG_THREAD},
+ {{"watch"}, {"log watchpoint related activities"}, KDP_LOG_WATCHPOINTS},
+};
-void ProcessKDPLog::ListLogCategories(Stream *strm) {
- strm->Printf(
- "Logging categories for '%s':\n"
- " all - turn on all available logging categories\n"
- " async - log asynchronous activity\n"
- " break - log breakpoints\n"
- " communication - log communication activity\n"
- " default - enable the default set of logging categories for liblldb\n"
- " packets - log gdb remote packets\n"
- " memory - log memory reads and writes\n"
- " data-short - log memory bytes for memory reads and writes for short "
- "transactions only\n"
- " data-long - log memory bytes for memory reads and writes for all "
- "transactions\n"
- " process - log process events and activities\n"
- " thread - log thread events and activities\n"
- " step - log step related activities\n"
- " verbose - enable verbose logging\n"
- " watch - log watchpoint related activities\n",
- ProcessKDP::GetPluginNameStatic().GetCString());
-}
+Log::Channel ProcessKDPLog::g_channel(g_categories, KDP_LOG_DEFAULT);
-void ProcessKDPLog::LogIf(uint32_t mask, const char *format, ...) {
- Log *log(ProcessKDPLog::GetLogIfAllCategoriesSet(mask));
- if (log) {
- va_list args;
- va_start(args, format);
- log->VAPrintf(format, args);
- va_end(args);
- }
-}
+void ProcessKDPLog::Initialize() { Log::Register("kdp-remote", g_channel); }
diff --git a/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h b/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h
index 703c775268d2..908754ec992b 100644
--- a/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h
+++ b/source/Plugins/Process/MacOSX-Kernel/ProcessKDPLog.h
@@ -10,14 +10,8 @@
#ifndef liblldb_ProcessKDPLog_h_
#define liblldb_ProcessKDPLog_h_
-// C Includes
-// C++ Includes
-// Other libraries and framework includes
+#include "lldb/Utility/Log.h"
-// Project includes
-#include "lldb/Core/Log.h"
-
-#define KDP_LOG_VERBOSE (1u << 0)
#define KDP_LOG_PROCESS (1u << 1)
#define KDP_LOG_THREAD (1u << 2)
#define KDP_LOG_PACKETS (1u << 3)
@@ -33,21 +27,17 @@
#define KDP_LOG_ALL (UINT32_MAX)
#define KDP_LOG_DEFAULT KDP_LOG_PACKETS
+namespace lldb_private {
class ProcessKDPLog {
-public:
- static lldb_private::Log *GetLogIfAllCategoriesSet(uint32_t mask = 0);
-
- static void DisableLog(const char **categories,
- lldb_private::Stream *feedback_strm);
+ static Log::Channel g_channel;
- static lldb_private::Log *EnableLog(lldb::StreamSP &log_stream_sp,
- uint32_t log_options,
- const char **categories,
- lldb_private::Stream *feedback_strm);
-
- static void ListLogCategories(lldb_private::Stream *strm);
+public:
+ static void Initialize();
- static void LogIf(uint32_t mask, const char *format, ...);
+ static Log *GetLogIfAllCategoriesSet(uint32_t mask) {
+ return g_channel.GetLogIfAll(mask);
+ }
};
+}
#endif // liblldb_ProcessKDPLog_h_
diff --git a/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp b/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp
index 9f594f35d70d..ae2f11f38006 100644
--- a/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp
+++ b/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp
@@ -13,14 +13,14 @@
#include "lldb/Breakpoint/Watchpoint.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/State.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Unwind.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/StreamString.h"
#include "Plugins/Process/Utility/StopInfoMachException.h"
#include "ProcessKDP.h"
@@ -40,15 +40,13 @@ using namespace lldb_private;
ThreadKDP::ThreadKDP(Process &process, lldb::tid_t tid)
: Thread(process, tid), m_thread_name(), m_dispatch_queue_name(),
m_thread_dispatch_qaddr(LLDB_INVALID_ADDRESS) {
- ProcessKDPLog::LogIf(KDP_LOG_THREAD,
- "%p: ThreadKDP::ThreadKDP (tid = 0x%4.4x)", this,
- GetID());
+ Log *log = ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_THREAD);
+ LLDB_LOG(log, "this = {0}, tid = {1:x}", this, GetID());
}
ThreadKDP::~ThreadKDP() {
- ProcessKDPLog::LogIf(KDP_LOG_THREAD,
- "%p: ThreadKDP::~ThreadKDP (tid = 0x%4.4x)", this,
- GetID());
+ Log *log = ProcessKDPLog::GetLogIfAllCategoriesSet(KDP_LOG_THREAD);
+ LLDB_LOG(log, "this = {0}, tid = {1:x}", this, GetID());
DestroyThread();
}
diff --git a/source/Plugins/Process/NetBSD/CMakeLists.txt b/source/Plugins/Process/NetBSD/CMakeLists.txt
new file mode 100644
index 000000000000..5b2cef8b847b
--- /dev/null
+++ b/source/Plugins/Process/NetBSD/CMakeLists.txt
@@ -0,0 +1,21 @@
+include_directories(.)
+include_directories(../POSIX)
+include_directories(../Utility)
+
+add_lldb_library(lldbPluginProcessNetBSD PLUGIN
+ NativeProcessNetBSD.cpp
+ NativeRegisterContextNetBSD.cpp
+ NativeRegisterContextNetBSD_x86_64.cpp
+ NativeThreadNetBSD.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ lldbPluginProcessPOSIX
+ lldbPluginProcessUtility
+ LINK_COMPONENTS
+ Support
+ )
diff --git a/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp b/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
new file mode 100644
index 000000000000..298faa48e1c3
--- /dev/null
+++ b/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
@@ -0,0 +1,1018 @@
+//===-- NativeProcessNetBSD.cpp ------------------------------- -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "NativeProcessNetBSD.h"
+
+// C Includes
+
+// C++ Includes
+
+// Other libraries and framework includes
+#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
+#include "lldb/Core/State.h"
+#include "lldb/Host/HostProcess.h"
+#include "lldb/Host/common/NativeBreakpoint.h"
+#include "lldb/Host/common/NativeRegisterContext.h"
+#include "lldb/Host/posix/ProcessLauncherPosixFork.h"
+#include "lldb/Target/Process.h"
+
+// System includes - They have to be included after framework includes because
+// they define some
+// macros which collide with variable names in other modules
+// clang-format off
+#include <sys/types.h>
+#include <sys/ptrace.h>
+#include <sys/sysctl.h>
+#include <sys/wait.h>
+#include <uvm/uvm_prot.h>
+#include <elf.h>
+#include <util.h>
+// clang-format on
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::process_netbsd;
+using namespace llvm;
+
+static ExitType convert_pid_status_to_exit_type(int status) {
+ if (WIFEXITED(status))
+ return ExitType::eExitTypeExit;
+ else if (WIFSIGNALED(status))
+ return ExitType::eExitTypeSignal;
+ else if (WIFSTOPPED(status))
+ return ExitType::eExitTypeStop;
+ else {
+ // We don't know what this is.
+ return ExitType::eExitTypeInvalid;
+ }
+}
+
+static int convert_pid_status_to_return_code(int status) {
+ if (WIFEXITED(status))
+ return WEXITSTATUS(status);
+ else if (WIFSIGNALED(status))
+ return WTERMSIG(status);
+ else if (WIFSTOPPED(status))
+ return WSTOPSIG(status);
+ else {
+ // We don't know what this is.
+ return ExitType::eExitTypeInvalid;
+ }
+}
+
+// Simple helper function to ensure flags are enabled on the given file
+// descriptor.
+static Error EnsureFDFlags(int fd, int flags) {
+ Error error;
+
+ int status = fcntl(fd, F_GETFL);
+ if (status == -1) {
+ error.SetErrorToErrno();
+ return error;
+ }
+
+ if (fcntl(fd, F_SETFL, status | flags) == -1) {
+ error.SetErrorToErrno();
+ return error;
+ }
+
+ return error;
+}
+
+// -----------------------------------------------------------------------------
+// Public Static Methods
+// -----------------------------------------------------------------------------
+
+Error NativeProcessProtocol::Launch(
+ ProcessLaunchInfo &launch_info,
+ NativeProcessProtocol::NativeDelegate &native_delegate, MainLoop &mainloop,
+ NativeProcessProtocolSP &native_process_sp) {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+
+ Error error;
+
+ // Verify the working directory is valid if one was specified.
+ FileSpec working_dir{launch_info.GetWorkingDirectory()};
+ if (working_dir && (!working_dir.ResolvePath() ||
+ !llvm::sys::fs::is_directory(working_dir.GetPath()))) {
+ error.SetErrorStringWithFormat("No such file or directory: %s",
+ working_dir.GetCString());
+ return error;
+ }
+
+ // Create the NativeProcessNetBSD in launch mode.
+ native_process_sp.reset(new NativeProcessNetBSD());
+
+ if (!native_process_sp->RegisterNativeDelegate(native_delegate)) {
+ native_process_sp.reset();
+ error.SetErrorStringWithFormat("failed to register the native delegate");
+ return error;
+ }
+
+ error = std::static_pointer_cast<NativeProcessNetBSD>(native_process_sp)
+ ->LaunchInferior(mainloop, launch_info);
+
+ if (error.Fail()) {
+ native_process_sp.reset();
+ LLDB_LOG(log, "failed to launch process: {0}", error);
+ return error;
+ }
+
+ launch_info.SetProcessID(native_process_sp->GetID());
+
+ return error;
+}
+
+Error NativeProcessProtocol::Attach(
+ lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate,
+ MainLoop &mainloop, NativeProcessProtocolSP &native_process_sp) {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+ LLDB_LOG(log, "pid = {0:x}", pid);
+
+ // Retrieve the architecture for the running process.
+ ArchSpec process_arch;
+ Error error = ResolveProcessArchitecture(pid, process_arch);
+ if (!error.Success())
+ return error;
+
+ std::shared_ptr<NativeProcessNetBSD> native_process_netbsd_sp(
+ new NativeProcessNetBSD());
+
+ if (!native_process_netbsd_sp->RegisterNativeDelegate(native_delegate)) {
+ error.SetErrorStringWithFormat("failed to register the native delegate");
+ return error;
+ }
+
+ native_process_netbsd_sp->AttachToInferior(mainloop, pid, error);
+ if (!error.Success())
+ return error;
+
+ native_process_sp = native_process_netbsd_sp;
+ return error;
+}
+
+// -----------------------------------------------------------------------------
+// Public Instance Methods
+// -----------------------------------------------------------------------------
+
+NativeProcessNetBSD::NativeProcessNetBSD()
+ : NativeProcessProtocol(LLDB_INVALID_PROCESS_ID), m_arch(),
+ m_supports_mem_region(eLazyBoolCalculate), m_mem_region_cache() {}
+
+// Handles all waitpid events from the inferior process.
+void NativeProcessNetBSD::MonitorCallback(lldb::pid_t pid, int signal) {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+
+ switch (signal) {
+ case SIGTRAP:
+ return MonitorSIGTRAP(pid);
+ case SIGSTOP:
+ return MonitorSIGSTOP(pid);
+ default:
+ return MonitorSignal(pid, signal);
+ }
+}
+
+void NativeProcessNetBSD::MonitorExited(lldb::pid_t pid, int signal,
+ int status) {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+
+ LLDB_LOG(log, "got exit signal({0}) , pid = {1}", signal, pid);
+
+ /* Stop Tracking All Threads attached to Process */
+ m_threads.clear();
+
+ SetExitStatus(convert_pid_status_to_exit_type(status),
+ convert_pid_status_to_return_code(status), nullptr, true);
+
+ // Notify delegate that our process has exited.
+ SetState(StateType::eStateExited, true);
+}
+
+void NativeProcessNetBSD::MonitorSIGSTOP(lldb::pid_t pid) {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+ ptrace_siginfo_t info;
+
+ const auto siginfo_err =
+ PtraceWrapper(PT_GET_SIGINFO, pid, &info, sizeof(info));
+
+ // Get details on the signal raised.
+ if (siginfo_err.Success()) {
+ // Handle SIGSTOP from LLGS (LLDB GDB Server)
+ if (info.psi_siginfo.si_code == SI_USER &&
+ info.psi_siginfo.si_pid == ::getpid()) {
+ /* Stop Tracking All Threads attached to Process */
+ for (const auto &thread_sp : m_threads) {
+ static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetStoppedBySignal(
+ SIGSTOP, &info.psi_siginfo);
+ }
+ }
+ }
+}
+
+void NativeProcessNetBSD::MonitorSIGTRAP(lldb::pid_t pid) {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+ ptrace_siginfo_t info;
+
+ const auto siginfo_err =
+ PtraceWrapper(PT_GET_SIGINFO, pid, &info, sizeof(info));
+
+ // Get details on the signal raised.
+ if (siginfo_err.Success()) {
+ switch (info.psi_siginfo.si_code) {
+ case TRAP_BRKPT:
+ for (const auto &thread_sp : m_threads) {
+ static_pointer_cast<NativeThreadNetBSD>(thread_sp)
+ ->SetStoppedByBreakpoint();
+ FixupBreakpointPCAsNeeded(
+ *static_pointer_cast<NativeThreadNetBSD>(thread_sp));
+ }
+ SetState(StateType::eStateStopped, true);
+ break;
+ case TRAP_TRACE:
+ for (const auto &thread_sp : m_threads) {
+ static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetStoppedByTrace();
+ }
+ SetState(StateType::eStateStopped, true);
+ break;
+ case TRAP_EXEC: {
+ Error error = ReinitializeThreads();
+ if (error.Fail()) {
+ SetState(StateType::eStateInvalid);
+ return;
+ }
+
+ // Let our delegate know we have just exec'd.
+ NotifyDidExec();
+
+ SetState(StateType::eStateStopped, true);
+ } break;
+ }
+ }
+}
+
+void NativeProcessNetBSD::MonitorSignal(lldb::pid_t pid, int signal) {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+
+ ptrace_siginfo_t info;
+ const auto siginfo_err =
+ PtraceWrapper(PT_GET_SIGINFO, pid, &info, sizeof(info));
+
+ for (const auto &thread_sp : m_threads) {
+ static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetStoppedBySignal(
+ info.psi_siginfo.si_signo, &info.psi_siginfo);
+ }
+ SetState(StateType::eStateStopped, true);
+}
+
+Error NativeProcessNetBSD::PtraceWrapper(int req, lldb::pid_t pid, void *addr,
+ int data, int *result) {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PTRACE));
+ Error error;
+ int ret;
+
+ errno = 0;
+ ret = ptrace(req, static_cast<::pid_t>(pid), addr, data);
+
+ if (ret == -1)
+ error.SetErrorToErrno();
+
+ if (result)
+ *result = ret;
+
+ LLDB_LOG(log, "ptrace({0}, {1}, {2}, {3})={4:x}", req, pid, addr, data, ret);
+
+ if (error.Fail())
+ LLDB_LOG(log, "ptrace() failed: {0}", error);
+
+ return error;
+}
+
+Error NativeProcessNetBSD::GetSoftwareBreakpointPCOffset(
+ uint32_t &actual_opcode_size) {
+ // FIXME put this behind a breakpoint protocol class that can be
+ // set per architecture. Need ARM, MIPS support here.
+ static const uint8_t g_i386_opcode[] = {0xCC};
+ switch (m_arch.GetMachine()) {
+ case llvm::Triple::x86_64:
+ actual_opcode_size = static_cast<uint32_t>(sizeof(g_i386_opcode));
+ return Error();
+ default:
+ assert(false && "CPU type not supported!");
+ return Error("CPU type not supported");
+ }
+}
+
+Error NativeProcessNetBSD::FixupBreakpointPCAsNeeded(
+ NativeThreadNetBSD &thread) {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_BREAKPOINTS));
+ Error error;
+ // Find out the size of a breakpoint (might depend on where we are in the
+ // code).
+ NativeRegisterContextSP context_sp = thread.GetRegisterContext();
+ if (!context_sp) {
+ error.SetErrorString("cannot get a NativeRegisterContext for the thread");
+ LLDB_LOG(log, "failed: {0}", error);
+ return error;
+ }
+ uint32_t breakpoint_size = 0;
+ error = GetSoftwareBreakpointPCOffset(breakpoint_size);
+ if (error.Fail()) {
+ LLDB_LOG(log, "GetBreakpointSize() failed: {0}", error);
+ return error;
+ } else
+ LLDB_LOG(log, "breakpoint size: {0}", breakpoint_size);
+ // First try probing for a breakpoint at a software breakpoint location: PC -
+ // breakpoint size.
+ const lldb::addr_t initial_pc_addr =
+ context_sp->GetPCfromBreakpointLocation();
+ lldb::addr_t breakpoint_addr = initial_pc_addr;
+ if (breakpoint_size > 0) {
+ // Do not allow breakpoint probe to wrap around.
+ if (breakpoint_addr >= breakpoint_size)
+ breakpoint_addr -= breakpoint_size;
+ }
+ // Check if we stopped because of a breakpoint.
+ NativeBreakpointSP breakpoint_sp;
+ error = m_breakpoint_list.GetBreakpoint(breakpoint_addr, breakpoint_sp);
+ if (!error.Success() || !breakpoint_sp) {
+ // We didn't find one at a software probe location. Nothing to do.
+ LLDB_LOG(log,
+ "pid {0} no lldb breakpoint found at current pc with "
+ "adjustment: {1}",
+ GetID(), breakpoint_addr);
+ return Error();
+ }
+ // If the breakpoint is not a software breakpoint, nothing to do.
+ if (!breakpoint_sp->IsSoftwareBreakpoint()) {
+ LLDB_LOG(
+ log,
+ "pid {0} breakpoint found at {1:x}, not software, nothing to adjust",
+ GetID(), breakpoint_addr);
+ return Error();
+ }
+ //
+ // We have a software breakpoint and need to adjust the PC.
+ //
+ // Sanity check.
+ if (breakpoint_size == 0) {
+ // Nothing to do! How did we get here?
+ LLDB_LOG(log,
+ "pid {0} breakpoint found at {1:x}, it is software, but the "
+ "size is zero, nothing to do (unexpected)",
+ GetID(), breakpoint_addr);
+ return Error();
+ }
+ //
+ // We have a software breakpoint and need to adjust the PC.
+ //
+ // Sanity check.
+ if (breakpoint_size == 0) {
+ // Nothing to do! How did we get here?
+ LLDB_LOG(log,
+ "pid {0} breakpoint found at {1:x}, it is software, but the "
+ "size is zero, nothing to do (unexpected)",
+ GetID(), breakpoint_addr);
+ return Error();
+ }
+ // Change the program counter.
+ LLDB_LOG(log, "pid {0} tid {1}: changing PC from {2:x} to {3:x}", GetID(),
+ thread.GetID(), initial_pc_addr, breakpoint_addr);
+ error = context_sp->SetPC(breakpoint_addr);
+ if (error.Fail()) {
+ LLDB_LOG(log, "pid {0} tid {1}: failed to set PC: {2}", GetID(),
+ thread.GetID(), error);
+ return error;
+ }
+ return error;
+}
+
+Error NativeProcessNetBSD::Resume(const ResumeActionList &resume_actions) {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+ LLDB_LOG(log, "pid {0}", GetID());
+
+ const auto &thread_sp = m_threads[0];
+ const ResumeAction *const action =
+ resume_actions.GetActionForThread(thread_sp->GetID(), true);
+
+ if (action == nullptr) {
+ LLDB_LOG(log, "no action specified for pid {0} tid {1}", GetID(),
+ thread_sp->GetID());
+ return Error();
+ }
+
+ Error error;
+
+ switch (action->state) {
+ case eStateRunning: {
+ // Run the thread, possibly feeding it the signal.
+ error = NativeProcessNetBSD::PtraceWrapper(PT_CONTINUE, GetID(), (void *)1,
+ action->signal);
+ if (!error.Success())
+ return error;
+ for (const auto &thread_sp : m_threads) {
+ static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetRunning();
+ }
+ SetState(eStateRunning, true);
+ break;
+ }
+ case eStateStepping:
+ // Run the thread, possibly feeding it the signal.
+ error = NativeProcessNetBSD::PtraceWrapper(PT_STEP, GetID(), (void *)1,
+ action->signal);
+ if (!error.Success())
+ return error;
+ for (const auto &thread_sp : m_threads) {
+ static_pointer_cast<NativeThreadNetBSD>(thread_sp)->SetStepping();
+ }
+ SetState(eStateStepping, true);
+ break;
+
+ case eStateSuspended:
+ case eStateStopped:
+ llvm_unreachable("Unexpected state");
+
+ default:
+ return Error("NativeProcessLinux::%s (): unexpected state %s specified "
+ "for pid %" PRIu64 ", tid %" PRIu64,
+ __FUNCTION__, StateAsCString(action->state), GetID(),
+ thread_sp->GetID());
+ }
+
+ return Error();
+}
+
+Error NativeProcessNetBSD::Halt() {
+ Error error;
+
+ if (kill(GetID(), SIGSTOP) != 0)
+ error.SetErrorToErrno();
+
+ return error;
+}
+
+Error NativeProcessNetBSD::Detach() {
+ Error error;
+
+ // Stop monitoring the inferior.
+ m_sigchld_handle.reset();
+
+ // Tell ptrace to detach from the process.
+ if (GetID() == LLDB_INVALID_PROCESS_ID)
+ return error;
+
+ return PtraceWrapper(PT_DETACH, GetID());
+}
+
+Error NativeProcessNetBSD::Signal(int signo) {
+ Error error;
+
+ if (kill(GetID(), signo))
+ error.SetErrorToErrno();
+
+ return error;
+}
+
+Error NativeProcessNetBSD::Kill() {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+ LLDB_LOG(log, "pid {0}", GetID());
+
+ Error error;
+
+ switch (m_state) {
+ case StateType::eStateInvalid:
+ case StateType::eStateExited:
+ case StateType::eStateCrashed:
+ case StateType::eStateDetached:
+ case StateType::eStateUnloaded:
+ // Nothing to do - the process is already dead.
+ LLDB_LOG(log, "ignored for PID {0} due to current state: {1}", GetID(),
+ StateAsCString(m_state));
+ return error;
+
+ case StateType::eStateConnected:
+ case StateType::eStateAttaching:
+ case StateType::eStateLaunching:
+ case StateType::eStateStopped:
+ case StateType::eStateRunning:
+ case StateType::eStateStepping:
+ case StateType::eStateSuspended:
+ // We can try to kill a process in these states.
+ break;
+ }
+
+ if (kill(GetID(), SIGKILL) != 0) {
+ error.SetErrorToErrno();
+ return error;
+ }
+
+ return error;
+}
+
+Error NativeProcessNetBSD::GetMemoryRegionInfo(lldb::addr_t load_addr,
+ MemoryRegionInfo &range_info) {
+
+ if (m_supports_mem_region == LazyBool::eLazyBoolNo) {
+ // We're done.
+ return Error("unsupported");
+ }
+
+ Error error = PopulateMemoryRegionCache();
+ if (error.Fail()) {
+ return error;
+ }
+
+ lldb::addr_t prev_base_address = 0;
+ // FIXME start by finding the last region that is <= target address using
+ // binary search. Data is sorted.
+ // There can be a ton of regions on pthreads apps with lots of threads.
+ for (auto it = m_mem_region_cache.begin(); it != m_mem_region_cache.end();
+ ++it) {
+ MemoryRegionInfo &proc_entry_info = it->first;
+ // Sanity check assumption that memory map entries are ascending.
+ assert((proc_entry_info.GetRange().GetRangeBase() >= prev_base_address) &&
+ "descending memory map entries detected, unexpected");
+ prev_base_address = proc_entry_info.GetRange().GetRangeBase();
+ UNUSED_IF_ASSERT_DISABLED(prev_base_address);
+ // If the target address comes before this entry, indicate distance to next
+ // region.
+ if (load_addr < proc_entry_info.GetRange().GetRangeBase()) {
+ range_info.GetRange().SetRangeBase(load_addr);
+ range_info.GetRange().SetByteSize(
+ proc_entry_info.GetRange().GetRangeBase() - load_addr);
+ range_info.SetReadable(MemoryRegionInfo::OptionalBool::eNo);
+ range_info.SetWritable(MemoryRegionInfo::OptionalBool::eNo);
+ range_info.SetExecutable(MemoryRegionInfo::OptionalBool::eNo);
+ range_info.SetMapped(MemoryRegionInfo::OptionalBool::eNo);
+ return error;
+ } else if (proc_entry_info.GetRange().Contains(load_addr)) {
+ // The target address is within the memory region we're processing here.
+ range_info = proc_entry_info;
+ return error;
+ }
+ // The target memory address comes somewhere after the region we just
+ // parsed.
+ }
+ // If we made it here, we didn't find an entry that contained the given
+ // address. Return the
+ // load_addr as start and the amount of bytes betwwen load address and the end
+ // of the memory as
+ // size.
+ range_info.GetRange().SetRangeBase(load_addr);
+ range_info.GetRange().SetRangeEnd(LLDB_INVALID_ADDRESS);
+ range_info.SetReadable(MemoryRegionInfo::OptionalBool::eNo);
+ range_info.SetWritable(MemoryRegionInfo::OptionalBool::eNo);
+ range_info.SetExecutable(MemoryRegionInfo::OptionalBool::eNo);
+ range_info.SetMapped(MemoryRegionInfo::OptionalBool::eNo);
+ return error;
+}
+
+Error NativeProcessNetBSD::PopulateMemoryRegionCache() {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+ // If our cache is empty, pull the latest. There should always be at least
+ // one memory region if memory region handling is supported.
+ if (!m_mem_region_cache.empty()) {
+ LLDB_LOG(log, "reusing {0} cached memory region entries",
+ m_mem_region_cache.size());
+ return Error();
+ }
+
+ struct kinfo_vmentry *vm;
+ size_t count, i;
+ vm = kinfo_getvmmap(GetID(), &count);
+ if (vm == NULL) {
+ m_supports_mem_region = LazyBool::eLazyBoolNo;
+ Error error;
+ error.SetErrorString("not supported");
+ return error;
+ }
+ for (i = 0; i < count; i++) {
+ MemoryRegionInfo info;
+ info.Clear();
+ info.GetRange().SetRangeBase(vm[i].kve_start);
+ info.GetRange().SetRangeEnd(vm[i].kve_end);
+ info.SetMapped(MemoryRegionInfo::OptionalBool::eYes);
+
+ if (vm[i].kve_protection & VM_PROT_READ)
+ info.SetReadable(MemoryRegionInfo::OptionalBool::eYes);
+ else
+ info.SetReadable(MemoryRegionInfo::OptionalBool::eNo);
+
+ if (vm[i].kve_protection & VM_PROT_WRITE)
+ info.SetWritable(MemoryRegionInfo::OptionalBool::eYes);
+ else
+ info.SetWritable(MemoryRegionInfo::OptionalBool::eNo);
+
+ if (vm[i].kve_protection & VM_PROT_EXECUTE)
+ info.SetExecutable(MemoryRegionInfo::OptionalBool::eYes);
+ else
+ info.SetExecutable(MemoryRegionInfo::OptionalBool::eNo);
+
+ if (vm[i].kve_path[0])
+ info.SetName(vm[i].kve_path);
+
+ m_mem_region_cache.emplace_back(
+ info, FileSpec(info.GetName().GetCString(), true));
+ }
+ free(vm);
+
+ if (m_mem_region_cache.empty()) {
+ // No entries after attempting to read them. This shouldn't happen.
+ // Assume we don't support map entries.
+ LLDB_LOG(log, "failed to find any vmmap entries, assuming no support "
+ "for memory region metadata retrieval");
+ m_supports_mem_region = LazyBool::eLazyBoolNo;
+ Error error;
+ error.SetErrorString("not supported");
+ return error;
+ }
+ LLDB_LOG(log, "read {0} memory region entries from process {1}",
+ m_mem_region_cache.size(), GetID());
+ // We support memory retrieval, remember that.
+ m_supports_mem_region = LazyBool::eLazyBoolYes;
+ return Error();
+}
+
+Error NativeProcessNetBSD::AllocateMemory(size_t size, uint32_t permissions,
+ lldb::addr_t &addr) {
+ return Error("Unimplemented");
+}
+
+Error NativeProcessNetBSD::DeallocateMemory(lldb::addr_t addr) {
+ return Error("Unimplemented");
+}
+
+lldb::addr_t NativeProcessNetBSD::GetSharedLibraryInfoAddress() {
+ // punt on this for now
+ return LLDB_INVALID_ADDRESS;
+}
+
+size_t NativeProcessNetBSD::UpdateThreads() { return m_threads.size(); }
+
+bool NativeProcessNetBSD::GetArchitecture(ArchSpec &arch) const {
+ arch = m_arch;
+ return true;
+}
+
+Error NativeProcessNetBSD::SetBreakpoint(lldb::addr_t addr, uint32_t size,
+ bool hardware) {
+ if (hardware)
+ return Error("NativeProcessNetBSD does not support hardware breakpoints");
+ else
+ return SetSoftwareBreakpoint(addr, size);
+}
+
+Error NativeProcessNetBSD::GetSoftwareBreakpointTrapOpcode(
+ size_t trap_opcode_size_hint, size_t &actual_opcode_size,
+ const uint8_t *&trap_opcode_bytes) {
+ static const uint8_t g_i386_opcode[] = {0xCC};
+
+ switch (m_arch.GetMachine()) {
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
+ trap_opcode_bytes = g_i386_opcode;
+ actual_opcode_size = sizeof(g_i386_opcode);
+ return Error();
+ default:
+ assert(false && "CPU type not supported!");
+ return Error("CPU type not supported");
+ }
+}
+
+Error NativeProcessNetBSD::GetLoadedModuleFileSpec(const char *module_path,
+ FileSpec &file_spec) {
+ return Error("Unimplemented");
+}
+
+Error NativeProcessNetBSD::GetFileLoadAddress(const llvm::StringRef &file_name,
+ lldb::addr_t &load_addr) {
+ load_addr = LLDB_INVALID_ADDRESS;
+ return Error();
+}
+
+Error NativeProcessNetBSD::LaunchInferior(MainLoop &mainloop,
+ ProcessLaunchInfo &launch_info) {
+ Error error;
+ m_sigchld_handle = mainloop.RegisterSignal(
+ SIGCHLD, [this](MainLoopBase &) { SigchldHandler(); }, error);
+ if (!m_sigchld_handle)
+ return error;
+
+ SetState(eStateLaunching);
+
+ ::pid_t pid = ProcessLauncherPosixFork()
+ .LaunchProcess(launch_info, error)
+ .GetProcessId();
+ if (error.Fail())
+ return error;
+
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+
+ // Wait for the child process to trap on its call to execve.
+ ::pid_t wpid;
+ int status;
+ if ((wpid = waitpid(pid, &status, 0)) < 0) {
+ error.SetErrorToErrno();
+ LLDB_LOG(log, "waitpid for inferior failed with %s", error);
+
+ // Mark the inferior as invalid.
+ // FIXME this could really use a new state - eStateLaunchFailure. For now,
+ // using eStateInvalid.
+ SetState(StateType::eStateInvalid);
+
+ return error;
+ }
+ assert(WIFSTOPPED(status) && (wpid == static_cast<::pid_t>(pid)) &&
+ "Could not sync with inferior process.");
+
+ LLDB_LOG(log, "inferior started, now in stopped state");
+
+ // Release the master terminal descriptor and pass it off to the
+ // NativeProcessNetBSD instance. Similarly stash the inferior pid.
+ m_terminal_fd = launch_info.GetPTY().ReleaseMasterFileDescriptor();
+ m_pid = pid;
+ launch_info.SetProcessID(pid);
+
+ if (m_terminal_fd != -1) {
+ error = EnsureFDFlags(m_terminal_fd, O_NONBLOCK);
+ if (error.Fail()) {
+ LLDB_LOG(log,
+ "inferior EnsureFDFlags failed for ensuring terminal "
+ "O_NONBLOCK setting: {0}",
+ error);
+
+ // Mark the inferior as invalid.
+ // FIXME this could really use a new state - eStateLaunchFailure. For
+ // now, using eStateInvalid.
+ SetState(StateType::eStateInvalid);
+
+ return error;
+ }
+ }
+
+ LLDB_LOG(log, "adding pid = {0}", pid);
+
+ ResolveProcessArchitecture(m_pid, m_arch);
+
+ error = ReinitializeThreads();
+ if (error.Fail()) {
+ SetState(StateType::eStateInvalid);
+ return error;
+ }
+
+ /* Set process stopped */
+ SetState(StateType::eStateStopped);
+
+ if (error.Fail())
+ LLDB_LOG(log, "inferior launching failed {0}", error);
+ return error;
+}
+
+void NativeProcessNetBSD::AttachToInferior(MainLoop &mainloop, lldb::pid_t pid,
+ Error &error) {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+ LLDB_LOG(log, "pid = {0:x}", pid);
+
+ m_sigchld_handle = mainloop.RegisterSignal(
+ SIGCHLD, [this](MainLoopBase &) { SigchldHandler(); }, error);
+ if (!m_sigchld_handle)
+ return;
+
+ error = ResolveProcessArchitecture(pid, m_arch);
+ if (!error.Success())
+ return;
+
+ // Set the architecture to the exe architecture.
+ LLDB_LOG(log, "pid = {0:x}, detected architecture {1}", pid,
+ m_arch.GetArchitectureName());
+
+ m_pid = pid;
+ SetState(eStateAttaching);
+
+ Attach(pid, error);
+}
+
+void NativeProcessNetBSD::SigchldHandler() {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_PROCESS));
+ // Process all pending waitpid notifications.
+ int status;
+ ::pid_t wait_pid = waitpid(GetID(), &status, WALLSIG | WNOHANG);
+
+ if (wait_pid == 0)
+ return; // We are done.
+
+ if (wait_pid == -1) {
+ if (errno == EINTR)
+ return;
+
+ Error error(errno, eErrorTypePOSIX);
+ LLDB_LOG(log, "waitpid ({0}, &status, _) failed: {1}", GetID(), error);
+ }
+
+ bool exited = false;
+ int signal = 0;
+ int exit_status = 0;
+ const char *status_cstr = nullptr;
+ if (WIFSTOPPED(status)) {
+ signal = WSTOPSIG(status);
+ status_cstr = "STOPPED";
+ } else if (WIFEXITED(status)) {
+ exit_status = WEXITSTATUS(status);
+ status_cstr = "EXITED";
+ exited = true;
+ } else if (WIFSIGNALED(status)) {
+ signal = WTERMSIG(status);
+ status_cstr = "SIGNALED";
+ if (wait_pid == static_cast<::pid_t>(GetID())) {
+ exited = true;
+ exit_status = -1;
+ }
+ } else
+ status_cstr = "(\?\?\?)";
+
+ LLDB_LOG(log,
+ "waitpid ({0}, &status, _) => pid = {1}, status = {2:x} "
+ "({3}), signal = {4}, exit_state = {5}",
+ GetID(), wait_pid, status, status_cstr, signal, exit_status);
+
+ if (exited)
+ MonitorExited(wait_pid, signal, exit_status);
+ else
+ MonitorCallback(wait_pid, signal);
+}
+
+NativeThreadNetBSDSP NativeProcessNetBSD::AddThread(lldb::tid_t thread_id) {
+
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD));
+ LLDB_LOG(log, "pid {0} adding thread with tid {1}", GetID(), thread_id);
+
+ assert(!HasThreadNoLock(thread_id) &&
+ "attempted to add a thread by id that already exists");
+
+ // If this is the first thread, save it as the current thread
+ if (m_threads.empty())
+ SetCurrentThreadID(thread_id);
+
+ auto thread_sp = std::make_shared<NativeThreadNetBSD>(this, thread_id);
+ m_threads.push_back(thread_sp);
+ return thread_sp;
+}
+
+::pid_t NativeProcessNetBSD::Attach(lldb::pid_t pid, Error &error) {
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+
+ if (pid <= 1) {
+ error.SetErrorToGenericError();
+ error.SetErrorString("Attaching to process 1 is not allowed.");
+ return -1;
+ }
+
+ // Attach to the requested process.
+ // An attach will cause the thread to stop with a SIGSTOP.
+ error = PtraceWrapper(PT_ATTACH, pid);
+ if (error.Fail())
+ return -1;
+
+ int status;
+ // Need to use WALLSIG otherwise we receive an error with errno=ECHLD
+ // At this point we should have a thread stopped if waitpid succeeds.
+ if ((status = waitpid(pid, NULL, WALLSIG)) < 0)
+ return -1;
+
+ m_pid = pid;
+
+ /* Initialize threads */
+ error = ReinitializeThreads();
+ if (error.Fail()) {
+ SetState(StateType::eStateInvalid);
+ return -1;
+ }
+
+ // Let our process instance know the thread has stopped.
+ SetState(StateType::eStateStopped);
+
+ return pid;
+}
+
+Error NativeProcessNetBSD::ReadMemory(lldb::addr_t addr, void *buf, size_t size,
+ size_t &bytes_read) {
+ unsigned char *dst = static_cast<unsigned char *>(buf);
+ struct ptrace_io_desc io;
+
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_MEMORY));
+ LLDB_LOG(log, "addr = {0}, buf = {1}, size = {2}", addr, buf, size);
+
+ bytes_read = 0;
+ io.piod_op = PIOD_READ_D;
+ io.piod_len = size;
+
+ do {
+ io.piod_offs = (void *)(addr + bytes_read);
+ io.piod_addr = dst + bytes_read;
+
+ Error error = NativeProcessNetBSD::PtraceWrapper(PT_IO, GetID(), &io);
+ if (error.Fail())
+ return error;
+
+ bytes_read = io.piod_len;
+ io.piod_len = size - bytes_read;
+ } while (bytes_read < size);
+
+ return Error();
+}
+
+Error NativeProcessNetBSD::ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf,
+ size_t size,
+ size_t &bytes_read) {
+ Error error = ReadMemory(addr, buf, size, bytes_read);
+ if (error.Fail())
+ return error;
+ return m_breakpoint_list.RemoveTrapsFromBuffer(addr, buf, size);
+}
+
+Error NativeProcessNetBSD::WriteMemory(lldb::addr_t addr, const void *buf,
+ size_t size, size_t &bytes_written) {
+ const unsigned char *src = static_cast<const unsigned char *>(buf);
+ Error error;
+ struct ptrace_io_desc io;
+
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_MEMORY));
+ LLDB_LOG(log, "addr = {0}, buf = {1}, size = {2}", addr, buf, size);
+
+ bytes_written = 0;
+ io.piod_op = PIOD_WRITE_D;
+ io.piod_len = size;
+
+ do {
+ io.piod_addr = (void *)(src + bytes_written);
+ io.piod_offs = (void *)(addr + bytes_written);
+
+ Error error = NativeProcessNetBSD::PtraceWrapper(PT_IO, GetID(), &io);
+ if (error.Fail())
+ return error;
+
+ bytes_written = io.piod_len;
+ io.piod_len = size - bytes_written;
+ } while (bytes_written < size);
+
+ return error;
+}
+
+llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+NativeProcessNetBSD::GetAuxvData() const {
+ /*
+ * ELF_AUX_ENTRIES is currently restricted to kernel
+ * (<sys/exec_elf.h> r. 1.155 specifies 15)
+ *
+ * ptrace(2) returns the whole AUXV including extra fiels after AT_NULL this
+ * information isn't needed.
+ */
+ size_t auxv_size = 100 * sizeof(AuxInfo);
+
+ ErrorOr<std::unique_ptr<MemoryBuffer>> buf =
+ llvm::MemoryBuffer::getNewMemBuffer(auxv_size);
+
+ struct ptrace_io_desc io = {.piod_op = PIOD_READ_AUXV,
+ .piod_offs = 0,
+ .piod_addr = (void *)buf.get()->getBufferStart(),
+ .piod_len = auxv_size};
+
+ Error error = NativeProcessNetBSD::PtraceWrapper(PT_IO, GetID(), &io);
+
+ if (error.Fail())
+ return std::error_code(error.GetError(), std::generic_category());
+
+ if (io.piod_len < 1)
+ return std::error_code(ECANCELED, std::generic_category());
+
+ return buf;
+}
+
+Error NativeProcessNetBSD::ReinitializeThreads() {
+ // Clear old threads
+ m_threads.clear();
+
+ // Initialize new thread
+ struct ptrace_lwpinfo info = {};
+ Error error = PtraceWrapper(PT_LWPINFO, GetID(), &info, sizeof(info));
+ if (error.Fail()) {
+ return error;
+ }
+ // Reinitialize from scratch threads and register them in process
+ while (info.pl_lwpid != 0) {
+ NativeThreadNetBSDSP thread_sp = AddThread(info.pl_lwpid);
+ thread_sp->SetStoppedByExec();
+ error = PtraceWrapper(PT_LWPINFO, GetID(), &info, sizeof(info));
+ if (error.Fail()) {
+ return error;
+ }
+ }
+
+ return error;
+}
diff --git a/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h b/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
new file mode 100644
index 000000000000..ae946a8e004d
--- /dev/null
+++ b/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
@@ -0,0 +1,141 @@
+//===-- NativeProcessNetBSD.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_NativeProcessNetBSD_H_
+#define liblldb_NativeProcessNetBSD_H_
+
+// C++ Includes
+
+// Other libraries and framework includes
+
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Utility/FileSpec.h"
+
+#include "NativeThreadNetBSD.h"
+#include "lldb/Host/common/NativeProcessProtocol.h"
+
+namespace lldb_private {
+namespace process_netbsd {
+/// @class NativeProcessNetBSD
+/// @brief Manages communication with the inferior (debugee) process.
+///
+/// Upon construction, this class prepares and launches an inferior process for
+/// debugging.
+///
+/// Changes in the inferior process state are broadcasted.
+class NativeProcessNetBSD : public NativeProcessProtocol {
+ friend Error NativeProcessProtocol::Launch(
+ ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate,
+ MainLoop &mainloop, NativeProcessProtocolSP &process_sp);
+
+ friend Error NativeProcessProtocol::Attach(
+ lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate,
+ MainLoop &mainloop, NativeProcessProtocolSP &process_sp);
+
+public:
+ // ---------------------------------------------------------------------
+ // NativeProcessProtocol Interface
+ // ---------------------------------------------------------------------
+ Error Resume(const ResumeActionList &resume_actions) override;
+
+ Error Halt() override;
+
+ Error Detach() override;
+
+ Error Signal(int signo) override;
+
+ Error Kill() override;
+
+ Error GetMemoryRegionInfo(lldb::addr_t load_addr,
+ MemoryRegionInfo &range_info) override;
+
+ Error ReadMemory(lldb::addr_t addr, void *buf, size_t size,
+ size_t &bytes_read) override;
+
+ Error ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size,
+ size_t &bytes_read) override;
+
+ Error WriteMemory(lldb::addr_t addr, const void *buf, size_t size,
+ size_t &bytes_written) override;
+
+ Error AllocateMemory(size_t size, uint32_t permissions,
+ lldb::addr_t &addr) override;
+
+ Error DeallocateMemory(lldb::addr_t addr) override;
+
+ lldb::addr_t GetSharedLibraryInfoAddress() override;
+
+ size_t UpdateThreads() override;
+
+ bool GetArchitecture(ArchSpec &arch) const override;
+
+ Error SetBreakpoint(lldb::addr_t addr, uint32_t size, bool hardware) override;
+
+ Error GetLoadedModuleFileSpec(const char *module_path,
+ FileSpec &file_spec) override;
+
+ Error GetFileLoadAddress(const llvm::StringRef &file_name,
+ lldb::addr_t &load_addr) override;
+
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
+ GetAuxvData() const override;
+
+ // ---------------------------------------------------------------------
+ // Interface used by NativeRegisterContext-derived classes.
+ // ---------------------------------------------------------------------
+ static Error PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr,
+ int data = 0, int *result = nullptr);
+
+protected:
+ // ---------------------------------------------------------------------
+ // NativeProcessProtocol protected interface
+ // ---------------------------------------------------------------------
+
+ Error
+ GetSoftwareBreakpointTrapOpcode(size_t trap_opcode_size_hint,
+ size_t &actual_opcode_size,
+ const uint8_t *&trap_opcode_bytes) override;
+
+private:
+ MainLoop::SignalHandleUP m_sigchld_handle;
+ ArchSpec m_arch;
+ LazyBool m_supports_mem_region;
+ std::vector<std::pair<MemoryRegionInfo, FileSpec>> m_mem_region_cache;
+
+ // ---------------------------------------------------------------------
+ // Private Instance Methods
+ // ---------------------------------------------------------------------
+ NativeProcessNetBSD();
+
+ NativeThreadNetBSDSP AddThread(lldb::tid_t thread_id);
+
+ Error LaunchInferior(MainLoop &mainloop, ProcessLaunchInfo &launch_info);
+ void AttachToInferior(MainLoop &mainloop, lldb::pid_t pid, Error &error);
+
+ void MonitorCallback(lldb::pid_t pid, int signal);
+ void MonitorExited(lldb::pid_t pid, int signal, int status);
+ void MonitorSIGSTOP(lldb::pid_t pid);
+ void MonitorSIGTRAP(lldb::pid_t pid);
+ void MonitorSignal(lldb::pid_t pid, int signal);
+
+ Error GetSoftwareBreakpointPCOffset(uint32_t &actual_opcode_size);
+ Error FixupBreakpointPCAsNeeded(NativeThreadNetBSD &thread);
+ Error PopulateMemoryRegionCache();
+ void SigchldHandler();
+
+ ::pid_t Attach(lldb::pid_t pid, Error &error);
+
+ Error ReinitializeThreads();
+};
+
+} // namespace process_netbsd
+} // namespace lldb_private
+
+#endif // #ifndef liblldb_NativeProcessNetBSD_H_
diff --git a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
new file mode 100644
index 000000000000..1bb6324c97fe
--- /dev/null
+++ b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
@@ -0,0 +1,92 @@
+//===-- NativeRegisterContextNetBSD.cpp -------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "NativeRegisterContextNetBSD.h"
+
+#include "lldb/Host/common/NativeProcessProtocol.h"
+
+using namespace lldb_private;
+using namespace lldb_private::process_netbsd;
+
+// clang-format off
+#include <sys/types.h>
+#include <sys/ptrace.h>
+// clang-format on
+
+NativeRegisterContextNetBSD::NativeRegisterContextNetBSD(
+ NativeThreadProtocol &native_thread, uint32_t concrete_frame_idx,
+ RegisterInfoInterface *reg_info_interface_p)
+ : NativeRegisterContextRegisterInfo(native_thread, concrete_frame_idx,
+ reg_info_interface_p) {}
+
+Error NativeRegisterContextNetBSD::ReadGPR() {
+ void *buf = GetGPRBuffer();
+ if (!buf)
+ return Error("GPR buffer is NULL");
+
+ return DoReadGPR(buf);
+}
+
+Error NativeRegisterContextNetBSD::WriteGPR() {
+ void *buf = GetGPRBuffer();
+ if (!buf)
+ return Error("GPR buffer is NULL");
+
+ return DoWriteGPR(buf);
+}
+
+Error NativeRegisterContextNetBSD::ReadFPR() {
+ void *buf = GetFPRBuffer();
+ if (!buf)
+ return Error("FPR buffer is NULL");
+
+ return DoReadFPR(buf);
+}
+
+Error NativeRegisterContextNetBSD::WriteFPR() {
+ void *buf = GetFPRBuffer();
+ if (!buf)
+ return Error("FPR buffer is NULL");
+
+ return DoWriteFPR(buf);
+}
+
+Error NativeRegisterContextNetBSD::DoReadGPR(void *buf) {
+ return NativeProcessNetBSD::PtraceWrapper(PT_GETREGS, GetProcessPid(), buf,
+ m_thread.GetID());
+}
+
+Error NativeRegisterContextNetBSD::DoWriteGPR(void *buf) {
+ return NativeProcessNetBSD::PtraceWrapper(PT_SETREGS, GetProcessPid(), buf,
+ m_thread.GetID());
+}
+
+Error NativeRegisterContextNetBSD::DoReadFPR(void *buf) {
+ return NativeProcessNetBSD::PtraceWrapper(PT_GETFPREGS, GetProcessPid(), buf,
+ m_thread.GetID());
+}
+
+Error NativeRegisterContextNetBSD::DoWriteFPR(void *buf) {
+ return NativeProcessNetBSD::PtraceWrapper(PT_SETFPREGS, GetProcessPid(), buf,
+ m_thread.GetID());
+}
+
+NativeProcessNetBSD &NativeRegisterContextNetBSD::GetProcess() {
+ auto process_sp =
+ std::static_pointer_cast<NativeProcessNetBSD>(m_thread.GetProcess());
+ assert(process_sp);
+ return *process_sp;
+}
+
+::pid_t NativeRegisterContextNetBSD::GetProcessPid() {
+ NativeProcessNetBSD &process = GetProcess();
+ lldb::pid_t pid = process.GetID();
+
+ return pid;
+}
diff --git a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
new file mode 100644
index 000000000000..5ff59bc87c98
--- /dev/null
+++ b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
@@ -0,0 +1,65 @@
+//===-- NativeRegisterContextNetBSD.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_NativeRegisterContextNetBSD_h
+#define lldb_NativeRegisterContextNetBSD_h
+
+#include "lldb/Host/common/NativeThreadProtocol.h"
+
+#include "Plugins/Process/NetBSD/NativeProcessNetBSD.h"
+#include "Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h"
+
+namespace lldb_private {
+namespace process_netbsd {
+
+class NativeRegisterContextNetBSD : public NativeRegisterContextRegisterInfo {
+public:
+ NativeRegisterContextNetBSD(NativeThreadProtocol &native_thread,
+ uint32_t concrete_frame_idx,
+ RegisterInfoInterface *reg_info_interface_p);
+
+ // This function is implemented in the NativeRegisterContextNetBSD_*
+ // subclasses to create a new instance of the host specific
+ // NativeRegisterContextNetBSD. The implementations can't collide as only one
+ // NativeRegisterContextNetBSD_* variant should be compiled into the final
+ // executable.
+ static NativeRegisterContextNetBSD *
+ CreateHostNativeRegisterContextNetBSD(const ArchSpec &target_arch,
+ NativeThreadProtocol &native_thread,
+ uint32_t concrete_frame_idx);
+
+protected:
+ virtual Error ReadGPR();
+ virtual Error WriteGPR();
+
+ virtual Error ReadFPR();
+ virtual Error WriteFPR();
+
+ virtual void *GetGPRBuffer() { return nullptr; }
+ virtual size_t GetGPRSize() {
+ return GetRegisterInfoInterface().GetGPRSize();
+ }
+
+ virtual void *GetFPRBuffer() { return nullptr; }
+ virtual size_t GetFPRSize() { return 0; }
+
+ virtual Error DoReadGPR(void *buf);
+ virtual Error DoWriteGPR(void *buf);
+
+ virtual Error DoReadFPR(void *buf);
+ virtual Error DoWriteFPR(void *buf);
+
+ virtual NativeProcessNetBSD &GetProcess();
+ virtual ::pid_t GetProcessPid();
+};
+
+} // namespace process_netbsd
+} // namespace lldb_private
+
+#endif // #ifndef lldb_NativeRegisterContextNetBSD_h
diff --git a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
new file mode 100644
index 000000000000..76e64ac48d66
--- /dev/null
+++ b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
@@ -0,0 +1,483 @@
+//===-- NativeRegisterContextNetBSD_x86_64.cpp ---------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#if defined(__x86_64__)
+
+#include "NativeRegisterContextNetBSD_x86_64.h"
+
+#include "lldb/Core/RegisterValue.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
+
+#include "Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h"
+
+#include <elf.h>
+
+using namespace lldb_private;
+using namespace lldb_private::process_netbsd;
+
+// ----------------------------------------------------------------------------
+// Private namespace.
+// ----------------------------------------------------------------------------
+
+namespace {
+// x86 64-bit general purpose registers.
+static const uint32_t g_gpr_regnums_x86_64[] = {
+ lldb_rax_x86_64, lldb_rbx_x86_64, lldb_rcx_x86_64, lldb_rdx_x86_64,
+ lldb_rdi_x86_64, lldb_rsi_x86_64, lldb_rbp_x86_64, lldb_rsp_x86_64,
+ lldb_r8_x86_64, lldb_r9_x86_64, lldb_r10_x86_64, lldb_r11_x86_64,
+ lldb_r12_x86_64, lldb_r13_x86_64, lldb_r14_x86_64, lldb_r15_x86_64,
+ lldb_rip_x86_64, lldb_rflags_x86_64, lldb_cs_x86_64, lldb_fs_x86_64,
+ lldb_gs_x86_64, lldb_ss_x86_64, lldb_ds_x86_64, lldb_es_x86_64,
+ lldb_eax_x86_64, lldb_ebx_x86_64, lldb_ecx_x86_64, lldb_edx_x86_64,
+ lldb_edi_x86_64, lldb_esi_x86_64, lldb_ebp_x86_64, lldb_esp_x86_64,
+ lldb_r8d_x86_64, // Low 32 bits or r8
+ lldb_r9d_x86_64, // Low 32 bits or r9
+ lldb_r10d_x86_64, // Low 32 bits or r10
+ lldb_r11d_x86_64, // Low 32 bits or r11
+ lldb_r12d_x86_64, // Low 32 bits or r12
+ lldb_r13d_x86_64, // Low 32 bits or r13
+ lldb_r14d_x86_64, // Low 32 bits or r14
+ lldb_r15d_x86_64, // Low 32 bits or r15
+ lldb_ax_x86_64, lldb_bx_x86_64, lldb_cx_x86_64, lldb_dx_x86_64,
+ lldb_di_x86_64, lldb_si_x86_64, lldb_bp_x86_64, lldb_sp_x86_64,
+ lldb_r8w_x86_64, // Low 16 bits or r8
+ lldb_r9w_x86_64, // Low 16 bits or r9
+ lldb_r10w_x86_64, // Low 16 bits or r10
+ lldb_r11w_x86_64, // Low 16 bits or r11
+ lldb_r12w_x86_64, // Low 16 bits or r12
+ lldb_r13w_x86_64, // Low 16 bits or r13
+ lldb_r14w_x86_64, // Low 16 bits or r14
+ lldb_r15w_x86_64, // Low 16 bits or r15
+ lldb_ah_x86_64, lldb_bh_x86_64, lldb_ch_x86_64, lldb_dh_x86_64,
+ lldb_al_x86_64, lldb_bl_x86_64, lldb_cl_x86_64, lldb_dl_x86_64,
+ lldb_dil_x86_64, lldb_sil_x86_64, lldb_bpl_x86_64, lldb_spl_x86_64,
+ lldb_r8l_x86_64, // Low 8 bits or r8
+ lldb_r9l_x86_64, // Low 8 bits or r9
+ lldb_r10l_x86_64, // Low 8 bits or r10
+ lldb_r11l_x86_64, // Low 8 bits or r11
+ lldb_r12l_x86_64, // Low 8 bits or r12
+ lldb_r13l_x86_64, // Low 8 bits or r13
+ lldb_r14l_x86_64, // Low 8 bits or r14
+ lldb_r15l_x86_64, // Low 8 bits or r15
+ LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+static_assert((sizeof(g_gpr_regnums_x86_64) / sizeof(g_gpr_regnums_x86_64[0])) -
+ 1 ==
+ k_num_gpr_registers_x86_64,
+ "g_gpr_regnums_x86_64 has wrong number of register infos");
+
+// Number of register sets provided by this context.
+enum { k_num_extended_register_sets = 2, k_num_register_sets = 4 };
+
+// Register sets for x86 64-bit.
+static const RegisterSet g_reg_sets_x86_64[k_num_register_sets] = {
+ {"General Purpose Registers", "gpr", k_num_gpr_registers_x86_64,
+ g_gpr_regnums_x86_64},
+};
+
+#define REG_CONTEXT_SIZE (GetRegisterInfoInterface().GetGPRSize())
+
+} // namespace
+
+NativeRegisterContextNetBSD *
+NativeRegisterContextNetBSD::CreateHostNativeRegisterContextNetBSD(
+ const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
+ uint32_t concrete_frame_idx) {
+ return new NativeRegisterContextNetBSD_x86_64(target_arch, native_thread,
+ concrete_frame_idx);
+}
+
+// ----------------------------------------------------------------------------
+// NativeRegisterContextNetBSD_x86_64 members.
+// ----------------------------------------------------------------------------
+
+static RegisterInfoInterface *
+CreateRegisterInfoInterface(const ArchSpec &target_arch) {
+ assert((HostInfo::GetArchitecture().GetAddressByteSize() == 8) &&
+ "Register setting path assumes this is a 64-bit host");
+ // X86_64 hosts know how to work with 64-bit and 32-bit EXEs using the
+ // x86_64 register context.
+ return new RegisterContextNetBSD_x86_64(target_arch);
+}
+
+NativeRegisterContextNetBSD_x86_64::NativeRegisterContextNetBSD_x86_64(
+ const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
+ uint32_t concrete_frame_idx)
+ : NativeRegisterContextNetBSD(native_thread, concrete_frame_idx,
+ CreateRegisterInfoInterface(target_arch)),
+ m_gpr_x86_64() {}
+
+// CONSIDER after local and llgs debugging are merged, register set support can
+// be moved into a base x86-64 class with IsRegisterSetAvailable made virtual.
+uint32_t NativeRegisterContextNetBSD_x86_64::GetRegisterSetCount() const {
+ uint32_t sets = 0;
+ for (uint32_t set_index = 0; set_index < k_num_register_sets; ++set_index) {
+ if (GetSetForNativeRegNum(set_index) != -1)
+ ++sets;
+ }
+
+ return sets;
+}
+
+const RegisterSet *
+NativeRegisterContextNetBSD_x86_64::GetRegisterSet(uint32_t set_index) const {
+ switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) {
+ case llvm::Triple::x86_64:
+ return &g_reg_sets_x86_64[set_index];
+ default:
+ assert(false && "Unhandled target architecture.");
+ return nullptr;
+ }
+
+ return nullptr;
+}
+
+int NativeRegisterContextNetBSD_x86_64::GetSetForNativeRegNum(
+ int reg_num) const {
+ if (reg_num < lldb_fctrl_x86_64)
+ return GPRegSet;
+ else
+ return -1;
+}
+
+int NativeRegisterContextNetBSD_x86_64::ReadRegisterSet(uint32_t set) {
+ switch (set) {
+ case GPRegSet:
+ ReadGPR();
+ return 0;
+ case FPRegSet:
+ ReadFPR();
+ return 0;
+ default:
+ break;
+ }
+ return -1;
+}
+int NativeRegisterContextNetBSD_x86_64::WriteRegisterSet(uint32_t set) {
+ switch (set) {
+ case GPRegSet:
+ WriteGPR();
+ return 0;
+ case FPRegSet:
+ WriteFPR();
+ return 0;
+ default:
+ break;
+ }
+ return -1;
+}
+
+Error NativeRegisterContextNetBSD_x86_64::ReadRegister(
+ const RegisterInfo *reg_info, RegisterValue &reg_value) {
+ Error error;
+
+ if (!reg_info) {
+ error.SetErrorString("reg_info NULL");
+ return error;
+ }
+
+ const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
+ if (reg == LLDB_INVALID_REGNUM) {
+ // This is likely an internal register for lldb use only and should not be
+ // directly queried.
+ error.SetErrorStringWithFormat("register \"%s\" is an internal-only lldb "
+ "register, cannot read directly",
+ reg_info->name);
+ return error;
+ }
+
+ int set = GetSetForNativeRegNum(reg);
+ if (set == -1) {
+ // This is likely an internal register for lldb use only and should not be
+ // directly queried.
+ error.SetErrorStringWithFormat("register \"%s\" is in unrecognized set",
+ reg_info->name);
+ return error;
+ }
+
+ if (ReadRegisterSet(set) != 0) {
+ // This is likely an internal register for lldb use only and should not be
+ // directly queried.
+ error.SetErrorStringWithFormat(
+ "reading register set for register \"%s\" failed", reg_info->name);
+ return error;
+ }
+
+ switch (reg) {
+ case lldb_rax_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RAX];
+ break;
+ case lldb_rbx_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RBX];
+ break;
+ case lldb_rcx_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RCX];
+ break;
+ case lldb_rdx_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RDX];
+ break;
+ case lldb_rdi_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RDI];
+ break;
+ case lldb_rsi_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RSI];
+ break;
+ case lldb_rbp_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RBP];
+ break;
+ case lldb_rsp_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RSP];
+ break;
+ case lldb_r8_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R8];
+ break;
+ case lldb_r9_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R9];
+ break;
+ case lldb_r10_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R10];
+ break;
+ case lldb_r11_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R11];
+ break;
+ case lldb_r12_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R12];
+ break;
+ case lldb_r13_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R13];
+ break;
+ case lldb_r14_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R14];
+ break;
+ case lldb_r15_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_R15];
+ break;
+ case lldb_rip_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RIP];
+ break;
+ case lldb_rflags_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_RFLAGS];
+ break;
+ case lldb_cs_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_CS];
+ break;
+ case lldb_fs_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_FS];
+ break;
+ case lldb_gs_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_GS];
+ break;
+ case lldb_ss_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_SS];
+ break;
+ case lldb_ds_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_DS];
+ break;
+ case lldb_es_x86_64:
+ reg_value = (uint64_t)m_gpr_x86_64.regs[_REG_ES];
+ break;
+ }
+
+ return error;
+}
+
+Error NativeRegisterContextNetBSD_x86_64::WriteRegister(
+ const RegisterInfo *reg_info, const RegisterValue &reg_value) {
+
+ Error error;
+
+ if (!reg_info) {
+ error.SetErrorString("reg_info NULL");
+ return error;
+ }
+
+ const uint32_t reg = reg_info->kinds[lldb::eRegisterKindLLDB];
+ if (reg == LLDB_INVALID_REGNUM) {
+ // This is likely an internal register for lldb use only and should not be
+ // directly queried.
+ error.SetErrorStringWithFormat("register \"%s\" is an internal-only lldb "
+ "register, cannot read directly",
+ reg_info->name);
+ return error;
+ }
+
+ int set = GetSetForNativeRegNum(reg);
+ if (set == -1) {
+ // This is likely an internal register for lldb use only and should not be
+ // directly queried.
+ error.SetErrorStringWithFormat("register \"%s\" is in unrecognized set",
+ reg_info->name);
+ return error;
+ }
+
+ if (ReadRegisterSet(set) != 0) {
+ // This is likely an internal register for lldb use only and should not be
+ // directly queried.
+ error.SetErrorStringWithFormat(
+ "reading register set for register \"%s\" failed", reg_info->name);
+ return error;
+ }
+
+ switch (reg) {
+ case lldb_rax_x86_64:
+ m_gpr_x86_64.regs[_REG_RAX] = reg_value.GetAsUInt64();
+ break;
+ case lldb_rbx_x86_64:
+ m_gpr_x86_64.regs[_REG_RBX] = reg_value.GetAsUInt64();
+ break;
+ case lldb_rcx_x86_64:
+ m_gpr_x86_64.regs[_REG_RCX] = reg_value.GetAsUInt64();
+ break;
+ case lldb_rdx_x86_64:
+ m_gpr_x86_64.regs[_REG_RDX] = reg_value.GetAsUInt64();
+ break;
+ case lldb_rdi_x86_64:
+ m_gpr_x86_64.regs[_REG_RDI] = reg_value.GetAsUInt64();
+ break;
+ case lldb_rsi_x86_64:
+ m_gpr_x86_64.regs[_REG_RSI] = reg_value.GetAsUInt64();
+ break;
+ case lldb_rbp_x86_64:
+ m_gpr_x86_64.regs[_REG_RBP] = reg_value.GetAsUInt64();
+ break;
+ case lldb_rsp_x86_64:
+ m_gpr_x86_64.regs[_REG_RSP] = reg_value.GetAsUInt64();
+ break;
+ case lldb_r8_x86_64:
+ m_gpr_x86_64.regs[_REG_R8] = reg_value.GetAsUInt64();
+ break;
+ case lldb_r9_x86_64:
+ m_gpr_x86_64.regs[_REG_R9] = reg_value.GetAsUInt64();
+ break;
+ case lldb_r10_x86_64:
+ m_gpr_x86_64.regs[_REG_R10] = reg_value.GetAsUInt64();
+ break;
+ case lldb_r11_x86_64:
+ m_gpr_x86_64.regs[_REG_R11] = reg_value.GetAsUInt64();
+ break;
+ case lldb_r12_x86_64:
+ m_gpr_x86_64.regs[_REG_R12] = reg_value.GetAsUInt64();
+ break;
+ case lldb_r13_x86_64:
+ m_gpr_x86_64.regs[_REG_R13] = reg_value.GetAsUInt64();
+ break;
+ case lldb_r14_x86_64:
+ m_gpr_x86_64.regs[_REG_R14] = reg_value.GetAsUInt64();
+ break;
+ case lldb_r15_x86_64:
+ m_gpr_x86_64.regs[_REG_R15] = reg_value.GetAsUInt64();
+ break;
+ case lldb_rip_x86_64:
+ m_gpr_x86_64.regs[_REG_RIP] = reg_value.GetAsUInt64();
+ break;
+ case lldb_rflags_x86_64:
+ m_gpr_x86_64.regs[_REG_RFLAGS] = reg_value.GetAsUInt64();
+ break;
+ case lldb_cs_x86_64:
+ m_gpr_x86_64.regs[_REG_CS] = reg_value.GetAsUInt64();
+ break;
+ case lldb_fs_x86_64:
+ m_gpr_x86_64.regs[_REG_FS] = reg_value.GetAsUInt64();
+ break;
+ case lldb_gs_x86_64:
+ m_gpr_x86_64.regs[_REG_GS] = reg_value.GetAsUInt64();
+ break;
+ case lldb_ss_x86_64:
+ m_gpr_x86_64.regs[_REG_SS] = reg_value.GetAsUInt64();
+ break;
+ case lldb_ds_x86_64:
+ m_gpr_x86_64.regs[_REG_DS] = reg_value.GetAsUInt64();
+ break;
+ case lldb_es_x86_64:
+ m_gpr_x86_64.regs[_REG_ES] = reg_value.GetAsUInt64();
+ break;
+ }
+
+ if (WriteRegisterSet(set) != 0)
+ error.SetErrorStringWithFormat("failed to write register set");
+
+ return error;
+}
+
+Error NativeRegisterContextNetBSD_x86_64::ReadAllRegisterValues(
+ lldb::DataBufferSP &data_sp) {
+ Error error;
+
+ data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
+ if (!data_sp) {
+ error.SetErrorStringWithFormat(
+ "failed to allocate DataBufferHeap instance of size %" PRIu64,
+ REG_CONTEXT_SIZE);
+ return error;
+ }
+
+ error = ReadGPR();
+ if (error.Fail())
+ return error;
+
+ uint8_t *dst = data_sp->GetBytes();
+ if (dst == nullptr) {
+ error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64
+ " returned a null pointer",
+ REG_CONTEXT_SIZE);
+ return error;
+ }
+
+ ::memcpy(dst, &m_gpr_x86_64, GetRegisterInfoInterface().GetGPRSize());
+ dst += GetRegisterInfoInterface().GetGPRSize();
+
+ RegisterValue value((uint64_t)-1);
+ const RegisterInfo *reg_info =
+ GetRegisterInfoInterface().GetDynamicRegisterInfo("orig_eax");
+ if (reg_info == nullptr)
+ reg_info = GetRegisterInfoInterface().GetDynamicRegisterInfo("orig_rax");
+ return error;
+}
+
+Error NativeRegisterContextNetBSD_x86_64::WriteAllRegisterValues(
+ const lldb::DataBufferSP &data_sp) {
+ Error error;
+
+ if (!data_sp) {
+ error.SetErrorStringWithFormat(
+ "NativeRegisterContextNetBSD_x86_64::%s invalid data_sp provided",
+ __FUNCTION__);
+ return error;
+ }
+
+ if (data_sp->GetByteSize() != REG_CONTEXT_SIZE) {
+ error.SetErrorStringWithFormat(
+ "NativeRegisterContextNetBSD_x86_64::%s data_sp contained mismatched "
+ "data size, expected %" PRIu64 ", actual %" PRIu64,
+ __FUNCTION__, REG_CONTEXT_SIZE, data_sp->GetByteSize());
+ return error;
+ }
+
+ uint8_t *src = data_sp->GetBytes();
+ if (src == nullptr) {
+ error.SetErrorStringWithFormat("NativeRegisterContextNetBSD_x86_64::%s "
+ "DataBuffer::GetBytes() returned a null "
+ "pointer",
+ __FUNCTION__);
+ return error;
+ }
+ ::memcpy(&m_gpr_x86_64, src, GetRegisterInfoInterface().GetGPRSize());
+
+ error = WriteGPR();
+ if (error.Fail())
+ return error;
+ src += GetRegisterInfoInterface().GetGPRSize();
+
+ return error;
+}
+
+#endif // defined(__x86_64__)
diff --git a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
new file mode 100644
index 000000000000..f6f7d7f0976a
--- /dev/null
+++ b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
@@ -0,0 +1,72 @@
+//===-- NativeRegisterContextNetBSD_x86_64.h --------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#if defined(__x86_64__)
+
+#ifndef lldb_NativeRegisterContextNetBSD_x86_64_h
+#define lldb_NativeRegisterContextNetBSD_x86_64_h
+
+// clang-format off
+#include <sys/param.h>
+#include <sys/types.h>
+#include <machine/reg.h>
+// clang-format on
+
+#include "Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h"
+#include "Plugins/Process/Utility/RegisterContext_x86.h"
+#include "Plugins/Process/Utility/lldb-x86-register-enums.h"
+
+namespace lldb_private {
+namespace process_netbsd {
+
+class NativeProcessNetBSD;
+
+class NativeRegisterContextNetBSD_x86_64 : public NativeRegisterContextNetBSD {
+public:
+ NativeRegisterContextNetBSD_x86_64(const ArchSpec &target_arch,
+ NativeThreadProtocol &native_thread,
+ uint32_t concrete_frame_idx);
+ uint32_t GetRegisterSetCount() const override;
+
+ const RegisterSet *GetRegisterSet(uint32_t set_index) const override;
+
+ Error ReadRegister(const RegisterInfo *reg_info,
+ RegisterValue &reg_value) override;
+
+ Error WriteRegister(const RegisterInfo *reg_info,
+ const RegisterValue &reg_value) override;
+
+ Error ReadAllRegisterValues(lldb::DataBufferSP &data_sp) override;
+
+ Error WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
+
+protected:
+ void *GetGPRBuffer() override { return &m_gpr_x86_64; }
+ void *GetFPRBuffer() override { return &m_fpr_x86_64; }
+
+private:
+ // Private member types.
+ enum { GPRegSet, FPRegSet };
+
+ // Private member variables.
+ struct reg m_gpr_x86_64;
+ struct fpreg m_fpr_x86_64;
+
+ int GetSetForNativeRegNum(int reg_num) const;
+
+ int ReadRegisterSet(uint32_t set);
+ int WriteRegisterSet(uint32_t set);
+};
+
+} // namespace process_netbsd
+} // namespace lldb_private
+
+#endif // #ifndef lldb_NativeRegisterContextNetBSD_x86_64_h
+
+#endif // defined(__x86_64__)
diff --git a/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp b/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
new file mode 100644
index 000000000000..f23621e45aad
--- /dev/null
+++ b/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
@@ -0,0 +1,159 @@
+//===-- NativeThreadNetBSD.cpp -------------------------------- -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "NativeThreadNetBSD.h"
+#include "NativeRegisterContextNetBSD.h"
+
+#include "NativeProcessNetBSD.h"
+
+#include "Plugins/Process/POSIX/CrashReason.h"
+#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
+#include "lldb/Core/RegisterValue.h"
+#include "lldb/Core/State.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::process_netbsd;
+
+NativeThreadNetBSD::NativeThreadNetBSD(NativeProcessNetBSD *process,
+ lldb::tid_t tid)
+ : NativeThreadProtocol(process, tid), m_state(StateType::eStateInvalid),
+ m_stop_info(), m_reg_context_sp(), m_stop_description() {}
+
+void NativeThreadNetBSD::SetStoppedBySignal(uint32_t signo,
+ const siginfo_t *info) {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD));
+ LLDB_LOG(log, "tid = {0} in called with signal {1}", GetID(), signo);
+
+ SetStopped();
+
+ m_stop_info.reason = StopReason::eStopReasonSignal;
+ m_stop_info.details.signal.signo = signo;
+
+ m_stop_description.clear();
+ if (info) {
+ switch (signo) {
+ case SIGSEGV:
+ case SIGBUS:
+ case SIGFPE:
+ case SIGILL:
+ const auto reason = GetCrashReason(*info);
+ m_stop_description = GetCrashReasonString(reason, *info);
+ break;
+ }
+ }
+}
+
+void NativeThreadNetBSD::SetStoppedByBreakpoint() {
+ SetStopped();
+ m_stop_info.reason = StopReason::eStopReasonBreakpoint;
+ m_stop_info.details.signal.signo = SIGTRAP;
+}
+
+void NativeThreadNetBSD::SetStoppedByTrace() {
+ SetStopped();
+ m_stop_info.reason = StopReason::eStopReasonTrace;
+ m_stop_info.details.signal.signo = SIGTRAP;
+}
+
+void NativeThreadNetBSD::SetStoppedByExec() {
+ SetStopped();
+ m_stop_info.reason = StopReason::eStopReasonExec;
+ m_stop_info.details.signal.signo = SIGTRAP;
+}
+
+void NativeThreadNetBSD::SetStopped() {
+ const StateType new_state = StateType::eStateStopped;
+ m_state = new_state;
+ m_stop_description.clear();
+}
+
+void NativeThreadNetBSD::SetRunning() {
+ m_state = StateType::eStateRunning;
+ m_stop_info.reason = StopReason::eStopReasonNone;
+}
+
+void NativeThreadNetBSD::SetStepping() {
+ m_state = StateType::eStateStepping;
+ m_stop_info.reason = StopReason::eStopReasonNone;
+}
+
+std::string NativeThreadNetBSD::GetName() { return std::string(""); }
+
+lldb::StateType NativeThreadNetBSD::GetState() { return m_state; }
+
+bool NativeThreadNetBSD::GetStopReason(ThreadStopInfo &stop_info,
+ std::string &description) {
+ Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD));
+
+ description.clear();
+
+ switch (m_state) {
+ case eStateStopped:
+ case eStateCrashed:
+ case eStateExited:
+ case eStateSuspended:
+ case eStateUnloaded:
+ stop_info = m_stop_info;
+ description = m_stop_description;
+
+ return true;
+
+ case eStateInvalid:
+ case eStateConnected:
+ case eStateAttaching:
+ case eStateLaunching:
+ case eStateRunning:
+ case eStateStepping:
+ case eStateDetached:
+ LLDB_LOG(log, "tid = {0} in state {1} cannot answer stop reason", GetID(),
+ StateAsCString(m_state));
+ return false;
+ }
+ llvm_unreachable("unhandled StateType!");
+}
+
+NativeRegisterContextSP NativeThreadNetBSD::GetRegisterContext() {
+ // Return the register context if we already created it.
+ if (m_reg_context_sp)
+ return m_reg_context_sp;
+
+ NativeProcessProtocolSP m_process_sp = m_process_wp.lock();
+ if (!m_process_sp)
+ return NativeRegisterContextSP();
+
+ ArchSpec target_arch;
+ if (!m_process_sp->GetArchitecture(target_arch))
+ return NativeRegisterContextSP();
+
+ const uint32_t concrete_frame_idx = 0;
+ m_reg_context_sp.reset(
+ NativeRegisterContextNetBSD::CreateHostNativeRegisterContextNetBSD(
+ target_arch, *this, concrete_frame_idx));
+
+ return m_reg_context_sp;
+}
+
+Error NativeThreadNetBSD::SetWatchpoint(lldb::addr_t addr, size_t size,
+ uint32_t watch_flags, bool hardware) {
+ return Error("Unimplemented");
+}
+
+Error NativeThreadNetBSD::RemoveWatchpoint(lldb::addr_t addr) {
+ return Error("Unimplemented");
+}
+
+Error NativeThreadNetBSD::SetHardwareBreakpoint(lldb::addr_t addr,
+ size_t size) {
+ return Error("Unimplemented");
+}
+
+Error NativeThreadNetBSD::RemoveHardwareBreakpoint(lldb::addr_t addr) {
+ return Error("Unimplemented");
+}
diff --git a/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h b/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
new file mode 100644
index 000000000000..85fff5d5653f
--- /dev/null
+++ b/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
@@ -0,0 +1,73 @@
+//===-- NativeThreadNetBSD.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_NativeThreadNetBSD_H_
+#define liblldb_NativeThreadNetBSD_H_
+
+#include "lldb/Host/common/NativeThreadProtocol.h"
+
+namespace lldb_private {
+namespace process_netbsd {
+
+class NativeProcessNetBSD;
+
+class NativeThreadNetBSD : public NativeThreadProtocol {
+ friend class NativeProcessNetBSD;
+
+public:
+ NativeThreadNetBSD(NativeProcessNetBSD *process, lldb::tid_t tid);
+
+ // ---------------------------------------------------------------------
+ // NativeThreadProtocol Interface
+ // ---------------------------------------------------------------------
+ std::string GetName() override;
+
+ lldb::StateType GetState() override;
+
+ bool GetStopReason(ThreadStopInfo &stop_info,
+ std::string &description) override;
+
+ NativeRegisterContextSP GetRegisterContext() override;
+
+ Error SetWatchpoint(lldb::addr_t addr, size_t size, uint32_t watch_flags,
+ bool hardware) override;
+
+ Error RemoveWatchpoint(lldb::addr_t addr) override;
+
+ Error SetHardwareBreakpoint(lldb::addr_t addr, size_t size) override;
+
+ Error RemoveHardwareBreakpoint(lldb::addr_t addr) override;
+
+private:
+ // ---------------------------------------------------------------------
+ // Interface for friend classes
+ // ---------------------------------------------------------------------
+
+ void SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr);
+ void SetStoppedByBreakpoint();
+ void SetStoppedByTrace();
+ void SetStoppedByExec();
+ void SetStopped();
+ void SetRunning();
+ void SetStepping();
+
+ // ---------------------------------------------------------------------
+ // Member Variables
+ // ---------------------------------------------------------------------
+ lldb::StateType m_state;
+ ThreadStopInfo m_stop_info;
+ NativeRegisterContextSP m_reg_context_sp;
+ std::string m_stop_description;
+};
+
+typedef std::shared_ptr<NativeThreadNetBSD> NativeThreadNetBSDSP;
+} // namespace process_netbsd
+} // namespace lldb_private
+
+#endif // #ifndef liblldb_NativeThreadNetBSD_H_
diff --git a/source/Plugins/Process/POSIX/CMakeLists.txt b/source/Plugins/Process/POSIX/CMakeLists.txt
index 2ed7326dbb71..66fb7aa155b4 100644
--- a/source/Plugins/Process/POSIX/CMakeLists.txt
+++ b/source/Plugins/Process/POSIX/CMakeLists.txt
@@ -1,8 +1,14 @@
include_directories(.)
include_directories(../Utility)
-add_lldb_library(lldbPluginProcessPOSIX
+add_lldb_library(lldbPluginProcessPOSIX PLUGIN
CrashReason.cpp
ProcessMessage.cpp
ProcessPOSIXLog.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbInterpreter
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/Process/POSIX/CrashReason.cpp b/source/Plugins/Process/POSIX/CrashReason.cpp
index 77d6e287486c..864418c90031 100644
--- a/source/Plugins/Process/POSIX/CrashReason.cpp
+++ b/source/Plugins/Process/POSIX/CrashReason.cpp
@@ -62,7 +62,6 @@ CrashReason GetCrashReasonForSIGSEGV(const siginfo_t &info) {
return CrashReason::eBoundViolation;
}
- assert(false && "unexpected si_code for SIGSEGV");
return CrashReason::eInvalidCrashReason;
}
@@ -88,7 +87,6 @@ CrashReason GetCrashReasonForSIGILL(const siginfo_t &info) {
return CrashReason::eInternalStackError;
}
- assert(false && "unexpected si_code for SIGILL");
return CrashReason::eInvalidCrashReason;
}
@@ -114,7 +112,6 @@ CrashReason GetCrashReasonForSIGFPE(const siginfo_t &info) {
return CrashReason::eFloatSubscriptRange;
}
- assert(false && "unexpected si_code for SIGFPE");
return CrashReason::eInvalidCrashReason;
}
@@ -130,7 +127,6 @@ CrashReason GetCrashReasonForSIGBUS(const siginfo_t &info) {
return CrashReason::eHardwareError;
}
- assert(false && "unexpected si_code for SIGBUS");
return CrashReason::eInvalidCrashReason;
}
}
@@ -158,7 +154,7 @@ std::string GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr) {
switch (reason) {
default:
- assert(false && "invalid CrashReason");
+ str = "unknown crash reason";
break;
case CrashReason::eInvalidAddress:
diff --git a/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp b/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
index 9ced11c7ca2a..f1beb0f7f738 100644
--- a/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
+++ b/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
@@ -10,188 +10,23 @@
#include "ProcessPOSIXLog.h"
-#include <mutex>
+#include "llvm/Support/Threading.h"
-#include "lldb/Core/StreamFile.h"
-#include "lldb/Interpreter/Args.h"
-
-#include "ProcessPOSIXLog.h"
-
-using namespace lldb;
using namespace lldb_private;
-// We want to avoid global constructors where code needs to be run so here we
-// control access to our static g_log_sp by hiding it in a singleton function
-// that will construct the static g_log_sp the first time this function is
-// called.
-static bool g_log_enabled = false;
-static Log *g_log = NULL;
-static Log *GetLog() {
- if (!g_log_enabled)
- return NULL;
- return g_log;
-}
+static constexpr Log::Category g_categories[] = {
+ {{"break"}, {"log breakpoints"}, POSIX_LOG_BREAKPOINTS},
+ {{"memory"}, {"log memory reads and writes"}, POSIX_LOG_MEMORY},
+ {{"process"}, {"log process events and activities"}, POSIX_LOG_PROCESS},
+ {{"ptrace"}, {"log all calls to ptrace"}, POSIX_LOG_PTRACE},
+ {{"registers"}, {"log register read/writes"}, POSIX_LOG_REGISTERS},
+ {{"thread"}, {"log thread events and activities"}, POSIX_LOG_THREAD},
+ {{"watch"}, {"log watchpoint related activities"}, POSIX_LOG_WATCHPOINTS},
+};
-void ProcessPOSIXLog::Initialize(ConstString name) {
- static std::once_flag g_once_flag;
-
- std::call_once(g_once_flag, [name]() {
- Log::Callbacks log_callbacks = {DisableLog, EnableLog, ListLogCategories};
-
- Log::RegisterLogChannel(name, log_callbacks);
- RegisterPluginName(name);
- });
-}
+Log::Channel ProcessPOSIXLog::g_channel(g_categories, POSIX_LOG_DEFAULT);
-Log *ProcessPOSIXLog::GetLogIfAllCategoriesSet(uint32_t mask) {
- Log *log(GetLog());
- if (log && mask) {
- uint32_t log_mask = log->GetMask().Get();
- if ((log_mask & mask) != mask)
- return NULL;
- }
- return log;
+void ProcessPOSIXLog::Initialize() {
+ static llvm::once_flag g_once_flag;
+ llvm::call_once(g_once_flag, []() { Log::Register("posix", g_channel); });
}
-
-static uint32_t GetFlagBits(const char *arg) {
- if (::strcasecmp(arg, "all") == 0)
- return POSIX_LOG_ALL;
- else if (::strcasecmp(arg, "async") == 0)
- return POSIX_LOG_ASYNC;
- else if (::strncasecmp(arg, "break", 5) == 0)
- return POSIX_LOG_BREAKPOINTS;
- else if (::strncasecmp(arg, "comm", 4) == 0)
- return POSIX_LOG_COMM;
- else if (::strcasecmp(arg, "default") == 0)
- return POSIX_LOG_DEFAULT;
- else if (::strcasecmp(arg, "packets") == 0)
- return POSIX_LOG_PACKETS;
- else if (::strcasecmp(arg, "memory") == 0)
- return POSIX_LOG_MEMORY;
- else if (::strcasecmp(arg, "data-short") == 0)
- return POSIX_LOG_MEMORY_DATA_SHORT;
- else if (::strcasecmp(arg, "data-long") == 0)
- return POSIX_LOG_MEMORY_DATA_LONG;
- else if (::strcasecmp(arg, "process") == 0)
- return POSIX_LOG_PROCESS;
- else if (::strcasecmp(arg, "ptrace") == 0)
- return POSIX_LOG_PTRACE;
- else if (::strcasecmp(arg, "registers") == 0)
- return POSIX_LOG_REGISTERS;
- else if (::strcasecmp(arg, "step") == 0)
- return POSIX_LOG_STEP;
- else if (::strcasecmp(arg, "thread") == 0)
- return POSIX_LOG_THREAD;
- else if (::strcasecmp(arg, "verbose") == 0)
- return POSIX_LOG_VERBOSE;
- else if (::strncasecmp(arg, "watch", 5) == 0)
- return POSIX_LOG_WATCHPOINTS;
- return 0;
-}
-
-void ProcessPOSIXLog::DisableLog(const char **args, Stream *feedback_strm) {
- Log *log(GetLog());
- if (log) {
- uint32_t flag_bits = 0;
-
- flag_bits = log->GetMask().Get();
- for (; args && args[0]; args++) {
- const char *arg = args[0];
- uint32_t bits = GetFlagBits(arg);
-
- if (bits) {
- flag_bits &= ~bits;
- } else {
- feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
- ListLogCategories(feedback_strm);
- }
- }
-
- log->GetMask().Reset(flag_bits);
- if (flag_bits == 0)
- g_log_enabled = false;
- }
-
- return;
-}
-
-Log *ProcessPOSIXLog::EnableLog(StreamSP &log_stream_sp, uint32_t log_options,
- const char **args, Stream *feedback_strm) {
- // Try see if there already is a log - that way we can reuse its settings.
- // We could reuse the log in toto, but we don't know that the stream is the
- // same.
- uint32_t flag_bits = 0;
- if (g_log)
- flag_bits = g_log->GetMask().Get();
-
- // Now make a new log with this stream if one was provided
- if (log_stream_sp) {
- if (g_log)
- g_log->SetStream(log_stream_sp);
- else
- g_log = new Log(log_stream_sp);
- }
-
- if (g_log) {
- bool got_unknown_category = false;
- for (; args && args[0]; args++) {
- const char *arg = args[0];
- uint32_t bits = GetFlagBits(arg);
-
- if (bits) {
- flag_bits |= bits;
- } else {
- feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
- if (got_unknown_category == false) {
- got_unknown_category = true;
- ListLogCategories(feedback_strm);
- }
- }
- }
- if (flag_bits == 0)
- flag_bits = POSIX_LOG_DEFAULT;
- g_log->GetMask().Reset(flag_bits);
- g_log->GetOptions().Reset(log_options);
- g_log_enabled = true;
- }
- return g_log;
-}
-
-void ProcessPOSIXLog::ListLogCategories(Stream *strm) {
- strm->Printf(
- "Logging categories for '%s':\n"
- " all - turn on all available logging categories\n"
- " async - log asynchronous activity\n"
- " break - log breakpoints\n"
- " communication - log communication activity\n"
- " default - enable the default set of logging categories for liblldb\n"
- " packets - log gdb remote packets\n"
- " memory - log memory reads and writes\n"
- " data-short - log memory bytes for memory reads and writes for short "
- "transactions only\n"
- " data-long - log memory bytes for memory reads and writes for all "
- "transactions\n"
- " process - log process events and activities\n"
-#ifndef LLDB_CONFIGURATION_BUILDANDINTEGRATION
- " ptrace - log all calls to ptrace\n"
-#endif
- " registers - log register read/writes\n"
- " thread - log thread events and activities\n"
- " step - log step related activities\n"
- " verbose - enable verbose logging\n"
- " watch - log watchpoint related activities\n",
- ProcessPOSIXLog::m_pluginname);
-}
-
-void ProcessPOSIXLog::LogIf(uint32_t mask, const char *format, ...) {
- Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(mask));
- if (log) {
- va_list args;
- va_start(args, format);
- log->VAPrintf(format, args);
- va_end(args);
- }
-}
-
-int ProcessPOSIXLog::m_nestinglevel;
-const char *ProcessPOSIXLog::m_pluginname = "";
diff --git a/source/Plugins/Process/POSIX/ProcessPOSIXLog.h b/source/Plugins/Process/POSIX/ProcessPOSIXLog.h
index 7d187da4e488..134013517a11 100644
--- a/source/Plugins/Process/POSIX/ProcessPOSIXLog.h
+++ b/source/Plugins/Process/POSIX/ProcessPOSIXLog.h
@@ -16,87 +16,29 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Log.h"
+#include "lldb/Utility/Log.h"
-#define POSIX_LOG_VERBOSE (1u << 0)
#define POSIX_LOG_PROCESS (1u << 1)
#define POSIX_LOG_THREAD (1u << 2)
-#define POSIX_LOG_PACKETS (1u << 3)
#define POSIX_LOG_MEMORY (1u << 4) // Log memory reads/writes calls
-#define POSIX_LOG_MEMORY_DATA_SHORT \
- (1u << 5) // Log short memory reads/writes bytes
-#define POSIX_LOG_MEMORY_DATA_LONG \
- (1u << 6) // Log all memory reads/writes bytes
+#define POSIX_LOG_PTRACE (1u << 5)
+#define POSIX_LOG_REGISTERS (1u << 6)
#define POSIX_LOG_BREAKPOINTS (1u << 7)
#define POSIX_LOG_WATCHPOINTS (1u << 8)
-#define POSIX_LOG_STEP (1u << 9)
-#define POSIX_LOG_COMM (1u << 10)
-#define POSIX_LOG_ASYNC (1u << 11)
-#define POSIX_LOG_PTRACE (1u << 12)
-#define POSIX_LOG_REGISTERS (1u << 13)
#define POSIX_LOG_ALL (UINT32_MAX)
-#define POSIX_LOG_DEFAULT POSIX_LOG_PACKETS
-
-// The size which determines "short memory reads/writes".
-#define POSIX_LOG_MEMORY_SHORT_BYTES (4 * sizeof(ptrdiff_t))
+#define POSIX_LOG_DEFAULT POSIX_LOG_PROCESS
+namespace lldb_private {
class ProcessPOSIXLog {
- static int m_nestinglevel;
- static const char *m_pluginname;
+ static Log::Channel g_channel;
public:
- // ---------------------------------------------------------------------
- // Public Static Methods
- // ---------------------------------------------------------------------
- static void Initialize(lldb_private::ConstString name);
-
- static void RegisterPluginName(const char *pluginName) {
- m_pluginname = pluginName;
- }
-
- static void RegisterPluginName(lldb_private::ConstString pluginName) {
- m_pluginname = pluginName.GetCString();
- }
-
- static lldb_private::Log *GetLogIfAllCategoriesSet(uint32_t mask = 0);
-
- static void DisableLog(const char **args,
- lldb_private::Stream *feedback_strm);
-
- static lldb_private::Log *EnableLog(lldb::StreamSP &log_stream_sp,
- uint32_t log_options, const char **args,
- lldb_private::Stream *feedback_strm);
-
- static void ListLogCategories(lldb_private::Stream *strm);
-
- static void LogIf(uint32_t mask, const char *format, ...);
-
- // The following functions can be used to enable the client to limit
- // logging to only the top level function calls. This is useful for
- // recursive functions. FIXME: not thread safe!
- // Example:
- // void NestingFunc() {
- // LogSP log
- // (ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_ALL));
- // if (log)
- // {
- // ProcessPOSIXLog::IncNestLevel();
- // if (ProcessPOSIXLog::AtTopNestLevel())
- // log->Print(msg);
- // }
- // NestingFunc();
- // if (log)
- // ProcessPOSIXLog::DecNestLevel();
- // }
-
- static bool AtTopNestLevel() { return m_nestinglevel == 1; }
-
- static void IncNestLevel() { ++m_nestinglevel; }
+ static void Initialize();
- static void DecNestLevel() {
- --m_nestinglevel;
- assert(m_nestinglevel >= 0);
+ static Log *GetLogIfAllCategoriesSet(uint32_t mask) {
+ return g_channel.GetLogIfAll(mask);
}
};
+}
#endif // liblldb_ProcessPOSIXLog_h_
diff --git a/source/Plugins/Process/Utility/CMakeLists.txt b/source/Plugins/Process/Utility/CMakeLists.txt
index c557667e3910..bda0ad626f6f 100644
--- a/source/Plugins/Process/Utility/CMakeLists.txt
+++ b/source/Plugins/Process/Utility/CMakeLists.txt
@@ -1,6 +1,6 @@
include_directories(../../../Utility/)
-add_lldb_library(lldbPluginProcessUtility
+add_lldb_library(lldbPluginProcessUtility PLUGIN
DynamicRegisterInfo.cpp
FreeBSDSignals.cpp
GDBRemoteSignals.cpp
@@ -9,19 +9,18 @@ add_lldb_library(lldbPluginProcessUtility
InferiorCallPOSIX.cpp
LinuxSignals.cpp
MipsLinuxSignals.cpp
+ NativeRegisterContextRegisterInfo.cpp
NetBSDSignals.cpp
RegisterContextDarwin_arm.cpp
RegisterContextDarwin_arm64.cpp
RegisterContextDarwin_i386.cpp
RegisterContextDarwin_x86_64.cpp
RegisterContextDummy.cpp
- RegisterContextFreeBSD_arm.cpp
RegisterContextFreeBSD_i386.cpp
RegisterContextFreeBSD_mips64.cpp
RegisterContextFreeBSD_powerpc.cpp
RegisterContextFreeBSD_x86_64.cpp
RegisterContextHistory.cpp
- RegisterContextLinux_arm.cpp
RegisterContextLinux_i386.cpp
RegisterContextLinux_x86_64.cpp
RegisterContextLinux_mips64.cpp
@@ -34,6 +33,8 @@ add_lldb_library(lldbPluginProcessUtility
RegisterContextMach_x86_64.cpp
RegisterContextMemory.cpp
RegisterContextNetBSD_x86_64.cpp
+ RegisterContextOpenBSD_i386.cpp
+ RegisterContextOpenBSD_x86_64.cpp
RegisterContextPOSIX_arm.cpp
RegisterContextPOSIX_arm64.cpp
RegisterContextPOSIX_mips64.cpp
@@ -41,9 +42,23 @@ add_lldb_library(lldbPluginProcessUtility
RegisterContextPOSIX_s390x.cpp
RegisterContextPOSIX_x86.cpp
RegisterContextThreadMemory.cpp
+ RegisterInfoPOSIX_arm.cpp
RegisterInfoPOSIX_arm64.cpp
StopInfoMachException.cpp
ThreadMemory.cpp
UnwindLLDB.cpp
UnwindMacOSXFrameBackchain.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbDataFormatters
+ lldbExpression
+ lldbHost
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ lldbPluginProcessElfCore
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp b/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
index 75f7251fb108..5e933d3b3dee 100644
--- a/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ b/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -14,11 +14,11 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/Host/StringConvert.h"
+#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/StringExtractor.h"
using namespace lldb;
@@ -281,6 +281,7 @@ DynamicRegisterInfo::SetRegisterInfo(const StructuredData::Dictionary &dict,
// Swap "dwarf_opcode_string" over into "opcode_extractor"
opcode_extractor.GetStringRef().swap(dwarf_opcode_string);
uint32_t ret_val = opcode_extractor.GetHexBytesAvail(dwarf_opcode_bytes);
+ UNUSED_IF_ASSERT_DISABLED(ret_val);
assert(ret_val == reg_info.dynamic_size_dwarf_len);
for (j = 0; j < reg_info.dynamic_size_dwarf_len; ++j)
diff --git a/source/Plugins/Process/Utility/DynamicRegisterInfo.h b/source/Plugins/Process/Utility/DynamicRegisterInfo.h
index e5c22fe484e9..a30bfa1e1f16 100644
--- a/source/Plugins/Process/Utility/DynamicRegisterInfo.h
+++ b/source/Plugins/Process/Utility/DynamicRegisterInfo.h
@@ -17,8 +17,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/StructuredData.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-private.h"
class DynamicRegisterInfo {
diff --git a/source/Plugins/Process/Utility/HistoryThread.cpp b/source/Plugins/Process/Utility/HistoryThread.cpp
index d27a7b0da943..4983dcdb5142 100644
--- a/source/Plugins/Process/Utility/HistoryThread.cpp
+++ b/source/Plugins/Process/Utility/HistoryThread.cpp
@@ -13,9 +13,9 @@
#include "Plugins/Process/Utility/HistoryUnwind.h"
#include "Plugins/Process/Utility/RegisterContextHistory.h"
-#include "lldb/Core/Log.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StackFrameList.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/Process/Utility/HistoryThread.h b/source/Plugins/Process/Utility/HistoryThread.h
index 1a4898a95b7d..363ba2669637 100644
--- a/source/Plugins/Process/Utility/HistoryThread.h
+++ b/source/Plugins/Process/Utility/HistoryThread.h
@@ -18,11 +18,11 @@
// Project includes
#include "lldb/Core/Broadcaster.h"
#include "lldb/Core/Event.h"
-#include "lldb/Core/UserID.h"
#include "lldb/Core/UserSettingsController.h"
#include "lldb/Target/ExecutionContextScope.h"
#include "lldb/Target/StackFrameList.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/UserID.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp b/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp
new file mode 100644
index 000000000000..0b1814362425
--- /dev/null
+++ b/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp
@@ -0,0 +1,43 @@
+//===-- NativeRegisterContextRegisterInfo.cpp -------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "NativeRegisterContextRegisterInfo.h"
+#include "lldb/lldb-private-forward.h"
+#include "lldb/lldb-types.h"
+
+using namespace lldb_private;
+
+NativeRegisterContextRegisterInfo::NativeRegisterContextRegisterInfo(
+ NativeThreadProtocol &thread, uint32_t concrete_frame_idx,
+ RegisterInfoInterface *register_info_interface)
+ : NativeRegisterContext(thread, concrete_frame_idx),
+ m_register_info_interface_up(register_info_interface) {
+ assert(register_info_interface && "null register_info_interface");
+}
+
+uint32_t NativeRegisterContextRegisterInfo::GetRegisterCount() const {
+ return m_register_info_interface_up->GetRegisterCount();
+}
+
+uint32_t NativeRegisterContextRegisterInfo::GetUserRegisterCount() const {
+ return m_register_info_interface_up->GetUserRegisterCount();
+}
+
+const RegisterInfo *NativeRegisterContextRegisterInfo::GetRegisterInfoAtIndex(
+ uint32_t reg_index) const {
+ if (reg_index <= GetRegisterCount())
+ return m_register_info_interface_up->GetRegisterInfo() + reg_index;
+ else
+ return nullptr;
+}
+
+const RegisterInfoInterface &
+NativeRegisterContextRegisterInfo::GetRegisterInfoInterface() const {
+ return *m_register_info_interface_up;
+}
diff --git a/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h b/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h
new file mode 100644
index 000000000000..c1b597462b60
--- /dev/null
+++ b/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h
@@ -0,0 +1,41 @@
+//===-- NativeRegisterContextRegisterInfo.h ---------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_PLUGINS_PROCESS_UTIILTY_NATIVE_REGISTER_CONTEXT_REGISTER_INFO
+#define LLDB_PLUGINS_PROCESS_UTIILTY_NATIVE_REGISTER_CONTEXT_REGISTER_INFO
+
+#include <memory>
+
+#include "RegisterInfoInterface.h"
+#include "lldb/Host/common/NativeRegisterContext.h"
+
+namespace lldb_private {
+class NativeRegisterContextRegisterInfo : public NativeRegisterContext {
+public:
+ ///
+ /// Construct a NativeRegisterContextRegisterInfo, taking ownership
+ /// of the register_info_interface pointer.
+ ///
+ NativeRegisterContextRegisterInfo(
+ NativeThreadProtocol &thread, uint32_t concrete_frame_idx,
+ RegisterInfoInterface *register_info_interface);
+
+ uint32_t GetRegisterCount() const override;
+
+ uint32_t GetUserRegisterCount() const override;
+
+ const RegisterInfo *GetRegisterInfoAtIndex(uint32_t reg_index) const override;
+
+ const RegisterInfoInterface &GetRegisterInfoInterface() const;
+
+private:
+ std::unique_ptr<RegisterInfoInterface> m_register_info_interface_up;
+};
+}
+#endif
diff --git a/source/Plugins/Process/Utility/NetBSDSignals.cpp b/source/Plugins/Process/Utility/NetBSDSignals.cpp
index 9b9db51e5167..7ed7189d8048 100644
--- a/source/Plugins/Process/Utility/NetBSDSignals.cpp
+++ b/source/Plugins/Process/Utility/NetBSDSignals.cpp
@@ -24,7 +24,35 @@ void NetBSDSignals::Reset() {
// ===================================================
AddSignal(32, "SIGPWR", false, true, true,
"power fail/restart (not reset when caught)");
-#ifdef SIGRTMIN /* SIGRTMAX */
- /* Kernel only; not exposed to userland yet */
-#endif
+ AddSignal(33, "SIGRTMIN", false, false, false, "real time signal 0");
+ AddSignal(34, "SIGRTMIN+1", false, false, false, "real time signal 1");
+ AddSignal(35, "SIGRTMIN+2", false, false, false, "real time signal 2");
+ AddSignal(36, "SIGRTMIN+3", false, false, false, "real time signal 3");
+ AddSignal(37, "SIGRTMIN+4", false, false, false, "real time signal 4");
+ AddSignal(38, "SIGRTMIN+5", false, false, false, "real time signal 5");
+ AddSignal(39, "SIGRTMIN+6", false, false, false, "real time signal 6");
+ AddSignal(40, "SIGRTMIN+7", false, false, false, "real time signal 7");
+ AddSignal(41, "SIGRTMIN+8", false, false, false, "real time signal 8");
+ AddSignal(42, "SIGRTMIN+9", false, false, false, "real time signal 9");
+ AddSignal(43, "SIGRTMIN+10", false, false, false, "real time signal 10");
+ AddSignal(44, "SIGRTMIN+11", false, false, false, "real time signal 11");
+ AddSignal(45, "SIGRTMIN+12", false, false, false, "real time signal 12");
+ AddSignal(46, "SIGRTMIN+13", false, false, false, "real time signal 13");
+ AddSignal(47, "SIGRTMIN+14", false, false, false, "real time signal 14");
+ AddSignal(48, "SIGRTMIN+15", false, false, false, "real time signal 15");
+ AddSignal(49, "SIGRTMIN-14", false, false, false, "real time signal 16");
+ AddSignal(50, "SIGRTMAX-13", false, false, false, "real time signal 17");
+ AddSignal(51, "SIGRTMAX-12", false, false, false, "real time signal 18");
+ AddSignal(52, "SIGRTMAX-11", false, false, false, "real time signal 19");
+ AddSignal(53, "SIGRTMAX-10", false, false, false, "real time signal 20");
+ AddSignal(54, "SIGRTMAX-9", false, false, false, "real time signal 21");
+ AddSignal(55, "SIGRTMAX-8", false, false, false, "real time signal 22");
+ AddSignal(56, "SIGRTMAX-7", false, false, false, "real time signal 23");
+ AddSignal(57, "SIGRTMAX-6", false, false, false, "real time signal 24");
+ AddSignal(58, "SIGRTMAX-5", false, false, false, "real time signal 25");
+ AddSignal(59, "SIGRTMAX-4", false, false, false, "real time signal 26");
+ AddSignal(60, "SIGRTMAX-3", false, false, false, "real time signal 27");
+ AddSignal(61, "SIGRTMAX-2", false, false, false, "real time signal 28");
+ AddSignal(62, "SIGRTMAX-1", false, false, false, "real time signal 29");
+ AddSignal(63, "SIGRTMAX", false, false, false, "real time signal 30");
}
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp b/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
index 52ace5602f49..64a697ff53c8 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
@@ -17,12 +17,12 @@
// C++ Includes
// Other libraries and framework includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
-#include "lldb/Host/Endian.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Log.h"
#include "llvm/Support/Compiler.h"
#include "Plugins/Process/Utility/InstructionUtils.h"
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp b/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
index 64983a2404e6..0c36f1a8346c 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
@@ -19,14 +19,14 @@
// C++ Includes
// Other libraries and framework includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Log.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Compiler.h"
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp b/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp
index f42fb00b375f..c818fad9ac0e 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp
@@ -12,12 +12,12 @@
// C++ Includes
// Other libraries and framework includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
-#include "lldb/Host/Endian.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Log.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Compiler.h"
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp b/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
index 7c0bafa68f9e..50e7292f86b1 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
@@ -14,12 +14,12 @@
// C++ Includes
// Other libraries and framework includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
-#include "lldb/Host/Endian.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Log.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Compiler.h"
diff --git a/source/Plugins/Process/Utility/RegisterContextDummy.cpp b/source/Plugins/Process/Utility/RegisterContextDummy.cpp
index 93bb09b810ac..dd6ca92a74ee 100644
--- a/source/Plugins/Process/Utility/RegisterContextDummy.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextDummy.cpp
@@ -10,8 +10,6 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/AddressRange.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Value.h"
@@ -28,6 +26,8 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Log.h"
#include "lldb/lldb-private.h"
#include "RegisterContextDummy.h"
diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_arm.cpp b/source/Plugins/Process/Utility/RegisterContextFreeBSD_arm.cpp
deleted file mode 100644
index fecfae0b7e66..000000000000
--- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_arm.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-//===-- RegisterContextFreeBSD_arm.cpp -------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===---------------------------------------------------------------------===//
-
-#include <cassert>
-#include <stddef.h>
-#include <vector>
-
-#include "lldb/lldb-defines.h"
-#include "llvm/Support/Compiler.h"
-
-#include "RegisterContextFreeBSD_arm.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-// Based on RegisterContextLinux_arm.cpp and
-// http://svnweb.freebsd.org/base/head/sys/arm/include/reg.h
-#define GPR_OFFSET(idx) ((idx)*4)
-#define FPU_OFFSET(idx) ((idx)*4 + sizeof(RegisterContextFreeBSD_arm::GPR))
-#define FPSCR_OFFSET \
- (LLVM_EXTENSION offsetof(RegisterContextFreeBSD_arm::FPU, fpscr) + \
- sizeof(RegisterContextFreeBSD_arm::GPR))
-#define EXC_OFFSET(idx) \
- ((idx)*4 + sizeof(RegisterContextFreeBSD_arm::GPR) + \
- sizeof(RegisterContextFreeBSD_arm::FPU))
-#define DBG_OFFSET(reg) \
- ((LLVM_EXTENSION offsetof(RegisterContextFreeBSD_arm::DBG, reg) + \
- sizeof(RegisterContextFreeBSD_arm::GPR) + \
- sizeof(RegisterContextFreeBSD_arm::FPU) + \
- sizeof(RegisterContextFreeBSD_arm::EXC)))
-
-#define DEFINE_DBG(reg, i) \
- #reg, NULL, sizeof(((RegisterContextFreeBSD_arm::DBG *) NULL)->reg[i]), \
- DBG_OFFSET(reg[i]), eEncodingUint, eFormatHex, \
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
- dbg_##reg##i }, \
- NULL, NULL, NULL, 0
-#define REG_CONTEXT_SIZE \
- (sizeof(RegisterContextFreeBSD_arm::GPR) + \
- sizeof(RegisterContextFreeBSD_arm::FPU) + \
- sizeof(RegisterContextFreeBSD_arm::EXC))
-
-//-----------------------------------------------------------------------------
-// Include RegisterInfos_arm to declare our g_register_infos_arm structure.
-//-----------------------------------------------------------------------------
-#define DECLARE_REGISTER_INFOS_ARM_STRUCT
-#include "RegisterInfos_arm.h"
-#undef DECLARE_REGISTER_INFOS_ARM_STRUCT
-
-static const lldb_private::RegisterInfo *
-GetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch) {
- switch (target_arch.GetMachine()) {
- case llvm::Triple::arm:
- return g_register_infos_arm;
- default:
- assert(false && "Unhandled target architecture.");
- return NULL;
- }
-}
-
-static uint32_t
-GetRegisterInfoCount(const lldb_private::ArchSpec &target_arch) {
- switch (target_arch.GetMachine()) {
- case llvm::Triple::arm:
- return static_cast<uint32_t>(sizeof(g_register_infos_arm) /
- sizeof(g_register_infos_arm[0]));
- default:
- assert(false && "Unhandled target architecture.");
- return 0;
- }
-}
-
-RegisterContextFreeBSD_arm::RegisterContextFreeBSD_arm(
- const lldb_private::ArchSpec &target_arch)
- : lldb_private::RegisterInfoInterface(target_arch),
- m_register_info_p(GetRegisterInfoPtr(target_arch)),
- m_register_info_count(GetRegisterInfoCount(target_arch)) {}
-
-size_t RegisterContextFreeBSD_arm::GetGPRSize() const {
- return sizeof(struct RegisterContextFreeBSD_arm::GPR);
-}
-
-const lldb_private::RegisterInfo *
-RegisterContextFreeBSD_arm::GetRegisterInfo() const {
- return m_register_info_p;
-}
-
-uint32_t RegisterContextFreeBSD_arm::GetRegisterCount() const {
- return m_register_info_count;
-}
diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp b/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp
index c114cfb829f5..55a72b2a31b4 100644
--- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp
@@ -9,11 +9,33 @@
#include "RegisterContextFreeBSD_mips64.h"
#include "RegisterContextPOSIX_mips64.h"
+#include "lldb-mips-freebsd-register-enums.h"
#include <vector>
using namespace lldb_private;
using namespace lldb;
+static const uint32_t g_gpr_regnums[] = {
+ gpr_zero_mips64, gpr_r1_mips64, gpr_r2_mips64, gpr_r3_mips64,
+ gpr_r4_mips64, gpr_r5_mips64, gpr_r6_mips64, gpr_r7_mips64,
+ gpr_r8_mips64, gpr_r9_mips64, gpr_r10_mips64, gpr_r11_mips64,
+ gpr_r12_mips64, gpr_r13_mips64, gpr_r14_mips64, gpr_r15_mips64,
+ gpr_r16_mips64, gpr_r17_mips64, gpr_r18_mips64, gpr_r19_mips64,
+ gpr_r20_mips64, gpr_r21_mips64, gpr_r22_mips64, gpr_r23_mips64,
+ gpr_r24_mips64, gpr_r25_mips64, gpr_r26_mips64, gpr_r27_mips64,
+ gpr_gp_mips64, gpr_sp_mips64, gpr_r30_mips64, gpr_ra_mips64,
+ gpr_sr_mips64, gpr_mullo_mips64, gpr_mulhi_mips64, gpr_badvaddr_mips64,
+ gpr_cause_mips64, gpr_pc_mips64, gpr_ic_mips64, gpr_dummy_mips64};
+
+// Number of register sets provided by this context.
+constexpr size_t k_num_register_sets = 1;
+
+static const RegisterSet g_reg_sets_mips64[k_num_register_sets] = {
+ {"General Purpose Registers", "gpr", k_num_gpr_registers_mips64,
+ g_gpr_regnums},
+};
+
+
// http://svnweb.freebsd.org/base/head/sys/mips/include/regnum.h
typedef struct _GPR {
uint64_t zero;
@@ -74,6 +96,19 @@ size_t RegisterContextFreeBSD_mips64::GetGPRSize() const {
return sizeof(GPR_freebsd_mips);
}
+const RegisterSet *
+RegisterContextFreeBSD_mips64::GetRegisterSet(size_t set) const {
+ // Check if RegisterSet is available
+ if (set < k_num_register_sets)
+ return &g_reg_sets_mips64[set];
+ return nullptr;
+}
+
+size_t
+RegisterContextFreeBSD_mips64::GetRegisterSetCount() const {
+ return k_num_register_sets;
+}
+
const RegisterInfo *RegisterContextFreeBSD_mips64::GetRegisterInfo() const {
assert(m_target_arch.GetCore() == ArchSpec::eCore_mips64);
return g_register_infos_mips64;
diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h b/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h
index 043e638758da..5e5de71ad72e 100644
--- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h
+++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h
@@ -19,6 +19,10 @@ public:
size_t GetGPRSize() const override;
+ const lldb_private::RegisterSet *GetRegisterSet(size_t set) const;
+
+ size_t GetRegisterSetCount() const;
+
const lldb_private::RegisterInfo *GetRegisterInfo() const override;
uint32_t GetRegisterCount() const override;
diff --git a/source/Plugins/Process/Utility/RegisterContextHistory.cpp b/source/Plugins/Process/Utility/RegisterContextHistory.cpp
index 0fc47fcd8e3a..cc0d696b338a 100644
--- a/source/Plugins/Process/Utility/RegisterContextHistory.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextHistory.cpp
@@ -10,8 +10,6 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/AddressRange.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Value.h"
@@ -28,6 +26,8 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Log.h"
#include "lldb/lldb-private.h"
#include "RegisterContextHistory.h"
diff --git a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
index ba84c40e9767..485a39e6c9a5 100644
--- a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -9,8 +9,6 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/AddressRange.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Value.h"
@@ -31,6 +29,8 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Log.h"
#include "lldb/lldb-private.h"
#include "RegisterContextLLDB.h"
@@ -2015,7 +2015,18 @@ bool RegisterContextLLDB::GetStartPC(addr_t &start_pc) {
return false;
if (!m_start_pc.IsValid()) {
- return ReadPC(start_pc);
+ bool read_successfully = ReadPC (start_pc);
+ if (read_successfully)
+ {
+ ProcessSP process_sp (m_thread.GetProcess());
+ if (process_sp)
+ {
+ ABI *abi = process_sp->GetABI().get();
+ if (abi)
+ start_pc = abi->FixCodeAddress(start_pc);
+ }
+ }
+ return read_successfully;
}
start_pc = m_start_pc.GetLoadAddress(CalculateTarget().get());
return true;
@@ -2044,9 +2055,16 @@ bool RegisterContextLLDB::ReadPC(addr_t &pc) {
if (m_all_registers_available == false && above_trap_handler == false &&
(pc == 0 || pc == 1)) {
return false;
- } else {
- return true;
}
+
+ ProcessSP process_sp (m_thread.GetProcess());
+ if (process_sp)
+ {
+ ABI *abi = process_sp->GetABI().get();
+ if (abi)
+ pc = abi->FixCodeAddress(pc);
+ }
+ return true;
} else {
return false;
}
diff --git a/source/Plugins/Process/Utility/RegisterContextLLDB.h b/source/Plugins/Process/Utility/RegisterContextLLDB.h
index cb22eedd560a..7e9e77dcf06d 100644
--- a/source/Plugins/Process/Utility/RegisterContextLLDB.h
+++ b/source/Plugins/Process/Utility/RegisterContextLLDB.h
@@ -21,7 +21,7 @@
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/RegisterContext.h"
-#include "lldb/Utility/RegisterNumber.h"
+#include "lldb/Target/RegisterNumber.h"
#include "lldb/lldb-private.h"
namespace lldb_private {
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_arm.h b/source/Plugins/Process/Utility/RegisterContextLinux_arm.h
deleted file mode 100644
index 9065bc0e08d2..000000000000
--- a/source/Plugins/Process/Utility/RegisterContextLinux_arm.h
+++ /dev/null
@@ -1,62 +0,0 @@
-//===-- RegisterContextLinux_arm.h -----------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_RegisterContextLinux_arm_h_
-#define liblldb_RegisterContextLinux_arm_h_
-
-#include "RegisterInfoInterface.h"
-#include "lldb/Target/RegisterContext.h"
-#include "lldb/lldb-private.h"
-
-class RegisterContextLinux_arm : public lldb_private::RegisterInfoInterface {
-public:
- struct GPR {
- uint32_t r[16]; // R0-R15
- uint32_t cpsr; // CPSR
- };
-
- struct QReg {
- uint8_t bytes[16];
- };
-
- struct FPU {
- union {
- uint32_t s[32];
- uint64_t d[32];
- QReg q[16]; // the 128-bit NEON registers
- } floats;
- uint32_t fpscr;
- };
- struct EXC {
- uint32_t exception;
- uint32_t fsr; /* Fault status */
- uint32_t far; /* Virtual Fault Address */
- };
-
- struct DBG {
- uint32_t bvr[16];
- uint32_t bcr[16];
- uint32_t wvr[16];
- uint32_t wcr[16];
- };
-
- RegisterContextLinux_arm(const lldb_private::ArchSpec &target_arch);
-
- size_t GetGPRSize() const override;
-
- const lldb_private::RegisterInfo *GetRegisterInfo() const override;
-
- uint32_t GetRegisterCount() const override;
-
-private:
- const lldb_private::RegisterInfo *m_register_info_p;
- uint32_t m_register_info_count;
-};
-
-#endif // liblldb_RegisterContextLinux_arm_h_
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp b/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp
index 982eefea9ba6..7b16531dcc89 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp
@@ -29,6 +29,73 @@ using namespace lldb;
#include "RegisterInfos_mips.h"
#undef DECLARE_REGISTER_INFOS_MIPS_STRUCT
+// mips general purpose registers.
+const uint32_t g_gp_regnums_mips[] = {
+ gpr_zero_mips, gpr_r1_mips, gpr_r2_mips, gpr_r3_mips,
+ gpr_r4_mips, gpr_r5_mips, gpr_r6_mips, gpr_r7_mips,
+ gpr_r8_mips, gpr_r9_mips, gpr_r10_mips, gpr_r11_mips,
+ gpr_r12_mips, gpr_r13_mips, gpr_r14_mips, gpr_r15_mips,
+ gpr_r16_mips, gpr_r17_mips, gpr_r18_mips, gpr_r19_mips,
+ gpr_r20_mips, gpr_r21_mips, gpr_r22_mips, gpr_r23_mips,
+ gpr_r24_mips, gpr_r25_mips, gpr_r26_mips, gpr_r27_mips,
+ gpr_gp_mips, gpr_sp_mips, gpr_r30_mips, gpr_ra_mips,
+ gpr_sr_mips, gpr_mullo_mips, gpr_mulhi_mips, gpr_badvaddr_mips,
+ gpr_cause_mips, gpr_pc_mips, gpr_config5_mips,
+ LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+
+static_assert((sizeof(g_gp_regnums_mips) / sizeof(g_gp_regnums_mips[0])) - 1 ==
+ k_num_gpr_registers_mips,
+ "g_gp_regnums_mips has wrong number of register infos");
+// mips floating point registers.
+const uint32_t g_fp_regnums_mips[] = {
+ fpr_f0_mips, fpr_f1_mips, fpr_f2_mips, fpr_f3_mips,
+ fpr_f4_mips, fpr_f5_mips, fpr_f6_mips, fpr_f7_mips,
+ fpr_f8_mips, fpr_f9_mips, fpr_f10_mips, fpr_f11_mips,
+ fpr_f12_mips, fpr_f13_mips, fpr_f14_mips, fpr_f15_mips,
+ fpr_f16_mips, fpr_f17_mips, fpr_f18_mips, fpr_f19_mips,
+ fpr_f20_mips, fpr_f21_mips, fpr_f22_mips, fpr_f23_mips,
+ fpr_f24_mips, fpr_f25_mips, fpr_f26_mips, fpr_f27_mips,
+ fpr_f28_mips, fpr_f29_mips, fpr_f30_mips, fpr_f31_mips,
+ fpr_fcsr_mips, fpr_fir_mips, fpr_config5_mips,
+ LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+
+static_assert((sizeof(g_fp_regnums_mips) / sizeof(g_fp_regnums_mips[0])) - 1 ==
+ k_num_fpr_registers_mips,
+ "g_fp_regnums_mips has wrong number of register infos");
+
+// mips MSA registers.
+const uint32_t g_msa_regnums_mips[] = {
+ msa_w0_mips, msa_w1_mips, msa_w2_mips, msa_w3_mips,
+ msa_w4_mips, msa_w5_mips, msa_w6_mips, msa_w7_mips,
+ msa_w8_mips, msa_w9_mips, msa_w10_mips, msa_w11_mips,
+ msa_w12_mips, msa_w13_mips, msa_w14_mips, msa_w15_mips,
+ msa_w16_mips, msa_w17_mips, msa_w18_mips, msa_w19_mips,
+ msa_w20_mips, msa_w21_mips, msa_w22_mips, msa_w23_mips,
+ msa_w24_mips, msa_w25_mips, msa_w26_mips, msa_w27_mips,
+ msa_w28_mips, msa_w29_mips, msa_w30_mips, msa_w31_mips,
+ msa_fcsr_mips, msa_fir_mips, msa_mcsr_mips, msa_mir_mips,
+ msa_config5_mips,
+ LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+
+static_assert((sizeof(g_msa_regnums_mips) / sizeof(g_msa_regnums_mips[0])) -
+ 1 ==
+ k_num_msa_registers_mips,
+ "g_msa_regnums_mips has wrong number of register infos");
+
+// Number of register sets provided by this context.
+constexpr size_t k_num_register_sets = 3;
+
+// Register sets for mips.
+static const RegisterSet g_reg_sets_mips[k_num_register_sets] = {
+ {"General Purpose Registers", "gpr", k_num_gpr_registers_mips,
+ g_gp_regnums_mips},
+ {"Floating Point Registers", "fpu", k_num_fpr_registers_mips,
+ g_fp_regnums_mips},
+ {"MSA Registers", "msa", k_num_msa_registers_mips, g_msa_regnums_mips}};
+
uint32_t GetUserRegisterInfoCount(bool msa_present) {
if (msa_present)
return static_cast<uint32_t>(k_num_user_registers_mips);
@@ -56,6 +123,25 @@ const RegisterInfo *RegisterContextLinux_mips::GetRegisterInfo() const {
}
}
+const RegisterSet *
+RegisterContextLinux_mips::GetRegisterSet(size_t set) const {
+ if (set >= k_num_register_sets)
+ return nullptr;
+ switch (m_target_arch.GetMachine()) {
+ case llvm::Triple::mips:
+ case llvm::Triple::mipsel:
+ return &g_reg_sets_mips[set];
+ default:
+ assert(false && "Unhandled target architecture.");
+ return nullptr;
+ }
+}
+
+size_t
+RegisterContextLinux_mips::GetRegisterSetCount() const {
+ return k_num_register_sets;
+}
+
uint32_t RegisterContextLinux_mips::GetRegisterCount() const {
return static_cast<uint32_t>(sizeof(g_register_infos_mips) /
sizeof(g_register_infos_mips[0]));
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_mips.h b/source/Plugins/Process/Utility/RegisterContextLinux_mips.h
index cba4ee6cd2b0..a16c4ecd15f8 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_mips.h
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_mips.h
@@ -22,6 +22,10 @@ public:
const lldb_private::RegisterInfo *GetRegisterInfo() const override;
+ const lldb_private::RegisterSet *GetRegisterSet(size_t set) const;
+
+ size_t GetRegisterSetCount() const;
+
uint32_t GetRegisterCount() const override;
uint32_t GetUserRegisterCount() const override;
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp b/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp
index c40f69492624..1bb16c701126 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp
@@ -7,7 +7,6 @@
//
//===---------------------------------------------------------------------===//
-#if defined(__mips__)
#include <stddef.h>
#include <vector>
@@ -41,6 +40,101 @@ using namespace lldb_private;
#include "RegisterInfos_mips.h"
#undef DECLARE_REGISTER_INFOS_MIPS_STRUCT
+// mips64 general purpose registers.
+const uint32_t g_gp_regnums_mips64[] = {
+ gpr_zero_mips64, gpr_r1_mips64, gpr_r2_mips64,
+ gpr_r3_mips64, gpr_r4_mips64, gpr_r5_mips64,
+ gpr_r6_mips64, gpr_r7_mips64, gpr_r8_mips64,
+ gpr_r9_mips64, gpr_r10_mips64, gpr_r11_mips64,
+ gpr_r12_mips64, gpr_r13_mips64, gpr_r14_mips64,
+ gpr_r15_mips64, gpr_r16_mips64, gpr_r17_mips64,
+ gpr_r18_mips64, gpr_r19_mips64, gpr_r20_mips64,
+ gpr_r21_mips64, gpr_r22_mips64, gpr_r23_mips64,
+ gpr_r24_mips64, gpr_r25_mips64, gpr_r26_mips64,
+ gpr_r27_mips64, gpr_gp_mips64, gpr_sp_mips64,
+ gpr_r30_mips64, gpr_ra_mips64, gpr_sr_mips64,
+ gpr_mullo_mips64, gpr_mulhi_mips64, gpr_badvaddr_mips64,
+ gpr_cause_mips64, gpr_pc_mips64, gpr_config5_mips64,
+ LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+
+static_assert((sizeof(g_gp_regnums_mips64) / sizeof(g_gp_regnums_mips64[0])) -
+ 1 ==
+ k_num_gpr_registers_mips64,
+ "g_gp_regnums_mips64 has wrong number of register infos");
+
+// mips64 floating point registers.
+const uint32_t g_fp_regnums_mips64[] = {
+ fpr_f0_mips64, fpr_f1_mips64, fpr_f2_mips64, fpr_f3_mips64,
+ fpr_f4_mips64, fpr_f5_mips64, fpr_f6_mips64, fpr_f7_mips64,
+ fpr_f8_mips64, fpr_f9_mips64, fpr_f10_mips64, fpr_f11_mips64,
+ fpr_f12_mips64, fpr_f13_mips64, fpr_f14_mips64, fpr_f15_mips64,
+ fpr_f16_mips64, fpr_f17_mips64, fpr_f18_mips64, fpr_f19_mips64,
+ fpr_f20_mips64, fpr_f21_mips64, fpr_f22_mips64, fpr_f23_mips64,
+ fpr_f24_mips64, fpr_f25_mips64, fpr_f26_mips64, fpr_f27_mips64,
+ fpr_f28_mips64, fpr_f29_mips64, fpr_f30_mips64, fpr_f31_mips64,
+ fpr_fcsr_mips64, fpr_fir_mips64, fpr_config5_mips64,
+ LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+
+static_assert((sizeof(g_fp_regnums_mips64) / sizeof(g_fp_regnums_mips64[0])) -
+ 1 ==
+ k_num_fpr_registers_mips64,
+ "g_fp_regnums_mips64 has wrong number of register infos");
+
+// mips64 MSA registers.
+const uint32_t g_msa_regnums_mips64[] = {
+ msa_w0_mips64, msa_w1_mips64, msa_w2_mips64, msa_w3_mips64,
+ msa_w4_mips64, msa_w5_mips64, msa_w6_mips64, msa_w7_mips64,
+ msa_w8_mips64, msa_w9_mips64, msa_w10_mips64, msa_w11_mips64,
+ msa_w12_mips64, msa_w13_mips64, msa_w14_mips64, msa_w15_mips64,
+ msa_w16_mips64, msa_w17_mips64, msa_w18_mips64, msa_w19_mips64,
+ msa_w20_mips64, msa_w21_mips64, msa_w22_mips64, msa_w23_mips64,
+ msa_w24_mips64, msa_w25_mips64, msa_w26_mips64, msa_w27_mips64,
+ msa_w28_mips64, msa_w29_mips64, msa_w30_mips64, msa_w31_mips64,
+ msa_fcsr_mips64, msa_fir_mips64, msa_mcsr_mips64, msa_mir_mips64,
+ msa_config5_mips64,
+ LLDB_INVALID_REGNUM // register sets need to end with this flag
+};
+
+static_assert((sizeof(g_msa_regnums_mips64) / sizeof(g_msa_regnums_mips64[0])) -
+ 1 ==
+ k_num_msa_registers_mips64,
+ "g_msa_regnums_mips64 has wrong number of register infos");
+
+// Number of register sets provided by this context.
+constexpr size_t k_num_register_sets = 3;
+
+// Register sets for mips64.
+static const RegisterSet g_reg_sets_mips64[k_num_register_sets] = {
+ {"General Purpose Registers", "gpr", k_num_gpr_registers_mips64,
+ g_gp_regnums_mips64},
+ {"Floating Point Registers", "fpu", k_num_fpr_registers_mips64,
+ g_fp_regnums_mips64},
+ {"MSA Registers", "msa", k_num_msa_registers_mips64, g_msa_regnums_mips64},
+};
+
+const RegisterSet *
+RegisterContextLinux_mips64::GetRegisterSet(size_t set) const {
+ if (set >= k_num_register_sets)
+ return nullptr;
+
+ switch (m_target_arch.GetMachine()) {
+ case llvm::Triple::mips64:
+ case llvm::Triple::mips64el:
+ return &g_reg_sets_mips64[set];
+ default:
+ assert(false && "Unhandled target architecture.");
+ return nullptr;
+ }
+ return nullptr;
+}
+
+size_t
+RegisterContextLinux_mips64::GetRegisterSetCount() const {
+ return k_num_register_sets;
+}
+
static const RegisterInfo *GetRegisterInfoPtr(const ArchSpec &target_arch) {
switch (target_arch.GetMachine()) {
case llvm::Triple::mips64:
@@ -116,4 +210,3 @@ uint32_t RegisterContextLinux_mips64::GetUserRegisterCount() const {
return m_user_register_count;
}
-#endif
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h b/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h
index 9669b0d84997..d3ca9d75300e 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h
@@ -7,8 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#if defined(__mips__)
-
#ifndef liblldb_RegisterContextLinux_mips64_H_
#define liblldb_RegisterContextLinux_mips64_H_
@@ -24,6 +22,10 @@ public:
const lldb_private::RegisterInfo *GetRegisterInfo() const override;
+ const lldb_private::RegisterSet *GetRegisterSet(size_t set) const;
+
+ size_t GetRegisterSetCount() const;
+
uint32_t GetRegisterCount() const override;
uint32_t GetUserRegisterCount() const override;
@@ -36,4 +38,3 @@ private:
#endif
-#endif
diff --git a/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp b/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp
index 95b106d68bb3..2d24bdaed2cd 100644
--- a/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp
@@ -12,12 +12,12 @@
// C Includes
// C++ Includes
// Other libraries and framework includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/StreamString.h"
// Project includes
#include "Utility/StringExtractorGDBRemote.h"
diff --git a/source/Plugins/Process/Utility/RegisterContextMemory.cpp b/source/Plugins/Process/Utility/RegisterContextMemory.cpp
index 57966e1729a6..eed5eec8fae8 100644
--- a/source/Plugins/Process/Utility/RegisterContextMemory.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextMemory.cpp
@@ -14,11 +14,11 @@
// Other libraries and framework includes
// Project includes
#include "DynamicRegisterInfo.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Error.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/Process/Utility/RegisterContextMemory.h b/source/Plugins/Process/Utility/RegisterContextMemory.h
index 55de0412b094..cad1592af5ba 100644
--- a/source/Plugins/Process/Utility/RegisterContextMemory.h
+++ b/source/Plugins/Process/Utility/RegisterContextMemory.h
@@ -16,8 +16,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/Utility/DataExtractor.h"
#include "lldb/lldb-private.h"
class DynamicRegisterInfo;
diff --git a/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp b/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp
index 4f64a8c4f321..ca7a0139ccc0 100644
--- a/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp
@@ -47,10 +47,14 @@ typedef struct _GPR {
uint64_t ss; /* 25 */
} GPR;
-/*
- * As of NetBSD-7.99.25 there is no support for debug registers
- * https://en.wikipedia.org/wiki/X86_debug_register
- */
+struct DBG {
+ uint64_t dr[16]; /* debug registers */
+ /* Index 0-3: debug address registers */
+ /* Index 4-5: reserved */
+ /* Index 6: debug status */
+ /* Index 7: debug control */
+ /* Index 8-15: reserved */
+};
/*
* src/sys/arch/amd64/include/mcontext.h
@@ -66,276 +70,21 @@ struct UserArea {
GPR gpr;
uint64_t mc_tlsbase;
FPR fpr;
+ DBG dbg;
};
-//---------------------------------------------------------------------------
-// Cherry-pick parts of RegisterInfos_x86_64.h, without debug registers
-//---------------------------------------------------------------------------
-// Computes the offset of the given GPR in the user data area.
-#define GPR_OFFSET(regname) (LLVM_EXTENSION offsetof(GPR, regname))
-
-// Computes the offset of the given FPR in the extended data area.
-#define FPR_OFFSET(regname) \
- (LLVM_EXTENSION offsetof(UserArea, fpr) + \
- LLVM_EXTENSION offsetof(FPR, xstate) + \
- LLVM_EXTENSION offsetof(FXSAVE, regname))
-
-// Computes the offset of the YMM register assembled from register halves.
-// Based on DNBArchImplX86_64.cpp from debugserver
-#define YMM_OFFSET(reg_index) \
- (LLVM_EXTENSION offsetof(UserArea, fpr) + \
- LLVM_EXTENSION offsetof(FPR, xstate) + \
- LLVM_EXTENSION offsetof(XSAVE, ymmh[0]) + (32 * reg_index))
-
-// Number of bytes needed to represent a FPR.
-#define FPR_SIZE(reg) sizeof(((FXSAVE *)nullptr)->reg)
-
-// Number of bytes needed to represent the i'th FP register.
-#define FP_SIZE sizeof(((MMSReg *)nullptr)->bytes)
-
-// Number of bytes needed to represent an XMM register.
-#define XMM_SIZE sizeof(XMMReg)
-
-// Number of bytes needed to represent a YMM register.
-#define YMM_SIZE sizeof(YMMReg)
-
-// RegisterKind: EHFrame, DWARF, Generic, Process Plugin, LLDB
-
-// Note that the size and offset will be updated by platform-specific classes.
-#define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \
- { \
- #reg, alt, sizeof(((GPR *)nullptr)->reg), \
- GPR_OFFSET(reg), eEncodingUint, eFormatHex, \
- {kind1, kind2, kind3, kind4, \
- lldb_##reg##_x86_64 }, \
- nullptr, nullptr, nullptr, 0 \
- }
-
-#define DEFINE_FPR(name, reg, kind1, kind2, kind3, kind4) \
- { \
- #name, nullptr, FPR_SIZE(reg), FPR_OFFSET(reg), eEncodingUint, eFormatHex, \
- {kind1, kind2, kind3, kind4, \
- lldb_##name##_x86_64 }, \
- nullptr, nullptr, nullptr, 0 \
- }
-
-#define DEFINE_FP_ST(reg, i) \
- { \
- #reg #i, nullptr, FP_SIZE, \
- LLVM_EXTENSION FPR_OFFSET( \
- stmm[i]), eEncodingVector, eFormatVectorOfUInt8, \
- {dwarf_st##i##_x86_64, dwarf_st##i##_x86_64, LLDB_INVALID_REGNUM, \
- LLDB_INVALID_REGNUM, lldb_st##i##_x86_64 }, \
- nullptr, nullptr, nullptr, 0 \
- }
-
-#define DEFINE_FP_MM(reg, i) \
- { \
- #reg #i, nullptr, sizeof(uint64_t), \
- LLVM_EXTENSION FPR_OFFSET( \
- stmm[i]), eEncodingUint, eFormatHex, \
- {dwarf_mm##i##_x86_64, dwarf_mm##i##_x86_64, \
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
- lldb_mm##i##_x86_64 }, \
- nullptr, nullptr, nullptr, 0 \
- }
-
-#define DEFINE_XMM(reg, i) \
- { \
- #reg #i, nullptr, XMM_SIZE, \
- LLVM_EXTENSION FPR_OFFSET( \
- reg[i]), eEncodingVector, eFormatVectorOfUInt8, \
- {dwarf_##reg##i##_x86_64, dwarf_##reg##i##_x86_64, \
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
- lldb_##reg##i##_x86_64 }, \
- nullptr, nullptr, nullptr, 0 \
- }
-
-#define DEFINE_YMM(reg, i) \
- { \
- #reg #i, nullptr, YMM_SIZE, \
- LLVM_EXTENSION YMM_OFFSET(i), eEncodingVector, eFormatVectorOfUInt8, \
- {dwarf_##reg##i##h_x86_64, \
- dwarf_##reg##i##h_x86_64, \
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
- lldb_##reg##i##_x86_64 }, \
- nullptr, nullptr, nullptr, 0 \
- }
+#define DR_OFFSET(reg_index) \
+ (LLVM_EXTENSION offsetof(UserArea, dbg) + \
+ LLVM_EXTENSION offsetof(DBG, dr[reg_index]))
-#define DEFINE_GPR_PSEUDO_32(reg32, reg64) \
- { \
- #reg32, nullptr, 4, \
- GPR_OFFSET(reg64), eEncodingUint, eFormatHex, \
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
- lldb_##reg32##_x86_64 }, \
- RegisterContextPOSIX_x86::g_contained_##reg64, \
- RegisterContextPOSIX_x86::g_invalidate_##reg64, nullptr, 0 \
- }
-
-#define DEFINE_GPR_PSEUDO_16(reg16, reg64) \
- { \
- #reg16, nullptr, 2, \
- GPR_OFFSET(reg64), eEncodingUint, eFormatHex, \
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
- lldb_##reg16##_x86_64 }, \
- RegisterContextPOSIX_x86::g_contained_##reg64, \
- RegisterContextPOSIX_x86::g_invalidate_##reg64, nullptr, 0 \
- }
-
-#define DEFINE_GPR_PSEUDO_8H(reg8, reg64) \
- { \
- #reg8, nullptr, 1, GPR_OFFSET(reg64) + 1, eEncodingUint, eFormatHex, \
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
- lldb_##reg8##_x86_64 }, \
- RegisterContextPOSIX_x86::g_contained_##reg64, \
- RegisterContextPOSIX_x86::g_invalidate_##reg64,\
- nullptr, 0 \
- }
-
-#define DEFINE_GPR_PSEUDO_8L(reg8, reg64) \
- { \
- #reg8, nullptr, 1, GPR_OFFSET(reg64), eEncodingUint, eFormatHex, \
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
- lldb_##reg8##_x86_64 }, \
- RegisterContextPOSIX_x86::g_contained_##reg64, \
- RegisterContextPOSIX_x86::g_invalidate_##reg64,\
- nullptr, 0 \
- }
-
-static RegisterInfo g_register_infos_x86_64[] = {
- // General purpose registers. EH_Frame, DWARF,
- // Generic, Process Plugin
- DEFINE_GPR(rax, nullptr, dwarf_rax_x86_64, dwarf_rax_x86_64,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(rbx, nullptr, dwarf_rbx_x86_64, dwarf_rbx_x86_64,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(rcx, "arg4", dwarf_rcx_x86_64, dwarf_rcx_x86_64,
- LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM),
- DEFINE_GPR(rdx, "arg3", dwarf_rdx_x86_64, dwarf_rdx_x86_64,
- LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM),
- DEFINE_GPR(rdi, "arg1", dwarf_rdi_x86_64, dwarf_rdi_x86_64,
- LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM),
- DEFINE_GPR(rsi, "arg2", dwarf_rsi_x86_64, dwarf_rsi_x86_64,
- LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM),
- DEFINE_GPR(rbp, "fp", dwarf_rbp_x86_64, dwarf_rbp_x86_64,
- LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM),
- DEFINE_GPR(rsp, "sp", dwarf_rsp_x86_64, dwarf_rsp_x86_64,
- LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r8, "arg5", dwarf_r8_x86_64, dwarf_r8_x86_64,
- LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r9, "arg6", dwarf_r9_x86_64, dwarf_r9_x86_64,
- LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r10, nullptr, dwarf_r10_x86_64, dwarf_r10_x86_64,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r11, nullptr, dwarf_r11_x86_64, dwarf_r11_x86_64,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r12, nullptr, dwarf_r12_x86_64, dwarf_r12_x86_64,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r13, nullptr, dwarf_r13_x86_64, dwarf_r13_x86_64,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r14, nullptr, dwarf_r14_x86_64, dwarf_r14_x86_64,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(r15, nullptr, dwarf_r15_x86_64, dwarf_r15_x86_64,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(rip, "pc", dwarf_rip_x86_64, dwarf_rip_x86_64,
- LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM),
- DEFINE_GPR(rflags, "flags", dwarf_rflags_x86_64, dwarf_rflags_x86_64,
- LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM),
- DEFINE_GPR(cs, nullptr, dwarf_cs_x86_64, dwarf_cs_x86_64,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(fs, nullptr, dwarf_fs_x86_64, dwarf_fs_x86_64,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(gs, nullptr, dwarf_gs_x86_64, dwarf_gs_x86_64,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(ss, nullptr, dwarf_ss_x86_64, dwarf_ss_x86_64,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(ds, nullptr, dwarf_ds_x86_64, dwarf_ds_x86_64,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_GPR(es, nullptr, dwarf_es_x86_64, dwarf_es_x86_64,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
-
- DEFINE_GPR_PSEUDO_32(eax, rax), DEFINE_GPR_PSEUDO_32(ebx, rbx),
- DEFINE_GPR_PSEUDO_32(ecx, rcx), DEFINE_GPR_PSEUDO_32(edx, rdx),
- DEFINE_GPR_PSEUDO_32(edi, rdi), DEFINE_GPR_PSEUDO_32(esi, rsi),
- DEFINE_GPR_PSEUDO_32(ebp, rbp), DEFINE_GPR_PSEUDO_32(esp, rsp),
- DEFINE_GPR_PSEUDO_32(r8d, r8), DEFINE_GPR_PSEUDO_32(r9d, r9),
- DEFINE_GPR_PSEUDO_32(r10d, r10), DEFINE_GPR_PSEUDO_32(r11d, r11),
- DEFINE_GPR_PSEUDO_32(r12d, r12), DEFINE_GPR_PSEUDO_32(r13d, r13),
- DEFINE_GPR_PSEUDO_32(r14d, r14), DEFINE_GPR_PSEUDO_32(r15d, r15),
- DEFINE_GPR_PSEUDO_16(ax, rax), DEFINE_GPR_PSEUDO_16(bx, rbx),
- DEFINE_GPR_PSEUDO_16(cx, rcx), DEFINE_GPR_PSEUDO_16(dx, rdx),
- DEFINE_GPR_PSEUDO_16(di, rdi), DEFINE_GPR_PSEUDO_16(si, rsi),
- DEFINE_GPR_PSEUDO_16(bp, rbp), DEFINE_GPR_PSEUDO_16(sp, rsp),
- DEFINE_GPR_PSEUDO_16(r8w, r8), DEFINE_GPR_PSEUDO_16(r9w, r9),
- DEFINE_GPR_PSEUDO_16(r10w, r10), DEFINE_GPR_PSEUDO_16(r11w, r11),
- DEFINE_GPR_PSEUDO_16(r12w, r12), DEFINE_GPR_PSEUDO_16(r13w, r13),
- DEFINE_GPR_PSEUDO_16(r14w, r14), DEFINE_GPR_PSEUDO_16(r15w, r15),
- DEFINE_GPR_PSEUDO_8H(ah, rax), DEFINE_GPR_PSEUDO_8H(bh, rbx),
- DEFINE_GPR_PSEUDO_8H(ch, rcx), DEFINE_GPR_PSEUDO_8H(dh, rdx),
- DEFINE_GPR_PSEUDO_8L(al, rax), DEFINE_GPR_PSEUDO_8L(bl, rbx),
- DEFINE_GPR_PSEUDO_8L(cl, rcx), DEFINE_GPR_PSEUDO_8L(dl, rdx),
- DEFINE_GPR_PSEUDO_8L(dil, rdi), DEFINE_GPR_PSEUDO_8L(sil, rsi),
- DEFINE_GPR_PSEUDO_8L(bpl, rbp), DEFINE_GPR_PSEUDO_8L(spl, rsp),
- DEFINE_GPR_PSEUDO_8L(r8l, r8), DEFINE_GPR_PSEUDO_8L(r9l, r9),
- DEFINE_GPR_PSEUDO_8L(r10l, r10), DEFINE_GPR_PSEUDO_8L(r11l, r11),
- DEFINE_GPR_PSEUDO_8L(r12l, r12), DEFINE_GPR_PSEUDO_8L(r13l, r13),
- DEFINE_GPR_PSEUDO_8L(r14l, r14), DEFINE_GPR_PSEUDO_8L(r15l, r15),
-
- // i387 Floating point registers. EH_frame,
- // DWARF, Generic, Process Plugin
- DEFINE_FPR(fctrl, fctrl, dwarf_fctrl_x86_64, dwarf_fctrl_x86_64,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR(fstat, fstat, dwarf_fstat_x86_64, dwarf_fstat_x86_64,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR(ftag, ftag, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR(fop, fop, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR(fiseg, ptr.i386_.fiseg, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR(fioff, ptr.i386_.fioff, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR(foseg, ptr.i386_.foseg, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR(fooff, ptr.i386_.fooff, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR(mxcsr, mxcsr, dwarf_mxcsr_x86_64, dwarf_mxcsr_x86_64,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
- DEFINE_FPR(mxcsrmask, mxcsrmask, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM),
-
- // FP registers.
- DEFINE_FP_ST(st, 0), DEFINE_FP_ST(st, 1), DEFINE_FP_ST(st, 2),
- DEFINE_FP_ST(st, 3), DEFINE_FP_ST(st, 4), DEFINE_FP_ST(st, 5),
- DEFINE_FP_ST(st, 6), DEFINE_FP_ST(st, 7), DEFINE_FP_MM(mm, 0),
- DEFINE_FP_MM(mm, 1), DEFINE_FP_MM(mm, 2), DEFINE_FP_MM(mm, 3),
- DEFINE_FP_MM(mm, 4), DEFINE_FP_MM(mm, 5), DEFINE_FP_MM(mm, 6),
- DEFINE_FP_MM(mm, 7),
-
- // XMM registers
- DEFINE_XMM(xmm, 0), DEFINE_XMM(xmm, 1), DEFINE_XMM(xmm, 2),
- DEFINE_XMM(xmm, 3), DEFINE_XMM(xmm, 4), DEFINE_XMM(xmm, 5),
- DEFINE_XMM(xmm, 6), DEFINE_XMM(xmm, 7), DEFINE_XMM(xmm, 8),
- DEFINE_XMM(xmm, 9), DEFINE_XMM(xmm, 10), DEFINE_XMM(xmm, 11),
- DEFINE_XMM(xmm, 12), DEFINE_XMM(xmm, 13), DEFINE_XMM(xmm, 14),
- DEFINE_XMM(xmm, 15),
-
- // Copy of YMM registers assembled from xmm and ymmh
- DEFINE_YMM(ymm, 0), DEFINE_YMM(ymm, 1), DEFINE_YMM(ymm, 2),
- DEFINE_YMM(ymm, 3), DEFINE_YMM(ymm, 4), DEFINE_YMM(ymm, 5),
- DEFINE_YMM(ymm, 6), DEFINE_YMM(ymm, 7), DEFINE_YMM(ymm, 8),
- DEFINE_YMM(ymm, 9), DEFINE_YMM(ymm, 10), DEFINE_YMM(ymm, 11),
- DEFINE_YMM(ymm, 12), DEFINE_YMM(ymm, 13), DEFINE_YMM(ymm, 14),
- DEFINE_YMM(ymm, 15),
-};
//---------------------------------------------------------------------------
-// End of cherry-pick of RegisterInfos_x86_64.h
+// Include RegisterInfos_x86_64 to declare our g_register_infos_x86_64
+// structure.
//---------------------------------------------------------------------------
+#define DECLARE_REGISTER_INFOS_X86_64_STRUCT
+#include "RegisterInfos_x86_64.h"
+#undef DECLARE_REGISTER_INFOS_X86_64_STRUCT
static const RegisterInfo *
PrivateGetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch) {
diff --git a/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp b/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp
new file mode 100644
index 000000000000..1f958105b10b
--- /dev/null
+++ b/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp
@@ -0,0 +1,80 @@
+//===-- RegisterContextOpenBSD_i386.cpp ------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===---------------------------------------------------------------------===//
+
+#include "RegisterContextOpenBSD_i386.h"
+#include "RegisterContextPOSIX_x86.h"
+
+using namespace lldb_private;
+using namespace lldb;
+
+// /usr/include/machine/reg.h
+struct GPR {
+ uint32_t eax;
+ uint32_t ecx;
+ uint32_t edx;
+ uint32_t ebx;
+ uint32_t esp;
+ uint32_t ebp;
+ uint32_t esi;
+ uint32_t edi;
+ uint32_t eip;
+ uint32_t eflags;
+ uint32_t cs;
+ uint32_t ss;
+ uint32_t ds;
+ uint32_t es;
+ uint32_t fs;
+ uint32_t gs;
+};
+
+struct dbreg {
+ uint32_t dr[8]; /* debug registers */
+ /* Index 0-3: debug address registers */
+ /* Index 4-5: reserved */
+ /* Index 6: debug status */
+ /* Index 7: debug control */
+};
+
+using FPR_i386 = FXSAVE;
+
+struct UserArea {
+ GPR gpr;
+ FPR_i386 i387;
+};
+
+#define DR_SIZE sizeof(uint32_t)
+#define DR_OFFSET(reg_index) (LLVM_EXTENSION offsetof(dbreg, dr[reg_index]))
+
+//---------------------------------------------------------------------------
+// Include RegisterInfos_i386 to declare our g_register_infos_i386 structure.
+//---------------------------------------------------------------------------
+#define DECLARE_REGISTER_INFOS_I386_STRUCT
+#include "RegisterInfos_i386.h"
+#undef DECLARE_REGISTER_INFOS_I386_STRUCT
+
+RegisterContextOpenBSD_i386::RegisterContextOpenBSD_i386(
+ const ArchSpec &target_arch)
+ : RegisterInfoInterface(target_arch) {}
+
+size_t RegisterContextOpenBSD_i386::GetGPRSize() const { return sizeof(GPR); }
+
+const RegisterInfo *RegisterContextOpenBSD_i386::GetRegisterInfo() const {
+ switch (m_target_arch.GetMachine()) {
+ case llvm::Triple::x86:
+ return g_register_infos_i386;
+ default:
+ assert(false && "Unhandled target architecture.");
+ return NULL;
+ }
+}
+
+uint32_t RegisterContextOpenBSD_i386::GetRegisterCount() const {
+ return static_cast<uint32_t>(sizeof(g_register_infos_i386) /
+ sizeof(g_register_infos_i386[0]));
+}
diff --git a/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.h b/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.h
new file mode 100644
index 000000000000..d3c13008bece
--- /dev/null
+++ b/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.h
@@ -0,0 +1,26 @@
+//===-- RegisterContextOpenBSD_i386.h ---------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_RegisterContextOpenBSD_i386_H_
+#define liblldb_RegisterContextOpenBSD_i386_H_
+
+#include "RegisterInfoInterface.h"
+
+class RegisterContextOpenBSD_i386 : public lldb_private::RegisterInfoInterface {
+public:
+ RegisterContextOpenBSD_i386(const lldb_private::ArchSpec &target_arch);
+
+ size_t GetGPRSize() const override;
+
+ const lldb_private::RegisterInfo *GetRegisterInfo() const override;
+
+ uint32_t GetRegisterCount() const override;
+};
+
+#endif
diff --git a/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp b/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp
new file mode 100644
index 000000000000..e7ff0732ffec
--- /dev/null
+++ b/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp
@@ -0,0 +1,107 @@
+//===-- RegisterContextOpenBSD_x86_64.cpp ----------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===---------------------------------------------------------------------===//
+
+#include "RegisterContextOpenBSD_x86_64.h"
+#include "RegisterContextPOSIX_x86.h"
+#include <vector>
+
+using namespace lldb_private;
+using namespace lldb;
+
+// /usr/include/machine/reg.h
+typedef struct _GPR {
+ uint64_t rdi;
+ uint64_t rsi;
+ uint64_t rdx;
+ uint64_t rcx;
+ uint64_t r8;
+ uint64_t r9;
+ uint64_t r10;
+ uint64_t r11;
+ uint64_t r12;
+ uint64_t r13;
+ uint64_t r14;
+ uint64_t r15;
+ uint64_t rbp;
+ uint64_t rbx;
+ uint64_t rax;
+ uint64_t rsp;
+ uint64_t rip;
+ uint64_t rflags;
+ uint64_t cs;
+ uint64_t ss;
+ uint64_t ds;
+ uint64_t es;
+ uint64_t fs;
+ uint64_t gs;
+} GPR;
+
+struct DBG {
+ uint64_t dr[16]; /* debug registers */
+ /* Index 0-3: debug address registers */
+ /* Index 4-5: reserved */
+ /* Index 6: debug status */
+ /* Index 7: debug control */
+ /* Index 8-15: reserved */
+};
+
+struct UserArea {
+ GPR gpr;
+ FPR fpr;
+ DBG dbg;
+};
+
+#define DR_OFFSET(reg_index) (LLVM_EXTENSION offsetof(DBG, dr[reg_index]))
+
+//---------------------------------------------------------------------------
+// Include RegisterInfos_x86_64 to declare our g_register_infos_x86_64
+// structure.
+//---------------------------------------------------------------------------
+#define DECLARE_REGISTER_INFOS_X86_64_STRUCT
+#include "RegisterInfos_x86_64.h"
+#undef DECLARE_REGISTER_INFOS_X86_64_STRUCT
+
+static const RegisterInfo *
+PrivateGetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch) {
+ switch (target_arch.GetMachine()) {
+ case llvm::Triple::x86_64:
+ return g_register_infos_x86_64;
+ default:
+ assert(false && "Unhandled target architecture.");
+ return nullptr;
+ }
+}
+
+static uint32_t
+PrivateGetRegisterCount(const lldb_private::ArchSpec &target_arch) {
+ switch (target_arch.GetMachine()) {
+ case llvm::Triple::x86_64:
+ return static_cast<uint32_t>(sizeof(g_register_infos_x86_64) /
+ sizeof(g_register_infos_x86_64[0]));
+ default:
+ assert(false && "Unhandled target architecture.");
+ return 0;
+ }
+}
+
+RegisterContextOpenBSD_x86_64::RegisterContextOpenBSD_x86_64(
+ const ArchSpec &target_arch)
+ : lldb_private::RegisterInfoInterface(target_arch),
+ m_register_info_p(PrivateGetRegisterInfoPtr(target_arch)),
+ m_register_count(PrivateGetRegisterCount(target_arch)) {}
+
+size_t RegisterContextOpenBSD_x86_64::GetGPRSize() const { return sizeof(GPR); }
+
+const RegisterInfo *RegisterContextOpenBSD_x86_64::GetRegisterInfo() const {
+ return m_register_info_p;
+}
+
+uint32_t RegisterContextOpenBSD_x86_64::GetRegisterCount() const {
+ return m_register_count;
+}
diff --git a/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h b/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h
new file mode 100644
index 000000000000..aa2b7733f389
--- /dev/null
+++ b/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h
@@ -0,0 +1,31 @@
+//===-- RegisterContextOpenBSD_x86_64.h -------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_RegisterContextOpenBSD_x86_64_H_
+#define liblldb_RegisterContextOpenBSD_x86_64_H_
+
+#include "RegisterInfoInterface.h"
+
+class RegisterContextOpenBSD_x86_64
+ : public lldb_private::RegisterInfoInterface {
+public:
+ RegisterContextOpenBSD_x86_64(const lldb_private::ArchSpec &target_arch);
+
+ size_t GetGPRSize() const override;
+
+ const lldb_private::RegisterInfo *GetRegisterInfo() const override;
+
+ uint32_t GetRegisterCount() const override;
+
+private:
+ const lldb_private::RegisterInfo *m_register_info_p;
+ const uint32_t m_register_count;
+};
+
+#endif
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp
index 15d155e315fa..bb3509330eec 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp
@@ -11,13 +11,13 @@
#include <errno.h>
#include <stdint.h>
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
#include "llvm/Support/Compiler.h"
#include "Plugins/Process/elf-core/ProcessElfCore.h"
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h
index 817649e7c498..8c5fe9d2c2de 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h
@@ -16,8 +16,8 @@
// Project includes
#include "RegisterInfoInterface.h"
#include "lldb-arm-register-enums.h"
-#include "lldb/Core/Log.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/Utility/Log.h"
class ProcessMonitor;
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
index 17c9dc301b50..89384c8f5190 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
@@ -11,13 +11,13 @@
#include <errno.h>
#include <stdint.h>
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
#include "llvm/Support/Compiler.h"
#include "Plugins/Process/elf-core/ProcessElfCore.h"
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
index 923e786dd045..27251da2a9af 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
@@ -16,8 +16,8 @@
// Project includes
#include "RegisterInfoInterface.h"
#include "lldb-arm64-register-enums.h"
-#include "lldb/Core/Log.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/Utility/Log.h"
class ProcessMonitor;
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp
index 8c67fb89d08e..207c69313282 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp
@@ -11,47 +11,33 @@
#include <errno.h>
#include <stdint.h>
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
#include "llvm/Support/Compiler.h"
#include "Plugins/Process/elf-core/ProcessElfCore.h"
#include "RegisterContextPOSIX_mips64.h"
+#include "RegisterContextFreeBSD_mips64.h"
+#include "RegisterContextLinux_mips64.h"
+#include "RegisterContextLinux_mips.h"
using namespace lldb_private;
using namespace lldb;
-static const uint32_t g_gpr_regnums[] = {
- gpr_zero_mips64, gpr_r1_mips64, gpr_r2_mips64, gpr_r3_mips64,
- gpr_r4_mips64, gpr_r5_mips64, gpr_r6_mips64, gpr_r7_mips64,
- gpr_r8_mips64, gpr_r9_mips64, gpr_r10_mips64, gpr_r11_mips64,
- gpr_r12_mips64, gpr_r13_mips64, gpr_r14_mips64, gpr_r15_mips64,
- gpr_r16_mips64, gpr_r17_mips64, gpr_r18_mips64, gpr_r19_mips64,
- gpr_r20_mips64, gpr_r21_mips64, gpr_r22_mips64, gpr_r23_mips64,
- gpr_r24_mips64, gpr_r25_mips64, gpr_r26_mips64, gpr_r27_mips64,
- gpr_gp_mips64, gpr_sp_mips64, gpr_r30_mips64, gpr_ra_mips64,
- gpr_sr_mips64, gpr_mullo_mips64, gpr_mulhi_mips64, gpr_badvaddr_mips64,
- gpr_cause_mips64, gpr_pc_mips64, gpr_ic_mips64, gpr_dummy_mips64};
-
-// Number of register sets provided by this context.
-enum { k_num_register_sets = 1 };
-
-static const RegisterSet g_reg_sets_mips64[k_num_register_sets] = {
- {"General Purpose Registers", "gpr", k_num_gpr_registers_mips64,
- g_gpr_regnums},
-};
-
bool RegisterContextPOSIX_mips64::IsGPR(unsigned reg) {
- return reg <= k_num_gpr_registers_mips64; // GPR's come first.
+ return reg < m_registers_count[gpr_registers_count]; // GPR's come first.
}
bool RegisterContextPOSIX_mips64::IsFPR(unsigned reg) {
- // XXX
+ int set = GetRegisterSetCount();
+ if (set > 1)
+ return reg < (m_registers_count[fpr_registers_count]
+ + m_registers_count[gpr_registers_count]);
return false;
}
@@ -60,6 +46,18 @@ RegisterContextPOSIX_mips64::RegisterContextPOSIX_mips64(
RegisterInfoInterface *register_info)
: RegisterContext(thread, concrete_frame_idx) {
m_register_info_ap.reset(register_info);
+ m_num_registers = GetRegisterCount();
+ int set = GetRegisterSetCount();
+
+ const RegisterSet *reg_set_ptr;
+ for(int i = 0; i < set; ++i) {
+ reg_set_ptr = GetRegisterSet(i);
+ m_registers_count[i] = reg_set_ptr->num_registers;
+ }
+
+ assert(m_num_registers == m_registers_count[gpr_registers_count] +
+ m_registers_count[fpr_registers_count] +
+ m_registers_count[msa_registers_count]);
// elf-core yet to support ReadFPR()
ProcessSP base = CalculateProcess();
@@ -74,18 +72,17 @@ void RegisterContextPOSIX_mips64::Invalidate() {}
void RegisterContextPOSIX_mips64::InvalidateAllRegisters() {}
unsigned RegisterContextPOSIX_mips64::GetRegisterOffset(unsigned reg) {
- assert(reg < k_num_registers_mips64 && "Invalid register number.");
+ assert(reg < m_num_registers && "Invalid register number.");
return GetRegisterInfo()[reg].byte_offset;
}
unsigned RegisterContextPOSIX_mips64::GetRegisterSize(unsigned reg) {
- assert(reg < k_num_registers_mips64 && "Invalid register number.");
+ assert(reg < m_num_registers && "Invalid register number.");
return GetRegisterInfo()[reg].byte_size;
}
size_t RegisterContextPOSIX_mips64::GetRegisterCount() {
- size_t num_registers = k_num_registers_mips64;
- return num_registers;
+ return m_register_info_ap->GetRegisterCount();
}
size_t RegisterContextPOSIX_mips64::GetGPRSize() {
@@ -101,31 +98,59 @@ const RegisterInfo *RegisterContextPOSIX_mips64::GetRegisterInfo() {
const RegisterInfo *
RegisterContextPOSIX_mips64::GetRegisterInfoAtIndex(size_t reg) {
- if (reg < k_num_registers_mips64)
+ if (reg < m_num_registers)
return &GetRegisterInfo()[reg];
else
return NULL;
}
size_t RegisterContextPOSIX_mips64::GetRegisterSetCount() {
- size_t sets = 0;
- for (size_t set = 0; set < k_num_register_sets; ++set) {
- if (IsRegisterSetAvailable(set))
- ++sets;
+ ArchSpec target_arch = m_register_info_ap->GetTargetArchitecture();
+ switch (target_arch.GetTriple().getOS()) {
+ case llvm::Triple::Linux: {
+ if ((target_arch.GetMachine() == llvm::Triple::mipsel) ||
+ (target_arch.GetMachine() == llvm::Triple::mips)) {
+ const auto *context = static_cast<const RegisterContextLinux_mips *>
+ (m_register_info_ap.get());
+ return context->GetRegisterSetCount();
+ }
+ const auto *context = static_cast<const RegisterContextLinux_mips64 *>
+ (m_register_info_ap.get());
+ return context->GetRegisterSetCount();
+ }
+ default: {
+ const auto *context = static_cast<const RegisterContextFreeBSD_mips64 *>
+ (m_register_info_ap.get());
+ return context->GetRegisterSetCount();
+ }
+
}
-
- return sets;
}
const RegisterSet *RegisterContextPOSIX_mips64::GetRegisterSet(size_t set) {
- if (IsRegisterSetAvailable(set))
- return &g_reg_sets_mips64[set];
- else
- return NULL;
+ ArchSpec target_arch = m_register_info_ap->GetTargetArchitecture();
+ switch (target_arch.GetTriple().getOS()) {
+ case llvm::Triple::Linux: {
+ if ((target_arch.GetMachine() == llvm::Triple::mipsel) ||
+ (target_arch.GetMachine() == llvm::Triple::mips)) {
+ const auto *context = static_cast<const RegisterContextLinux_mips *>
+ (m_register_info_ap.get());
+ return context->GetRegisterSet(set);
+ }
+ const auto *context = static_cast<const RegisterContextLinux_mips64 *>
+ (m_register_info_ap.get());
+ return context->GetRegisterSet(set);
+ }
+ default: {
+ const auto *context = static_cast<const RegisterContextFreeBSD_mips64 *>
+ (m_register_info_ap.get());
+ return context->GetRegisterSet(set);
+ }
+ }
}
const char *RegisterContextPOSIX_mips64::GetRegisterName(unsigned reg) {
- assert(reg < k_num_registers_mips64 && "Invalid register offset.");
+ assert(reg < m_num_registers && "Invalid register offset.");
return GetRegisterInfo()[reg].name;
}
@@ -141,7 +166,7 @@ lldb::ByteOrder RegisterContextPOSIX_mips64::GetByteOrder() {
}
bool RegisterContextPOSIX_mips64::IsRegisterSetAvailable(size_t set_index) {
- size_t num_sets = k_num_register_sets;
+ size_t num_sets = GetRegisterSetCount();
return (set_index < num_sets);
}
@@ -150,7 +175,7 @@ bool RegisterContextPOSIX_mips64::IsRegisterSetAvailable(size_t set_index) {
// object file sections that contain register numbers in them.
uint32_t RegisterContextPOSIX_mips64::ConvertRegisterKindToRegisterNumber(
lldb::RegisterKind kind, uint32_t num) {
- const uint32_t num_regs = GetRegisterCount();
+ const uint32_t num_regs = m_num_registers;
assert(kind < kNumRegisterKinds);
for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) {
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h
index 90ff9d659491..1695ec9a0bab 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h
@@ -16,9 +16,8 @@
// Project includes
#include "RegisterContext_mips.h"
#include "RegisterInfoInterface.h"
-#include "lldb-mips-freebsd-register-enums.h"
-#include "lldb/Core/Log.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/Utility/Log.h"
using namespace lldb_private;
@@ -26,6 +25,14 @@ class ProcessMonitor;
class RegisterContextPOSIX_mips64 : public lldb_private::RegisterContext {
public:
+
+ enum Register_count{
+ gpr_registers_count = 0,
+ fpr_registers_count,
+ msa_registers_count,
+ register_set_count
+ };
+
RegisterContextPOSIX_mips64(
lldb_private::Thread &thread, uint32_t concrete_frame_idx,
lldb_private::RegisterInfoInterface *register_info);
@@ -56,8 +63,8 @@ public:
uint32_t num) override;
protected:
- uint64_t
- m_gpr_mips64[k_num_gpr_registers_mips64]; // general purpose registers.
+ uint32_t m_num_registers;
+ uint8_t m_registers_count[register_set_count];
std::unique_ptr<lldb_private::RegisterInfoInterface>
m_register_info_ap; // Register Info Interface (FreeBSD or Linux)
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp
index 6a9838a6fd0c..c2b73e226165 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp
@@ -12,13 +12,13 @@
#include <errno.h>
#include <stdint.h>
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
#include "llvm/Support/Compiler.h"
#include "Plugins/Process/elf-core/ProcessElfCore.h"
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h
index 79bb01f6740c..50f234680ca0 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h
@@ -16,8 +16,8 @@
// Project includes
#include "RegisterContext_powerpc.h"
#include "RegisterInfoInterface.h"
-#include "lldb/Core/Log.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/Utility/Log.h"
class ProcessMonitor;
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp
index e4dbe333a22d..b3365ee2f098 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp
@@ -11,14 +11,14 @@
#include <errno.h>
#include <stdint.h>
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
#include "llvm/Support/Compiler.h"
#include "RegisterContextPOSIX_s390x.h"
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h
index 1ffc45c2d4b1..d5337630c32d 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h
@@ -17,8 +17,8 @@
#include "RegisterContext_s390x.h"
#include "RegisterInfoInterface.h"
#include "lldb-s390x-register-enums.h"
-#include "lldb/Core/Log.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/Utility/Log.h"
class ProcessMonitor;
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
index 99525b6c2df2..5e1bf35356b8 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
@@ -11,14 +11,14 @@
#include <errno.h>
#include <stdint.h>
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
-#include "lldb/Host/Endian.h"
+#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
-#include "lldb/Target/Process.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
#include "llvm/Support/Compiler.h"
#include "RegisterContextPOSIX_x86.h"
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
index c5afe089e476..aa689273f218 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
@@ -17,8 +17,8 @@
#include "RegisterContext_x86.h"
#include "RegisterInfoInterface.h"
#include "lldb-x86-register-enums.h"
-#include "lldb/Core/Log.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/Utility/Log.h"
class ProcessMonitor;
diff --git a/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp b/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
index 2b5cb00fa96a..7d990e73b5be 100644
--- a/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
@@ -7,10 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/Error.h"
#include "lldb/Target/OperatingSystem.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-private.h"
#include "RegisterContextThreadMemory.h"
diff --git a/source/Plugins/Process/Utility/RegisterInfoInterface.h b/source/Plugins/Process/Utility/RegisterInfoInterface.h
index 12db366d7a57..74d5d6e50208 100644
--- a/source/Plugins/Process/Utility/RegisterInfoInterface.h
+++ b/source/Plugins/Process/Utility/RegisterInfoInterface.h
@@ -13,6 +13,7 @@
#include <vector>
#include "lldb/Core/ArchSpec.h"
+#include "lldb/lldb-private-types.h"
namespace lldb_private {
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_arm.cpp b/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.cpp
index afa105f25404..0111b842509b 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_arm.cpp
+++ b/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.cpp
@@ -1,4 +1,4 @@
-//===-- RegisterContextLinux_arm.cpp ---------------------------*- C++ -*-===//
+//===-- RegisterInfoPOSIX_arm.cpp ------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -14,37 +14,35 @@
#include "lldb/lldb-defines.h"
#include "llvm/Support/Compiler.h"
-#include "RegisterContextLinux_arm.h"
+#include "RegisterInfoPOSIX_arm.h"
using namespace lldb;
using namespace lldb_private;
// Based on RegisterContextDarwin_arm.cpp
#define GPR_OFFSET(idx) ((idx)*4)
-#define FPU_OFFSET(idx) ((idx)*4 + sizeof(RegisterContextLinux_arm::GPR))
+#define FPU_OFFSET(idx) ((idx)*4 + sizeof(RegisterInfoPOSIX_arm::GPR))
#define FPSCR_OFFSET \
- (LLVM_EXTENSION offsetof(RegisterContextLinux_arm::FPU, fpscr) + \
- sizeof(RegisterContextLinux_arm::GPR))
+ (LLVM_EXTENSION offsetof(RegisterInfoPOSIX_arm::FPU, fpscr) + \
+ sizeof(RegisterInfoPOSIX_arm::GPR))
#define EXC_OFFSET(idx) \
- ((idx)*4 + sizeof(RegisterContextLinux_arm::GPR) + \
- sizeof(RegisterContextLinux_arm::FPU))
+ ((idx)*4 + sizeof(RegisterInfoPOSIX_arm::GPR) + \
+ sizeof(RegisterInfoPOSIX_arm::FPU))
#define DBG_OFFSET(reg) \
- ((LLVM_EXTENSION offsetof(RegisterContextLinux_arm::DBG, reg) + \
- sizeof(RegisterContextLinux_arm::GPR) + \
- sizeof(RegisterContextLinux_arm::FPU) + \
- sizeof(RegisterContextLinux_arm::EXC)))
+ ((LLVM_EXTENSION offsetof(RegisterInfoPOSIX_arm::DBG, reg) + \
+ sizeof(RegisterInfoPOSIX_arm::GPR) + sizeof(RegisterInfoPOSIX_arm::FPU) + \
+ sizeof(RegisterInfoPOSIX_arm::EXC)))
#define DEFINE_DBG(reg, i) \
- #reg, NULL, sizeof(((RegisterContextLinux_arm::DBG *) NULL)->reg[i]), \
+ #reg, NULL, sizeof(((RegisterInfoPOSIX_arm::DBG *) NULL)->reg[i]), \
DBG_OFFSET(reg[i]), eEncodingUint, eFormatHex, \
{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
dbg_##reg##i }, \
NULL, NULL, NULL, 0
#define REG_CONTEXT_SIZE \
- (sizeof(RegisterContextLinux_arm::GPR) + \
- sizeof(RegisterContextLinux_arm::FPU) + \
- sizeof(RegisterContextLinux_arm::EXC))
+ (sizeof(RegisterInfoPOSIX_arm::GPR) + sizeof(RegisterInfoPOSIX_arm::FPU) + \
+ sizeof(RegisterInfoPOSIX_arm::EXC))
//-----------------------------------------------------------------------------
// Include RegisterInfos_arm to declare our g_register_infos_arm structure.
@@ -76,21 +74,21 @@ GetRegisterInfoCount(const lldb_private::ArchSpec &target_arch) {
}
}
-RegisterContextLinux_arm::RegisterContextLinux_arm(
+RegisterInfoPOSIX_arm::RegisterInfoPOSIX_arm(
const lldb_private::ArchSpec &target_arch)
: lldb_private::RegisterInfoInterface(target_arch),
m_register_info_p(GetRegisterInfoPtr(target_arch)),
m_register_info_count(GetRegisterInfoCount(target_arch)) {}
-size_t RegisterContextLinux_arm::GetGPRSize() const {
- return sizeof(struct RegisterContextLinux_arm::GPR);
+size_t RegisterInfoPOSIX_arm::GetGPRSize() const {
+ return sizeof(struct RegisterInfoPOSIX_arm::GPR);
}
const lldb_private::RegisterInfo *
-RegisterContextLinux_arm::GetRegisterInfo() const {
+RegisterInfoPOSIX_arm::GetRegisterInfo() const {
return m_register_info_p;
}
-uint32_t RegisterContextLinux_arm::GetRegisterCount() const {
+uint32_t RegisterInfoPOSIX_arm::GetRegisterCount() const {
return m_register_info_count;
}
diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_arm.h b/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.h
index 422ecb7686dc..d90aec1c5116 100644
--- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_arm.h
+++ b/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.h
@@ -1,4 +1,4 @@
-//===-- RegisterContextFreeBSD_arm.h ----------------------------*- C++ -*-===//
+//===-- RegisterInfoPOSIX_arm.h ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,14 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RegisterContextFreeBSD_arm_h_
-#define liblldb_RegisterContextFreeBSD_arm_h_
+#ifndef liblldb_RegisterInfoPOSIX_arm_h_
+#define liblldb_RegisterInfoPOSIX_arm_h_
#include "RegisterInfoInterface.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/lldb-private.h"
-class RegisterContextFreeBSD_arm : public lldb_private::RegisterInfoInterface {
+class RegisterInfoPOSIX_arm : public lldb_private::RegisterInfoInterface {
public:
struct GPR {
uint32_t r[16]; // R0-R15
@@ -46,7 +46,7 @@ public:
uint32_t wcr[16];
};
- RegisterContextFreeBSD_arm(const lldb_private::ArchSpec &target_arch);
+ RegisterInfoPOSIX_arm(const lldb_private::ArchSpec &target_arch);
size_t GetGPRSize() const override;
@@ -59,4 +59,4 @@ private:
uint32_t m_register_info_count;
};
-#endif // liblldb_RegisterContextFreeBSD_arm_h_
+#endif // liblldb_RegisterInfoPOSIX_arm_h_
diff --git a/source/Plugins/Process/Utility/StopInfoMachException.cpp b/source/Plugins/Process/Utility/StopInfoMachException.cpp
index 3b29a18dbe20..435f3d18c062 100644
--- a/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ b/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -15,7 +15,6 @@
// Project includes
#include "lldb/Breakpoint/Watchpoint.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/ExecutionContext.h"
@@ -25,6 +24,7 @@
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlan.h"
#include "lldb/Target/UnixSignals.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/Process/Utility/UnwindLLDB.cpp b/source/Plugins/Process/Utility/UnwindLLDB.cpp
index 6e2a9a9ee100..2b34bddd90b2 100644
--- a/source/Plugins/Process/Utility/UnwindLLDB.cpp
+++ b/source/Plugins/Process/Utility/UnwindLLDB.cpp
@@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/FuncUnwinders.h"
#include "lldb/Symbol/Function.h"
@@ -17,6 +16,7 @@
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/Log.h"
#include "RegisterContextLLDB.h"
#include "UnwindLLDB.h"
diff --git a/source/Plugins/Process/Utility/UnwindLLDB.h b/source/Plugins/Process/Utility/UnwindLLDB.h
index b9323032180d..3f84649aa05f 100644
--- a/source/Plugins/Process/Utility/UnwindLLDB.h
+++ b/source/Plugins/Process/Utility/UnwindLLDB.h
@@ -16,11 +16,11 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
#include "lldb/Symbol/FuncUnwinders.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Unwind.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-public.h"
namespace lldb_private {
diff --git a/source/Plugins/Process/Windows/Common/CMakeLists.txt b/source/Plugins/Process/Windows/Common/CMakeLists.txt
index 9386ed8a0e4c..009a289bae39 100644
--- a/source/Plugins/Process/Windows/Common/CMakeLists.txt
+++ b/source/Plugins/Process/Windows/Common/CMakeLists.txt
@@ -20,6 +20,17 @@ elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
)
endif()
-add_lldb_library(lldbPluginProcessWindowsCommon
+add_lldb_library(lldbPluginProcessWindowsCommon PLUGIN
${PROC_WINDOWS_COMMON_SOURCES}
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ ws2_32
+ rpcrt4
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/Process/Windows/Common/DebuggerThread.cpp b/source/Plugins/Process/Windows/Common/DebuggerThread.cpp
index be1462aa6602..b79359ba9667 100644
--- a/source/Plugins/Process/Windows/Common/DebuggerThread.cpp
+++ b/source/Plugins/Process/Windows/Common/DebuggerThread.cpp
@@ -11,23 +11,23 @@
#include "ExceptionRecord.h"
#include "IDebugDelegate.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/ModuleSpec.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Predicate.h"
-#include "lldb/Host/ThisThread.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Host/windows/HostProcessWindows.h"
#include "lldb/Host/windows/HostThreadWindows.h"
#include "lldb/Host/windows/ProcessLauncherWindows.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/ProcessLaunchInfo.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
#include "Plugins/Process/Windows/Common/ProcessWindowsLog.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/Threading.h"
#include "llvm/Support/raw_ostream.h"
using namespace lldb;
@@ -61,9 +61,8 @@ DebuggerThread::DebuggerThread(DebugDelegateSP debug_delegate)
DebuggerThread::~DebuggerThread() { ::CloseHandle(m_debugging_ended_event); }
Error DebuggerThread::DebugLaunch(const ProcessLaunchInfo &launch_info) {
- WINLOG_IFALL(WINDOWS_LOG_PROCESS,
- "DebuggerThread::DebugLaunch launching '%s'",
- launch_info.GetExecutableFile().GetPath().c_str());
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ LLDB_LOG(log, "launching '{0}'", launch_info.GetExecutableFile().GetPath());
Error error;
DebugLaunchContext *context = new DebugLaunchContext(this, launch_info);
@@ -71,19 +70,16 @@ Error DebuggerThread::DebugLaunch(const ProcessLaunchInfo &launch_info) {
"lldb.plugin.process-windows.slave[?]", DebuggerThreadLaunchRoutine,
context, &error));
- if (!error.Success()) {
- WINERR_IFALL(WINDOWS_LOG_PROCESS,
- "DebugLaunch couldn't launch debugger thread. %s",
- error.AsCString());
- }
+ if (!error.Success())
+ LLDB_LOG(log, "couldn't launch debugger thread. {0}", error);
return error;
}
Error DebuggerThread::DebugAttach(lldb::pid_t pid,
const ProcessAttachInfo &attach_info) {
- WINLOG_IFALL(WINDOWS_LOG_PROCESS,
- "DebuggerThread::DebugAttach attaching to '%llu'", pid);
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ LLDB_LOG(log, "attaching to '{0}'", pid);
Error error;
DebugAttachContext *context = new DebugAttachContext(this, pid, attach_info);
@@ -91,11 +87,8 @@ Error DebuggerThread::DebugAttach(lldb::pid_t pid,
"lldb.plugin.process-windows.slave[?]", DebuggerThreadAttachRoutine,
context, &error));
- if (!error.Success()) {
- WINERR_IFALL(WINDOWS_LOG_PROCESS,
- "DebugAttach couldn't attach to process '%llu'. %s", pid,
- error.AsCString());
- }
+ if (!error.Success())
+ LLDB_LOG(log, "couldn't attach to process '{0}'. {1}", pid, error);
return error;
}
@@ -123,9 +116,9 @@ lldb::thread_result_t DebuggerThread::DebuggerThreadLaunchRoutine(
// thread routine has exited.
std::shared_ptr<DebuggerThread> this_ref(shared_from_this());
- WINLOG_IFALL(WINDOWS_LOG_PROCESS,
- "DebuggerThread preparing to launch '%s' on background thread.",
- launch_info.GetExecutableFile().GetPath().c_str());
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ LLDB_LOG(log, "preparing to launch '{0}' on background thread.",
+ launch_info.GetExecutableFile().GetPath());
Error error;
ProcessLauncherWindows launcher;
@@ -154,9 +147,9 @@ lldb::thread_result_t DebuggerThread::DebuggerThreadAttachRoutine(
// thread routine has exited.
std::shared_ptr<DebuggerThread> this_ref(shared_from_this());
- WINLOG_IFALL(WINDOWS_LOG_PROCESS, "DebuggerThread preparing to attach to "
- "process '%llu' on background thread.",
- pid);
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ LLDB_LOG(log, "preparing to attach to process '{0}' on background thread.",
+ pid);
if (!DebugActiveProcess((DWORD)pid)) {
Error error(::GetLastError(), eErrorTypeWin32);
@@ -179,9 +172,8 @@ Error DebuggerThread::StopDebugging(bool terminate) {
lldb::pid_t pid = m_process.GetProcessId();
- WINLOG_IFALL(WINDOWS_LOG_PROCESS,
- "StopDebugging('%s') called (inferior=%I64u).",
- (terminate ? "true" : "false"), pid);
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ LLDB_LOG(log, "terminate = {0}, inferior={1}.", terminate, pid);
// Set m_is_shutting_down to true if it was false. Return if it was already
// true.
@@ -200,10 +192,9 @@ Error DebuggerThread::StopDebugging(bool terminate) {
// next debug
// event we get is the exit process event, and not some other event.
BOOL terminate_suceeded = TerminateProcess(handle, 0);
- WINLOG_IFALL(WINDOWS_LOG_PROCESS, "StopDebugging called "
- "TerminateProcess(0x%p, 0) "
- "(inferior=%I64u), success='%s'",
- handle, pid, (terminate_suceeded ? "true" : "false"));
+ LLDB_LOG(log,
+ "calling TerminateProcess({0}, 0) (inferior={1}), success={2}",
+ handle, pid, terminate_suceeded);
}
// If we're stuck waiting for an exception to continue (e.g. the user is at a
@@ -213,9 +204,7 @@ Error DebuggerThread::StopDebugging(bool terminate) {
// to make sure that the very next call to WaitForDebugEvent is an exit
// process event.
if (m_active_exception.get()) {
- WINLOG_IFANY(WINDOWS_LOG_PROCESS | WINDOWS_LOG_EXCEPTION,
- "StopDebugging masking active exception");
-
+ LLDB_LOG(log, "masking active exception");
ContinueAsyncException(ExceptionResult::MaskException);
}
@@ -231,26 +220,19 @@ Error DebuggerThread::StopDebugging(bool terminate) {
}
}
- WINLOG_IFALL(
- WINDOWS_LOG_PROCESS,
- "StopDebugging waiting for detach from process %llu to complete.", pid);
+ LLDB_LOG(log, "waiting for detach from process {0} to complete.", pid);
DWORD wait_result = WaitForSingleObject(m_debugging_ended_event, 5000);
if (wait_result != WAIT_OBJECT_0) {
error.SetError(GetLastError(), eErrorTypeWin32);
- WINERR_IFALL(WINDOWS_LOG_PROCESS,
- "StopDebugging WaitForSingleObject(0x%p, 5000) returned %lu",
- m_debugging_ended_event, wait_result);
- } else {
- WINLOG_IFALL(
- WINDOWS_LOG_PROCESS,
- "StopDebugging detach from process %llu completed successfully.", pid);
- }
+ LLDB_LOG(log, "error: WaitForSingleObject({0}, 5000) returned {1}",
+ m_debugging_ended_event, wait_result);
+ } else
+ LLDB_LOG(log, "detach from process {0} completed successfully.", pid);
if (!error.Success()) {
- WINERR_IFALL(WINDOWS_LOG_PROCESS, "StopDebugging encountered an error "
- "while trying to stop process %llu. %s",
- pid, error.AsCString());
+ LLDB_LOG(log, "encountered an error while trying to stop process {0}. {1}",
+ pid, error);
}
return error;
}
@@ -259,10 +241,10 @@ void DebuggerThread::ContinueAsyncException(ExceptionResult result) {
if (!m_active_exception.get())
return;
- WINLOG_IFANY(
- WINDOWS_LOG_PROCESS | WINDOWS_LOG_EXCEPTION,
- "ContinueAsyncException called for inferior process %I64u, broadcasting.",
- m_process.GetProcessId());
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS |
+ WINDOWS_LOG_EXCEPTION);
+ LLDB_LOG(log, "broadcasting for inferior process {0}.",
+ m_process.GetProcessId());
m_active_exception.reset();
m_exception_pred.SetValue(result, eBroadcastAlways);
@@ -278,11 +260,12 @@ void DebuggerThread::FreeProcessHandles() {
}
void DebuggerThread::DebugLoop() {
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT);
DEBUG_EVENT dbe = {};
bool should_debug = true;
- WINLOG_IFALL(WINDOWS_LOG_EVENT, "Entering WaitForDebugEvent loop");
+ LLDB_LOGV(log, "Entering WaitForDebugEvent loop");
while (should_debug) {
- WINLOGD_IFALL(WINDOWS_LOG_EVENT, "Calling WaitForDebugEvent");
+ LLDB_LOGV(log, "Calling WaitForDebugEvent");
BOOL wait_result = WaitForDebugEvent(&dbe, INFINITE);
if (wait_result) {
DWORD continue_status = DBG_CONTINUE;
@@ -331,11 +314,9 @@ void DebuggerThread::DebugLoop() {
break;
}
- WINLOGD_IFALL(
- WINDOWS_LOG_EVENT,
- "DebugLoop calling ContinueDebugEvent(%lu, %lu, %lu) on thread %lu.",
- dbe.dwProcessId, dbe.dwThreadId, continue_status,
- ::GetCurrentThreadId());
+ LLDB_LOGV(log, "calling ContinueDebugEvent({0}, {1}, {2}) on thread {3}.",
+ dbe.dwProcessId, dbe.dwThreadId, continue_status,
+ ::GetCurrentThreadId());
::ContinueDebugEvent(dbe.dwProcessId, dbe.dwThreadId, continue_status);
@@ -343,23 +324,23 @@ void DebuggerThread::DebugLoop() {
should_debug = false;
}
} else {
- WINERR_IFALL(
- WINDOWS_LOG_EVENT,
- "DebugLoop returned FALSE from WaitForDebugEvent. Error = %lu",
- ::GetLastError());
+ LLDB_LOG(log, "returned FALSE from WaitForDebugEvent. Error = {0}",
+ ::GetLastError());
should_debug = false;
}
}
FreeProcessHandles();
- WINLOG_IFALL(WINDOWS_LOG_EVENT, "WaitForDebugEvent loop completed, exiting.");
+ LLDB_LOG(log, "WaitForDebugEvent loop completed, exiting.");
SetEvent(m_debugging_ended_event);
}
ExceptionResult
DebuggerThread::HandleExceptionEvent(const EXCEPTION_DEBUG_INFO &info,
DWORD thread_id) {
+ Log *log =
+ ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION);
if (m_is_shutting_down) {
// A breakpoint that occurs while `m_pid_to_detach` is non-zero is a magic
// exception that
@@ -367,10 +348,8 @@ DebuggerThread::HandleExceptionEvent(const EXCEPTION_DEBUG_INFO &info,
// debug loop.
if (m_pid_to_detach != 0 &&
info.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT) {
- WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION |
- WINDOWS_LOG_PROCESS,
- "Breakpoint exception is cue to detach from process 0x%lx",
- m_pid_to_detach.load());
+ LLDB_LOG(log, "Breakpoint exception is cue to detach from process {0:x}",
+ m_pid_to_detach.load());
::DebugActiveProcessStop(m_pid_to_detach);
m_detached = true;
}
@@ -385,36 +364,29 @@ DebuggerThread::HandleExceptionEvent(const EXCEPTION_DEBUG_INFO &info,
m_active_exception.reset(
new ExceptionRecord(info.ExceptionRecord, thread_id));
- WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION,
- "HandleExceptionEvent encountered %s chance exception 0x%lx on "
- "thread 0x%lx",
- first_chance ? "first" : "second",
- info.ExceptionRecord.ExceptionCode, thread_id);
+ LLDB_LOG(log, "encountered {0} chance exception {1:x} on thread {2:x}",
+ first_chance ? "first" : "second",
+ info.ExceptionRecord.ExceptionCode, thread_id);
ExceptionResult result =
m_debug_delegate->OnDebugException(first_chance, *m_active_exception);
m_exception_pred.SetValue(result, eBroadcastNever);
- WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION,
- "DebuggerThread::HandleExceptionEvent waiting for ExceptionPred "
- "!= BreakInDebugger");
-
+ LLDB_LOG(log, "waiting for ExceptionPred != BreakInDebugger");
m_exception_pred.WaitForValueNotEqualTo(ExceptionResult::BreakInDebugger,
result);
- WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION,
- "DebuggerThread::HandleExceptionEvent got ExceptionPred = %u",
- m_exception_pred.GetValue());
-
+ LLDB_LOG(log, "got ExceptionPred = {0}", (int)m_exception_pred.GetValue());
return result;
}
DWORD
DebuggerThread::HandleCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO &info,
DWORD thread_id) {
- WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD,
- "HandleCreateThreadEvent Thread 0x%lx spawned in process %llu",
- thread_id, m_process.GetProcessId());
+ Log *log =
+ ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD);
+ LLDB_LOG(log, "Thread {0:x} spawned in process {1}", thread_id,
+ m_process.GetProcessId());
HostThread thread(info.hThread);
thread.GetNativeThread().SetOwnsHandle(false);
m_debug_delegate->OnCreateThread(thread);
@@ -424,16 +396,17 @@ DebuggerThread::HandleCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO &info,
DWORD
DebuggerThread::HandleCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO &info,
DWORD thread_id) {
+ Log *log =
+ ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT | WINDOWS_LOG_PROCESS);
uint32_t process_id = ::GetProcessId(info.hProcess);
- WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_PROCESS,
- "HandleCreateProcessEvent process %u spawned", process_id);
+ LLDB_LOG(log, "process {0} spawned", process_id);
std::string thread_name;
llvm::raw_string_ostream name_stream(thread_name);
name_stream << "lldb.plugin.process-windows.slave[" << process_id << "]";
name_stream.flush();
- ThisThread::SetName(thread_name.c_str());
+ llvm::set_thread_name(thread_name);
// info.hProcess and info.hThread are closed automatically by Windows when
// EXIT_PROCESS_DEBUG_EVENT is received.
@@ -452,10 +425,10 @@ DebuggerThread::HandleCreateProcessEvent(const CREATE_PROCESS_DEBUG_INFO &info,
DWORD
DebuggerThread::HandleExitThreadEvent(const EXIT_THREAD_DEBUG_INFO &info,
DWORD thread_id) {
- WINLOG_IFANY(
- WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD,
- "HandleExitThreadEvent Thread %lu exited with code %lu in process %llu",
- thread_id, info.dwExitCode, m_process.GetProcessId());
+ Log *log =
+ ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD);
+ LLDB_LOG(log, "Thread {0} exited with code {1} in process {2}", thread_id,
+ info.dwExitCode, m_process.GetProcessId());
m_debug_delegate->OnExitThread(thread_id, info.dwExitCode);
return DBG_CONTINUE;
}
@@ -463,9 +436,10 @@ DebuggerThread::HandleExitThreadEvent(const EXIT_THREAD_DEBUG_INFO &info,
DWORD
DebuggerThread::HandleExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO &info,
DWORD thread_id) {
- WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD,
- "HandleExitProcessEvent process %llu exited with code %lu",
- m_process.GetProcessId(), info.dwExitCode);
+ Log *log =
+ ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT | WINDOWS_LOG_THREAD);
+ LLDB_LOG(log, "process {0} exited with code {1}", m_process.GetProcessId(),
+ info.dwExitCode);
m_debug_delegate->OnExitProcess(info.dwExitCode);
@@ -476,11 +450,11 @@ DebuggerThread::HandleExitProcessEvent(const EXIT_PROCESS_DEBUG_INFO &info,
DWORD
DebuggerThread::HandleLoadDllEvent(const LOAD_DLL_DEBUG_INFO &info,
DWORD thread_id) {
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT);
if (info.hFile == nullptr) {
// Not sure what this is, so just ignore it.
- WINWARN_IFALL(WINDOWS_LOG_EVENT, "Inferior %llu - HandleLoadDllEvent has "
- "a NULL file handle, returning...",
- m_process.GetProcessId());
+ LLDB_LOG(log, "Warning: Inferior {0} has a NULL file handle, returning...",
+ m_process.GetProcessId());
return DBG_CONTINUE;
}
@@ -502,16 +476,15 @@ DebuggerThread::HandleLoadDllEvent(const LOAD_DLL_DEBUG_INFO &info,
ModuleSpec module_spec(file_spec);
lldb::addr_t load_addr = reinterpret_cast<lldb::addr_t>(info.lpBaseOfDll);
- WINLOG_IFALL(WINDOWS_LOG_EVENT, "Inferior %I64u - HandleLoadDllEvent DLL "
- "'%s' loaded at address 0x%p...",
- m_process.GetProcessId(), path, info.lpBaseOfDll);
+ LLDB_LOG(log, "Inferior {0} - DLL '{1}' loaded at address {2:x}...",
+ m_process.GetProcessId(), path, info.lpBaseOfDll);
m_debug_delegate->OnLoadDll(module_spec, load_addr);
} else {
- WINERR_IFALL(WINDOWS_LOG_EVENT, "Inferior %llu - HandleLoadDllEvent Error "
- "%lu occurred calling "
- "GetFinalPathNameByHandle",
- m_process.GetProcessId(), ::GetLastError());
+ LLDB_LOG(
+ log,
+ "Inferior {0} - Error {1} occurred calling GetFinalPathNameByHandle",
+ m_process.GetProcessId(), ::GetLastError());
}
// Windows does not automatically close info.hFile, so we need to do it.
::CloseHandle(info.hFile);
@@ -521,9 +494,9 @@ DebuggerThread::HandleLoadDllEvent(const LOAD_DLL_DEBUG_INFO &info,
DWORD
DebuggerThread::HandleUnloadDllEvent(const UNLOAD_DLL_DEBUG_INFO &info,
DWORD thread_id) {
- WINLOG_IFALL(WINDOWS_LOG_EVENT,
- "HandleUnloadDllEvent process %llu unloading DLL at addr 0x%p.",
- m_process.GetProcessId(), info.lpBaseOfDll);
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT);
+ LLDB_LOG(log, "process {0} unloading DLL at addr {1:x}.",
+ m_process.GetProcessId(), info.lpBaseOfDll);
m_debug_delegate->OnUnloadDll(
reinterpret_cast<lldb::addr_t>(info.lpBaseOfDll));
@@ -538,9 +511,9 @@ DebuggerThread::HandleODSEvent(const OUTPUT_DEBUG_STRING_INFO &info,
DWORD
DebuggerThread::HandleRipEvent(const RIP_INFO &info, DWORD thread_id) {
- WINERR_IFALL(WINDOWS_LOG_EVENT, "HandleRipEvent encountered error %lu "
- "(type=%lu) in process %llu thread %lu",
- info.dwError, info.dwType, m_process.GetProcessId(), thread_id);
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EVENT);
+ LLDB_LOG(log, "encountered error {0} (type={1}) in process {2} thread {3}",
+ info.dwError, info.dwType, m_process.GetProcessId(), thread_id);
Error error(info.dwError, eErrorTypeWin32);
m_debug_delegate->OnDebuggerError(error, info.dwType);
diff --git a/source/Plugins/Process/Windows/Common/ProcessWindows.cpp b/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
index 50f787f78495..56a98a8eef63 100644
--- a/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
+++ b/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
@@ -23,6 +23,7 @@
#include "lldb/Host/HostProcess.h"
#include "lldb/Host/windows/HostThreadWindows.h"
#include "lldb/Host/windows/windows.h"
+#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Target/StopInfo.h"
@@ -30,6 +31,7 @@
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/Format.h"
+#include "llvm/Support/Threading.h"
#include "llvm/Support/raw_ostream.h"
#include "DebuggerThread.h"
@@ -102,9 +104,9 @@ ProcessSP ProcessWindows::CreateInstance(lldb::TargetSP target_sp,
}
void ProcessWindows::Initialize() {
- static std::once_flag g_once_flag;
+ static llvm::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
+ llvm::call_once(g_once_flag, []() {
PluginManager::RegisterPlugin(GetPluginNameStatic(),
GetPluginDescriptionStatic(), CreateInstance);
});
@@ -156,35 +158,30 @@ lldb_private::ConstString ProcessWindows::GetPluginName() {
uint32_t ProcessWindows::GetPluginVersion() { return 1; }
Error ProcessWindows::EnableBreakpointSite(BreakpointSite *bp_site) {
- WINLOG_IFALL(WINDOWS_LOG_BREAKPOINTS,
- "EnableBreakpointSite called with bp_site 0x%p "
- "(id=%d, addr=0x%llx)",
- bp_site, bp_site->GetID(), bp_site->GetLoadAddress());
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_BREAKPOINTS);
+ LLDB_LOG(log, "bp_site = {0:x}, id={1}, addr={2:x}", bp_site,
+ bp_site->GetID(), bp_site->GetLoadAddress());
Error error = EnableSoftwareBreakpoint(bp_site);
- if (!error.Success()) {
- WINERR_IFALL(WINDOWS_LOG_BREAKPOINTS, "EnableBreakpointSite failed. %s",
- error.AsCString());
- }
+ if (!error.Success())
+ LLDB_LOG(log, "error: {0}", error);
return error;
}
Error ProcessWindows::DisableBreakpointSite(BreakpointSite *bp_site) {
- WINLOG_IFALL(WINDOWS_LOG_BREAKPOINTS,
- "DisableBreakpointSite called with bp_site 0x%p "
- "(id=%d, addr=0x%llx)",
- bp_site, bp_site->GetID(), bp_site->GetLoadAddress());
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_BREAKPOINTS);
+ LLDB_LOG(log, "bp_site = {0:x}, id={1}, addr={2:x}", bp_site,
+ bp_site->GetID(), bp_site->GetLoadAddress());
Error error = DisableSoftwareBreakpoint(bp_site);
- if (!error.Success()) {
- WINERR_IFALL(WINDOWS_LOG_BREAKPOINTS, "DisableBreakpointSite failed. %s",
- error.AsCString());
- }
+ if (!error.Success())
+ LLDB_LOG(log, "error: {0}", error);
return error;
}
Error ProcessWindows::DoDetach(bool keep_stopped) {
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
DebuggerThreadSP debugger_thread;
StateType private_state;
{
@@ -197,10 +194,8 @@ Error ProcessWindows::DoDetach(bool keep_stopped) {
private_state = GetPrivateState();
if (!m_session_data) {
- WINWARN_IFALL(
- WINDOWS_LOG_PROCESS,
- "DoDetach called while state = %u, but there is no active session.",
- private_state);
+ LLDB_LOG(log, "state = {0}, but there is no active session.",
+ private_state);
return Error();
}
@@ -209,11 +204,9 @@ Error ProcessWindows::DoDetach(bool keep_stopped) {
Error error;
if (private_state != eStateExited && private_state != eStateDetached) {
- WINLOG_IFALL(
- WINDOWS_LOG_PROCESS,
- "DoDetach called for process %p while state = %d. Detaching...",
- debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(),
- private_state);
+ LLDB_LOG(log, "detaching from process {0} while state = {1}.",
+ debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(),
+ private_state);
error = debugger_thread->StopDebugging(false);
if (error.Success()) {
SetPrivateState(eStateDetached);
@@ -223,9 +216,9 @@ Error ProcessWindows::DoDetach(bool keep_stopped) {
// we can be assured that no other thread will race for the session data.
m_session_data.reset();
} else {
- WINERR_IFALL(
- WINDOWS_LOG_PROCESS, "DoDetach called for process %p while state = "
- "%d, but cannot destroy in this state.",
+ LLDB_LOG(
+ log,
+ "error: process {0} in state = {1}, but cannot destroy in this state.",
debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(),
private_state);
}
@@ -241,6 +234,7 @@ Error ProcessWindows::DoLaunch(Module *exe_module,
// to acquire
// the mutex.
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
Error result;
if (!launch_info.GetFlags().Test(eLaunchFlagDebug)) {
StreamString stream;
@@ -250,7 +244,7 @@ Error ProcessWindows::DoLaunch(Module *exe_module,
std::string message = stream.GetString();
result.SetErrorString(message.c_str());
- WINERR_IFALL(WINDOWS_LOG_PROCESS, "%s", message.c_str());
+ LLDB_LOG(log, "error: {0}", message);
return result;
}
@@ -265,23 +259,21 @@ Error ProcessWindows::DoLaunch(Module *exe_module,
// Kick off the DebugLaunch asynchronously and wait for it to complete.
result = debugger->DebugLaunch(launch_info);
if (result.Fail()) {
- WINERR_IFALL(WINDOWS_LOG_PROCESS, "DoLaunch failed launching '%s'. %s",
- launch_info.GetExecutableFile().GetPath().c_str(),
- result.AsCString());
+ LLDB_LOG(log, "failed launching '{0}'. {1}",
+ launch_info.GetExecutableFile().GetPath(), result);
return result;
}
HostProcess process;
Error error = WaitForDebuggerConnection(debugger, process);
if (error.Fail()) {
- WINERR_IFALL(WINDOWS_LOG_PROCESS, "DoLaunch failed launching '%s'. %s",
- launch_info.GetExecutableFile().GetPath().c_str(),
- error.AsCString());
+ LLDB_LOG(log, "failed launching '{0}'. {1}",
+ launch_info.GetExecutableFile().GetPath(), error);
return error;
}
- WINLOG_IFALL(WINDOWS_LOG_PROCESS, "DoLaunch successfully launched '%s'",
- launch_info.GetExecutableFile().GetPath().c_str());
+ LLDB_LOG(log, "successfully launched '{0}'",
+ launch_info.GetExecutableFile().GetPath());
// We've hit the initial stop. If eLaunchFlagsStopAtEntry was specified, the
// private state
@@ -298,6 +290,7 @@ Error ProcessWindows::DoLaunch(Module *exe_module,
Error ProcessWindows::DoAttachToProcessWithID(
lldb::pid_t pid, const ProcessAttachInfo &attach_info) {
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
m_session_data.reset(
new ProcessWindowsData(!attach_info.GetContinueOnceAttached()));
@@ -309,27 +302,23 @@ Error ProcessWindows::DoAttachToProcessWithID(
DWORD process_id = static_cast<DWORD>(pid);
Error error = debugger->DebugAttach(process_id, attach_info);
if (error.Fail()) {
- WINLOG_IFALL(WINDOWS_LOG_PROCESS, "DoAttachToProcessWithID encountered an "
- "error occurred initiating the "
- "asynchronous attach. %s",
- error.AsCString());
+ LLDB_LOG(
+ log,
+ "encountered an error occurred initiating the asynchronous attach. {0}",
+ error);
return error;
}
HostProcess process;
error = WaitForDebuggerConnection(debugger, process);
if (error.Fail()) {
- WINLOG_IFALL(WINDOWS_LOG_PROCESS, "DoAttachToProcessWithID encountered an "
- "error waiting for the debugger to "
- "connect. %s",
- error.AsCString());
+ LLDB_LOG(log,
+ "encountered an error waiting for the debugger to connect. {0}",
+ error);
return error;
}
- WINLOG_IFALL(
- WINDOWS_LOG_PROCESS,
- "DoAttachToProcessWithID successfully attached to process with pid=%lu",
- process_id);
+ LLDB_LOG(log, "successfully attached to process with pid={0}", process_id);
// We've hit the initial stop. If eLaunchFlagsStopAtEntry was specified, the
// private state
@@ -343,16 +332,15 @@ Error ProcessWindows::DoAttachToProcessWithID(
}
Error ProcessWindows::DoResume() {
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
llvm::sys::ScopedLock lock(m_mutex);
Error error;
StateType private_state = GetPrivateState();
if (private_state == eStateStopped || private_state == eStateCrashed) {
- WINLOG_IFALL(
- WINDOWS_LOG_PROCESS,
- "DoResume called for process %I64u while state is %u. Resuming...",
- m_session_data->m_debugger->GetProcess().GetProcessId(),
- GetPrivateState());
+ LLDB_LOG(log, "process {0} is in state {1}. Resuming...",
+ m_session_data->m_debugger->GetProcess().GetProcessId(),
+ GetPrivateState());
ExceptionRecordSP active_exception =
m_session_data->m_debugger->GetActiveException().lock();
@@ -364,8 +352,7 @@ Error ProcessWindows::DoResume() {
ExceptionResult::MaskException);
}
- WINLOG_IFANY(WINDOWS_LOG_PROCESS | WINDOWS_LOG_THREAD,
- "DoResume resuming %u threads.", m_thread_list.GetSize());
+ LLDB_LOG(log, "resuming {0} threads.", m_thread_list.GetSize());
for (uint32_t i = 0; i < m_thread_list.GetSize(); ++i) {
auto thread = std::static_pointer_cast<TargetThreadWindows>(
@@ -375,16 +362,15 @@ Error ProcessWindows::DoResume() {
SetPrivateState(eStateRunning);
} else {
- WINERR_IFALL(
- WINDOWS_LOG_PROCESS,
- "DoResume called for process %I64u but state is %u. Returning...",
- m_session_data->m_debugger->GetProcess().GetProcessId(),
- GetPrivateState());
+ LLDB_LOG(log, "error: process %I64u is in state %u. Returning...",
+ m_session_data->m_debugger->GetProcess().GetProcessId(),
+ GetPrivateState());
}
return error;
}
Error ProcessWindows::DoDestroy() {
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
DebuggerThreadSP debugger_thread;
StateType private_state;
{
@@ -398,10 +384,8 @@ Error ProcessWindows::DoDestroy() {
private_state = GetPrivateState();
if (!m_session_data) {
- WINWARN_IFALL(
- WINDOWS_LOG_PROCESS,
- "DoDestroy called while state = %u, but there is no active session.",
- private_state);
+ LLDB_LOG(log, "warning: state = {0}, but there is no active session.",
+ private_state);
return Error();
}
@@ -410,28 +394,25 @@ Error ProcessWindows::DoDestroy() {
Error error;
if (private_state != eStateExited && private_state != eStateDetached) {
- WINLOG_IFALL(
- WINDOWS_LOG_PROCESS, "DoDestroy called for process %p while state = "
- "%u. Shutting down...",
- debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(),
- private_state);
+ LLDB_LOG(log, "Shutting down process {0} while state = {1}.",
+ debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(),
+ private_state);
error = debugger_thread->StopDebugging(true);
// By the time StopDebugging returns, there is no more debugger thread, so
// we can be assured that no other thread will race for the session data.
m_session_data.reset();
} else {
- WINERR_IFALL(
- WINDOWS_LOG_PROCESS, "DoDestroy called for process %p while state = "
- "%d, but cannot destroy in this state.",
- debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(),
- private_state);
+ LLDB_LOG(log, "cannot destroy process {0} while state = {1}",
+ debugger_thread->GetProcess().GetNativeProcess().GetSystemHandle(),
+ private_state);
}
return error;
}
Error ProcessWindows::DoHalt(bool &caused_stop) {
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
Error error;
StateType state = GetPrivateState();
if (state == eStateStopped)
@@ -443,10 +424,7 @@ Error ProcessWindows::DoHalt(bool &caused_stop) {
.GetSystemHandle());
if (!caused_stop) {
error.SetError(::GetLastError(), eErrorTypeWin32);
- WINERR_IFALL(
- WINDOWS_LOG_PROCESS,
- "DoHalt called DebugBreakProcess, but it failed with error %u",
- error.GetError());
+ LLDB_LOG(log, "DebugBreakProcess failed with error {0}", error);
}
}
return error;
@@ -468,12 +446,11 @@ void ProcessWindows::DidAttach(ArchSpec &arch_spec) {
}
void ProcessWindows::RefreshStateAfterStop() {
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EXCEPTION);
llvm::sys::ScopedLock lock(m_mutex);
if (!m_session_data) {
- WINWARN_IFALL(
- WINDOWS_LOG_PROCESS,
- "RefreshStateAfterStop called with no active session. Returning...");
+ LLDB_LOG(log, "no active session. Returning...");
return;
}
@@ -483,11 +460,9 @@ void ProcessWindows::RefreshStateAfterStop() {
m_session_data->m_debugger->GetActiveException();
ExceptionRecordSP active_exception = exception_record.lock();
if (!active_exception) {
- WINERR_IFALL(
- WINDOWS_LOG_PROCESS,
- "RefreshStateAfterStop called for process %I64u but there is no "
- "active exception. Why is the process stopped?",
- m_session_data->m_debugger->GetProcess().GetProcessId());
+ LLDB_LOG(log, "there is no active exception in process {0}. Why is the "
+ "process stopped?",
+ m_session_data->m_debugger->GetProcess().GetProcessId());
return;
}
@@ -503,19 +478,15 @@ void ProcessWindows::RefreshStateAfterStop() {
const uint64_t pc = register_context->GetPC();
BreakpointSiteSP site(GetBreakpointSiteList().FindByAddress(pc));
if (site && site->ValidForThisThread(stop_thread.get())) {
- WINLOG_IFANY(WINDOWS_LOG_BREAKPOINTS | WINDOWS_LOG_EXCEPTION |
- WINDOWS_LOG_STEP,
- "Single-stepped onto a breakpoint in process %I64u at "
- "address 0x%I64x with breakpoint site %d",
- m_session_data->m_debugger->GetProcess().GetProcessId(), pc,
- site->GetID());
+ LLDB_LOG(log, "Single-stepped onto a breakpoint in process {0} at "
+ "address {1:x} with breakpoint site {2}",
+ m_session_data->m_debugger->GetProcess().GetProcessId(), pc,
+ site->GetID());
stop_info = StopInfo::CreateStopReasonWithBreakpointSiteID(*stop_thread,
site->GetID());
stop_thread->SetStopInfo(stop_info);
} else {
- WINLOG_IFANY(WINDOWS_LOG_EXCEPTION | WINDOWS_LOG_STEP,
- "RefreshStateAfterStop single stepping thread %llu",
- stop_thread->GetID());
+ LLDB_LOG(log, "single stepping thread {0}", stop_thread->GetID());
stop_info = StopInfo::CreateStopReasonToTrace(*stop_thread);
stop_thread->SetStopInfo(stop_info);
}
@@ -530,37 +501,32 @@ void ProcessWindows::RefreshStateAfterStop() {
BreakpointSiteSP site(GetBreakpointSiteList().FindByAddress(pc));
if (site) {
- WINLOG_IFANY(
- WINDOWS_LOG_BREAKPOINTS | WINDOWS_LOG_EXCEPTION,
- "RefreshStateAfterStop detected breakpoint in process %I64u at "
- "address 0x%I64x with breakpoint site %d",
- m_session_data->m_debugger->GetProcess().GetProcessId(), pc,
- site->GetID());
+ LLDB_LOG(log, "detected breakpoint in process {0} at address {1:x} with "
+ "breakpoint site {2}",
+ m_session_data->m_debugger->GetProcess().GetProcessId(), pc,
+ site->GetID());
if (site->ValidForThisThread(stop_thread.get())) {
- WINLOG_IFALL(WINDOWS_LOG_BREAKPOINTS | WINDOWS_LOG_EXCEPTION,
- "Breakpoint site %d is valid for this thread (0x%I64x), "
- "creating stop info.",
- site->GetID(), stop_thread->GetID());
+ LLDB_LOG(log, "Breakpoint site {0} is valid for this thread ({1:x}), "
+ "creating stop info.",
+ site->GetID(), stop_thread->GetID());
stop_info = StopInfo::CreateStopReasonWithBreakpointSiteID(
*stop_thread, site->GetID());
register_context->SetPC(pc);
} else {
- WINLOG_IFALL(WINDOWS_LOG_BREAKPOINTS | WINDOWS_LOG_EXCEPTION,
- "Breakpoint site %d is not valid for this thread, "
- "creating empty stop info.",
- site->GetID());
+ LLDB_LOG(log, "Breakpoint site {0} is not valid for this thread, "
+ "creating empty stop info.",
+ site->GetID());
}
stop_thread->SetStopInfo(stop_info);
return;
} else {
// The thread hit a hard-coded breakpoint like an `int 3` or
// `__debugbreak()`.
- WINLOG_IFALL(
- WINDOWS_LOG_BREAKPOINTS | WINDOWS_LOG_EXCEPTION,
- "No breakpoint site matches for this thread. __debugbreak()? "
- "Creating stop info with the exception.");
+ LLDB_LOG(log,
+ "No breakpoint site matches for this thread. __debugbreak()? "
+ "Creating stop info with the exception.");
// FALLTHROUGH: We'll treat this as a generic exception record in the
// default case.
}
@@ -576,7 +542,7 @@ void ProcessWindows::RefreshStateAfterStop() {
stop_info = StopInfo::CreateStopReasonWithException(
*stop_thread, desc_stream.str().c_str());
stop_thread->SetStopInfo(stop_info);
- WINLOG_IFALL(WINDOWS_LOG_EXCEPTION, "%s", desc_stream.str().c_str());
+ LLDB_LOG(log, "{0}", desc_stream.str());
return;
}
}
@@ -598,6 +564,7 @@ bool ProcessWindows::CanDebug(lldb::TargetSP target_sp,
bool ProcessWindows::UpdateThreadList(ThreadList &old_thread_list,
ThreadList &new_thread_list) {
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_THREAD);
// Add all the threads that were previously running and for which we did not
// detect a thread exited event.
int new_size = 0;
@@ -613,15 +580,10 @@ bool ProcessWindows::UpdateThreadList(ThreadList &old_thread_list,
new_thread_list.AddThread(old_thread);
++new_size;
++continued_threads;
- WINLOGV_IFALL(
- WINDOWS_LOG_THREAD,
- "UpdateThreadList - Thread %llu was running and is still running.",
- old_thread_id);
+ LLDB_LOGV(log, "Thread {0} was running and is still running.",
+ old_thread_id);
} else {
- WINLOGV_IFALL(
- WINDOWS_LOG_THREAD,
- "UpdateThreadList - Thread %llu was running and has exited.",
- old_thread_id);
+ LLDB_LOGV(log, "Thread {0} was running and has exited.", old_thread_id);
++exited_threads;
}
}
@@ -634,15 +596,11 @@ bool ProcessWindows::UpdateThreadList(ThreadList &old_thread_list,
new_thread_list.AddThread(thread);
++new_size;
++new_threads;
- WINLOGV_IFALL(WINDOWS_LOG_THREAD,
- "UpdateThreadList - Thread %llu is new since last update.",
- thread_info.first);
+ LLDB_LOGV(log, "Thread {0} is new since last update.", thread_info.first);
}
- WINLOG_IFALL(
- WINDOWS_LOG_THREAD,
- "UpdateThreadList - %d new threads, %d old threads, %d exited threads.",
- new_threads, continued_threads, exited_threads);
+ LLDB_LOG(log, "{0} new threads, {1} old threads, {2} exited threads.",
+ new_threads, continued_threads, exited_threads);
m_session_data->m_new_threads.clear();
m_session_data->m_exited_threads.clear();
@@ -666,14 +624,14 @@ bool ProcessWindows::IsAlive() {
size_t ProcessWindows::DoReadMemory(lldb::addr_t vm_addr, void *buf,
size_t size, Error &error) {
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY);
llvm::sys::ScopedLock lock(m_mutex);
if (!m_session_data)
return 0;
- WINLOG_IFALL(WINDOWS_LOG_MEMORY,
- "DoReadMemory attempting to read %u bytes from address 0x%I64x",
- size, vm_addr);
+ LLDB_LOG(log, "attempting to read {0} bytes from address {1:x}", size,
+ vm_addr);
HostProcess process = m_session_data->m_debugger->GetProcess();
void *addr = reinterpret_cast<void *>(vm_addr);
@@ -681,24 +639,20 @@ size_t ProcessWindows::DoReadMemory(lldb::addr_t vm_addr, void *buf,
if (!ReadProcessMemory(process.GetNativeProcess().GetSystemHandle(), addr,
buf, size, &bytes_read)) {
error.SetError(GetLastError(), eErrorTypeWin32);
- WINERR_IFALL(WINDOWS_LOG_MEMORY, "DoReadMemory failed with error code %u",
- error.GetError());
+ LLDB_LOG(log, "reading failed with error: {0}", error);
}
return bytes_read;
}
size_t ProcessWindows::DoWriteMemory(lldb::addr_t vm_addr, const void *buf,
size_t size, Error &error) {
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY);
llvm::sys::ScopedLock lock(m_mutex);
- WINLOG_IFALL(
- WINDOWS_LOG_MEMORY,
- "DoWriteMemory attempting to write %u bytes into address 0x%I64x", size,
- vm_addr);
+ LLDB_LOG(log, "attempting to write {0} bytes into address {1:x}", size,
+ vm_addr);
if (!m_session_data) {
- WINERR_IFANY(
- WINDOWS_LOG_MEMORY,
- "DoWriteMemory cannot write, there is no active debugger connection.");
+ LLDB_LOG(log, "cannot write, there is no active debugger connection.");
return 0;
}
@@ -710,16 +664,14 @@ size_t ProcessWindows::DoWriteMemory(lldb::addr_t vm_addr, const void *buf,
FlushInstructionCache(handle, addr, bytes_written);
else {
error.SetError(GetLastError(), eErrorTypeWin32);
- WINLOG_IFALL(WINDOWS_LOG_MEMORY, "DoWriteMemory failed with error code %u",
- error.GetError());
+ LLDB_LOG(log, "writing failed with error: {0}", error);
}
return bytes_written;
}
-#define BOOL_STR(b) ((b) ? "true" : "false")
-
Error ProcessWindows::GetMemoryRegionInfo(lldb::addr_t vm_addr,
MemoryRegionInfo &info) {
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_MEMORY);
Error error;
llvm::sys::ScopedLock lock(m_mutex);
info.Clear();
@@ -727,7 +679,7 @@ Error ProcessWindows::GetMemoryRegionInfo(lldb::addr_t vm_addr,
if (!m_session_data) {
error.SetErrorString(
"GetMemoryRegionInfo called with no debugging session.");
- WINERR_IFALL(WINDOWS_LOG_MEMORY, "%s", error.AsCString());
+ LLDB_LOG(log, "error: {0}", error);
return error;
}
HostProcess process = m_session_data->m_debugger->GetProcess();
@@ -735,12 +687,11 @@ Error ProcessWindows::GetMemoryRegionInfo(lldb::addr_t vm_addr,
if (handle == nullptr || handle == LLDB_INVALID_PROCESS) {
error.SetErrorString(
"GetMemoryRegionInfo called with an invalid target process.");
- WINERR_IFALL(WINDOWS_LOG_MEMORY, "%s", error.AsCString());
+ LLDB_LOG(log, "error: {0}", error);
return error;
}
- WINLOG_IFALL(WINDOWS_LOG_MEMORY,
- "GetMemoryRegionInfo getting info for address 0x%I64x", vm_addr);
+ LLDB_LOG(log, "getting info for address {0:x}", vm_addr);
void *addr = reinterpret_cast<void *>(vm_addr);
MEMORY_BASIC_INFORMATION mem_info = {};
@@ -761,10 +712,9 @@ Error ProcessWindows::GetMemoryRegionInfo(lldb::addr_t vm_addr,
return error;
} else {
error.SetError(::GetLastError(), eErrorTypeWin32);
- WINERR_IFALL(WINDOWS_LOG_MEMORY, "VirtualQueryEx returned error %u while "
- "getting memory region info for address "
- "0x%I64x",
- error.GetError(), vm_addr);
+ LLDB_LOG(log, "VirtualQueryEx returned error {0} while getting memory "
+ "region info for address {1:x}",
+ error, vm_addr);
return error;
}
}
@@ -806,10 +756,10 @@ Error ProcessWindows::GetMemoryRegionInfo(lldb::addr_t vm_addr,
}
error.SetError(::GetLastError(), eErrorTypeWin32);
- WINLOGV_IFALL(WINDOWS_LOG_MEMORY, "Memory region info for address %llu: "
- "readable=%s, executable=%s, writable=%s",
- vm_addr, BOOL_STR(info.GetReadable()),
- BOOL_STR(info.GetExecutable()), BOOL_STR(info.GetWritable()));
+ LLDB_LOGV(log, "Memory region info for address {0}: readable={1}, "
+ "executable={2}, writable={3}",
+ vm_addr, info.GetReadable(), info.GetExecutable(),
+ info.GetWritable());
return error;
}
@@ -825,8 +775,8 @@ lldb::addr_t ProcessWindows::GetImageInfoAddress() {
void ProcessWindows::OnExitProcess(uint32_t exit_code) {
// No need to acquire the lock since m_session_data isn't accessed.
- WINLOG_IFALL(WINDOWS_LOG_PROCESS, "Process %llu exited with code %u", GetID(),
- exit_code);
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ LLDB_LOG(log, "Process {0} exited with code {1}", GetID(), exit_code);
TargetSP target = m_target_sp.lock();
if (target) {
@@ -842,10 +792,9 @@ void ProcessWindows::OnExitProcess(uint32_t exit_code) {
void ProcessWindows::OnDebuggerConnected(lldb::addr_t image_base) {
DebuggerThreadSP debugger = m_session_data->m_debugger;
-
- WINLOG_IFALL(WINDOWS_LOG_PROCESS,
- "Debugger connected to process %I64u. Image base = 0x%I64x",
- debugger->GetProcess().GetProcessId(), image_base);
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
+ LLDB_LOG(log, "Debugger connected to process {0}. Image base = {1:x}",
+ debugger->GetProcess().GetProcessId(), image_base);
ModuleSP module = GetTarget().GetExecutableModule();
if (!module) {
@@ -889,6 +838,7 @@ void ProcessWindows::OnDebuggerConnected(lldb::addr_t image_base) {
ExceptionResult
ProcessWindows::OnDebugException(bool first_chance,
const ExceptionRecord &record) {
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_EXCEPTION);
llvm::sys::ScopedLock lock(m_mutex);
// FIXME: Without this check, occasionally when running the test suite there
@@ -901,10 +851,9 @@ ProcessWindows::OnDebugException(bool first_chance,
// full
// lldb logs, and then add logging to the process plugin.
if (!m_session_data) {
- WINERR_IFANY(WINDOWS_LOG_EXCEPTION, "Debugger thread reported exception "
- "0x%lx at address 0x%llu, but there is "
- "no session.",
- record.GetExceptionCode(), record.GetExceptionAddress());
+ LLDB_LOG(log, "Debugger thread reported exception {0:x} at address {1:x}, "
+ "but there is no session.",
+ record.GetExceptionCode(), record.GetExceptionAddress());
return ExceptionResult::SendToApplication;
}
@@ -920,16 +869,15 @@ ProcessWindows::OnDebugException(bool first_chance,
result = ExceptionResult::BreakInDebugger;
if (!m_session_data->m_initial_stop_received) {
- WINLOG_IFANY(WINDOWS_LOG_BREAKPOINTS, "Hit loader breakpoint at address "
- "0x%I64x, setting initial stop "
- "event.",
- record.GetExceptionAddress());
+ LLDB_LOG(
+ log,
+ "Hit loader breakpoint at address {0:x}, setting initial stop event.",
+ record.GetExceptionAddress());
m_session_data->m_initial_stop_received = true;
::SetEvent(m_session_data->m_initial_stop_event);
} else {
- WINLOG_IFANY(WINDOWS_LOG_BREAKPOINTS,
- "Hit non-loader breakpoint at address 0x%I64x.",
- record.GetExceptionAddress());
+ LLDB_LOG(log, "Hit non-loader breakpoint at address {0:x}.",
+ record.GetExceptionAddress());
}
SetPrivateState(eStateStopped);
break;
@@ -938,11 +886,10 @@ ProcessWindows::OnDebugException(bool first_chance,
SetPrivateState(eStateStopped);
break;
default:
- WINLOG_IFANY(WINDOWS_LOG_EXCEPTION, "Debugger thread reported exception "
- "0x%lx at address 0x%llx "
- "(first_chance=%s)",
- record.GetExceptionCode(), record.GetExceptionAddress(),
- BOOL_STR(first_chance));
+ LLDB_LOG(log, "Debugger thread reported exception {0:x} at address {1:x} "
+ "(first_chance={2})",
+ record.GetExceptionCode(), record.GetExceptionAddress(),
+ first_chance);
// For non-breakpoints, give the application a chance to handle the
// exception first.
if (first_chance)
@@ -1010,14 +957,14 @@ void ProcessWindows::OnDebugString(const std::string &string) {}
void ProcessWindows::OnDebuggerError(const Error &error, uint32_t type) {
llvm::sys::ScopedLock lock(m_mutex);
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS);
if (m_session_data->m_initial_stop_received) {
// This happened while debugging. Do we shutdown the debugging session, try
- // to continue,
- // or do something else?
- WINERR_IFALL(WINDOWS_LOG_PROCESS, "Error %u occurred during debugging. "
- "Unexpected behavior may result. %s",
- error.GetError(), error.AsCString());
+ // to continue, or do something else?
+ LLDB_LOG(log, "Error {0} occurred during debugging. Unexpected behavior "
+ "may result. {1}",
+ error.GetError(), error);
} else {
// If we haven't actually launched the process yet, this was an error
// launching the
@@ -1026,10 +973,10 @@ void ProcessWindows::OnDebuggerError(const Error &error, uint32_t type) {
// method wakes up and returns a failure.
m_session_data->m_launch_error = error;
::SetEvent(m_session_data->m_initial_stop_event);
- WINERR_IFALL(
- WINDOWS_LOG_PROCESS,
- "Error %u occurred launching the process before the initial stop. %s",
- error.GetError(), error.AsCString());
+ LLDB_LOG(
+ log,
+ "Error {0} occurred launching the process before the initial stop. {1}",
+ error.GetError(), error);
return;
}
}
@@ -1037,14 +984,14 @@ void ProcessWindows::OnDebuggerError(const Error &error, uint32_t type) {
Error ProcessWindows::WaitForDebuggerConnection(DebuggerThreadSP debugger,
HostProcess &process) {
Error result;
- WINLOG_IFANY(WINDOWS_LOG_PROCESS | WINDOWS_LOG_BREAKPOINTS,
- "WaitForDebuggerConnection Waiting for loader breakpoint.");
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_PROCESS |
+ WINDOWS_LOG_BREAKPOINTS);
+ LLDB_LOG(log, "Waiting for loader breakpoint.");
// Block this function until we receive the initial stop from the process.
if (::WaitForSingleObject(m_session_data->m_initial_stop_event, INFINITE) ==
WAIT_OBJECT_0) {
- WINLOG_IFANY(WINDOWS_LOG_PROCESS | WINDOWS_LOG_BREAKPOINTS,
- "WaitForDebuggerConnection hit loader breakpoint, returning.");
+ LLDB_LOG(log, "hit loader breakpoint, returning.");
process = debugger->GetProcess();
return m_session_data->m_launch_error;
diff --git a/source/Plugins/Process/Windows/Common/ProcessWindows.h b/source/Plugins/Process/Windows/Common/ProcessWindows.h
index fac06c46b2ba..f2db102299ae 100644
--- a/source/Plugins/Process/Windows/Common/ProcessWindows.h
+++ b/source/Plugins/Process/Windows/Common/ProcessWindows.h
@@ -11,8 +11,8 @@
#define liblldb_Plugins_Process_Windows_Common_ProcessWindows_H_
// Other libraries and framework includes
-#include "lldb/Core/Error.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-forward.h"
#include "llvm/Support/Mutex.h"
diff --git a/source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp b/source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp
index 242c1996bdd4..386e9a5816c5 100644
--- a/source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp
+++ b/source/Plugins/Process/Windows/Common/ProcessWindowsLog.cpp
@@ -9,160 +9,33 @@
#include "ProcessWindowsLog.h"
-#include <mutex>
-
-#include "lldb/Core/StreamFile.h"
-#include "lldb/Interpreter/Args.h"
-#include "llvm/Support/ManagedStatic.h"
-
-using namespace lldb;
using namespace lldb_private;
-// We want to avoid global constructors where code needs to be run so here we
-// control access to our static g_log_sp by hiding it in a singleton function
-// that will construct the static g_log_sp the first time this function is
-// called.
-static bool g_log_enabled = false;
-static Log *g_log = nullptr;
+static constexpr Log::Category g_categories[] = {
+ {{"break"}, {"log breakpoints"}, WINDOWS_LOG_BREAKPOINTS},
+ {{"event"}, {"log low level debugger events"}, WINDOWS_LOG_EVENT},
+ {{"exception"}, {"log exception information"}, WINDOWS_LOG_EXCEPTION},
+ {{"memory"}, {"log memory reads and writes"}, WINDOWS_LOG_MEMORY},
+ {{"process"}, {"log process events and activities"}, WINDOWS_LOG_PROCESS},
+ {{"registers"}, {"log register read/writes"}, WINDOWS_LOG_REGISTERS},
+ {{"step"}, {"log step related activities"}, WINDOWS_LOG_STEP},
+ {{"thread"}, {"log thread events and activities"}, WINDOWS_LOG_THREAD},
+};
-static llvm::ManagedStatic<std::once_flag> g_once_flag;
+Log::Channel ProcessWindowsLog::g_channel(g_categories, WINDOWS_LOG_PROCESS);
void ProcessWindowsLog::Initialize() {
- static ConstString g_name("windows");
-
- std::call_once(*g_once_flag, []() {
- Log::Callbacks log_callbacks = {DisableLog, EnableLog, ListLogCategories};
-
- Log::RegisterLogChannel(g_name, log_callbacks);
- RegisterPluginName(g_name);
- });
+ static llvm::once_flag g_once_flag;
+ llvm::call_once(g_once_flag, []() { Log::Register("windows", g_channel); });
}
void ProcessWindowsLog::Terminate() {}
-Log *ProcessWindowsLog::GetLog() { return (g_log_enabled) ? g_log : nullptr; }
-bool ProcessWindowsLog::TestLogFlags(uint32_t mask, LogMaskReq req) {
- Log *log = GetLog();
- if (!log)
- return false;
- uint32_t log_mask = log->GetMask().Get();
- if (req == LogMaskReq::All)
- return ((log_mask & mask) == mask);
- else
- return (log_mask & mask);
-}
-
-static uint32_t GetFlagBits(const char *arg) {
- if (::strcasecmp(arg, "all") == 0)
- return WINDOWS_LOG_ALL;
- else if (::strcasecmp(arg, "break") == 0)
- return WINDOWS_LOG_BREAKPOINTS;
- else if (::strcasecmp(arg, "event") == 0)
- return WINDOWS_LOG_EVENT;
- else if (::strcasecmp(arg, "exception") == 0)
- return WINDOWS_LOG_EXCEPTION;
- else if (::strcasecmp(arg, "memory") == 0)
- return WINDOWS_LOG_MEMORY;
- else if (::strcasecmp(arg, "process") == 0)
- return WINDOWS_LOG_PROCESS;
- else if (::strcasecmp(arg, "registers") == 0)
- return WINDOWS_LOG_REGISTERS;
- else if (::strcasecmp(arg, "step") == 0)
- return WINDOWS_LOG_STEP;
- else if (::strcasecmp(arg, "thread") == 0)
- return WINDOWS_LOG_THREAD;
- else if (::strcasecmp(arg, "verbose") == 0)
- return WINDOWS_LOG_VERBOSE;
- return 0;
-}
-void ProcessWindowsLog::DisableLog(const char **args, Stream *feedback_strm) {
- Log *log(GetLog());
- if (log) {
- uint32_t flag_bits = 0;
- if (args[0] != nullptr) {
- flag_bits = log->GetMask().Get();
- for (; args[0]; args++) {
- const char *arg = args[0];
- uint32_t bits = GetFlagBits(arg);
- if (bits) {
- flag_bits &= ~bits;
- } else {
- feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
- ListLogCategories(feedback_strm);
- }
- }
- }
- log->GetMask().Reset(flag_bits);
- if (flag_bits == 0) {
- g_log_enabled = false;
- log->SetStream(lldb::StreamSP());
- }
- }
- return;
-}
-
-Log *ProcessWindowsLog::EnableLog(StreamSP &log_stream_sp, uint32_t log_options,
- const char **args, Stream *feedback_strm) {
- // Try see if there already is a log - that way we can reuse its settings.
- // We could reuse the log in toto, but we don't know that the stream is the
- // same.
- uint32_t flag_bits = 0;
- if (g_log)
- flag_bits = g_log->GetMask().Get();
-
- // Now make a new log with this stream if one was provided
- if (log_stream_sp) {
- if (g_log)
- g_log->SetStream(log_stream_sp);
- else
- g_log = new Log(log_stream_sp);
- }
-
- if (g_log) {
- bool got_unknown_category = false;
- for (; args[0]; args++) {
- const char *arg = args[0];
- uint32_t bits = GetFlagBits(arg);
-
- if (bits) {
- flag_bits |= bits;
- } else {
- feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
- if (got_unknown_category == false) {
- got_unknown_category = true;
- ListLogCategories(feedback_strm);
- }
- }
- }
- if (flag_bits == 0)
- flag_bits = WINDOWS_LOG_ALL;
- g_log->GetMask().Reset(flag_bits);
- g_log->GetOptions().Reset(log_options);
- g_log_enabled = true;
- }
- return g_log;
-}
-
-void ProcessWindowsLog::ListLogCategories(Stream *strm) {
- strm->Printf("Logging categories for '%s':\n"
- " all - turn on all available logging categories\n"
- " break - log breakpoints\n"
- " event - log low level debugger events\n"
- " exception - log exception information\n"
- " memory - log memory reads and writes\n"
- " process - log process events and activities\n"
- " registers - log register read/writes\n"
- " thread - log thread events and activities\n"
- " step - log step related activities\n"
- " verbose - enable verbose logging\n",
- ProcessWindowsLog::m_pluginname);
-}
-const char *ProcessWindowsLog::m_pluginname = "";
diff --git a/source/Plugins/Process/Windows/Common/ProcessWindowsLog.h b/source/Plugins/Process/Windows/Common/ProcessWindowsLog.h
index cbb99e8d907e..b7f59c708143 100644
--- a/source/Plugins/Process/Windows/Common/ProcessWindowsLog.h
+++ b/source/Plugins/Process/Windows/Common/ProcessWindowsLog.h
@@ -10,9 +10,8 @@
#ifndef liblldb_ProcessWindowsLog_h_
#define liblldb_ProcessWindowsLog_h_
-#include "lldb/Core/Log.h"
+#include "lldb/Utility/Log.h"
-#define WINDOWS_LOG_VERBOSE (1u << 0)
#define WINDOWS_LOG_PROCESS (1u << 1) // Log process operations
#define WINDOWS_LOG_EXCEPTION (1u << 1) // Log exceptions
#define WINDOWS_LOG_THREAD (1u << 2) // Log thread operations
@@ -21,71 +20,17 @@
#define WINDOWS_LOG_STEP (1u << 5) // Log step operations
#define WINDOWS_LOG_REGISTERS (1u << 6) // Log register operations
#define WINDOWS_LOG_EVENT (1u << 7) // Low level debug events
-#define WINDOWS_LOG_ALL (UINT32_MAX)
-
-enum class LogMaskReq { All, Any };
+namespace lldb_private {
class ProcessWindowsLog {
- static const char *m_pluginname;
+ static Log::Channel g_channel;
public:
- // ---------------------------------------------------------------------
- // Public Static Methods
- // ---------------------------------------------------------------------
static void Initialize();
-
static void Terminate();
- static void RegisterPluginName(const char *pluginName) {
- m_pluginname = pluginName;
- }
-
- static void RegisterPluginName(lldb_private::ConstString pluginName) {
- m_pluginname = pluginName.GetCString();
- }
-
- static bool TestLogFlags(uint32_t mask, LogMaskReq req);
-
- static lldb_private::Log *GetLog();
-
- static void DisableLog(const char **args,
- lldb_private::Stream *feedback_strm);
-
- static lldb_private::Log *EnableLog(lldb::StreamSP &log_stream_sp,
- uint32_t log_options, const char **args,
- lldb_private::Stream *feedback_strm);
-
- static void ListLogCategories(lldb_private::Stream *strm);
+ static Log *GetLogIfAny(uint32_t mask) { return g_channel.GetLogIfAny(mask); }
};
-
-#define WINLOGF_IF(Flags, Req, Method, ...) \
- { \
- if (ProcessWindowsLog::TestLogFlags(Flags, Req)) { \
- Log *log = ProcessWindowsLog::GetLog(); \
- if (log) \
- log->Method(__VA_ARGS__); \
- } \
- }
-
-#define WINLOG_IFANY(Flags, ...) \
- WINLOGF_IF(Flags, LogMaskReq::Any, Printf, __VA_ARGS__)
-#define WINLOG_IFALL(Flags, ...) \
- WINLOGF_IF(Flags, LogMaskReq::All, Printf, __VA_ARGS__)
-#define WINLOGV_IFANY(Flags, ...) \
- WINLOGF_IF(Flags, LogMaskReq::Any, Verbose, __VA_ARGS__)
-#define WINLOGV_IFALL(Flags, ...) \
- WINLOGF_IF(Flags, LogMaskReq::All, Verbose, __VA_ARGS__)
-#define WINLOGD_IFANY(Flags, ...) \
- WINLOGF_IF(Flags, LogMaskReq::Any, Debug, __VA_ARGS__)
-#define WINLOGD_IFALL(Flags, ...) \
- WINLOGF_IF(Flags, LogMaskReq::All, Debug, __VA_ARGS__)
-#define WINERR_IFANY(Flags, ...) \
- WINLOGF_IF(Flags, LogMaskReq::Any, Error, __VA_ARGS__)
-#define WINERR_IFALL(Flags, ...) \
- WINLOGF_IF(Flags, LogMaskReq::All, Error, __VA_ARGS__)
-#define WINWARN_IFANY(Flags, ...) \
- WINLOGF_IF(Flags, LogMaskReq::Any, Warning, __VA_ARGS__)
-#define WINWARN_IFALL(Flags, ...) \
- WINLOGF_IF(Flags, LogMaskReq::All, Warning, __VA_ARGS__)
+}
#endif // liblldb_ProcessWindowsLog_h_
diff --git a/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp b/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
index 0ef3c77e47c1..bfed3044910d 100644
--- a/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
+++ b/source/Plugins/Process/Windows/Common/RegisterContextWindows.cpp
@@ -7,10 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Error.h"
#include "lldb/Host/windows/HostThreadWindows.h"
#include "lldb/Host/windows/windows.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-private-types.h"
#include "ProcessWindowsLog.h"
@@ -113,6 +113,7 @@ bool RegisterContextWindows::ClearHardwareWatchpoint(uint32_t hw_index) {
bool RegisterContextWindows::HardwareSingleStep(bool enable) { return false; }
bool RegisterContextWindows::CacheAllRegisterValues() {
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
if (!m_context_stale)
return true;
@@ -122,14 +123,13 @@ bool RegisterContextWindows::CacheAllRegisterValues() {
if (!::GetThreadContext(
wthread.GetHostThread().GetNativeThread().GetSystemHandle(),
&m_context)) {
- WINERR_IFALL(
- WINDOWS_LOG_REGISTERS,
- "GetThreadContext failed with error %lu while caching register values.",
+ LLDB_LOG(
+ log,
+ "GetThreadContext failed with error {0} while caching register values.",
::GetLastError());
return false;
}
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS,
- "GetThreadContext successfully updated the register values.");
+ LLDB_LOG(log, "successfully updated the register values.");
m_context_stale = false;
return true;
}
diff --git a/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp b/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
index 8f2603c3365b..a4d60303877e 100644
--- a/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
+++ b/source/Plugins/Process/Windows/Common/TargetThreadWindows.cpp
@@ -7,14 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Logging.h"
#include "lldb/Core/State.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/HostNativeThreadBase.h"
#include "lldb/Host/windows/HostThreadWindows.h"
#include "lldb/Host/windows/windows.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Logging.h"
#include "ProcessWindows.h"
#include "ProcessWindowsLog.h"
diff --git a/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp b/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
index 942b4e97c40d..53fe1d902494 100644
--- a/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
+++ b/source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
@@ -7,10 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/Error.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Host/windows/HostThreadWindows.h"
#include "lldb/Host/windows/windows.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-private-types.h"
#include "RegisterContextWindows_x64.h"
diff --git a/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp b/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
index 2938f77f3c2a..8127606583cd 100644
--- a/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
+++ b/source/Plugins/Process/Windows/Common/x86/RegisterContextWindows_x86.cpp
@@ -7,10 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/Error.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Host/windows/HostThreadWindows.h"
#include "lldb/Host/windows/windows.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-private-types.h"
#include "ProcessWindowsLog.h"
@@ -203,7 +203,8 @@ bool RegisterContextWindows_x86::ReadRegister(const RegisterInfo *reg_info,
return ReadRegisterHelper(CONTEXT_CONTROL, "EFLAGS", m_context.EFlags,
reg_value);
default:
- WINWARN_IFALL(WINDOWS_LOG_REGISTERS, "Requested unknown register %u", reg);
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
+ LLDB_LOG(log, "Requested unknown register {0}", reg);
break;
}
return false;
@@ -219,62 +220,52 @@ bool RegisterContextWindows_x86::WriteRegister(const RegisterInfo *reg_info,
if (!CacheAllRegisterValues())
return false;
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
switch (reg) {
case lldb_eax_i386:
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EAX",
- reg_value.GetAsUInt32());
+ LLDB_LOG(log, "Write value {0:x} to EAX", reg_value.GetAsUInt32());
m_context.Eax = reg_value.GetAsUInt32();
break;
case lldb_ebx_i386:
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EBX",
- reg_value.GetAsUInt32());
+ LLDB_LOG(log, "Write value {0:x} to EBX", reg_value.GetAsUInt32());
m_context.Ebx = reg_value.GetAsUInt32();
break;
case lldb_ecx_i386:
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to ECX",
- reg_value.GetAsUInt32());
+ LLDB_LOG(log, "Write value {0:x} to ECX", reg_value.GetAsUInt32());
m_context.Ecx = reg_value.GetAsUInt32();
break;
case lldb_edx_i386:
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EDX",
- reg_value.GetAsUInt32());
+ LLDB_LOG(log, "Write value {0:x} to EDX", reg_value.GetAsUInt32());
m_context.Edx = reg_value.GetAsUInt32();
break;
case lldb_edi_i386:
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EDI",
- reg_value.GetAsUInt32());
+ LLDB_LOG(log, "Write value {0:x} to EDI", reg_value.GetAsUInt32());
m_context.Edi = reg_value.GetAsUInt32();
break;
case lldb_esi_i386:
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to ESI",
- reg_value.GetAsUInt32());
+ LLDB_LOG(log, "Write value {0:x} to ESI", reg_value.GetAsUInt32());
m_context.Esi = reg_value.GetAsUInt32();
break;
case lldb_ebp_i386:
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EBP",
- reg_value.GetAsUInt32());
+ LLDB_LOG(log, "Write value {0:x} to EBP", reg_value.GetAsUInt32());
m_context.Ebp = reg_value.GetAsUInt32();
break;
case lldb_esp_i386:
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to ESP",
- reg_value.GetAsUInt32());
+ LLDB_LOG(log, "Write value {0:x} to ESP", reg_value.GetAsUInt32());
m_context.Esp = reg_value.GetAsUInt32();
break;
case lldb_eip_i386:
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EIP",
- reg_value.GetAsUInt32());
+ LLDB_LOG(log, "Write value {0:x} to EIP", reg_value.GetAsUInt32());
m_context.Eip = reg_value.GetAsUInt32();
break;
case lldb_eflags_i386:
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Write value 0x%x to EFLAGS",
- reg_value.GetAsUInt32());
+ LLDB_LOG(log, "Write value {0:x} to EFLAGS", reg_value.GetAsUInt32());
m_context.EFlags = reg_value.GetAsUInt32();
break;
default:
- WINWARN_IFALL(WINDOWS_LOG_REGISTERS,
- "Write value 0x%x to unknown register %u",
- reg_value.GetAsUInt32(), reg);
+ LLDB_LOG(log, "Write value {0:x} to unknown register {1}",
+ reg_value.GetAsUInt32(), reg);
}
// Physically update the registers in the target process.
@@ -286,13 +277,12 @@ bool RegisterContextWindows_x86::WriteRegister(const RegisterInfo *reg_info,
bool RegisterContextWindows_x86::ReadRegisterHelper(
DWORD flags_required, const char *reg_name, DWORD value,
RegisterValue &reg_value) const {
+ Log *log = ProcessWindowsLog::GetLogIfAny(WINDOWS_LOG_REGISTERS);
if ((m_context.ContextFlags & flags_required) != flags_required) {
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Thread context doesn't have %s",
- reg_name);
+ LLDB_LOG(log, "Thread context doesn't have {0}", reg_name);
return false;
}
- WINLOG_IFALL(WINDOWS_LOG_REGISTERS, "Read value 0x%lx from %s", value,
- reg_name);
+ LLDB_LOG(log, "Read value {0:x} from {1}", value, reg_name);
reg_value.SetUInt32(value);
return true;
}
diff --git a/source/Plugins/Process/elf-core/CMakeLists.txt b/source/Plugins/Process/elf-core/CMakeLists.txt
index b9f0b6cdfb7c..b358697d25af 100644
--- a/source/Plugins/Process/elf-core/CMakeLists.txt
+++ b/source/Plugins/Process/elf-core/CMakeLists.txt
@@ -1,6 +1,6 @@
include_directories(../Utility)
-add_lldb_library(lldbPluginProcessElfCore
+add_lldb_library(lldbPluginProcessElfCore PLUGIN
ProcessElfCore.cpp
ThreadElfCore.cpp
RegisterContextPOSIXCore_arm.cpp
@@ -9,4 +9,13 @@ add_lldb_library(lldbPluginProcessElfCore
RegisterContextPOSIXCore_powerpc.cpp
RegisterContextPOSIXCore_s390x.cpp
RegisterContextPOSIXCore_x86_64.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbTarget
+ lldbPluginDynamicLoaderPosixDYLD
+ lldbPluginObjectFileELF
+ lldbPluginProcessUtility
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 6ac308fe559c..6561d2a05828 100644
--- a/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -14,8 +14,6 @@
#include <mutex>
// Other libraries and framework includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
@@ -25,8 +23,12 @@
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/UnixSignals.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataBufferLLVM.h"
+#include "lldb/Utility/Log.h"
#include "llvm/Support/ELF.h"
+#include "llvm/Support/Threading.h"
#include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
@@ -56,9 +58,12 @@ lldb::ProcessSP ProcessElfCore::CreateInstance(lldb::TargetSP target_sp,
lldb::ProcessSP process_sp;
if (crash_file) {
// Read enough data for a ELF32 header or ELF64 header
+ // Note: Here we care about e_type field only, so it is safe
+ // to ignore possible presence of the header extension.
const size_t header_size = sizeof(llvm::ELF::Elf64_Ehdr);
- lldb::DataBufferSP data_sp(crash_file->ReadFileContents(0, header_size));
+ auto data_sp = DataBufferLLVM::CreateSliceFromPath(crash_file->GetPath(),
+ header_size, 0);
if (data_sp && data_sp->GetByteSize() == header_size &&
elf::ELFHeader::MagicBytesMatch(data_sp->GetBytes())) {
elf::ELFHeader elf_header;
@@ -209,16 +214,19 @@ Error ProcessElfCore::DoLoadCore() {
// Even if the architecture is set in the target, we need to override
// it to match the core file which is always single arch.
ArchSpec arch(m_core_module_sp->GetArchitecture());
- if (arch.IsValid())
- GetTarget().SetArchitecture(arch);
+ ArchSpec target_arch = GetTarget().GetArchitecture();
+ ArchSpec core_arch(m_core_module_sp->GetArchitecture());
+ target_arch.MergeFrom(core_arch);
+ GetTarget().SetArchitecture(target_arch);
+
SetUnixSignals(UnixSignals::Create(GetArchitecture()));
// Ensure we found at least one thread that was stopped on a signal.
bool siginfo_signal_found = false;
bool prstatus_signal_found = false;
// Check we found a signal in a SIGINFO note.
- for (const auto &thread_data: m_thread_data) {
+ for (const auto &thread_data : m_thread_data) {
if (thread_data.signo != 0)
siginfo_signal_found = true;
if (thread_data.prstatus_sig != 0)
@@ -228,7 +236,7 @@ Error ProcessElfCore::DoLoadCore() {
// If we don't have signal from SIGINFO use the signal from each threads
// PRSTATUS note.
if (prstatus_signal_found) {
- for (auto &thread_data: m_thread_data)
+ for (auto &thread_data : m_thread_data)
thread_data.signo = thread_data.prstatus_sig;
} else if (m_thread_data.size() > 0) {
// If all else fails force the first thread to be SIGSTOP
@@ -365,6 +373,10 @@ size_t ProcessElfCore::DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
lldb::addr_t bytes_left =
0; // Number of bytes available in the core file from the given address
+ // Don't proceed if core file doesn't contain the actual data for this address range.
+ if (file_start == file_end)
+ return 0;
+
// Figure out how many on-disk bytes remain in this segment
// starting at the given offset
if (file_end > file_start + offset)
@@ -398,9 +410,9 @@ void ProcessElfCore::Clear() {
}
void ProcessElfCore::Initialize() {
- static std::once_flag g_once_flag;
+ static llvm::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
+ llvm::call_once(g_once_flag, []() {
PluginManager::RegisterPlugin(GetPluginNameStatic(),
GetPluginDescriptionStatic(), CreateInstance);
});
@@ -426,6 +438,10 @@ enum {
NT_FILE = 0x46494c45,
NT_PRXFPREG = 0x46e62b7f,
NT_SIGINFO = 0x53494749,
+ NT_OPENBSD_PROCINFO = 10,
+ NT_OPENBSD_AUXV = 11,
+ NT_OPENBSD_REGS = 20,
+ NT_OPENBSD_FPREGS = 21,
};
namespace FREEBSD {
@@ -440,6 +456,11 @@ enum {
};
}
+namespace NETBSD {
+
+enum { NT_PROCINFO = 1, NT_AUXV, NT_AMD64_REGS = 33, NT_AMD64_FPREGS = 35 };
+}
+
// Parse a FreeBSD NT_PRSTATUS note - see FreeBSD sys/procfs.h for details.
static void ParseFreeBSDPrStatus(ThreadData &thread_data, DataExtractor &data,
ArchSpec &arch) {
@@ -476,6 +497,28 @@ static void ParseFreeBSDThrMisc(ThreadData &thread_data, DataExtractor &data) {
thread_data.name = data.GetCStr(&offset, 20);
}
+static void ParseNetBSDProcInfo(ThreadData &thread_data, DataExtractor &data) {
+ lldb::offset_t offset = 0;
+
+ int version = data.GetU32(&offset);
+ if (version != 1)
+ return;
+
+ offset += 4;
+ thread_data.signo = data.GetU32(&offset);
+}
+
+static void ParseOpenBSDProcInfo(ThreadData &thread_data, DataExtractor &data) {
+ lldb::offset_t offset = 0;
+
+ int version = data.GetU32(&offset);
+ if (version != 1)
+ return;
+
+ offset += 4;
+ thread_data.signo = data.GetU32(&offset);
+}
+
/// Parse Thread context from PT_NOTE segment and store it in the thread list
/// Notes:
/// 1) A PT_NOTE segment is composed of one or more NOTE entries.
@@ -564,6 +607,39 @@ Error ProcessElfCore::ParseThreadContextsFromNoteSegment(
default:
break;
}
+ } else if (note.n_name.substr(0, 11) == "NetBSD-CORE") {
+ // NetBSD per-thread information is stored in notes named
+ // "NetBSD-CORE@nnn" so match on the initial part of the string.
+ m_os = llvm::Triple::NetBSD;
+ if (note.n_type == NETBSD::NT_PROCINFO) {
+ ParseNetBSDProcInfo(*thread_data, note_data);
+ } else if (note.n_type == NETBSD::NT_AUXV) {
+ m_auxv = DataExtractor(note_data);
+ } else if (arch.GetMachine() == llvm::Triple::x86_64 &&
+ note.n_type == NETBSD::NT_AMD64_REGS) {
+ thread_data->gpregset = note_data;
+ } else if (arch.GetMachine() == llvm::Triple::x86_64 &&
+ note.n_type == NETBSD::NT_AMD64_FPREGS) {
+ thread_data->fpregset = note_data;
+ }
+ } else if (note.n_name.substr(0, 7) == "OpenBSD") {
+ // OpenBSD per-thread information is stored in notes named
+ // "OpenBSD@nnn" so match on the initial part of the string.
+ m_os = llvm::Triple::OpenBSD;
+ switch (note.n_type) {
+ case NT_OPENBSD_PROCINFO:
+ ParseOpenBSDProcInfo(*thread_data, note_data);
+ break;
+ case NT_OPENBSD_AUXV:
+ m_auxv = DataExtractor(note_data);
+ break;
+ case NT_OPENBSD_REGS:
+ thread_data->gpregset = note_data;
+ break;
+ case NT_OPENBSD_FPREGS:
+ thread_data->fpregset = note_data;
+ break;
+ }
} else if (note.n_name == "CORE") {
switch (note.n_type) {
case NT_PRSTATUS:
@@ -583,6 +659,8 @@ Error ProcessElfCore::ParseThreadContextsFromNoteSegment(
// The result from FXSAVE is in NT_PRXFPREG for i386 core files
if (arch.GetCore() == ArchSpec::eCore_x86_64_x86_64)
thread_data->fpregset = note_data;
+ else if(arch.IsMIPS())
+ thread_data->fpregset = note_data;
break;
case NT_PRPSINFO:
have_prpsinfo = true;
@@ -650,6 +728,12 @@ ArchSpec ProcessElfCore::GetArchitecture() {
(ObjectFileELF *)(m_core_module_sp->GetObjectFile());
ArchSpec arch;
core_file->GetArchitecture(arch);
+
+ ArchSpec target_arch = GetTarget().GetArchitecture();
+
+ if (target_arch.IsMIPS())
+ return target_arch;
+
return arch;
}
diff --git a/source/Plugins/Process/elf-core/ProcessElfCore.h b/source/Plugins/Process/elf-core/ProcessElfCore.h
index a8dde47b3079..cb2f31bde4c5 100644
--- a/source/Plugins/Process/elf-core/ProcessElfCore.h
+++ b/source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -24,9 +24,9 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
#include "Plugins/ObjectFile/ELF/ELFHeader.h"
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h
index c0850e5e414e..e095eac5eaf8 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h
@@ -15,8 +15,8 @@
// Other libraries and framework includes
// Project includes
#include "Plugins/Process/Utility/RegisterContextPOSIX_arm.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
class RegisterContextCorePOSIX_arm : public RegisterContextPOSIX_arm {
public:
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
index da3e5bff605c..3a2bbdb0a2eb 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
@@ -15,8 +15,8 @@
// Other libraries and framework includes
// Project includes
#include "Plugins/Process/Utility/RegisterContextPOSIX_arm64.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
class RegisterContextCorePOSIX_arm64 : public RegisterContextPOSIX_arm64 {
public:
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp
index 6a168d314fd7..7549cf074be7 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp
@@ -22,6 +22,10 @@ RegisterContextCorePOSIX_mips64::RegisterContextCorePOSIX_mips64(
new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
m_gpr.SetData(m_gpr_buffer);
m_gpr.SetByteOrder(gpregset.GetByteOrder());
+ m_fpr_buffer.reset(
+ new DataBufferHeap(fpregset.GetDataStart(), fpregset.GetByteSize()));
+ m_fpr.SetData(m_fpr_buffer);
+ m_fpr.SetByteOrder(fpregset.GetByteOrder());
}
RegisterContextCorePOSIX_mips64::~RegisterContextCorePOSIX_mips64() {}
@@ -42,12 +46,24 @@ bool RegisterContextCorePOSIX_mips64::WriteFPR() {
bool RegisterContextCorePOSIX_mips64::ReadRegister(const RegisterInfo *reg_info,
RegisterValue &value) {
+
lldb::offset_t offset = reg_info->byte_offset;
- uint64_t v = m_gpr.GetMaxU64(&offset, reg_info->byte_size);
- if (offset == reg_info->byte_offset + reg_info->byte_size) {
+ lldb_private::ArchSpec arch = m_register_info_ap->GetTargetArchitecture();
+ uint64_t v;
+ if (IsGPR(reg_info->kinds[lldb::eRegisterKindLLDB])) {
+ if (reg_info->byte_size == 4 && !(arch.GetMachine() == llvm::Triple::mips64el))
+ // In case of 32bit core file, the register data are placed at 4 byte
+ // offset.
+ offset = offset / 2;
+ v = m_gpr.GetMaxU64(&offset, reg_info->byte_size);
value = v;
return true;
- }
+ } else if (IsFPR(reg_info->kinds[lldb::eRegisterKindLLDB])) {
+ offset = offset - sizeof(GPR_linux_mips);
+ v =m_fpr.GetMaxU64(&offset, reg_info->byte_size);
+ value = v;
+ return true;
+ }
return false;
}
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h
index b1deca3d3178..2cb527a8de7c 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h
@@ -15,8 +15,8 @@
// Other libraries and framework includes
// Project includes
#include "Plugins/Process/Utility/RegisterContextPOSIX_mips64.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
class RegisterContextCorePOSIX_mips64 : public RegisterContextPOSIX_mips64 {
public:
@@ -51,7 +51,9 @@ protected:
private:
lldb::DataBufferSP m_gpr_buffer;
+ lldb::DataBufferSP m_fpr_buffer;
lldb_private::DataExtractor m_gpr;
+ lldb_private::DataExtractor m_fpr;
};
#endif // liblldb_RegisterContextCorePOSIX_mips64_h_
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp
index edfa1902c327..62f6413722f7 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp
@@ -9,9 +9,9 @@
#include "RegisterContextPOSIXCore_powerpc.h"
-#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
using namespace lldb_private;
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h
index 8e6315f06636..aaa95e5d2397 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h
@@ -15,7 +15,7 @@
// Other libraries and framework includes
// Project includes
#include "Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h"
-#include "lldb/Core/DataExtractor.h"
+#include "lldb/Utility/DataExtractor.h"
class RegisterContextCorePOSIX_powerpc : public RegisterContextPOSIX_powerpc {
public:
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp
index 6db817789612..b3530a8d6a42 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp
@@ -9,9 +9,9 @@
#include "RegisterContextPOSIXCore_s390x.h"
-#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
using namespace lldb_private;
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h
index 516e5c57e2b9..2b4ae10a87bd 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h
@@ -15,7 +15,7 @@
// Other libraries and framework includes
// Project includes
#include "Plugins/Process/Utility/RegisterContextPOSIX_s390x.h"
-#include "lldb/Core/DataExtractor.h"
+#include "lldb/Utility/DataExtractor.h"
class RegisterContextCorePOSIX_s390x : public RegisterContextPOSIX_s390x {
public:
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
index 7f8223f7752e..260ae15d7a54 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
@@ -8,9 +8,9 @@
//===----------------------------------------------------------------------===//
#include "RegisterContextPOSIXCore_x86_64.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataExtractor.h"
using namespace lldb_private;
diff --git a/source/Plugins/Process/elf-core/ThreadElfCore.cpp b/source/Plugins/Process/elf-core/ThreadElfCore.cpp
index bdf0c69bef24..13ad82d92c5d 100644
--- a/source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ b/source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -7,22 +7,26 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Log.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Unwind.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Log.h"
-#include "Plugins/Process/Utility/RegisterContextFreeBSD_arm.h"
#include "Plugins/Process/Utility/RegisterContextFreeBSD_i386.h"
#include "Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h"
#include "Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h"
#include "Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h"
-#include "Plugins/Process/Utility/RegisterContextLinux_arm.h"
+#include "Plugins/Process/Utility/RegisterContextLinux_mips64.h"
+#include "Plugins/Process/Utility/RegisterContextLinux_mips.h"
#include "Plugins/Process/Utility/RegisterContextLinux_i386.h"
#include "Plugins/Process/Utility/RegisterContextLinux_s390x.h"
#include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h"
+#include "Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h"
+#include "Plugins/Process/Utility/RegisterContextOpenBSD_i386.h"
+#include "Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h"
+#include "Plugins/Process/Utility/RegisterInfoPOSIX_arm.h"
#include "Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h"
#include "ProcessElfCore.h"
#include "RegisterContextPOSIXCore_arm.h"
@@ -88,7 +92,7 @@ ThreadElfCore::CreateRegisterContextForFrame(StackFrame *frame) {
reg_interface = new RegisterInfoPOSIX_arm64(arch);
break;
case llvm::Triple::arm:
- reg_interface = new RegisterContextFreeBSD_arm(arch);
+ reg_interface = new RegisterInfoPOSIX_arm(arch);
break;
case llvm::Triple::ppc:
reg_interface = new RegisterContextFreeBSD_powerpc32(arch);
@@ -111,14 +115,33 @@ ThreadElfCore::CreateRegisterContextForFrame(StackFrame *frame) {
break;
}
+ case llvm::Triple::NetBSD: {
+ switch (arch.GetMachine()) {
+ case llvm::Triple::x86_64:
+ reg_interface = new RegisterContextNetBSD_x86_64(arch);
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+
case llvm::Triple::Linux: {
switch (arch.GetMachine()) {
case llvm::Triple::arm:
- reg_interface = new RegisterContextLinux_arm(arch);
+ reg_interface = new RegisterInfoPOSIX_arm(arch);
break;
case llvm::Triple::aarch64:
reg_interface = new RegisterInfoPOSIX_arm64(arch);
break;
+ case llvm::Triple::mipsel:
+ case llvm::Triple::mips:
+ reg_interface = new RegisterContextLinux_mips(arch);
+ break;
+ case llvm::Triple::mips64el:
+ case llvm::Triple::mips64:
+ reg_interface = new RegisterContextLinux_mips64(arch);
+ break;
case llvm::Triple::systemz:
reg_interface = new RegisterContextLinux_s390x(arch);
break;
@@ -134,6 +157,26 @@ ThreadElfCore::CreateRegisterContextForFrame(StackFrame *frame) {
break;
}
+ case llvm::Triple::OpenBSD: {
+ switch (arch.GetMachine()) {
+ case llvm::Triple::aarch64:
+ reg_interface = new RegisterInfoPOSIX_arm64(arch);
+ break;
+ case llvm::Triple::arm:
+ reg_interface = new RegisterInfoPOSIX_arm(arch);
+ break;
+ case llvm::Triple::x86:
+ reg_interface = new RegisterContextOpenBSD_i386(arch);
+ break;
+ case llvm::Triple::x86_64:
+ reg_interface = new RegisterContextOpenBSD_x86_64(arch);
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+
default:
break;
}
@@ -154,7 +197,13 @@ ThreadElfCore::CreateRegisterContextForFrame(StackFrame *frame) {
m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_arm(
*this, reg_interface, m_gpregset_data, m_fpregset_data));
break;
+ case llvm::Triple::mipsel:
+ case llvm::Triple::mips:
+ m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_mips64(
+ *this, reg_interface, m_gpregset_data, m_fpregset_data));
+ break;
case llvm::Triple::mips64:
+ case llvm::Triple::mips64el:
m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_mips64(
*this, reg_interface, m_gpregset_data, m_fpregset_data));
break;
@@ -200,6 +249,31 @@ ELFLinuxPrStatus::ELFLinuxPrStatus() {
memset(this, 0, sizeof(ELFLinuxPrStatus));
}
+size_t ELFLinuxPrStatus::GetSize(lldb_private::ArchSpec &arch) {
+ constexpr size_t mips_linux_pr_status_size_o32 = 96;
+ constexpr size_t mips_linux_pr_status_size_n32 = 72;
+ if (arch.IsMIPS()) {
+ std::string abi = arch.GetTargetABI();
+ assert(!abi.empty() && "ABI is not set");
+ if (!abi.compare("n64"))
+ return sizeof(ELFLinuxPrStatus);
+ else if (!abi.compare("o32"))
+ return mips_linux_pr_status_size_o32;
+ // N32 ABI
+ return mips_linux_pr_status_size_n32;
+ }
+ switch (arch.GetCore()) {
+ case lldb_private::ArchSpec::eCore_s390x_generic:
+ case lldb_private::ArchSpec::eCore_x86_64_x86_64:
+ return sizeof(ELFLinuxPrStatus);
+ case lldb_private::ArchSpec::eCore_x86_32_i386:
+ case lldb_private::ArchSpec::eCore_x86_32_i486:
+ return 72;
+ default:
+ return 0;
+ }
+}
+
Error ELFLinuxPrStatus::Parse(DataExtractor &data, ArchSpec &arch) {
Error error;
if (GetSize(arch) > data.GetByteSize()) {
@@ -239,7 +313,6 @@ Error ELFLinuxPrStatus::Parse(DataExtractor &data, ArchSpec &arch) {
pr_cstime.tv_sec = data.GetPointer(&offset);
pr_cstime.tv_usec = data.GetPointer(&offset);
-
return error;
}
@@ -250,6 +323,27 @@ ELFLinuxPrPsInfo::ELFLinuxPrPsInfo() {
memset(this, 0, sizeof(ELFLinuxPrPsInfo));
}
+size_t ELFLinuxPrPsInfo::GetSize(lldb_private::ArchSpec &arch) {
+ constexpr size_t mips_linux_pr_psinfo_size_o32_n32 = 128;
+ if (arch.IsMIPS()) {
+ uint8_t address_byte_size = arch.GetAddressByteSize();
+ if (address_byte_size == 8)
+ return sizeof(ELFLinuxPrPsInfo);
+ return mips_linux_pr_psinfo_size_o32_n32;
+ }
+
+ switch (arch.GetCore()) {
+ case lldb_private::ArchSpec::eCore_s390x_generic:
+ case lldb_private::ArchSpec::eCore_x86_64_x86_64:
+ return sizeof(ELFLinuxPrPsInfo);
+ case lldb_private::ArchSpec::eCore_x86_32_i386:
+ case lldb_private::ArchSpec::eCore_x86_32_i486:
+ return 124;
+ default:
+ return 0;
+ }
+}
+
Error ELFLinuxPrPsInfo::Parse(DataExtractor &data, ArchSpec &arch) {
Error error;
ByteOrder byteorder = data.GetByteOrder();
@@ -273,9 +367,15 @@ Error ELFLinuxPrPsInfo::Parse(DataExtractor &data, ArchSpec &arch) {
pr_flag = data.GetPointer(&offset);
+ if (arch.IsMIPS()) {
+ // The pr_uid and pr_gid is always 32 bit irrespective of platforms
+ pr_uid = data.GetU32(&offset);
+ pr_gid = data.GetU32(&offset);
+ } else {
// 16 bit on 32 bit platforms, 32 bit on 64 bit platforms
pr_uid = data.GetMaxU64(&offset, data.GetAddressByteSize() >> 1);
pr_gid = data.GetMaxU64(&offset, data.GetAddressByteSize() >> 1);
+ }
pr_pid = data.GetU32(&offset);
pr_ppid = data.GetU32(&offset);
@@ -296,8 +396,21 @@ Error ELFLinuxPrPsInfo::Parse(DataExtractor &data, ArchSpec &arch) {
//----------------------------------------------------------------
// Parse SIGINFO from NOTE entry
//----------------------------------------------------------------
-ELFLinuxSigInfo::ELFLinuxSigInfo() {
- memset(this, 0, sizeof(ELFLinuxSigInfo));
+ELFLinuxSigInfo::ELFLinuxSigInfo() { memset(this, 0, sizeof(ELFLinuxSigInfo)); }
+
+size_t ELFLinuxSigInfo::GetSize(const lldb_private::ArchSpec &arch) {
+ if (arch.IsMIPS())
+ return sizeof(ELFLinuxSigInfo);
+ switch (arch.GetCore()) {
+ case lldb_private::ArchSpec::eCore_x86_64_x86_64:
+ return sizeof(ELFLinuxSigInfo);
+ case lldb_private::ArchSpec::eCore_s390x_generic:
+ case lldb_private::ArchSpec::eCore_x86_32_i386:
+ case lldb_private::ArchSpec::eCore_x86_32_i486:
+ return 12;
+ default:
+ return 0;
+ }
}
Error ELFLinuxSigInfo::Parse(DataExtractor &data, const ArchSpec &arch) {
diff --git a/source/Plugins/Process/elf-core/ThreadElfCore.h b/source/Plugins/Process/elf-core/ThreadElfCore.h
index 1957ac243ceb..38c52658a23a 100644
--- a/source/Plugins/Process/elf-core/ThreadElfCore.h
+++ b/source/Plugins/Process/elf-core/ThreadElfCore.h
@@ -16,8 +16,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataExtractor.h"
struct compat_timeval {
alignas(8) uint64_t tv_sec;
@@ -65,18 +65,7 @@ struct ELFLinuxPrStatus {
// 32 bit - hardcoded because we are reusing the struct, but some of the
// members are smaller -
// so the layout is not the same
- static size_t GetSize(lldb_private::ArchSpec &arch) {
- switch (arch.GetCore()) {
- case lldb_private::ArchSpec::eCore_s390x_generic:
- case lldb_private::ArchSpec::eCore_x86_64_x86_64:
- return sizeof(ELFLinuxPrStatus);
- case lldb_private::ArchSpec::eCore_x86_32_i386:
- case lldb_private::ArchSpec::eCore_x86_32_i486:
- return 72;
- default:
- return 0;
- }
- }
+ static size_t GetSize(lldb_private::ArchSpec &arch);
};
static_assert(sizeof(ELFLinuxPrStatus) == 112,
@@ -97,18 +86,7 @@ struct ELFLinuxSigInfo {
// 32 bit - hardcoded because we are reusing the struct, but some of the
// members are smaller -
// so the layout is not the same
- static size_t GetSize(const lldb_private::ArchSpec &arch) {
- switch (arch.GetCore()) {
- case lldb_private::ArchSpec::eCore_x86_64_x86_64:
- return sizeof(ELFLinuxSigInfo);
- case lldb_private::ArchSpec::eCore_s390x_generic:
- case lldb_private::ArchSpec::eCore_x86_32_i386:
- case lldb_private::ArchSpec::eCore_x86_32_i486:
- return 12;
- default:
- return 0;
- }
- }
+ static size_t GetSize(const lldb_private::ArchSpec &arch);
};
static_assert(sizeof(ELFLinuxSigInfo) == 12,
@@ -143,18 +121,7 @@ struct ELFLinuxPrPsInfo {
// 32 bit - hardcoded because we are reusing the struct, but some of the
// members are smaller -
// so the layout is not the same
- static size_t GetSize(lldb_private::ArchSpec &arch) {
- switch (arch.GetCore()) {
- case lldb_private::ArchSpec::eCore_s390x_generic:
- case lldb_private::ArchSpec::eCore_x86_64_x86_64:
- return sizeof(ELFLinuxPrPsInfo);
- case lldb_private::ArchSpec::eCore_x86_32_i386:
- case lldb_private::ArchSpec::eCore_x86_32_i486:
- return 124;
- default:
- return 0;
- }
- }
+ static size_t GetSize(lldb_private::ArchSpec &arch);
};
static_assert(sizeof(ELFLinuxPrPsInfo) == 136,
diff --git a/source/Plugins/Process/gdb-remote/CMakeLists.txt b/source/Plugins/Process/gdb-remote/CMakeLists.txt
index b28522725868..3d008f42499d 100644
--- a/source/Plugins/Process/gdb-remote/CMakeLists.txt
+++ b/source/Plugins/Process/gdb-remote/CMakeLists.txt
@@ -2,7 +2,20 @@ if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
include_directories(${LIBXML2_INCLUDE_DIR})
endif()
-add_lldb_library(lldbPluginProcessGDBRemote
+set(LLDB_PLUGINS
+ lldbPluginProcessUtility
+ lldbPluginPlatformMacOSX
+)
+
+if(CMAKE_SYSTEM_NAME MATCHES "Linux|Android")
+ list(APPEND LLDB_PLUGINS lldbPluginProcessLinux)
+endif()
+
+if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
+ list(APPEND LLDB_PLUGINS lldbPluginProcessNetBSD)
+endif()
+
+add_lldb_library(lldbPluginProcessGDBRemote PLUGIN
GDBRemoteClientBase.cpp
GDBRemoteCommunication.cpp
GDBRemoteCommunicationClient.cpp
@@ -14,4 +27,17 @@ add_lldb_library(lldbPluginProcessGDBRemote
ProcessGDBRemote.cpp
ProcessGDBRemoteLog.cpp
ThreadGDBRemote.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbDataFormatters
+ lldbHost
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ ${LLDB_PLUGINS}
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index bd87521fe6e7..7ef253decad6 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -16,12 +16,8 @@
// C++ Includes
// Other libraries and framework includes
-#include "lldb/Core/Log.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/Pipe.h"
@@ -30,6 +26,10 @@
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/StreamString.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/ScopedPrinter.h"
@@ -72,7 +72,7 @@ void GDBRemoteCommunication::History::AddPacket(char packet_char,
m_packets[idx].type = type;
m_packets[idx].bytes_transmitted = bytes_transmitted;
m_packets[idx].packet_idx = m_total_packet_count;
- m_packets[idx].tid = Host::GetCurrentThreadID();
+ m_packets[idx].tid = llvm::get_threadid();
}
}
@@ -87,7 +87,7 @@ void GDBRemoteCommunication::History::AddPacket(const std::string &src,
m_packets[idx].type = type;
m_packets[idx].bytes_transmitted = bytes_transmitted;
m_packets[idx].packet_idx = m_total_packet_count;
- m_packets[idx].tid = Host::GetCurrentThreadID();
+ m_packets[idx].tid = llvm::get_threadid();
}
}
@@ -321,8 +321,7 @@ GDBRemoteCommunication::WaitForPacketNoLock(StringExtractorGDBRemote &packet,
uint8_t buffer[8192];
Error error;
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS |
- GDBR_LOG_VERBOSE));
+ Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
// Check for a packet from our cache first without trying any reading...
if (CheckForPacket(NULL, 0, packet) != PacketType::Invalid)
@@ -334,12 +333,11 @@ GDBRemoteCommunication::WaitForPacketNoLock(StringExtractorGDBRemote &packet,
lldb::ConnectionStatus status = eConnectionStatusNoConnection;
size_t bytes_read = Read(buffer, sizeof(buffer), timeout, status, &error);
- if (log)
- log->Printf("%s: Read (buffer, (sizeof(buffer), timeout = %ld us, "
- "status = %s, error = %s) => bytes_read = %" PRIu64,
- LLVM_PRETTY_FUNCTION, long(timeout ? timeout->count() : -1),
- Communication::ConnectionStatusAsCString(status),
- error.AsCString(), (uint64_t)bytes_read);
+ LLDB_LOGV(log,
+ "Read(buffer, sizeof(buffer), timeout = {0}, "
+ "status = {1}, error = {2}) => bytes_read = {3}",
+ timeout, Communication::ConnectionStatusAsCString(status), error,
+ bytes_read);
if (bytes_read > 0) {
if (CheckForPacket(buffer, bytes_read, packet) != PacketType::Invalid)
@@ -607,10 +605,10 @@ bool GDBRemoteCommunication::DecompressPacket() {
m_compression_type == CompressionType::LZFSE ||
m_compression_type == CompressionType::LZ4)) {
compression_algorithm compression_type;
- if (m_compression_type == CompressionType::ZlibDeflate)
- compression_type = COMPRESSION_ZLIB;
- else if (m_compression_type == CompressionType::LZFSE)
+ if (m_compression_type == CompressionType::LZFSE)
compression_type = COMPRESSION_LZFSE;
+ else if (m_compression_type == CompressionType::ZlibDeflate)
+ compression_type = COMPRESSION_ZLIB;
else if (m_compression_type == CompressionType::LZ4)
compression_type = COMPRESSION_LZ4_RAW;
else if (m_compression_type == CompressionType::LZMA)
@@ -1085,8 +1083,7 @@ Error GDBRemoteCommunication::StartDebugserverProcess(
// port is null when debug server should listen on domain socket -
// we're not interested in port value but rather waiting for debug server
// to become available.
- if (pass_comm_fd == -1 &&
- ((port != nullptr && *port == 0) || port == nullptr)) {
+ if (pass_comm_fd == -1) {
if (url) {
// Create a temporary file to get the stdout/stderr and redirect the
// output of the command into this file. We will later read this file
@@ -1258,11 +1255,21 @@ Error GDBRemoteCommunication::StartDebugserverProcess(
port_cstr, num_bytes, std::chrono::seconds{10}, num_bytes);
if (error.Success() && (port != nullptr)) {
assert(num_bytes > 0 && port_cstr[num_bytes - 1] == '\0');
- *port = StringConvert::ToUInt32(port_cstr, 0);
- if (log)
- log->Printf("GDBRemoteCommunication::%s() "
- "debugserver listens %u port",
- __FUNCTION__, *port);
+ uint16_t child_port = StringConvert::ToUInt32(port_cstr, 0);
+ if (*port == 0 || *port == child_port) {
+ *port = child_port;
+ if (log)
+ log->Printf("GDBRemoteCommunication::%s() "
+ "debugserver listens %u port",
+ __FUNCTION__, *port);
+ } else {
+ if (log)
+ log->Printf("GDBRemoteCommunication::%s() "
+ "debugserver listening on port "
+ "%d but requested port was %d",
+ __FUNCTION__, (uint32_t)child_port,
+ (uint32_t)(*port));
+ }
} else {
if (log)
log->Printf("GDBRemoteCommunication::%s() "
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index b70f0903dbd5..2e94fa94331d 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -18,21 +18,20 @@
#include <sstream>
// Other libraries and framework includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/State.h"
-#include "lldb/Core/StreamGDBRemote.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Host/HostInfo.h"
-#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/UnixSignals.h"
+#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/JSON.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamGDBRemote.h"
+#include "lldb/Utility/StreamString.h"
// Project includes
#include "ProcessGDBRemote.h"
@@ -87,6 +86,7 @@ GDBRemoteCommunicationClient::GDBRemoteCommunicationClient()
m_supports_jThreadExtendedInfo(eLazyBoolCalculate),
m_supports_jLoadedDynamicLibrariesInfos(eLazyBoolCalculate),
m_supports_jGetSharedCacheInfo(eLazyBoolCalculate),
+ m_supports_QPassSignals(eLazyBoolCalculate),
m_supports_qProcessInfoPID(true), m_supports_qfProcessInfo(true),
m_supports_qUserName(true), m_supports_qGroupName(true),
m_supports_qThreadStopInfo(true), m_supports_z0(true),
@@ -150,6 +150,13 @@ bool GDBRemoteCommunicationClient::GetEchoSupported() {
return m_supports_qEcho == eLazyBoolYes;
}
+bool GDBRemoteCommunicationClient::GetQPassSignalsSupported() {
+ if (m_supports_QPassSignals == eLazyBoolCalculate) {
+ GetRemoteQSupported();
+ }
+ return m_supports_QPassSignals == eLazyBoolYes;
+}
+
bool GDBRemoteCommunicationClient::GetAugmentedLibrariesSVR4ReadSupported() {
if (m_supports_augmented_libraries_svr4_read == eLazyBoolCalculate) {
GetRemoteQSupported();
@@ -419,6 +426,11 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() {
else
m_supports_qEcho = eLazyBoolNo;
+ if (::strstr(response_cstr, "QPassSignals+"))
+ m_supports_QPassSignals = eLazyBoolYes;
+ else
+ m_supports_QPassSignals = eLazyBoolNo;
+
const char *packet_size_str = ::strstr(response_cstr, "PacketSize=");
if (packet_size_str) {
StringExtractorGDBRemote packet_response(packet_size_str +
@@ -1491,13 +1503,18 @@ Error GDBRemoteCommunicationClient::GetMemoryRegionInfo(
}
}
- // We got a valid address range back but no permissions -- which means
- // this is an unmapped page
- if (region_info.GetRange().IsValid() && saw_permissions == false) {
- region_info.SetReadable(MemoryRegionInfo::eNo);
- region_info.SetWritable(MemoryRegionInfo::eNo);
- region_info.SetExecutable(MemoryRegionInfo::eNo);
- region_info.SetMapped(MemoryRegionInfo::eNo);
+ if (region_info.GetRange().IsValid()) {
+ // We got a valid address range back but no permissions -- which means
+ // this is an unmapped page
+ if (!saw_permissions) {
+ region_info.SetReadable(MemoryRegionInfo::eNo);
+ region_info.SetWritable(MemoryRegionInfo::eNo);
+ region_info.SetExecutable(MemoryRegionInfo::eNo);
+ region_info.SetMapped(MemoryRegionInfo::eNo);
+ }
+ } else {
+ // We got an invalid address range back
+ error.SetErrorString("Server returned invalid range");
}
} else {
m_supports_memory_region_info = eLazyBoolNo;
@@ -1660,7 +1677,7 @@ bool GDBRemoteCommunicationClient::GetWorkingDir(FileSpec &working_dir) {
return false;
std::string cwd;
response.GetHexByteString(cwd);
- working_dir.SetFile(cwd, false, GetHostArchitecture());
+ working_dir.SetFile(cwd, false, GetHostArchitecture().GetTriple());
return !cwd.empty();
}
return false;
@@ -1907,6 +1924,7 @@ bool GDBRemoteCommunicationClient::GetCurrentProcessInfo(bool allow_lazy) {
llvm::Triple triple(llvm::Twine("-") + vendor_name + "-" + os_name);
assert(triple.getObjectFormat() != llvm::Triple::UnknownObjectFormat);
+ assert(triple.getObjectFormat() != llvm::Triple::Wasm);
switch (triple.getObjectFormat()) {
case llvm::Triple::MachO:
m_process_arch.SetArchitecture(eArchTypeMachO, cpu, sub);
@@ -1917,6 +1935,10 @@ bool GDBRemoteCommunicationClient::GetCurrentProcessInfo(bool allow_lazy) {
case llvm::Triple::COFF:
m_process_arch.SetArchitecture(eArchTypeCOFF, cpu, sub);
break;
+ case llvm::Triple::Wasm:
+ if (log)
+ log->Printf("error: not supported target architecture");
+ return false;
case llvm::Triple::UnknownObjectFormat:
if (log)
log->Printf("error: failed to determine target architecture");
@@ -1957,29 +1979,29 @@ uint32_t GDBRemoteCommunicationClient::FindProcesses(
bool has_name_match = false;
if (name && name[0]) {
has_name_match = true;
- NameMatchType name_match_type = match_info.GetNameMatchType();
+ NameMatch name_match_type = match_info.GetNameMatchType();
switch (name_match_type) {
- case eNameMatchIgnore:
+ case NameMatch::Ignore:
has_name_match = false;
break;
- case eNameMatchEquals:
+ case NameMatch::Equals:
packet.PutCString("name_match:equals;");
break;
- case eNameMatchContains:
+ case NameMatch::Contains:
packet.PutCString("name_match:contains;");
break;
- case eNameMatchStartsWith:
+ case NameMatch::StartsWith:
packet.PutCString("name_match:starts_with;");
break;
- case eNameMatchEndsWith:
+ case NameMatch::EndsWith:
packet.PutCString("name_match:ends_with;");
break;
- case eNameMatchRegularExpression:
+ case NameMatch::RegularExpression:
packet.PutCString("name_match:regex;");
break;
}
@@ -2190,23 +2212,19 @@ void GDBRemoteCommunicationClient::TestPacketSpeed(const uint32_t num_packets,
const duration<float> standard_deviation =
calculate_standard_deviation(packet_times);
if (json) {
- strm.Printf("%s\n {\"send_size\" : %6" PRIu32
- ", \"recv_size\" : %6" PRIu32
- ", \"total_time_nsec\" : %12" PRIu64
- ", \"standard_deviation_nsec\" : %9" PRIu64 " }",
+ strm.Format("{0}\n {{\"send_size\" : {1,6}, \"recv_size\" : "
+ "{2,6}, \"total_time_nsec\" : {3,12:ns-}, "
+ "\"standard_deviation_nsec\" : {4,9:ns-f0}}",
result_idx > 0 ? "," : "", send_size, recv_size,
- duration_cast<nanoseconds>(total_time).count(),
- duration_cast<nanoseconds>(standard_deviation).count());
+ total_time, standard_deviation);
++result_idx;
} else {
- strm.Printf(
- "qSpeedTest(send=%-7u, recv=%-7u) in %.9f"
- " sec for %9.2f packets/sec (%10.6f ms per packet) with standard "
- "deviation of %10.6f ms\n",
- send_size, recv_size, duration<float>(total_time).count(),
- packets_per_second,
- duration<float, std::milli>(average_per_packet).count(),
- duration<float, std::milli>(standard_deviation).count());
+ strm.Format("qSpeedTest(send={0,7}, recv={1,7}) in {2:s+f9} for "
+ "{3,9:f2} packets/s ({4,10:ms+f6} per packet) with "
+ "standard deviation of {5,10:ms+f6}\n",
+ send_size, recv_size, duration<float>(total_time),
+ packets_per_second, duration<float>(average_per_packet),
+ standard_deviation);
}
strm.Flush();
}
@@ -2249,21 +2267,18 @@ void GDBRemoteCommunicationClient::TestPacketSpeed(const uint32_t num_packets,
const auto average_per_packet = total_time / packet_count;
if (json) {
- strm.Printf("%s\n {\"send_size\" : %6" PRIu32
- ", \"recv_size\" : %6" PRIu32
- ", \"total_time_nsec\" : %12" PRIu64 " }",
+ strm.Format("{0}\n {{\"send_size\" : {1,6}, \"recv_size\" : "
+ "{2,6}, \"total_time_nsec\" : {3,12:ns-}}",
result_idx > 0 ? "," : "", send_size, recv_size,
- duration_cast<nanoseconds>(total_time).count());
+ total_time);
++result_idx;
} else {
- strm.Printf("qSpeedTest(send=%-7u, recv=%-7u) %6u packets needed to "
- "receive %2.1fMB in %.9f"
- " sec for %f MB/sec for %9.2f packets/sec (%10.6f ms per "
- "packet)\n",
+ strm.Format("qSpeedTest(send={0,7}, recv={1,7}) {2,6} packets needed "
+ "to receive {3:f1}MB in {4:s+f9} for {5} MB/sec for "
+ "{6,9:f2} packets/sec ({7,10:ms+f6} per packet)\n",
send_size, recv_size, packet_count, k_recv_amount_mb,
- duration<float>(total_time).count(), mb_second,
- packets_per_second,
- duration<float, std::milli>(average_per_packet).count());
+ duration<float>(total_time), mb_second,
+ packets_per_second, duration<float>(average_per_packet));
}
strm.Flush();
}
@@ -3193,7 +3208,7 @@ bool GDBRemoteCommunicationClient::GetModuleInfo(
StringExtractor extractor(value);
std::string path;
extractor.GetHexByteString(path);
- module_spec.GetFileSpec() = FileSpec(path, false, arch_spec);
+ module_spec.GetFileSpec() = FileSpec(path, false, arch_spec.GetTriple());
}
}
@@ -3227,7 +3242,8 @@ ParseModuleSpec(StructuredData::Dictionary *dict) {
if (!dict->GetValueForKeyAsString("file_path", string))
return llvm::None;
- result.GetFileSpec() = FileSpec(string, false, result.GetArchitecture());
+ result.GetFileSpec() =
+ FileSpec(string, false, result.GetArchitecture().GetTriple());
return result;
}
@@ -3254,6 +3270,9 @@ GDBRemoteCommunicationClient::GetModulesInfo(
payload.PutEscapedBytes(unescaped_payload.GetString().data(),
unescaped_payload.GetSize());
+ // Increase the timeout for jModulesInfo since this packet can take longer.
+ ScopedTimeout timeout(*this, std::chrono::seconds(10));
+
StringExtractorGDBRemote response;
if (SendPacketAndWaitForResponse(payload.GetString(), response, false) !=
PacketResult::Success ||
@@ -3571,6 +3590,26 @@ GDBRemoteCommunicationClient::GetSupportedStructuredDataPlugins() {
: nullptr;
}
+Error GDBRemoteCommunicationClient::SendSignalsToIgnore(
+ llvm::ArrayRef<int32_t> signals) {
+ // Format packet:
+ // QPassSignals:<hex_sig1>;<hex_sig2>...;<hex_sigN>
+ auto range = llvm::make_range(signals.begin(), signals.end());
+ std::string packet = formatv("QPassSignals:{0:$[;]@(x-2)}", range).str();
+
+ StringExtractorGDBRemote response;
+ auto send_status = SendPacketAndWaitForResponse(packet, response, false);
+
+ if (send_status != GDBRemoteCommunication::PacketResult::Success)
+ return Error("Sending QPassSignals packet failed");
+
+ if (response.IsOKResponse()) {
+ return Error();
+ } else {
+ return Error("Unknown error happened during sending QPassSignals packet.");
+ }
+}
+
Error GDBRemoteCommunicationClient::ConfigureRemoteStructuredData(
const ConstString &type_name, const StructuredData::ObjectSP &config_sp) {
Error error;
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
index 83162a662e06..63b9708cc9a0 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
@@ -347,6 +347,8 @@ public:
bool GetEchoSupported();
+ bool GetQPassSignalsSupported();
+
bool GetAugmentedLibrariesSVR4ReadSupported();
bool GetQXferFeaturesReadSupported();
@@ -450,6 +452,9 @@ public:
void ServeSymbolLookups(lldb_private::Process *process);
+ // Sends QPassSignals packet to the server with given signals to ignore.
+ Error SendSignalsToIgnore(llvm::ArrayRef<int32_t> signals);
+
//------------------------------------------------------------------
/// Return the feature set supported by the gdb-remote server.
///
@@ -527,6 +532,7 @@ protected:
LazyBool m_supports_jThreadExtendedInfo;
LazyBool m_supports_jLoadedDynamicLibrariesInfos;
LazyBool m_supports_jGetSharedCacheInfo;
+ LazyBool m_supports_QPassSignals;
bool m_supports_qProcessInfoPID : 1, m_supports_qfProcessInfo : 1,
m_supports_qUserName : 1, m_supports_qGroupName : 1,
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index e4e6810f665c..66c1b15ff857 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -22,23 +22,22 @@
#include <cstring>
// Other libraries and framework includes
-#include "lldb/Core/Log.h"
#include "lldb/Core/ModuleSpec.h"
-#include "lldb/Core/StreamGDBRemote.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Host/Config.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Host/File.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
-#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/FileAction.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/Endian.h"
#include "lldb/Utility/JSON.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamGDBRemote.h"
+#include "lldb/Utility/StreamString.h"
#include "llvm/ADT/Triple.h"
// Project includes
@@ -360,16 +359,15 @@ GDBRemoteCommunicationServerCommon::Handle_qfProcessInfo(
extractor.GetHexByteString(file);
match_info.GetProcessInfo().GetExecutableFile().SetFile(file, false);
} else if (key.equals("name_match")) {
- NameMatchType name_match =
- llvm::StringSwitch<NameMatchType>(value)
- .Case("equals", eNameMatchEquals)
- .Case("starts_with", eNameMatchStartsWith)
- .Case("ends_with", eNameMatchEndsWith)
- .Case("contains", eNameMatchContains)
- .Case("regex", eNameMatchRegularExpression)
- .Default(eNameMatchIgnore);
+ NameMatch name_match = llvm::StringSwitch<NameMatch>(value)
+ .Case("equals", NameMatch::Equals)
+ .Case("starts_with", NameMatch::StartsWith)
+ .Case("ends_with", NameMatch::EndsWith)
+ .Case("contains", NameMatch::Contains)
+ .Case("regex", NameMatch::RegularExpression)
+ .Default(NameMatch::Ignore);
match_info.SetNameMatchType(name_match);
- if (name_match == eNameMatchIgnore)
+ if (name_match == NameMatch::Ignore)
return SendErrorResponse(2);
} else if (key.equals("pid")) {
lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
@@ -643,14 +641,15 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_Size(
std::string path;
packet.GetHexByteString(path);
if (!path.empty()) {
- lldb::user_id_t retcode = FileSystem::GetFileSize(FileSpec(path, false));
+ uint64_t Size;
+ if (llvm::sys::fs::file_size(path, Size))
+ return SendErrorResponse(5);
StreamString response;
response.PutChar('F');
- response.PutHex64(retcode);
- if (retcode == UINT64_MAX) {
+ response.PutHex64(Size);
+ if (Size == UINT64_MAX) {
response.PutChar(',');
- response.PutHex64(
- retcode); // TODO: replace with Host::GetSyswideErrorCode()
+ response.PutHex64(Size); // TODO: replace with Host::GetSyswideErrorCode()
}
return SendPacketNoLock(response.GetString());
}
@@ -682,7 +681,7 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_Exists(
std::string path;
packet.GetHexByteString(path);
if (!path.empty()) {
- bool retcode = FileSystem::GetFileExists(FileSpec(path, false));
+ bool retcode = llvm::sys::fs::exists(path);
StreamString response;
response.PutChar('F');
response.PutChar(',');
@@ -715,7 +714,7 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_unlink(
packet.SetFilePos(::strlen("vFile:unlink:"));
std::string path;
packet.GetHexByteString(path);
- Error error = FileSystem::Unlink(FileSpec{path, true});
+ Error error(llvm::sys::fs::remove(path));
StreamString response;
response.Printf("F%u,%u", error.GetError(), error.GetError());
return SendPacketNoLock(response.GetString());
@@ -772,15 +771,15 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_MD5(
std::string path;
packet.GetHexByteString(path);
if (!path.empty()) {
- uint64_t a, b;
StreamGDBRemote response;
- if (!FileSystem::CalculateMD5(FileSpec(path, false), a, b)) {
+ auto Result = llvm::sys::fs::md5_contents(path);
+ if (!Result) {
response.PutCString("F,");
response.PutCString("x");
} else {
response.PutCString("F,");
- response.PutHex64(a);
- response.PutHex64(b);
+ response.PutHex64(Result->low());
+ response.PutHex64(Result->high());
}
return SendPacketNoLock(response.GetString());
}
@@ -795,7 +794,7 @@ GDBRemoteCommunicationServerCommon::Handle_qPlatform_mkdir(
if (packet.GetChar() == ',') {
std::string path;
packet.GetHexByteString(path);
- Error error = FileSystem::MakeDirectory(FileSpec{path, false}, mode);
+ Error error(llvm::sys::fs::create_directory(path, mode));
StreamGDBRemote response;
response.Printf("F%u", error.GetError());
@@ -810,11 +809,12 @@ GDBRemoteCommunicationServerCommon::Handle_qPlatform_chmod(
StringExtractorGDBRemote &packet) {
packet.SetFilePos(::strlen("qPlatform_chmod:"));
- mode_t mode = packet.GetHexMaxU32(false, UINT32_MAX);
+ auto perms =
+ static_cast<llvm::sys::fs::perms>(packet.GetHexMaxU32(false, UINT32_MAX));
if (packet.GetChar() == ',') {
std::string path;
packet.GetHexByteString(path);
- Error error = FileSystem::SetFilePermissions(FileSpec{path, true}, mode);
+ Error error(llvm::sys::fs::setPermissions(path, perms));
StreamGDBRemote response;
response.Printf("F%u", error.GetError());
@@ -838,7 +838,8 @@ GDBRemoteCommunicationServerCommon::Handle_qSupported(
response.PutCString(";QThreadSuffixSupported+");
response.PutCString(";QListThreadsInStopReply+");
response.PutCString(";qEcho+");
-#if defined(__linux__)
+#if defined(__linux__) || defined(__NetBSD__)
+ response.PutCString(";QPassSignals+");
response.PutCString(";qXfer:auxv:read+");
#endif
@@ -1091,12 +1092,11 @@ GDBRemoteCommunicationServerCommon::Handle_qModuleInfo(
StreamGDBRemote response;
if (uuid_str.empty()) {
- std::string md5_hash;
- if (!FileSystem::CalculateMD5AsString(matched_module_spec.GetFileSpec(),
- file_offset, file_size, md5_hash))
+ auto Result = llvm::sys::fs::md5_contents(matched_module_spec.GetFileSpec().GetPath());
+ if (!Result)
return SendErrorResponse(5);
response.PutCString("md5:");
- response.PutCStringAsRawHex8(md5_hash.c_str());
+ response.PutCStringAsRawHex8(Result->digest().c_str());
} else {
response.PutCString("uuid:");
response.PutCStringAsRawHex8(uuid_str.c_str());
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index bf72673f1769..290889ec662a 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -12,7 +12,7 @@
#include "lldb/Host/Config.h"
#include "GDBRemoteCommunicationServerLLGS.h"
-#include "lldb/Core/StreamGDBRemote.h"
+#include "lldb/Utility/StreamGDBRemote.h"
// C Includes
// C++ Includes
@@ -21,27 +21,27 @@
#include <thread>
// Other libraries and framework includes
-#include "lldb/Core/DataBuffer.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/State.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/Debug.h"
-#include "lldb/Host/Endian.h"
#include "lldb/Host/File.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
-#include "lldb/Host/StringConvert.h"
#include "lldb/Host/common/NativeProcessProtocol.h"
#include "lldb/Host/common/NativeRegisterContext.h"
#include "lldb/Host/common/NativeThreadProtocol.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Target/FileAction.h"
#include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/Utility/Endian.h"
#include "lldb/Utility/JSON.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/UriParser.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Support/ScopedPrinter.h"
@@ -49,7 +49,6 @@
#include "ProcessGDBRemote.h"
#include "ProcessGDBRemoteLog.h"
#include "Utility/StringExtractorGDBRemote.h"
-#include "Utility/UriParser.h"
using namespace lldb;
using namespace lldb_private;
@@ -81,7 +80,6 @@ GDBRemoteCommunicationServerLLGS::GDBRemoteCommunicationServerLLGS(
m_continue_tid(LLDB_INVALID_THREAD_ID), m_debugged_process_mutex(),
m_debugged_process_sp(), m_stdio_communication("process.stdio"),
m_inferior_prev_state(StateType::eStateInvalid),
- m_active_auxv_buffer_sp(), m_saved_registers_mutex(),
m_saved_registers_map(), m_next_saved_registers_id(1),
m_handshake_completed(false) {
RegisterPacketHandlers();
@@ -181,6 +179,9 @@ void GDBRemoteCommunicationServerLLGS::RegisterPacketHandlers() {
&GDBRemoteCommunicationServerLLGS::Handle_Z);
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_z,
&GDBRemoteCommunicationServerLLGS::Handle_z);
+ RegisterMemberFunctionHandler(
+ StringExtractorGDBRemote::eServerPacketType_QPassSignals,
+ &GDBRemoteCommunicationServerLLGS::Handle_QPassSignals);
RegisterPacketHandler(StringExtractorGDBRemote::eServerPacketType_k,
[this](StringExtractorGDBRemote packet, Error &error,
@@ -415,7 +416,8 @@ static void AppendHexValue(StreamString &response, const uint8_t *buf,
static void WriteRegisterValueInHexFixedWidth(
StreamString &response, NativeRegisterContextSP &reg_ctx_sp,
- const RegisterInfo &reg_info, const RegisterValue *reg_value_p) {
+ const RegisterInfo &reg_info, const RegisterValue *reg_value_p,
+ lldb::ByteOrder byte_order) {
RegisterValue reg_value;
if (!reg_value_p) {
Error error = reg_ctx_sp->ReadRegister(&reg_info, reg_value);
@@ -426,7 +428,8 @@ static void WriteRegisterValueInHexFixedWidth(
if (reg_value_p) {
AppendHexValue(response, (const uint8_t *)reg_value_p->GetBytes(),
- reg_value_p->GetByteSize(), false);
+ reg_value_p->GetByteSize(),
+ byte_order == lldb::eByteOrderLittle);
} else {
// Zero-out any unreadable values.
if (reg_info.byte_size > 0) {
@@ -436,8 +439,7 @@ static void WriteRegisterValueInHexFixedWidth(
}
}
-static JSONObject::SP GetRegistersAsJSON(NativeThreadProtocol &thread,
- bool abridged) {
+static JSONObject::SP GetRegistersAsJSON(NativeThreadProtocol &thread) {
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_THREAD));
NativeRegisterContextSP reg_ctx_sp = thread.GetRegisterContext();
@@ -462,11 +464,8 @@ static JSONObject::SP GetRegistersAsJSON(NativeThreadProtocol &thread,
static const uint32_t k_expedited_registers[] = {
LLDB_REGNUM_GENERIC_PC, LLDB_REGNUM_GENERIC_SP, LLDB_REGNUM_GENERIC_FP,
LLDB_REGNUM_GENERIC_RA, LLDB_INVALID_REGNUM};
- static const uint32_t k_abridged_expedited_registers[] = {
- LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM};
- for (const uint32_t *generic_reg_p = abridged ? k_abridged_expedited_registers
- : k_expedited_registers;
+ for (const uint32_t *generic_reg_p = k_expedited_registers;
*generic_reg_p != LLDB_INVALID_REGNUM; ++generic_reg_p) {
uint32_t reg_num = reg_ctx_sp->ConvertRegisterKindToRegisterNumber(
eRegisterKindGeneric, *generic_reg_p);
@@ -501,7 +500,7 @@ static JSONObject::SP GetRegistersAsJSON(NativeThreadProtocol &thread,
StreamString stream;
WriteRegisterValueInHexFixedWidth(stream, reg_ctx_sp, *reg_info_p,
- &reg_value);
+ &reg_value, lldb::eByteOrderBig);
register_object_sp->SetObject(
llvm::to_string(reg_num),
@@ -567,8 +566,10 @@ static JSONArray::SP GetJSONThreadsInfo(NativeProcessProtocol &process,
JSONObject::SP thread_obj_sp = std::make_shared<JSONObject>();
threads_array_sp->AppendObject(thread_obj_sp);
- if (JSONObject::SP registers_sp = GetRegistersAsJSON(*thread_sp, abridged))
- thread_obj_sp->SetObject("registers", registers_sp);
+ if (!abridged) {
+ if (JSONObject::SP registers_sp = GetRegistersAsJSON(*thread_sp))
+ thread_obj_sp->SetObject("registers", registers_sp);
+ }
thread_obj_sp->SetObject("tid", std::make_shared<JSONNumber>(tid));
if (signum != 0)
@@ -721,6 +722,41 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread(
"jstopinfo field for pid %" PRIu64,
__FUNCTION__, m_debugged_process_sp->GetID());
}
+
+ uint32_t i = 0;
+ response.PutCString("thread-pcs");
+ char delimiter = ':';
+ for (NativeThreadProtocolSP thread_sp;
+ (thread_sp = m_debugged_process_sp->GetThreadAtIndex(i)) != nullptr;
+ ++i) {
+ NativeRegisterContextSP reg_ctx_sp = thread_sp->GetRegisterContext();
+ if (!reg_ctx_sp)
+ continue;
+
+ uint32_t reg_to_read = reg_ctx_sp->ConvertRegisterKindToRegisterNumber(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
+ const RegisterInfo *const reg_info_p =
+ reg_ctx_sp->GetRegisterInfoAtIndex(reg_to_read);
+
+ RegisterValue reg_value;
+ Error error = reg_ctx_sp->ReadRegister(reg_info_p, reg_value);
+ if (error.Fail()) {
+ if (log)
+ log->Printf("%s failed to read register '%s' index %" PRIu32 ": %s",
+ __FUNCTION__,
+ reg_info_p->name ? reg_info_p->name
+ : "<unnamed-register>",
+ reg_to_read, error.AsCString());
+ continue;
+ }
+
+ response.PutChar(delimiter);
+ delimiter = ',';
+ WriteRegisterValueInHexFixedWidth(response, reg_ctx_sp, *reg_info_p,
+ &reg_value, endian::InlHostByteOrder());
+ }
+
+ response.PutChar(';');
}
//
@@ -761,7 +797,7 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread(
if (error.Success()) {
response.Printf("%.02x:", *reg_num_p);
WriteRegisterValueInHexFixedWidth(response, reg_ctx_sp, *reg_info_p,
- &reg_value);
+ &reg_value, lldb::eByteOrderBig);
response.PutChar(';');
} else {
if (log)
@@ -2496,12 +2532,14 @@ GDBRemoteCommunicationServerLLGS::Handle_z(StringExtractorGDBRemote &packet) {
packet, "Too short z packet, missing software/hardware specifier");
bool want_breakpoint = true;
+ bool want_hardware = false;
const GDBStoppointType stoppoint_type =
GDBStoppointType(packet.GetS32(eStoppointInvalid));
switch (stoppoint_type) {
case eBreakpointHardware:
want_breakpoint = true;
+ want_hardware = true;
break;
case eBreakpointSoftware:
want_breakpoint = true;
@@ -2544,7 +2582,8 @@ GDBRemoteCommunicationServerLLGS::Handle_z(StringExtractorGDBRemote &packet) {
if (want_breakpoint) {
// Try to clear the breakpoint.
- const Error error = m_debugged_process_sp->RemoveBreakpoint(addr);
+ const Error error =
+ m_debugged_process_sp->RemoveBreakpoint(addr, want_hardware);
if (error.Success())
return SendOKResponse();
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
@@ -2625,7 +2664,7 @@ GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerLLGS::Handle_qXfer_auxv_read(
StringExtractorGDBRemote &packet) {
// *BSD impls should be able to do this too.
-#if defined(__linux__)
+#if defined(__linux__) || defined(__NetBSD__)
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
// Parse out the offset.
@@ -2653,7 +2692,7 @@ GDBRemoteCommunicationServerLLGS::Handle_qXfer_auxv_read(
"qXfer:auxv:read:: packet missing length");
// Grab the auxv data if we need it.
- if (!m_active_auxv_buffer_sp) {
+ if (!m_active_auxv_buffer_up) {
// Make sure we have a valid process.
if (!m_debugged_process_sp ||
(m_debugged_process_sp->GetID() == LLDB_INVALID_PROCESS_ID)) {
@@ -2665,55 +2704,45 @@ GDBRemoteCommunicationServerLLGS::Handle_qXfer_auxv_read(
}
// Grab the auxv data.
- m_active_auxv_buffer_sp = Host::GetAuxvData(m_debugged_process_sp->GetID());
- if (!m_active_auxv_buffer_sp ||
- m_active_auxv_buffer_sp->GetByteSize() == 0) {
- // Hmm, no auxv data, call that an error.
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s failed, no auxv data "
- "retrieved",
- __FUNCTION__);
- m_active_auxv_buffer_sp.reset();
- return SendErrorResponse(0x11);
+ auto buffer_or_error = m_debugged_process_sp->GetAuxvData();
+ if (!buffer_or_error) {
+ std::error_code ec = buffer_or_error.getError();
+ LLDB_LOG(log, "no auxv data retrieved: {0}", ec.message());
+ return SendErrorResponse(ec.value());
}
+ m_active_auxv_buffer_up = std::move(*buffer_or_error);
}
- // FIXME find out if/how I lock the stream here.
-
StreamGDBRemote response;
bool done_with_buffer = false;
- if (auxv_offset >= m_active_auxv_buffer_sp->GetByteSize()) {
+ llvm::StringRef buffer = m_active_auxv_buffer_up->getBuffer();
+ if (auxv_offset >= buffer.size()) {
// We have nothing left to send. Mark the buffer as complete.
response.PutChar('l');
done_with_buffer = true;
} else {
// Figure out how many bytes are available starting at the given offset.
- const uint64_t bytes_remaining =
- m_active_auxv_buffer_sp->GetByteSize() - auxv_offset;
-
- // Figure out how many bytes we're going to read.
- const uint64_t bytes_to_read =
- (auxv_length > bytes_remaining) ? bytes_remaining : auxv_length;
+ buffer = buffer.drop_front(auxv_offset);
// Mark the response type according to whether we're reading the remainder
// of the auxv data.
- if (bytes_to_read >= bytes_remaining) {
+ if (auxv_length >= buffer.size()) {
// There will be nothing left to read after this
response.PutChar('l');
done_with_buffer = true;
} else {
// There will still be bytes to read after this request.
response.PutChar('m');
+ buffer = buffer.take_front(auxv_length);
}
// Now write the data in encoded binary form.
- response.PutEscapedBytes(m_active_auxv_buffer_sp->GetBytes() + auxv_offset,
- bytes_to_read);
+ response.PutEscapedBytes(buffer.data(), buffer.size());
}
if (done_with_buffer)
- m_active_auxv_buffer_sp.reset();
+ m_active_auxv_buffer_up.reset();
return SendPacketNoLock(response.GetString());
#else
@@ -3002,9 +3031,14 @@ GDBRemoteCommunicationServerLLGS::Handle_qWatchpointSupportInfo(
if (packet.GetChar() != ':')
return SendErrorResponse(67);
- uint32_t num = m_debugged_process_sp->GetMaxWatchpoints();
+ auto hw_debug_cap = m_debugged_process_sp->GetHardwareDebugSupportInfo();
+
StreamGDBRemote response;
- response.Printf("num:%d;", num);
+ if (hw_debug_cap == llvm::None)
+ response.Printf("num:0;");
+ else
+ response.Printf("num:%d;", hw_debug_cap->second);
+
return SendPacketNoLock(response.GetString());
}
@@ -3037,6 +3071,40 @@ GDBRemoteCommunicationServerLLGS::Handle_qFileLoadAddress(
return SendPacketNoLock(response.GetString());
}
+GDBRemoteCommunication::PacketResult
+GDBRemoteCommunicationServerLLGS::Handle_QPassSignals(
+ StringExtractorGDBRemote &packet) {
+ std::vector<int> signals;
+ packet.SetFilePos(strlen("QPassSignals:"));
+
+ // Read sequence of hex signal numbers divided by a semicolon and
+ // optionally spaces.
+ while (packet.GetBytesLeft() > 0) {
+ int signal = packet.GetS32(-1, 16);
+ if (signal < 0)
+ return SendIllFormedResponse(packet, "Failed to parse signal number.");
+ signals.push_back(signal);
+
+ packet.SkipSpaces();
+ char separator = packet.GetChar();
+ if (separator == '\0')
+ break; // End of string
+ if (separator != ';')
+ return SendIllFormedResponse(packet, "Invalid separator,"
+ " expected semicolon.");
+ }
+
+ // Fail if we don't have a current process.
+ if (!m_debugged_process_sp)
+ return SendErrorResponse(68);
+
+ Error error = m_debugged_process_sp->IgnoreSignals(signals);
+ if (error.Fail())
+ return SendErrorResponse(69);
+
+ return SendOKResponse();
+}
+
void GDBRemoteCommunicationServerLLGS::MaybeCloseInferiorTerminalConnection() {
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
@@ -3136,20 +3204,10 @@ uint32_t GDBRemoteCommunicationServerLLGS::GetNextSavedRegistersID() {
}
void GDBRemoteCommunicationServerLLGS::ClearProcessSpecificData() {
- Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | GDBR_LOG_PROCESS));
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s()", __FUNCTION__);
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
-// Clear any auxv cached data.
-// *BSD impls should be able to do this too.
-#if defined(__linux__)
- if (log)
- log->Printf("GDBRemoteCommunicationServerLLGS::%s clearing auxv buffer "
- "(previously %s)",
- __FUNCTION__,
- m_active_auxv_buffer_sp ? "was set" : "was not set");
- m_active_auxv_buffer_sp.reset();
-#endif
+ LLDB_LOG(log, "clearing auxv buffer: {0}", m_active_auxv_buffer_up.get());
+ m_active_auxv_buffer_up.reset();
}
FileSpec
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
index fa52cdaab493..a47927e1c640 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -117,7 +117,7 @@ protected:
MainLoop::ReadHandleUP m_stdio_handle_up;
lldb::StateType m_inferior_prev_state;
- lldb::DataBufferSP m_active_auxv_buffer_sp;
+ std::unique_ptr<llvm::MemoryBuffer> m_active_auxv_buffer_up;
std::mutex m_saved_registers_mutex;
std::unordered_map<uint32_t, lldb::DataBufferSP> m_saved_registers_map;
uint32_t m_next_saved_registers_id;
@@ -203,6 +203,8 @@ protected:
PacketResult Handle_qFileLoadAddress(StringExtractorGDBRemote &packet);
+ PacketResult Handle_QPassSignals(StringExtractorGDBRemote &packet);
+
void SetCurrentThreadID(lldb::tid_t tid);
lldb::tid_t GetCurrentThreadID() const;
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
index 11069749186a..ae1c1adb5b45 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
@@ -20,25 +20,25 @@
// Other libraries and framework includes
#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Threading.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/StreamGDBRemote.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Host/Config.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
-#include "lldb/Host/StringConvert.h"
#include "lldb/Target/FileAction.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/UnixSignals.h"
#include "lldb/Utility/JSON.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamGDBRemote.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/UriParser.h"
// Project includes
#include "Utility/StringExtractorGDBRemote.h"
-#include "Utility/UriParser.h"
using namespace lldb;
using namespace lldb_private;
@@ -82,8 +82,8 @@ GDBRemoteCommunicationServerPlatform::GDBRemoteCommunicationServerPlatform(
&GDBRemoteCommunicationServerPlatform::Handle_jSignalsInfo);
RegisterPacketHandler(StringExtractorGDBRemote::eServerPacketType_interrupt,
- [this](StringExtractorGDBRemote packet, Error &error,
- bool &interrupt, bool &quit) {
+ [](StringExtractorGDBRemote packet, Error &error,
+ bool &interrupt, bool &quit) {
error.SetErrorString("interrupt received");
interrupt = true;
return PacketResult::Success;
@@ -353,15 +353,13 @@ GDBRemoteCommunicationServerPlatform::Handle_qProcessInfo(
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerPlatform::Handle_qGetWorkingDir(
StringExtractorGDBRemote &packet) {
- // If this packet is sent to a platform, then change the current working
- // directory
- char cwd[PATH_MAX];
- if (getcwd(cwd, sizeof(cwd)) == NULL)
- return SendErrorResponse(errno);
+ llvm::SmallString<64> cwd;
+ if (std::error_code ec = llvm::sys::fs::current_path(cwd))
+ return SendErrorResponse(ec.value());
StreamString response;
- response.PutBytesAsRawHex8(cwd, strlen(cwd));
+ response.PutBytesAsRawHex8(cwd.data(), cwd.size());
return SendPacketNoLock(response.GetString());
}
@@ -372,10 +370,8 @@ GDBRemoteCommunicationServerPlatform::Handle_QSetWorkingDir(
std::string path;
packet.GetHexByteString(path);
- // If this packet is sent to a platform, then change the current working
- // directory
- if (::chdir(path.c_str()) != 0)
- return SendErrorResponse(errno);
+ if (std::error_code ec = llvm::sys::fs::set_current_path(path))
+ return SendErrorResponse(ec.value());
return SendOKResponse();
}
@@ -532,9 +528,9 @@ bool GDBRemoteCommunicationServerPlatform::FreePortForProcess(lldb::pid_t pid) {
const FileSpec &GDBRemoteCommunicationServerPlatform::GetDomainSocketDir() {
static FileSpec g_domainsocket_dir;
- static std::once_flag g_once_flag;
+ static llvm::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
+ llvm::call_once(g_once_flag, []() {
const char *domainsocket_dir_env =
::getenv("LLDB_DEBUGSERVER_DOMAINSOCKET_DIR");
if (domainsocket_dir_env != nullptr)
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index 27ce67ded783..ea4acc74893a 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -12,14 +12,13 @@
// C Includes
// C++ Includes
// Other libraries and framework includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/RegisterValue.h"
#include "lldb/Core/Scalar.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Target.h"
-#include "lldb/Utility/Utils.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/StreamString.h"
// Project includes
#include "ProcessGDBRemote.h"
#include "ProcessGDBRemoteLog.h"
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
index 5b3e04eb588e..8ef91af55e0f 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
@@ -17,9 +17,9 @@
// Other libraries and framework includes
// Project includes
#include "Plugins/Process/Utility/DynamicRegisterInfo.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataExtractor.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-private.h"
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index fac52901e763..c4ae5e36d9ad 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -35,14 +35,13 @@
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/State.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
#include "lldb/Core/Value.h"
#include "lldb/DataFormatters/FormatManager.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostThread.h"
+#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Host/Symbols.h"
#include "lldb/Host/ThreadLauncher.h"
@@ -65,7 +64,8 @@
#include "lldb/Target/TargetList.h"
#include "lldb/Target/ThreadPlanCallFunction.h"
#include "lldb/Utility/CleanUp.h"
-#include "lldb/Utility/PseudoTerminal.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/StreamString.h"
// Project includes
#include "GDBRemoteRegisterContext.h"
@@ -80,6 +80,7 @@
#include "lldb/Host/Host.h"
#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/Threading.h"
#include "llvm/Support/raw_ostream.h"
#define DEBUGSERVER_BASENAME "debugserver"
@@ -576,7 +577,7 @@ void ProcessGDBRemote::BuildDynamicRegisterInfo(bool force) {
uint32_t ret_val =
opcode_extractor.GetHexBytesAvail(dwarf_opcode_bytes);
assert(dwarf_opcode_len == ret_val);
-
+ UNUSED_IF_ASSERT_DISABLED(ret_val);
reg_info.dynamic_size_dwarf_expr_bytes = dwarf_opcode_bytes.data();
}
}
@@ -1616,9 +1617,7 @@ bool ProcessGDBRemote::UpdateThreadList(ThreadList &old_thread_list,
ThreadList &new_thread_list) {
// locker will keep a mutex locked until it goes out of scope
Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_THREAD));
- if (log && log->GetMask().Test(GDBR_LOG_VERBOSE))
- log->Printf("ProcessGDBRemote::%s (pid = %" PRIu64 ")", __FUNCTION__,
- GetID());
+ LLDB_LOGV(log, "pid = {0}", GetID());
size_t num_thread_ids = m_thread_ids.size();
// The "m_thread_ids" thread ID list should always be updated after each stop
@@ -1637,39 +1636,14 @@ bool ProcessGDBRemote::UpdateThreadList(ThreadList &old_thread_list,
old_thread_list_copy.RemoveThreadByProtocolID(tid, false));
if (!thread_sp) {
thread_sp.reset(new ThreadGDBRemote(*this, tid));
- if (log && log->GetMask().Test(GDBR_LOG_VERBOSE))
- log->Printf("ProcessGDBRemote::%s Making new thread: %p for thread "
- "ID: 0x%" PRIx64 ".\n",
- __FUNCTION__, static_cast<void *>(thread_sp.get()),
- thread_sp->GetID());
+ LLDB_LOGV(log, "Making new thread: {0} for thread ID: {1:x}.",
+ thread_sp.get(), thread_sp->GetID());
} else {
- if (log && log->GetMask().Test(GDBR_LOG_VERBOSE))
- log->Printf("ProcessGDBRemote::%s Found old thread: %p for thread "
- "ID: 0x%" PRIx64 ".\n",
- __FUNCTION__, static_cast<void *>(thread_sp.get()),
- thread_sp->GetID());
- }
- // The m_thread_pcs vector has pc values in big-endian order, not
- // target-endian, unlike most
- // of the register read/write packets in gdb-remote protocol.
- // Early in the process startup, we may not yet have set the process
- // ByteOrder so we ignore these;
- // they are a performance improvement over fetching thread register values
- // individually, the
- // method we will fall back to if needed.
- if (m_thread_ids.size() == m_thread_pcs.size() && thread_sp.get() &&
- GetByteOrder() != eByteOrderInvalid) {
- ThreadGDBRemote *gdb_thread =
- static_cast<ThreadGDBRemote *>(thread_sp.get());
- RegisterContextSP reg_ctx_sp(thread_sp->GetRegisterContext());
- if (reg_ctx_sp) {
- uint32_t pc_regnum = reg_ctx_sp->ConvertRegisterKindToRegisterNumber(
- eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
- if (pc_regnum != LLDB_INVALID_REGNUM) {
- gdb_thread->PrivateSetRegisterValue(pc_regnum, m_thread_pcs[i]);
- }
- }
+ LLDB_LOGV(log, "Found old thread: {0} for thread ID: {1:x}.",
+ thread_sp.get(), thread_sp->GetID());
}
+
+ SetThreadPc(thread_sp, i);
new_thread_list.AddThreadSortedByIndexID(thread_sp);
}
}
@@ -1689,6 +1663,22 @@ bool ProcessGDBRemote::UpdateThreadList(ThreadList &old_thread_list,
return true;
}
+void ProcessGDBRemote::SetThreadPc(const ThreadSP &thread_sp, uint64_t index) {
+ if (m_thread_ids.size() == m_thread_pcs.size() && thread_sp.get() &&
+ GetByteOrder() != eByteOrderInvalid) {
+ ThreadGDBRemote *gdb_thread =
+ static_cast<ThreadGDBRemote *>(thread_sp.get());
+ RegisterContextSP reg_ctx_sp(thread_sp->GetRegisterContext());
+ if (reg_ctx_sp) {
+ uint32_t pc_regnum = reg_ctx_sp->ConvertRegisterKindToRegisterNumber(
+ eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
+ if (pc_regnum != LLDB_INVALID_REGNUM) {
+ gdb_thread->PrivateSetRegisterValue(pc_regnum, m_thread_pcs[index]);
+ }
+ }
+ }
+}
+
bool ProcessGDBRemote::GetThreadStopInfoFromJSON(
ThreadGDBRemote *thread, const StructuredData::ObjectSP &thread_infos_sp) {
// See if we got thread stop infos for all threads via the "jThreadsInfo"
@@ -1774,6 +1764,11 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo(
static_cast<ThreadGDBRemote *>(thread_sp.get());
gdb_thread->GetRegisterContext()->InvalidateIfNeeded(true);
+ auto iter = std::find(m_thread_ids.begin(), m_thread_ids.end(), tid);
+ if (iter != m_thread_ids.end()) {
+ SetThreadPc(thread_sp, iter - m_thread_ids.begin());
+ }
+
for (const auto &pair : expedited_register_map) {
StringExtractor reg_value_extractor;
reg_value_extractor.GetStringRef() = pair.second;
@@ -2729,16 +2724,19 @@ void ProcessGDBRemote::WillPublicStop() {
size_t ProcessGDBRemote::DoReadMemory(addr_t addr, void *buf, size_t size,
Error &error) {
GetMaxMemorySize();
- if (size > m_max_memory_size) {
+ bool binary_memory_read = m_gdb_comm.GetxPacketSupported();
+ // M and m packets take 2 bytes for 1 byte of memory
+ size_t max_memory_size =
+ binary_memory_read ? m_max_memory_size : m_max_memory_size / 2;
+ if (size > max_memory_size) {
// Keep memory read sizes down to a sane limit. This function will be
// called multiple times in order to complete the task by
// lldb_private::Process so it is ok to do this.
- size = m_max_memory_size;
+ size = max_memory_size;
}
char packet[64];
int packet_len;
- bool binary_memory_read = m_gdb_comm.GetxPacketSupported();
packet_len = ::snprintf(packet, sizeof(packet), "%c%" PRIx64 ",%" PRIx64,
binary_memory_read ? 'x' : 'm', (uint64_t)addr,
(uint64_t)size);
@@ -2785,11 +2783,13 @@ size_t ProcessGDBRemote::DoReadMemory(addr_t addr, void *buf, size_t size,
size_t ProcessGDBRemote::DoWriteMemory(addr_t addr, const void *buf,
size_t size, Error &error) {
GetMaxMemorySize();
- if (size > m_max_memory_size) {
+ // M and m packets take 2 bytes for 1 byte of memory
+ size_t max_memory_size = m_max_memory_size / 2;
+ if (size > max_memory_size) {
// Keep memory read sizes down to a sane limit. This function will be
// called multiple times in order to complete the task by
// lldb_private::Process so it is ok to do this.
- size = m_max_memory_size;
+ size = max_memory_size;
}
StreamString packet;
@@ -3427,9 +3427,9 @@ void ProcessGDBRemote::KillDebugserverProcess() {
}
void ProcessGDBRemote::Initialize() {
- static std::once_flag g_once_flag;
+ static llvm::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
+ llvm::call_once(g_once_flag, []() {
PluginManager::RegisterPlugin(GetPluginNameStatic(),
GetPluginDescriptionStatic(), CreateInstance,
DebuggerInitialize);
@@ -3739,6 +3739,43 @@ bool ProcessGDBRemote::NewThreadNotifyBreakpointHit(
return false;
}
+Error ProcessGDBRemote::UpdateAutomaticSignalFiltering() {
+ Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+ LLDB_LOG(log, "Check if need to update ignored signals");
+
+ // QPassSignals package is not supported by the server,
+ // there is no way we can ignore any signals on server side.
+ if (!m_gdb_comm.GetQPassSignalsSupported())
+ return Error();
+
+ // No signals, nothing to send.
+ if (m_unix_signals_sp == nullptr)
+ return Error();
+
+ // Signals' version hasn't changed, no need to send anything.
+ uint64_t new_signals_version = m_unix_signals_sp->GetVersion();
+ if (new_signals_version == m_last_signals_version) {
+ LLDB_LOG(log, "Signals' version hasn't changed. version={0}",
+ m_last_signals_version);
+ return Error();
+ }
+
+ auto signals_to_ignore =
+ m_unix_signals_sp->GetFilteredSignals(false, false, false);
+ Error error = m_gdb_comm.SendSignalsToIgnore(signals_to_ignore);
+
+ LLDB_LOG(log,
+ "Signals' version changed. old version={0}, new version={1}, "
+ "signals ignored={2}, update result={3}",
+ m_last_signals_version, new_signals_version,
+ signals_to_ignore.size(), error);
+
+ if (error.Success())
+ m_last_signals_version = new_signals_version;
+
+ return error;
+}
+
bool ProcessGDBRemote::StartNoticingNewThreads() {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
if (m_thread_create_bp_sp) {
@@ -3988,6 +4025,21 @@ void ProcessGDBRemote::GetMaxMemorySize() {
stub_max_size = reasonable_largeish_default;
}
+ // Memory packet have other overheads too like Maddr,size:#NN
+ // Instead of calculating the bytes taken by size and addr every
+ // time, we take a maximum guess here.
+ if (stub_max_size > 70)
+ stub_max_size -= 32 + 32 + 6;
+ else {
+ // In unlikely scenario that max packet size is less then 70, we will
+ // hope that data being written is small enough to fit.
+ Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(
+ GDBR_LOG_COMM | GDBR_LOG_MEMORY));
+ if (log)
+ log->Warning("Packet size is too small. "
+ "LLDB may face problems while writing memory");
+ }
+
m_max_memory_size = stub_max_size;
} else {
m_max_memory_size = conservative_default;
@@ -4132,8 +4184,7 @@ bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info,
reg_node.ForEachAttribute([&target_info, &gdb_group, &gdb_type,
&reg_name, &alt_name, &set_name, &value_regs,
&invalidate_regs, &encoding_set, &format_set,
- &reg_info, &cur_reg_num, &reg_offset,
- &dwarf_opcode_bytes](
+ &reg_info, &reg_offset, &dwarf_opcode_bytes](
const llvm::StringRef &name,
const llvm::StringRef &value) -> bool {
if (name == "name") {
@@ -4213,7 +4264,7 @@ bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info,
uint32_t ret_val =
opcode_extractor.GetHexBytesAvail(dwarf_opcode_bytes);
assert(dwarf_opcode_len == ret_val);
-
+ UNUSED_IF_ASSERT_DISABLED(ret_val);
reg_info.dynamic_size_dwarf_expr_bytes = dwarf_opcode_bytes.data();
} else {
printf("unhandled attribute %s = %s\n", name.data(), value.data());
@@ -4295,7 +4346,7 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec &arch_to_use) {
XMLNode target_node = xml_document.GetRootElement("target");
if (target_node) {
XMLNode feature_node;
- target_node.ForEachChildElement([&target_info, this, &feature_node](
+ target_node.ForEachChildElement([&target_info, &feature_node](
const XMLNode &node) -> bool {
llvm::StringRef name = node.GetName();
if (name == "architecture") {
@@ -4421,8 +4472,8 @@ Error ProcessGDBRemote::GetLoadedModuleList(LoadedModuleInfoList &list) {
LoadedModuleInfoList::LoadedModuleInfo module;
library.ForEachAttribute(
- [log, &module](const llvm::StringRef &name,
- const llvm::StringRef &value) -> bool {
+ [&module](const llvm::StringRef &name,
+ const llvm::StringRef &value) -> bool {
if (name == "name")
module.set_name(value.str());
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index 6423abc55836..a1794d0f5050 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -22,18 +22,18 @@
// Project includes
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Broadcaster.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/LoadedModuleInfoList.h"
#include "lldb/Core/ModuleSpec.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Core/ThreadSafeValue.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/StringExtractor.h"
+#include "lldb/Utility/StringList.h"
#include "lldb/lldb-private-forward.h"
#include "GDBRemoteCommunicationClient.h"
@@ -397,12 +397,15 @@ protected:
lldb::addr_t base_addr,
bool value_is_offset);
+ Error UpdateAutomaticSignalFiltering() override;
+
private:
//------------------------------------------------------------------
// For ProcessGDBRemote only
//------------------------------------------------------------------
std::string m_partial_profile_data;
std::map<uint64_t, uint32_t> m_thread_id_to_used_usec_map;
+ uint64_t m_last_signals_version = 0;
static bool NewThreadNotifyBreakpointHit(void *baton,
StoppointCallbackContext *context,
@@ -417,6 +420,7 @@ private:
void HandleStopReply() override;
void HandleAsyncStructuredDataPacket(llvm::StringRef data) override;
+ void SetThreadPc(const lldb::ThreadSP &thread_sp, uint64_t index);
using ModuleCacheKey = std::pair<std::string, std::string>;
// KeyInfo for the cached module spec DenseMap.
// The invariant is that all real keys will have the file and architecture
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
index 899037ae98aa..8f16b83907cf 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
@@ -8,210 +8,37 @@
//===----------------------------------------------------------------------===//
#include "ProcessGDBRemoteLog.h"
-
-#include <mutex>
-
-#include "lldb/Core/StreamFile.h"
-#include "lldb/Interpreter/Args.h"
-
#include "ProcessGDBRemote.h"
+#include "llvm/Support/Threading.h"
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::process_gdb_remote;
-// We want to avoid global constructors where code needs to be run so here we
-// control access to our static g_log_sp by hiding it in a singleton function
-// that will construct the static g_lob_sp the first time this function is
-// called.
-static bool g_log_enabled = false;
-static Log *g_log = NULL;
-static Log *GetLog() {
- if (!g_log_enabled)
- return NULL;
- return g_log;
-}
+static constexpr Log::Category g_categories[] = {
+ {{"async"}, {"log asynchronous activity"}, GDBR_LOG_ASYNC},
+ {{"break"}, {"log breakpoints"}, GDBR_LOG_BREAKPOINTS},
+ {{"comm"}, {"log communication activity"}, GDBR_LOG_COMM},
+ {{"packets"}, {"log gdb remote packets"}, GDBR_LOG_PACKETS},
+ {{"memory"}, {"log memory reads and writes"}, GDBR_LOG_MEMORY},
+ {{"data-short"},
+ {"log memory bytes for memory reads and writes for short transactions "
+ "only"},
+ GDBR_LOG_MEMORY_DATA_SHORT},
+ {{"data-long"},
+ {"log memory bytes for memory reads and writes for all transactions"},
+ GDBR_LOG_MEMORY_DATA_LONG},
+ {{"process"}, {"log process events and activities"}, GDBR_LOG_PROCESS},
+ {{"step"}, {"log step related activities"}, GDBR_LOG_STEP},
+ {{"thread"}, {"log thread events and activities"}, GDBR_LOG_THREAD},
+ {{"watch"}, {"log watchpoint related activities"}, GDBR_LOG_WATCHPOINTS},
+};
-void ProcessGDBRemoteLog::Initialize() {
- static ConstString g_name("gdb-remote");
- static std::once_flag g_once_flag;
-
- std::call_once(g_once_flag, []() {
- Log::Callbacks log_callbacks = {DisableLog, EnableLog, ListLogCategories};
+Log::Channel ProcessGDBRemoteLog::g_channel(g_categories, GDBR_LOG_DEFAULT);
- Log::RegisterLogChannel(g_name, log_callbacks);
+void ProcessGDBRemoteLog::Initialize() {
+ static llvm::once_flag g_once_flag;
+ llvm::call_once(g_once_flag, []() {
+ Log::Register("gdb-remote", g_channel);
});
}
-
-Log *ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(uint32_t mask) {
- Log *log(GetLog());
- if (log && mask) {
- uint32_t log_mask = log->GetMask().Get();
- if ((log_mask & mask) != mask)
- return NULL;
- }
- return log;
-}
-
-Log *ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(uint32_t mask) {
- Log *log(GetLog());
- if (log && log->GetMask().Get() & mask)
- return log;
- return NULL;
-}
-
-void ProcessGDBRemoteLog::DisableLog(const char **categories,
- Stream *feedback_strm) {
- Log *log(GetLog());
- if (log) {
- uint32_t flag_bits = 0;
-
- if (categories && categories[0]) {
- flag_bits = log->GetMask().Get();
- for (size_t i = 0; categories[i] != NULL; ++i) {
- const char *arg = categories[i];
-
- if (::strcasecmp(arg, "all") == 0)
- flag_bits &= ~GDBR_LOG_ALL;
- else if (::strcasecmp(arg, "async") == 0)
- flag_bits &= ~GDBR_LOG_ASYNC;
- else if (::strncasecmp(arg, "break", 5) == 0)
- flag_bits &= ~GDBR_LOG_BREAKPOINTS;
- else if (::strncasecmp(arg, "comm", 4) == 0)
- flag_bits &= ~GDBR_LOG_COMM;
- else if (::strcasecmp(arg, "default") == 0)
- flag_bits &= ~GDBR_LOG_DEFAULT;
- else if (::strcasecmp(arg, "packets") == 0)
- flag_bits &= ~GDBR_LOG_PACKETS;
- else if (::strcasecmp(arg, "memory") == 0)
- flag_bits &= ~GDBR_LOG_MEMORY;
- else if (::strcasecmp(arg, "data-short") == 0)
- flag_bits &= ~GDBR_LOG_MEMORY_DATA_SHORT;
- else if (::strcasecmp(arg, "data-long") == 0)
- flag_bits &= ~GDBR_LOG_MEMORY_DATA_LONG;
- else if (::strcasecmp(arg, "process") == 0)
- flag_bits &= ~GDBR_LOG_PROCESS;
- else if (::strcasecmp(arg, "step") == 0)
- flag_bits &= ~GDBR_LOG_STEP;
- else if (::strcasecmp(arg, "thread") == 0)
- flag_bits &= ~GDBR_LOG_THREAD;
- else if (::strcasecmp(arg, "verbose") == 0)
- flag_bits &= ~GDBR_LOG_VERBOSE;
- else if (::strncasecmp(arg, "watch", 5) == 0)
- flag_bits &= ~GDBR_LOG_WATCHPOINTS;
- else {
- feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
- ListLogCategories(feedback_strm);
- }
- }
- }
-
- if (flag_bits == 0)
- g_log_enabled = false;
- else
- log->GetMask().Reset(flag_bits);
- }
-
- return;
-}
-
-Log *ProcessGDBRemoteLog::EnableLog(StreamSP &log_stream_sp,
- uint32_t log_options,
- const char **categories,
- Stream *feedback_strm) {
- // Try see if there already is a log - that way we can reuse its settings.
- // We could reuse the log in toto, but we don't know that the stream is the
- // same.
- uint32_t flag_bits = 0;
- if (g_log)
- flag_bits = g_log->GetMask().Get();
-
- // Now make a new log with this stream if one was provided
- if (log_stream_sp) {
- if (g_log)
- g_log->SetStream(log_stream_sp);
- else
- g_log = new Log(log_stream_sp);
- }
-
- if (g_log) {
- bool got_unknown_category = false;
- for (size_t i = 0; categories[i] != NULL; ++i) {
- const char *arg = categories[i];
-
- if (::strcasecmp(arg, "all") == 0)
- flag_bits |= GDBR_LOG_ALL;
- else if (::strcasecmp(arg, "async") == 0)
- flag_bits |= GDBR_LOG_ASYNC;
- else if (::strncasecmp(arg, "break", 5) == 0)
- flag_bits |= GDBR_LOG_BREAKPOINTS;
- else if (::strncasecmp(arg, "comm", 4) == 0)
- flag_bits |= GDBR_LOG_COMM;
- else if (::strcasecmp(arg, "default") == 0)
- flag_bits |= GDBR_LOG_DEFAULT;
- else if (::strcasecmp(arg, "packets") == 0)
- flag_bits |= GDBR_LOG_PACKETS;
- else if (::strcasecmp(arg, "memory") == 0)
- flag_bits |= GDBR_LOG_MEMORY;
- else if (::strcasecmp(arg, "data-short") == 0)
- flag_bits |= GDBR_LOG_MEMORY_DATA_SHORT;
- else if (::strcasecmp(arg, "data-long") == 0)
- flag_bits |= GDBR_LOG_MEMORY_DATA_LONG;
- else if (::strcasecmp(arg, "process") == 0)
- flag_bits |= GDBR_LOG_PROCESS;
- else if (::strcasecmp(arg, "step") == 0)
- flag_bits |= GDBR_LOG_STEP;
- else if (::strcasecmp(arg, "thread") == 0)
- flag_bits |= GDBR_LOG_THREAD;
- else if (::strcasecmp(arg, "verbose") == 0)
- flag_bits |= GDBR_LOG_VERBOSE;
- else if (::strncasecmp(arg, "watch", 5) == 0)
- flag_bits |= GDBR_LOG_WATCHPOINTS;
- else {
- feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
- if (got_unknown_category == false) {
- got_unknown_category = true;
- ListLogCategories(feedback_strm);
- }
- }
- }
- if (flag_bits == 0)
- flag_bits = GDBR_LOG_DEFAULT;
- g_log->GetMask().Reset(flag_bits);
- g_log->GetOptions().Reset(log_options);
- }
- g_log_enabled = true;
- return g_log;
-}
-
-void ProcessGDBRemoteLog::ListLogCategories(Stream *strm) {
- strm->Printf(
- "Logging categories for '%s':\n"
- " all - turn on all available logging categories\n"
- " async - log asynchronous activity\n"
- " break - log breakpoints\n"
- " communication - log communication activity\n"
- " default - enable the default set of logging categories for liblldb\n"
- " packets - log gdb remote packets\n"
- " memory - log memory reads and writes\n"
- " data-short - log memory bytes for memory reads and writes for short "
- "transactions only\n"
- " data-long - log memory bytes for memory reads and writes for all "
- "transactions\n"
- " process - log process events and activities\n"
- " thread - log thread events and activities\n"
- " step - log step related activities\n"
- " verbose - enable verbose logging\n"
- " watch - log watchpoint related activities\n",
- ProcessGDBRemote::GetPluginNameStatic().GetCString());
-}
-
-void ProcessGDBRemoteLog::LogIf(uint32_t mask, const char *format, ...) {
- Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(mask));
- if (log) {
- va_list args;
- va_start(args, format);
- log->VAPrintf(format, args);
- va_end(args);
- }
-}
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h b/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h
index f5e92b450614..3c5801176690 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h
@@ -15,9 +15,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Log.h"
+#include "lldb/Utility/Log.h"
-#define GDBR_LOG_VERBOSE (1u << 0)
#define GDBR_LOG_PROCESS (1u << 1)
#define GDBR_LOG_THREAD (1u << 2)
#define GDBR_LOG_PACKETS (1u << 3)
@@ -37,21 +36,13 @@ namespace lldb_private {
namespace process_gdb_remote {
class ProcessGDBRemoteLog {
+ static Log::Channel g_channel;
+
public:
static void Initialize();
- static Log *GetLogIfAllCategoriesSet(uint32_t mask = 0);
-
- static Log *GetLogIfAnyCategoryIsSet(uint32_t mask);
-
- static void DisableLog(const char **categories, Stream *feedback_strm);
-
- static Log *EnableLog(lldb::StreamSP &log_stream_sp, uint32_t log_options,
- const char **categories, Stream *feedback_strm);
-
- static void ListLogCategories(Stream *strm);
-
- static void LogIf(uint32_t mask, const char *format, ...);
+ static Log *GetLogIfAllCategoriesSet(uint32_t mask) { return g_channel.GetLogIfAll(mask); }
+ static Log *GetLogIfAnyCategoryIsSet(uint32_t mask) { return g_channel.GetLogIfAny(mask); }
};
} // namespace process_gdb_remote
diff --git a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
index ab552145a18b..5197e8f9adfc 100644
--- a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
@@ -11,9 +11,7 @@
#include "lldb/Breakpoint/Watchpoint.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/State.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
@@ -22,6 +20,8 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/UnixSignals.h"
#include "lldb/Target/Unwind.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/StreamString.h"
#include "ProcessGDBRemote.h"
#include "ProcessGDBRemoteLog.h"
@@ -41,18 +41,16 @@ ThreadGDBRemote::ThreadGDBRemote(Process &process, lldb::tid_t tid)
m_dispatch_queue_t(LLDB_INVALID_ADDRESS), m_queue_kind(eQueueKindUnknown),
m_queue_serial_number(LLDB_INVALID_QUEUE_ID),
m_associated_with_libdispatch_queue(eLazyBoolCalculate) {
- ProcessGDBRemoteLog::LogIf(
- GDBR_LOG_THREAD,
- "%p: ThreadGDBRemote::ThreadGDBRemote (pid = %i, tid = 0x%4.4x)", this,
- process.GetID(), GetID());
+ Log *log(GetLogIfAnyCategoriesSet(GDBR_LOG_THREAD));
+ LLDB_LOG(log, "this = {0}, pid = {1}, tid = {2}", this, process.GetID(),
+ GetID());
}
ThreadGDBRemote::~ThreadGDBRemote() {
ProcessSP process_sp(GetProcess());
- ProcessGDBRemoteLog::LogIf(
- GDBR_LOG_THREAD,
- "%p: ThreadGDBRemote::~ThreadGDBRemote (pid = %i, tid = 0x%4.4x)", this,
- process_sp ? process_sp->GetID() : LLDB_INVALID_PROCESS_ID, GetID());
+ Log *log(GetLogIfAnyCategoriesSet(GDBR_LOG_THREAD));
+ LLDB_LOG(log, "this = {0}, pid = {1}, tid = {2}", this,
+ process_sp ? process_sp->GetID() : LLDB_INVALID_PROCESS_ID, GetID());
DestroyThread();
}
diff --git a/source/Plugins/Process/mach-core/CMakeLists.txt b/source/Plugins/Process/mach-core/CMakeLists.txt
index ac54658cf4dc..18f6ff581ea3 100644
--- a/source/Plugins/Process/mach-core/CMakeLists.txt
+++ b/source/Plugins/Process/mach-core/CMakeLists.txt
@@ -1,6 +1,19 @@
include_directories(../Utility)
-add_lldb_library(lldbPluginProcessMachCore
+add_lldb_library(lldbPluginProcessMachCore PLUGIN
ProcessMachCore.cpp
ThreadMachCore.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbHost
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ lldbPluginDynamicLoaderDarwinKernel
+ lldbPluginDynamicLoaderMacOSXDYLD
+ lldbPluginObjectFileMachO
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/Process/mach-core/ProcessMachCore.cpp b/source/Plugins/Process/mach-core/ProcessMachCore.cpp
index f83499cdb233..3b636b9795fd 100644
--- a/source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ b/source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -14,12 +14,11 @@
// C++ Includes
#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/Threading.h"
#include <mutex>
// Other libraries and framework includes
-#include "lldb/Core/DataBuffer.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
@@ -30,6 +29,9 @@
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/Utility/DataBufferLLVM.h"
+#include "lldb/Utility/Log.h"
// Project includes
#include "ProcessMachCore.h"
@@ -65,7 +67,8 @@ lldb::ProcessSP ProcessMachCore::CreateInstance(lldb::TargetSP target_sp,
lldb::ProcessSP process_sp;
if (crash_file) {
const size_t header_size = sizeof(llvm::MachO::mach_header);
- lldb::DataBufferSP data_sp(crash_file->ReadFileContents(0, header_size));
+ auto data_sp =
+ DataBufferLLVM::CreateSliceFromPath(crash_file->GetPath(), header_size, 0);
if (data_sp && data_sp->GetByteSize() == header_size) {
DataExtractor data(data_sp, lldb::eByteOrderLittle, 4);
@@ -288,8 +291,57 @@ Error ProcessMachCore::DoLoadCore() {
m_core_range_infos.Sort();
}
- if (m_dyld_addr == LLDB_INVALID_ADDRESS ||
- m_mach_kernel_addr == LLDB_INVALID_ADDRESS) {
+
+ bool found_main_binary_definitively = false;
+
+ addr_t objfile_binary_addr;
+ UUID objfile_binary_uuid;
+ if (core_objfile->GetCorefileMainBinaryInfo (objfile_binary_addr, objfile_binary_uuid))
+ {
+ if (objfile_binary_addr != LLDB_INVALID_ADDRESS)
+ {
+ m_mach_kernel_addr = objfile_binary_addr;
+ found_main_binary_definitively = true;
+ if (log)
+ log->Printf ("ProcessMachCore::DoLoadCore: using kernel address 0x%" PRIx64
+ " from LC_NOTE 'main bin spec' load command.", m_mach_kernel_addr);
+ }
+ }
+
+ // This checks for the presence of an LC_IDENT string in a core file;
+ // LC_IDENT is very obsolete and should not be used in new code, but
+ // if the load command is present, let's use the contents.
+ std::string corefile_identifier = core_objfile->GetIdentifierString();
+ if (found_main_binary_definitively == false
+ && corefile_identifier.find("Darwin Kernel") != std::string::npos) {
+ UUID uuid;
+ addr_t addr = LLDB_INVALID_ADDRESS;
+ if (corefile_identifier.find("UUID=") != std::string::npos) {
+ size_t p = corefile_identifier.find("UUID=") + strlen("UUID=");
+ std::string uuid_str = corefile_identifier.substr(p, 36);
+ uuid.SetFromCString(uuid_str.c_str());
+ }
+ if (corefile_identifier.find("stext=") != std::string::npos) {
+ size_t p = corefile_identifier.find("stext=") + strlen("stext=");
+ if (corefile_identifier[p] == '0' && corefile_identifier[p + 1] == 'x') {
+ errno = 0;
+ addr = ::strtoul(corefile_identifier.c_str() + p, NULL, 16);
+ if (errno != 0 || addr == 0)
+ addr = LLDB_INVALID_ADDRESS;
+ }
+ }
+ if (uuid.IsValid() && addr != LLDB_INVALID_ADDRESS) {
+ m_mach_kernel_addr = addr;
+ found_main_binary_definitively = true;
+ if (log)
+ log->Printf("ProcessMachCore::DoLoadCore: Using the kernel address 0x%" PRIx64
+ " from LC_IDENT/LC_NOTE 'kern ver str' string: '%s'", addr, corefile_identifier.c_str());
+ }
+ }
+
+ if (found_main_binary_definitively == false
+ && (m_dyld_addr == LLDB_INVALID_ADDRESS
+ || m_mach_kernel_addr == LLDB_INVALID_ADDRESS)) {
// We need to locate the main executable in the memory ranges
// we have in the core file. We need to search for both a user-process dyld
// binary
@@ -314,7 +366,8 @@ Error ProcessMachCore::DoLoadCore() {
}
}
- if (m_mach_kernel_addr != LLDB_INVALID_ADDRESS) {
+ if (found_main_binary_definitively == false
+ && m_mach_kernel_addr != LLDB_INVALID_ADDRESS) {
// In the case of multiple kernel images found in the core file via
// exhaustive
// search, we may not pick the correct one. See if the
@@ -579,9 +632,9 @@ Error ProcessMachCore::GetMemoryRegionInfo(addr_t load_addr,
void ProcessMachCore::Clear() { m_thread_list.Clear(); }
void ProcessMachCore::Initialize() {
- static std::once_flag g_once_flag;
+ static llvm::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
+ llvm::call_once(g_once_flag, []() {
PluginManager::RegisterPlugin(GetPluginNameStatic(),
GetPluginDescriptionStatic(), CreateInstance);
});
diff --git a/source/Plugins/Process/mach-core/ProcessMachCore.h b/source/Plugins/Process/mach-core/ProcessMachCore.h
index 7094eb33110b..99bb4a60ff39 100644
--- a/source/Plugins/Process/mach-core/ProcessMachCore.h
+++ b/source/Plugins/Process/mach-core/ProcessMachCore.h
@@ -17,9 +17,9 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
#include "lldb/Target/Process.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
class ThreadKDP;
diff --git a/source/Plugins/Process/mach-core/ThreadMachCore.cpp b/source/Plugins/Process/mach-core/ThreadMachCore.cpp
index 828b705edf57..3917b99bd63d 100644
--- a/source/Plugins/Process/mach-core/ThreadMachCore.cpp
+++ b/source/Plugins/Process/mach-core/ThreadMachCore.cpp
@@ -13,15 +13,15 @@
#include "lldb/Breakpoint/Watchpoint.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/State.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Unwind.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/StreamString.h"
#include "ProcessMachCore.h"
//#include "RegisterContextKDP_arm.h"
diff --git a/source/Plugins/Process/minidump/CMakeLists.txt b/source/Plugins/Process/minidump/CMakeLists.txt
index ddc89cbd92c1..61ce16830c9b 100644
--- a/source/Plugins/Process/minidump/CMakeLists.txt
+++ b/source/Plugins/Process/minidump/CMakeLists.txt
@@ -1,10 +1,19 @@
include_directories(../Utility)
-add_lldb_library(lldbPluginProcessMinidump
+add_lldb_library(lldbPluginProcessMinidump PLUGIN
MinidumpTypes.cpp
MinidumpParser.cpp
RegisterContextMinidump_x86_32.cpp
RegisterContextMinidump_x86_64.cpp
ProcessMinidump.cpp
ThreadMinidump.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbTarget
+ lldbUtility
+ lldbPluginProcessUtility
+ lldbPluginProcessElfCore
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/Process/minidump/MinidumpParser.h b/source/Plugins/Process/minidump/MinidumpParser.h
index 67523a72ad11..189aeb3d64e6 100644
--- a/source/Plugins/Process/minidump/MinidumpParser.h
+++ b/source/Plugins/Process/minidump/MinidumpParser.h
@@ -16,8 +16,8 @@
// Other libraries and framework includes
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataBuffer.h"
-#include "lldb/Core/Error.h"
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/Utility/Error.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
diff --git a/source/Plugins/Process/minidump/MinidumpTypes.h b/source/Plugins/Process/minidump/MinidumpTypes.h
index 46871a1b84d8..42de7eaaca03 100644
--- a/source/Plugins/Process/minidump/MinidumpTypes.h
+++ b/source/Plugins/Process/minidump/MinidumpTypes.h
@@ -13,7 +13,7 @@
// Project includes
// Other libraries and framework includes
-#include "lldb/Core/Error.h"
+#include "lldb/Utility/Error.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitmaskEnum.h"
diff --git a/source/Plugins/Process/minidump/ProcessMinidump.cpp b/source/Plugins/Process/minidump/ProcessMinidump.cpp
index 46d8df8b16f1..f3f4664ad6e1 100644
--- a/source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ b/source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -12,8 +12,6 @@
#include "ThreadMinidump.h"
// Other libraries and framework includes
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
@@ -23,7 +21,12 @@
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/UnixSignals.h"
+#include "lldb/Utility/DataBufferLLVM.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
+
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Threading.h"
// C includes
// C++ includes
@@ -48,20 +51,25 @@ lldb::ProcessSP ProcessMinidump::CreateInstance(lldb::TargetSP target_sp,
lldb::ProcessSP process_sp;
// Read enough data for the Minidump header
- const size_t header_size = sizeof(MinidumpHeader);
- lldb::DataBufferSP data_sp(crash_file->MemoryMapFileContents(0, header_size));
- if (!data_sp)
+ constexpr size_t header_size = sizeof(MinidumpHeader);
+ auto DataPtr =
+ DataBufferLLVM::CreateSliceFromPath(crash_file->GetPath(), header_size, 0);
+ if (!DataPtr)
return nullptr;
+ assert(DataPtr->GetByteSize() == header_size);
+
// first, only try to parse the header, beacuse we need to be fast
- llvm::ArrayRef<uint8_t> header_data(data_sp->GetBytes(), header_size);
- const MinidumpHeader *header = MinidumpHeader::Parse(header_data);
+ llvm::ArrayRef<uint8_t> HeaderBytes = DataPtr->GetData();
+ const MinidumpHeader *header = MinidumpHeader::Parse(HeaderBytes);
+ if (header == nullptr)
+ return nullptr;
- if (data_sp->GetByteSize() != header_size || header == nullptr)
+ auto AllData = DataBufferLLVM::CreateSliceFromPath(crash_file->GetPath(), -1, 0);
+ if (!AllData)
return nullptr;
- lldb::DataBufferSP all_data_sp(crash_file->MemoryMapFileContents());
- auto minidump_parser = MinidumpParser::Create(all_data_sp);
+ auto minidump_parser = MinidumpParser::Create(AllData);
// check if the parser object is valid
if (!minidump_parser)
return nullptr;
@@ -92,9 +100,9 @@ ProcessMinidump::~ProcessMinidump() {
}
void ProcessMinidump::Initialize() {
- static std::once_flag g_once_flag;
+ static llvm::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
+ llvm::call_once(g_once_flag, []() {
PluginManager::RegisterPlugin(GetPluginNameStatic(),
GetPluginDescriptionStatic(),
ProcessMinidump::CreateInstance);
diff --git a/source/Plugins/Process/minidump/ProcessMinidump.h b/source/Plugins/Process/minidump/ProcessMinidump.h
index 78eadc809a4d..62407f927551 100644
--- a/source/Plugins/Process/minidump/ProcessMinidump.h
+++ b/source/Plugins/Process/minidump/ProcessMinidump.h
@@ -15,11 +15,11 @@
#include "MinidumpTypes.h"
// Other libraries and framework includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Error.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Error.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
diff --git a/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp b/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp
index 7f3768216f3a..7605f8b143af 100644
--- a/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp
+++ b/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp
@@ -11,7 +11,7 @@
#include "RegisterContextMinidump_x86_32.h"
// Other libraries and framework includes
-#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Utility/DataBufferHeap.h"
// C includes
// C++ includes
diff --git a/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp b/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
index 881c26a5774a..ba1cb6dbf3ef 100644
--- a/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
+++ b/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
@@ -11,7 +11,7 @@
#include "RegisterContextMinidump_x86_64.h"
// Other libraries and framework includes
-#include "lldb/Core/DataBufferHeap.h"
+#include "lldb/Utility/DataBufferHeap.h"
// C includes
// C++ includes
diff --git a/source/Plugins/Process/minidump/ThreadMinidump.cpp b/source/Plugins/Process/minidump/ThreadMinidump.cpp
index e42108b9261a..9c21cc92376f 100644
--- a/source/Plugins/Process/minidump/ThreadMinidump.cpp
+++ b/source/Plugins/Process/minidump/ThreadMinidump.cpp
@@ -20,12 +20,12 @@
#include "Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Log.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Unwind.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Log.h"
// C Includes
// C++ Includes
diff --git a/source/Plugins/ScriptInterpreter/None/CMakeLists.txt b/source/Plugins/ScriptInterpreter/None/CMakeLists.txt
index 5692d2f90710..7e7dd5896f7c 100644
--- a/source/Plugins/ScriptInterpreter/None/CMakeLists.txt
+++ b/source/Plugins/ScriptInterpreter/None/CMakeLists.txt
@@ -1,3 +1,7 @@
-add_lldb_library(lldbPluginScriptInterpreterNone
+add_lldb_library(lldbPluginScriptInterpreterNone PLUGIN
ScriptInterpreterNone.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbInterpreter
) \ No newline at end of file
diff --git a/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp b/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
index 2f04ec97a9ff..9ec9f4344613 100644
--- a/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
+++ b/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
@@ -10,10 +10,12 @@
#include "ScriptInterpreterNone.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StringList.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StringList.h"
+
+#include "llvm/Support/Threading.h"
#include <mutex>
@@ -39,9 +41,9 @@ void ScriptInterpreterNone::ExecuteInterpreterLoop() {
}
void ScriptInterpreterNone::Initialize() {
- static std::once_flag g_once_flag;
+ static llvm::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
+ llvm::call_once(g_once_flag, []() {
PluginManager::RegisterPlugin(GetPluginNameStatic(),
GetPluginDescriptionStatic(),
lldb::eScriptLanguageNone, CreateInstance);
diff --git a/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt b/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
index 71f5807b6f62..c337fc7b5874 100644
--- a/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
+++ b/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
@@ -1,5 +1,15 @@
-add_lldb_library(lldbPluginScriptInterpreterPython
+add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN
PythonDataObjects.cpp
PythonExceptionState.cpp
ScriptInterpreterPython.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbDataFormatters
+ lldbHost
+ lldbInterpreter
+ lldbTarget
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
index f3453f2d011d..966bdff3ad95 100644
--- a/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -17,10 +17,10 @@
#include "PythonDataObjects.h"
#include "ScriptInterpreterPython.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Host/File.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
+#include "lldb/Utility/Stream.h"
#include "llvm/Support/ConvertUTF.h"
diff --git a/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
index b84996c928da..e613e3d6aa6c 100644
--- a/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
+++ b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
@@ -19,11 +19,12 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Flags.h"
+#include "lldb/Utility/Flags.h"
+
#include "lldb/Core/StructuredData.h"
#include "lldb/Host/File.h"
#include "lldb/Interpreter/OptionValue.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-defines.h"
#include "llvm/ADT/ArrayRef.h"
diff --git a/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index 357b48e53c48..cfab9b33e662 100644
--- a/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -51,6 +51,7 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FileSystem.h"
using namespace lldb;
using namespace lldb_private;
@@ -142,14 +143,9 @@ public:
~InitializePythonRAII() {
if (m_was_already_initialized) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT |
- LIBLLDB_LOG_VERBOSE));
-
- if (log) {
- log->Printf("Releasing PyGILState. Returning to state = %slocked\n",
- m_was_already_initialized == PyGILState_UNLOCKED ? "un"
- : "");
- }
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT));
+ LLDB_LOGV(log, "Releasing PyGILState. Returning to state = {0}locked",
+ m_was_already_initialized == PyGILState_UNLOCKED ? "un" : "");
PyGILState_Release(m_gil_state);
} else {
// We initialized the threads in this function, just unlock the GIL.
@@ -174,15 +170,12 @@ private:
void InitializeThreadsPrivate() {
if (PyEval_ThreadsInitialized()) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT |
- LIBLLDB_LOG_VERBOSE));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT));
m_was_already_initialized = true;
m_gil_state = PyGILState_Ensure();
- if (log) {
- log->Printf("Ensured PyGILState. Previous state = %slocked\n",
- m_gil_state == PyGILState_UNLOCKED ? "un" : "");
- }
+ LLDB_LOGV(log, "Ensured PyGILState. Previous state = {0}locked\n",
+ m_gil_state == PyGILState_UNLOCKED ? "un" : "");
return;
}
@@ -212,12 +205,10 @@ ScriptInterpreterPython::Locker::Locker(ScriptInterpreterPython *py_interpreter,
}
bool ScriptInterpreterPython::Locker::DoAcquireLock() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT |
- LIBLLDB_LOG_VERBOSE));
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT));
m_GILState = PyGILState_Ensure();
- if (log)
- log->Printf("Ensured PyGILState. Previous state = %slocked\n",
- m_GILState == PyGILState_UNLOCKED ? "un" : "");
+ LLDB_LOGV(log, "Ensured PyGILState. Previous state = {0}locked",
+ m_GILState == PyGILState_UNLOCKED ? "un" : "");
// we need to save the thread state when we first start the command
// because we might decide to interrupt it while some action is taking
@@ -239,11 +230,9 @@ bool ScriptInterpreterPython::Locker::DoInitSession(uint16_t on_entry_flags,
}
bool ScriptInterpreterPython::Locker::DoFreeLock() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT |
- LIBLLDB_LOG_VERBOSE));
- if (log)
- log->Printf("Releasing PyGILState. Returning to state = %slocked\n",
- m_GILState == PyGILState_UNLOCKED ? "un" : "");
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT));
+ LLDB_LOGV(log, "Releasing PyGILState. Returning to state = {0}locked",
+ m_GILState == PyGILState_UNLOCKED ? "un" : "");
PyGILState_Release(m_GILState);
m_python_interpreter->DecrementLockCount();
return true;
@@ -338,9 +327,9 @@ ScriptInterpreterPython::~ScriptInterpreterPython() {
}
void ScriptInterpreterPython::Initialize() {
- static std::once_flag g_once_flag;
+ static llvm::once_flag g_once_flag;
- std::call_once(g_once_flag, []() {
+ llvm::call_once(g_once_flag, []() {
PluginManager::RegisterPlugin(GetPluginNameStatic(),
GetPluginDescriptionStatic(),
lldb::eScriptLanguagePython, CreateInstance);
@@ -2587,9 +2576,13 @@ bool ScriptInterpreterPython::LoadScriptingModule(
Locker::NoSTDIN,
Locker::FreeAcquiredLock |
(init_session ? Locker::TearDownSession : 0));
+ namespace fs = llvm::sys::fs;
+ fs::file_status st;
+ std::error_code ec = status(target_file.GetPath(), st);
- if (target_file.GetFileType() == FileSpec::eFileTypeInvalid ||
- target_file.GetFileType() == FileSpec::eFileTypeUnknown) {
+ if (ec || st.type() == fs::file_type::status_error ||
+ st.type() == fs::file_type::type_unknown ||
+ st.type() == fs::file_type::file_not_found) {
// if not a valid file of any sort, check if it might be a filename still
// dot can't be used but / and \ can, and if either is found, reject
if (strchr(pathname, '\\') || strchr(pathname, '/')) {
@@ -2598,9 +2591,7 @@ bool ScriptInterpreterPython::LoadScriptingModule(
}
basename = pathname; // not a filename, probably a package of some sort,
// let it go through
- } else if (target_file.GetFileType() == FileSpec::eFileTypeDirectory ||
- target_file.GetFileType() == FileSpec::eFileTypeRegular ||
- target_file.GetFileType() == FileSpec::eFileTypeSymbolicLink) {
+ } else if (is_directory(st) || is_regular_file(st)) {
std::string directory = target_file.GetDirectory().GetCString();
replace_all(directory, "\\", "\\\\");
replace_all(directory, "'", "\\'");
diff --git a/source/Plugins/StructuredData/DarwinLog/CMakeLists.txt b/source/Plugins/StructuredData/DarwinLog/CMakeLists.txt
index ce0e21b4ed33..4df391276c00 100644
--- a/source/Plugins/StructuredData/DarwinLog/CMakeLists.txt
+++ b/source/Plugins/StructuredData/DarwinLog/CMakeLists.txt
@@ -1,5 +1,10 @@
-list(APPEND SOURCES
+add_lldb_library(lldbPluginStructuredDataDarwinLog PLUGIN
StructuredDataDarwinLog.cpp
- )
-add_lldb_library(lldbPluginStructuredDataDarwinLog ${SOURCES})
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbHost
+ lldbInterpreter
+ lldbTarget
+ )
diff --git a/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp b/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
index e459268f5448..041d827d526b 100644
--- a/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
+++ b/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
@@ -17,10 +17,9 @@
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegularExpression.h"
+#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandObjectMultiword.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -30,6 +29,8 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadPlanCallOnFunctionExit.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegularExpression.h"
#define DARWIN_LOG_TYPE_VALUE "DarwinLog"
@@ -746,8 +747,8 @@ private:
int MatchAttributeIndex(llvm::StringRef attribute_name) const {
for (const auto &Item : llvm::enumerate(s_filter_attributes)) {
- if (attribute_name == Item.Value)
- return Item.Index;
+ if (attribute_name == Item.value())
+ return Item.index();
}
// We didn't match anything.
diff --git a/source/Plugins/SymbolFile/DWARF/CMakeLists.txt b/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
index 5ce20cc0989c..fb468440f9e0 100644
--- a/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
+++ b/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_lldb_library(lldbPluginSymbolFileDWARF
+add_lldb_library(lldbPluginSymbolFileDWARF PLUGIN
DIERef.cpp
DWARFAbbreviationDeclaration.cpp
DWARFASTParserClang.cpp
@@ -32,4 +32,20 @@ add_lldb_library(lldbPluginSymbolFileDWARF
SymbolFileDWARFDwo.cpp
SymbolFileDWARFDebugMap.cpp
UniqueDWARFASTType.cpp
+
+ LINK_LIBS
+ clangAST
+ clangBasic
+ lldbCore
+ lldbExpression
+ lldbHost
+ lldbInterpreter
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ lldbPluginObjCLanguage
+ lldbPluginCPlusPlusLanguage
+ lldbPluginExpressionParserClang
+ LINK_COMPONENTS
+ Support
)
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index c064d61d71d4..e2902d5ef787 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -21,9 +21,7 @@
#include "UniqueDWARFASTType.h"
#include "Plugins/Language/ObjC/ObjCLanguage.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Value.h"
#include "lldb/Host/Host.h"
#include "lldb/Interpreter/Args.h"
@@ -38,6 +36,8 @@
#include "lldb/Symbol/TypeMap.h"
#include "lldb/Target/Language.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp b/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp
index 0cf7ff2b938f..2e5be393dea2 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp
@@ -2,14 +2,14 @@
#include "DWARFASTParserOCaml.h"
-#include "lldb/Core/Error.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/TypeList.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
index 6d3ff8e35910..ef499a6d5615 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -10,15 +10,16 @@
#include "DWARFCompileUnit.h"
#include "Plugins/Language/ObjC/ObjCLanguage.h"
+#include "lldb/Core/DumpDataExtractor.h"
#include "lldb/Core/Mangled.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StreamString.h"
#include "DWARFDIECollection.h"
#include "DWARFDebugAbbrev.h"
@@ -256,16 +257,15 @@ size_t DWARFCompileUnit::ExtractDIEsIfNeeded(bool cu_die_only) {
m_die_array.end());
exact_size_die_array.swap(m_die_array);
}
- Log *verbose_log(
- LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO | DWARF_LOG_VERBOSE));
- if (verbose_log) {
+ Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
+ if (log && log->GetVerbose()) {
StreamString strm;
Dump(&strm);
if (m_die_array.empty())
strm.Printf("error: no DIE for compile unit");
else
m_die_array[0].Dump(m_dwarf2Data, this, strm, UINT32_MAX);
- verbose_log->PutString(strm.GetString());
+ log->PutString(strm.GetString());
}
if (!m_dwo_symbol_file)
@@ -324,18 +324,14 @@ bool DWARFCompileUnit::Verify(Stream *s) const {
bool abbr_offset_OK =
m_dwarf2Data->get_debug_abbrev_data().ValidOffset(GetAbbrevOffset());
bool addr_size_OK = ((m_addr_size == 4) || (m_addr_size == 8));
- bool verbose = s->GetVerbose();
if (valid_offset && length_OK && version_OK && addr_size_OK &&
abbr_offset_OK) {
- if (verbose)
- s->Printf(" 0x%8.8x: OK\n", m_offset);
return true;
} else {
s->Printf(" 0x%8.8x: ", m_offset);
-
- m_dwarf2Data->get_debug_info_data().Dump(s, m_offset, lldb::eFormatHex, 1,
- Size(), 32, LLDB_INVALID_ADDRESS,
- 0, 0);
+ DumpDataExtractor(m_dwarf2Data->get_debug_info_data(), s, m_offset,
+ lldb::eFormatHex, 1, Size(), 32, LLDB_INVALID_ADDRESS, 0,
+ 0);
s->EOL();
if (valid_offset) {
if (!length_OK)
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp
index 5fb63589591e..1e5bf619f798 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp
@@ -11,7 +11,7 @@
#include <algorithm>
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb_private;
using namespace std;
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h b/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
index 62ddbe8ecd5a..46d09f1ca237 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
@@ -11,12 +11,12 @@
#define liblldb_DWARFDataExtractor_h_
// Other libraries and framework includes.
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/dwarf.h"
+#include "lldb/Utility/DataExtractor.h"
namespace lldb_private {
-class DWARFDataExtractor : public lldb_private::DataExtractor {
+class DWARFDataExtractor : public DataExtractor {
public:
DWARFDataExtractor() : DataExtractor(), m_is_dwarf64(false) {}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
index fe6df913b762..d681925daeac 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
@@ -9,7 +9,7 @@
#include "DWARFDebugAbbrev.h"
#include "DWARFDataExtractor.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
index 06b46f0569eb..cecb69c8fb46 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
@@ -10,7 +10,7 @@
#include "DWARFDebugArangeSet.h"
#include "SymbolFileDWARF.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/Stream.h"
#include <assert.h>
using namespace lldb_private;
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
index 5e71e9dfcbb3..d571c512658e 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
@@ -14,9 +14,9 @@
#include <algorithm>
-#include "lldb/Core/Log.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/Timer.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Stream.h"
#include "DWARFCompileUnit.h"
#include "DWARFDebugInfo.h"
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
index 9dc656d79326..eff9850d435d 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -12,10 +12,10 @@
#include <algorithm>
#include <set>
-#include "lldb/Core/RegularExpression.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Host/PosixApi.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/Stream.h"
#include "DWARFCompileUnit.h"
#include "DWARFDebugAranges.h"
@@ -430,10 +430,6 @@ static dw_offset_t DumpCallback(SymbolFileDWARF *dwarf2Data,
} else {
// See if the DIE is in this compile unit?
if (cu && dumpInfo->die_offset < cu->GetNextCompileUnitOffset()) {
- // This DIE is in this compile unit!
- if (s->GetVerbose())
- cu->Dump(s); // Dump the compile unit for the DIE in verbose mode
-
return next_offset;
// // We found our compile unit that contains our DIE, just skip to
// dumping the requested DIE...
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
index a05a8886bb48..be4e18b12be0 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
@@ -15,7 +15,7 @@
#include "DWARFDIE.h"
#include "SymbolFileDWARF.h"
-#include "lldb/lldb-private.h"
+#include "lldb/Core/STLUtils.h"
#include "lldb/lldb-private.h"
typedef std::multimap<const char *, dw_offset_t, CStringCompareFunctionObject>
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index a824c4ac6afe..e00eda4f35c5 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -14,9 +14,9 @@
#include <algorithm>
#include "lldb/Core/Module.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Expression/DWARFExpression.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Utility/Stream.h"
#include "DWARFCompileUnit.h"
#include "DWARFDIECollection.h"
@@ -666,13 +666,9 @@ void DWARFDebugInfoEntry::DumpAttribute(
SymbolFileDWARF *dwarf2Data, const DWARFCompileUnit *cu,
const DWARFDataExtractor &debug_info_data, lldb::offset_t *offset_ptr,
Stream &s, dw_attr_t attr, dw_form_t form) {
- bool verbose = s.GetVerbose();
bool show_form = s.GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowForm);
- if (verbose)
- s.Offset(*offset_ptr);
- else
- s.Printf(" ");
+ s.Printf(" ");
s.Indent(DW_AT_value_to_name(attr));
if (show_form) {
@@ -694,35 +690,18 @@ void DWARFDebugInfoEntry::DumpAttribute(
s.PutCString("( ");
- // Always dump form value if verbose is enabled
- if (verbose) {
- form_value.Dump(s);
- }
-
// Check to see if we have any special attribute formatters
switch (attr) {
case DW_AT_stmt_list:
- if (verbose)
- s.PutCString(" ( ");
s.Printf("0x%8.8" PRIx64, form_value.Unsigned());
- if (verbose)
- s.PutCString(" )");
break;
case DW_AT_language:
- if (verbose)
- s.PutCString(" ( ");
s.PutCString(DW_LANG_value_to_name(form_value.Unsigned()));
- if (verbose)
- s.PutCString(" )");
break;
case DW_AT_encoding:
- if (verbose)
- s.PutCString(" ( ");
s.PutCString(DW_ATE_value_to_name(form_value.Unsigned()));
- if (verbose)
- s.PutCString(" )");
break;
case DW_AT_frame_base:
@@ -730,32 +709,20 @@ void DWARFDebugInfoEntry::DumpAttribute(
case DW_AT_data_member_location: {
const uint8_t *blockData = form_value.BlockData();
if (blockData) {
- if (!verbose)
- form_value.Dump(s);
-
// Location description is inlined in data in the form value
DWARFDataExtractor locationData(debug_info_data,
(*offset_ptr) - form_value.Unsigned(),
form_value.Unsigned());
- if (verbose)
- s.PutCString(" ( ");
DWARFExpression::PrintDWARFExpression(
s, locationData, DWARFCompileUnit::GetAddressByteSize(cu), 4, false);
- if (verbose)
- s.PutCString(" )");
} else {
// We have a location list offset as the value that is
// the offset into the .debug_loc section that describes
// the value over it's lifetime
uint64_t debug_loc_offset = form_value.Unsigned();
if (dwarf2Data) {
- if (!verbose)
- form_value.Dump(s);
DWARFExpression::PrintDWARFLocationList(
s, cu, dwarf2Data->get_debug_loc_data(), debug_loc_offset);
- } else {
- if (!verbose)
- form_value.Dump(s);
}
}
} break;
@@ -765,25 +732,17 @@ void DWARFDebugInfoEntry::DumpAttribute(
uint64_t abstract_die_offset = form_value.Reference();
form_value.Dump(s);
// *ostrm_ptr << HEX32 << abstract_die_offset << " ( ";
- if (verbose)
- s.PutCString(" ( ");
GetName(dwarf2Data, cu, abstract_die_offset, s);
- if (verbose)
- s.PutCString(" )");
} break;
case DW_AT_type: {
uint64_t type_die_offset = form_value.Reference();
- if (!verbose)
- form_value.Dump(s);
s.PutCString(" ( ");
AppendTypeName(dwarf2Data, cu, type_die_offset, s);
s.PutCString(" )");
} break;
case DW_AT_ranges: {
- if (!verbose)
- form_value.Dump(s);
lldb::offset_t ranges_offset = form_value.Unsigned();
dw_addr_t base_addr = cu ? cu->GetBaseAddress() : 0;
if (dwarf2Data)
@@ -792,8 +751,6 @@ void DWARFDebugInfoEntry::DumpAttribute(
} break;
default:
- if (!verbose)
- form_value.Dump(s);
break;
}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
index bce21c44b73e..077675be2271 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
@@ -13,10 +13,10 @@
#include <assert.h>
#include "lldb/Core/FileSpecList.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Timer.h"
#include "lldb/Host/Host.h"
+#include "lldb/Utility/Log.h"
#include "LogChannelDWARF.h"
#include "SymbolFileDWARF.h"
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.cpp
index d56463039a19..19074b8865ff 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.cpp
@@ -12,7 +12,7 @@
#include "DWARFDebugMacinfoEntry.h"
#include "SymbolFileDWARF.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb_private;
using namespace std;
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp
index 45498590236f..f078fbd44f2f 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp
@@ -9,7 +9,7 @@
#include "DWARFDebugMacinfoEntry.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/Stream.h"
using namespace lldb_private;
using namespace std;
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp
index d4281bac79a1..81e27f2bc95e 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp
@@ -9,8 +9,8 @@
#include "DWARFDebugPubnames.h"
-#include "lldb/Core/Stream.h"
#include "lldb/Core/Timer.h"
+#include "lldb/Utility/Stream.h"
#include "DWARFCompileUnit.h"
#include "DWARFDIECollection.h"
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.cpp
index 4518d65811b5..21e2482783a1 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.cpp
@@ -9,8 +9,8 @@
#include "DWARFDebugPubnamesSet.h"
-#include "lldb/Core/Log.h"
-#include "lldb/Core/RegularExpression.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegularExpression.h"
#include "SymbolFileDWARF.h"
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.h
index 9654ee3d6da7..6e7d3f38aa85 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.h
@@ -11,6 +11,7 @@
#define SymbolFileDWARF_DWARFDebugPubnamesSet_h_
#include "SymbolFileDWARF.h"
+#include <map>
#include <string>
#include <vector>
#if __cplusplus >= 201103L || defined(_MSC_VER)
@@ -19,6 +20,8 @@
#include <ext/hash_map>
#endif
+#include "lldb/Core/STLUtils.h"
+
class DWARFDebugPubnamesSet {
public:
struct Header {
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
index ef3566855298..515c083fedb0 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
@@ -9,7 +9,7 @@
#include "DWARFDebugRanges.h"
#include "SymbolFileDWARF.h"
-#include "lldb/Core/Stream.h"
+#include "lldb/Utility/Stream.h"
#include <assert.h>
using namespace lldb_private;
@@ -82,7 +82,6 @@ void DWARFDebugRanges::Dump(Stream &s,
lldb::offset_t *offset_ptr,
dw_addr_t cu_base_addr) {
uint32_t addr_size = s.GetAddressByteSize();
- bool verbose = s.GetVerbose();
dw_addr_t base_addr = cu_base_addr;
while (
@@ -95,10 +94,6 @@ void DWARFDebugRanges::Dump(Stream &s,
begin = LLDB_INVALID_ADDRESS;
s.Indent();
- if (verbose) {
- s.AddressRange(begin, end, sizeof(dw_addr_t), " offsets = ");
- }
-
if (begin == 0 && end == 0) {
s.PutCString(" End");
break;
@@ -111,8 +106,7 @@ void DWARFDebugRanges::Dump(Stream &s,
dw_addr_t begin_addr = begin + base_addr;
dw_addr_t end_addr = end + base_addr;
- s.AddressRange(begin_addr, end_addr, sizeof(dw_addr_t),
- verbose ? " ==> addrs = " : NULL);
+ s.AddressRange(begin_addr, end_addr, sizeof(dw_addr_t), NULL);
}
}
}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h b/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
index 0d0a5a317262..1f3c59768fdf 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
@@ -15,7 +15,7 @@
#include <string>
#include <vector>
// Other libraries and framework includes
-#include "lldb/Core/ConstString.h"
+#include "lldb/Utility/ConstString.h"
// Project includes
#include "DWARFDefines.h"
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp
index c5260bb1cb1a..f0d66720c55c 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
#include "DWARFDefines.h"
-#include "lldb/Core/ConstString.h"
+#include "lldb/Utility/ConstString.h"
#include <cstdio>
#include <cstring>
#include <string>
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
index 39c52a8a5e57..0853671ee874 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -9,8 +9,8 @@
#include <assert.h>
-#include "lldb/Core/Stream.h"
#include "lldb/Core/dwarf.h"
+#include "lldb/Utility/Stream.h"
#include "DWARFCompileUnit.h"
#include "DWARFFormValue.h"
@@ -406,8 +406,6 @@ void DWARFFormValue::Dump(Stream &s) const {
uint64_t uvalue = Unsigned();
bool cu_relative_offset = false;
- bool verbose = s.GetVerbose();
-
switch (m_form) {
case DW_FORM_addr:
s.Address(uvalue, sizeof(uint64_t));
@@ -476,8 +474,6 @@ void DWARFFormValue::Dump(Stream &s) const {
case DW_FORM_strp: {
const char *dbg_str = AsCString();
if (dbg_str) {
- if (verbose)
- s.Printf(" .debug_str[0x%8.8x] = ", (uint32_t)uvalue);
s.QuotedCString(dbg_str);
} else {
s.PutHex32(uvalue);
@@ -496,28 +492,18 @@ void DWARFFormValue::Dump(Stream &s) const {
}
case DW_FORM_ref1:
cu_relative_offset = true;
- if (verbose)
- s.Printf("cu + 0x%2.2x", (uint8_t)uvalue);
break;
case DW_FORM_ref2:
cu_relative_offset = true;
- if (verbose)
- s.Printf("cu + 0x%4.4x", (uint16_t)uvalue);
break;
case DW_FORM_ref4:
cu_relative_offset = true;
- if (verbose)
- s.Printf("cu + 0x%4.4x", (uint32_t)uvalue);
break;
case DW_FORM_ref8:
cu_relative_offset = true;
- if (verbose)
- s.Printf("cu + 0x%8.8" PRIx64, uvalue);
break;
case DW_FORM_ref_udata:
cu_relative_offset = true;
- if (verbose)
- s.Printf("cu + 0x%" PRIx64, uvalue);
break;
// All DW_FORM_indirect attributes should be resolved prior to calling this
@@ -535,9 +521,6 @@ void DWARFFormValue::Dump(Stream &s) const {
if (cu_relative_offset) {
assert(m_cu); // CU must be valid for DW_FORM_ref forms that are compile
// unit relative or we will get this wrong
- if (verbose)
- s.PutCString(" => ");
-
s.Printf("{0x%8.8" PRIx64 "}", uvalue + m_cu->GetOffset());
}
}
diff --git a/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h b/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
index c1cb30b60045..959517529e52 100644
--- a/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
+++ b/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
@@ -13,8 +13,8 @@
#include <vector>
#include "lldb/Core/MappedHash.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/dwarf.h"
+#include "lldb/Utility/RegularExpression.h"
#include "lldb/lldb-defines.h"
#include "DWARFDefines.h"
diff --git a/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp b/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
index 1385e3dd28de..0b06713f9543 100644
--- a/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
+++ b/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
@@ -9,195 +9,35 @@
#include "LogChannelDWARF.h"
-#include "SymbolFileDWARF.h"
-#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/StreamFile.h"
-#include "lldb/Interpreter/Args.h"
-
-using namespace lldb;
using namespace lldb_private;
-// when the one and only logging channel is enabled, then this will be non NULL.
-static LogChannelDWARF *g_log_channel = NULL;
-
-LogChannelDWARF::LogChannelDWARF() : LogChannel() {}
+static constexpr Log::Category g_categories[] = {
+ {{"aranges"},
+ {"log the parsing of .debug_aranges"},
+ DWARF_LOG_DEBUG_ARANGES},
+ {{"comp"},
+ {"log insertions of object files into DWARF debug maps"},
+ DWARF_LOG_TYPE_COMPLETION},
+ {{"info"}, {"log the parsing of .debug_info"}, DWARF_LOG_DEBUG_INFO},
+ {{"line"}, {"log the parsing of .debug_line"}, DWARF_LOG_DEBUG_LINE},
+ {{"lookups"},
+ {"log any lookups that happen by name, regex, or address"},
+ DWARF_LOG_LOOKUPS},
+ {{"map"},
+ {"log struct/unions/class type completions"},
+ DWARF_LOG_DEBUG_MAP},
+ {{"pubnames"},
+ {"log the parsing of .debug_pubnames"},
+ DWARF_LOG_DEBUG_PUBNAMES},
+ {{"pubtypes"},
+ {"log the parsing of .debug_pubtypes"},
+ DWARF_LOG_DEBUG_PUBTYPES},
+};
-LogChannelDWARF::~LogChannelDWARF() {}
+Log::Channel LogChannelDWARF::g_channel(g_categories, DWARF_LOG_DEFAULT);
void LogChannelDWARF::Initialize() {
- PluginManager::RegisterPlugin(GetPluginNameStatic(),
- GetPluginDescriptionStatic(),
- LogChannelDWARF::CreateInstance);
-}
-
-void LogChannelDWARF::Terminate() {
- PluginManager::UnregisterPlugin(LogChannelDWARF::CreateInstance);
-}
-
-LogChannel *LogChannelDWARF::CreateInstance() { return new LogChannelDWARF(); }
-
-lldb_private::ConstString LogChannelDWARF::GetPluginNameStatic() {
- return SymbolFileDWARF::GetPluginNameStatic();
-}
-
-const char *LogChannelDWARF::GetPluginDescriptionStatic() {
- return "DWARF log channel for debugging plug-in issues.";
-}
-
-lldb_private::ConstString LogChannelDWARF::GetPluginName() {
- return GetPluginNameStatic();
-}
-
-uint32_t LogChannelDWARF::GetPluginVersion() { return 1; }
-
-void LogChannelDWARF::Delete() { g_log_channel = NULL; }
-
-void LogChannelDWARF::Disable(const char **categories, Stream *feedback_strm) {
- if (m_log_ap.get() == NULL)
- return;
-
- uint32_t flag_bits = m_log_ap->GetMask().Get();
- for (size_t i = 0; categories[i] != NULL; ++i) {
- const char *arg = categories[i];
-
- if (::strcasecmp(arg, "all") == 0)
- flag_bits &= ~DWARF_LOG_ALL;
- else if (::strcasecmp(arg, "info") == 0)
- flag_bits &= ~DWARF_LOG_DEBUG_INFO;
- else if (::strcasecmp(arg, "line") == 0)
- flag_bits &= ~DWARF_LOG_DEBUG_LINE;
- else if (::strcasecmp(arg, "pubnames") == 0)
- flag_bits &= ~DWARF_LOG_DEBUG_PUBNAMES;
- else if (::strcasecmp(arg, "pubtypes") == 0)
- flag_bits &= ~DWARF_LOG_DEBUG_PUBTYPES;
- else if (::strcasecmp(arg, "aranges") == 0)
- flag_bits &= ~DWARF_LOG_DEBUG_ARANGES;
- else if (::strcasecmp(arg, "lookups") == 0)
- flag_bits &= ~DWARF_LOG_LOOKUPS;
- else if (::strcasecmp(arg, "map") == 0)
- flag_bits &= ~DWARF_LOG_DEBUG_MAP;
- else if (::strcasecmp(arg, "default") == 0)
- flag_bits &= ~DWARF_LOG_DEFAULT;
- else if (::strcasecmp(arg, "verbose") == 0)
- flag_bits &= ~DWARF_LOG_VERBOSE;
- else if (::strncasecmp(arg, "comp", 4) == 0)
- flag_bits &= ~DWARF_LOG_TYPE_COMPLETION;
- else {
- feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
- ListCategories(feedback_strm);
- }
- }
-
- if (flag_bits == 0)
- Delete();
- else
- m_log_ap->GetMask().Reset(flag_bits);
-
- return;
-}
-
-bool LogChannelDWARF::Enable(
- StreamSP &log_stream_sp, uint32_t log_options,
- Stream *feedback_strm, // Feedback stream for argument errors etc
- const char **categories // The categories to enable within this logging
- // stream, if empty, enable default set
- ) {
- Delete();
-
- if (m_log_ap)
- m_log_ap->SetStream(log_stream_sp);
- else
- m_log_ap.reset(new Log(log_stream_sp));
-
- g_log_channel = this;
- uint32_t flag_bits = 0;
- bool got_unknown_category = false;
- for (size_t i = 0; categories[i] != NULL; ++i) {
- const char *arg = categories[i];
-
- if (::strcasecmp(arg, "all") == 0)
- flag_bits |= DWARF_LOG_ALL;
- else if (::strcasecmp(arg, "info") == 0)
- flag_bits |= DWARF_LOG_DEBUG_INFO;
- else if (::strcasecmp(arg, "line") == 0)
- flag_bits |= DWARF_LOG_DEBUG_LINE;
- else if (::strcasecmp(arg, "pubnames") == 0)
- flag_bits |= DWARF_LOG_DEBUG_PUBNAMES;
- else if (::strcasecmp(arg, "pubtypes") == 0)
- flag_bits |= DWARF_LOG_DEBUG_PUBTYPES;
- else if (::strcasecmp(arg, "aranges") == 0)
- flag_bits |= DWARF_LOG_DEBUG_ARANGES;
- else if (::strcasecmp(arg, "lookups") == 0)
- flag_bits |= DWARF_LOG_LOOKUPS;
- else if (::strcasecmp(arg, "map") == 0)
- flag_bits |= DWARF_LOG_DEBUG_MAP;
- else if (::strcasecmp(arg, "default") == 0)
- flag_bits |= DWARF_LOG_DEFAULT;
- else if (::strcasecmp(arg, "verbose") == 0)
- flag_bits |= DWARF_LOG_VERBOSE;
- else if (::strncasecmp(arg, "comp", 4) == 0)
- flag_bits |= DWARF_LOG_TYPE_COMPLETION;
- else {
- feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
- if (got_unknown_category == false) {
- got_unknown_category = true;
- ListCategories(feedback_strm);
- }
- }
- }
- if (flag_bits == 0)
- flag_bits = DWARF_LOG_DEFAULT;
- m_log_ap->GetMask().Reset(flag_bits);
- m_log_ap->GetOptions().Reset(log_options);
- return m_log_ap.get() != NULL;
-}
-
-void LogChannelDWARF::ListCategories(Stream *strm) {
- strm->Printf(
- "Logging categories for '%s':\n"
- " all - turn on all available logging categories\n"
- " info - log the parsing of .debug_info\n"
- " line - log the parsing of .debug_line\n"
- " pubnames - log the parsing of .debug_pubnames\n"
- " pubtypes - log the parsing of .debug_pubtypes\n"
- " aranges - log the parsing of .debug_aranges\n"
- " lookups - log any lookups that happen by name, regex, or address\n"
- " completion - log struct/unions/class type completions\n"
- " map - log insertions of object files into DWARF debug maps\n",
- SymbolFileDWARF::GetPluginNameStatic().GetCString());
+ Log::Register("dwarf", g_channel);
}
-Log *LogChannelDWARF::GetLog() {
- if (g_log_channel)
- return g_log_channel->m_log_ap.get();
-
- return NULL;
-}
-
-Log *LogChannelDWARF::GetLogIfAll(uint32_t mask) {
- if (g_log_channel && g_log_channel->m_log_ap.get()) {
- if (g_log_channel->m_log_ap->GetMask().AllSet(mask))
- return g_log_channel->m_log_ap.get();
- }
- return NULL;
-}
-
-Log *LogChannelDWARF::GetLogIfAny(uint32_t mask) {
- if (g_log_channel && g_log_channel->m_log_ap.get()) {
- if (g_log_channel->m_log_ap->GetMask().AnySet(mask))
- return g_log_channel->m_log_ap.get();
- }
- return NULL;
-}
-
-void LogChannelDWARF::LogIf(uint32_t mask, const char *format, ...) {
- if (g_log_channel) {
- Log *log = g_log_channel->m_log_ap.get();
- if (log && log->GetMask().AnySet(mask)) {
- va_list args;
- va_start(args, format);
- log->VAPrintf(format, args);
- va_end(args);
- }
- }
-}
+void LogChannelDWARF::Terminate() { Log::Unregister("dwarf"); }
diff --git a/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h b/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h
index 4802f858f3a1..0293fbd7c495 100644
--- a/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h
+++ b/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h
@@ -14,9 +14,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Log.h"
+#include "lldb/Utility/Log.h"
-#define DWARF_LOG_VERBOSE (1u << 0)
#define DWARF_LOG_DEBUG_INFO (1u << 1)
#define DWARF_LOG_DEBUG_LINE (1u << 2)
#define DWARF_LOG_DEBUG_PUBNAMES (1u << 3)
@@ -28,47 +27,17 @@
#define DWARF_LOG_ALL (UINT32_MAX)
#define DWARF_LOG_DEFAULT (DWARF_LOG_DEBUG_INFO)
-class LogChannelDWARF : public lldb_private::LogChannel {
-public:
- LogChannelDWARF();
-
- ~LogChannelDWARF() override;
+namespace lldb_private {
+class LogChannelDWARF {
+ static Log::Channel g_channel;
+public:
static void Initialize();
-
static void Terminate();
- static lldb_private::ConstString GetPluginNameStatic();
-
- static const char *GetPluginDescriptionStatic();
-
- static lldb_private::LogChannel *CreateInstance();
-
- lldb_private::ConstString GetPluginName() override;
-
- uint32_t GetPluginVersion() override;
-
- void Disable(const char **categories,
- lldb_private::Stream *feedback_strm) override;
-
- void Delete();
-
- bool Enable(lldb::StreamSP &log_stream_sp, uint32_t log_options,
- lldb_private::Stream
- *feedback_strm, // Feedback stream for argument errors etc
- const char **categories) override; // The categories to enable
- // within this logging stream,
- // if empty, enable default set
-
- void ListCategories(lldb_private::Stream *strm) override;
-
- static lldb_private::Log *GetLog();
-
- static lldb_private::Log *GetLogIfAll(uint32_t mask);
-
- static lldb_private::Log *GetLogIfAny(uint32_t mask);
-
- static void LogIf(uint32_t mask, const char *format, ...);
+ static Log *GetLogIfAll(uint32_t mask) { return g_channel.GetLogIfAll(mask); }
+ static Log *GetLogIfAny(uint32_t mask) { return g_channel.GetLogIfAny(mask); }
};
+}
#endif // SymbolFileDWARF_LogChannelDWARF_h_
diff --git a/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp b/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
index c3d90d171b79..f5f979caa38e 100644
--- a/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
+++ b/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
@@ -8,11 +8,11 @@
//===----------------------------------------------------------------------===//
#include "NameToDIE.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/RegularExpression.h"
-#include "lldb/Core/Stream.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StreamString.h"
#include "DWARFCompileUnit.h"
#include "DWARFDebugInfo.h"
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 5c44ee03b02c..856c371636d9 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -11,19 +11,20 @@
// Other libraries and framework includes
#include "llvm/Support/Casting.h"
+#include "llvm/Support/Threading.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
#include "lldb/Core/Value.h"
+#include "lldb/Utility/RegularExpression.h"
+#include "lldb/Utility/StreamString.h"
#include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h"
@@ -71,6 +72,8 @@
#include "SymbolFileDWARFDebugMap.h"
#include "SymbolFileDWARFDwo.h"
+#include "llvm/Support/FileSystem.h"
+
#include <map>
#include <ctype.h>
@@ -190,7 +193,9 @@ static const char *resolveCompDir(const char *path_from_dwarf) {
if (!is_symlink)
return local_path;
- if (!local_path_spec.IsSymbolicLink())
+ namespace fs = llvm::sys::fs;
+ if (fs::get_file_type(local_path_spec.GetPath(), false) !=
+ fs::file_type::symlink_file)
return local_path;
FileSpec resolved_local_path_spec;
@@ -222,7 +227,7 @@ void SymbolFileDWARF::DebuggerInitialize(Debugger &debugger) {
void SymbolFileDWARF::Terminate() {
PluginManager::UnregisterPlugin(CreateInstance);
- LogChannelDWARF::Initialize();
+ LogChannelDWARF::Terminate();
}
lldb_private::ConstString SymbolFileDWARF::GetPluginNameStatic() {
@@ -553,8 +558,9 @@ uint32_t SymbolFileDWARF::CalculateAbilities() {
const DWARFDataExtractor &
SymbolFileDWARF::GetCachedSectionData(lldb::SectionType sect_type,
DWARFDataSegment &data_segment) {
- std::call_once(data_segment.m_flag, &SymbolFileDWARF::LoadSectionData, this,
- sect_type, std::ref(data_segment.m_data));
+ llvm::call_once(data_segment.m_flag, [this, sect_type, &data_segment] {
+ this->LoadSectionData(sect_type, std::ref(data_segment.m_data));
+ });
return data_segment.m_data;
}
@@ -1935,7 +1941,7 @@ void SymbolFileDWARF::Index() {
std::vector<NameToDIE> namespace_index(num_compile_units);
std::vector<bool> clear_cu_dies(num_compile_units, false);
- auto parser_fn = [this, debug_info, &function_basename_index,
+ auto parser_fn = [debug_info, &function_basename_index,
&function_fullname_index, &function_method_index,
&function_selector_index, &objc_class_selectors_index,
&global_index, &type_index,
@@ -1951,7 +1957,7 @@ void SymbolFileDWARF::Index() {
return cu_idx;
};
- auto extract_fn = [this, debug_info, num_compile_units](uint32_t cu_idx) {
+ auto extract_fn = [debug_info](uint32_t cu_idx) {
DWARFCompileUnit *dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
if (dwarf_cu) {
// dwarf_cu->ExtractDIEsIfNeeded(false) will return zero if the
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 52937697500f..14b29fa44fa3 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -21,9 +21,10 @@
// Other libraries and framework includes
#include "llvm/ADT/DenseMap.h"
+#include "llvm/Support/Threading.h"
+
+#include "lldb/Utility/Flags.h"
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Flags.h"
#include "lldb/Core/RangeMap.h"
#include "lldb/Core/UniqueCStringMap.h"
#include "lldb/Core/dwarf.h"
@@ -31,6 +32,7 @@
#include "lldb/Symbol/DebugMacros.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/SymbolFile.h"
+#include "lldb/Utility/ConstString.h"
#include "lldb/lldb-private.h"
// Project includes
@@ -305,7 +307,7 @@ protected:
typedef llvm::DenseMap<lldb::opaque_compiler_type_t, DIERef> ClangTypeToDIE;
struct DWARFDataSegment {
- std::once_flag m_flag;
+ llvm::once_flag m_flag;
lldb_private::DWARFDataExtractor m_data;
};
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index 16bb578e99c2..45519663f71f 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -19,9 +19,9 @@
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RangeMap.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Section.h"
#include "lldb/Host/FileSystem.h"
+#include "lldb/Utility/RegularExpression.h"
//#define DEBUG_OSO_DMAP // DO NOT CHECKIN WITH THIS NOT COMMENTED OUT
#if defined(DEBUG_OSO_DMAP)
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
index 109da631d771..dcca4268b6eb 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -11,6 +11,7 @@
#define SymbolFileDWARF_SymbolFileDWARFDebugMap_h_
#include <bitset>
+#include <map>
#include <vector>
#include "lldb/Core/RangeMap.h"
diff --git a/source/Plugins/SymbolFile/PDB/CMakeLists.txt b/source/Plugins/SymbolFile/PDB/CMakeLists.txt
index 55aaadaf191b..871f382298d6 100644
--- a/source/Plugins/SymbolFile/PDB/CMakeLists.txt
+++ b/source/Plugins/SymbolFile/PDB/CMakeLists.txt
@@ -1,7 +1,14 @@
-set(LLVM_LINK_COMPONENTS
- DebugInfoPDB)
-
-add_lldb_library(lldbPluginSymbolFilePDB
+add_lldb_library(lldbPluginSymbolFilePDB PLUGIN
PDBASTParser.cpp
SymbolFilePDB.cpp
+
+ LINK_LIBS
+ clangAST
+ clangLex
+ lldbCore
+ lldbSymbol
+ lldbUtility
+ LINK_COMPONENTS
+ DebugInfoPDB
+ Support
)
diff --git a/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index cd99493c239a..5e713224fcf8 100644
--- a/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -125,9 +125,8 @@ uint32_t SymbolFilePDB::GetNumCompileUnits() {
m_cached_compile_unit_count = compilands->getChildCount();
// The linker can inject an additional "dummy" compilation unit into the
- // PDB.
- // Ignore this special compile unit for our purposes, if it is there. It is
- // always the last one.
+ // PDB. Ignore this special compile unit for our purposes, if it is there.
+ // It is always the last one.
auto last_cu = compilands->getChildAtIndex(m_cached_compile_unit_count - 1);
std::string name = last_cu->getName();
if (name == "* Linker *")
@@ -187,12 +186,10 @@ bool SymbolFilePDB::ParseCompileUnitSupportFiles(
return false;
// In theory this is unnecessary work for us, because all of this information
- // is easily
- // (and quickly) accessible from DebugInfoPDB, so caching it a second time
- // seems like a waste.
- // Unfortunately, there's no good way around this short of a moderate
- // refactor, since SymbolVendor
- // depends on being able to cache this list.
+ // is easily (and quickly) accessible from DebugInfoPDB, so caching it a
+ // second time seems like a waste. Unfortunately, there's no good way around
+ // this short of a moderate refactor since SymbolVendor depends on being able
+ // to cache this list.
auto cu = m_session_up->getConcreteSymbolById<PDBSymbolCompiland>(
sc.comp_unit->GetID());
if (!cu)
@@ -269,9 +266,8 @@ lldb_private::CompilerDecl SymbolFilePDB::GetDeclForUID(lldb::user_id_t uid) {
lldb_private::CompilerDeclContext
SymbolFilePDB::GetDeclContextForUID(lldb::user_id_t uid) {
// PDB always uses the translation unit decl context for everything. We can
- // improve this later
- // but it's not easy because PDB doesn't provide a high enough level of type
- // fidelity in this area.
+ // improve this later but it's not easy because PDB doesn't provide a high
+ // enough level of type fidelity in this area.
return *m_tu_decl_ctx_up;
}
@@ -295,30 +291,25 @@ uint32_t SymbolFilePDB::ResolveSymbolContext(
uint32_t resolve_scope, lldb_private::SymbolContextList &sc_list) {
if (resolve_scope & lldb::eSymbolContextCompUnit) {
// Locate all compilation units with line numbers referencing the specified
- // file. For example, if
- // `file_spec` is <vector>, then this should return all source files and
- // header files that reference
- // <vector>, either directly or indirectly.
+ // file. For example, if `file_spec` is <vector>, then this should return
+ // all source files and header files that reference <vector>, either
+ // directly or indirectly.
auto compilands = m_session_up->findCompilandsForSourceFile(
file_spec.GetPath(), PDB_NameSearchFlags::NS_CaseInsensitive);
- // For each one, either find get its previously parsed data, or parse it
- // afresh and add it to
- // the symbol context list.
+ // For each one, either find its previously parsed data or parse it afresh
+ // and add it to the symbol context list.
while (auto compiland = compilands->getNext()) {
// If we're not checking inlines, then don't add line information for this
- // file unless the FileSpec
- // matches.
+ // file unless the FileSpec matches.
if (!check_inlines) {
// `getSourceFileName` returns the basename of the original source file
- // used to generate this compiland.
- // It does not return the full path. Currently the only way to get that
- // is to do a basename lookup to
- // get the IPDBSourceFile, but this is ambiguous in the case of two
- // source files with the same name
- // contributing to the same compiland. This is a moderately extreme
- // edge case, so we consider this ok
- // for now, although we need to find a long term solution.
+ // used to generate this compiland. It does not return the full path.
+ // Currently the only way to get that is to do a basename lookup to get
+ // the IPDBSourceFile, but this is ambiguous in the case of two source
+ // files with the same name contributing to the same compiland. This is
+ // a moderately extreme edge case, so we consider this OK for now,
+ // although we need to find a long-term solution.
std::string source_file = compiland->getSourceFileName();
auto pdb_file = m_session_up->findOneSourceFile(
compiland.get(), source_file,
@@ -336,8 +327,7 @@ uint32_t SymbolFilePDB::ResolveSymbolContext(
sc_list.Append(sc);
// If we were asked to resolve line entries, add all entries to the line
- // table that match the requested
- // line (or all lines if `line` == 0)
+ // table that match the requested line (or all lines if `line` == 0).
if (resolve_scope & lldb::eSymbolContextLineEntry)
ParseCompileUnitLineTable(sc, line);
}
@@ -396,9 +386,8 @@ uint32_t SymbolFilePDB::FindTypes(
std::string name_str = name.AsCString();
// If this might be a regex, we have to return EVERY symbol and process them
- // one by one, which is going
- // to destroy performance on large PDB files. So try really hard not to use a
- // regex match.
+ // one by one, which is going to destroy performance on large PDB files. So
+ // try really hard not to use a regex match.
if (name_str.find_first_of("[]?*.-+\\") != std::string::npos)
FindTypesByRegex(name_str, max_matches, types);
else
@@ -410,14 +399,11 @@ void SymbolFilePDB::FindTypesByRegex(const std::string &regex,
uint32_t max_matches,
lldb_private::TypeMap &types) {
// When searching by regex, we need to go out of our way to limit the search
- // space as much as possible, since
- // the way this is implemented is by searching EVERYTHING in the PDB and
- // manually doing a regex compare. PDB
- // library isn't optimized for regex searches or searches across multiple
- // symbol types at the same time, so the
+ // space as much as possible since this searches EVERYTHING in the PDB,
+ // manually doing regex comparisons. PDB library isn't optimized for regex
+ // searches or searches across multiple symbol types at the same time, so the
// best we can do is to search enums, then typedefs, then classes one by one,
- // and do a regex compare against all
- // of them.
+ // and do a regex comparison against each of them.
PDB_SymType tags_to_search[] = {PDB_SymType::Enum, PDB_SymType::Typedef,
PDB_SymType::UDT};
auto global = m_session_up->getGlobalScope();
@@ -442,9 +428,8 @@ void SymbolFilePDB::FindTypesByRegex(const std::string &regex,
else if (auto class_type = llvm::dyn_cast<PDBSymbolTypeUDT>(result.get()))
type_name = class_type->getName();
else {
- // We're only looking for types that have names. Skip symbols, as well
- // as
- // unnamed types such as arrays, pointers, etc.
+ // We're looking only for types that have names. Skip symbols, as well
+ // as unnamed types such as arrays, pointers, etc.
continue;
}
@@ -484,7 +469,7 @@ void SymbolFilePDB::FindTypesByName(const std::string &name,
case PDB_SymType::Typedef:
break;
default:
- // We're only looking for types that have names. Skip symbols, as well as
+ // We're looking only for types that have names. Skip symbols, as well as
// unnamed types such as arrays, pointers, etc.
continue;
}
@@ -553,14 +538,12 @@ lldb::CompUnitSP SymbolFilePDB::ParseCompileUnitForSymIndex(uint32_t id) {
auto cu = m_session_up->getConcreteSymbolById<PDBSymbolCompiland>(id);
// `getSourceFileName` returns the basename of the original source file used
- // to generate this compiland. It does
- // not return the full path. Currently the only way to get that is to do a
- // basename lookup to get the
+ // to generate this compiland. It does not return the full path. Currently
+ // the only way to get that is to do a basename lookup to get the
// IPDBSourceFile, but this is ambiguous in the case of two source files with
- // the same name contributing to the
- // same compiland. This is a moderately extreme edge case, so we consider this
- // ok for now, although we need to find
- // a long term solution.
+ // the same name contributing to the same compiland. This is a moderately
+ // extreme edge case, so we consider this OK for now, although we need to find
+ // a long-term solution.
auto file =
m_session_up->findOneSourceFile(cu.get(), cu->getSourceFileName(),
PDB_NameSearchFlags::NS_CaseInsensitive);
@@ -589,12 +572,9 @@ bool SymbolFilePDB::ParseCompileUnitLineTable(
sc.comp_unit->GetID());
// LineEntry needs the *index* of the file into the list of support files
- // returned by
- // ParseCompileUnitSupportFiles. But the underlying SDK gives us a globally
- // unique
- // idenfitifier in the namespace of the PDB. So, we have to do a mapping so
- // that we
- // can hand out indices.
+ // returned by ParseCompileUnitSupportFiles. But the underlying SDK gives us
+ // a globally unique idenfitifier in the namespace of the PDB. So, we have to
+ // do a mapping so that we can hand out indices.
llvm::DenseMap<uint32_t, uint32_t> index_map;
BuildSupportFileIdToSupportFileIndexMap(*cu, index_map);
auto line_table = llvm::make_unique<LineTable>(sc.comp_unit);
@@ -604,8 +584,7 @@ bool SymbolFilePDB::ParseCompileUnitLineTable(
auto files = m_session_up->getSourceFilesForCompiland(*cu);
// For each source and header file, create a LineSequence for contributions to
- // the cu
- // from that file, and add the sequence.
+ // the cu from that file, and add the sequence.
while (auto file = files->getNext()) {
std::unique_ptr<LineSequence> sequence(
line_table->CreateLineSequenceContainer());
@@ -628,13 +607,12 @@ bool SymbolFilePDB::ParseCompileUnitLineTable(
uint32_t source_idx = index_map[source_id];
// There was a gap between the current entry and the previous entry if the
- // addresses don't perfectly line
- // up.
+ // addresses don't perfectly line up.
bool is_gap = (i > 0) && (prev_addr + prev_length < addr);
// Before inserting the current entry, insert a terminal entry at the end
- // of the previous entry's address
- // range if the current entry resulted in a gap from the previous entry.
+ // of the previous entry's address range if the current entry resulted in
+ // a gap from the previous entry.
if (is_gap && ShouldAddLine(match_line, prev_line, prev_length)) {
line_table->AppendLineEntryToSequence(
sequence.get(), prev_addr + prev_length, prev_line, 0,
@@ -684,14 +662,10 @@ void SymbolFilePDB::BuildSupportFileIdToSupportFileIndexMap(
const PDBSymbolCompiland &cu,
llvm::DenseMap<uint32_t, uint32_t> &index_map) const {
// This is a hack, but we need to convert the source id into an index into the
- // support
- // files array. We don't want to do path comparisons to avoid basename / full
- // path
- // issues that may or may not even be a problem, so we use the globally unique
- // source
- // file identifiers. Ideally we could use the global identifiers everywhere,
- // but LineEntry
- // currently assumes indices.
+ // support files array. We don't want to do path comparisons to avoid
+ // basename / full path issues that may or may not even be a problem, so we
+ // use the globally unique source file identifiers. Ideally we could use the
+ // global identifiers everywhere, but LineEntry currently assumes indices.
auto source_files = m_session_up->getSourceFilesForCompiland(cu);
int index = 0;
diff --git a/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h b/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
index 2e5918328ff0..efd2cb081dca 100644
--- a/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
+++ b/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
@@ -10,8 +10,8 @@
#ifndef lldb_Plugins_SymbolFile_PDB_SymbolFilePDB_h_
#define lldb_Plugins_SymbolFile_PDB_SymbolFilePDB_h_
-#include "lldb/Core/UserID.h"
#include "lldb/Symbol/SymbolFile.h"
+#include "lldb/Utility/UserID.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/DebugInfo/PDB/IPDBSession.h"
diff --git a/source/Plugins/SymbolFile/Symtab/CMakeLists.txt b/source/Plugins/SymbolFile/Symtab/CMakeLists.txt
index 20e406b08ab2..a2e19bd283f1 100644
--- a/source/Plugins/SymbolFile/Symtab/CMakeLists.txt
+++ b/source/Plugins/SymbolFile/Symtab/CMakeLists.txt
@@ -1,3 +1,7 @@
-add_lldb_library(lldbPluginSymbolFileSymtab
+add_lldb_library(lldbPluginSymbolFileSymtab PLUGIN
SymbolFileSymtab.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
)
diff --git a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
index 39073991c32c..094e48cf00e1 100644
--- a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
+++ b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
@@ -10,16 +10,15 @@
#include "SymbolFileSymtab.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Timer.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/Symtab.h"
#include "lldb/Symbol/TypeList.h"
+#include "lldb/Utility/RegularExpression.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
index 1945af9a337e..d1887a707ea6 100644
--- a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
+++ b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
@@ -12,6 +12,7 @@
// C Includes
// C++ Includes
+#include <map>
#include <vector>
// Other libraries and framework includes
diff --git a/source/Plugins/SymbolVendor/ELF/CMakeLists.txt b/source/Plugins/SymbolVendor/ELF/CMakeLists.txt
index cffc2ef74597..e742fac93129 100644
--- a/source/Plugins/SymbolVendor/ELF/CMakeLists.txt
+++ b/source/Plugins/SymbolVendor/ELF/CMakeLists.txt
@@ -1,3 +1,8 @@
-add_lldb_library(lldbPluginSymbolVendorELF
+add_lldb_library(lldbPluginSymbolVendorELF PLUGIN
SymbolVendorELF.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbSymbol
)
diff --git a/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp b/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
index 4934a80c09ee..363fba2b0bba 100644
--- a/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
+++ b/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
@@ -15,11 +15,11 @@
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/Symbols.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt b/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt
index 093766ac07d5..bbcdff9705af 100644
--- a/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt
+++ b/source/Plugins/SymbolVendor/MacOSX/CMakeLists.txt
@@ -1,5 +1,10 @@
include_directories(${LIBXML2_INCLUDE_DIR})
-add_lldb_library(lldbPluginSymbolVendorMacOSX
+add_lldb_library(lldbPluginSymbolVendorMacOSX PLUGIN
SymbolVendorMacOSX.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ lldbSymbol
)
diff --git a/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp b/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
index 5e1953e03208..259912e4c36e 100644
--- a/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
+++ b/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
@@ -15,12 +15,12 @@
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Timer.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/Symbols.h"
#include "lldb/Host/XML.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp b/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
index dcc532db2021..ff96267b8831 100644
--- a/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
+++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.cpp
@@ -15,10 +15,7 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Value.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
@@ -29,6 +26,9 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h b/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h
index c0581576bbf1..db05a19cf9ec 100644
--- a/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h
+++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetItemInfoHandler.h
@@ -18,9 +18,9 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Error.h"
#include "lldb/Expression/UtilityFunction.h"
#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-public.h"
// This class will insert a UtilityFunction into the inferior process for
diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp b/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
index fc91ba47ba18..911a07f5d738 100644
--- a/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
+++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.cpp
@@ -15,10 +15,7 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Value.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
@@ -29,6 +26,9 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h b/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h
index 824619f5cfe0..95e19625ff80 100644
--- a/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h
+++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetPendingItemsHandler.h
@@ -19,8 +19,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Error.h"
#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-public.h"
// This class will insert a UtilityFunction into the inferior process for
diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp b/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
index ddc56d8feb3c..3de294f6e80e 100644
--- a/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
+++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.cpp
@@ -13,10 +13,7 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Value.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
@@ -27,6 +24,9 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h b/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h
index b3965667bb3e..3e20fbe08d2a 100644
--- a/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h
+++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetQueuesHandler.h
@@ -18,8 +18,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Error.h"
#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-public.h"
// This class will insert a UtilityFunction into the inferior process for
diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp b/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
index c05523e0f333..c3c0f4423c84 100644
--- a/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
+++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
@@ -15,10 +15,7 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/ConstString.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Core/Value.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/Expression.h"
@@ -31,6 +28,9 @@
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
#include "lldb/lldb-private.h"
using namespace lldb;
diff --git a/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h b/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h
index f7804de40899..53fdda2d5ca0 100644
--- a/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h
+++ b/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.h
@@ -19,8 +19,8 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/Core/Error.h"
#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Utility/Error.h"
#include "lldb/lldb-public.h"
// This class will insert a UtilityFunction into the inferior process for
diff --git a/source/Plugins/SystemRuntime/MacOSX/CMakeLists.txt b/source/Plugins/SystemRuntime/MacOSX/CMakeLists.txt
index d1580cce20d6..ac5781b98b09 100644
--- a/source/Plugins/SystemRuntime/MacOSX/CMakeLists.txt
+++ b/source/Plugins/SystemRuntime/MacOSX/CMakeLists.txt
@@ -1,7 +1,17 @@
-add_lldb_library(lldbPluginSystemRuntimeMacOSX
+add_lldb_library(lldbPluginSystemRuntimeMacOSX PLUGIN
AppleGetItemInfoHandler.cpp
AppleGetPendingItemsHandler.cpp
AppleGetQueuesHandler.cpp
AppleGetThreadItemInfoHandler.cpp
SystemRuntimeMacOSX.cpp
+
+ LINK_LIBS
+ lldbBreakpoint
+ lldbCore
+ lldbExpression
+ lldbHost
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ lldbPluginProcessUtility
)
diff --git a/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp b/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
index ec13dfa7fd78..394f05ca770a 100644
--- a/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
+++ b/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
@@ -9,24 +9,24 @@
#include "Plugins/Process/Utility/HistoryThread.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/Queue.h"
#include "lldb/Target/QueueList.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
-#include "lldb/Utility/ProcessStructReader.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
#include "SystemRuntimeMacOSX.h"
diff --git a/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h b/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h
index 2b98c084161d..56212b94521a 100644
--- a/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h
+++ b/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h
@@ -18,14 +18,14 @@
// Other libraries and framework include
// Project includes
-#include "lldb/Core/ConstString.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/StructuredData.h"
-#include "lldb/Core/UUID.h"
-#include "lldb/Host/FileSpec.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/QueueItem.h"
#include "lldb/Target/SystemRuntime.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
#include "AppleGetItemInfoHandler.h"
#include "AppleGetPendingItemsHandler.h"
diff --git a/source/Plugins/UnwindAssembly/InstEmulation/CMakeLists.txt b/source/Plugins/UnwindAssembly/InstEmulation/CMakeLists.txt
index 21673160bf40..7b7fd721f850 100644
--- a/source/Plugins/UnwindAssembly/InstEmulation/CMakeLists.txt
+++ b/source/Plugins/UnwindAssembly/InstEmulation/CMakeLists.txt
@@ -1,3 +1,8 @@
-add_lldb_library(lldbPluginUnwindAssemblyInstEmulation
+add_lldb_library(lldbPluginUnwindAssemblyInstEmulation PLUGIN
UnwindAssemblyInstEmulation.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
+ lldbTarget
)
diff --git a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
index be770a38fba7..84e16991cce1 100644
--- a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
+++ b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
@@ -11,18 +11,19 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/DataBufferHeap.h"
-#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Disassembler.h"
-#include "lldb/Core/Error.h"
+#include "lldb/Core/DumpDataExtractor.h"
#include "lldb/Core/FormatEntity.h"
-#include "lldb/Core/Log.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/StreamString.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/DataBufferHeap.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Error.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
@@ -408,7 +409,8 @@ size_t UnwindAssemblyInstEmulation::WriteMemory(
StreamString strm;
strm.PutCString("UnwindAssemblyInstEmulation::WriteMemory (");
- data.Dump(&strm, 0, eFormatBytes, 1, dst_len, UINT32_MAX, addr, 0, 0);
+ DumpDataExtractor(data, &strm, 0, eFormatBytes, 1, dst_len, UINT32_MAX,
+ addr, 0, 0);
strm.PutCString(", context = ");
context.Dump(strm, instruction);
log->PutString(strm.GetString());
diff --git a/source/Plugins/UnwindAssembly/x86/CMakeLists.txt b/source/Plugins/UnwindAssembly/x86/CMakeLists.txt
index 024b0dab2e2b..425ae1190992 100644
--- a/source/Plugins/UnwindAssembly/x86/CMakeLists.txt
+++ b/source/Plugins/UnwindAssembly/x86/CMakeLists.txt
@@ -1,4 +1,14 @@
-add_lldb_library(lldbPluginUnwindAssemblyX86
+add_lldb_library(lldbPluginUnwindAssemblyX86 PLUGIN
UnwindAssembly-x86.cpp
x86AssemblyInspectionEngine.cpp
+
+ LINK_LIBS
+ lldbCore
+ lldbSymbol
+ lldbTarget
+ lldbUtility
+ LINK_COMPONENTS
+ Support
+ MC
+ MCDisassembler
)
diff --git a/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp b/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
index e298b856d395..e72097474097 100644
--- a/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
+++ b/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
@@ -16,17 +16,17 @@
#include "lldb/Core/Address.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/Error.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/RegisterNumber.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/UnwindAssembly.h"
-#include "lldb/Utility/RegisterNumber.h"
+#include "lldb/Utility/Error.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp b/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
index e731a5a02ab0..9aad2e1e70e2 100644
--- a/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
+++ b/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
@@ -979,11 +979,12 @@ bool x86AssemblyInspectionEngine::AugmentUnwindPlanFromCallSite(
offset += insn_len;
m_cur_insn = data + offset;
- if (reinstate_unwind_state) {
- // that was the last instruction of this function
- if (offset >= size)
- continue;
+ // offset is pointing beyond the bounds of the
+ // function; stop looping.
+ if (offset >= size)
+ continue;
+ if (reinstate_unwind_state) {
UnwindPlan::RowSP new_row(new UnwindPlan::Row());
*new_row = *original_last_row;
new_row->SetOffset(offset);
diff --git a/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h b/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h
index 0294f5a0c282..1c84c89aee83 100644
--- a/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h
+++ b/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h
@@ -17,7 +17,7 @@
#include "lldb/lldb-private.h"
#include "lldb/Core/ArchSpec.h"
-#include "lldb/Core/ConstString.h"
+#include "lldb/Utility/ConstString.h"
#include <map>
#include <vector>